@cogcoin/client 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/bitcoind/node.js +2 -1
- package/dist/bitcoind/progress/tty-renderer.js +3 -2
- package/dist/bitcoind/service.js +6 -24
- package/dist/bitcoind/types.d.ts +1 -0
- package/dist/bitcoind/types.js +1 -0
- 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/managed-core.d.ts +23 -0
- package/dist/wallet/lifecycle/managed-core.js +257 -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 +11 -0
- package/dist/wallet/lifecycle/repair.js +368 -0
- package/dist/wallet/lifecycle/setup.d.ts +16 -0
- package/dist/wallet/lifecycle/setup.js +430 -0
- package/dist/wallet/lifecycle/types.d.ts +125 -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.d.ts +5 -1
- package/dist/wallet/read/context.js +19 -4
- 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
package/dist/cli/output.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { FileLockBusyError } from "../wallet/fs/lock.js";
|
|
2
|
+
import { describeCanonicalCommandFromArgs } from "./command-registry.js";
|
|
2
3
|
export function writeJsonValue(stream, value) {
|
|
3
4
|
stream.write(`${JSON.stringify(value, jsonReplacer)}\n`);
|
|
4
5
|
}
|
|
5
|
-
export function isStructuredOutputMode(mode) {
|
|
6
|
-
return mode === "json" || mode === "preview-json";
|
|
7
|
-
}
|
|
8
6
|
function jsonReplacer(_key, value) {
|
|
9
7
|
return typeof value === "bigint" ? value.toString() : value;
|
|
10
8
|
}
|
|
@@ -255,7 +253,7 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
255
253
|
if (errorCode === "reset_wallet_choice_invalid") {
|
|
256
254
|
return {
|
|
257
255
|
what: "Wallet reset choice is invalid.",
|
|
258
|
-
why: "This reset path accepts only Enter for the default entropy-retaining reset, \"skip\", or \"
|
|
256
|
+
why: "This reset path accepts only Enter for the default entropy-retaining reset, \"skip\", or \"clear wallet entropy\".",
|
|
259
257
|
next: "Rerun `cogcoin reset` and enter one of the accepted wallet reset choices.",
|
|
260
258
|
};
|
|
261
259
|
}
|
|
@@ -263,7 +261,7 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
263
261
|
return {
|
|
264
262
|
what: "Entropy-retaining wallet reset is unavailable.",
|
|
265
263
|
why: "Cogcoin found wallet state, but it could not safely load and reconstruct it into a fresh wallet while preserving only the mnemonic-derived continuity data.",
|
|
266
|
-
next: "Rerun `cogcoin reset` and choose \"skip\" to keep the wallet unchanged, or type \"
|
|
264
|
+
next: "Rerun `cogcoin reset` and choose \"skip\" to keep the wallet unchanged, or type \"clear wallet entropy\" to erase it fully.",
|
|
267
265
|
};
|
|
268
266
|
}
|
|
269
267
|
if (errorCode === "reset_process_shutdown_failed") {
|
|
@@ -343,39 +341,60 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
343
341
|
next: "Run `cogcoin client change-password` in an interactive terminal.",
|
|
344
342
|
};
|
|
345
343
|
}
|
|
344
|
+
if (errorCode === "cli_restore_removed" || errorCode === "cli_wallet_restore_removed") {
|
|
345
|
+
return {
|
|
346
|
+
what: "Standalone restore commands were removed.",
|
|
347
|
+
why: "Cogcoin now uses `cogcoin init` as the single wallet setup entrypoint for both new and restored wallets.",
|
|
348
|
+
next: "Run `cogcoin init` and choose \"Restore existing wallet\".",
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (errorCode === "cli_wallet_delete_removed") {
|
|
352
|
+
return {
|
|
353
|
+
what: "`wallet delete` was removed.",
|
|
354
|
+
why: "Cogcoin no longer supports multiple local wallet seeds, so replacing the wallet now flows through reset and init.",
|
|
355
|
+
next: "Run `cogcoin reset`, choose \"clear wallet entropy\", then rerun `cogcoin init`.",
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
if (errorCode === "cli_seed_removed") {
|
|
359
|
+
return {
|
|
360
|
+
what: "`--seed` was removed.",
|
|
361
|
+
why: "Cogcoin now supports only a single local wallet instead of multiple named wallet seeds.",
|
|
362
|
+
next: "Use the current wallet directly, or run `cogcoin reset`, choose \"clear wallet entropy\", then rerun `cogcoin init` to import a different wallet.",
|
|
363
|
+
};
|
|
364
|
+
}
|
|
346
365
|
if (errorCode === "wallet_restore_requires_main_wallet") {
|
|
347
366
|
return {
|
|
348
|
-
what: "
|
|
349
|
-
why: "
|
|
350
|
-
next: "Run `cogcoin init
|
|
367
|
+
what: "Legacy multi-seed restore is no longer available.",
|
|
368
|
+
why: "Cogcoin no longer supports restoring into named imported wallet slots.",
|
|
369
|
+
next: "Run `cogcoin init` and choose \"Restore existing wallet\".",
|
|
351
370
|
};
|
|
352
371
|
}
|
|
353
372
|
if (errorCode === "wallet_seed_name_exists") {
|
|
354
373
|
return {
|
|
355
|
-
what: "
|
|
356
|
-
why: "This machine
|
|
357
|
-
next: "
|
|
374
|
+
what: "Legacy multi-seed state is still present.",
|
|
375
|
+
why: "This machine still has old named-wallet artifacts from the removed multi-seed model.",
|
|
376
|
+
next: "Run `cogcoin reset`, choose \"clear wallet entropy\", then rerun `cogcoin init`.",
|
|
358
377
|
};
|
|
359
378
|
}
|
|
360
379
|
if (errorCode === "wallet_seed_not_found") {
|
|
361
380
|
return {
|
|
362
|
-
what: "
|
|
363
|
-
why: "
|
|
364
|
-
next: "
|
|
381
|
+
what: "Legacy named-wallet state was not found.",
|
|
382
|
+
why: "Cogcoin no longer supports selecting named local wallet seeds.",
|
|
383
|
+
next: "Use the single current wallet, or run `cogcoin reset` and `cogcoin init` to replace it.",
|
|
365
384
|
};
|
|
366
385
|
}
|
|
367
386
|
if (errorCode === "wallet_seed_index_invalid") {
|
|
368
387
|
return {
|
|
369
|
-
what: "
|
|
370
|
-
why: "Cogcoin
|
|
371
|
-
next: "Run `cogcoin repair`,
|
|
388
|
+
what: "Legacy wallet-seed registry is invalid.",
|
|
389
|
+
why: "Cogcoin found old multi-seed metadata from a removed feature and could not trust it for cleanup decisions.",
|
|
390
|
+
next: "Run `cogcoin repair`, or reset the wallet state if you intend to replace the local wallet.",
|
|
372
391
|
};
|
|
373
392
|
}
|
|
374
393
|
if (errorCode === "wallet_delete_main_not_supported") {
|
|
375
394
|
return {
|
|
376
|
-
what: "
|
|
377
|
-
why: "
|
|
378
|
-
next: "
|
|
395
|
+
what: "`wallet delete` is no longer available.",
|
|
396
|
+
why: "Cogcoin no longer supports deleting named imported wallets because the client now has a single local wallet model.",
|
|
397
|
+
next: "Run `cogcoin reset`, choose \"clear wallet entropy\", then rerun `cogcoin init`.",
|
|
379
398
|
};
|
|
380
399
|
}
|
|
381
400
|
if (errorCode === "local-state-corrupt" || errorCode.includes("repair_required") || errorCode.includes("repair-required")) {
|
|
@@ -410,7 +429,7 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
410
429
|
return {
|
|
411
430
|
what: "Recovery phrase is invalid.",
|
|
412
431
|
why: "Mnemonic-only restore accepts only a valid 24-word English BIP39 phrase with a matching checksum.",
|
|
413
|
-
next: "Rerun `cogcoin
|
|
432
|
+
next: "Rerun `cogcoin init`, choose \"Restore existing wallet\", and enter the 24 recovery words in the original order.",
|
|
414
433
|
};
|
|
415
434
|
}
|
|
416
435
|
if (errorCode === "wallet_restore_replace_confirmation_required") {
|
|
@@ -422,23 +441,23 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
422
441
|
}
|
|
423
442
|
if (errorCode === "wallet_seed_name_invalid" || errorCode === "wallet_seed_name_reserved" || errorCode === "cli_invalid_seed_name") {
|
|
424
443
|
return {
|
|
425
|
-
what: "
|
|
426
|
-
why: "
|
|
427
|
-
next: "
|
|
444
|
+
what: "Named wallet seeds were removed.",
|
|
445
|
+
why: "Cogcoin no longer accepts named local wallet seeds because the client now uses a single wallet model.",
|
|
446
|
+
next: "Run `cogcoin init` for setup, or reset the wallet first if you need to replace it.",
|
|
428
447
|
};
|
|
429
448
|
}
|
|
430
449
|
if (errorCode === "cli_missing_seed_name") {
|
|
431
450
|
return {
|
|
432
|
-
what: "
|
|
433
|
-
why: "This
|
|
434
|
-
next: "
|
|
451
|
+
what: "Named wallet seeds were removed.",
|
|
452
|
+
why: "This version of Cogcoin no longer supports `--seed`.",
|
|
453
|
+
next: "Drop `--seed` and retry, or use reset plus init if you need to replace the wallet.",
|
|
435
454
|
};
|
|
436
455
|
}
|
|
437
456
|
if (errorCode === "cli_seed_not_supported_for_command" || errorCode === "wallet_init_seed_not_supported") {
|
|
438
457
|
return {
|
|
439
|
-
what: "
|
|
440
|
-
why: "
|
|
441
|
-
next: "Drop `--seed`
|
|
458
|
+
what: "Named wallet seeds were removed.",
|
|
459
|
+
why: "Cogcoin now operates on a single local wallet instead of multiple named wallet seeds.",
|
|
460
|
+
next: "Drop `--seed` and retry.",
|
|
442
461
|
};
|
|
443
462
|
}
|
|
444
463
|
if (errorCode === "cli_from_not_supported_for_command") {
|
|
@@ -487,7 +506,7 @@ export function createCliErrorPresentation(errorCode, fallbackMessage, error) {
|
|
|
487
506
|
return {
|
|
488
507
|
what: "`wallet import` is no longer available.",
|
|
489
508
|
why: "Portable encrypted wallet archives were removed from the client, so this version no longer imports wallet state from archive files.",
|
|
490
|
-
next: "Use `cogcoin
|
|
509
|
+
next: "Use `cogcoin init`, choose \"Restore existing wallet\", and enter the recovery mnemonic instead.",
|
|
491
510
|
};
|
|
492
511
|
}
|
|
493
512
|
if (errorCode === "cli_field_create_initial_value_not_supported") {
|
|
@@ -954,460 +973,12 @@ function classifiedAsBlockedMessage(errorCode) {
|
|
|
954
973
|
return isBlockedError(errorCode);
|
|
955
974
|
}
|
|
956
975
|
export function describeCanonicalCommand(parsed) {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
case "init":
|
|
960
|
-
case "wallet-init":
|
|
961
|
-
return "cogcoin init";
|
|
962
|
-
case "restore":
|
|
963
|
-
case "wallet-restore":
|
|
964
|
-
return "cogcoin restore";
|
|
965
|
-
case "wallet-delete":
|
|
966
|
-
return "cogcoin wallet delete";
|
|
967
|
-
case "wallet-show-mnemonic":
|
|
968
|
-
return "cogcoin wallet show-mnemonic";
|
|
969
|
-
case "client-unlock":
|
|
970
|
-
return "cogcoin client unlock";
|
|
971
|
-
case "client-lock":
|
|
972
|
-
return "cogcoin client lock";
|
|
973
|
-
case "client-change-password":
|
|
974
|
-
return "cogcoin client change-password";
|
|
975
|
-
case "bitcoin-transfer":
|
|
976
|
-
return `cogcoin bitcoin transfer ${args[0] ?? "<sats>"}`;
|
|
977
|
-
case "reset":
|
|
978
|
-
return "cogcoin reset";
|
|
979
|
-
case "repair":
|
|
980
|
-
return "cogcoin repair";
|
|
981
|
-
case "update":
|
|
982
|
-
return "cogcoin update";
|
|
983
|
-
case "anchor":
|
|
984
|
-
case "domain-anchor":
|
|
985
|
-
return `cogcoin anchor ${args[0] ?? "<domain>"}`;
|
|
986
|
-
case "register":
|
|
987
|
-
case "domain-register":
|
|
988
|
-
return `cogcoin register ${args[0] ?? "<domain>"}`;
|
|
989
|
-
case "transfer":
|
|
990
|
-
case "domain-transfer":
|
|
991
|
-
return `cogcoin transfer ${args[0] ?? "<domain>"}`;
|
|
992
|
-
case "sell":
|
|
993
|
-
case "domain-sell":
|
|
994
|
-
return `cogcoin sell ${args[0] ?? "<domain>"} ${args[1] ?? "<price>"}`;
|
|
995
|
-
case "unsell":
|
|
996
|
-
case "domain-unsell":
|
|
997
|
-
return `cogcoin unsell ${args[0] ?? "<domain>"}`;
|
|
998
|
-
case "buy":
|
|
999
|
-
case "domain-buy":
|
|
1000
|
-
return `cogcoin buy ${args[0] ?? "<domain>"}`;
|
|
1001
|
-
case "send":
|
|
1002
|
-
case "cog-send":
|
|
1003
|
-
return `cogcoin send ${args[0] ?? "<amount>"}`;
|
|
1004
|
-
case "claim":
|
|
1005
|
-
case "cog-claim":
|
|
1006
|
-
return `cogcoin claim ${args[0] ?? "<lock-id>"}`;
|
|
1007
|
-
case "reclaim":
|
|
1008
|
-
case "cog-reclaim":
|
|
1009
|
-
return `cogcoin reclaim ${args[0] ?? "<lock-id>"}`;
|
|
1010
|
-
case "cog-lock":
|
|
1011
|
-
return `cogcoin cog lock ${args[0] ?? "<amount>"}`;
|
|
1012
|
-
case "domain-endpoint-set":
|
|
1013
|
-
return `cogcoin domain endpoint set ${args[0] ?? "<domain>"}`;
|
|
1014
|
-
case "domain-endpoint-clear":
|
|
1015
|
-
return `cogcoin domain endpoint clear ${args[0] ?? "<domain>"}`;
|
|
1016
|
-
case "domain-delegate-set":
|
|
1017
|
-
return `cogcoin domain delegate set ${args[0] ?? "<domain>"} ${args[1] ?? "<btc-target>"}`;
|
|
1018
|
-
case "domain-delegate-clear":
|
|
1019
|
-
return `cogcoin domain delegate clear ${args[0] ?? "<domain>"}`;
|
|
1020
|
-
case "domain-miner-set":
|
|
1021
|
-
return `cogcoin domain miner set ${args[0] ?? "<domain>"} ${args[1] ?? "<btc-target>"}`;
|
|
1022
|
-
case "domain-miner-clear":
|
|
1023
|
-
return `cogcoin domain miner clear ${args[0] ?? "<domain>"}`;
|
|
1024
|
-
case "domain-canonical":
|
|
1025
|
-
return `cogcoin domain canonical ${args[0] ?? "<domain>"}`;
|
|
1026
|
-
case "field-create":
|
|
1027
|
-
return `cogcoin field create ${args[0] ?? "<domain>"} ${args[1] ?? "<field>"}`;
|
|
1028
|
-
case "field-set":
|
|
1029
|
-
return `cogcoin field set ${args[0] ?? "<domain>"} ${args[1] ?? "<field>"}`;
|
|
1030
|
-
case "field-clear":
|
|
1031
|
-
return `cogcoin field clear ${args[0] ?? "<domain>"} ${args[1] ?? "<field>"}`;
|
|
1032
|
-
case "rep-give":
|
|
1033
|
-
return `cogcoin rep give ${args[0] ?? "<source-domain>"} ${args[1] ?? "<target-domain>"} ${args[2] ?? "<amount>"}`;
|
|
1034
|
-
case "rep-revoke":
|
|
1035
|
-
return `cogcoin rep revoke ${args[0] ?? "<source-domain>"} ${args[1] ?? "<target-domain>"} ${args[2] ?? "<amount>"}`;
|
|
1036
|
-
case "wallet-address":
|
|
1037
|
-
case "address":
|
|
1038
|
-
return "cogcoin address";
|
|
1039
|
-
case "wallet-ids":
|
|
1040
|
-
case "ids":
|
|
1041
|
-
return "cogcoin ids";
|
|
1042
|
-
case "wallet-status":
|
|
1043
|
-
return "cogcoin wallet status";
|
|
1044
|
-
case "mine-setup":
|
|
1045
|
-
return "cogcoin mine setup";
|
|
1046
|
-
case "mine-prompt":
|
|
1047
|
-
return `cogcoin mine prompt ${args[0] ?? "<domain>"}`;
|
|
1048
|
-
case "mine-prompt-list":
|
|
1049
|
-
return "cogcoin mine prompt";
|
|
1050
|
-
case "mine-start":
|
|
1051
|
-
return "cogcoin mine start";
|
|
1052
|
-
case "mine-stop":
|
|
1053
|
-
return "cogcoin mine stop";
|
|
1054
|
-
case "mine-status":
|
|
1055
|
-
return "cogcoin mine status";
|
|
1056
|
-
case "mine-log":
|
|
1057
|
-
return `cogcoin mine log${parsed.follow ? " --follow" : ""}`;
|
|
1058
|
-
case "cog-balance":
|
|
1059
|
-
case "balance":
|
|
1060
|
-
return "cogcoin balance";
|
|
1061
|
-
case "cog-locks":
|
|
1062
|
-
case "locks":
|
|
1063
|
-
return "cogcoin locks";
|
|
1064
|
-
case "field-list":
|
|
1065
|
-
case "fields":
|
|
1066
|
-
return `cogcoin fields ${args[0] ?? "<domain>"}`;
|
|
1067
|
-
case "field-show":
|
|
1068
|
-
case "field":
|
|
1069
|
-
return `cogcoin field ${args[0] ?? "<domain>"} ${args[1] ?? "<field>"}`;
|
|
1070
|
-
case "domain-show":
|
|
1071
|
-
case "show":
|
|
1072
|
-
return `cogcoin show ${args[0] ?? "<domain>"}`;
|
|
1073
|
-
case "status":
|
|
1074
|
-
return "cogcoin status";
|
|
1075
|
-
case "domain-list":
|
|
1076
|
-
case "domains":
|
|
1077
|
-
return "cogcoin domains";
|
|
1078
|
-
default:
|
|
1079
|
-
return parsed.command === null ? "cogcoin" : `cogcoin ${parsed.command.replaceAll("-", " ")}`;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
export function inferOutputMode(argv) {
|
|
1083
|
-
const index = argv.lastIndexOf("--output");
|
|
1084
|
-
if (index === -1) {
|
|
1085
|
-
return "text";
|
|
1086
|
-
}
|
|
1087
|
-
const value = argv[index + 1];
|
|
1088
|
-
if (value === "json" || value === "preview-json") {
|
|
1089
|
-
return value;
|
|
1090
|
-
}
|
|
1091
|
-
return "text";
|
|
1092
|
-
}
|
|
1093
|
-
export function resolveStableJsonSchema(parsed) {
|
|
1094
|
-
switch (parsed.command) {
|
|
1095
|
-
case "status":
|
|
1096
|
-
return "cogcoin/status/v1";
|
|
1097
|
-
case "bitcoin-start":
|
|
1098
|
-
return "cogcoin/bitcoin-start/v1";
|
|
1099
|
-
case "bitcoin-stop":
|
|
1100
|
-
return "cogcoin/bitcoin-stop/v1";
|
|
1101
|
-
case "bitcoin-status":
|
|
1102
|
-
return "cogcoin/bitcoin-status/v1";
|
|
1103
|
-
case "indexer-start":
|
|
1104
|
-
return "cogcoin/indexer-start/v1";
|
|
1105
|
-
case "indexer-stop":
|
|
1106
|
-
return "cogcoin/indexer-stop/v1";
|
|
1107
|
-
case "indexer-status":
|
|
1108
|
-
return "cogcoin/indexer-status/v1";
|
|
1109
|
-
case "wallet-address":
|
|
1110
|
-
case "address":
|
|
1111
|
-
return "cogcoin/address/v1";
|
|
1112
|
-
case "wallet-ids":
|
|
1113
|
-
case "ids":
|
|
1114
|
-
return "cogcoin/ids/v1";
|
|
1115
|
-
case "wallet-status":
|
|
1116
|
-
return "cogcoin/wallet-status/v1";
|
|
1117
|
-
case "mine-status":
|
|
1118
|
-
return "cogcoin/mine-status/v1";
|
|
1119
|
-
case "mine-log":
|
|
1120
|
-
return "cogcoin/mine-log/v1";
|
|
1121
|
-
case "mine-prompt-list":
|
|
1122
|
-
return "cogcoin/mine-prompt-list/v1";
|
|
1123
|
-
case "balance":
|
|
1124
|
-
case "cog-balance":
|
|
1125
|
-
return "cogcoin/balance/v1";
|
|
1126
|
-
case "locks":
|
|
1127
|
-
case "cog-locks":
|
|
1128
|
-
return "cogcoin/locks/v1";
|
|
1129
|
-
case "domain-list":
|
|
1130
|
-
case "domains":
|
|
1131
|
-
return "cogcoin/domains/v1";
|
|
1132
|
-
case "domain-show":
|
|
1133
|
-
case "show":
|
|
1134
|
-
return "cogcoin/show/v1";
|
|
1135
|
-
case "fields":
|
|
1136
|
-
case "field-list":
|
|
1137
|
-
return "cogcoin/fields/v1";
|
|
1138
|
-
case "field":
|
|
1139
|
-
case "field-show":
|
|
1140
|
-
return "cogcoin/field/v1";
|
|
1141
|
-
default:
|
|
1142
|
-
return null;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
export function resolveStableMutationJsonSchema(parsed) {
|
|
1146
|
-
switch (parsed.command) {
|
|
1147
|
-
case "init":
|
|
1148
|
-
case "wallet-init":
|
|
1149
|
-
return "cogcoin/init/v1";
|
|
1150
|
-
case "restore":
|
|
1151
|
-
case "wallet-restore":
|
|
1152
|
-
return "cogcoin/restore/v1";
|
|
1153
|
-
case "client-unlock":
|
|
1154
|
-
return "cogcoin/client-unlock/v1";
|
|
1155
|
-
case "client-lock":
|
|
1156
|
-
return "cogcoin/client-lock/v1";
|
|
1157
|
-
case "client-change-password":
|
|
1158
|
-
return "cogcoin/client-change-password/v1";
|
|
1159
|
-
case "bitcoin-transfer":
|
|
1160
|
-
return "cogcoin/bitcoin-transfer/v1";
|
|
1161
|
-
case "wallet-delete":
|
|
1162
|
-
return "cogcoin/wallet-delete/v1";
|
|
1163
|
-
case "reset":
|
|
1164
|
-
return "cogcoin/reset/v1";
|
|
1165
|
-
case "repair":
|
|
1166
|
-
return "cogcoin/repair/v1";
|
|
1167
|
-
case "update":
|
|
1168
|
-
return "cogcoin/update/v1";
|
|
1169
|
-
case "anchor":
|
|
1170
|
-
case "domain-anchor":
|
|
1171
|
-
return "cogcoin/anchor/v1";
|
|
1172
|
-
case "register":
|
|
1173
|
-
case "domain-register":
|
|
1174
|
-
return "cogcoin/register/v1";
|
|
1175
|
-
case "transfer":
|
|
1176
|
-
case "domain-transfer":
|
|
1177
|
-
return "cogcoin/transfer/v1";
|
|
1178
|
-
case "sell":
|
|
1179
|
-
case "domain-sell":
|
|
1180
|
-
return "cogcoin/sell/v1";
|
|
1181
|
-
case "unsell":
|
|
1182
|
-
case "domain-unsell":
|
|
1183
|
-
return "cogcoin/unsell/v1";
|
|
1184
|
-
case "buy":
|
|
1185
|
-
case "domain-buy":
|
|
1186
|
-
return "cogcoin/buy/v1";
|
|
1187
|
-
case "send":
|
|
1188
|
-
case "cog-send":
|
|
1189
|
-
return "cogcoin/send/v1";
|
|
1190
|
-
case "claim":
|
|
1191
|
-
case "cog-claim":
|
|
1192
|
-
return "cogcoin/claim/v1";
|
|
1193
|
-
case "reclaim":
|
|
1194
|
-
case "cog-reclaim":
|
|
1195
|
-
return "cogcoin/reclaim/v1";
|
|
1196
|
-
case "cog-lock":
|
|
1197
|
-
return "cogcoin/cog-lock/v1";
|
|
1198
|
-
case "domain-endpoint-set":
|
|
1199
|
-
return "cogcoin/domain-endpoint-set/v1";
|
|
1200
|
-
case "domain-endpoint-clear":
|
|
1201
|
-
return "cogcoin/domain-endpoint-clear/v1";
|
|
1202
|
-
case "domain-delegate-set":
|
|
1203
|
-
return "cogcoin/domain-delegate-set/v1";
|
|
1204
|
-
case "domain-delegate-clear":
|
|
1205
|
-
return "cogcoin/domain-delegate-clear/v1";
|
|
1206
|
-
case "domain-miner-set":
|
|
1207
|
-
return "cogcoin/domain-miner-set/v1";
|
|
1208
|
-
case "domain-miner-clear":
|
|
1209
|
-
return "cogcoin/domain-miner-clear/v1";
|
|
1210
|
-
case "domain-canonical":
|
|
1211
|
-
return "cogcoin/domain-canonical/v1";
|
|
1212
|
-
case "field-create":
|
|
1213
|
-
return "cogcoin/field-create/v1";
|
|
1214
|
-
case "field-set":
|
|
1215
|
-
return "cogcoin/field-set/v1";
|
|
1216
|
-
case "field-clear":
|
|
1217
|
-
return "cogcoin/field-clear/v1";
|
|
1218
|
-
case "rep-give":
|
|
1219
|
-
return "cogcoin/rep-give/v1";
|
|
1220
|
-
case "rep-revoke":
|
|
1221
|
-
return "cogcoin/rep-revoke/v1";
|
|
1222
|
-
default:
|
|
1223
|
-
return null;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
export function resolveStableMiningControlJsonSchema(parsed) {
|
|
1227
|
-
switch (parsed.command) {
|
|
1228
|
-
case "mine-setup":
|
|
1229
|
-
return "cogcoin/mine-setup/v1";
|
|
1230
|
-
case "mine-prompt":
|
|
1231
|
-
return "cogcoin/mine-prompt/v1";
|
|
1232
|
-
case "mine-start":
|
|
1233
|
-
return "cogcoin/mine-start/v1";
|
|
1234
|
-
case "mine-stop":
|
|
1235
|
-
return "cogcoin/mine-stop/v1";
|
|
1236
|
-
default:
|
|
1237
|
-
return null;
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
export function resolvePreviewJsonSchema(parsed) {
|
|
1241
|
-
const stableMutationSchema = resolveStableMutationJsonSchema(parsed);
|
|
1242
|
-
const stableMiningControlSchema = resolveStableMiningControlJsonSchema(parsed);
|
|
1243
|
-
switch (parsed.command) {
|
|
1244
|
-
case "reset":
|
|
1245
|
-
case "repair":
|
|
1246
|
-
case "anchor":
|
|
1247
|
-
case "domain-anchor":
|
|
1248
|
-
case "register":
|
|
1249
|
-
case "domain-register":
|
|
1250
|
-
case "transfer":
|
|
1251
|
-
case "domain-transfer":
|
|
1252
|
-
case "sell":
|
|
1253
|
-
case "domain-sell":
|
|
1254
|
-
case "unsell":
|
|
1255
|
-
case "domain-unsell":
|
|
1256
|
-
case "buy":
|
|
1257
|
-
case "domain-buy":
|
|
1258
|
-
case "send":
|
|
1259
|
-
case "cog-send":
|
|
1260
|
-
case "claim":
|
|
1261
|
-
case "cog-claim":
|
|
1262
|
-
case "reclaim":
|
|
1263
|
-
case "cog-reclaim":
|
|
1264
|
-
case "cog-lock":
|
|
1265
|
-
case "domain-endpoint-set":
|
|
1266
|
-
case "domain-endpoint-clear":
|
|
1267
|
-
case "domain-delegate-set":
|
|
1268
|
-
case "domain-delegate-clear":
|
|
1269
|
-
case "domain-miner-set":
|
|
1270
|
-
case "domain-miner-clear":
|
|
1271
|
-
case "domain-canonical":
|
|
1272
|
-
case "field-create":
|
|
1273
|
-
case "field-set":
|
|
1274
|
-
case "field-clear":
|
|
1275
|
-
case "rep-give":
|
|
1276
|
-
case "rep-revoke":
|
|
1277
|
-
return stableMutationSchema === null
|
|
1278
|
-
? null
|
|
1279
|
-
: stableMutationSchema.replace(/^cogcoin\//, "cogcoin-preview/");
|
|
1280
|
-
case "mine-setup":
|
|
1281
|
-
case "mine-start":
|
|
1282
|
-
case "mine-stop":
|
|
1283
|
-
return stableMiningControlSchema === null
|
|
1284
|
-
? null
|
|
1285
|
-
: stableMiningControlSchema.replace(/^cogcoin\//, "cogcoin-preview/");
|
|
1286
|
-
default:
|
|
1287
|
-
return null;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
function createSchemaProbe(command) {
|
|
1291
|
-
return {
|
|
1292
|
-
command,
|
|
1293
|
-
args: [],
|
|
1294
|
-
help: false,
|
|
1295
|
-
version: false,
|
|
1296
|
-
outputMode: "json",
|
|
1297
|
-
dbPath: null,
|
|
1298
|
-
dataDir: null,
|
|
1299
|
-
progressOutput: "auto",
|
|
1300
|
-
seedName: null,
|
|
1301
|
-
unlockFor: null,
|
|
1302
|
-
assumeYes: false,
|
|
1303
|
-
force: false,
|
|
1304
|
-
forceRace: false,
|
|
1305
|
-
anchorMessage: null,
|
|
1306
|
-
transferTarget: null,
|
|
1307
|
-
endpointText: null,
|
|
1308
|
-
endpointJson: null,
|
|
1309
|
-
endpointBytes: null,
|
|
1310
|
-
fieldPermanent: false,
|
|
1311
|
-
fieldFormat: null,
|
|
1312
|
-
fieldValue: null,
|
|
1313
|
-
lockRecipientDomain: null,
|
|
1314
|
-
conditionHex: null,
|
|
1315
|
-
untilHeight: null,
|
|
1316
|
-
preimageHex: null,
|
|
1317
|
-
reviewText: null,
|
|
1318
|
-
satvb: null,
|
|
1319
|
-
locksClaimableOnly: false,
|
|
1320
|
-
locksReclaimableOnly: false,
|
|
1321
|
-
domainsAnchoredOnly: false,
|
|
1322
|
-
domainsListedOnly: false,
|
|
1323
|
-
domainsMineableOnly: false,
|
|
1324
|
-
listLimit: null,
|
|
1325
|
-
listAll: false,
|
|
1326
|
-
follow: false,
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
function isStableJsonCommand(command) {
|
|
1330
|
-
return resolveStableJsonSchema(createSchemaProbe(command)) !== null;
|
|
1331
|
-
}
|
|
1332
|
-
function isStableMutationJsonCommand(command) {
|
|
1333
|
-
return resolveStableMutationJsonSchema(createSchemaProbe(command)) !== null;
|
|
1334
|
-
}
|
|
1335
|
-
function isStableMiningControlJsonCommand(command) {
|
|
1336
|
-
return resolveStableMiningControlJsonSchema(createSchemaProbe(command)) !== null;
|
|
1337
|
-
}
|
|
1338
|
-
function isPreviewJsonCommand(command) {
|
|
1339
|
-
return resolvePreviewJsonSchema(createSchemaProbe(command)) !== null;
|
|
1340
|
-
}
|
|
1341
|
-
export function isJsonOutputSupportedCommand(command) {
|
|
1342
|
-
return isStableJsonCommand(command)
|
|
1343
|
-
|| isStableMutationJsonCommand(command)
|
|
1344
|
-
|| isStableMiningControlJsonCommand(command)
|
|
1345
|
-
|| isPreviewJsonCommand(command);
|
|
1346
|
-
}
|
|
1347
|
-
export function isPreviewJsonOutputSupportedCommand(command) {
|
|
1348
|
-
return isPreviewJsonCommand(command);
|
|
1349
|
-
}
|
|
1350
|
-
export function createCommandJsonErrorEnvelope(parsed, error) {
|
|
1351
|
-
const classified = classifyCliError(error);
|
|
1352
|
-
const presentation = createCliErrorPresentation(classified.errorCode, classified.message, error);
|
|
1353
|
-
const humanMessage = presentation?.what ?? classified.message;
|
|
1354
|
-
const explanations = presentation?.why === null || presentation?.why === undefined ? [] : [presentation.why];
|
|
1355
|
-
const nextSteps = presentation?.next === null || presentation?.next === undefined ? [] : [presentation.next];
|
|
1356
|
-
const details = createCliErrorDetails(classified.errorCode, humanMessage, classified.message);
|
|
1357
|
-
const stableMutationSchema = resolveStableMutationJsonSchema(parsed);
|
|
1358
|
-
const stableMiningControlSchema = resolveStableMiningControlJsonSchema(parsed);
|
|
1359
|
-
const previewSchema = resolvePreviewJsonSchema(parsed);
|
|
1360
|
-
if (parsed.outputMode === "preview-json" && previewSchema !== null) {
|
|
1361
|
-
return createPreviewErrorEnvelope(previewSchema, describeCanonicalCommand(parsed), classified.errorCode, humanMessage, {
|
|
1362
|
-
explanations,
|
|
1363
|
-
nextSteps,
|
|
1364
|
-
details,
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
if (stableMutationSchema !== null) {
|
|
1368
|
-
return createMutationErrorEnvelope(stableMutationSchema, describeCanonicalCommand(parsed), classified.errorCode, humanMessage, {
|
|
1369
|
-
explanations,
|
|
1370
|
-
nextSteps,
|
|
1371
|
-
details,
|
|
1372
|
-
});
|
|
1373
|
-
}
|
|
1374
|
-
if (stableMiningControlSchema !== null) {
|
|
1375
|
-
return createMutationErrorEnvelope(stableMiningControlSchema, describeCanonicalCommand(parsed), classified.errorCode, humanMessage, {
|
|
1376
|
-
explanations,
|
|
1377
|
-
nextSteps,
|
|
1378
|
-
details,
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
if (previewSchema !== null) {
|
|
1382
|
-
return createPreviewErrorEnvelope(previewSchema, describeCanonicalCommand(parsed), classified.errorCode, humanMessage, {
|
|
1383
|
-
explanations,
|
|
1384
|
-
nextSteps,
|
|
1385
|
-
details,
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
|
-
return createErrorEnvelope(resolveStableJsonSchema(parsed) ?? "cogcoin/cli/v1", describeCanonicalCommand(parsed), classified.errorCode, humanMessage, {
|
|
1389
|
-
explanations,
|
|
1390
|
-
nextSteps,
|
|
1391
|
-
details,
|
|
976
|
+
return describeCanonicalCommandFromArgs(parsed.command, parsed.args, {
|
|
977
|
+
follow: parsed.follow,
|
|
1392
978
|
});
|
|
1393
979
|
}
|
|
1394
|
-
function createCliErrorDetails(errorCode, humanMessage, rawMessage) {
|
|
1395
|
-
const details = {};
|
|
1396
|
-
const initMatch = /^wallet_init_confirmation_failed_word_(\d+)$/.exec(errorCode);
|
|
1397
|
-
if (initMatch !== null) {
|
|
1398
|
-
details.wordIndex = Number.parseInt(initMatch[1], 10);
|
|
1399
|
-
}
|
|
1400
|
-
if (humanMessage !== rawMessage) {
|
|
1401
|
-
details.rawMessage = rawMessage;
|
|
1402
|
-
}
|
|
1403
|
-
return details;
|
|
1404
|
-
}
|
|
1405
980
|
export function writeHandledCliError(options) {
|
|
1406
981
|
const classified = classifyCliError(options.error);
|
|
1407
|
-
if (isStructuredOutputMode(options.parsed.outputMode)) {
|
|
1408
|
-
writeJsonValue(options.stdout, createCommandJsonErrorEnvelope(options.parsed, options.error));
|
|
1409
|
-
return classified.exitCode;
|
|
1410
|
-
}
|
|
1411
982
|
const formatted = formatCliTextError(options.error);
|
|
1412
983
|
if (formatted !== null) {
|
|
1413
984
|
for (const line of formatted) {
|
package/dist/cli/parse.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ParsedCliArgs } from "./types.js";
|
|
2
|
-
export declare const HELP_TEXT
|
|
2
|
+
export declare const HELP_TEXT: string;
|
|
3
3
|
export declare function parseCliArgs(argv: string[]): ParsedCliArgs;
|