@cogcoin/client 0.5.5 → 0.5.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.
- package/README.md +11 -2
- package/dist/bitcoind/bootstrap/chainstate.d.ts +2 -1
- package/dist/bitcoind/bootstrap/chainstate.js +4 -1
- package/dist/bitcoind/bootstrap/controller.d.ts +4 -1
- package/dist/bitcoind/bootstrap/controller.js +42 -5
- package/dist/bitcoind/bootstrap/getblock-archive.d.ts +39 -0
- package/dist/bitcoind/bootstrap/getblock-archive.js +548 -0
- package/dist/bitcoind/bootstrap/headers.d.ts +12 -0
- package/dist/bitcoind/bootstrap/headers.js +95 -10
- package/dist/bitcoind/bootstrap.d.ts +1 -0
- package/dist/bitcoind/bootstrap.js +1 -0
- package/dist/bitcoind/client/factory.js +91 -28
- package/dist/bitcoind/client/managed-client.d.ts +1 -1
- package/dist/bitcoind/client/managed-client.js +4 -3
- package/dist/bitcoind/client/sync-engine.js +55 -13
- package/dist/bitcoind/errors.js +18 -0
- package/dist/bitcoind/indexer-daemon-main.js +78 -0
- package/dist/bitcoind/indexer-daemon.d.ts +10 -1
- package/dist/bitcoind/indexer-daemon.js +44 -28
- package/dist/bitcoind/node.js +2 -0
- package/dist/bitcoind/processing-start-height.d.ts +7 -0
- package/dist/bitcoind/processing-start-height.js +9 -0
- package/dist/bitcoind/progress/constants.d.ts +1 -0
- package/dist/bitcoind/progress/constants.js +1 -0
- package/dist/bitcoind/progress/controller.d.ts +22 -0
- package/dist/bitcoind/progress/controller.js +49 -23
- package/dist/bitcoind/progress/formatting.js +29 -1
- package/dist/bitcoind/progress/render-policy.d.ts +35 -0
- package/dist/bitcoind/progress/render-policy.js +81 -0
- package/dist/bitcoind/retryable-rpc.d.ts +11 -0
- package/dist/bitcoind/retryable-rpc.js +30 -0
- package/dist/bitcoind/service-paths.js +2 -6
- package/dist/bitcoind/service.d.ts +21 -2
- package/dist/bitcoind/service.js +274 -122
- package/dist/bitcoind/testing.d.ts +2 -2
- package/dist/bitcoind/testing.js +2 -2
- package/dist/bitcoind/types.d.ts +36 -1
- package/dist/cli/commands/follow.js +11 -0
- package/dist/cli/commands/getblock-archive-restart.d.ts +5 -0
- package/dist/cli/commands/getblock-archive-restart.js +15 -0
- package/dist/cli/commands/mining-admin.js +4 -0
- package/dist/cli/commands/mining-read.js +8 -5
- package/dist/cli/commands/mining-runtime.js +4 -0
- package/dist/cli/commands/service-runtime.js +150 -134
- package/dist/cli/commands/status.js +2 -0
- package/dist/cli/commands/sync.js +11 -0
- package/dist/cli/commands/wallet-admin.js +106 -24
- package/dist/cli/commands/wallet-mutation.js +57 -4
- package/dist/cli/commands/wallet-read.js +2 -0
- package/dist/cli/context.js +8 -4
- package/dist/cli/mutation-command-groups.d.ts +2 -1
- package/dist/cli/mutation-command-groups.js +5 -0
- package/dist/cli/mutation-json.d.ts +18 -2
- package/dist/cli/mutation-json.js +49 -0
- package/dist/cli/mutation-success.d.ts +1 -0
- package/dist/cli/mutation-success.js +2 -2
- package/dist/cli/output.js +86 -1
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.js +133 -3
- package/dist/cli/preview-json.d.ts +10 -1
- package/dist/cli/preview-json.js +32 -0
- package/dist/cli/prompt.js +1 -1
- package/dist/cli/runner.js +4 -0
- package/dist/cli/types.d.ts +15 -5
- package/dist/cli/types.js +1 -1
- package/dist/cli/wallet-format.js +140 -14
- package/dist/wallet/lifecycle.d.ts +21 -1
- package/dist/wallet/lifecycle.js +252 -116
- package/dist/wallet/mining/visualizer.d.ts +11 -6
- package/dist/wallet/mining/visualizer.js +32 -15
- package/dist/wallet/read/context.js +10 -4
- package/dist/wallet/reset.d.ts +61 -2
- package/dist/wallet/reset.js +246 -89
- package/dist/wallet/root-resolution.d.ts +20 -0
- package/dist/wallet/root-resolution.js +37 -0
- package/dist/wallet/runtime.d.ts +13 -1
- package/dist/wallet/runtime.js +54 -11
- package/dist/wallet/state/crypto.d.ts +3 -0
- package/dist/wallet/state/crypto.js +3 -0
- package/dist/wallet/state/provider.d.ts +1 -0
- package/dist/wallet/state/provider.js +119 -3
- package/dist/wallet/state/seed-index.d.ts +43 -0
- package/dist/wallet/state/seed-index.js +151 -0
- package/dist/wallet/state/storage.d.ts +7 -1
- package/dist/wallet/state/storage.js +39 -0
- package/dist/wallet/tx/anchor.d.ts +22 -0
- package/dist/wallet/tx/anchor.js +215 -8
- package/dist/wallet/tx/index.d.ts +1 -1
- package/dist/wallet/tx/index.js +1 -1
- package/dist/wallet/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,11 +4,13 @@ import { attachOrStartIndexerDaemon, probeIndexerDaemon, readObservedIndexerDaem
|
|
|
4
4
|
import { createRpcClient } from "../../bitcoind/node.js";
|
|
5
5
|
import { UNINITIALIZED_WALLET_ROOT_ID } from "../../bitcoind/service-paths.js";
|
|
6
6
|
import { attachOrStartManagedBitcoindService, probeManagedBitcoindService, } from "../../bitcoind/service.js";
|
|
7
|
+
import { resolveCogcoinProcessingStartHeight } from "../../bitcoind/processing-start-height.js";
|
|
7
8
|
import {} from "../../bitcoind/types.js";
|
|
8
9
|
import { loadOrAutoUnlockWalletState, verifyManagedCoreWalletReplica, } from "../lifecycle.js";
|
|
9
10
|
import { persistNormalizedWalletDescriptorStateIfNeeded } from "../descriptor-normalization.js";
|
|
10
11
|
import { inspectMiningControlPlane } from "../mining/index.js";
|
|
11
12
|
import { normalizeMiningStateRecord } from "../mining/state.js";
|
|
13
|
+
import { resolveWalletRootIdFromLocalArtifacts } from "../root-resolution.js";
|
|
12
14
|
import { resolveWalletRuntimePathsForTesting } from "../runtime.js";
|
|
13
15
|
import { loadWalletExplicitLock } from "../state/explicit-lock.js";
|
|
14
16
|
import { loadWalletState } from "../state/storage.js";
|
|
@@ -86,6 +88,7 @@ async function normalizeLoadedWalletStateForRead(options) {
|
|
|
86
88
|
async function inspectWalletLocalState(options = {}) {
|
|
87
89
|
const paths = options.paths ?? resolveWalletRuntimePathsForTesting();
|
|
88
90
|
const now = options.now ?? Date.now();
|
|
91
|
+
const provider = options.secretProvider ?? createDefaultWalletSecretProvider();
|
|
89
92
|
const [hasPrimaryStateFile, hasBackupStateFile, hasUnlockSessionFile] = await Promise.all([
|
|
90
93
|
pathExists(paths.walletStatePath),
|
|
91
94
|
pathExists(paths.walletStateBackupPath),
|
|
@@ -106,7 +109,6 @@ async function inspectWalletLocalState(options = {}) {
|
|
|
106
109
|
}
|
|
107
110
|
if (options.passphrase === undefined) {
|
|
108
111
|
try {
|
|
109
|
-
const provider = options.secretProvider ?? createDefaultWalletSecretProvider();
|
|
110
112
|
const unlocked = await loadOrAutoUnlockWalletState({
|
|
111
113
|
provider,
|
|
112
114
|
nowUnixMs: now,
|
|
@@ -147,10 +149,14 @@ async function inspectWalletLocalState(options = {}) {
|
|
|
147
149
|
};
|
|
148
150
|
}
|
|
149
151
|
catch (error) {
|
|
152
|
+
const resolvedRoot = await resolveWalletRootIdFromLocalArtifacts({
|
|
153
|
+
paths,
|
|
154
|
+
provider,
|
|
155
|
+
}).catch(() => null);
|
|
150
156
|
if (isLockedWalletAccessError(error)) {
|
|
151
157
|
return {
|
|
152
158
|
availability: "locked",
|
|
153
|
-
walletRootId: null,
|
|
159
|
+
walletRootId: resolvedRoot?.walletRootId ?? null,
|
|
154
160
|
state: null,
|
|
155
161
|
source: null,
|
|
156
162
|
unlockUntilUnixMs: null,
|
|
@@ -166,7 +172,7 @@ async function inspectWalletLocalState(options = {}) {
|
|
|
166
172
|
}
|
|
167
173
|
return {
|
|
168
174
|
availability: "local-state-corrupt",
|
|
169
|
-
walletRootId: null,
|
|
175
|
+
walletRootId: resolvedRoot?.walletRootId ?? null,
|
|
170
176
|
state: null,
|
|
171
177
|
source: null,
|
|
172
178
|
unlockUntilUnixMs: null,
|
|
@@ -461,7 +467,7 @@ async function attachNodeStatus(options) {
|
|
|
461
467
|
const handle = await attachOrStartManagedBitcoindService({
|
|
462
468
|
dataDir: options.dataDir,
|
|
463
469
|
chain: "main",
|
|
464
|
-
startHeight: genesis
|
|
470
|
+
startHeight: resolveCogcoinProcessingStartHeight(genesis),
|
|
465
471
|
walletRootId: options.walletRootId,
|
|
466
472
|
startupTimeoutMs: options.startupTimeoutMs,
|
|
467
473
|
});
|
package/dist/wallet/reset.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { createRpcClient } from "../bitcoind/node.js";
|
|
2
|
+
import { attachOrStartManagedBitcoindService } from "../bitcoind/service.js";
|
|
1
3
|
import { type WalletRuntimePaths } from "./runtime.js";
|
|
2
4
|
import { type WalletSecretProvider } from "./state/provider.js";
|
|
3
5
|
import type { WalletPrompter } from "./lifecycle.js";
|
|
4
|
-
export type WalletResetAction = "not-present" | "kept-unchanged" | "
|
|
6
|
+
export type WalletResetAction = "not-present" | "kept-unchanged" | "retain-mnemonic" | "deleted";
|
|
5
7
|
export type WalletResetSecretCleanupStatus = "deleted" | "not-found" | "failed" | "unknown";
|
|
6
8
|
export type WalletResetSnapshotResultStatus = "not-present" | "invalid-removed" | "deleted" | "preserved";
|
|
9
|
+
export type WalletResetBitcoinDataDirResultStatus = "not-present" | "preserved" | "deleted" | "outside-reset-scope";
|
|
7
10
|
export interface WalletResetResult {
|
|
8
11
|
dataRoot: string;
|
|
9
12
|
factoryResetReady: true;
|
|
@@ -24,13 +27,17 @@ export interface WalletResetResult {
|
|
|
24
27
|
status: WalletResetSnapshotResultStatus;
|
|
25
28
|
path: string;
|
|
26
29
|
};
|
|
30
|
+
bitcoinDataDir: {
|
|
31
|
+
status: WalletResetBitcoinDataDirResultStatus;
|
|
32
|
+
path: string;
|
|
33
|
+
};
|
|
27
34
|
removedPaths: string[];
|
|
28
35
|
}
|
|
29
36
|
export interface WalletResetPreview {
|
|
30
37
|
dataRoot: string;
|
|
31
38
|
confirmationPhrase: "permanently reset";
|
|
32
39
|
walletPrompt: null | {
|
|
33
|
-
defaultAction: "
|
|
40
|
+
defaultAction: "retain-mnemonic";
|
|
34
41
|
acceptedInputs: ["", "skip", "delete wallet"];
|
|
35
42
|
entropyRetainingResetAvailable: boolean;
|
|
36
43
|
requiresPassphrase: boolean;
|
|
@@ -41,10 +48,59 @@ export interface WalletResetPreview {
|
|
|
41
48
|
path: string;
|
|
42
49
|
defaultAction: "preserve" | "delete";
|
|
43
50
|
};
|
|
51
|
+
bitcoinDataDir: {
|
|
52
|
+
status: "not-present" | "within-reset-scope" | "outside-reset-scope";
|
|
53
|
+
path: string;
|
|
54
|
+
conditionalPrompt: null | {
|
|
55
|
+
prompt: "Delete managed Bitcoin datadir too? [y/N]: ";
|
|
56
|
+
defaultAction: "preserve";
|
|
57
|
+
acceptedInputs: ["", "n", "no", "y", "yes"];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
44
60
|
trackedProcessKinds: Array<"managed-bitcoind" | "indexer-daemon" | "background-mining">;
|
|
45
61
|
willDeleteOsSecrets: boolean;
|
|
46
62
|
removedPaths: string[];
|
|
47
63
|
}
|
|
64
|
+
interface ResetWalletRpcClient {
|
|
65
|
+
getDescriptorInfo(descriptor: string): Promise<{
|
|
66
|
+
descriptor: string;
|
|
67
|
+
checksum: string;
|
|
68
|
+
}>;
|
|
69
|
+
createWallet(walletName: string, options: {
|
|
70
|
+
blank: boolean;
|
|
71
|
+
descriptors: boolean;
|
|
72
|
+
disablePrivateKeys: boolean;
|
|
73
|
+
loadOnStartup: boolean;
|
|
74
|
+
passphrase: string;
|
|
75
|
+
}): Promise<unknown>;
|
|
76
|
+
walletPassphrase(walletName: string, passphrase: string, timeoutSeconds: number): Promise<null>;
|
|
77
|
+
importDescriptors(walletName: string, requests: Array<{
|
|
78
|
+
desc: string;
|
|
79
|
+
timestamp: string | number;
|
|
80
|
+
active?: boolean;
|
|
81
|
+
internal?: boolean;
|
|
82
|
+
range?: number | [number, number];
|
|
83
|
+
}>): Promise<Array<{
|
|
84
|
+
success: boolean;
|
|
85
|
+
}>>;
|
|
86
|
+
walletLock(walletName: string): Promise<null>;
|
|
87
|
+
deriveAddresses(descriptor: string, range?: number | [number, number]): Promise<string[]>;
|
|
88
|
+
listDescriptors(walletName: string, privateOnly?: boolean): Promise<{
|
|
89
|
+
descriptors: Array<{
|
|
90
|
+
desc: string;
|
|
91
|
+
}>;
|
|
92
|
+
}>;
|
|
93
|
+
getWalletInfo(walletName: string): Promise<{
|
|
94
|
+
walletname: string;
|
|
95
|
+
private_keys_enabled: boolean;
|
|
96
|
+
descriptors: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
loadWallet(walletName: string, loadOnStartup?: boolean): Promise<{
|
|
99
|
+
name: string;
|
|
100
|
+
warning: string;
|
|
101
|
+
}>;
|
|
102
|
+
listWallets(): Promise<string[]>;
|
|
103
|
+
}
|
|
48
104
|
export declare function previewResetWallet(options: {
|
|
49
105
|
dataDir: string;
|
|
50
106
|
provider?: WalletSecretProvider;
|
|
@@ -58,4 +114,7 @@ export declare function resetWallet(options: {
|
|
|
58
114
|
nowUnixMs?: number;
|
|
59
115
|
paths?: WalletRuntimePaths;
|
|
60
116
|
validateSnapshotFile?: (path: string) => Promise<void>;
|
|
117
|
+
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
118
|
+
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => ResetWalletRpcClient;
|
|
61
119
|
}): Promise<WalletResetResult>;
|
|
120
|
+
export {};
|