@cogcoin/client 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +11 -2
  2. package/dist/bitcoind/bootstrap/chainstate.d.ts +2 -1
  3. package/dist/bitcoind/bootstrap/chainstate.js +4 -1
  4. package/dist/bitcoind/bootstrap/controller.d.ts +4 -1
  5. package/dist/bitcoind/bootstrap/controller.js +42 -5
  6. package/dist/bitcoind/bootstrap/getblock-archive.d.ts +39 -0
  7. package/dist/bitcoind/bootstrap/getblock-archive.js +548 -0
  8. package/dist/bitcoind/bootstrap/headers.d.ts +12 -0
  9. package/dist/bitcoind/bootstrap/headers.js +95 -10
  10. package/dist/bitcoind/bootstrap.d.ts +1 -0
  11. package/dist/bitcoind/bootstrap.js +1 -0
  12. package/dist/bitcoind/client/factory.js +91 -28
  13. package/dist/bitcoind/client/managed-client.d.ts +1 -1
  14. package/dist/bitcoind/client/managed-client.js +4 -3
  15. package/dist/bitcoind/client/sync-engine.js +55 -13
  16. package/dist/bitcoind/errors.js +18 -0
  17. package/dist/bitcoind/indexer-daemon-main.js +78 -0
  18. package/dist/bitcoind/indexer-daemon.d.ts +10 -1
  19. package/dist/bitcoind/indexer-daemon.js +44 -28
  20. package/dist/bitcoind/node.js +2 -0
  21. package/dist/bitcoind/processing-start-height.d.ts +7 -0
  22. package/dist/bitcoind/processing-start-height.js +9 -0
  23. package/dist/bitcoind/progress/constants.d.ts +1 -0
  24. package/dist/bitcoind/progress/constants.js +1 -0
  25. package/dist/bitcoind/progress/controller.d.ts +22 -0
  26. package/dist/bitcoind/progress/controller.js +49 -23
  27. package/dist/bitcoind/progress/formatting.js +29 -1
  28. package/dist/bitcoind/progress/render-policy.d.ts +35 -0
  29. package/dist/bitcoind/progress/render-policy.js +81 -0
  30. package/dist/bitcoind/retryable-rpc.d.ts +11 -0
  31. package/dist/bitcoind/retryable-rpc.js +30 -0
  32. package/dist/bitcoind/service-paths.js +2 -6
  33. package/dist/bitcoind/service.d.ts +21 -2
  34. package/dist/bitcoind/service.js +274 -122
  35. package/dist/bitcoind/testing.d.ts +2 -2
  36. package/dist/bitcoind/testing.js +2 -2
  37. package/dist/bitcoind/types.d.ts +36 -1
  38. package/dist/cli/commands/follow.js +11 -0
  39. package/dist/cli/commands/getblock-archive-restart.d.ts +5 -0
  40. package/dist/cli/commands/getblock-archive-restart.js +15 -0
  41. package/dist/cli/commands/mining-admin.js +4 -0
  42. package/dist/cli/commands/mining-read.js +8 -5
  43. package/dist/cli/commands/mining-runtime.js +4 -0
  44. package/dist/cli/commands/service-runtime.js +150 -134
  45. package/dist/cli/commands/status.js +2 -0
  46. package/dist/cli/commands/sync.js +11 -0
  47. package/dist/cli/commands/wallet-admin.js +106 -24
  48. package/dist/cli/commands/wallet-mutation.js +57 -4
  49. package/dist/cli/commands/wallet-read.js +2 -0
  50. package/dist/cli/context.js +8 -4
  51. package/dist/cli/mutation-command-groups.d.ts +2 -1
  52. package/dist/cli/mutation-command-groups.js +5 -0
  53. package/dist/cli/mutation-json.d.ts +18 -2
  54. package/dist/cli/mutation-json.js +49 -0
  55. package/dist/cli/mutation-success.d.ts +1 -0
  56. package/dist/cli/mutation-success.js +2 -2
  57. package/dist/cli/output.js +86 -1
  58. package/dist/cli/parse.d.ts +1 -1
  59. package/dist/cli/parse.js +133 -3
  60. package/dist/cli/preview-json.d.ts +10 -1
  61. package/dist/cli/preview-json.js +32 -0
  62. package/dist/cli/prompt.js +1 -1
  63. package/dist/cli/runner.js +4 -0
  64. package/dist/cli/types.d.ts +15 -5
  65. package/dist/cli/types.js +1 -1
  66. package/dist/cli/wallet-format.js +140 -14
  67. package/dist/wallet/lifecycle.d.ts +21 -1
  68. package/dist/wallet/lifecycle.js +252 -116
  69. package/dist/wallet/mining/visualizer.d.ts +11 -6
  70. package/dist/wallet/mining/visualizer.js +32 -15
  71. package/dist/wallet/read/context.js +10 -4
  72. package/dist/wallet/reset.d.ts +61 -2
  73. package/dist/wallet/reset.js +246 -89
  74. package/dist/wallet/root-resolution.d.ts +20 -0
  75. package/dist/wallet/root-resolution.js +37 -0
  76. package/dist/wallet/runtime.d.ts +13 -1
  77. package/dist/wallet/runtime.js +54 -11
  78. package/dist/wallet/state/crypto.d.ts +3 -0
  79. package/dist/wallet/state/crypto.js +3 -0
  80. package/dist/wallet/state/provider.d.ts +1 -0
  81. package/dist/wallet/state/provider.js +119 -3
  82. package/dist/wallet/state/seed-index.d.ts +43 -0
  83. package/dist/wallet/state/seed-index.js +151 -0
  84. package/dist/wallet/state/storage.d.ts +7 -1
  85. package/dist/wallet/state/storage.js +39 -0
  86. package/dist/wallet/tx/anchor.d.ts +22 -0
  87. package/dist/wallet/tx/anchor.js +215 -8
  88. package/dist/wallet/tx/index.d.ts +1 -1
  89. package/dist/wallet/tx/index.js +1 -1
  90. package/dist/wallet/types.d.ts +1 -0
  91. package/package.json +1 -1
@@ -140,6 +140,36 @@ export function buildAnchorMutationData(result, options) {
140
140
  },
141
141
  });
142
142
  }
143
+ export function buildAnchorClearMutationData(result) {
144
+ const before = result.cleared
145
+ ? {
146
+ localAnchorIntent: "reserved",
147
+ dedicatedIndex: result.releasedDedicatedIndex,
148
+ familyStatus: result.previousFamilyStatus,
149
+ familyStep: result.previousFamilyStep,
150
+ }
151
+ : null;
152
+ const after = result.cleared
153
+ ? {
154
+ localAnchorIntent: "none",
155
+ dedicatedIndex: null,
156
+ familyStatus: "canceled",
157
+ familyStep: result.previousFamilyStep,
158
+ }
159
+ : null;
160
+ return buildStateChangeData({
161
+ kind: "anchor-clear",
162
+ state: {
163
+ domainName: result.domainName,
164
+ cleared: result.cleared,
165
+ previousFamilyStatus: result.previousFamilyStatus,
166
+ previousFamilyStep: result.previousFamilyStep,
167
+ releasedDedicatedIndex: result.releasedDedicatedIndex,
168
+ },
169
+ before,
170
+ after,
171
+ });
172
+ }
143
173
  export function buildResetMutationData(result) {
144
174
  return buildOperationData({
145
175
  kind: "reset",
@@ -150,6 +180,7 @@ export function buildResetMutationData(result) {
150
180
  walletOldRootId: result.walletOldRootId,
151
181
  walletNewRootId: result.walletNewRootId,
152
182
  bootstrapSnapshot: result.bootstrapSnapshot,
183
+ bitcoinDataDir: result.bitcoinDataDir,
153
184
  stoppedProcesses: result.stoppedProcesses,
154
185
  secretCleanupStatus: result.secretCleanupStatus,
155
186
  },
@@ -165,10 +196,26 @@ export function buildResetMutationData(result) {
165
196
  walletOldRootId: result.walletOldRootId,
166
197
  walletNewRootId: result.walletNewRootId,
167
198
  bootstrapSnapshot: result.bootstrapSnapshot,
199
+ bitcoinDataDir: result.bitcoinDataDir,
168
200
  removedPaths: result.removedPaths,
169
201
  },
170
202
  });
171
203
  }
204
+ export function buildWalletDeleteMutationData(result) {
205
+ return buildOperationData({
206
+ kind: "wallet-delete",
207
+ state: {
208
+ seedName: result.seedName,
209
+ walletRootId: result.walletRootId,
210
+ deleted: result.deleted,
211
+ },
212
+ operation: {
213
+ seedName: result.seedName,
214
+ walletRootId: result.walletRootId,
215
+ deleted: result.deleted,
216
+ },
217
+ });
218
+ }
172
219
  export function buildDomainAdminMutationData(result, options) {
173
220
  const data = buildSingleTxMutationData({
174
221
  kind: options.commandKind,
@@ -259,6 +306,7 @@ export function buildWalletLockMutationData(result) {
259
306
  }
260
307
  export function buildInitMutationData(result) {
261
308
  const after = {
309
+ seedName: "main",
262
310
  walletRootId: result.walletRootId,
263
311
  fundingAddress: result.fundingAddress,
264
312
  unlockUntilUnixMs: result.unlockUntilUnixMs,
@@ -273,6 +321,7 @@ export function buildInitMutationData(result) {
273
321
  }
274
322
  export function buildRestoreMutationData(result) {
275
323
  const after = {
324
+ seedName: result.seedName ?? null,
276
325
  walletRootId: result.walletRootId,
277
326
  fundingAddress: result.fundingAddress,
278
327
  unlockUntilUnixMs: result.unlockUntilUnixMs,
@@ -12,6 +12,7 @@ export declare function writeMutationCommandSuccess(parsed: ParsedCliArgs, conte
12
12
  reusedExisting: boolean;
13
13
  reusedMessage: string;
14
14
  nextSteps: MutationSuccessNextSteps;
15
+ outcome?: string;
15
16
  text: {
16
17
  heading: string;
17
18
  fields: MutationTextField[];
@@ -21,7 +21,7 @@ function reuseExplanation(reusedExisting, message) {
21
21
  }
22
22
  export function writeMutationCommandSuccess(parsed, context, options) {
23
23
  if (parsed.outputMode === "preview-json") {
24
- writeJsonValue(context.stdout, createPreviewSuccessEnvelope(resolvePreviewJsonSchema(parsed), describeCanonicalCommand(parsed), mutationOutcome(options.reusedExisting), options.previewData ?? options.data, {
24
+ writeJsonValue(context.stdout, createPreviewSuccessEnvelope(resolvePreviewJsonSchema(parsed), describeCanonicalCommand(parsed), options.outcome ?? mutationOutcome(options.reusedExisting), options.previewData ?? options.data, {
25
25
  explanations: reuseExplanation(options.reusedExisting, options.reusedMessage),
26
26
  nextSteps: options.nextSteps.json,
27
27
  warnings: options.warnings,
@@ -29,7 +29,7 @@ export function writeMutationCommandSuccess(parsed, context, options) {
29
29
  return 0;
30
30
  }
31
31
  if (parsed.outputMode === "json") {
32
- writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMutationJsonSchema(parsed), describeCanonicalCommand(parsed), mutationOutcome(options.reusedExisting), options.data, {
32
+ writeJsonValue(context.stdout, createMutationSuccessEnvelope(resolveStableMutationJsonSchema(parsed), describeCanonicalCommand(parsed), options.outcome ?? mutationOutcome(options.reusedExisting), options.data, {
33
33
  explanations: reuseExplanation(options.reusedExisting, options.reusedMessage),
34
34
  nextSteps: options.nextSteps.json,
35
35
  warnings: options.warnings,
@@ -151,10 +151,13 @@ export function classifyCliError(error) {
151
151
  }
152
152
  if (message === "wallet_typed_confirmation_rejected"
153
153
  || message === "wallet_export_overwrite_declined"
154
+ || message === "wallet_delete_confirmation_required"
154
155
  || message === "wallet_prompt_value_required"
155
156
  || message === "wallet_archive_passphrase_mismatch"
156
157
  || message === "wallet_restore_mnemonic_invalid"
157
158
  || message === "wallet_restore_replace_confirmation_required"
159
+ || message === "wallet_seed_name_invalid"
160
+ || message === "wallet_seed_name_reserved"
158
161
  || message === "reset_wallet_choice_invalid"
159
162
  || message === "reset_wallet_passphrase_required"
160
163
  || message === "reset_wallet_access_failed") {
@@ -185,6 +188,10 @@ function isBlockedError(message) {
185
188
  || message === "wallet_export_core_replica_not_ready"
186
189
  || message === "wallet_export_tip_mismatch"
187
190
  || message === "wallet_export_requires_quiescent_local_state"
191
+ || message === "wallet_restore_requires_main_wallet"
192
+ || message === "wallet_seed_name_exists"
193
+ || message === "wallet_seed_not_found"
194
+ || message === "wallet_delete_main_not_supported"
188
195
  || message === "wallet_repair_indexer_reset_requires_yes"
189
196
  || message === "managed_bitcoind_service_version_mismatch"
190
197
  || message === "managed_bitcoind_wallet_root_mismatch"
@@ -303,6 +310,34 @@ export function createCliErrorPresentation(errorCode, fallbackMessage) {
303
310
  next: "Run `cogcoin status` to inspect the existing wallet, or export/import it instead of reinitializing.",
304
311
  };
305
312
  }
313
+ if (errorCode === "wallet_restore_requires_main_wallet") {
314
+ return {
315
+ what: "Main wallet is required before importing another seed.",
316
+ 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.",
317
+ next: "Run `cogcoin init`, then rerun `cogcoin restore --seed <name>`.",
318
+ };
319
+ }
320
+ if (errorCode === "wallet_seed_name_exists") {
321
+ return {
322
+ what: "Seed name is already in use.",
323
+ why: "This machine already has a wallet seed registered with that name.",
324
+ next: "Choose a different `--seed` name, or delete the imported seed first with `cogcoin wallet delete --seed <name>`.",
325
+ };
326
+ }
327
+ if (errorCode === "wallet_seed_not_found") {
328
+ return {
329
+ what: "Seed was not found.",
330
+ why: "No local wallet seed is registered under that name.",
331
+ next: "Check `--seed <name>` and retry.",
332
+ };
333
+ }
334
+ if (errorCode === "wallet_delete_main_not_supported") {
335
+ return {
336
+ what: "The main wallet cannot be deleted with `wallet delete`.",
337
+ why: "This command only removes imported seeds. The canonical `main` wallet is part of the base local client state.",
338
+ next: "Use `cogcoin reset` if you need to remove the main wallet.",
339
+ };
340
+ }
306
341
  if (errorCode === "local-state-corrupt" || errorCode.includes("repair_required") || errorCode.includes("repair-required")) {
307
342
  return {
308
343
  what: "Local recovery is required.",
@@ -342,7 +377,7 @@ export function createCliErrorPresentation(errorCode, fallbackMessage) {
342
377
  return {
343
378
  what: "Recovery phrase is invalid.",
344
379
  why: "Mnemonic-only restore accepts only a valid 24-word English BIP39 phrase with a matching checksum.",
345
- next: "Rerun `cogcoin restore` and enter the 24 recovery words in the original order.",
380
+ next: "Rerun `cogcoin restore --seed <name>` and enter the 24 recovery words in the original order.",
346
381
  };
347
382
  }
348
383
  if (errorCode === "wallet_restore_replace_confirmation_required") {
@@ -352,6 +387,41 @@ export function createCliErrorPresentation(errorCode, fallbackMessage) {
352
387
  next: "Rerun `cogcoin restore` in an interactive terminal and type \"RESTORE\" when prompted.",
353
388
  };
354
389
  }
390
+ if (errorCode === "wallet_seed_name_invalid" || errorCode === "wallet_seed_name_reserved" || errorCode === "cli_invalid_seed_name") {
391
+ return {
392
+ what: "Seed name is invalid.",
393
+ why: "Wallet seed names must be lowercase slugs like `trading` or `cold-backup`, and `main` is reserved.",
394
+ next: "Choose a different seed name and retry.",
395
+ };
396
+ }
397
+ if (errorCode === "cli_missing_seed_name") {
398
+ return {
399
+ what: "A seed name is required.",
400
+ why: "This command needs `--seed <name>` to identify which imported wallet seed it should restore or delete.",
401
+ next: "Rerun the command with `--seed <name>`.",
402
+ };
403
+ }
404
+ if (errorCode === "cli_seed_not_supported_for_command" || errorCode === "wallet_init_seed_not_supported" || errorCode === "wallet_import_seed_not_supported") {
405
+ return {
406
+ what: "This command does not support `--seed`.",
407
+ why: "Only wallet-aware commands are seed-selectable. Global lifecycle and shared service commands still operate on the shared local client state.",
408
+ next: "Drop `--seed` for this command and retry.",
409
+ };
410
+ }
411
+ if (errorCode === "wallet_anchor_clear_inconsistent_state") {
412
+ return {
413
+ what: "Pending anchor state is inconsistent.",
414
+ why: "The domain still shows local pending anchor state, but the wallet could not find a matching clearable reserved anchor family.",
415
+ next: "Run `cogcoin repair`, then inspect the domain again before retrying `cogcoin anchor clear`.",
416
+ };
417
+ }
418
+ if (errorCode.startsWith("wallet_anchor_clear_not_clearable_")) {
419
+ return {
420
+ what: "Pending anchor cannot be cleared safely.",
421
+ why: "This command only clears a local pre-broadcast reservation. The anchor family is already beyond that safe stage or may have been observed by the wallet.",
422
+ next: "Rerun `cogcoin anchor <domain>` to reconcile the family, or run `cogcoin repair` if it remains unresolved.",
423
+ };
424
+ }
355
425
  if (errorCode === "mining_hooks_enable_trust_acknowledgement_required") {
356
426
  return {
357
427
  what: "Trust acknowledgement is still required.",
@@ -735,6 +805,10 @@ export function describeCanonicalCommand(parsed) {
735
805
  case "restore":
736
806
  case "wallet-restore":
737
807
  return "cogcoin restore";
808
+ case "wallet-delete":
809
+ return "cogcoin wallet delete";
810
+ case "wallet-show-mnemonic":
811
+ return "cogcoin wallet show-mnemonic";
738
812
  case "unlock":
739
813
  case "wallet-unlock":
740
814
  return "cogcoin unlock";
@@ -747,6 +821,9 @@ export function describeCanonicalCommand(parsed) {
747
821
  case "anchor":
748
822
  case "domain-anchor":
749
823
  return `cogcoin anchor ${args[0] ?? "<domain>"}`;
824
+ case "anchor-clear":
825
+ case "domain-anchor-clear":
826
+ return `cogcoin anchor clear ${args[0] ?? "<domain>"}`;
750
827
  case "register":
751
828
  case "domain-register":
752
829
  return `cogcoin register ${args[0] ?? "<domain>"}`;
@@ -916,6 +993,8 @@ export function resolveStableMutationJsonSchema(parsed) {
916
993
  case "restore":
917
994
  case "wallet-restore":
918
995
  return "cogcoin/restore/v1";
996
+ case "wallet-delete":
997
+ return "cogcoin/wallet-delete/v1";
919
998
  case "unlock":
920
999
  case "wallet-unlock":
921
1000
  return "cogcoin/unlock/v1";
@@ -932,6 +1011,9 @@ export function resolveStableMutationJsonSchema(parsed) {
932
1011
  case "anchor":
933
1012
  case "domain-anchor":
934
1013
  return "cogcoin/anchor/v1";
1014
+ case "anchor-clear":
1015
+ case "domain-anchor-clear":
1016
+ return "cogcoin/anchor-clear/v1";
935
1017
  case "register":
936
1018
  case "domain-register":
937
1019
  return "cogcoin/register/v1";
@@ -1010,7 +1092,9 @@ export function resolvePreviewJsonSchema(parsed) {
1010
1092
  case "reset":
1011
1093
  case "repair":
1012
1094
  case "anchor":
1095
+ case "anchor-clear":
1013
1096
  case "domain-anchor":
1097
+ case "domain-anchor-clear":
1014
1098
  case "register":
1015
1099
  case "domain-register":
1016
1100
  case "transfer":
@@ -1065,6 +1149,7 @@ function createSchemaProbe(command) {
1065
1149
  dbPath: null,
1066
1150
  dataDir: null,
1067
1151
  progressOutput: "auto",
1152
+ seedName: null,
1068
1153
  unlockFor: null,
1069
1154
  assumeYes: false,
1070
1155
  forceRace: false,
@@ -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 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 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 a fresh local wallet 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 unlock Clear an explicit wallet lock and unlock for a limited duration\n wallet address Alias for address\n wallet ids Alias for ids\n hooks enable mining Enable a validated custom mining hook\n hooks disable mining Return to built-in mining hooks\n hooks status Show mining hook validation and trust status\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 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 Tx1/Tx2 family\n register <domain> [--from <identity>]\n Register a root domain or subdomain\n transfer <domain> --to <btc-target>\n Transfer an unanchored domain to another BTC identity\n sell <domain> <price> List an unanchored domain for sale in COG\n unsell <domain> Clear an active domain listing\n buy <domain> [--from <identity>]\n Buy an unanchored listed domain in COG\n send <amount> --to <btc-target>\n Send COG from one local identity 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 a fresh local wallet from a 24-word mnemonic; run sync afterward\n wallet unlock Clear an explicit wallet lock and unlock for a limited duration\n wallet lock Lock the local wallet and disable on-demand unlock\n wallet export <path> Export a portable encrypted wallet archive\n wallet import <path> Import a portable encrypted wallet archive\n address Show the BTC funding identity for this wallet\n ids List locally controlled identities\n balance Show per-identity 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 anchored field, optionally with an initial value\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> Unlock duration like 15m, 2h, or 1d when unlocking explicitly\n --message <text> Founding message text for anchor\n --to <btc-target> Transfer or send target as an address or spk:<hex>\n --from <identity> Resolve sender identity as id:<n>, domain:<name>, 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 --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 --verify Run full custom-hook verification\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 --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 wallet address\n cogcoin domain list --mineable\n cogcoin register alpha-child\n cogcoin register weatherbot --from id:1\n cogcoin anchor alpha\n cogcoin buy alpha\n cogcoin buy alpha --from id:1\n cogcoin field create alpha bio --text \"hello\"\n cogcoin rep give alpha beta 10 --review \"great operator\"\n cogcoin hooks status\n cogcoin mine setup --output json\n cogcoin register alpha-child --output preview-json\n cogcoin mine status\n";
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 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 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 unlock Clear an explicit wallet lock and unlock for a limited duration\n wallet address Alias for address\n wallet ids Alias for ids\n hooks enable mining Enable a validated custom mining hook\n hooks disable mining Return to built-in mining hooks\n hooks status Show mining hook validation and trust status\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 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 Tx1/Tx2 family\n anchor clear <domain> Clear a local-only pending anchor reservation before broadcast\n register <domain> [--from <identity>]\n Register a root domain or subdomain\n transfer <domain> --to <btc-target>\n Transfer an unanchored domain to another BTC identity\n sell <domain> <price> List an unanchored domain for sale in COG\n unsell <domain> Clear an active domain listing\n buy <domain> [--from <identity>]\n Buy an unanchored listed domain in COG\n send <amount> --to <btc-target>\n Send COG from one local identity 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 wallet unlock Clear an explicit wallet lock and unlock for a limited duration\n wallet lock Lock the local wallet and disable on-demand unlock\n wallet export <path> Export a portable encrypted wallet archive\n wallet import <path> Import a portable encrypted wallet archive\n address Show the BTC funding identity for this wallet\n ids List locally controlled identities\n balance Show per-identity 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 anchored field, optionally with an initial value\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> Unlock duration like 15m, 2h, or 1d when unlocking explicitly\n --message <text> Founding message text for anchor\n --to <btc-target> Transfer or send target as an address or spk:<hex>\n --from <identity> Resolve sender identity as id:<n>, domain:<name>, 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 --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 --verify Run full custom-hook verification\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-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 register weatherbot --from id:1\n cogcoin anchor alpha\n cogcoin buy alpha\n cogcoin buy alpha --from id:1\n cogcoin field create alpha bio --text \"hello\"\n cogcoin rep give alpha beta 10 --review \"great operator\"\n cogcoin hooks status\n cogcoin mine setup --output json\n cogcoin register alpha-child --output preview-json\n cogcoin mine status\n";
3
3
  export declare function parseCliArgs(argv: string[]): ParsedCliArgs;
package/dist/cli/parse.js CHANGED
@@ -12,7 +12,7 @@ Commands:
12
12
  indexer status Show managed Cogcoin indexer status without starting it
13
13
  init Initialize a new local wallet root
14
14
  init --output json Emit the stable v1 machine-readable init result envelope
15
- restore Restore a fresh local wallet from a 24-word mnemonic; run sync afterward
15
+ restore Restore an imported named seed from a 24-word mnemonic; run sync afterward
16
16
  reset Factory-reset local Cogcoin state with interactive retention prompts
17
17
  repair Recover bounded wallet/indexer/runtime state
18
18
  unlock Clear an explicit wallet lock and unlock for a limited duration
@@ -30,6 +30,7 @@ Commands:
30
30
  mine status Show mining control-plane health and readiness
31
31
  mine log Show recent mining control-plane events
32
32
  anchor <domain> Anchor an owned unanchored domain with the Tx1/Tx2 family
33
+ anchor clear <domain> Clear a local-only pending anchor reservation before broadcast
33
34
  register <domain> [--from <identity>]
34
35
  Register a root domain or subdomain
35
36
  transfer <domain> --to <btc-target>
@@ -47,7 +48,9 @@ Commands:
47
48
  Lock COG to an anchored recipient domain
48
49
  wallet status Show detailed wallet-local status and service health
49
50
  wallet init Initialize a new local wallet root
50
- wallet restore Restore a fresh local wallet from a 24-word mnemonic; run sync afterward
51
+ wallet restore Restore an imported named seed from a 24-word mnemonic; run sync afterward
52
+ wallet delete Delete one imported named seed without affecting main
53
+ wallet show-mnemonic Reveal the initialized wallet recovery phrase after typed confirmation
51
54
  wallet unlock Clear an explicit wallet lock and unlock for a limited duration
52
55
  wallet lock Lock the local wallet and disable on-demand unlock
53
56
  wallet export <path> Export a portable encrypted wallet archive
@@ -107,6 +110,7 @@ Options:
107
110
  --follow Follow mining log output
108
111
  --output <mode> Output mode: text, json, or preview-json
109
112
  --progress <mode> Progress output mode: auto, tty, or none
113
+ --seed <name> Select an imported wallet seed for wallet-aware commands
110
114
  --force-race Allow a visible root registration race
111
115
  --yes Approve eligible plain yes/no mutation confirmations non-interactively
112
116
  --help Show help
@@ -122,6 +126,7 @@ Examples:
122
126
  cogcoin bitcoin status
123
127
  cogcoin indexer status
124
128
  cogcoin init --output json
129
+ cogcoin restore --seed trading
125
130
  cogcoin wallet address
126
131
  cogcoin domain list --mineable
127
132
  cogcoin register alpha-child
@@ -138,7 +143,12 @@ Examples:
138
143
  `;
139
144
  function supportsYesFlag(command) {
140
145
  switch (command) {
146
+ case "sync":
147
+ case "follow":
141
148
  case "repair":
149
+ case "wallet-delete":
150
+ case "anchor-clear":
151
+ case "domain-anchor-clear":
142
152
  case "register":
143
153
  case "domain-register":
144
154
  case "transfer":
@@ -173,6 +183,81 @@ function supportsYesFlag(command) {
173
183
  return false;
174
184
  }
175
185
  }
186
+ function supportsSeedFlag(command) {
187
+ switch (command) {
188
+ case "status":
189
+ case "unlock":
190
+ case "anchor":
191
+ case "anchor-clear":
192
+ case "domain-anchor":
193
+ case "domain-anchor-clear":
194
+ case "register":
195
+ case "domain-register":
196
+ case "transfer":
197
+ case "domain-transfer":
198
+ case "sell":
199
+ case "domain-sell":
200
+ case "unsell":
201
+ case "domain-unsell":
202
+ case "buy":
203
+ case "domain-buy":
204
+ case "domain-endpoint-set":
205
+ case "domain-endpoint-clear":
206
+ case "domain-delegate-set":
207
+ case "domain-delegate-clear":
208
+ case "domain-miner-set":
209
+ case "domain-miner-clear":
210
+ case "domain-canonical":
211
+ case "field-list":
212
+ case "field-show":
213
+ case "field-create":
214
+ case "field-set":
215
+ case "field-clear":
216
+ case "send":
217
+ case "claim":
218
+ case "reclaim":
219
+ case "cog-send":
220
+ case "cog-claim":
221
+ case "cog-reclaim":
222
+ case "cog-lock":
223
+ case "rep-give":
224
+ case "rep-revoke":
225
+ case "cog-balance":
226
+ case "cog-locks":
227
+ case "mine":
228
+ case "mine-start":
229
+ case "mine-stop":
230
+ case "mine-setup":
231
+ case "mine-status":
232
+ case "mine-log":
233
+ case "wallet-export":
234
+ case "wallet-delete":
235
+ case "wallet-restore":
236
+ case "restore":
237
+ case "wallet-show-mnemonic":
238
+ case "wallet-lock":
239
+ case "wallet-unlock":
240
+ case "wallet-status":
241
+ case "wallet-address":
242
+ case "wallet-ids":
243
+ case "address":
244
+ case "ids":
245
+ case "balance":
246
+ case "locks":
247
+ case "domain-list":
248
+ case "domains":
249
+ case "domain-show":
250
+ case "show":
251
+ case "fields":
252
+ case "field":
253
+ return true;
254
+ default:
255
+ return false;
256
+ }
257
+ }
258
+ function requiresSeedFlag(command) {
259
+ return command === "restore" || command === "wallet-restore" || command === "wallet-delete";
260
+ }
176
261
  export function parseCliArgs(argv) {
177
262
  let command = null;
178
263
  const args = [];
@@ -182,6 +267,7 @@ export function parseCliArgs(argv) {
182
267
  let dbPath = null;
183
268
  let dataDir = null;
184
269
  let progressOutput = "auto";
270
+ let seedName = null;
185
271
  let unlockFor = null;
186
272
  let assumeYes = false;
187
273
  let forceRace = false;
@@ -235,6 +321,17 @@ export function parseCliArgs(argv) {
235
321
  }
236
322
  continue;
237
323
  }
324
+ if (token === "--seed") {
325
+ index += 1;
326
+ seedName = argv[index] ?? null;
327
+ if (seedName === null) {
328
+ throw new Error("cli_missing_seed_name");
329
+ }
330
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(seedName)) {
331
+ throw new Error("cli_invalid_seed_name");
332
+ }
333
+ continue;
334
+ }
238
335
  if (token === "--data-dir") {
239
336
  index += 1;
240
337
  dataDir = argv[index] ?? null;
@@ -451,6 +548,16 @@ export function parseCliArgs(argv) {
451
548
  index += 1;
452
549
  continue;
453
550
  }
551
+ if (subcommand === "delete") {
552
+ command = "wallet-delete";
553
+ index += 1;
554
+ continue;
555
+ }
556
+ if (subcommand === "show-mnemonic") {
557
+ command = "wallet-show-mnemonic";
558
+ index += 1;
559
+ continue;
560
+ }
454
561
  if (subcommand === "unlock") {
455
562
  command = "wallet-unlock";
456
563
  index += 1;
@@ -580,6 +687,12 @@ export function parseCliArgs(argv) {
580
687
  continue;
581
688
  }
582
689
  if (subcommand === "anchor") {
690
+ const action = argv[index + 2] ?? null;
691
+ if (action === "clear") {
692
+ command = "domain-anchor-clear";
693
+ index += 2;
694
+ continue;
695
+ }
583
696
  command = "domain-anchor";
584
697
  index += 1;
585
698
  continue;
@@ -755,6 +868,11 @@ export function parseCliArgs(argv) {
755
868
  || token === "domains"
756
869
  || token === "show"
757
870
  || token === "fields") {
871
+ if (token === "anchor" && argv[index + 1] === "clear") {
872
+ command = "anchor-clear";
873
+ index += 1;
874
+ continue;
875
+ }
758
876
  command = token;
759
877
  continue;
760
878
  }
@@ -774,6 +892,7 @@ export function parseCliArgs(argv) {
774
892
  || command === "reset"
775
893
  || command === "unlock"
776
894
  || command === "wallet-init"
895
+ || command === "wallet-delete"
777
896
  || command === "wallet-restore"
778
897
  || command === "wallet-lock"
779
898
  || command === "wallet-unlock"
@@ -806,7 +925,11 @@ export function parseCliArgs(argv) {
806
925
  if ((command === "register" || command === "domain-register") && args.length !== 1) {
807
926
  throw new Error("cli_missing_domain_argument");
808
927
  }
809
- if ((command === "anchor" || command === "domain-anchor") && args.length !== 1) {
928
+ if ((command === "anchor"
929
+ || command === "domain-anchor"
930
+ || command === "anchor-clear"
931
+ || command === "domain-anchor-clear")
932
+ && args.length !== 1) {
810
933
  throw new Error("cli_missing_domain_argument");
811
934
  }
812
935
  if ((command === "domain-endpoint-set"
@@ -862,6 +985,12 @@ export function parseCliArgs(argv) {
862
985
  if (assumeYes && !supportsYesFlag(command)) {
863
986
  throw new Error("cli_yes_not_supported_for_command");
864
987
  }
988
+ if (seedName !== null && !supportsSeedFlag(command)) {
989
+ throw new Error("cli_seed_not_supported_for_command");
990
+ }
991
+ if (requiresSeedFlag(command) && seedName === null) {
992
+ throw new Error("cli_missing_seed_name");
993
+ }
865
994
  if (forceRace && command !== "register" && command !== "domain-register") {
866
995
  throw new Error("cli_force_race_not_supported_for_command");
867
996
  }
@@ -1006,6 +1135,7 @@ export function parseCliArgs(argv) {
1006
1135
  dbPath,
1007
1136
  dataDir,
1008
1137
  progressOutput,
1138
+ seedName,
1009
1139
  unlockFor,
1010
1140
  assumeYes,
1011
1141
  forceRace,
@@ -1,4 +1,4 @@
1
- import type { AnchorDomainResult, CogMutationResult, DomainAdminMutationResult, DomainMarketMutationResult, FieldMutationResult, RegisterDomainResult, ReputationMutationResult } from "../wallet/tx/index.js";
1
+ import type { AnchorDomainResult, ClearPendingAnchorResult, CogMutationResult, DomainAdminMutationResult, DomainMarketMutationResult, FieldMutationResult, RegisterDomainResult, ReputationMutationResult } from "../wallet/tx/index.js";
2
2
  import type { WalletRepairResult, WalletResetPreview } from "../wallet/lifecycle.js";
3
3
  import type { MiningControlPlaneView, MiningRuntimeStatusV1 } from "../wallet/mining/index.js";
4
4
  export declare function buildSingleTxMutationPreviewData(options: {
@@ -223,6 +223,15 @@ export declare function buildAnchorPreviewData(result: AnchorDomainResult, optio
223
223
  };
224
224
  intent: Record<string, unknown>;
225
225
  };
226
+ export declare function buildAnchorClearPreviewData(result: ClearPendingAnchorResult): {
227
+ resultType: "state-change";
228
+ stateChange: {
229
+ kind: string;
230
+ before: Record<string, unknown> | null;
231
+ after: Record<string, unknown> | null;
232
+ };
233
+ state: Record<string, unknown>;
234
+ };
226
235
  export declare function buildDomainAdminPreviewData(result: DomainAdminMutationResult, options: {
227
236
  commandKind: "domain-endpoint-set" | "domain-endpoint-clear" | "domain-delegate-set" | "domain-delegate-clear" | "domain-miner-set" | "domain-miner-clear" | "domain-canonical";
228
237
  }): {
@@ -140,6 +140,36 @@ export function buildAnchorPreviewData(result, options) {
140
140
  },
141
141
  });
142
142
  }
143
+ export function buildAnchorClearPreviewData(result) {
144
+ const before = result.cleared
145
+ ? {
146
+ localAnchorIntent: "reserved",
147
+ dedicatedIndex: result.releasedDedicatedIndex,
148
+ familyStatus: result.previousFamilyStatus,
149
+ familyStep: result.previousFamilyStep,
150
+ }
151
+ : null;
152
+ const after = result.cleared
153
+ ? {
154
+ localAnchorIntent: "none",
155
+ dedicatedIndex: null,
156
+ familyStatus: "canceled",
157
+ familyStep: result.previousFamilyStep,
158
+ }
159
+ : null;
160
+ return buildStateChangePreviewData({
161
+ kind: "anchor-clear",
162
+ state: {
163
+ domainName: result.domainName,
164
+ cleared: result.cleared,
165
+ previousFamilyStatus: result.previousFamilyStatus,
166
+ previousFamilyStep: result.previousFamilyStep,
167
+ releasedDedicatedIndex: result.releasedDedicatedIndex,
168
+ },
169
+ before,
170
+ after,
171
+ });
172
+ }
143
173
  export function buildDomainAdminPreviewData(result, options) {
144
174
  const data = buildSingleTxMutationPreviewData({
145
175
  kind: options.commandKind,
@@ -234,6 +264,7 @@ export function buildResetPreviewData(result) {
234
264
  trackedProcessKinds: result.trackedProcessKinds,
235
265
  willDeleteOsSecrets: result.willDeleteOsSecrets,
236
266
  bootstrapSnapshot: result.bootstrapSnapshot,
267
+ bitcoinDataDir: result.bitcoinDataDir,
237
268
  walletPrompt: result.walletPrompt,
238
269
  },
239
270
  operation: {
@@ -241,6 +272,7 @@ export function buildResetPreviewData(result) {
241
272
  confirmationPhrase: result.confirmationPhrase,
242
273
  walletPrompt: result.walletPrompt,
243
274
  bootstrapSnapshot: result.bootstrapSnapshot,
275
+ bitcoinDataDir: result.bitcoinDataDir,
244
276
  trackedProcessKinds: result.trackedProcessKinds,
245
277
  willDeleteOsSecrets: result.willDeleteOsSecrets,
246
278
  removedPaths: result.removedPaths,
@@ -53,7 +53,7 @@ export function createTerminalPrompter(input, output) {
53
53
  if (!input.isTTY || !output.isTTY) {
54
54
  return;
55
55
  }
56
- if (scope === "mnemonic-reveal") {
56
+ if (scope === "mnemonic-reveal" || scope === "restore-mnemonic-entry") {
57
57
  output.write(CLEAR_SENSITIVE_DISPLAY_SEQUENCE);
58
58
  }
59
59
  },
@@ -76,13 +76,17 @@ export async function runCli(argv, contextOverrides = {}) {
76
76
  || parsed.command === "wallet-export"
77
77
  || parsed.command === "wallet-import"
78
78
  || parsed.command === "wallet-init"
79
+ || parsed.command === "wallet-delete"
79
80
  || parsed.command === "wallet-restore"
81
+ || parsed.command === "wallet-show-mnemonic"
80
82
  || parsed.command === "wallet-unlock"
81
83
  || parsed.command === "wallet-lock") {
82
84
  return runWalletAdminCommand(parsed, context);
83
85
  }
84
86
  if (parsed.command === "anchor"
87
+ || parsed.command === "anchor-clear"
85
88
  || parsed.command === "domain-anchor"
89
+ || parsed.command === "domain-anchor-clear"
86
90
  || parsed.command === "register"
87
91
  || parsed.command === "domain-register"
88
92
  || parsed.command === "transfer"