@cogcoin/client 1.1.4 → 1.1.5

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 (83) hide show
  1. package/README.md +4 -5
  2. package/dist/bitcoind/progress/tty-renderer.js +3 -2
  3. package/dist/bitcoind/service.js +1 -1
  4. package/dist/cli/command-registry.d.ts +39 -0
  5. package/dist/cli/command-registry.js +1132 -0
  6. package/dist/cli/commands/client-admin.js +6 -56
  7. package/dist/cli/commands/mining-admin.js +9 -32
  8. package/dist/cli/commands/mining-read.js +15 -56
  9. package/dist/cli/commands/mining-runtime.js +258 -57
  10. package/dist/cli/commands/service-runtime.js +1 -64
  11. package/dist/cli/commands/status.js +2 -15
  12. package/dist/cli/commands/update.js +6 -21
  13. package/dist/cli/commands/wallet-admin.js +18 -120
  14. package/dist/cli/commands/wallet-mutation.js +4 -7
  15. package/dist/cli/commands/wallet-read.js +31 -138
  16. package/dist/cli/context.js +2 -4
  17. package/dist/cli/mining-format.js +8 -2
  18. package/dist/cli/mutation-command-groups.d.ts +11 -11
  19. package/dist/cli/mutation-command-groups.js +9 -18
  20. package/dist/cli/mutation-json.d.ts +1 -17
  21. package/dist/cli/mutation-json.js +1 -28
  22. package/dist/cli/mutation-success.d.ts +0 -1
  23. package/dist/cli/mutation-success.js +0 -19
  24. package/dist/cli/output.d.ts +1 -10
  25. package/dist/cli/output.js +52 -481
  26. package/dist/cli/parse.d.ts +1 -1
  27. package/dist/cli/parse.js +38 -695
  28. package/dist/cli/runner.js +28 -113
  29. package/dist/cli/types.d.ts +7 -8
  30. package/dist/cli/update-notifier.js +1 -1
  31. package/dist/cli/wallet-format.js +1 -1
  32. package/dist/wallet/lifecycle/managed-core.d.ts +23 -0
  33. package/dist/wallet/lifecycle/managed-core.js +257 -0
  34. package/dist/wallet/lifecycle/repair-mining.d.ts +49 -0
  35. package/dist/wallet/lifecycle/repair-mining.js +304 -0
  36. package/dist/wallet/lifecycle/repair-runtime.d.ts +36 -0
  37. package/dist/wallet/lifecycle/repair-runtime.js +206 -0
  38. package/dist/wallet/lifecycle/repair.d.ts +11 -0
  39. package/dist/wallet/lifecycle/repair.js +368 -0
  40. package/dist/wallet/lifecycle/setup.d.ts +16 -0
  41. package/dist/wallet/lifecycle/setup.js +430 -0
  42. package/dist/wallet/lifecycle/types.d.ts +125 -0
  43. package/dist/wallet/lifecycle/types.js +1 -0
  44. package/dist/wallet/lifecycle.d.ts +4 -165
  45. package/dist/wallet/lifecycle.js +3 -1656
  46. package/dist/wallet/mining/candidate.d.ts +60 -0
  47. package/dist/wallet/mining/candidate.js +290 -0
  48. package/dist/wallet/mining/competitiveness.d.ts +22 -0
  49. package/dist/wallet/mining/competitiveness.js +640 -0
  50. package/dist/wallet/mining/control.js +7 -251
  51. package/dist/wallet/mining/cycle.d.ts +39 -0
  52. package/dist/wallet/mining/cycle.js +542 -0
  53. package/dist/wallet/mining/engine-state.d.ts +66 -0
  54. package/dist/wallet/mining/engine-state.js +211 -0
  55. package/dist/wallet/mining/engine-types.d.ts +173 -0
  56. package/dist/wallet/mining/engine-types.js +1 -0
  57. package/dist/wallet/mining/engine-utils.d.ts +7 -0
  58. package/dist/wallet/mining/engine-utils.js +75 -0
  59. package/dist/wallet/mining/events.d.ts +2 -0
  60. package/dist/wallet/mining/events.js +19 -0
  61. package/dist/wallet/mining/lifecycle.d.ts +71 -0
  62. package/dist/wallet/mining/lifecycle.js +355 -0
  63. package/dist/wallet/mining/projection.d.ts +61 -0
  64. package/dist/wallet/mining/projection.js +319 -0
  65. package/dist/wallet/mining/publish.d.ts +79 -0
  66. package/dist/wallet/mining/publish.js +614 -0
  67. package/dist/wallet/mining/runner.d.ts +12 -418
  68. package/dist/wallet/mining/runner.js +274 -3433
  69. package/dist/wallet/mining/supervisor.d.ts +134 -0
  70. package/dist/wallet/mining/supervisor.js +558 -0
  71. package/dist/wallet/mining/visualizer-sync.d.ts +42 -0
  72. package/dist/wallet/mining/visualizer-sync.js +166 -0
  73. package/dist/wallet/mining/visualizer.d.ts +1 -0
  74. package/dist/wallet/mining/visualizer.js +33 -18
  75. package/dist/wallet/reset.d.ts +1 -1
  76. package/dist/wallet/reset.js +35 -11
  77. package/dist/wallet/runtime.d.ts +0 -6
  78. package/dist/wallet/runtime.js +2 -38
  79. package/dist/wallet/tx/common.d.ts +18 -0
  80. package/dist/wallet/tx/common.js +40 -26
  81. package/package.json +1 -1
  82. package/dist/wallet/state/seed-index.d.ts +0 -43
  83. package/dist/wallet/state/seed-index.js +0 -151
@@ -5,20 +5,11 @@ import { loadWalletState } from "../state/storage.js";
5
5
  import { isRootDomainName } from "../read/filter.js";
6
6
  import { appendMiningEvent, getLastMiningEventTimestamp, loadMiningRuntimeStatus, readMiningEvents, saveMiningRuntimeStatus, followMiningEvents, } from "./runtime-artifacts.js";
7
7
  import { requestMiningGenerationPreemption } from "./coordination.js";
8
- import { normalizeMiningPublishState, normalizeMiningStateRecord } from "./state.js";
9
8
  import { loadClientConfig, saveBuiltInMiningProviderConfig } from "./config.js";
10
- import { MINING_WORKER_API_VERSION, MINING_WORKER_HEARTBEAT_STALE_MS, } from "./constants.js";
9
+ import { buildMiningRuntimeStatusSnapshot } from "./projection.js";
11
10
  import { estimateBuiltInModelDailyCost, getBuiltInProviderModelCatalog, getRecommendedBuiltInProviderModel, MINING_MODEL_DAILY_COST_ESTIMATE_ASSUMPTION, resolveBuiltInProviderSelection, } from "./provider-model.js";
11
+ import { createMiningEventRecord } from "./events.js";
12
12
  const KEEP_CURRENT_MODEL_SELECTION = "__keep_current__";
13
- function createMiningEvent(kind, message, options = {}) {
14
- return {
15
- schemaVersion: 1,
16
- timestampUnixMs: options.timestampUnixMs ?? Date.now(),
17
- level: options.level ?? "info",
18
- kind,
19
- message,
20
- };
21
- }
22
13
  function buildProviderInspection(options) {
23
14
  if (options.error !== null) {
24
15
  return {
@@ -86,241 +77,6 @@ function countEligibleAnchoredRoots(localState) {
86
77
  }
87
78
  return count;
88
79
  }
89
- async function isProcessAlive(pid) {
90
- if (pid === null) {
91
- return false;
92
- }
93
- try {
94
- process.kill(pid, 0);
95
- return true;
96
- }
97
- catch (error) {
98
- if (error instanceof Error && "code" in error && error.code === "ESRCH") {
99
- return false;
100
- }
101
- return true;
102
- }
103
- }
104
- function mapProviderState(provider, localState, existingRuntime) {
105
- const miningState = localState.state?.miningState === undefined
106
- ? null
107
- : normalizeMiningStateRecord(localState.state.miningState);
108
- if (existingRuntime?.currentPhase === "waiting-provider"
109
- && existingRuntime.providerState !== null
110
- && (miningState === null || miningState.state === "idle")) {
111
- return existingRuntime.providerState;
112
- }
113
- if (miningState?.state === "paused" && miningState.pauseReason?.includes("rate-limit")) {
114
- return "rate-limited";
115
- }
116
- if (miningState?.state === "paused" && miningState.pauseReason?.includes("auth")) {
117
- return "auth-error";
118
- }
119
- if (miningState?.state === "paused" && miningState.pauseReason?.includes("provider")) {
120
- return "backoff";
121
- }
122
- if (provider.status === "ready") {
123
- return "ready";
124
- }
125
- return "unavailable";
126
- }
127
- function shouldReuseExistingProviderWait(options) {
128
- return options.existingRuntime?.currentPhase === "waiting-provider"
129
- && options.existingRuntime.providerState !== null
130
- && (options.miningState === null || options.miningState.state === "idle");
131
- }
132
- function mapIndexerDaemonState(indexer) {
133
- if (indexer.health === "wallet-root-mismatch") {
134
- return "wallet-root-mismatch";
135
- }
136
- if (indexer.health === "service-version-mismatch") {
137
- return "service-version-mismatch";
138
- }
139
- if (indexer.health === "schema-mismatch") {
140
- return "schema-mismatch";
141
- }
142
- if (indexer.status !== null) {
143
- switch (indexer.status.state) {
144
- case "synced":
145
- return indexer.health === "stale-heartbeat" ? "stale-heartbeat" : "synced";
146
- case "catching-up":
147
- return indexer.health === "stale-heartbeat" ? "stale-heartbeat" : "catching-up";
148
- case "reorging":
149
- return indexer.health === "stale-heartbeat" ? "stale-heartbeat" : "reorging";
150
- case "starting":
151
- case "stopping":
152
- return indexer.health === "stale-heartbeat" ? "stale-heartbeat" : "starting";
153
- case "failed":
154
- return "failed";
155
- case "schema-mismatch":
156
- return "schema-mismatch";
157
- case "service-version-mismatch":
158
- return "service-version-mismatch";
159
- default:
160
- break;
161
- }
162
- }
163
- switch (indexer.health) {
164
- case "failed":
165
- return "failed";
166
- case "starting":
167
- return "starting";
168
- case "catching-up":
169
- return "catching-up";
170
- case "reorging":
171
- return "reorging";
172
- case "stale-heartbeat":
173
- return "stale-heartbeat";
174
- case "synced":
175
- return "synced";
176
- default:
177
- return "unavailable";
178
- }
179
- }
180
- function mapCorePublishState(nodeHealth, nodeStatus) {
181
- if (nodeStatus === null || !nodeStatus.ready) {
182
- return "unknown";
183
- }
184
- if (nodeHealth === "catching-up") {
185
- return "ibd";
186
- }
187
- return "healthy";
188
- }
189
- async function deriveBackgroundWorkerHealth(options) {
190
- const runtime = options.runtime;
191
- if (runtime?.runMode !== "background") {
192
- return null;
193
- }
194
- if (runtime.walletRootId !== null
195
- && options.localState.walletRootId !== null
196
- && runtime.walletRootId !== options.localState.walletRootId) {
197
- return "version-mismatch";
198
- }
199
- if (runtime.workerApiVersion !== null && runtime.workerApiVersion !== MINING_WORKER_API_VERSION) {
200
- return "version-mismatch";
201
- }
202
- if (!await isProcessAlive(runtime.backgroundWorkerPid)) {
203
- return "stale-pid";
204
- }
205
- if (runtime.backgroundWorkerHeartbeatAtUnixMs === null
206
- || (options.nowUnixMs - runtime.backgroundWorkerHeartbeatAtUnixMs) > MINING_WORKER_HEARTBEAT_STALE_MS) {
207
- return "stale-heartbeat";
208
- }
209
- return "healthy";
210
- }
211
- async function buildMiningRuntimeSnapshot(options) {
212
- const state = options.localState.state?.miningState === undefined
213
- ? null
214
- : normalizeMiningStateRecord(options.localState.state.miningState);
215
- const backgroundWorkerHealth = await deriveBackgroundWorkerHealth({
216
- runtime: options.existingRuntime,
217
- localState: options.localState,
218
- nowUnixMs: options.nowUnixMs,
219
- });
220
- const providerState = mapProviderState(options.provider, options.localState, options.existingRuntime);
221
- const indexerDaemonState = mapIndexerDaemonState(options.indexer);
222
- const corePublishState = mapCorePublishState(options.nodeHealth, options.nodeStatus);
223
- const existing = options.existingRuntime;
224
- const reuseExistingProviderWait = shouldReuseExistingProviderWait({
225
- existingRuntime: existing,
226
- miningState: state,
227
- });
228
- return {
229
- schemaVersion: 1,
230
- walletRootId: options.localState.walletRootId,
231
- workerApiVersion: existing?.workerApiVersion ?? null,
232
- workerBinaryVersion: existing?.workerBinaryVersion ?? null,
233
- workerBuildId: existing?.workerBuildId ?? null,
234
- updatedAtUnixMs: options.nowUnixMs,
235
- runMode: state?.runMode ?? existing?.runMode ?? "stopped",
236
- backgroundWorkerPid: existing?.backgroundWorkerPid ?? null,
237
- backgroundWorkerRunId: existing?.backgroundWorkerRunId ?? null,
238
- backgroundWorkerHeartbeatAtUnixMs: existing?.backgroundWorkerHeartbeatAtUnixMs ?? null,
239
- backgroundWorkerHealth,
240
- indexerDaemonState,
241
- indexerDaemonInstanceId: options.indexer.daemonInstanceId ?? null,
242
- indexerSnapshotSeq: options.indexer.snapshotSeq ?? null,
243
- indexerSnapshotOpenedAtUnixMs: options.indexer.openedAtUnixMs ?? null,
244
- indexerTruthSource: options.indexer.source ?? "none",
245
- indexerHeartbeatAtUnixMs: options.indexer.status?.heartbeatAtUnixMs ?? null,
246
- coreBestHeight: options.nodeStatus?.nodeBestHeight ?? options.indexer.status?.coreBestHeight ?? existing?.coreBestHeight ?? null,
247
- coreBestHash: options.nodeStatus?.nodeBestHashHex ?? options.indexer.status?.coreBestHash ?? existing?.coreBestHash ?? null,
248
- indexerTipHeight: options.indexer.snapshotTip?.height ?? options.indexer.status?.appliedTipHeight ?? null,
249
- indexerTipHash: options.indexer.snapshotTip?.blockHashHex ?? options.indexer.status?.appliedTipHash ?? null,
250
- indexerReorgDepth: options.indexer.status?.reorgDepth ?? null,
251
- indexerTipAligned: options.tipsAligned,
252
- corePublishState,
253
- providerState,
254
- lastSuspendDetectedAtUnixMs: existing?.lastSuspendDetectedAtUnixMs ?? null,
255
- reconnectSettledUntilUnixMs: existing?.reconnectSettledUntilUnixMs ?? null,
256
- tipSettledUntilUnixMs: existing?.tipSettledUntilUnixMs ?? null,
257
- miningState: state?.state ?? existing?.miningState ?? "idle",
258
- currentPhase: existing?.currentPhase ?? "idle",
259
- currentPublishState: normalizeMiningPublishState(state?.currentPublishState ?? options.existingRuntime?.currentPublishState ?? "none"),
260
- targetBlockHeight: state?.currentBlockTargetHeight ?? existing?.targetBlockHeight ?? null,
261
- referencedBlockHashDisplay: state?.currentReferencedBlockHashDisplay ?? existing?.referencedBlockHashDisplay ?? null,
262
- currentDomainId: state?.currentDomainId ?? existing?.currentDomainId ?? null,
263
- currentDomainName: state?.currentDomain ?? existing?.currentDomainName ?? null,
264
- currentSentenceDisplay: state?.currentSentence ?? existing?.currentSentenceDisplay ?? null,
265
- currentCanonicalBlend: state?.currentScore ?? existing?.currentCanonicalBlend ?? null,
266
- currentTxid: state?.currentTxid ?? existing?.currentTxid ?? null,
267
- currentWtxid: state?.currentWtxid ?? existing?.currentWtxid ?? null,
268
- livePublishInMempool: state?.livePublishInMempool ?? existing?.livePublishInMempool ?? null,
269
- currentFeeRateSatVb: state?.currentFeeRateSatVb ?? existing?.currentFeeRateSatVb ?? null,
270
- currentAbsoluteFeeSats: state?.currentAbsoluteFeeSats ?? existing?.currentAbsoluteFeeSats ?? null,
271
- currentBlockFeeSpentSats: state?.currentBlockFeeSpentSats ?? existing?.currentBlockFeeSpentSats ?? "0",
272
- sessionFeeSpentSats: state?.sessionFeeSpentSats ?? existing?.sessionFeeSpentSats ?? "0",
273
- lifetimeFeeSpentSats: state?.lifetimeFeeSpentSats ?? existing?.lifetimeFeeSpentSats ?? "0",
274
- sameDomainCompetitorSuppressed: existing?.sameDomainCompetitorSuppressed ?? null,
275
- higherRankedCompetitorDomainCount: existing?.higherRankedCompetitorDomainCount ?? null,
276
- dedupedCompetitorDomainCount: existing?.dedupedCompetitorDomainCount ?? null,
277
- competitivenessGateIndeterminate: existing?.competitivenessGateIndeterminate ?? null,
278
- mempoolSequenceCacheStatus: existing?.mempoolSequenceCacheStatus ?? null,
279
- currentPublishDecision: state?.currentPublishDecision ?? existing?.currentPublishDecision ?? null,
280
- lastMempoolSequence: existing?.lastMempoolSequence ?? null,
281
- lastCompetitivenessGateAtUnixMs: existing?.lastCompetitivenessGateAtUnixMs ?? null,
282
- pauseReason: state?.pauseReason ?? options.existingRuntime?.pauseReason ?? null,
283
- providerConfigured: options.provider.configured,
284
- providerKind: options.provider.provider,
285
- bitcoindHealth: options.bitcoind.health,
286
- bitcoindServiceState: options.nodeStatus?.serviceStatus?.state ?? null,
287
- bitcoindReplicaStatus: options.nodeStatus?.walletReplica?.proofStatus ?? null,
288
- nodeHealth: options.nodeHealth,
289
- indexerHealth: options.indexer.health,
290
- tipsAligned: options.tipsAligned,
291
- lastEventAtUnixMs: options.lastEventAtUnixMs,
292
- lastError: reuseExistingProviderWait
293
- ? existing?.lastError ?? null
294
- : existing?.currentPhase === "waiting-bitcoin-network" || existing?.currentPhase === "waiting-indexer"
295
- ? existing?.lastError ?? options.provider.message ?? options.indexer.message ?? null
296
- : options.provider.message ?? options.indexer.message ?? null,
297
- note: state?.pauseReason === "zero-reward"
298
- ? "Mining is disabled because the target block reward is zero."
299
- : existing?.currentPhase === "resuming"
300
- ? "Mining discarded stale in-flight work after a large local runtime gap and is rechecking health."
301
- : reuseExistingProviderWait
302
- ? "Mining is waiting for the sentence provider to recover."
303
- : existing?.currentPhase === "waiting-indexer"
304
- ? "Mining is waiting for Bitcoin Core and the indexer to align."
305
- : existing?.currentPhase === "waiting-bitcoin-network"
306
- ? "Mining is waiting for the local Bitcoin node to become publishable."
307
- : state?.state === "repair-required"
308
- ? "Mining is blocked until the current mining publish is reconciled or `cogcoin repair` completes."
309
- : state?.state === "paused-stale" && state.livePublishInMempool
310
- ? "A previously broadcast mining transaction is still in mempool for an older tip context. Wait for confirmation or rerun mining to replace it."
311
- : state?.state === "paused" && state.livePublishInMempool
312
- ? "Mining is paused, but the last mining transaction may still confirm from mempool without further fee bumps."
313
- : state?.state === "paused"
314
- ? "Mining is paused by another wallet command or local policy."
315
- : options.provider.status === "missing"
316
- ? "Run `cogcoin mine setup` to configure the built-in mining provider."
317
- : options.indexer.health === "reorging"
318
- ? "Mining remains stopped while the indexer replays a reorg and refreshes the coherent snapshot."
319
- : options.indexer.health !== "synced" || options.nodeHealth !== "synced"
320
- ? "Mining remains stopped until Bitcoin Core and the indexer are both healthy and aligned."
321
- : null,
322
- };
323
- }
324
80
  async function loadMiningProviderConfig(options) {
325
81
  try {
326
82
  const config = await loadClientConfig({
@@ -356,7 +112,7 @@ export async function inspectMiningControlPlane(options) {
356
112
  const nodeBestHeight = options.nodeStatus?.nodeBestHeight ?? null;
357
113
  const indexerHeight = options.indexer.snapshotTip?.height ?? null;
358
114
  const tipsAligned = nodeBestHeight === null || indexerHeight === null ? null : nodeBestHeight === indexerHeight;
359
- const runtime = await buildMiningRuntimeSnapshot({
115
+ const runtime = await buildMiningRuntimeStatusSnapshot({
360
116
  nowUnixMs,
361
117
  localState: options.localState,
362
118
  bitcoind: options.bitcoind,
@@ -633,7 +389,7 @@ export async function setupBuiltInMining(options) {
633
389
  path: paths.clientConfigPath,
634
390
  provider,
635
391
  }).catch(() => null);
636
- await appendMiningEvent(paths.miningEventsPath, createMiningEvent("mine-setup-started", "Started built-in mining provider setup.", { timestampUnixMs: nowUnixMs }));
392
+ await appendMiningEvent(paths.miningEventsPath, createMiningEventRecord("mine-setup-started", "Started built-in mining provider setup.", { timestampUnixMs: nowUnixMs }));
637
393
  try {
638
394
  const config = await promptForMiningProviderConfig(options.prompter, eligibleRootCount, {
639
395
  currentConfig: clientConfig?.mining.builtIn ?? null,
@@ -646,7 +402,7 @@ export async function setupBuiltInMining(options) {
646
402
  secretReference: createWalletSecretReference(loaded.state.walletRootId),
647
403
  config,
648
404
  });
649
- await appendMiningEvent(paths.miningEventsPath, createMiningEvent("mine-setup-completed", `Configured the built-in ${config.provider} mining provider with model ${config.modelOverride} (${describeModelSelectionSource(config.modelSelectionSource)}).`, { timestampUnixMs: nowUnixMs }));
405
+ await appendMiningEvent(paths.miningEventsPath, createMiningEventRecord("mine-setup-completed", `Configured the built-in ${config.provider} mining provider with model ${config.modelOverride} (${describeModelSelectionSource(config.modelSelectionSource)}).`, { timestampUnixMs: nowUnixMs }));
650
406
  return refreshMiningRuntimeStatus({
651
407
  provider,
652
408
  localState,
@@ -673,13 +429,13 @@ export async function setupBuiltInMining(options) {
673
429
  }
674
430
  catch (error) {
675
431
  if (error instanceof Error && error.message === "mining_setup_canceled") {
676
- await appendMiningEvent(paths.miningEventsPath, createMiningEvent("mine-setup-canceled", "Canceled built-in mining provider setup.", {
432
+ await appendMiningEvent(paths.miningEventsPath, createMiningEventRecord("mine-setup-canceled", "Canceled built-in mining provider setup.", {
677
433
  level: "warn",
678
434
  timestampUnixMs: nowUnixMs,
679
435
  }));
680
436
  throw error;
681
437
  }
682
- await appendMiningEvent(paths.miningEventsPath, createMiningEvent("mine-setup-failed", error instanceof Error ? error.message : String(error), {
438
+ await appendMiningEvent(paths.miningEventsPath, createMiningEventRecord("mine-setup-failed", error instanceof Error ? error.message : String(error), {
683
439
  level: "error",
684
440
  timestampUnixMs: nowUnixMs,
685
441
  }));
@@ -0,0 +1,39 @@
1
+ import { assaySentences } from "@cogcoin/scoring";
2
+ import { openWalletReadContext, type WalletReadContext } from "../read/index.js";
3
+ import type { WalletRuntimePaths } from "../runtime.js";
4
+ import type { WalletSecretProvider } from "../state/provider.js";
5
+ import type { MiningCooperativeYield, MiningRpcClient, ReadyMiningReadContext } from "./engine-types.js";
6
+ import type { MiningEventRecord, MiningRuntimeStatusV1 } from "./types.js";
7
+ import { generateCandidatesForDomains } from "./candidate.js";
8
+ import { runCompetitivenessGate } from "./competitiveness.js";
9
+ import { type MiningRuntimeLoopState } from "./engine-state.js";
10
+ import { attachOrStartManagedBitcoindService } from "../../bitcoind/service.js";
11
+ import { createRpcClient } from "../../bitcoind/node.js";
12
+ import { type MiningRuntimeStatusOverrides } from "./projection.js";
13
+ export declare function runMiningPhaseMachine(options: {
14
+ dataDir: string;
15
+ databasePath: string;
16
+ provider: WalletSecretProvider;
17
+ paths: WalletRuntimePaths;
18
+ runMode: "foreground" | "background";
19
+ backgroundWorkerRunId: string | null;
20
+ readContext: ReadyMiningReadContext;
21
+ rpc: MiningRpcClient;
22
+ targetBlockHeight: number | null;
23
+ tipKey: string | null;
24
+ corePublishState: MiningRuntimeStatusV1["corePublishState"];
25
+ loopState: MiningRuntimeLoopState;
26
+ openReadContext: typeof openWalletReadContext;
27
+ attachService: typeof attachOrStartManagedBitcoindService;
28
+ rpcFactory: (config: Parameters<typeof createRpcClient>[0]) => MiningRpcClient;
29
+ fetchImpl?: typeof fetch;
30
+ generateCandidatesForDomainsImpl?: typeof generateCandidatesForDomains;
31
+ runCompetitivenessGateImpl?: typeof runCompetitivenessGate;
32
+ assaySentencesImpl?: typeof assaySentences;
33
+ cooperativeYieldImpl?: MiningCooperativeYield;
34
+ cooperativeYieldEvery?: number;
35
+ nowImpl?: () => number;
36
+ saveCycleStatus: (readContext: WalletReadContext, overrides: MiningRuntimeStatusOverrides) => Promise<MiningRuntimeStatusV1>;
37
+ appendEvent: (event: MiningEventRecord) => Promise<void>;
38
+ throwIfSuspendDetected?: () => void;
39
+ }): Promise<void>;