@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.
Files changed (107) hide show
  1. package/README.md +4 -5
  2. package/dist/bitcoind/indexer-daemon.d.ts +3 -7
  3. package/dist/bitcoind/indexer-daemon.js +43 -158
  4. package/dist/bitcoind/managed-runtime/bitcoind-policy.d.ts +16 -0
  5. package/dist/bitcoind/managed-runtime/bitcoind-policy.js +177 -0
  6. package/dist/bitcoind/managed-runtime/indexer-policy.d.ts +34 -0
  7. package/dist/bitcoind/managed-runtime/indexer-policy.js +200 -0
  8. package/dist/bitcoind/managed-runtime/status.d.ts +11 -0
  9. package/dist/bitcoind/managed-runtime/status.js +59 -0
  10. package/dist/bitcoind/managed-runtime/types.d.ts +37 -0
  11. package/dist/bitcoind/managed-runtime/types.js +1 -0
  12. package/dist/bitcoind/progress/tty-renderer.js +3 -2
  13. package/dist/bitcoind/service.d.ts +2 -7
  14. package/dist/bitcoind/service.js +46 -94
  15. package/dist/cli/command-registry.d.ts +39 -0
  16. package/dist/cli/command-registry.js +1132 -0
  17. package/dist/cli/commands/client-admin.js +6 -56
  18. package/dist/cli/commands/mining-admin.js +9 -32
  19. package/dist/cli/commands/mining-read.js +15 -56
  20. package/dist/cli/commands/mining-runtime.js +258 -57
  21. package/dist/cli/commands/service-runtime.js +1 -64
  22. package/dist/cli/commands/status.js +2 -15
  23. package/dist/cli/commands/update.js +6 -21
  24. package/dist/cli/commands/wallet-admin.js +18 -120
  25. package/dist/cli/commands/wallet-mutation.js +4 -7
  26. package/dist/cli/commands/wallet-read.js +31 -138
  27. package/dist/cli/context.js +2 -4
  28. package/dist/cli/mining-format.js +8 -2
  29. package/dist/cli/mutation-command-groups.d.ts +11 -11
  30. package/dist/cli/mutation-command-groups.js +9 -18
  31. package/dist/cli/mutation-json.d.ts +1 -17
  32. package/dist/cli/mutation-json.js +1 -28
  33. package/dist/cli/mutation-success.d.ts +0 -1
  34. package/dist/cli/mutation-success.js +0 -19
  35. package/dist/cli/output.d.ts +1 -10
  36. package/dist/cli/output.js +52 -481
  37. package/dist/cli/parse.d.ts +1 -1
  38. package/dist/cli/parse.js +38 -695
  39. package/dist/cli/runner.js +28 -113
  40. package/dist/cli/types.d.ts +7 -8
  41. package/dist/cli/update-notifier.js +1 -1
  42. package/dist/cli/wallet-format.js +1 -1
  43. package/dist/wallet/lifecycle/access.d.ts +5 -0
  44. package/dist/wallet/lifecycle/access.js +79 -0
  45. package/dist/wallet/lifecycle/context.d.ts +26 -0
  46. package/dist/wallet/lifecycle/context.js +58 -0
  47. package/dist/wallet/lifecycle/managed-core.d.ts +15 -0
  48. package/dist/wallet/lifecycle/managed-core.js +197 -0
  49. package/dist/wallet/lifecycle/repair-bitcoind.d.ts +10 -0
  50. package/dist/wallet/lifecycle/repair-bitcoind.js +142 -0
  51. package/dist/wallet/lifecycle/repair-indexer.d.ts +8 -0
  52. package/dist/wallet/lifecycle/repair-indexer.js +117 -0
  53. package/dist/wallet/lifecycle/repair-mining.d.ts +49 -0
  54. package/dist/wallet/lifecycle/repair-mining.js +304 -0
  55. package/dist/wallet/lifecycle/repair-runtime.d.ts +36 -0
  56. package/dist/wallet/lifecycle/repair-runtime.js +206 -0
  57. package/dist/wallet/lifecycle/repair.d.ts +9 -0
  58. package/dist/wallet/lifecycle/repair.js +127 -0
  59. package/dist/wallet/lifecycle/setup-prompts.d.ts +7 -0
  60. package/dist/wallet/lifecycle/setup-prompts.js +88 -0
  61. package/dist/wallet/lifecycle/setup-state.d.ts +26 -0
  62. package/dist/wallet/lifecycle/setup-state.js +159 -0
  63. package/dist/wallet/lifecycle/setup.d.ts +15 -0
  64. package/dist/wallet/lifecycle/setup.js +124 -0
  65. package/dist/wallet/lifecycle/types.d.ts +156 -0
  66. package/dist/wallet/lifecycle/types.js +1 -0
  67. package/dist/wallet/lifecycle.d.ts +4 -165
  68. package/dist/wallet/lifecycle.js +3 -1656
  69. package/dist/wallet/mining/candidate.d.ts +60 -0
  70. package/dist/wallet/mining/candidate.js +290 -0
  71. package/dist/wallet/mining/competitiveness.d.ts +22 -0
  72. package/dist/wallet/mining/competitiveness.js +640 -0
  73. package/dist/wallet/mining/control.js +7 -251
  74. package/dist/wallet/mining/cycle.d.ts +39 -0
  75. package/dist/wallet/mining/cycle.js +542 -0
  76. package/dist/wallet/mining/engine-state.d.ts +66 -0
  77. package/dist/wallet/mining/engine-state.js +211 -0
  78. package/dist/wallet/mining/engine-types.d.ts +173 -0
  79. package/dist/wallet/mining/engine-types.js +1 -0
  80. package/dist/wallet/mining/engine-utils.d.ts +7 -0
  81. package/dist/wallet/mining/engine-utils.js +75 -0
  82. package/dist/wallet/mining/events.d.ts +2 -0
  83. package/dist/wallet/mining/events.js +19 -0
  84. package/dist/wallet/mining/lifecycle.d.ts +71 -0
  85. package/dist/wallet/mining/lifecycle.js +355 -0
  86. package/dist/wallet/mining/projection.d.ts +61 -0
  87. package/dist/wallet/mining/projection.js +319 -0
  88. package/dist/wallet/mining/publish.d.ts +79 -0
  89. package/dist/wallet/mining/publish.js +614 -0
  90. package/dist/wallet/mining/runner.d.ts +12 -418
  91. package/dist/wallet/mining/runner.js +274 -3433
  92. package/dist/wallet/mining/supervisor.d.ts +134 -0
  93. package/dist/wallet/mining/supervisor.js +558 -0
  94. package/dist/wallet/mining/visualizer-sync.d.ts +42 -0
  95. package/dist/wallet/mining/visualizer-sync.js +166 -0
  96. package/dist/wallet/mining/visualizer.d.ts +1 -0
  97. package/dist/wallet/mining/visualizer.js +33 -18
  98. package/dist/wallet/read/context.js +13 -188
  99. package/dist/wallet/reset.d.ts +1 -1
  100. package/dist/wallet/reset.js +35 -11
  101. package/dist/wallet/runtime.d.ts +0 -6
  102. package/dist/wallet/runtime.js +2 -38
  103. package/dist/wallet/tx/common.d.ts +18 -0
  104. package/dist/wallet/tx/common.js +40 -26
  105. package/package.json +1 -1
  106. package/dist/wallet/state/seed-index.d.ts +0 -43
  107. package/dist/wallet/state/seed-index.js +0 -151
@@ -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 \"delete wallet\".",
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 \"delete wallet\" to erase it fully.",
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: "Main wallet is required before importing another seed.",
349
- why: "Named restore only creates imported seeds. Cogcoin requires the primary `main` wallet to exist first so shared local state has a canonical default seed.",
350
- next: "Run `cogcoin init`, then rerun `cogcoin restore --seed <name>`.",
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: "Seed name is already in use.",
356
- why: "This machine already has a wallet seed registered with that name.",
357
- next: "Choose a different `--seed` name, or delete the imported seed first with `cogcoin wallet delete --seed <name>`.",
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: "Seed was not found.",
363
- why: "No local wallet seed is registered under that name.",
364
- next: "Check `--seed <name>` and retry.",
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: "Wallet seed registry is invalid.",
370
- why: "Cogcoin could not parse or trust the local seed registry file, so it cannot safely decide which named wallet seed to use.",
371
- next: "Run `cogcoin repair`, then retry the command.",
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: "The main wallet cannot be deleted with `wallet delete`.",
377
- why: "This command only removes imported seeds. The canonical `main` wallet is part of the base local client state.",
378
- next: "Use `cogcoin reset` if you need to remove the main wallet.",
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 restore --seed <name>` and enter the 24 recovery words in the original order.",
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: "Seed name is invalid.",
426
- why: "Wallet seed names must be lowercase slugs like `trading` or `cold-backup`, and `main` is reserved.",
427
- next: "Choose a different seed name and retry.",
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: "A seed name is required.",
433
- why: "This command needs `--seed <name>` to identify which imported wallet seed it should restore or delete.",
434
- next: "Rerun the command with `--seed <name>`.",
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: "This command does not support `--seed`.",
440
- why: "Only wallet-aware commands are seed-selectable. Global lifecycle and shared service commands still operate on the shared local client state.",
441
- next: "Drop `--seed` for this command and retry.",
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 restore --seed <name>` with the recovery mnemonic instead.",
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
- const args = parsed.args;
958
- switch (parsed.command) {
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) {
@@ -1,3 +1,3 @@
1
1
  import type { ParsedCliArgs } from "./types.js";
2
- export declare const HELP_TEXT = "Usage: cogcoin <command> [options]\n\nCommands:\n status Show wallet-aware local service and chain status\n status --output json Emit the stable v1 machine-readable status envelope\n update Show the current and latest client versions and install updates\n update --output json Emit the stable v1 machine-readable update result envelope\n client unlock Unlock password-protected local wallet secrets for a limited time\n client lock Flush the cached client password unlock session\n client change-password Rotate the client password that protects local wallet secrets\n bitcoin start Start the managed Bitcoin daemon\n bitcoin stop Stop the managed Bitcoin daemon and paired indexer\n bitcoin status Show managed Bitcoin daemon status without starting it\n bitcoin transfer <sats> --to <address>\n Send plain BTC from the wallet address\n indexer start Start the managed Cogcoin indexer (and bitcoind if needed)\n indexer stop Stop the managed Cogcoin indexer only\n indexer status Show managed Cogcoin indexer status without starting it\n init Initialize a new local wallet root\n init --output json Emit the stable v1 machine-readable init result envelope\n restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n reset Factory-reset local Cogcoin state with interactive retention prompts\n repair Recover bounded wallet/indexer/runtime state\n wallet address Alias for address\n wallet ids Alias for ids\n mine Run the miner in the foreground\n mine start Start the miner as a background worker\n mine stop Stop the active background miner\n mine setup Configure the built-in mining provider\n mine setup --output json\n Emit the stable v1 machine-readable mine setup result envelope\n mine prompt Show per-domain mining prompt state\n mine prompt --output json\n Emit the stable v1 machine-readable mine prompt list envelope\n mine prompt <domain> Configure a per-domain mining prompt override\n mine prompt <domain> --output json\n Emit the stable v1 machine-readable mine prompt result envelope\n mine prompt list Alias for mine prompt\n mine status Show mining control-plane health and readiness\n mine log Show recent mining control-plane events\n anchor <domain> Anchor an owned unanchored domain with the wallet address\n register <domain>\n Register a root domain or subdomain\n transfer <domain> --to <btc-target>\n Transfer an unanchored domain to another BTC address or script\n sell <domain> <price> List an unanchored domain for sale in COG\n unsell <domain> Clear an active domain listing\n buy <domain>\n Buy an unanchored listed domain in COG\n send <amount> --to <btc-target>\n Send COG from the wallet address to another BTC target\n claim <lock-id> --preimage <32-byte-hex>\n Claim an active COG lock before timeout\n reclaim <lock-id> Reclaim an expired COG lock as the original locker\n cog lock <amount> --to-domain <domain> (--for <blocks-or-duration> | --until-height <height>) --condition <sha256hex>\n Lock COG to an anchored recipient domain\n wallet status Show detailed wallet-local status and service health\n wallet init Initialize a new local wallet root\n wallet restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n wallet delete Delete one imported named seed without affecting main\n wallet show-mnemonic Reveal the initialized wallet recovery phrase after typed confirmation\n address Show the BTC wallet address for this wallet\n ids Show the local wallet address\n balance Show local wallet COG balances\n locks Show locally related active COG locks\n domain list Alias for domains\n domain show <domain> Alias for show <domain>\n domains [--anchored] [--listed] [--mineable]\n Show locally related domains\n show <domain> Show one domain and its local-wallet relationship\n fields <domain> List current fields on a domain\n field <domain> <field> Show one current field value\n field create <domain> <field>\n Create a new empty anchored field\n field set <domain> <field>\n Update an existing anchored field value\n field clear <domain> <field>\n Clear an existing anchored field value\n rep give <source-domain> <target-domain> <amount>\n Burn COG as anchored-domain reputation support\n rep revoke <source-domain> <target-domain> <amount>\n Revoke visible support without refunding burned COG\n\nOptions:\n --db <path> Override the SQLite database path\n --data-dir <path> Override the managed bitcoin datadir\n --for <duration> Relative timeout for cog lock, like 15m, 2h, or 1d\n --message <text> Founding message text for anchor\n --to <btc-target> Transfer or send target as an address or spk:<hex>\n --to-domain <domain>\n Recipient domain for cog lock\n --condition <sha256hex>\n 32-byte lock condition hash\n --until-height <height>\n Absolute timeout height for cog lock\n --preimage <32-byte-hex>\n Claim preimage for an active lock\n --review <text> Optional public review text for reputation operations\n --satvb <n> Override the mutation fee rate in sat/vB\n --text <utf8> UTF-8 payload text for endpoint or field writes\n --json <json> UTF-8 payload JSON text for endpoint or field writes\n --bytes <spec> Payload bytes as hex:<hex> or @<path>\n --permanent Create the field as permanent\n --format <spec> Advanced field format as raw:<u8>\n --value <spec> Advanced field value as hex:<hex>, @<path>, or utf8:<text>\n --claimable Show only currently claimable locks\n --reclaimable Show only currently reclaimable locks\n --anchored Show only anchored domains\n --listed Show only currently listed domains\n --mineable Show only locally mineable root domains\n --limit <n> Limit list rows (1..1000)\n --all Show all rows for list commands\n --follow Follow mining log output\n --output <mode> Output mode: text, json, or preview-json\n --progress <mode> Progress output mode: auto, tty, or none\n --seed <name> Select an imported wallet seed for wallet-aware commands\n --force Reserved for future use\n --force-race Allow a visible root registration race\n --yes Approve eligible plain yes/no mutation confirmations non-interactively\n --help Show help\n --version Show package version\n\nQuickstart:\n 1. Run `cogcoin init` to create the wallet.\n 2. Run `cogcoin sync` to bootstrap assumeutxo and the managed Bitcoin/indexer state.\n 3. Run `cogcoin address`, then fund the wallet with about 0.0015 BTC so you can buy a 6+ character domain to start mining and still keep BTC available for mining transaction fees.\n\nExamples:\n cogcoin status --output json\n cogcoin bitcoin status\n cogcoin indexer status\n cogcoin init --output json\n cogcoin restore --seed trading\n cogcoin wallet address\n cogcoin domain list --mineable\n cogcoin register alpha-child\n cogcoin anchor alpha\n cogcoin register alpha --satvb 12.5\n cogcoin buy alpha\n cogcoin field set alpha bio --text \"hello\"\n cogcoin rep give alpha beta 10 --review \"great operator\"\n cogcoin mine setup --output json\n cogcoin mine prompt\n cogcoin mine prompt alpha\n cogcoin register alpha-child --output preview-json\n cogcoin mine status\n";
2
+ export declare const HELP_TEXT: string;
3
3
  export declare function parseCliArgs(argv: string[]): ParsedCliArgs;