@cogcoin/client 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +2 -2
  2. package/dist/bitcoind/indexer-daemon.d.ts +3 -7
  3. package/dist/bitcoind/indexer-daemon.js +39 -204
  4. package/dist/bitcoind/managed-runtime/bitcoind-policy.d.ts +16 -0
  5. package/dist/bitcoind/managed-runtime/bitcoind-policy.js +177 -0
  6. package/dist/bitcoind/managed-runtime/bitcoind-runtime.d.ts +20 -0
  7. package/dist/bitcoind/managed-runtime/bitcoind-runtime.js +74 -0
  8. package/dist/bitcoind/managed-runtime/bitcoind-status.d.ts +11 -0
  9. package/dist/bitcoind/managed-runtime/bitcoind-status.js +44 -0
  10. package/dist/bitcoind/managed-runtime/indexer-policy.d.ts +34 -0
  11. package/dist/bitcoind/managed-runtime/indexer-policy.js +200 -0
  12. package/dist/bitcoind/managed-runtime/indexer-runtime.d.ts +15 -0
  13. package/dist/bitcoind/managed-runtime/indexer-runtime.js +82 -0
  14. package/dist/bitcoind/managed-runtime/status.d.ts +11 -0
  15. package/dist/bitcoind/managed-runtime/status.js +59 -0
  16. package/dist/bitcoind/managed-runtime/types.d.ts +77 -0
  17. package/dist/bitcoind/node.d.ts +2 -2
  18. package/dist/bitcoind/node.js +2 -2
  19. package/dist/bitcoind/rpc.d.ts +2 -1
  20. package/dist/bitcoind/rpc.js +53 -3
  21. package/dist/bitcoind/service.d.ts +2 -7
  22. package/dist/bitcoind/service.js +79 -207
  23. package/dist/cli/command-registry.d.ts +1 -1
  24. package/dist/cli/command-registry.js +2 -64
  25. package/dist/cli/commands/client-admin.js +3 -18
  26. package/dist/cli/commands/mining-runtime.js +4 -60
  27. package/dist/cli/commands/wallet-admin.js +6 -6
  28. package/dist/cli/context.js +1 -3
  29. package/dist/cli/mining-json.d.ts +1 -22
  30. package/dist/cli/mining-json.js +0 -23
  31. package/dist/cli/output.js +16 -2
  32. package/dist/cli/parse.js +0 -2
  33. package/dist/cli/preview-json.d.ts +1 -22
  34. package/dist/cli/preview-json.js +0 -19
  35. package/dist/cli/types.d.ts +1 -3
  36. package/dist/cli/wallet-format.js +1 -1
  37. package/dist/cli/workflow-hints.d.ts +1 -2
  38. package/dist/cli/workflow-hints.js +5 -8
  39. package/dist/wallet/lifecycle/access.d.ts +5 -0
  40. package/dist/wallet/lifecycle/access.js +79 -0
  41. package/dist/wallet/lifecycle/context.d.ts +26 -0
  42. package/dist/wallet/lifecycle/context.js +57 -0
  43. package/dist/wallet/lifecycle/managed-core.d.ts +1 -9
  44. package/dist/wallet/lifecycle/managed-core.js +3 -63
  45. package/dist/wallet/lifecycle/repair-bitcoind.d.ts +10 -0
  46. package/dist/wallet/lifecycle/repair-bitcoind.js +142 -0
  47. package/dist/wallet/lifecycle/repair-indexer.d.ts +8 -0
  48. package/dist/wallet/lifecycle/repair-indexer.js +117 -0
  49. package/dist/wallet/lifecycle/repair-mining.d.ts +1 -5
  50. package/dist/wallet/lifecycle/repair-mining.js +5 -39
  51. package/dist/wallet/lifecycle/repair.d.ts +2 -4
  52. package/dist/wallet/lifecycle/repair.js +74 -318
  53. package/dist/wallet/lifecycle/setup-prompts.d.ts +7 -0
  54. package/dist/wallet/lifecycle/setup-prompts.js +88 -0
  55. package/dist/wallet/lifecycle/setup-state.d.ts +26 -0
  56. package/dist/wallet/lifecycle/setup-state.js +159 -0
  57. package/dist/wallet/lifecycle/setup.d.ts +3 -4
  58. package/dist/wallet/lifecycle/setup.js +47 -351
  59. package/dist/wallet/lifecycle/types.d.ts +33 -5
  60. package/dist/wallet/managed-core-wallet.d.ts +2 -0
  61. package/dist/wallet/managed-core-wallet.js +27 -1
  62. package/dist/wallet/mining/candidate.d.ts +1 -0
  63. package/dist/wallet/mining/candidate.js +38 -6
  64. package/dist/wallet/mining/competitiveness.d.ts +1 -0
  65. package/dist/wallet/mining/competitiveness.js +6 -0
  66. package/dist/wallet/mining/cycle.d.ts +2 -0
  67. package/dist/wallet/mining/cycle.js +14 -4
  68. package/dist/wallet/mining/engine-types.d.ts +1 -0
  69. package/dist/wallet/mining/index.d.ts +1 -1
  70. package/dist/wallet/mining/index.js +1 -1
  71. package/dist/wallet/mining/publish.d.ts +3 -0
  72. package/dist/wallet/mining/publish.js +78 -6
  73. package/dist/wallet/mining/runner.d.ts +0 -32
  74. package/dist/wallet/mining/runner.js +59 -104
  75. package/dist/wallet/mining/stop.d.ts +7 -0
  76. package/dist/wallet/mining/stop.js +23 -0
  77. package/dist/wallet/mining/supervisor.d.ts +2 -36
  78. package/dist/wallet/mining/supervisor.js +139 -246
  79. package/dist/wallet/read/context.d.ts +1 -5
  80. package/dist/wallet/read/context.js +20 -379
  81. package/dist/wallet/read/managed-services.d.ts +33 -0
  82. package/dist/wallet/read/managed-services.js +222 -0
  83. package/dist/wallet/state/client-password/bootstrap.d.ts +2 -0
  84. package/dist/wallet/state/client-password/bootstrap.js +3 -0
  85. package/dist/wallet/state/client-password/context.d.ts +10 -0
  86. package/dist/wallet/state/client-password/context.js +46 -0
  87. package/dist/wallet/state/client-password/crypto.d.ts +34 -0
  88. package/dist/wallet/state/client-password/crypto.js +117 -0
  89. package/dist/wallet/state/client-password/files.d.ts +10 -0
  90. package/dist/wallet/state/client-password/files.js +109 -0
  91. package/dist/wallet/state/client-password/legacy-cleanup.d.ts +11 -0
  92. package/dist/wallet/state/client-password/legacy-cleanup.js +338 -0
  93. package/dist/wallet/state/client-password/messages.d.ts +3 -0
  94. package/dist/wallet/state/client-password/messages.js +9 -0
  95. package/dist/wallet/state/client-password/migration.d.ts +4 -0
  96. package/dist/wallet/state/client-password/migration.js +32 -0
  97. package/dist/wallet/state/client-password/prompts.d.ts +12 -0
  98. package/dist/wallet/state/client-password/prompts.js +79 -0
  99. package/dist/wallet/state/client-password/protected-secrets.d.ts +13 -0
  100. package/dist/wallet/state/client-password/protected-secrets.js +90 -0
  101. package/dist/wallet/state/client-password/readiness.d.ts +4 -0
  102. package/dist/wallet/state/client-password/readiness.js +48 -0
  103. package/dist/wallet/state/client-password/references.d.ts +1 -0
  104. package/dist/wallet/state/client-password/references.js +56 -0
  105. package/dist/wallet/state/client-password/rotation.d.ts +6 -0
  106. package/dist/wallet/state/client-password/rotation.js +98 -0
  107. package/dist/wallet/state/client-password/session-policy.d.ts +6 -0
  108. package/dist/wallet/state/client-password/session-policy.js +28 -0
  109. package/dist/wallet/state/client-password/session.d.ts +19 -0
  110. package/dist/wallet/state/client-password/session.js +170 -0
  111. package/dist/wallet/state/client-password/setup.d.ts +8 -0
  112. package/dist/wallet/state/client-password/setup.js +49 -0
  113. package/dist/wallet/state/client-password/types.d.ts +82 -0
  114. package/dist/wallet/state/client-password/types.js +5 -0
  115. package/dist/wallet/state/client-password.d.ts +7 -38
  116. package/dist/wallet/state/client-password.js +52 -937
  117. package/dist/wallet/tx/anchor.js +123 -216
  118. package/dist/wallet/tx/cog.js +294 -489
  119. package/dist/wallet/tx/common.d.ts +2 -0
  120. package/dist/wallet/tx/common.js +2 -0
  121. package/dist/wallet/tx/domain-admin.js +111 -220
  122. package/dist/wallet/tx/domain-market.js +401 -681
  123. package/dist/wallet/tx/executor.d.ts +176 -0
  124. package/dist/wallet/tx/executor.js +302 -0
  125. package/dist/wallet/tx/field.js +109 -215
  126. package/dist/wallet/tx/register.js +158 -269
  127. package/dist/wallet/tx/reputation.js +120 -227
  128. package/package.json +1 -1
  129. package/dist/wallet/mining/worker-main.js +0 -17
  130. package/dist/wallet/state/client-password-agent.d.ts +0 -1
  131. package/dist/wallet/state/client-password-agent.js +0 -211
  132. /package/dist/{wallet/mining/worker-main.d.ts → bitcoind/managed-runtime/types.js} +0 -0
@@ -0,0 +1,142 @@
1
+ import { normalizeWalletDescriptorState } from "../descriptor-normalization.js";
2
+ import { acquireFileLock } from "../fs/lock.js";
3
+ import { persistWalletCoinControlStateIfNeeded } from "../coin-control.js";
4
+ import { createWalletSecretReference } from "../state/provider.js";
5
+ import { recreateManagedCoreWalletReplica, verifyManagedCoreWalletReplica } from "./managed-core.js";
6
+ import { pathExists } from "./context.js";
7
+ import { clearManagedBitcoindArtifacts, mapBitcoindCompatibilityToRepairIssue, mapBitcoindRepairHealth, waitForProcessExit, } from "./repair-runtime.js";
8
+ export async function repairManagedBitcoindStage(options) {
9
+ let state = options.state;
10
+ let repairStateNeedsPersist = options.repairStateNeedsPersist;
11
+ let bitcoindServiceAction = "none";
12
+ let bitcoindCompatibilityIssue = "none";
13
+ let managedCoreReplicaAction = "none";
14
+ let recreatedManagedCoreWallet = false;
15
+ let initialBitcoindProbe = {
16
+ compatibility: "unreachable",
17
+ status: null,
18
+ error: null,
19
+ };
20
+ let bitcoindPostRepairHealth = "unavailable";
21
+ const bitcoindLock = await acquireFileLock(options.servicePaths.bitcoindLockPath, {
22
+ purpose: "managed-bitcoind-repair",
23
+ walletRootId: state.walletRootId,
24
+ dataDir: options.context.dataDir,
25
+ });
26
+ try {
27
+ initialBitcoindProbe = await options.context.probeBitcoindService({
28
+ dataDir: options.context.dataDir,
29
+ chain: "main",
30
+ startHeight: 0,
31
+ walletRootId: state.walletRootId,
32
+ });
33
+ bitcoindCompatibilityIssue = mapBitcoindCompatibilityToRepairIssue(initialBitcoindProbe.compatibility);
34
+ if (initialBitcoindProbe.compatibility === "service-version-mismatch"
35
+ || initialBitcoindProbe.compatibility === "wallet-root-mismatch"
36
+ || initialBitcoindProbe.compatibility === "runtime-mismatch") {
37
+ const processId = initialBitcoindProbe.status?.processId ?? null;
38
+ if (processId === null) {
39
+ throw new Error("managed_bitcoind_process_id_unavailable");
40
+ }
41
+ try {
42
+ process.kill(processId, "SIGTERM");
43
+ }
44
+ catch (error) {
45
+ if (!(error instanceof Error) || !("code" in error) || error.code !== "ESRCH") {
46
+ throw error;
47
+ }
48
+ }
49
+ await waitForProcessExit(processId, 15_000, "managed_bitcoind_stop_timeout");
50
+ await clearManagedBitcoindArtifacts(options.servicePaths);
51
+ bitcoindServiceAction = "stopped-incompatible-service";
52
+ }
53
+ else if (initialBitcoindProbe.compatibility === "unreachable") {
54
+ const hasStaleArtifacts = await Promise.all([
55
+ options.servicePaths.bitcoindStatusPath,
56
+ options.servicePaths.bitcoindPidPath,
57
+ options.servicePaths.bitcoindReadyPath,
58
+ options.servicePaths.bitcoindWalletStatusPath,
59
+ ].map(pathExists));
60
+ if (hasStaleArtifacts.some(Boolean)) {
61
+ await clearManagedBitcoindArtifacts(options.servicePaths);
62
+ bitcoindServiceAction = "cleared-stale-artifacts";
63
+ }
64
+ }
65
+ else if (initialBitcoindProbe.compatibility === "protocol-error") {
66
+ throw new Error(initialBitcoindProbe.error ?? "managed_bitcoind_protocol_error");
67
+ }
68
+ }
69
+ finally {
70
+ await bitcoindLock.release();
71
+ }
72
+ const bitcoindHandle = await options.context.attachService({
73
+ dataDir: options.context.dataDir,
74
+ chain: "main",
75
+ startHeight: 0,
76
+ walletRootId: state.walletRootId,
77
+ });
78
+ try {
79
+ const rpc = options.context.rpcFactory(bitcoindHandle.rpc);
80
+ const normalizedDescriptorState = await normalizeWalletDescriptorState(state, rpc);
81
+ if (normalizedDescriptorState.changed) {
82
+ state = normalizedDescriptorState.state;
83
+ repairStateNeedsPersist = true;
84
+ }
85
+ const reconciledCoinControl = await persistWalletCoinControlStateIfNeeded({
86
+ state,
87
+ access: {
88
+ provider: options.context.provider,
89
+ secretReference: createWalletSecretReference(state.walletRootId),
90
+ },
91
+ paths: options.context.paths,
92
+ nowUnixMs: options.context.nowUnixMs,
93
+ replacePrimary: options.recoveredFromBackup && !repairStateNeedsPersist,
94
+ rpc,
95
+ });
96
+ state = reconciledCoinControl.state;
97
+ if (reconciledCoinControl.changed) {
98
+ repairStateNeedsPersist = false;
99
+ }
100
+ let replica = await verifyManagedCoreWalletReplica(state, options.context.dataDir, {
101
+ nodeHandle: bitcoindHandle,
102
+ attachService: options.context.attachService,
103
+ rpcFactory: options.context.rpcFactory,
104
+ });
105
+ if (replica.proofStatus !== "ready") {
106
+ state = await recreateManagedCoreWalletReplica(state, options.context.provider, options.context.paths, options.context.dataDir, options.context.nowUnixMs, {
107
+ attachService: options.context.attachService,
108
+ rpcFactory: options.context.rpcFactory,
109
+ });
110
+ recreatedManagedCoreWallet = true;
111
+ managedCoreReplicaAction = "recreated";
112
+ repairStateNeedsPersist = false;
113
+ replica = await verifyManagedCoreWalletReplica(state, options.context.dataDir, {
114
+ nodeHandle: bitcoindHandle,
115
+ attachService: options.context.attachService,
116
+ rpcFactory: options.context.rpcFactory,
117
+ });
118
+ }
119
+ const finalBitcoindStatus = await bitcoindHandle.refreshServiceStatus?.() ?? null;
120
+ const chainInfo = await rpc.getBlockchainInfo();
121
+ bitcoindPostRepairHealth = mapBitcoindRepairHealth({
122
+ serviceState: finalBitcoindStatus?.state ?? null,
123
+ catchingUp: chainInfo.blocks < chainInfo.headers,
124
+ replica,
125
+ });
126
+ if (bitcoindServiceAction === "none" && initialBitcoindProbe.compatibility === "unreachable") {
127
+ bitcoindServiceAction = "restarted-compatible-service";
128
+ }
129
+ }
130
+ finally {
131
+ await bitcoindHandle.stop?.().catch(() => undefined);
132
+ }
133
+ return {
134
+ state,
135
+ repairStateNeedsPersist,
136
+ recreatedManagedCoreWallet,
137
+ bitcoindServiceAction,
138
+ bitcoindCompatibilityIssue,
139
+ managedCoreReplicaAction,
140
+ bitcoindPostRepairHealth,
141
+ };
142
+ }
@@ -0,0 +1,8 @@
1
+ import type { ManagedServicePaths } from "../../bitcoind/service-paths.js";
2
+ import type { WalletStateV1 } from "../types.js";
3
+ import type { WalletIndexerRepairStageResult, WalletRepairContext } from "./types.js";
4
+ export declare function repairManagedIndexerStage(options: {
5
+ context: WalletRepairContext;
6
+ servicePaths: ManagedServicePaths;
7
+ state: WalletStateV1;
8
+ }): Promise<WalletIndexerRepairStageResult>;
@@ -0,0 +1,117 @@
1
+ import { acquireFileLock } from "../fs/lock.js";
2
+ import { pathExists } from "./context.js";
3
+ import { clearIndexerDaemonArtifacts, ensureIndexerDatabaseHealthy, mapIndexerCompatibilityToRepairIssue, verifyIndexerPostRepairHealth, waitForProcessExit, } from "./repair-runtime.js";
4
+ export async function repairManagedIndexerStage(options) {
5
+ let indexerDaemonAction = "none";
6
+ let indexerCompatibilityIssue = "none";
7
+ let initialIndexerDaemonInstanceId = null;
8
+ const indexerLock = await acquireFileLock(options.servicePaths.indexerDaemonLockPath, {
9
+ purpose: "indexer-daemon-repair",
10
+ walletRootId: options.state.walletRootId,
11
+ dataDir: options.context.dataDir,
12
+ databasePath: options.context.databasePath,
13
+ });
14
+ let resetIndexerDatabase = false;
15
+ try {
16
+ const initialProbe = await options.context.probeIndexerDaemon({
17
+ dataDir: options.context.dataDir,
18
+ walletRootId: options.state.walletRootId,
19
+ });
20
+ indexerCompatibilityIssue = mapIndexerCompatibilityToRepairIssue(initialProbe.compatibility);
21
+ initialIndexerDaemonInstanceId = initialProbe.status?.daemonInstanceId ?? null;
22
+ if (initialProbe.compatibility === "compatible") {
23
+ await initialProbe.client?.close().catch(() => undefined);
24
+ }
25
+ else if (initialProbe.compatibility === "service-version-mismatch"
26
+ || initialProbe.compatibility === "wallet-root-mismatch"
27
+ || initialProbe.compatibility === "schema-mismatch") {
28
+ const processId = initialProbe.status?.processId ?? null;
29
+ if (processId === null) {
30
+ throw new Error("indexer_daemon_process_id_unavailable");
31
+ }
32
+ try {
33
+ process.kill(processId, "SIGTERM");
34
+ }
35
+ catch (error) {
36
+ if (!(error instanceof Error) || !("code" in error) || error.code !== "ESRCH") {
37
+ throw error;
38
+ }
39
+ }
40
+ await waitForProcessExit(processId);
41
+ await clearIndexerDaemonArtifacts(options.servicePaths);
42
+ indexerDaemonAction = "stopped-incompatible-daemon";
43
+ }
44
+ else if (initialProbe.compatibility === "unreachable") {
45
+ const hasStaleArtifacts = await Promise.all([
46
+ options.servicePaths.indexerDaemonSocketPath,
47
+ options.servicePaths.indexerDaemonStatusPath,
48
+ ].map(pathExists));
49
+ if (hasStaleArtifacts.some(Boolean)) {
50
+ await clearIndexerDaemonArtifacts(options.servicePaths);
51
+ indexerDaemonAction = "cleared-stale-artifacts";
52
+ }
53
+ }
54
+ else {
55
+ throw new Error(initialProbe.error ?? "indexer_daemon_protocol_error");
56
+ }
57
+ resetIndexerDatabase = await ensureIndexerDatabaseHealthy({
58
+ databasePath: options.context.databasePath,
59
+ dataDir: options.context.dataDir,
60
+ walletRootId: options.state.walletRootId,
61
+ resetIfNeeded: options.context.assumeYes,
62
+ });
63
+ }
64
+ finally {
65
+ await indexerLock.release();
66
+ }
67
+ let preAttachIndexerDaemonInstanceId = null;
68
+ const preAttachProbe = await options.context.probeIndexerDaemon({
69
+ dataDir: options.context.dataDir,
70
+ walletRootId: options.state.walletRootId,
71
+ });
72
+ if (preAttachProbe.compatibility === "compatible") {
73
+ preAttachIndexerDaemonInstanceId = preAttachProbe.status?.daemonInstanceId ?? null;
74
+ await preAttachProbe.client?.close().catch(() => undefined);
75
+ }
76
+ else if (preAttachProbe.compatibility !== "unreachable") {
77
+ throw new Error(preAttachProbe.error ?? "indexer_daemon_protocol_error");
78
+ }
79
+ const daemon = await options.context.attachIndexerDaemon({
80
+ dataDir: options.context.dataDir,
81
+ databasePath: options.context.databasePath,
82
+ walletRootId: options.state.walletRootId,
83
+ });
84
+ try {
85
+ const { health: indexerPostRepairHealth, daemonInstanceId: postRepairDaemonInstanceId, } = await verifyIndexerPostRepairHealth({
86
+ daemon,
87
+ probeIndexerDaemon: options.context.probeIndexerDaemon,
88
+ dataDir: options.context.dataDir,
89
+ walletRootId: options.state.walletRootId,
90
+ nowUnixMs: options.context.nowUnixMs,
91
+ });
92
+ const restartedIndexerDaemon = indexerDaemonAction !== "none" || preAttachProbe.compatibility === "unreachable";
93
+ if (restartedIndexerDaemon
94
+ && initialIndexerDaemonInstanceId !== null
95
+ && postRepairDaemonInstanceId === initialIndexerDaemonInstanceId) {
96
+ throw new Error("indexer_daemon_repair_identity_not_rotated");
97
+ }
98
+ if (!restartedIndexerDaemon
99
+ && preAttachProbe.compatibility === "compatible"
100
+ && preAttachIndexerDaemonInstanceId !== null
101
+ && postRepairDaemonInstanceId !== preAttachIndexerDaemonInstanceId) {
102
+ throw new Error("indexer_daemon_repair_identity_changed");
103
+ }
104
+ if (indexerDaemonAction === "none" && preAttachProbe.compatibility === "unreachable") {
105
+ indexerDaemonAction = "restarted-compatible-daemon";
106
+ }
107
+ return {
108
+ resetIndexerDatabase,
109
+ indexerDaemonAction,
110
+ indexerCompatibilityIssue,
111
+ indexerPostRepairHealth,
112
+ };
113
+ }
114
+ finally {
115
+ await daemon.close().catch(() => undefined);
116
+ }
117
+ }
@@ -2,8 +2,7 @@ import type { MiningRuntimeStatusV1 } from "../mining/types.js";
2
2
  import type { WalletRuntimePaths } from "../runtime.js";
3
3
  import { type WalletSecretProvider } from "../state/provider.js";
4
4
  import type { WalletStateV1 } from "../types.js";
5
- import type { WalletPrompter, WalletRepairResult } from "./types.js";
6
- export declare function createSilentNonInteractivePrompter(): WalletPrompter;
5
+ import type { WalletRepairResult } from "./types.js";
7
6
  export declare function applyRepairStoppedMiningState(state: WalletStateV1): WalletStateV1;
8
7
  export declare function createStoppedMiningRuntimeSnapshotForRepair(options: {
9
8
  state: WalletStateV1;
@@ -39,9 +38,6 @@ export declare function resumeBackgroundMiningAfterRepair(options: {
39
38
  repairedState: WalletStateV1;
40
39
  bitcoindPostRepairHealth: WalletRepairResult["bitcoindPostRepairHealth"];
41
40
  indexerPostRepairHealth: WalletRepairResult["indexerPostRepairHealth"];
42
- dataDir: string;
43
- databasePath: string;
44
- startBackgroundMining?: typeof import("../mining/runner.js").startBackgroundMining;
45
41
  }): Promise<{
46
42
  miningResumeAction: WalletRepairResult["miningResumeAction"];
47
43
  miningPostRepairRunMode: WalletRepairResult["miningPostRepairRunMode"];
@@ -8,15 +8,6 @@ import { normalizeMiningStateRecord } from "../mining/state.js";
8
8
  import { createWalletSecretReference } from "../state/provider.js";
9
9
  import { persistWalletStateUpdate } from "../descriptor-normalization.js";
10
10
  import { isProcessAlive, stopRecordedManagedProcess } from "./repair-runtime.js";
11
- export function createSilentNonInteractivePrompter() {
12
- return {
13
- isInteractive: false,
14
- writeLine() { },
15
- async prompt() {
16
- return "";
17
- },
18
- };
19
- }
20
11
  export function applyRepairStoppedMiningState(state) {
21
12
  const miningState = normalizeMiningStateRecord(state.miningState);
22
13
  return {
@@ -271,34 +262,9 @@ export async function resumeBackgroundMiningAfterRepair(options) {
271
262
  miningResumeError: null,
272
263
  };
273
264
  }
274
- try {
275
- const startBackgroundMining = options.startBackgroundMining
276
- ?? (await import("../mining/runner.js")).startBackgroundMining;
277
- const resumed = await startBackgroundMining({
278
- dataDir: options.dataDir,
279
- databasePath: options.databasePath,
280
- provider: options.provider,
281
- paths: options.paths,
282
- prompter: createSilentNonInteractivePrompter(),
283
- });
284
- if (resumed.snapshot?.runMode === "background") {
285
- return {
286
- miningResumeAction: "resumed-background",
287
- miningPostRepairRunMode: "background",
288
- miningResumeError: null,
289
- };
290
- }
291
- return {
292
- miningResumeAction: "resume-failed",
293
- miningPostRepairRunMode: "stopped",
294
- miningResumeError: "Background mining did not report a background runtime after repair.",
295
- };
296
- }
297
- catch (error) {
298
- return {
299
- miningResumeAction: "resume-failed",
300
- miningPostRepairRunMode: "stopped",
301
- miningResumeError: error instanceof Error ? error.message : String(error),
302
- };
303
- }
265
+ return {
266
+ miningResumeAction: "skipped-background-mode-removed",
267
+ miningPostRepairRunMode: "stopped",
268
+ miningResumeError: null,
269
+ };
304
270
  }
@@ -1,11 +1,9 @@
1
- import { type WalletRuntimePaths } from "../runtime.js";
2
- import { type WalletSecretProvider } from "../state/provider.js";
3
1
  import type { WalletRepairDependencies, WalletRepairResult } from "./types.js";
4
2
  export declare function repairWallet(options: {
5
3
  dataDir: string;
6
4
  databasePath: string;
7
- provider?: WalletSecretProvider;
5
+ provider?: import("../state/provider.js").WalletSecretProvider;
8
6
  assumeYes?: boolean;
9
7
  nowUnixMs?: number;
10
- paths?: WalletRuntimePaths;
8
+ paths?: import("../runtime.js").WalletRuntimePaths;
11
9
  } & WalletRepairDependencies): Promise<WalletRepairResult>;