@cogcoin/client 1.1.4 → 1.1.6
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 +4 -5
- package/dist/bitcoind/indexer-daemon.d.ts +3 -7
- package/dist/bitcoind/indexer-daemon.js +43 -158
- 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/indexer-policy.d.ts +34 -0
- package/dist/bitcoind/managed-runtime/indexer-policy.js +200 -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 +37 -0
- package/dist/bitcoind/managed-runtime/types.js +1 -0
- package/dist/bitcoind/progress/tty-renderer.js +3 -2
- package/dist/bitcoind/service.d.ts +2 -7
- package/dist/bitcoind/service.js +46 -94
- package/dist/cli/command-registry.d.ts +39 -0
- package/dist/cli/command-registry.js +1132 -0
- package/dist/cli/commands/client-admin.js +6 -56
- package/dist/cli/commands/mining-admin.js +9 -32
- package/dist/cli/commands/mining-read.js +15 -56
- package/dist/cli/commands/mining-runtime.js +258 -57
- package/dist/cli/commands/service-runtime.js +1 -64
- package/dist/cli/commands/status.js +2 -15
- package/dist/cli/commands/update.js +6 -21
- package/dist/cli/commands/wallet-admin.js +18 -120
- package/dist/cli/commands/wallet-mutation.js +4 -7
- package/dist/cli/commands/wallet-read.js +31 -138
- package/dist/cli/context.js +2 -4
- package/dist/cli/mining-format.js +8 -2
- package/dist/cli/mutation-command-groups.d.ts +11 -11
- package/dist/cli/mutation-command-groups.js +9 -18
- package/dist/cli/mutation-json.d.ts +1 -17
- package/dist/cli/mutation-json.js +1 -28
- package/dist/cli/mutation-success.d.ts +0 -1
- package/dist/cli/mutation-success.js +0 -19
- package/dist/cli/output.d.ts +1 -10
- package/dist/cli/output.js +52 -481
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.js +38 -695
- package/dist/cli/runner.js +28 -113
- package/dist/cli/types.d.ts +7 -8
- package/dist/cli/update-notifier.js +1 -1
- package/dist/cli/wallet-format.js +1 -1
- 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 +58 -0
- package/dist/wallet/lifecycle/managed-core.d.ts +15 -0
- package/dist/wallet/lifecycle/managed-core.js +197 -0
- 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 +49 -0
- package/dist/wallet/lifecycle/repair-mining.js +304 -0
- package/dist/wallet/lifecycle/repair-runtime.d.ts +36 -0
- package/dist/wallet/lifecycle/repair-runtime.js +206 -0
- package/dist/wallet/lifecycle/repair.d.ts +9 -0
- package/dist/wallet/lifecycle/repair.js +127 -0
- 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 +15 -0
- package/dist/wallet/lifecycle/setup.js +124 -0
- package/dist/wallet/lifecycle/types.d.ts +156 -0
- package/dist/wallet/lifecycle/types.js +1 -0
- package/dist/wallet/lifecycle.d.ts +4 -165
- package/dist/wallet/lifecycle.js +3 -1656
- package/dist/wallet/mining/candidate.d.ts +60 -0
- package/dist/wallet/mining/candidate.js +290 -0
- package/dist/wallet/mining/competitiveness.d.ts +22 -0
- package/dist/wallet/mining/competitiveness.js +640 -0
- package/dist/wallet/mining/control.js +7 -251
- package/dist/wallet/mining/cycle.d.ts +39 -0
- package/dist/wallet/mining/cycle.js +542 -0
- package/dist/wallet/mining/engine-state.d.ts +66 -0
- package/dist/wallet/mining/engine-state.js +211 -0
- package/dist/wallet/mining/engine-types.d.ts +173 -0
- package/dist/wallet/mining/engine-types.js +1 -0
- package/dist/wallet/mining/engine-utils.d.ts +7 -0
- package/dist/wallet/mining/engine-utils.js +75 -0
- package/dist/wallet/mining/events.d.ts +2 -0
- package/dist/wallet/mining/events.js +19 -0
- package/dist/wallet/mining/lifecycle.d.ts +71 -0
- package/dist/wallet/mining/lifecycle.js +355 -0
- package/dist/wallet/mining/projection.d.ts +61 -0
- package/dist/wallet/mining/projection.js +319 -0
- package/dist/wallet/mining/publish.d.ts +79 -0
- package/dist/wallet/mining/publish.js +614 -0
- package/dist/wallet/mining/runner.d.ts +12 -418
- package/dist/wallet/mining/runner.js +274 -3433
- package/dist/wallet/mining/supervisor.d.ts +134 -0
- package/dist/wallet/mining/supervisor.js +558 -0
- package/dist/wallet/mining/visualizer-sync.d.ts +42 -0
- package/dist/wallet/mining/visualizer-sync.js +166 -0
- package/dist/wallet/mining/visualizer.d.ts +1 -0
- package/dist/wallet/mining/visualizer.js +33 -18
- package/dist/wallet/read/context.js +13 -188
- package/dist/wallet/reset.d.ts +1 -1
- package/dist/wallet/reset.js +35 -11
- package/dist/wallet/runtime.d.ts +0 -6
- package/dist/wallet/runtime.js +2 -38
- package/dist/wallet/tx/common.d.ts +18 -0
- package/dist/wallet/tx/common.js +40 -26
- package/package.json +1 -1
- package/dist/wallet/state/seed-index.d.ts +0 -43
- package/dist/wallet/state/seed-index.js +0 -151
|
@@ -1,77 +1,27 @@
|
|
|
1
1
|
import { writeLine } from "../io.js";
|
|
2
|
-
import {
|
|
3
|
-
import { createMutationSuccessEnvelope, describeCanonicalCommand, resolveStableMutationJsonSchema, writeHandledCliError, writeJsonValue, } from "../output.js";
|
|
2
|
+
import { writeHandledCliError } from "../output.js";
|
|
4
3
|
import { changeClientPassword, lockClientPassword, unlockClientPassword, } from "../../wallet/state/provider.js";
|
|
5
|
-
function createCommandPrompter(
|
|
6
|
-
return
|
|
7
|
-
? createTerminalPrompter(context.stdin, context.stderr)
|
|
8
|
-
: context.createPrompter();
|
|
4
|
+
function createCommandPrompter(context) {
|
|
5
|
+
return context.createPrompter();
|
|
9
6
|
}
|
|
10
7
|
export async function runClientAdminCommand(parsed, context) {
|
|
11
8
|
try {
|
|
12
9
|
if (parsed.command === "client-lock") {
|
|
13
|
-
|
|
14
|
-
if (parsed.outputMode === "json") {
|
|
15
|
-
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMutationJsonSchema(parsed), describeCanonicalCommand(parsed), "locked", {
|
|
16
|
-
resultType: "operation",
|
|
17
|
-
operation: {
|
|
18
|
-
kind: "client-lock",
|
|
19
|
-
locked: true,
|
|
20
|
-
unlockUntilUnixMs: status.unlockUntilUnixMs,
|
|
21
|
-
},
|
|
22
|
-
state: {
|
|
23
|
-
locked: true,
|
|
24
|
-
unlockUntilUnixMs: status.unlockUntilUnixMs,
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
10
|
+
await lockClientPassword(context.walletSecretProvider);
|
|
29
11
|
writeLine(context.stdout, "Client locked.");
|
|
30
12
|
return 0;
|
|
31
13
|
}
|
|
32
14
|
if (parsed.command === "client-unlock") {
|
|
33
|
-
const prompter = createCommandPrompter(
|
|
15
|
+
const prompter = createCommandPrompter(context);
|
|
34
16
|
const status = await unlockClientPassword(context.walletSecretProvider, prompter);
|
|
35
|
-
if (parsed.outputMode === "json") {
|
|
36
|
-
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMutationJsonSchema(parsed), describeCanonicalCommand(parsed), "unlocked", {
|
|
37
|
-
resultType: "operation",
|
|
38
|
-
operation: {
|
|
39
|
-
kind: "client-unlock",
|
|
40
|
-
unlocked: status.unlocked,
|
|
41
|
-
unlockUntilUnixMs: status.unlockUntilUnixMs,
|
|
42
|
-
},
|
|
43
|
-
state: {
|
|
44
|
-
unlocked: status.unlocked,
|
|
45
|
-
unlockUntilUnixMs: status.unlockUntilUnixMs,
|
|
46
|
-
},
|
|
47
|
-
}));
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
17
|
writeLine(context.stdout, status.unlockUntilUnixMs === null
|
|
51
18
|
? "Client unlocked."
|
|
52
19
|
: `Client unlocked until ${new Date(status.unlockUntilUnixMs).toISOString()}.`);
|
|
53
20
|
return 0;
|
|
54
21
|
}
|
|
55
22
|
if (parsed.command === "client-change-password") {
|
|
56
|
-
const prompter = createCommandPrompter(
|
|
23
|
+
const prompter = createCommandPrompter(context);
|
|
57
24
|
const status = await changeClientPassword(context.walletSecretProvider, prompter);
|
|
58
|
-
if (parsed.outputMode === "json") {
|
|
59
|
-
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMutationJsonSchema(parsed), describeCanonicalCommand(parsed), "changed", {
|
|
60
|
-
resultType: "operation",
|
|
61
|
-
operation: {
|
|
62
|
-
kind: "client-change-password",
|
|
63
|
-
changed: true,
|
|
64
|
-
unlocked: status.unlocked,
|
|
65
|
-
unlockUntilUnixMs: status.unlockUntilUnixMs,
|
|
66
|
-
},
|
|
67
|
-
state: {
|
|
68
|
-
changed: true,
|
|
69
|
-
unlocked: status.unlocked,
|
|
70
|
-
unlockUntilUnixMs: status.unlockUntilUnixMs,
|
|
71
|
-
},
|
|
72
|
-
}));
|
|
73
|
-
return 0;
|
|
74
|
-
}
|
|
75
25
|
writeLine(context.stdout, status.unlockUntilUnixMs === null
|
|
76
26
|
? "Client password changed."
|
|
77
27
|
: `Client password changed. Client unlocked until ${new Date(status.unlockUntilUnixMs).toISOString()}.`);
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
|
-
import { buildMinePromptData, buildMineSetupData, } from "../mining-json.js";
|
|
3
|
-
import { buildMineSetupPreviewData } from "../preview-json.js";
|
|
4
2
|
import { formatMiningPromptMutationReport } from "../mining-format.js";
|
|
5
3
|
import { writeLine } from "../io.js";
|
|
6
|
-
import {
|
|
7
|
-
import { createPreviewSuccessEnvelope, createMutationSuccessEnvelope, describeCanonicalCommand, resolvePreviewJsonSchema, resolveStableMiningControlJsonSchema, writeHandledCliError, writeJsonValue, } from "../output.js";
|
|
4
|
+
import { writeHandledCliError } from "../output.js";
|
|
8
5
|
import { formatNextStepLines, getMineSetupNextSteps } from "../workflow-hints.js";
|
|
9
6
|
import { withInteractiveWalletSecretProvider } from "../../wallet/state/provider.js";
|
|
10
|
-
function createCommandPrompter(
|
|
11
|
-
return
|
|
12
|
-
? createTerminalPrompter(context.stdin, context.stderr)
|
|
13
|
-
: context.createPrompter();
|
|
7
|
+
function createCommandPrompter(context) {
|
|
8
|
+
return context.createPrompter();
|
|
14
9
|
}
|
|
15
10
|
export async function runMiningAdminCommand(parsed, context) {
|
|
16
11
|
try {
|
|
17
|
-
const runtimePaths = context.resolveWalletRuntimePaths(
|
|
12
|
+
const runtimePaths = context.resolveWalletRuntimePaths();
|
|
18
13
|
const dbPath = parsed.dbPath ?? context.resolveDefaultClientDatabasePath();
|
|
19
14
|
const dataDir = parsed.dataDir ?? context.resolveDefaultBitcoindDataDir();
|
|
20
15
|
const packageVersion = await context.readPackageVersion();
|
|
21
16
|
if (parsed.command === "mine-setup") {
|
|
22
|
-
const prompter = createCommandPrompter(
|
|
17
|
+
const prompter = createCommandPrompter(context);
|
|
23
18
|
const provider = withInteractiveWalletSecretProvider(context.walletSecretProvider, prompter);
|
|
24
19
|
const view = await context.setupBuiltInMining({
|
|
25
20
|
provider,
|
|
@@ -27,18 +22,6 @@ export async function runMiningAdminCommand(parsed, context) {
|
|
|
27
22
|
paths: runtimePaths,
|
|
28
23
|
});
|
|
29
24
|
const nextSteps = getMineSetupNextSteps();
|
|
30
|
-
if (parsed.outputMode === "preview-json") {
|
|
31
|
-
writeJsonValue(context.stdout, createPreviewSuccessEnvelope(resolvePreviewJsonSchema(parsed), describeCanonicalCommand(parsed), "configured", buildMineSetupPreviewData(view), {
|
|
32
|
-
nextSteps,
|
|
33
|
-
}));
|
|
34
|
-
return 0;
|
|
35
|
-
}
|
|
36
|
-
if (parsed.outputMode === "json") {
|
|
37
|
-
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMiningControlJsonSchema(parsed), "cogcoin mine setup", "configured", buildMineSetupData(view), {
|
|
38
|
-
nextSteps,
|
|
39
|
-
}));
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
25
|
writeLine(context.stdout, "Built-in mining provider configured.");
|
|
43
26
|
writeLine(context.stdout, `Provider: ${view.provider.provider ?? "unknown"}`);
|
|
44
27
|
if (view.provider.modelId !== null) {
|
|
@@ -56,7 +39,7 @@ export async function runMiningAdminCommand(parsed, context) {
|
|
|
56
39
|
return 0;
|
|
57
40
|
}
|
|
58
41
|
if (parsed.command === "mine-prompt") {
|
|
59
|
-
const prompter = createCommandPrompter(
|
|
42
|
+
const prompter = createCommandPrompter(context);
|
|
60
43
|
if (!prompter.isInteractive) {
|
|
61
44
|
throw new Error("mine_prompt_requires_tty");
|
|
62
45
|
}
|
|
@@ -80,11 +63,9 @@ export async function runMiningAdminCommand(parsed, context) {
|
|
|
80
63
|
if (currentEntry === undefined) {
|
|
81
64
|
throw new Error("mine_prompt_domain_not_mineable");
|
|
82
65
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
writeLine(context.stdout, `Global fallback prompt: ${promptState.fallbackPromptConfigured ? "configured" : "not configured"}`);
|
|
87
|
-
}
|
|
66
|
+
writeLine(context.stdout, `Domain: ${currentEntry.domain.name}`);
|
|
67
|
+
writeLine(context.stdout, `Current domain prompt: ${currentEntry.prompt ?? "none"}`);
|
|
68
|
+
writeLine(context.stdout, `Global fallback prompt: ${promptState.fallbackPromptConfigured ? "configured" : "not configured"}`);
|
|
88
69
|
const nextPrompt = await prompter.prompt("Domain prompt (blank to clear and use the global fallback): ");
|
|
89
70
|
const result = await context.updateMiningDomainPrompt({
|
|
90
71
|
paths: runtimePaths,
|
|
@@ -93,10 +74,6 @@ export async function runMiningAdminCommand(parsed, context) {
|
|
|
93
74
|
domainName: targetDomain,
|
|
94
75
|
prompt: nextPrompt,
|
|
95
76
|
});
|
|
96
|
-
if (parsed.outputMode === "json") {
|
|
97
|
-
writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMiningControlJsonSchema(parsed), describeCanonicalCommand(parsed), result.status, buildMinePromptData(result)));
|
|
98
|
-
return 0;
|
|
99
|
-
}
|
|
100
77
|
writeLine(context.stdout, formatMiningPromptMutationReport(result));
|
|
101
78
|
return 0;
|
|
102
79
|
}
|
|
@@ -2,8 +2,7 @@ import { dirname } from "node:path";
|
|
|
2
2
|
import { stat } from "node:fs/promises";
|
|
3
3
|
import { formatMineStatusReport, formatMiningEventRecord, formatMiningPromptListReport, } from "../mining-format.js";
|
|
4
4
|
import { writeLine } from "../io.js";
|
|
5
|
-
import {
|
|
6
|
-
import { buildMineLogJson, buildMinePromptListJson, buildMineStatusJson } from "../read-json.js";
|
|
5
|
+
import { normalizeListPage, } from "../output.js";
|
|
7
6
|
import { formatNextStepLines } from "../workflow-hints.js";
|
|
8
7
|
import { withInteractiveWalletSecretProvider } from "../../wallet/state/provider.js";
|
|
9
8
|
async function readRotationIndices(paths) {
|
|
@@ -21,12 +20,19 @@ async function readRotationIndices(paths) {
|
|
|
21
20
|
}
|
|
22
21
|
return rotation;
|
|
23
22
|
}
|
|
23
|
+
function getMinePromptListNextSteps(result) {
|
|
24
|
+
if (result.prompts.length === 0) {
|
|
25
|
+
return ["cogcoin domains --mineable"];
|
|
26
|
+
}
|
|
27
|
+
const nextDomainPrompt = result.prompts.find((entry) => entry.mineable && entry.prompt === null);
|
|
28
|
+
return nextDomainPrompt === undefined ? [] : [`cogcoin mine prompt ${nextDomainPrompt.domain.name}`];
|
|
29
|
+
}
|
|
24
30
|
export async function runMiningReadCommand(parsed, context) {
|
|
25
31
|
try {
|
|
26
32
|
const dbPath = parsed.dbPath ?? context.resolveDefaultClientDatabasePath();
|
|
27
33
|
const dataDir = parsed.dataDir ?? context.resolveDefaultBitcoindDataDir();
|
|
28
34
|
const packageVersion = await context.readPackageVersion();
|
|
29
|
-
const runtimePaths = context.resolveWalletRuntimePaths(
|
|
35
|
+
const runtimePaths = context.resolveWalletRuntimePaths();
|
|
30
36
|
await context.ensureDirectory(dirname(dbPath));
|
|
31
37
|
if (parsed.command === "mine-log") {
|
|
32
38
|
if (!parsed.follow) {
|
|
@@ -41,27 +47,9 @@ export async function runMiningReadCommand(parsed, context) {
|
|
|
41
47
|
});
|
|
42
48
|
const events = normalized.items.slice().reverse();
|
|
43
49
|
if (events.length === 0) {
|
|
44
|
-
if (parsed.outputMode === "json") {
|
|
45
|
-
const result = buildMineLogJson(events, normalized.page, await readRotationIndices(runtimePaths));
|
|
46
|
-
writeJsonValue(context.stdout, createSuccessEnvelope("cogcoin/mine-log/v1", describeCanonicalCommand(parsed), result.data, {
|
|
47
|
-
warnings: result.warnings,
|
|
48
|
-
explanations: result.explanations,
|
|
49
|
-
nextSteps: result.nextSteps,
|
|
50
|
-
}));
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
50
|
writeLine(context.stdout, "No mining events recorded yet.");
|
|
54
51
|
return 0;
|
|
55
52
|
}
|
|
56
|
-
if (parsed.outputMode === "json") {
|
|
57
|
-
const result = buildMineLogJson(events, normalized.page, await readRotationIndices(runtimePaths));
|
|
58
|
-
writeJsonValue(context.stdout, createSuccessEnvelope("cogcoin/mine-log/v1", describeCanonicalCommand(parsed), result.data, {
|
|
59
|
-
warnings: result.warnings,
|
|
60
|
-
explanations: result.explanations,
|
|
61
|
-
nextSteps: result.nextSteps,
|
|
62
|
-
}));
|
|
63
|
-
return 0;
|
|
64
|
-
}
|
|
65
53
|
for (const event of events) {
|
|
66
54
|
writeLine(context.stdout, formatMiningEventRecord(event));
|
|
67
55
|
}
|
|
@@ -91,9 +79,7 @@ export async function runMiningReadCommand(parsed, context) {
|
|
|
91
79
|
return 0;
|
|
92
80
|
}
|
|
93
81
|
if (parsed.command === "mine-prompt-list") {
|
|
94
|
-
const provider =
|
|
95
|
-
? withInteractiveWalletSecretProvider(context.walletSecretProvider, context.createPrompter())
|
|
96
|
-
: context.walletSecretProvider;
|
|
82
|
+
const provider = withInteractiveWalletSecretProvider(context.walletSecretProvider, context.createPrompter());
|
|
97
83
|
const readContext = await context.openWalletReadContext({
|
|
98
84
|
dataDir,
|
|
99
85
|
databasePath: dbPath,
|
|
@@ -102,21 +88,13 @@ export async function runMiningReadCommand(parsed, context) {
|
|
|
102
88
|
paths: runtimePaths,
|
|
103
89
|
});
|
|
104
90
|
try {
|
|
105
|
-
const result =
|
|
91
|
+
const result = await context.inspectMiningDomainPromptState({
|
|
106
92
|
paths: runtimePaths,
|
|
107
93
|
provider,
|
|
108
94
|
readContext,
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
warnings: result.warnings,
|
|
113
|
-
explanations: result.explanations,
|
|
114
|
-
nextSteps: result.nextSteps,
|
|
115
|
-
}));
|
|
116
|
-
return 0;
|
|
117
|
-
}
|
|
118
|
-
writeLine(context.stdout, formatMiningPromptListReport(result.data));
|
|
119
|
-
for (const line of formatNextStepLines(result.nextSteps)) {
|
|
95
|
+
});
|
|
96
|
+
writeLine(context.stdout, formatMiningPromptListReport(result));
|
|
97
|
+
for (const line of formatNextStepLines(getMinePromptListNextSteps(result))) {
|
|
120
98
|
writeLine(context.stdout, line);
|
|
121
99
|
}
|
|
122
100
|
return 0;
|
|
@@ -125,9 +103,7 @@ export async function runMiningReadCommand(parsed, context) {
|
|
|
125
103
|
await readContext.close();
|
|
126
104
|
}
|
|
127
105
|
}
|
|
128
|
-
const provider =
|
|
129
|
-
? withInteractiveWalletSecretProvider(context.walletSecretProvider, context.createPrompter())
|
|
130
|
-
: context.walletSecretProvider;
|
|
106
|
+
const provider = withInteractiveWalletSecretProvider(context.walletSecretProvider, context.createPrompter());
|
|
131
107
|
const readContext = await context.openWalletReadContext({
|
|
132
108
|
dataDir,
|
|
133
109
|
databasePath: dbPath,
|
|
@@ -145,15 +121,6 @@ export async function runMiningReadCommand(parsed, context) {
|
|
|
145
121
|
indexer: readContext.indexer,
|
|
146
122
|
paths: runtimePaths,
|
|
147
123
|
});
|
|
148
|
-
if (parsed.outputMode === "json") {
|
|
149
|
-
const result = buildMineStatusJson(mining);
|
|
150
|
-
writeJsonValue(context.stdout, createSuccessEnvelope("cogcoin/mine-status/v1", describeCanonicalCommand(parsed), result.data, {
|
|
151
|
-
warnings: result.warnings,
|
|
152
|
-
explanations: result.explanations,
|
|
153
|
-
nextSteps: result.nextSteps,
|
|
154
|
-
}));
|
|
155
|
-
return 0;
|
|
156
|
-
}
|
|
157
124
|
writeLine(context.stdout, formatMineStatusReport(mining));
|
|
158
125
|
return 0;
|
|
159
126
|
}
|
|
@@ -163,14 +130,6 @@ export async function runMiningReadCommand(parsed, context) {
|
|
|
163
130
|
}
|
|
164
131
|
catch (error) {
|
|
165
132
|
const message = error instanceof Error ? error.message : String(error);
|
|
166
|
-
if (parsed.outputMode === "json") {
|
|
167
|
-
writeJsonValue(context.stdout, createErrorEnvelope(parsed.command === "mine-log"
|
|
168
|
-
? "cogcoin/mine-log/v1"
|
|
169
|
-
: parsed.command === "mine-prompt-list"
|
|
170
|
-
? "cogcoin/mine-prompt-list/v1"
|
|
171
|
-
: "cogcoin/mine-status/v1", describeCanonicalCommand(parsed), message, message));
|
|
172
|
-
return 5;
|
|
173
|
-
}
|
|
174
133
|
writeLine(context.stderr, message);
|
|
175
134
|
return 5;
|
|
176
135
|
}
|