@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.
- package/README.md +2 -2
- package/dist/bitcoind/indexer-daemon.d.ts +3 -7
- package/dist/bitcoind/indexer-daemon.js +39 -204
- package/dist/bitcoind/managed-runtime/bitcoind-policy.d.ts +16 -0
- package/dist/bitcoind/managed-runtime/bitcoind-policy.js +177 -0
- package/dist/bitcoind/managed-runtime/bitcoind-runtime.d.ts +20 -0
- package/dist/bitcoind/managed-runtime/bitcoind-runtime.js +74 -0
- package/dist/bitcoind/managed-runtime/bitcoind-status.d.ts +11 -0
- package/dist/bitcoind/managed-runtime/bitcoind-status.js +44 -0
- package/dist/bitcoind/managed-runtime/indexer-policy.d.ts +34 -0
- package/dist/bitcoind/managed-runtime/indexer-policy.js +200 -0
- package/dist/bitcoind/managed-runtime/indexer-runtime.d.ts +15 -0
- package/dist/bitcoind/managed-runtime/indexer-runtime.js +82 -0
- package/dist/bitcoind/managed-runtime/status.d.ts +11 -0
- package/dist/bitcoind/managed-runtime/status.js +59 -0
- package/dist/bitcoind/managed-runtime/types.d.ts +77 -0
- package/dist/bitcoind/node.d.ts +2 -2
- package/dist/bitcoind/node.js +2 -2
- package/dist/bitcoind/rpc.d.ts +2 -1
- package/dist/bitcoind/rpc.js +53 -3
- package/dist/bitcoind/service.d.ts +2 -7
- package/dist/bitcoind/service.js +79 -207
- package/dist/cli/command-registry.d.ts +1 -1
- package/dist/cli/command-registry.js +2 -64
- package/dist/cli/commands/client-admin.js +3 -18
- package/dist/cli/commands/mining-runtime.js +4 -60
- package/dist/cli/commands/wallet-admin.js +6 -6
- package/dist/cli/context.js +1 -3
- package/dist/cli/mining-json.d.ts +1 -22
- package/dist/cli/mining-json.js +0 -23
- package/dist/cli/output.js +16 -2
- package/dist/cli/parse.js +0 -2
- package/dist/cli/preview-json.d.ts +1 -22
- package/dist/cli/preview-json.js +0 -19
- package/dist/cli/types.d.ts +1 -3
- package/dist/cli/wallet-format.js +1 -1
- package/dist/cli/workflow-hints.d.ts +1 -2
- package/dist/cli/workflow-hints.js +5 -8
- package/dist/wallet/lifecycle/access.d.ts +5 -0
- package/dist/wallet/lifecycle/access.js +79 -0
- package/dist/wallet/lifecycle/context.d.ts +26 -0
- package/dist/wallet/lifecycle/context.js +57 -0
- package/dist/wallet/lifecycle/managed-core.d.ts +1 -9
- package/dist/wallet/lifecycle/managed-core.js +3 -63
- package/dist/wallet/lifecycle/repair-bitcoind.d.ts +10 -0
- package/dist/wallet/lifecycle/repair-bitcoind.js +142 -0
- package/dist/wallet/lifecycle/repair-indexer.d.ts +8 -0
- package/dist/wallet/lifecycle/repair-indexer.js +117 -0
- package/dist/wallet/lifecycle/repair-mining.d.ts +1 -5
- package/dist/wallet/lifecycle/repair-mining.js +5 -39
- package/dist/wallet/lifecycle/repair.d.ts +2 -4
- package/dist/wallet/lifecycle/repair.js +74 -318
- package/dist/wallet/lifecycle/setup-prompts.d.ts +7 -0
- package/dist/wallet/lifecycle/setup-prompts.js +88 -0
- package/dist/wallet/lifecycle/setup-state.d.ts +26 -0
- package/dist/wallet/lifecycle/setup-state.js +159 -0
- package/dist/wallet/lifecycle/setup.d.ts +3 -4
- package/dist/wallet/lifecycle/setup.js +47 -351
- package/dist/wallet/lifecycle/types.d.ts +33 -5
- package/dist/wallet/managed-core-wallet.d.ts +2 -0
- package/dist/wallet/managed-core-wallet.js +27 -1
- package/dist/wallet/mining/candidate.d.ts +1 -0
- package/dist/wallet/mining/candidate.js +38 -6
- package/dist/wallet/mining/competitiveness.d.ts +1 -0
- package/dist/wallet/mining/competitiveness.js +6 -0
- package/dist/wallet/mining/cycle.d.ts +2 -0
- package/dist/wallet/mining/cycle.js +14 -4
- package/dist/wallet/mining/engine-types.d.ts +1 -0
- package/dist/wallet/mining/index.d.ts +1 -1
- package/dist/wallet/mining/index.js +1 -1
- package/dist/wallet/mining/publish.d.ts +3 -0
- package/dist/wallet/mining/publish.js +78 -6
- package/dist/wallet/mining/runner.d.ts +0 -32
- package/dist/wallet/mining/runner.js +59 -104
- package/dist/wallet/mining/stop.d.ts +7 -0
- package/dist/wallet/mining/stop.js +23 -0
- package/dist/wallet/mining/supervisor.d.ts +2 -36
- package/dist/wallet/mining/supervisor.js +139 -246
- package/dist/wallet/read/context.d.ts +1 -5
- package/dist/wallet/read/context.js +20 -379
- package/dist/wallet/read/managed-services.d.ts +33 -0
- package/dist/wallet/read/managed-services.js +222 -0
- package/dist/wallet/state/client-password/bootstrap.d.ts +2 -0
- package/dist/wallet/state/client-password/bootstrap.js +3 -0
- package/dist/wallet/state/client-password/context.d.ts +10 -0
- package/dist/wallet/state/client-password/context.js +46 -0
- package/dist/wallet/state/client-password/crypto.d.ts +34 -0
- package/dist/wallet/state/client-password/crypto.js +117 -0
- package/dist/wallet/state/client-password/files.d.ts +10 -0
- package/dist/wallet/state/client-password/files.js +109 -0
- package/dist/wallet/state/client-password/legacy-cleanup.d.ts +11 -0
- package/dist/wallet/state/client-password/legacy-cleanup.js +338 -0
- package/dist/wallet/state/client-password/messages.d.ts +3 -0
- package/dist/wallet/state/client-password/messages.js +9 -0
- package/dist/wallet/state/client-password/migration.d.ts +4 -0
- package/dist/wallet/state/client-password/migration.js +32 -0
- package/dist/wallet/state/client-password/prompts.d.ts +12 -0
- package/dist/wallet/state/client-password/prompts.js +79 -0
- package/dist/wallet/state/client-password/protected-secrets.d.ts +13 -0
- package/dist/wallet/state/client-password/protected-secrets.js +90 -0
- package/dist/wallet/state/client-password/readiness.d.ts +4 -0
- package/dist/wallet/state/client-password/readiness.js +48 -0
- package/dist/wallet/state/client-password/references.d.ts +1 -0
- package/dist/wallet/state/client-password/references.js +56 -0
- package/dist/wallet/state/client-password/rotation.d.ts +6 -0
- package/dist/wallet/state/client-password/rotation.js +98 -0
- package/dist/wallet/state/client-password/session-policy.d.ts +6 -0
- package/dist/wallet/state/client-password/session-policy.js +28 -0
- package/dist/wallet/state/client-password/session.d.ts +19 -0
- package/dist/wallet/state/client-password/session.js +170 -0
- package/dist/wallet/state/client-password/setup.d.ts +8 -0
- package/dist/wallet/state/client-password/setup.js +49 -0
- package/dist/wallet/state/client-password/types.d.ts +82 -0
- package/dist/wallet/state/client-password/types.js +5 -0
- package/dist/wallet/state/client-password.d.ts +7 -38
- package/dist/wallet/state/client-password.js +52 -937
- package/dist/wallet/tx/anchor.js +123 -216
- package/dist/wallet/tx/cog.js +294 -489
- package/dist/wallet/tx/common.d.ts +2 -0
- package/dist/wallet/tx/common.js +2 -0
- package/dist/wallet/tx/domain-admin.js +111 -220
- package/dist/wallet/tx/domain-market.js +401 -681
- package/dist/wallet/tx/executor.d.ts +176 -0
- package/dist/wallet/tx/executor.js +302 -0
- package/dist/wallet/tx/field.js +109 -215
- package/dist/wallet/tx/register.js +158 -269
- package/dist/wallet/tx/reputation.js +120 -227
- package/package.json +1 -1
- package/dist/wallet/mining/worker-main.js +0 -17
- package/dist/wallet/state/client-password-agent.d.ts +0 -1
- package/dist/wallet/state/client-password-agent.js +0 -211
- /package/dist/{wallet/mining/worker-main.d.ts → bitcoind/managed-runtime/types.js} +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { writeLine } from "../io.js";
|
|
2
2
|
import { writeHandledCliError } from "../output.js";
|
|
3
3
|
import { loadWelcomeArtText } from "../art.js";
|
|
4
|
-
import { formatNextStepLines, getFundingQuickstartGuidance,
|
|
4
|
+
import { formatNextStepLines, getFundingQuickstartGuidance, getInitUnlockGuidanceLines, getInitNextSteps, } from "../workflow-hints.js";
|
|
5
5
|
import { createOwnedLockCleanupSignalWatcher, waitForCompletionOrStop, } from "../signals.js";
|
|
6
6
|
import { runSyncCommand } from "./sync.js";
|
|
7
|
-
import { CLIENT_PASSWORD_SETUP_AUTO_UNLOCK_SECONDS } from "../../wallet/state/client-password.js";
|
|
8
7
|
import { withInteractiveWalletSecretProvider } from "../../wallet/state/provider.js";
|
|
9
8
|
function createCommandPrompter(context) {
|
|
10
9
|
return context.createPrompter();
|
|
11
10
|
}
|
|
12
11
|
function getRepairWarnings(result) {
|
|
13
|
-
return result.miningResumeAction === "
|
|
14
|
-
? [
|
|
12
|
+
return result.miningResumeAction === "skipped-background-mode-removed"
|
|
13
|
+
? ["Background mining no longer resumes automatically after repair. Run `cogcoin mine` if you want mining resumed."]
|
|
15
14
|
: [];
|
|
16
15
|
}
|
|
17
16
|
function getResetWarnings(result) {
|
|
@@ -20,7 +19,7 @@ function getResetWarnings(result) {
|
|
|
20
19
|
: [];
|
|
21
20
|
}
|
|
22
21
|
function writeSetupUnlockGuidance(stdout) {
|
|
23
|
-
for (const line of
|
|
22
|
+
for (const line of getInitUnlockGuidanceLines()) {
|
|
24
23
|
writeLine(stdout, line);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
@@ -100,7 +99,8 @@ function formatResetResultText(result) {
|
|
|
100
99
|
function isRepairMiningResumeActionOk(action) {
|
|
101
100
|
return action === "none"
|
|
102
101
|
|| action === "skipped-not-resumable"
|
|
103
|
-
|| action === "
|
|
102
|
+
|| action === "skipped-post-repair-blocked"
|
|
103
|
+
|| action === "skipped-background-mode-removed";
|
|
104
104
|
}
|
|
105
105
|
function buildRepairWarningEntries(result) {
|
|
106
106
|
const entries = [];
|
package/dist/cli/context.js
CHANGED
|
@@ -13,7 +13,7 @@ import { initializeWallet, previewResetWallet, repairWallet, resetWallet, showWa
|
|
|
13
13
|
import { resolveWalletRuntimePathsForTesting } from "../wallet/runtime.js";
|
|
14
14
|
import { openWalletReadContext } from "../wallet/read/index.js";
|
|
15
15
|
import { loadRawWalletStateEnvelope, loadWalletState } from "../wallet/state/storage.js";
|
|
16
|
-
import { ensureBuiltInMiningSetupIfNeeded, followMiningLog, inspectMiningControlPlane, inspectMiningDomainPromptState, readMiningLog, runForegroundMining, setupBuiltInMining,
|
|
16
|
+
import { ensureBuiltInMiningSetupIfNeeded, followMiningLog, inspectMiningControlPlane, inspectMiningDomainPromptState, readMiningLog, runForegroundMining, setupBuiltInMining, updateMiningDomainPrompt, } from "../wallet/mining/index.js";
|
|
17
17
|
import { createLazyDefaultWalletSecretProvider } from "../wallet/state/provider.js";
|
|
18
18
|
import { anchorDomain, transferBitcoin, buyDomain, claimCogLock, clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, clearField, createField, giveReputation, lockCogToDomain, registerDomain, reclaimCogLock, revokeReputation, sendCog, setField, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, sellDomain, transferDomain, } from "../wallet/tx/index.js";
|
|
19
19
|
import { createTerminalPrompter } from "./prompt.js";
|
|
@@ -93,8 +93,6 @@ export function createDefaultContext(overrides = {}) {
|
|
|
93
93
|
inspectMiningDomainPromptState: overrides.inspectMiningDomainPromptState ?? inspectMiningDomainPromptState,
|
|
94
94
|
ensureBuiltInMiningSetupIfNeeded: overrides.ensureBuiltInMiningSetupIfNeeded ?? ensureBuiltInMiningSetupIfNeeded,
|
|
95
95
|
runForegroundMining: overrides.runForegroundMining ?? runForegroundMining,
|
|
96
|
-
startBackgroundMining: overrides.startBackgroundMining ?? startBackgroundMining,
|
|
97
|
-
stopBackgroundMining: overrides.stopBackgroundMining ?? stopBackgroundMining,
|
|
98
96
|
setupBuiltInMining: overrides.setupBuiltInMining ?? setupBuiltInMining,
|
|
99
97
|
updateMiningDomainPrompt: overrides.updateMiningDomainPrompt ?? updateMiningDomainPrompt,
|
|
100
98
|
readMiningLog: overrides.readMiningLog ?? readMiningLog,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MiningControlPlaneView, MiningDomainPromptMutationResult
|
|
1
|
+
import type { MiningControlPlaneView, MiningDomainPromptMutationResult } from "../wallet/mining/index.js";
|
|
2
2
|
export declare function buildMineSetupData(view: MiningControlPlaneView): {
|
|
3
3
|
resultType: "state-change";
|
|
4
4
|
stateChange: {
|
|
@@ -8,27 +8,6 @@ export declare function buildMineSetupData(view: MiningControlPlaneView): {
|
|
|
8
8
|
};
|
|
9
9
|
state: Record<string, unknown>;
|
|
10
10
|
};
|
|
11
|
-
export declare function buildMineStartData(result: {
|
|
12
|
-
started: boolean;
|
|
13
|
-
snapshot: MiningRuntimeStatusV1 | null;
|
|
14
|
-
}): {
|
|
15
|
-
resultType: "state-change";
|
|
16
|
-
stateChange: {
|
|
17
|
-
kind: string;
|
|
18
|
-
before: Record<string, unknown> | null;
|
|
19
|
-
after: Record<string, unknown> | null;
|
|
20
|
-
};
|
|
21
|
-
state: Record<string, unknown>;
|
|
22
|
-
};
|
|
23
|
-
export declare function buildMineStopData(snapshot: MiningRuntimeStatusV1 | null): {
|
|
24
|
-
resultType: "state-change";
|
|
25
|
-
stateChange: {
|
|
26
|
-
kind: string;
|
|
27
|
-
before: Record<string, unknown> | null;
|
|
28
|
-
after: Record<string, unknown> | null;
|
|
29
|
-
};
|
|
30
|
-
state: Record<string, unknown>;
|
|
31
|
-
};
|
|
32
11
|
export declare function buildMinePromptData(result: MiningDomainPromptMutationResult): {
|
|
33
12
|
domain: {
|
|
34
13
|
name: string;
|
package/dist/cli/mining-json.js
CHANGED
|
@@ -35,29 +35,6 @@ export function buildMineSetupData(view) {
|
|
|
35
35
|
after,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
export function buildMineStartData(result) {
|
|
39
|
-
const after = {
|
|
40
|
-
started: result.started,
|
|
41
|
-
runtime: summarizeRuntime(result.snapshot),
|
|
42
|
-
};
|
|
43
|
-
return buildStateChangeData({
|
|
44
|
-
kind: "mine-start",
|
|
45
|
-
state: after,
|
|
46
|
-
after,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
export function buildMineStopData(snapshot) {
|
|
50
|
-
const after = {
|
|
51
|
-
stopped: snapshot !== null,
|
|
52
|
-
runtime: summarizeRuntime(snapshot),
|
|
53
|
-
note: snapshot?.note ?? "Background mining was not active.",
|
|
54
|
-
};
|
|
55
|
-
return buildStateChangeData({
|
|
56
|
-
kind: "mine-stop",
|
|
57
|
-
state: after,
|
|
58
|
-
after,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
38
|
export function buildMinePromptData(result) {
|
|
62
39
|
return {
|
|
63
40
|
domain: result.domain,
|
package/dist/cli/output.js
CHANGED
|
@@ -330,8 +330,8 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
330
330
|
if (errorCode === "wallet_client_password_locked") {
|
|
331
331
|
return {
|
|
332
332
|
what: "Client password is locked.",
|
|
333
|
-
why: "This command needs the password-protected local wallet secret, but
|
|
334
|
-
next: "
|
|
333
|
+
why: "This command needs the password-protected local wallet secret, but this process does not currently hold an unlocked client-password session.",
|
|
334
|
+
next: "Rerun the command in an interactive terminal so Cogcoin can prompt for the client password. Separate CLI invocations no longer share unlocked state.",
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
if (errorCode === "wallet_client_password_change_requires_tty") {
|
|
@@ -341,6 +341,20 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
341
341
|
next: "Run `cogcoin client change-password` in an interactive terminal.",
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
|
+
if (errorCode === "cli_client_unlock_removed") {
|
|
345
|
+
return {
|
|
346
|
+
what: "`client unlock` was removed.",
|
|
347
|
+
why: "Cogcoin no longer shares unlocked client-password sessions across separate CLI commands.",
|
|
348
|
+
next: "Rerun password-aware commands in an interactive terminal so Cogcoin can prompt for the client password when needed.",
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (errorCode === "cli_client_lock_removed") {
|
|
352
|
+
return {
|
|
353
|
+
what: "`client lock` was removed.",
|
|
354
|
+
why: "Cogcoin no longer keeps reusable unlocked client-password sessions after a command exits.",
|
|
355
|
+
next: "Fresh CLI invocations start locked automatically and prompt when wallet-local secrets are needed.",
|
|
356
|
+
};
|
|
357
|
+
}
|
|
344
358
|
if (errorCode === "cli_restore_removed" || errorCode === "cli_wallet_restore_removed") {
|
|
345
359
|
return {
|
|
346
360
|
what: "Standalone restore commands were removed.",
|
package/dist/cli/parse.js
CHANGED
|
@@ -282,8 +282,6 @@ export function parseCliArgs(argv) {
|
|
|
282
282
|
|| command === "sync"
|
|
283
283
|
|| command === "follow"
|
|
284
284
|
|| command === "mine"
|
|
285
|
-
|| command === "mine-start"
|
|
286
|
-
|| command === "mine-stop"
|
|
287
285
|
|| command === "mine-setup"
|
|
288
286
|
|| command === "mine-prompt-list"
|
|
289
287
|
|| command === "mine-status"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnchorDomainResult, CogMutationResult, DomainAdminMutationResult, DomainMarketMutationResult, FieldMutationResult, RegisterDomainResult, ReputationMutationResult, WalletMutationFeeSummary } from "../wallet/tx/index.js";
|
|
2
2
|
import type { WalletRepairResult, WalletResetPreview } from "../wallet/lifecycle.js";
|
|
3
|
-
import type { MiningControlPlaneView
|
|
3
|
+
import type { MiningControlPlaneView } from "../wallet/mining/index.js";
|
|
4
4
|
export declare function buildSingleTxMutationPreviewData(options: {
|
|
5
5
|
kind: string;
|
|
6
6
|
localStatus: string;
|
|
@@ -317,24 +317,3 @@ export declare function buildMineSetupPreviewData(view: MiningControlPlaneView):
|
|
|
317
317
|
};
|
|
318
318
|
state: Record<string, unknown>;
|
|
319
319
|
};
|
|
320
|
-
export declare function buildMineStartPreviewData(result: {
|
|
321
|
-
started: boolean;
|
|
322
|
-
snapshot: MiningRuntimeStatusV1 | null;
|
|
323
|
-
}): {
|
|
324
|
-
resultType: "state-change";
|
|
325
|
-
stateChange: {
|
|
326
|
-
kind: string;
|
|
327
|
-
before: Record<string, unknown> | null;
|
|
328
|
-
after: Record<string, unknown> | null;
|
|
329
|
-
};
|
|
330
|
-
state: Record<string, unknown>;
|
|
331
|
-
};
|
|
332
|
-
export declare function buildMineStopPreviewData(snapshot: MiningRuntimeStatusV1 | null): {
|
|
333
|
-
resultType: "state-change";
|
|
334
|
-
stateChange: {
|
|
335
|
-
kind: string;
|
|
336
|
-
before: Record<string, unknown> | null;
|
|
337
|
-
after: Record<string, unknown> | null;
|
|
338
|
-
};
|
|
339
|
-
state: Record<string, unknown>;
|
|
340
|
-
};
|
package/dist/cli/preview-json.js
CHANGED
|
@@ -252,22 +252,3 @@ export function buildMineSetupPreviewData(view) {
|
|
|
252
252
|
},
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
-
export function buildMineStartPreviewData(result) {
|
|
256
|
-
return buildStateChangePreviewData({
|
|
257
|
-
kind: "mine-start",
|
|
258
|
-
state: {
|
|
259
|
-
started: result.started,
|
|
260
|
-
runtime: summarizeRuntime(result.snapshot),
|
|
261
|
-
},
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
export function buildMineStopPreviewData(snapshot) {
|
|
265
|
-
return buildStateChangePreviewData({
|
|
266
|
-
kind: "mine-stop",
|
|
267
|
-
state: {
|
|
268
|
-
stopped: snapshot !== null,
|
|
269
|
-
runtime: summarizeRuntime(snapshot),
|
|
270
|
-
note: snapshot?.note ?? "Background mining was not active.",
|
|
271
|
-
},
|
|
272
|
-
});
|
|
273
|
-
}
|
package/dist/cli/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { WalletPrompter, initializeWallet, previewResetWallet, repairWallet
|
|
|
11
11
|
import type { openWalletReadContext } from "../wallet/read/index.js";
|
|
12
12
|
import { loadRawWalletStateEnvelope, loadWalletState } from "../wallet/state/storage.js";
|
|
13
13
|
import type { WalletSecretProvider } from "../wallet/state/provider.js";
|
|
14
|
-
import type { ensureBuiltInMiningSetupIfNeeded, followMiningLog, inspectMiningControlPlane, inspectMiningDomainPromptState, readMiningLog, runForegroundMining, setupBuiltInMining,
|
|
14
|
+
import type { ensureBuiltInMiningSetupIfNeeded, followMiningLog, inspectMiningControlPlane, inspectMiningDomainPromptState, readMiningLog, runForegroundMining, setupBuiltInMining, updateMiningDomainPrompt } from "../wallet/mining/index.js";
|
|
15
15
|
import type { anchorDomain, transferBitcoin, buyDomain, claimCogLock, clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, clearField, createField, giveReputation, lockCogToDomain, registerDomain, reclaimCogLock, revokeReputation, sendCog, setField, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, sellDomain, transferDomain } from "../wallet/tx/index.js";
|
|
16
16
|
import type { CommandHandlerFamily, CommandName } from "./command-registry.js";
|
|
17
17
|
export type { CommandHandlerFamily, CommandName } from "./command-registry.js";
|
|
@@ -154,8 +154,6 @@ export interface CliRunnerContext {
|
|
|
154
154
|
inspectMiningDomainPromptState?: typeof inspectMiningDomainPromptState;
|
|
155
155
|
ensureBuiltInMiningSetupIfNeeded?: typeof ensureBuiltInMiningSetupIfNeeded;
|
|
156
156
|
runForegroundMining?: typeof runForegroundMining;
|
|
157
|
-
startBackgroundMining?: typeof startBackgroundMining;
|
|
158
|
-
stopBackgroundMining?: typeof stopBackgroundMining;
|
|
159
157
|
setupBuiltInMining?: typeof setupBuiltInMining;
|
|
160
158
|
updateMiningDomainPrompt?: typeof updateMiningDomainPrompt;
|
|
161
159
|
readMiningLog?: typeof readMiningLog;
|
|
@@ -115,7 +115,7 @@ export function getRepairRecommendation(context) {
|
|
|
115
115
|
}
|
|
116
116
|
export function getClientUnlockRecommendation(context) {
|
|
117
117
|
if (context.localState.unlockRequired) {
|
|
118
|
-
return "
|
|
118
|
+
return "Rerun this command in an interactive terminal so Cogcoin can prompt for the client password.";
|
|
119
119
|
}
|
|
120
120
|
return null;
|
|
121
121
|
}
|
|
@@ -3,12 +3,11 @@ export declare function formatNextStepLines(nextSteps: readonly string[]): strin
|
|
|
3
3
|
export declare function getFundingQuickstartGuidance(): string;
|
|
4
4
|
export declare function getInitNextSteps(): string[];
|
|
5
5
|
export declare function getRestoreNextSteps(): string[];
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getInitUnlockGuidanceLines(): string[];
|
|
7
7
|
export declare function getBootstrapSyncNextStep(context: Pick<WalletReadContext, "bitcoind" | "indexer" | "nodeHealth">): string | null;
|
|
8
8
|
export declare function getRegisterNextSteps(domainName: string, registerKind: "root" | "subdomain"): string[];
|
|
9
9
|
export declare function getAnchorNextSteps(domainName: string): string[];
|
|
10
10
|
export declare function getMineSetupNextSteps(): string[];
|
|
11
|
-
export declare function getMineStopNextSteps(): string[];
|
|
12
11
|
export declare function getAddressNextSteps(context: Pick<WalletReadContext, "bitcoind" | "indexer" | "nodeHealth">, address: string | null | undefined): string[];
|
|
13
12
|
export declare function getIdsNextSteps(walletAddress: string | null | undefined): string[];
|
|
14
13
|
export declare function getLocksNextSteps(locks: readonly WalletLockView[] | null | undefined): string[];
|
|
@@ -13,10 +13,10 @@ export function getInitNextSteps() {
|
|
|
13
13
|
export function getRestoreNextSteps() {
|
|
14
14
|
return ["cogcoin sync", "cogcoin address"];
|
|
15
15
|
}
|
|
16
|
-
export function
|
|
16
|
+
export function getInitUnlockGuidanceLines() {
|
|
17
17
|
return [
|
|
18
|
-
|
|
19
|
-
"
|
|
18
|
+
"Client password reuse stays active in memory for the rest of this long-running init command, up to about 24 hours.",
|
|
19
|
+
"Future Cogcoin commands will prompt again when they need wallet-local secrets.",
|
|
20
20
|
];
|
|
21
21
|
}
|
|
22
22
|
function blocksSyncBootstrap(context) {
|
|
@@ -52,15 +52,12 @@ export function getRegisterNextSteps(domainName, registerKind) {
|
|
|
52
52
|
export function getAnchorNextSteps(domainName) {
|
|
53
53
|
const nextSteps = [`cogcoin show ${domainName}`];
|
|
54
54
|
if (isRootDomainName(domainName)) {
|
|
55
|
-
nextSteps.push("cogcoin mine"
|
|
55
|
+
nextSteps.push("cogcoin mine");
|
|
56
56
|
}
|
|
57
57
|
return nextSteps;
|
|
58
58
|
}
|
|
59
59
|
export function getMineSetupNextSteps() {
|
|
60
|
-
return ["cogcoin mine"
|
|
61
|
-
}
|
|
62
|
-
export function getMineStopNextSteps() {
|
|
63
|
-
return ["cogcoin mine log"];
|
|
60
|
+
return ["cogcoin mine"];
|
|
64
61
|
}
|
|
65
62
|
export function getAddressNextSteps(context, address) {
|
|
66
63
|
if (address === null || address === undefined || address.length === 0) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WalletAccessContext, WalletLoadedState } from "./types.js";
|
|
2
|
+
export declare function isWalletSecretAccessError(error: unknown): boolean;
|
|
3
|
+
export declare function mapWalletReadAccessError(error: unknown): Error;
|
|
4
|
+
export declare function normalizeLoadedWalletStateIfNeeded(options: WalletAccessContext & WalletLoadedState): Promise<WalletLoadedState>;
|
|
5
|
+
export declare function loadWalletStateForAccess(options: WalletAccessContext): Promise<WalletLoadedState>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { normalizeWalletStateRecord, persistWalletCoinControlStateIfNeeded, } from "../coin-control.js";
|
|
2
|
+
import { persistNormalizedWalletDescriptorStateIfNeeded } from "../descriptor-normalization.js";
|
|
3
|
+
import { normalizeMiningStateRecord } from "../mining/state.js";
|
|
4
|
+
import { createWalletSecretReference } from "../state/provider.js";
|
|
5
|
+
import { loadWalletState } from "../state/storage.js";
|
|
6
|
+
export function isWalletSecretAccessError(error) {
|
|
7
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8
|
+
return message.startsWith("wallet_secret_missing_")
|
|
9
|
+
|| message.startsWith("wallet_secret_provider_");
|
|
10
|
+
}
|
|
11
|
+
export function mapWalletReadAccessError(error) {
|
|
12
|
+
if (isWalletSecretAccessError(error)) {
|
|
13
|
+
return new Error("wallet_secret_provider_unavailable");
|
|
14
|
+
}
|
|
15
|
+
return new Error("local-state-corrupt");
|
|
16
|
+
}
|
|
17
|
+
export async function normalizeLoadedWalletStateIfNeeded(options) {
|
|
18
|
+
let state = options.state;
|
|
19
|
+
let source = options.source;
|
|
20
|
+
if (options.dataDir !== undefined) {
|
|
21
|
+
const node = await options.attachService({
|
|
22
|
+
dataDir: options.dataDir,
|
|
23
|
+
chain: "main",
|
|
24
|
+
startHeight: 0,
|
|
25
|
+
walletRootId: state.walletRootId,
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
const normalizedDescriptorState = await persistNormalizedWalletDescriptorStateIfNeeded({
|
|
29
|
+
state,
|
|
30
|
+
access: {
|
|
31
|
+
provider: options.provider,
|
|
32
|
+
secretReference: createWalletSecretReference(state.walletRootId),
|
|
33
|
+
},
|
|
34
|
+
paths: options.paths,
|
|
35
|
+
nowUnixMs: options.nowUnixMs,
|
|
36
|
+
replacePrimary: source === "backup",
|
|
37
|
+
rpc: options.rpcFactory(node.rpc),
|
|
38
|
+
});
|
|
39
|
+
state = normalizedDescriptorState.state;
|
|
40
|
+
source = normalizedDescriptorState.changed ? "primary" : source;
|
|
41
|
+
const reconciledCoinControl = await persistWalletCoinControlStateIfNeeded({
|
|
42
|
+
state,
|
|
43
|
+
access: {
|
|
44
|
+
provider: options.provider,
|
|
45
|
+
secretReference: createWalletSecretReference(state.walletRootId),
|
|
46
|
+
},
|
|
47
|
+
paths: options.paths,
|
|
48
|
+
nowUnixMs: options.nowUnixMs,
|
|
49
|
+
replacePrimary: source === "backup",
|
|
50
|
+
rpc: options.rpcFactory(node.rpc),
|
|
51
|
+
});
|
|
52
|
+
state = reconciledCoinControl.state;
|
|
53
|
+
source = reconciledCoinControl.changed ? "primary" : source;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await node.stop?.().catch(() => undefined);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
state: normalizeWalletStateRecord({
|
|
61
|
+
...state,
|
|
62
|
+
miningState: normalizeMiningStateRecord(state.miningState),
|
|
63
|
+
}),
|
|
64
|
+
source,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export async function loadWalletStateForAccess(options) {
|
|
68
|
+
const loaded = await loadWalletState({
|
|
69
|
+
primaryPath: options.paths.walletStatePath,
|
|
70
|
+
backupPath: options.paths.walletStateBackupPath,
|
|
71
|
+
}, {
|
|
72
|
+
provider: options.provider,
|
|
73
|
+
});
|
|
74
|
+
return await normalizeLoadedWalletStateIfNeeded({
|
|
75
|
+
...options,
|
|
76
|
+
state: loaded.state,
|
|
77
|
+
source: loaded.source,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type WalletRuntimePaths } from "../runtime.js";
|
|
2
|
+
import { type WalletSecretProvider } from "../state/provider.js";
|
|
3
|
+
import type { WalletManagedCoreContext, WalletManagedCoreDependencies, WalletPrompter, WalletRepairContext, WalletRepairDependencies, WalletSetupContext, WalletSetupDependencies } from "./types.js";
|
|
4
|
+
export declare function pathExists(path: string): Promise<boolean>;
|
|
5
|
+
export declare function walletStateExists(paths: WalletRuntimePaths): Promise<boolean>;
|
|
6
|
+
export declare function resolveWalletManagedCoreContext(options: {
|
|
7
|
+
provider?: WalletSecretProvider;
|
|
8
|
+
nowUnixMs?: number;
|
|
9
|
+
paths?: WalletRuntimePaths;
|
|
10
|
+
} & WalletManagedCoreDependencies): WalletManagedCoreContext;
|
|
11
|
+
export declare function resolveWalletSetupContext(options: {
|
|
12
|
+
dataDir: string;
|
|
13
|
+
prompter: WalletPrompter;
|
|
14
|
+
provider?: WalletSecretProvider;
|
|
15
|
+
nowUnixMs?: number;
|
|
16
|
+
paths?: WalletRuntimePaths;
|
|
17
|
+
} & WalletSetupDependencies): WalletSetupContext;
|
|
18
|
+
export declare function resolveWalletRepairContext(options: {
|
|
19
|
+
dataDir: string;
|
|
20
|
+
databasePath: string;
|
|
21
|
+
provider?: WalletSecretProvider;
|
|
22
|
+
assumeYes?: boolean;
|
|
23
|
+
nowUnixMs?: number;
|
|
24
|
+
paths?: WalletRuntimePaths;
|
|
25
|
+
} & WalletRepairDependencies): WalletRepairContext;
|
|
26
|
+
export declare function acquireWalletControlLock(paths: WalletRuntimePaths, purpose: "wallet-init" | "wallet-show-mnemonic" | "wallet-repair"): Promise<import("../fs/lock.js").FileLockHandle>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { access, constants } from "node:fs/promises";
|
|
2
|
+
import { attachOrStartIndexerDaemon, probeIndexerDaemon, } from "../../bitcoind/indexer-daemon.js";
|
|
3
|
+
import { createRpcClient } from "../../bitcoind/node.js";
|
|
4
|
+
import { attachOrStartManagedBitcoindService, probeManagedBitcoindService, } from "../../bitcoind/service.js";
|
|
5
|
+
import { acquireFileLock } from "../fs/lock.js";
|
|
6
|
+
import { resolveWalletRuntimePathsForTesting } from "../runtime.js";
|
|
7
|
+
import { createDefaultWalletSecretProvider, } from "../state/provider.js";
|
|
8
|
+
export async function pathExists(path) {
|
|
9
|
+
try {
|
|
10
|
+
await access(path, constants.F_OK);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function walletStateExists(paths) {
|
|
18
|
+
const [hasPrimaryState, hasBackupState] = await Promise.all([
|
|
19
|
+
pathExists(paths.walletStatePath),
|
|
20
|
+
pathExists(paths.walletStateBackupPath),
|
|
21
|
+
]);
|
|
22
|
+
return hasPrimaryState || hasBackupState;
|
|
23
|
+
}
|
|
24
|
+
export function resolveWalletManagedCoreContext(options) {
|
|
25
|
+
return {
|
|
26
|
+
provider: options.provider ?? createDefaultWalletSecretProvider(),
|
|
27
|
+
paths: options.paths ?? resolveWalletRuntimePathsForTesting(),
|
|
28
|
+
nowUnixMs: options.nowUnixMs ?? Date.now(),
|
|
29
|
+
attachService: options.attachService ?? attachOrStartManagedBitcoindService,
|
|
30
|
+
rpcFactory: options.rpcFactory ?? createRpcClient,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function resolveWalletSetupContext(options) {
|
|
34
|
+
return {
|
|
35
|
+
...resolveWalletManagedCoreContext(options),
|
|
36
|
+
dataDir: options.dataDir,
|
|
37
|
+
prompter: options.prompter,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function resolveWalletRepairContext(options) {
|
|
41
|
+
return {
|
|
42
|
+
...resolveWalletManagedCoreContext(options),
|
|
43
|
+
dataDir: options.dataDir,
|
|
44
|
+
databasePath: options.databasePath,
|
|
45
|
+
assumeYes: options.assumeYes ?? false,
|
|
46
|
+
probeBitcoindService: options.probeBitcoindService ?? probeManagedBitcoindService,
|
|
47
|
+
attachIndexerDaemon: options.attachIndexerDaemon ?? attachOrStartIndexerDaemon,
|
|
48
|
+
probeIndexerDaemon: options.probeIndexerDaemon ?? probeIndexerDaemon,
|
|
49
|
+
requestMiningPreemption: options.requestMiningPreemption,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export async function acquireWalletControlLock(paths, purpose) {
|
|
53
|
+
return await acquireFileLock(paths.walletControlLockPath, {
|
|
54
|
+
purpose,
|
|
55
|
+
walletRootId: null,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -4,16 +4,8 @@ import type { ManagedCoreWalletReplicaStatus } from "../../bitcoind/types.js";
|
|
|
4
4
|
import type { WalletRuntimePaths } from "../runtime.js";
|
|
5
5
|
import { type WalletSecretProvider } from "../state/provider.js";
|
|
6
6
|
import type { WalletStateV1 } from "../types.js";
|
|
7
|
-
import type { WalletLifecycleRpcClient, WalletManagedCoreDependencies
|
|
7
|
+
import type { WalletLifecycleRpcClient, WalletManagedCoreDependencies } from "./types.js";
|
|
8
8
|
export declare function sanitizeWalletName(walletRootId: string): string;
|
|
9
|
-
export declare function normalizeLoadedWalletStateIfNeeded(options: WalletLifecycleResolvedContext & {
|
|
10
|
-
state: WalletStateV1;
|
|
11
|
-
source: "primary" | "backup";
|
|
12
|
-
dataDir?: string;
|
|
13
|
-
} & WalletManagedCoreDependencies): Promise<{
|
|
14
|
-
state: WalletStateV1;
|
|
15
|
-
source: "primary" | "backup";
|
|
16
|
-
}>;
|
|
17
9
|
export declare function importDescriptorIntoManagedCoreWallet(state: WalletStateV1, provider: WalletSecretProvider, paths: WalletRuntimePaths, dataDir: string, nowUnixMs: number, attachService?: typeof attachOrStartManagedBitcoindService, rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => WalletLifecycleRpcClient): Promise<WalletStateV1>;
|
|
18
10
|
export declare function recreateManagedCoreWalletReplica(state: WalletStateV1, provider: WalletSecretProvider, paths: WalletRuntimePaths, dataDir: string, nowUnixMs: number, options?: WalletManagedCoreDependencies): Promise<WalletStateV1>;
|
|
19
11
|
export declare function verifyManagedCoreWalletReplica(state: WalletStateV1, dataDir: string, dependencies?: WalletManagedCoreDependencies & {
|
|
@@ -1,75 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rename } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { attachOrStartManagedBitcoindService, createManagedWalletReplica } from "../../bitcoind/service.js";
|
|
4
4
|
import { createRpcClient } from "../../bitcoind/node.js";
|
|
5
|
-
import {
|
|
6
|
-
import { persistNormalizedWalletDescriptorStateIfNeeded, resolveNormalizedWalletDescriptorState, } from "../descriptor-normalization.js";
|
|
7
|
-
import { normalizeMiningStateRecord } from "../mining/state.js";
|
|
5
|
+
import { resolveNormalizedWalletDescriptorState, } from "../descriptor-normalization.js";
|
|
8
6
|
import { createWalletSecretReference } from "../state/provider.js";
|
|
9
7
|
import { saveWalletState } from "../state/storage.js";
|
|
10
8
|
import { withUnlockedManagedCoreWallet } from "../managed-core-wallet.js";
|
|
9
|
+
import { pathExists } from "./context.js";
|
|
11
10
|
export function sanitizeWalletName(walletRootId) {
|
|
12
11
|
return `cogcoin-${walletRootId}`.replace(/[^a-zA-Z0-9._-]+/g, "-").slice(0, 63);
|
|
13
12
|
}
|
|
14
|
-
async function pathExists(path) {
|
|
15
|
-
try {
|
|
16
|
-
await access(path, constants.F_OK);
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export async function normalizeLoadedWalletStateIfNeeded(options) {
|
|
24
|
-
let state = options.state;
|
|
25
|
-
let source = options.source;
|
|
26
|
-
if (options.dataDir !== undefined) {
|
|
27
|
-
const node = await (options.attachService ?? attachOrStartManagedBitcoindService)({
|
|
28
|
-
dataDir: options.dataDir,
|
|
29
|
-
chain: "main",
|
|
30
|
-
startHeight: 0,
|
|
31
|
-
walletRootId: state.walletRootId,
|
|
32
|
-
});
|
|
33
|
-
try {
|
|
34
|
-
const normalized = await persistNormalizedWalletDescriptorStateIfNeeded({
|
|
35
|
-
state,
|
|
36
|
-
access: {
|
|
37
|
-
provider: options.provider,
|
|
38
|
-
secretReference: createWalletSecretReference(state.walletRootId),
|
|
39
|
-
},
|
|
40
|
-
paths: options.paths,
|
|
41
|
-
nowUnixMs: options.nowUnixMs,
|
|
42
|
-
replacePrimary: options.source === "backup",
|
|
43
|
-
rpc: (options.rpcFactory ?? createRpcClient)(node.rpc),
|
|
44
|
-
});
|
|
45
|
-
state = normalized.state;
|
|
46
|
-
source = normalized.changed ? "primary" : options.source;
|
|
47
|
-
const coinControl = await persistWalletCoinControlStateIfNeeded({
|
|
48
|
-
state,
|
|
49
|
-
access: {
|
|
50
|
-
provider: options.provider,
|
|
51
|
-
secretReference: createWalletSecretReference(state.walletRootId),
|
|
52
|
-
},
|
|
53
|
-
paths: options.paths,
|
|
54
|
-
nowUnixMs: options.nowUnixMs,
|
|
55
|
-
replacePrimary: source === "backup",
|
|
56
|
-
rpc: createRpcClient(node.rpc),
|
|
57
|
-
});
|
|
58
|
-
state = coinControl.state;
|
|
59
|
-
source = coinControl.changed ? "primary" : source;
|
|
60
|
-
}
|
|
61
|
-
finally {
|
|
62
|
-
await node.stop?.().catch(() => undefined);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
state: normalizeWalletStateRecord({
|
|
67
|
-
...state,
|
|
68
|
-
miningState: normalizeMiningStateRecord(state.miningState),
|
|
69
|
-
}),
|
|
70
|
-
source,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
13
|
export async function importDescriptorIntoManagedCoreWallet(state, provider, paths, dataDir, nowUnixMs, attachService = attachOrStartManagedBitcoindService, rpcFactory = createRpcClient) {
|
|
74
14
|
const node = await attachService({
|
|
75
15
|
dataDir,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ManagedServicePaths } from "../../bitcoind/service-paths.js";
|
|
2
|
+
import type { WalletStateV1 } from "../types.js";
|
|
3
|
+
import type { WalletBitcoindRepairStageResult, WalletRepairContext } from "./types.js";
|
|
4
|
+
export declare function repairManagedBitcoindStage(options: {
|
|
5
|
+
context: WalletRepairContext;
|
|
6
|
+
servicePaths: ManagedServicePaths;
|
|
7
|
+
state: WalletStateV1;
|
|
8
|
+
recoveredFromBackup: boolean;
|
|
9
|
+
repairStateNeedsPersist: boolean;
|
|
10
|
+
}): Promise<WalletBitcoindRepairStageResult>;
|