@cogcoin/client 0.5.0
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.
- package/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/app-paths.d.ts +38 -0
- package/dist/app-paths.js +121 -0
- package/dist/art/banner.txt +13 -0
- package/dist/art/scroll.txt +13 -0
- package/dist/art/train-car.txt +6 -0
- package/dist/art/train-smoke.txt +6 -0
- package/dist/art/train.txt +6 -0
- package/dist/bitcoind/bootstrap/chainstate.d.ts +4 -0
- package/dist/bitcoind/bootstrap/chainstate.js +13 -0
- package/dist/bitcoind/bootstrap/constants.d.ts +7 -0
- package/dist/bitcoind/bootstrap/constants.js +12 -0
- package/dist/bitcoind/bootstrap/controller.d.ts +29 -0
- package/dist/bitcoind/bootstrap/controller.js +101 -0
- package/dist/bitcoind/bootstrap/download.d.ts +2 -0
- package/dist/bitcoind/bootstrap/download.js +196 -0
- package/dist/bitcoind/bootstrap/headers.d.ts +13 -0
- package/dist/bitcoind/bootstrap/headers.js +61 -0
- package/dist/bitcoind/bootstrap/paths.d.ts +4 -0
- package/dist/bitcoind/bootstrap/paths.js +15 -0
- package/dist/bitcoind/bootstrap/snapshot-file.d.ts +7 -0
- package/dist/bitcoind/bootstrap/snapshot-file.js +42 -0
- package/dist/bitcoind/bootstrap/state.d.ts +40 -0
- package/dist/bitcoind/bootstrap/state.js +70 -0
- package/dist/bitcoind/bootstrap/types.d.ts +28 -0
- package/dist/bitcoind/bootstrap/types.js +1 -0
- package/dist/bitcoind/bootstrap.d.ts +8 -0
- package/dist/bitcoind/bootstrap.js +7 -0
- package/dist/bitcoind/client/factory.d.ts +3 -0
- package/dist/bitcoind/client/factory.js +57 -0
- package/dist/bitcoind/client/follow-block-times.d.ts +8 -0
- package/dist/bitcoind/client/follow-block-times.js +25 -0
- package/dist/bitcoind/client/follow-loop.d.ts +10 -0
- package/dist/bitcoind/client/follow-loop.js +57 -0
- package/dist/bitcoind/client/internal-types.d.ts +63 -0
- package/dist/bitcoind/client/internal-types.js +18 -0
- package/dist/bitcoind/client/managed-client.d.ts +20 -0
- package/dist/bitcoind/client/managed-client.js +197 -0
- package/dist/bitcoind/client/rate-tracker.d.ts +2 -0
- package/dist/bitcoind/client/rate-tracker.js +24 -0
- package/dist/bitcoind/client/sync-engine.d.ts +3 -0
- package/dist/bitcoind/client/sync-engine.js +143 -0
- package/dist/bitcoind/client.d.ts +1 -0
- package/dist/bitcoind/client.js +1 -0
- package/dist/bitcoind/errors.d.ts +1 -0
- package/dist/bitcoind/errors.js +49 -0
- package/dist/bitcoind/index.d.ts +2 -0
- package/dist/bitcoind/index.js +1 -0
- package/dist/bitcoind/indexer-daemon-main.d.ts +1 -0
- package/dist/bitcoind/indexer-daemon-main.js +472 -0
- package/dist/bitcoind/indexer-daemon.d.ts +107 -0
- package/dist/bitcoind/indexer-daemon.js +391 -0
- package/dist/bitcoind/node.d.ts +8 -0
- package/dist/bitcoind/node.js +219 -0
- package/dist/bitcoind/normalize.d.ts +3 -0
- package/dist/bitcoind/normalize.js +47 -0
- package/dist/bitcoind/progress/assets.d.ts +10 -0
- package/dist/bitcoind/progress/assets.js +90 -0
- package/dist/bitcoind/progress/constants.d.ts +48 -0
- package/dist/bitcoind/progress/constants.js +53 -0
- package/dist/bitcoind/progress/controller.d.ts +28 -0
- package/dist/bitcoind/progress/controller.js +188 -0
- package/dist/bitcoind/progress/follow-scene.d.ts +40 -0
- package/dist/bitcoind/progress/follow-scene.js +367 -0
- package/dist/bitcoind/progress/formatting.d.ts +23 -0
- package/dist/bitcoind/progress/formatting.js +227 -0
- package/dist/bitcoind/progress/quote-scene.d.ts +4 -0
- package/dist/bitcoind/progress/quote-scene.js +137 -0
- package/dist/bitcoind/progress/train-scene.d.ts +9 -0
- package/dist/bitcoind/progress/train-scene.js +92 -0
- package/dist/bitcoind/progress/tty-renderer.d.ts +18 -0
- package/dist/bitcoind/progress/tty-renderer.js +150 -0
- package/dist/bitcoind/progress.d.ts +7 -0
- package/dist/bitcoind/progress.js +7 -0
- package/dist/bitcoind/quotes.d.ts +24 -0
- package/dist/bitcoind/quotes.js +195 -0
- package/dist/bitcoind/rpc.d.ts +71 -0
- package/dist/bitcoind/rpc.js +322 -0
- package/dist/bitcoind/service-paths.d.ts +19 -0
- package/dist/bitcoind/service-paths.js +49 -0
- package/dist/bitcoind/service.d.ts +40 -0
- package/dist/bitcoind/service.js +735 -0
- package/dist/bitcoind/testing.d.ts +9 -0
- package/dist/bitcoind/testing.js +9 -0
- package/dist/bitcoind/types.d.ts +396 -0
- package/dist/bitcoind/types.js +3 -0
- package/dist/bytes.d.ts +9 -0
- package/dist/bytes.js +36 -0
- package/dist/cli/commands/follow.d.ts +2 -0
- package/dist/cli/commands/follow.js +43 -0
- package/dist/cli/commands/mining-admin.d.ts +2 -0
- package/dist/cli/commands/mining-admin.js +92 -0
- package/dist/cli/commands/mining-read.d.ts +2 -0
- package/dist/cli/commands/mining-read.js +173 -0
- package/dist/cli/commands/mining-runtime.d.ts +2 -0
- package/dist/cli/commands/mining-runtime.js +108 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.js +31 -0
- package/dist/cli/commands/sync.d.ts +2 -0
- package/dist/cli/commands/sync.js +52 -0
- package/dist/cli/commands/wallet-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-admin.js +175 -0
- package/dist/cli/commands/wallet-mutation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation.js +681 -0
- package/dist/cli/commands/wallet-read.d.ts +2 -0
- package/dist/cli/commands/wallet-read.js +265 -0
- package/dist/cli/context.d.ts +3 -0
- package/dist/cli/context.js +75 -0
- package/dist/cli/io.d.ts +3 -0
- package/dist/cli/io.js +12 -0
- package/dist/cli/mining-format.d.ts +5 -0
- package/dist/cli/mining-format.js +156 -0
- package/dist/cli/mining-json.d.ts +49 -0
- package/dist/cli/mining-json.js +89 -0
- package/dist/cli/mutation-command-groups.d.ts +15 -0
- package/dist/cli/mutation-command-groups.js +71 -0
- package/dist/cli/mutation-json.d.ts +430 -0
- package/dist/cli/mutation-json.js +311 -0
- package/dist/cli/mutation-resolved-json.d.ts +124 -0
- package/dist/cli/mutation-resolved-json.js +129 -0
- package/dist/cli/mutation-success.d.ts +20 -0
- package/dist/cli/mutation-success.js +47 -0
- package/dist/cli/mutation-text-format.d.ts +22 -0
- package/dist/cli/mutation-text-format.js +171 -0
- package/dist/cli/mutation-text-write.d.ts +13 -0
- package/dist/cli/mutation-text-write.js +16 -0
- package/dist/cli/output.d.ts +185 -0
- package/dist/cli/output.js +1085 -0
- package/dist/cli/parse.d.ts +3 -0
- package/dist/cli/parse.js +971 -0
- package/dist/cli/preview-json.d.ts +416 -0
- package/dist/cli/preview-json.js +293 -0
- package/dist/cli/prompt.d.ts +3 -0
- package/dist/cli/prompt.js +33 -0
- package/dist/cli/read-json.d.ts +187 -0
- package/dist/cli/read-json.js +675 -0
- package/dist/cli/runner.d.ts +2 -0
- package/dist/cli/runner.js +129 -0
- package/dist/cli/signals.d.ts +3 -0
- package/dist/cli/signals.js +63 -0
- package/dist/cli/status-format.d.ts +2 -0
- package/dist/cli/status-format.js +48 -0
- package/dist/cli/types.d.ts +148 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/wallet-format.d.ts +29 -0
- package/dist/cli/wallet-format.js +637 -0
- package/dist/cli/workflow-hints.d.ts +13 -0
- package/dist/cli/workflow-hints.js +94 -0
- package/dist/cli-runner.d.ts +3 -0
- package/dist/cli-runner.js +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6 -0
- package/dist/client/default-client.d.ts +11 -0
- package/dist/client/default-client.js +118 -0
- package/dist/client/factory.d.ts +2 -0
- package/dist/client/factory.js +15 -0
- package/dist/client/initialization.d.ts +6 -0
- package/dist/client/initialization.js +30 -0
- package/dist/client/persistence.d.ts +5 -0
- package/dist/client/persistence.js +28 -0
- package/dist/client/store-adapter.d.ts +3 -0
- package/dist/client/store-adapter.js +20 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/passive-status.d.ts +36 -0
- package/dist/passive-status.js +100 -0
- package/dist/sqlite/better-sqlite3.d.ts +26 -0
- package/dist/sqlite/better-sqlite3.js +4 -0
- package/dist/sqlite/checkpoints.d.ts +11 -0
- package/dist/sqlite/checkpoints.js +27 -0
- package/dist/sqlite/driver.d.ts +17 -0
- package/dist/sqlite/driver.js +98 -0
- package/dist/sqlite/index.d.ts +4 -0
- package/dist/sqlite/index.js +9 -0
- package/dist/sqlite/migrate.d.ts +2 -0
- package/dist/sqlite/migrate.js +37 -0
- package/dist/sqlite/store.d.ts +3 -0
- package/dist/sqlite/store.js +122 -0
- package/dist/sqlite/tip-meta.d.ts +26 -0
- package/dist/sqlite/tip-meta.js +97 -0
- package/dist/sqlite/types.d.ts +10 -0
- package/dist/sqlite/types.js +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +1 -0
- package/dist/wallet/archive.d.ts +4 -0
- package/dist/wallet/archive.js +39 -0
- package/dist/wallet/cogop/constants.d.ts +32 -0
- package/dist/wallet/cogop/constants.js +32 -0
- package/dist/wallet/cogop/index.d.ts +32 -0
- package/dist/wallet/cogop/index.js +213 -0
- package/dist/wallet/cogop/numeric.d.ts +3 -0
- package/dist/wallet/cogop/numeric.js +24 -0
- package/dist/wallet/cogop/scriptpubkey.d.ts +2 -0
- package/dist/wallet/cogop/scriptpubkey.js +13 -0
- package/dist/wallet/cogop/validate-name.d.ts +2 -0
- package/dist/wallet/cogop/validate-name.js +18 -0
- package/dist/wallet/fs/atomic.d.ts +6 -0
- package/dist/wallet/fs/atomic.js +46 -0
- package/dist/wallet/fs/lock.d.ts +19 -0
- package/dist/wallet/fs/lock.js +61 -0
- package/dist/wallet/fs/status-file.d.ts +1 -0
- package/dist/wallet/fs/status-file.js +4 -0
- package/dist/wallet/lifecycle.d.ts +193 -0
- package/dist/wallet/lifecycle.js +1475 -0
- package/dist/wallet/material.d.ts +45 -0
- package/dist/wallet/material.js +118 -0
- package/dist/wallet/mining/config.d.ts +18 -0
- package/dist/wallet/mining/config.js +44 -0
- package/dist/wallet/mining/constants.d.ts +24 -0
- package/dist/wallet/mining/constants.js +24 -0
- package/dist/wallet/mining/control.d.ts +53 -0
- package/dist/wallet/mining/control.js +758 -0
- package/dist/wallet/mining/coordination.d.ts +40 -0
- package/dist/wallet/mining/coordination.js +121 -0
- package/dist/wallet/mining/hook-protocol.d.ts +47 -0
- package/dist/wallet/mining/hook-protocol.js +161 -0
- package/dist/wallet/mining/hook-runner.d.ts +1 -0
- package/dist/wallet/mining/hook-runner.js +52 -0
- package/dist/wallet/mining/hooks.d.ts +38 -0
- package/dist/wallet/mining/hooks.js +520 -0
- package/dist/wallet/mining/index.d.ts +8 -0
- package/dist/wallet/mining/index.js +6 -0
- package/dist/wallet/mining/runner.d.ts +155 -0
- package/dist/wallet/mining/runner.js +2574 -0
- package/dist/wallet/mining/runtime-artifacts.d.ts +17 -0
- package/dist/wallet/mining/runtime-artifacts.js +166 -0
- package/dist/wallet/mining/sentences.d.ts +23 -0
- package/dist/wallet/mining/sentences.js +281 -0
- package/dist/wallet/mining/state.d.ts +9 -0
- package/dist/wallet/mining/state.js +75 -0
- package/dist/wallet/mining/types.d.ts +141 -0
- package/dist/wallet/mining/types.js +1 -0
- package/dist/wallet/mining/visualizer.d.ts +19 -0
- package/dist/wallet/mining/visualizer.js +134 -0
- package/dist/wallet/mining/worker-main.d.ts +1 -0
- package/dist/wallet/mining/worker-main.js +17 -0
- package/dist/wallet/read/context.d.ts +20 -0
- package/dist/wallet/read/context.js +532 -0
- package/dist/wallet/read/filter.d.ts +9 -0
- package/dist/wallet/read/filter.js +42 -0
- package/dist/wallet/read/index.d.ts +4 -0
- package/dist/wallet/read/index.js +3 -0
- package/dist/wallet/read/project.d.ts +11 -0
- package/dist/wallet/read/project.js +300 -0
- package/dist/wallet/read/types.d.ts +144 -0
- package/dist/wallet/read/types.js +1 -0
- package/dist/wallet/runtime.d.ts +26 -0
- package/dist/wallet/runtime.js +28 -0
- package/dist/wallet/state/crypto.d.ts +31 -0
- package/dist/wallet/state/crypto.js +127 -0
- package/dist/wallet/state/provider.d.ts +37 -0
- package/dist/wallet/state/provider.js +312 -0
- package/dist/wallet/state/session.d.ts +12 -0
- package/dist/wallet/state/session.js +23 -0
- package/dist/wallet/state/storage.d.ts +19 -0
- package/dist/wallet/state/storage.js +55 -0
- package/dist/wallet/tx/anchor.d.ts +40 -0
- package/dist/wallet/tx/anchor.js +1210 -0
- package/dist/wallet/tx/cog.d.ts +92 -0
- package/dist/wallet/tx/cog.js +1055 -0
- package/dist/wallet/tx/common.d.ts +89 -0
- package/dist/wallet/tx/common.js +156 -0
- package/dist/wallet/tx/confirm.d.ts +15 -0
- package/dist/wallet/tx/confirm.js +24 -0
- package/dist/wallet/tx/domain-admin.d.ts +105 -0
- package/dist/wallet/tx/domain-admin.js +869 -0
- package/dist/wallet/tx/domain-market.d.ts +112 -0
- package/dist/wallet/tx/domain-market.js +1365 -0
- package/dist/wallet/tx/field.d.ts +101 -0
- package/dist/wallet/tx/field.js +1853 -0
- package/dist/wallet/tx/identity-selector.d.ts +12 -0
- package/dist/wallet/tx/identity-selector.js +52 -0
- package/dist/wallet/tx/index.d.ts +7 -0
- package/dist/wallet/tx/index.js +7 -0
- package/dist/wallet/tx/journal.d.ts +5 -0
- package/dist/wallet/tx/journal.js +31 -0
- package/dist/wallet/tx/register.d.ts +68 -0
- package/dist/wallet/tx/register.js +952 -0
- package/dist/wallet/tx/reputation.d.ts +72 -0
- package/dist/wallet/tx/reputation.js +693 -0
- package/dist/wallet/tx/targets.d.ts +7 -0
- package/dist/wallet/tx/targets.js +122 -0
- package/dist/wallet/types.d.ts +249 -0
- package/dist/wallet/types.js +1 -0
- package/dist/writing_quotes.json +1654 -0
- package/package.json +78 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { openManagedBitcoindClientInternal } from "./client.js";
|
|
2
|
+
export { attachOrStartIndexerDaemon, readIndexerDaemonStatusForTesting, shutdownIndexerDaemonForTesting, } from "./indexer-daemon.js";
|
|
3
|
+
export { normalizeRpcBlock } from "./normalize.js";
|
|
4
|
+
export { BitcoinRpcClient } from "./rpc.js";
|
|
5
|
+
export { attachOrStartManagedBitcoindService, readManagedBitcoindServiceStatusForTesting, shutdownManagedBitcoindServiceForTesting, } from "./service.js";
|
|
6
|
+
export { AssumeUtxoBootstrapController, DEFAULT_SNAPSHOT_METADATA, createBootstrapStateForTesting, downloadSnapshotFileForTesting, loadBootstrapStateForTesting, resolveBootstrapPathsForTesting, saveBootstrapStateForTesting, validateSnapshotFileForTesting, waitForHeadersForTesting, } from "./bootstrap.js";
|
|
7
|
+
export { buildBitcoindArgsForTesting, createRpcClient, launchManagedBitcoindNode, resolveDefaultBitcoindDataDirForTesting, validateNodeConfigForTesting, } from "./node.js";
|
|
8
|
+
export { ManagedProgressController, TtyProgressRenderer, advanceFollowSceneStateForTesting, createFollowSceneStateForTesting, createBootstrapProgressForTesting, formatCompactFollowAgeLabelForTesting, loadBannerArtForTesting, loadScrollArtForTesting, loadTrainCarArtForTesting, loadTrainArtForTesting, loadTrainSmokeArtForTesting, formatProgressLineForTesting, formatQuoteLineForTesting, renderArtFrameForTesting, renderCompletionFrameForTesting, renderFollowFrameForTesting, renderIntroFrameForTesting, resolveCompletionMessageForTesting, resolveIntroMessageForTesting, resolveStatusFieldTextForTesting, setFollowBlockTimeForTesting, setFollowBlockTimesForTesting, syncFollowSceneStateForTesting, } from "./progress.js";
|
|
9
|
+
export { WritingQuoteRotator, loadWritingQuotesForTesting, shuffleIndicesForTesting, } from "./quotes.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { openManagedBitcoindClientInternal } from "./client.js";
|
|
2
|
+
export { attachOrStartIndexerDaemon, readIndexerDaemonStatusForTesting, shutdownIndexerDaemonForTesting, } from "./indexer-daemon.js";
|
|
3
|
+
export { normalizeRpcBlock } from "./normalize.js";
|
|
4
|
+
export { BitcoinRpcClient } from "./rpc.js";
|
|
5
|
+
export { attachOrStartManagedBitcoindService, readManagedBitcoindServiceStatusForTesting, shutdownManagedBitcoindServiceForTesting, } from "./service.js";
|
|
6
|
+
export { AssumeUtxoBootstrapController, DEFAULT_SNAPSHOT_METADATA, createBootstrapStateForTesting, downloadSnapshotFileForTesting, loadBootstrapStateForTesting, resolveBootstrapPathsForTesting, saveBootstrapStateForTesting, validateSnapshotFileForTesting, waitForHeadersForTesting, } from "./bootstrap.js";
|
|
7
|
+
export { buildBitcoindArgsForTesting, createRpcClient, launchManagedBitcoindNode, resolveDefaultBitcoindDataDirForTesting, validateNodeConfigForTesting, } from "./node.js";
|
|
8
|
+
export { ManagedProgressController, TtyProgressRenderer, advanceFollowSceneStateForTesting, createFollowSceneStateForTesting, createBootstrapProgressForTesting, formatCompactFollowAgeLabelForTesting, loadBannerArtForTesting, loadScrollArtForTesting, loadTrainCarArtForTesting, loadTrainArtForTesting, loadTrainSmokeArtForTesting, formatProgressLineForTesting, formatQuoteLineForTesting, renderArtFrameForTesting, renderCompletionFrameForTesting, renderFollowFrameForTesting, renderIntroFrameForTesting, resolveCompletionMessageForTesting, resolveIntroMessageForTesting, resolveStatusFieldTextForTesting, setFollowBlockTimeForTesting, setFollowBlockTimesForTesting, syncFollowSceneStateForTesting, } from "./progress.js";
|
|
9
|
+
export { WritingQuoteRotator, loadWritingQuotesForTesting, shuffleIndicesForTesting, } from "./quotes.js";
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import type { BitcoinBlock, Client, ClientOptions, ClientTip } from "../types.js";
|
|
2
|
+
export type BootstrapPhase = "snapshot_download" | "wait_headers_for_snapshot" | "load_snapshot" | "bitcoin_sync" | "cogcoin_sync" | "follow_tip" | "paused" | "error" | "complete";
|
|
3
|
+
export type ProgressOutputMode = "auto" | "tty" | "none";
|
|
4
|
+
export interface SnapshotMetadata {
|
|
5
|
+
url: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
height: number;
|
|
8
|
+
sha256: string;
|
|
9
|
+
sizeBytes: number;
|
|
10
|
+
}
|
|
11
|
+
export interface WritingQuote {
|
|
12
|
+
quote: string;
|
|
13
|
+
author: string;
|
|
14
|
+
}
|
|
15
|
+
export interface BootstrapProgress {
|
|
16
|
+
phase: BootstrapPhase;
|
|
17
|
+
message: string;
|
|
18
|
+
resumed: boolean;
|
|
19
|
+
downloadedBytes: number | null;
|
|
20
|
+
totalBytes: number | null;
|
|
21
|
+
percent: number | null;
|
|
22
|
+
bytesPerSecond: number | null;
|
|
23
|
+
etaSeconds: number | null;
|
|
24
|
+
headers: number | null;
|
|
25
|
+
blocks: number | null;
|
|
26
|
+
targetHeight: number | null;
|
|
27
|
+
baseHeight: number | null;
|
|
28
|
+
tipHashHex: string | null;
|
|
29
|
+
lastError: string | null;
|
|
30
|
+
updatedAt: number;
|
|
31
|
+
}
|
|
32
|
+
export interface ManagedBitcoindProgressEvent {
|
|
33
|
+
phase: BootstrapPhase;
|
|
34
|
+
progress: BootstrapProgress;
|
|
35
|
+
snapshot: SnapshotMetadata;
|
|
36
|
+
currentQuote: WritingQuote | null;
|
|
37
|
+
cogcoinSyncHeight: number | null;
|
|
38
|
+
cogcoinSyncTargetHeight: number | null;
|
|
39
|
+
}
|
|
40
|
+
export interface BitcoindRpcConfig {
|
|
41
|
+
url: string;
|
|
42
|
+
cookieFile: string;
|
|
43
|
+
port: number;
|
|
44
|
+
}
|
|
45
|
+
export interface BitcoindZmqConfig {
|
|
46
|
+
endpoint: string;
|
|
47
|
+
topic: "hashblock";
|
|
48
|
+
port: number;
|
|
49
|
+
pollIntervalMs: number;
|
|
50
|
+
}
|
|
51
|
+
export interface ManagedBitcoindRuntimeConfig {
|
|
52
|
+
chain: "main" | "regtest";
|
|
53
|
+
rpc: BitcoindRpcConfig;
|
|
54
|
+
zmqPort: number;
|
|
55
|
+
p2pPort: number;
|
|
56
|
+
}
|
|
57
|
+
export declare const MANAGED_BITCOIND_SERVICE_API_VERSION = "cogcoin/bitcoind-service/v1";
|
|
58
|
+
export type ManagedBitcoindServiceState = "starting" | "ready" | "stopping" | "failed";
|
|
59
|
+
export interface ManagedBitcoindServiceStatus {
|
|
60
|
+
serviceApiVersion: typeof MANAGED_BITCOIND_SERVICE_API_VERSION;
|
|
61
|
+
binaryVersion: string;
|
|
62
|
+
buildId: string | null;
|
|
63
|
+
serviceInstanceId: string;
|
|
64
|
+
state: ManagedBitcoindServiceState;
|
|
65
|
+
processId: number | null;
|
|
66
|
+
walletRootId: string;
|
|
67
|
+
chain: "main" | "regtest";
|
|
68
|
+
dataDir: string;
|
|
69
|
+
runtimeRoot: string;
|
|
70
|
+
startHeight: number;
|
|
71
|
+
rpc: BitcoindRpcConfig;
|
|
72
|
+
zmq: BitcoindZmqConfig;
|
|
73
|
+
p2pPort: number;
|
|
74
|
+
walletReplica: ManagedCoreWalletReplicaStatus | null;
|
|
75
|
+
startedAtUnixMs: number;
|
|
76
|
+
heartbeatAtUnixMs: number;
|
|
77
|
+
updatedAtUnixMs: number;
|
|
78
|
+
lastError: string | null;
|
|
79
|
+
}
|
|
80
|
+
export interface ManagedBitcoindObservedStatus extends Omit<ManagedBitcoindServiceStatus, "serviceApiVersion"> {
|
|
81
|
+
serviceApiVersion: string;
|
|
82
|
+
}
|
|
83
|
+
export type ManagedBitcoindHealth = "ready" | "starting" | "failed" | "service-version-mismatch" | "wallet-root-mismatch" | "runtime-mismatch" | "replica-missing" | "replica-mismatch" | "unavailable";
|
|
84
|
+
export interface SyncResult {
|
|
85
|
+
appliedBlocks: number;
|
|
86
|
+
rewoundBlocks: number;
|
|
87
|
+
commonAncestorHeight: number | null;
|
|
88
|
+
startingHeight: number | null;
|
|
89
|
+
endingHeight: number | null;
|
|
90
|
+
bestHeight: number;
|
|
91
|
+
bestHashHex: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ManagedBitcoindStatus {
|
|
94
|
+
ready: boolean;
|
|
95
|
+
following: boolean;
|
|
96
|
+
chain: string;
|
|
97
|
+
pid: number | null;
|
|
98
|
+
walletRootId: string | null;
|
|
99
|
+
rpc: BitcoindRpcConfig;
|
|
100
|
+
zmq: BitcoindZmqConfig;
|
|
101
|
+
indexedTip: ClientTip | null;
|
|
102
|
+
nodeBestHeight: number | null;
|
|
103
|
+
nodeBestHashHex: string | null;
|
|
104
|
+
bootstrapPhase: BootstrapPhase;
|
|
105
|
+
bootstrapProgress: BootstrapProgress;
|
|
106
|
+
cogcoinSyncHeight: number | null;
|
|
107
|
+
cogcoinSyncTargetHeight: number | null;
|
|
108
|
+
currentQuote: WritingQuote | null;
|
|
109
|
+
snapshot: SnapshotMetadata;
|
|
110
|
+
serviceRuntimeRoot?: string;
|
|
111
|
+
serviceUpdatedAtUnixMs?: number | null;
|
|
112
|
+
walletReplica?: ManagedCoreWalletReplicaStatus | null;
|
|
113
|
+
serviceStatus?: ManagedBitcoindObservedStatus | null;
|
|
114
|
+
indexerDaemon?: ManagedIndexerDaemonObservedStatus | null;
|
|
115
|
+
}
|
|
116
|
+
export interface ManagedBitcoindOptions extends ClientOptions {
|
|
117
|
+
dataDir?: string;
|
|
118
|
+
databasePath?: string;
|
|
119
|
+
rpcPort?: number;
|
|
120
|
+
zmqPort?: number;
|
|
121
|
+
p2pPort?: number;
|
|
122
|
+
startupTimeoutMs?: number;
|
|
123
|
+
shutdownTimeoutMs?: number;
|
|
124
|
+
pollIntervalMs?: number;
|
|
125
|
+
syncDebounceMs?: number;
|
|
126
|
+
walletRootId?: string;
|
|
127
|
+
managedWalletPassphrase?: string;
|
|
128
|
+
onProgress?: (event: ManagedBitcoindProgressEvent) => void;
|
|
129
|
+
progressOutput?: ProgressOutputMode;
|
|
130
|
+
}
|
|
131
|
+
export interface ManagedBitcoindClient extends Client {
|
|
132
|
+
syncToTip(): Promise<SyncResult>;
|
|
133
|
+
startFollowingTip(): Promise<void>;
|
|
134
|
+
getNodeStatus(): Promise<ManagedBitcoindStatus>;
|
|
135
|
+
close(): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
export interface InternalManagedBitcoindOptions extends ManagedBitcoindOptions {
|
|
138
|
+
chain: "main" | "regtest";
|
|
139
|
+
startHeight: number;
|
|
140
|
+
}
|
|
141
|
+
export interface ManagedCoreWalletReplicaStatus {
|
|
142
|
+
walletRootId: string;
|
|
143
|
+
walletName: string;
|
|
144
|
+
loaded: boolean;
|
|
145
|
+
descriptors: boolean;
|
|
146
|
+
privateKeysEnabled: boolean;
|
|
147
|
+
created: boolean;
|
|
148
|
+
proofStatus?: "not-proven" | "ready" | "missing" | "mismatch";
|
|
149
|
+
descriptorChecksum?: string | null;
|
|
150
|
+
fundingAddress0?: string | null;
|
|
151
|
+
fundingScriptPubKeyHex0?: string | null;
|
|
152
|
+
message?: string | null;
|
|
153
|
+
}
|
|
154
|
+
export declare const INDEXER_DAEMON_SERVICE_API_VERSION = "cogcoin/indexer-ipc/v1";
|
|
155
|
+
export declare const INDEXER_DAEMON_SCHEMA_VERSION = "cogcoin/indexer-db/v1";
|
|
156
|
+
export type ManagedIndexerTruthSource = "lease" | "probe" | "status-file" | "none";
|
|
157
|
+
export type ManagedIndexerDaemonState = "starting" | "catching-up" | "reorging" | "synced" | "stopping" | "failed" | "schema-mismatch" | "service-version-mismatch";
|
|
158
|
+
export interface ManagedIndexerDaemonRuntimeIdentity {
|
|
159
|
+
serviceApiVersion: typeof INDEXER_DAEMON_SERVICE_API_VERSION;
|
|
160
|
+
schemaVersion: typeof INDEXER_DAEMON_SCHEMA_VERSION;
|
|
161
|
+
walletRootId: string;
|
|
162
|
+
daemonInstanceId: string;
|
|
163
|
+
processId: number | null;
|
|
164
|
+
startedAtUnixMs: number;
|
|
165
|
+
}
|
|
166
|
+
export interface ManagedIndexerSnapshotIdentity extends ManagedIndexerDaemonRuntimeIdentity {
|
|
167
|
+
snapshotSeq: string | null;
|
|
168
|
+
tipHeight: number | null;
|
|
169
|
+
tipHash: string | null;
|
|
170
|
+
openedAtUnixMs: number;
|
|
171
|
+
}
|
|
172
|
+
export interface ManagedIndexerDaemonStatus {
|
|
173
|
+
serviceApiVersion: typeof INDEXER_DAEMON_SERVICE_API_VERSION;
|
|
174
|
+
binaryVersion: string;
|
|
175
|
+
buildId: string | null;
|
|
176
|
+
updatedAtUnixMs: number;
|
|
177
|
+
walletRootId: string;
|
|
178
|
+
daemonInstanceId: string;
|
|
179
|
+
schemaVersion: typeof INDEXER_DAEMON_SCHEMA_VERSION;
|
|
180
|
+
state: ManagedIndexerDaemonState;
|
|
181
|
+
processId: number | null;
|
|
182
|
+
startedAtUnixMs: number;
|
|
183
|
+
heartbeatAtUnixMs: number;
|
|
184
|
+
ipcReady: boolean;
|
|
185
|
+
rpcReachable: boolean;
|
|
186
|
+
coreBestHeight: number | null;
|
|
187
|
+
coreBestHash: string | null;
|
|
188
|
+
appliedTipHeight: number | null;
|
|
189
|
+
appliedTipHash: string | null;
|
|
190
|
+
snapshotSeq: string | null;
|
|
191
|
+
backlogBlocks: number | null;
|
|
192
|
+
reorgDepth: number | null;
|
|
193
|
+
lastAppliedAtUnixMs: number | null;
|
|
194
|
+
activeSnapshotCount: number;
|
|
195
|
+
lastError: string | null;
|
|
196
|
+
}
|
|
197
|
+
export interface ManagedIndexerDaemonObservedStatus extends Omit<ManagedIndexerDaemonStatus, "serviceApiVersion" | "schemaVersion"> {
|
|
198
|
+
serviceApiVersion: string;
|
|
199
|
+
schemaVersion: string;
|
|
200
|
+
}
|
|
201
|
+
export interface RpcBlockchainInfo {
|
|
202
|
+
chain: string;
|
|
203
|
+
blocks: number;
|
|
204
|
+
headers: number;
|
|
205
|
+
bestblockhash: string;
|
|
206
|
+
pruned: boolean;
|
|
207
|
+
verificationprogress?: number;
|
|
208
|
+
initialblockdownload?: boolean;
|
|
209
|
+
}
|
|
210
|
+
export interface RpcNetworkInfo {
|
|
211
|
+
networkactive: boolean;
|
|
212
|
+
connections: number;
|
|
213
|
+
connections_in?: number;
|
|
214
|
+
connections_out?: number;
|
|
215
|
+
}
|
|
216
|
+
export interface RpcZmqNotification {
|
|
217
|
+
type: string;
|
|
218
|
+
address: string;
|
|
219
|
+
hwm: number;
|
|
220
|
+
}
|
|
221
|
+
export interface RpcVout {
|
|
222
|
+
value: number | string;
|
|
223
|
+
n: number;
|
|
224
|
+
scriptPubKey?: {
|
|
225
|
+
hex?: string;
|
|
226
|
+
address?: string;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
export interface RpcPrevout {
|
|
230
|
+
scriptPubKey?: {
|
|
231
|
+
hex?: string;
|
|
232
|
+
address?: string;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export interface RpcVin {
|
|
236
|
+
txid?: string;
|
|
237
|
+
coinbase?: string;
|
|
238
|
+
prevout?: RpcPrevout;
|
|
239
|
+
}
|
|
240
|
+
export interface RpcTransaction {
|
|
241
|
+
txid: string;
|
|
242
|
+
hash?: string;
|
|
243
|
+
vin: RpcVin[];
|
|
244
|
+
vout: RpcVout[];
|
|
245
|
+
}
|
|
246
|
+
export interface RpcMempoolInfo {
|
|
247
|
+
loaded: boolean;
|
|
248
|
+
size?: number;
|
|
249
|
+
}
|
|
250
|
+
export interface RpcMempoolEntry {
|
|
251
|
+
vsize: number;
|
|
252
|
+
fees: {
|
|
253
|
+
base: number;
|
|
254
|
+
ancestor: number;
|
|
255
|
+
descendant: number;
|
|
256
|
+
};
|
|
257
|
+
ancestorsize?: number;
|
|
258
|
+
descendantsize?: number;
|
|
259
|
+
}
|
|
260
|
+
export interface RpcRawMempoolVerbose {
|
|
261
|
+
txids: string[];
|
|
262
|
+
mempool_sequence: string | number;
|
|
263
|
+
}
|
|
264
|
+
export interface RpcWalletTransaction {
|
|
265
|
+
txid: string;
|
|
266
|
+
walletconflicts?: string[];
|
|
267
|
+
confirmations: number;
|
|
268
|
+
blockhash?: string;
|
|
269
|
+
blockheight?: number;
|
|
270
|
+
time?: number;
|
|
271
|
+
timereceived?: number;
|
|
272
|
+
}
|
|
273
|
+
export interface RpcBlock {
|
|
274
|
+
hash: string;
|
|
275
|
+
previousblockhash?: string;
|
|
276
|
+
height: number;
|
|
277
|
+
time?: number;
|
|
278
|
+
tx: RpcTransaction[];
|
|
279
|
+
}
|
|
280
|
+
export interface RpcChainState {
|
|
281
|
+
blocks?: number;
|
|
282
|
+
validated?: boolean;
|
|
283
|
+
snapshot_blockhash?: string;
|
|
284
|
+
verificationprogress?: number;
|
|
285
|
+
}
|
|
286
|
+
export interface RpcChainStatesResponse {
|
|
287
|
+
chainstates: RpcChainState[];
|
|
288
|
+
headers?: number;
|
|
289
|
+
}
|
|
290
|
+
export interface RpcLoadTxOutSetResult {
|
|
291
|
+
coins_loaded: number;
|
|
292
|
+
base_height: number;
|
|
293
|
+
tip_hash: string;
|
|
294
|
+
}
|
|
295
|
+
export interface RpcCreateWalletResult {
|
|
296
|
+
name: string;
|
|
297
|
+
warning: string;
|
|
298
|
+
}
|
|
299
|
+
export interface RpcLoadWalletResult {
|
|
300
|
+
name: string;
|
|
301
|
+
warning: string;
|
|
302
|
+
}
|
|
303
|
+
export interface RpcWalletInfo {
|
|
304
|
+
walletname: string;
|
|
305
|
+
private_keys_enabled: boolean;
|
|
306
|
+
descriptors: boolean;
|
|
307
|
+
unlocked_until?: number;
|
|
308
|
+
}
|
|
309
|
+
export interface RpcDescriptorInfo {
|
|
310
|
+
descriptor: string;
|
|
311
|
+
checksum: string;
|
|
312
|
+
isrange: boolean;
|
|
313
|
+
issolvable: boolean;
|
|
314
|
+
hasprivatekeys: boolean;
|
|
315
|
+
}
|
|
316
|
+
export interface RpcListDescriptorsEntry {
|
|
317
|
+
desc: string;
|
|
318
|
+
active?: boolean;
|
|
319
|
+
internal?: boolean;
|
|
320
|
+
next?: number;
|
|
321
|
+
range?: number | [number, number];
|
|
322
|
+
timestamp?: number | string;
|
|
323
|
+
}
|
|
324
|
+
export interface RpcListDescriptorsResult {
|
|
325
|
+
wallet_name?: string;
|
|
326
|
+
descriptors: RpcListDescriptorsEntry[];
|
|
327
|
+
}
|
|
328
|
+
export interface RpcImportDescriptorRequest {
|
|
329
|
+
desc: string;
|
|
330
|
+
timestamp: string | number;
|
|
331
|
+
active?: boolean;
|
|
332
|
+
internal?: boolean;
|
|
333
|
+
next_index?: number;
|
|
334
|
+
range?: number | [number, number];
|
|
335
|
+
label?: string;
|
|
336
|
+
}
|
|
337
|
+
export interface RpcImportDescriptorResult {
|
|
338
|
+
success: boolean;
|
|
339
|
+
warnings?: string[];
|
|
340
|
+
error?: {
|
|
341
|
+
code: number;
|
|
342
|
+
message: string;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
export interface RpcWalletProcessPsbtResult {
|
|
346
|
+
psbt: string;
|
|
347
|
+
complete: boolean;
|
|
348
|
+
}
|
|
349
|
+
export interface RpcWalletCreateFundedPsbtResult {
|
|
350
|
+
psbt: string;
|
|
351
|
+
fee: number;
|
|
352
|
+
changepos: number;
|
|
353
|
+
}
|
|
354
|
+
export interface RpcLockedUnspent {
|
|
355
|
+
txid: string;
|
|
356
|
+
vout: number;
|
|
357
|
+
}
|
|
358
|
+
export interface RpcListUnspentEntry {
|
|
359
|
+
txid: string;
|
|
360
|
+
vout: number;
|
|
361
|
+
address?: string;
|
|
362
|
+
scriptPubKey: string;
|
|
363
|
+
amount: number;
|
|
364
|
+
confirmations: number;
|
|
365
|
+
spendable?: boolean;
|
|
366
|
+
solvable?: boolean;
|
|
367
|
+
safe?: boolean;
|
|
368
|
+
}
|
|
369
|
+
export interface RpcDecodedPsbt {
|
|
370
|
+
tx: RpcTransaction;
|
|
371
|
+
}
|
|
372
|
+
export interface RpcFinalizePsbtResult {
|
|
373
|
+
psbt?: string;
|
|
374
|
+
hex?: string;
|
|
375
|
+
complete: boolean;
|
|
376
|
+
}
|
|
377
|
+
export interface RpcTestMempoolAcceptResult {
|
|
378
|
+
txid?: string;
|
|
379
|
+
wtxid?: string;
|
|
380
|
+
allowed: boolean;
|
|
381
|
+
"reject-reason"?: string;
|
|
382
|
+
}
|
|
383
|
+
export interface ManagedBitcoindNodeHandle {
|
|
384
|
+
rpc: BitcoindRpcConfig;
|
|
385
|
+
zmq: BitcoindZmqConfig;
|
|
386
|
+
pid: number | null;
|
|
387
|
+
expectedChain: "main" | "regtest";
|
|
388
|
+
startHeight: number;
|
|
389
|
+
dataDir: string;
|
|
390
|
+
walletRootId?: string;
|
|
391
|
+
runtimeRoot?: string;
|
|
392
|
+
validate(): Promise<void>;
|
|
393
|
+
refreshServiceStatus?(): Promise<ManagedBitcoindServiceStatus>;
|
|
394
|
+
stop(): Promise<void>;
|
|
395
|
+
}
|
|
396
|
+
export type { BitcoinBlock };
|
package/dist/bytes.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
2
|
+
export declare function hexToBytes(hex: string): Uint8Array;
|
|
3
|
+
export declare function cloneBytes(bytes: Uint8Array): Uint8Array;
|
|
4
|
+
export declare function encodeText(value: string): Uint8Array;
|
|
5
|
+
export declare function decodeText(bytes: Uint8Array): string;
|
|
6
|
+
export declare function encodeNullableText(value: string | null): Uint8Array;
|
|
7
|
+
export declare function decodeNullableText(bytes: Uint8Array): string | null;
|
|
8
|
+
export declare function encodeInteger(value: number): Uint8Array;
|
|
9
|
+
export declare function decodeInteger(bytes: Uint8Array): number;
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const textEncoder = new TextEncoder();
|
|
2
|
+
const textDecoder = new TextDecoder();
|
|
3
|
+
export function bytesToHex(bytes) {
|
|
4
|
+
return Buffer.from(bytes).toString("hex");
|
|
5
|
+
}
|
|
6
|
+
export function hexToBytes(hex) {
|
|
7
|
+
return new Uint8Array(Buffer.from(hex, "hex"));
|
|
8
|
+
}
|
|
9
|
+
export function cloneBytes(bytes) {
|
|
10
|
+
return new Uint8Array(bytes);
|
|
11
|
+
}
|
|
12
|
+
export function encodeText(value) {
|
|
13
|
+
return textEncoder.encode(value);
|
|
14
|
+
}
|
|
15
|
+
export function decodeText(bytes) {
|
|
16
|
+
return textDecoder.decode(bytes);
|
|
17
|
+
}
|
|
18
|
+
export function encodeNullableText(value) {
|
|
19
|
+
return encodeText(value ?? "");
|
|
20
|
+
}
|
|
21
|
+
export function decodeNullableText(bytes) {
|
|
22
|
+
if (bytes.length === 0) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return decodeText(bytes);
|
|
26
|
+
}
|
|
27
|
+
export function encodeInteger(value) {
|
|
28
|
+
return encodeText(String(value));
|
|
29
|
+
}
|
|
30
|
+
export function decodeInteger(bytes) {
|
|
31
|
+
const decoded = Number.parseInt(decodeText(bytes), 10);
|
|
32
|
+
if (!Number.isSafeInteger(decoded)) {
|
|
33
|
+
throw new Error("sqlite_meta_integer_invalid");
|
|
34
|
+
}
|
|
35
|
+
return decoded;
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { usesTtyProgress, writeLine } from "../io.js";
|
|
3
|
+
import { classifyCliError } from "../output.js";
|
|
4
|
+
import { createStopSignalWatcher } from "../signals.js";
|
|
5
|
+
export async function runFollowCommand(parsed, context) {
|
|
6
|
+
const dbPath = parsed.dbPath ?? context.resolveDefaultClientDatabasePath();
|
|
7
|
+
const dataDir = parsed.dataDir ?? context.resolveDefaultBitcoindDataDir();
|
|
8
|
+
await context.ensureDirectory(dirname(dbPath));
|
|
9
|
+
const store = await context.openSqliteStore({ filename: dbPath });
|
|
10
|
+
let storeOwned = true;
|
|
11
|
+
try {
|
|
12
|
+
const client = await context.openManagedBitcoindClient({
|
|
13
|
+
store,
|
|
14
|
+
databasePath: dbPath,
|
|
15
|
+
dataDir,
|
|
16
|
+
progressOutput: parsed.progressOutput,
|
|
17
|
+
});
|
|
18
|
+
storeOwned = false;
|
|
19
|
+
const stopWatcher = createStopSignalWatcher(context.signalSource, context.stderr, client, context.forceExit);
|
|
20
|
+
try {
|
|
21
|
+
await client.startFollowingTip();
|
|
22
|
+
if (!usesTtyProgress(parsed.progressOutput, context.stderr)) {
|
|
23
|
+
writeLine(context.stdout, "Following managed Cogcoin tip. Press Ctrl-C to stop.");
|
|
24
|
+
}
|
|
25
|
+
return await stopWatcher.promise;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
writeLine(context.stderr, `follow failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
29
|
+
await client.close().catch(() => undefined);
|
|
30
|
+
return classifyCliError(error).exitCode;
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
stopWatcher.cleanup();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
writeLine(context.stderr, `follow failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
38
|
+
if (storeOwned) {
|
|
39
|
+
await store.close().catch(() => undefined);
|
|
40
|
+
}
|
|
41
|
+
return classifyCliError(error).exitCode;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { buildHooksDisableMiningData, buildHooksEnableMiningData, buildMineSetupData, } from "../mining-json.js";
|
|
2
|
+
import { buildHooksPreviewData } from "../preview-json.js";
|
|
3
|
+
import { writeLine } from "../io.js";
|
|
4
|
+
import { createTerminalPrompter } from "../prompt.js";
|
|
5
|
+
import { createPreviewSuccessEnvelope, createMutationSuccessEnvelope, describeCanonicalCommand, resolvePreviewJsonSchema, resolveStableMiningControlJsonSchema, writeHandledCliError, writeJsonValue, } from "../output.js";
|
|
6
|
+
import { formatNextStepLines, getHooksEnableMiningNextSteps, getMineSetupNextSteps, } from "../workflow-hints.js";
|
|
7
|
+
function createCommandPrompter(parsed, context) {
|
|
8
|
+
return parsed.outputMode !== "text"
|
|
9
|
+
? createTerminalPrompter(context.stdin, context.stderr)
|
|
10
|
+
: context.createPrompter();
|
|
11
|
+
}
|
|
12
|
+
export async function runMiningAdminCommand(parsed, context) {
|
|
13
|
+
try {
|
|
14
|
+
const provider = context.walletSecretProvider;
|
|
15
|
+
if (parsed.command === "hooks-mining-enable") {
|
|
16
|
+
const prompter = createCommandPrompter(parsed, context);
|
|
17
|
+
const view = await context.enableMiningHooks({
|
|
18
|
+
provider,
|
|
19
|
+
prompter,
|
|
20
|
+
});
|
|
21
|
+
const nextSteps = getHooksEnableMiningNextSteps();
|
|
22
|
+
if (parsed.outputMode === "preview-json") {
|
|
23
|
+
writeJsonValue(context.stdout, createPreviewSuccessEnvelope(resolvePreviewJsonSchema(parsed), describeCanonicalCommand(parsed), "enabled", buildHooksPreviewData("hooks-enable-mining", view), {
|
|
24
|
+
nextSteps,
|
|
25
|
+
}));
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
if (parsed.outputMode === "json") {
|
|
29
|
+
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMiningControlJsonSchema(parsed), "cogcoin hooks enable mining", "enabled", buildHooksEnableMiningData(view), {
|
|
30
|
+
nextSteps,
|
|
31
|
+
}));
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
writeLine(context.stdout, "Custom mining hook enabled.");
|
|
35
|
+
for (const line of formatNextStepLines(nextSteps)) {
|
|
36
|
+
writeLine(context.stdout, line);
|
|
37
|
+
}
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
if (parsed.command === "hooks-mining-disable") {
|
|
41
|
+
const view = await context.disableMiningHooks({
|
|
42
|
+
provider,
|
|
43
|
+
});
|
|
44
|
+
if (parsed.outputMode === "preview-json") {
|
|
45
|
+
writeJsonValue(context.stdout, createPreviewSuccessEnvelope(resolvePreviewJsonSchema(parsed), describeCanonicalCommand(parsed), "disabled", buildHooksPreviewData("hooks-disable-mining", view)));
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
if (parsed.outputMode === "json") {
|
|
49
|
+
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMiningControlJsonSchema(parsed), "cogcoin hooks disable mining", "disabled", buildHooksDisableMiningData(view)));
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
writeLine(context.stdout, "Mining hooks switched back to builtin mode.");
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
if (parsed.command === "mine-setup") {
|
|
56
|
+
const prompter = createCommandPrompter(parsed, context);
|
|
57
|
+
const view = await context.setupBuiltInMining({
|
|
58
|
+
provider,
|
|
59
|
+
prompter,
|
|
60
|
+
});
|
|
61
|
+
const nextSteps = getMineSetupNextSteps();
|
|
62
|
+
if (parsed.outputMode === "preview-json") {
|
|
63
|
+
writeJsonValue(context.stdout, createPreviewSuccessEnvelope(resolvePreviewJsonSchema(parsed), describeCanonicalCommand(parsed), "configured", buildHooksPreviewData("mine-setup", view), {
|
|
64
|
+
nextSteps,
|
|
65
|
+
}));
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
if (parsed.outputMode === "json") {
|
|
69
|
+
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMiningControlJsonSchema(parsed), "cogcoin mine setup", "configured", buildMineSetupData(view), {
|
|
70
|
+
nextSteps,
|
|
71
|
+
}));
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
writeLine(context.stdout, "Built-in mining provider configured.");
|
|
75
|
+
writeLine(context.stdout, `Provider: ${view.provider.provider ?? "unknown"}`);
|
|
76
|
+
for (const line of formatNextStepLines(nextSteps)) {
|
|
77
|
+
writeLine(context.stdout, line);
|
|
78
|
+
}
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
writeLine(context.stderr, `mining admin command not implemented: ${parsed.command}`);
|
|
82
|
+
return 1;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return writeHandledCliError({
|
|
86
|
+
parsed,
|
|
87
|
+
stdout: context.stdout,
|
|
88
|
+
stderr: context.stderr,
|
|
89
|
+
error,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|