@cogcoin/client 0.5.0

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 (289) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/dist/app-paths.d.ts +38 -0
  4. package/dist/app-paths.js +121 -0
  5. package/dist/art/banner.txt +13 -0
  6. package/dist/art/scroll.txt +13 -0
  7. package/dist/art/train-car.txt +6 -0
  8. package/dist/art/train-smoke.txt +6 -0
  9. package/dist/art/train.txt +6 -0
  10. package/dist/bitcoind/bootstrap/chainstate.d.ts +4 -0
  11. package/dist/bitcoind/bootstrap/chainstate.js +13 -0
  12. package/dist/bitcoind/bootstrap/constants.d.ts +7 -0
  13. package/dist/bitcoind/bootstrap/constants.js +12 -0
  14. package/dist/bitcoind/bootstrap/controller.d.ts +29 -0
  15. package/dist/bitcoind/bootstrap/controller.js +101 -0
  16. package/dist/bitcoind/bootstrap/download.d.ts +2 -0
  17. package/dist/bitcoind/bootstrap/download.js +196 -0
  18. package/dist/bitcoind/bootstrap/headers.d.ts +13 -0
  19. package/dist/bitcoind/bootstrap/headers.js +61 -0
  20. package/dist/bitcoind/bootstrap/paths.d.ts +4 -0
  21. package/dist/bitcoind/bootstrap/paths.js +15 -0
  22. package/dist/bitcoind/bootstrap/snapshot-file.d.ts +7 -0
  23. package/dist/bitcoind/bootstrap/snapshot-file.js +42 -0
  24. package/dist/bitcoind/bootstrap/state.d.ts +40 -0
  25. package/dist/bitcoind/bootstrap/state.js +70 -0
  26. package/dist/bitcoind/bootstrap/types.d.ts +28 -0
  27. package/dist/bitcoind/bootstrap/types.js +1 -0
  28. package/dist/bitcoind/bootstrap.d.ts +8 -0
  29. package/dist/bitcoind/bootstrap.js +7 -0
  30. package/dist/bitcoind/client/factory.d.ts +3 -0
  31. package/dist/bitcoind/client/factory.js +57 -0
  32. package/dist/bitcoind/client/follow-block-times.d.ts +8 -0
  33. package/dist/bitcoind/client/follow-block-times.js +25 -0
  34. package/dist/bitcoind/client/follow-loop.d.ts +10 -0
  35. package/dist/bitcoind/client/follow-loop.js +57 -0
  36. package/dist/bitcoind/client/internal-types.d.ts +63 -0
  37. package/dist/bitcoind/client/internal-types.js +18 -0
  38. package/dist/bitcoind/client/managed-client.d.ts +20 -0
  39. package/dist/bitcoind/client/managed-client.js +197 -0
  40. package/dist/bitcoind/client/rate-tracker.d.ts +2 -0
  41. package/dist/bitcoind/client/rate-tracker.js +24 -0
  42. package/dist/bitcoind/client/sync-engine.d.ts +3 -0
  43. package/dist/bitcoind/client/sync-engine.js +143 -0
  44. package/dist/bitcoind/client.d.ts +1 -0
  45. package/dist/bitcoind/client.js +1 -0
  46. package/dist/bitcoind/errors.d.ts +1 -0
  47. package/dist/bitcoind/errors.js +49 -0
  48. package/dist/bitcoind/index.d.ts +2 -0
  49. package/dist/bitcoind/index.js +1 -0
  50. package/dist/bitcoind/indexer-daemon-main.d.ts +1 -0
  51. package/dist/bitcoind/indexer-daemon-main.js +472 -0
  52. package/dist/bitcoind/indexer-daemon.d.ts +107 -0
  53. package/dist/bitcoind/indexer-daemon.js +391 -0
  54. package/dist/bitcoind/node.d.ts +8 -0
  55. package/dist/bitcoind/node.js +219 -0
  56. package/dist/bitcoind/normalize.d.ts +3 -0
  57. package/dist/bitcoind/normalize.js +47 -0
  58. package/dist/bitcoind/progress/assets.d.ts +10 -0
  59. package/dist/bitcoind/progress/assets.js +90 -0
  60. package/dist/bitcoind/progress/constants.d.ts +48 -0
  61. package/dist/bitcoind/progress/constants.js +53 -0
  62. package/dist/bitcoind/progress/controller.d.ts +28 -0
  63. package/dist/bitcoind/progress/controller.js +188 -0
  64. package/dist/bitcoind/progress/follow-scene.d.ts +40 -0
  65. package/dist/bitcoind/progress/follow-scene.js +367 -0
  66. package/dist/bitcoind/progress/formatting.d.ts +23 -0
  67. package/dist/bitcoind/progress/formatting.js +227 -0
  68. package/dist/bitcoind/progress/quote-scene.d.ts +4 -0
  69. package/dist/bitcoind/progress/quote-scene.js +137 -0
  70. package/dist/bitcoind/progress/train-scene.d.ts +9 -0
  71. package/dist/bitcoind/progress/train-scene.js +92 -0
  72. package/dist/bitcoind/progress/tty-renderer.d.ts +18 -0
  73. package/dist/bitcoind/progress/tty-renderer.js +150 -0
  74. package/dist/bitcoind/progress.d.ts +7 -0
  75. package/dist/bitcoind/progress.js +7 -0
  76. package/dist/bitcoind/quotes.d.ts +24 -0
  77. package/dist/bitcoind/quotes.js +195 -0
  78. package/dist/bitcoind/rpc.d.ts +71 -0
  79. package/dist/bitcoind/rpc.js +322 -0
  80. package/dist/bitcoind/service-paths.d.ts +19 -0
  81. package/dist/bitcoind/service-paths.js +49 -0
  82. package/dist/bitcoind/service.d.ts +40 -0
  83. package/dist/bitcoind/service.js +735 -0
  84. package/dist/bitcoind/testing.d.ts +9 -0
  85. package/dist/bitcoind/testing.js +9 -0
  86. package/dist/bitcoind/types.d.ts +396 -0
  87. package/dist/bitcoind/types.js +3 -0
  88. package/dist/bytes.d.ts +9 -0
  89. package/dist/bytes.js +36 -0
  90. package/dist/cli/commands/follow.d.ts +2 -0
  91. package/dist/cli/commands/follow.js +43 -0
  92. package/dist/cli/commands/mining-admin.d.ts +2 -0
  93. package/dist/cli/commands/mining-admin.js +92 -0
  94. package/dist/cli/commands/mining-read.d.ts +2 -0
  95. package/dist/cli/commands/mining-read.js +173 -0
  96. package/dist/cli/commands/mining-runtime.d.ts +2 -0
  97. package/dist/cli/commands/mining-runtime.js +108 -0
  98. package/dist/cli/commands/status.d.ts +2 -0
  99. package/dist/cli/commands/status.js +31 -0
  100. package/dist/cli/commands/sync.d.ts +2 -0
  101. package/dist/cli/commands/sync.js +52 -0
  102. package/dist/cli/commands/wallet-admin.d.ts +2 -0
  103. package/dist/cli/commands/wallet-admin.js +175 -0
  104. package/dist/cli/commands/wallet-mutation.d.ts +2 -0
  105. package/dist/cli/commands/wallet-mutation.js +681 -0
  106. package/dist/cli/commands/wallet-read.d.ts +2 -0
  107. package/dist/cli/commands/wallet-read.js +265 -0
  108. package/dist/cli/context.d.ts +3 -0
  109. package/dist/cli/context.js +75 -0
  110. package/dist/cli/io.d.ts +3 -0
  111. package/dist/cli/io.js +12 -0
  112. package/dist/cli/mining-format.d.ts +5 -0
  113. package/dist/cli/mining-format.js +156 -0
  114. package/dist/cli/mining-json.d.ts +49 -0
  115. package/dist/cli/mining-json.js +89 -0
  116. package/dist/cli/mutation-command-groups.d.ts +15 -0
  117. package/dist/cli/mutation-command-groups.js +71 -0
  118. package/dist/cli/mutation-json.d.ts +430 -0
  119. package/dist/cli/mutation-json.js +311 -0
  120. package/dist/cli/mutation-resolved-json.d.ts +124 -0
  121. package/dist/cli/mutation-resolved-json.js +129 -0
  122. package/dist/cli/mutation-success.d.ts +20 -0
  123. package/dist/cli/mutation-success.js +47 -0
  124. package/dist/cli/mutation-text-format.d.ts +22 -0
  125. package/dist/cli/mutation-text-format.js +171 -0
  126. package/dist/cli/mutation-text-write.d.ts +13 -0
  127. package/dist/cli/mutation-text-write.js +16 -0
  128. package/dist/cli/output.d.ts +185 -0
  129. package/dist/cli/output.js +1085 -0
  130. package/dist/cli/parse.d.ts +3 -0
  131. package/dist/cli/parse.js +971 -0
  132. package/dist/cli/preview-json.d.ts +416 -0
  133. package/dist/cli/preview-json.js +293 -0
  134. package/dist/cli/prompt.d.ts +3 -0
  135. package/dist/cli/prompt.js +33 -0
  136. package/dist/cli/read-json.d.ts +187 -0
  137. package/dist/cli/read-json.js +675 -0
  138. package/dist/cli/runner.d.ts +2 -0
  139. package/dist/cli/runner.js +129 -0
  140. package/dist/cli/signals.d.ts +3 -0
  141. package/dist/cli/signals.js +63 -0
  142. package/dist/cli/status-format.d.ts +2 -0
  143. package/dist/cli/status-format.js +48 -0
  144. package/dist/cli/types.d.ts +148 -0
  145. package/dist/cli/types.js +2 -0
  146. package/dist/cli/wallet-format.d.ts +29 -0
  147. package/dist/cli/wallet-format.js +637 -0
  148. package/dist/cli/workflow-hints.d.ts +13 -0
  149. package/dist/cli/workflow-hints.js +94 -0
  150. package/dist/cli-runner.d.ts +3 -0
  151. package/dist/cli-runner.js +3 -0
  152. package/dist/cli.d.ts +2 -0
  153. package/dist/cli.js +6 -0
  154. package/dist/client/default-client.d.ts +11 -0
  155. package/dist/client/default-client.js +118 -0
  156. package/dist/client/factory.d.ts +2 -0
  157. package/dist/client/factory.js +15 -0
  158. package/dist/client/initialization.d.ts +6 -0
  159. package/dist/client/initialization.js +30 -0
  160. package/dist/client/persistence.d.ts +5 -0
  161. package/dist/client/persistence.js +28 -0
  162. package/dist/client/store-adapter.d.ts +3 -0
  163. package/dist/client/store-adapter.js +20 -0
  164. package/dist/client.d.ts +2 -0
  165. package/dist/client.js +2 -0
  166. package/dist/index.d.ts +2 -0
  167. package/dist/index.js +1 -0
  168. package/dist/passive-status.d.ts +36 -0
  169. package/dist/passive-status.js +100 -0
  170. package/dist/sqlite/better-sqlite3.d.ts +26 -0
  171. package/dist/sqlite/better-sqlite3.js +4 -0
  172. package/dist/sqlite/checkpoints.d.ts +11 -0
  173. package/dist/sqlite/checkpoints.js +27 -0
  174. package/dist/sqlite/driver.d.ts +17 -0
  175. package/dist/sqlite/driver.js +98 -0
  176. package/dist/sqlite/index.d.ts +4 -0
  177. package/dist/sqlite/index.js +9 -0
  178. package/dist/sqlite/migrate.d.ts +2 -0
  179. package/dist/sqlite/migrate.js +37 -0
  180. package/dist/sqlite/store.d.ts +3 -0
  181. package/dist/sqlite/store.js +122 -0
  182. package/dist/sqlite/tip-meta.d.ts +26 -0
  183. package/dist/sqlite/tip-meta.js +97 -0
  184. package/dist/sqlite/types.d.ts +10 -0
  185. package/dist/sqlite/types.js +1 -0
  186. package/dist/types.d.ts +55 -0
  187. package/dist/types.js +1 -0
  188. package/dist/wallet/archive.d.ts +4 -0
  189. package/dist/wallet/archive.js +39 -0
  190. package/dist/wallet/cogop/constants.d.ts +32 -0
  191. package/dist/wallet/cogop/constants.js +32 -0
  192. package/dist/wallet/cogop/index.d.ts +32 -0
  193. package/dist/wallet/cogop/index.js +213 -0
  194. package/dist/wallet/cogop/numeric.d.ts +3 -0
  195. package/dist/wallet/cogop/numeric.js +24 -0
  196. package/dist/wallet/cogop/scriptpubkey.d.ts +2 -0
  197. package/dist/wallet/cogop/scriptpubkey.js +13 -0
  198. package/dist/wallet/cogop/validate-name.d.ts +2 -0
  199. package/dist/wallet/cogop/validate-name.js +18 -0
  200. package/dist/wallet/fs/atomic.d.ts +6 -0
  201. package/dist/wallet/fs/atomic.js +46 -0
  202. package/dist/wallet/fs/lock.d.ts +19 -0
  203. package/dist/wallet/fs/lock.js +61 -0
  204. package/dist/wallet/fs/status-file.d.ts +1 -0
  205. package/dist/wallet/fs/status-file.js +4 -0
  206. package/dist/wallet/lifecycle.d.ts +193 -0
  207. package/dist/wallet/lifecycle.js +1475 -0
  208. package/dist/wallet/material.d.ts +45 -0
  209. package/dist/wallet/material.js +118 -0
  210. package/dist/wallet/mining/config.d.ts +18 -0
  211. package/dist/wallet/mining/config.js +44 -0
  212. package/dist/wallet/mining/constants.d.ts +24 -0
  213. package/dist/wallet/mining/constants.js +24 -0
  214. package/dist/wallet/mining/control.d.ts +53 -0
  215. package/dist/wallet/mining/control.js +758 -0
  216. package/dist/wallet/mining/coordination.d.ts +40 -0
  217. package/dist/wallet/mining/coordination.js +121 -0
  218. package/dist/wallet/mining/hook-protocol.d.ts +47 -0
  219. package/dist/wallet/mining/hook-protocol.js +161 -0
  220. package/dist/wallet/mining/hook-runner.d.ts +1 -0
  221. package/dist/wallet/mining/hook-runner.js +52 -0
  222. package/dist/wallet/mining/hooks.d.ts +38 -0
  223. package/dist/wallet/mining/hooks.js +520 -0
  224. package/dist/wallet/mining/index.d.ts +8 -0
  225. package/dist/wallet/mining/index.js +6 -0
  226. package/dist/wallet/mining/runner.d.ts +155 -0
  227. package/dist/wallet/mining/runner.js +2574 -0
  228. package/dist/wallet/mining/runtime-artifacts.d.ts +17 -0
  229. package/dist/wallet/mining/runtime-artifacts.js +166 -0
  230. package/dist/wallet/mining/sentences.d.ts +23 -0
  231. package/dist/wallet/mining/sentences.js +281 -0
  232. package/dist/wallet/mining/state.d.ts +9 -0
  233. package/dist/wallet/mining/state.js +75 -0
  234. package/dist/wallet/mining/types.d.ts +141 -0
  235. package/dist/wallet/mining/types.js +1 -0
  236. package/dist/wallet/mining/visualizer.d.ts +19 -0
  237. package/dist/wallet/mining/visualizer.js +134 -0
  238. package/dist/wallet/mining/worker-main.d.ts +1 -0
  239. package/dist/wallet/mining/worker-main.js +17 -0
  240. package/dist/wallet/read/context.d.ts +20 -0
  241. package/dist/wallet/read/context.js +532 -0
  242. package/dist/wallet/read/filter.d.ts +9 -0
  243. package/dist/wallet/read/filter.js +42 -0
  244. package/dist/wallet/read/index.d.ts +4 -0
  245. package/dist/wallet/read/index.js +3 -0
  246. package/dist/wallet/read/project.d.ts +11 -0
  247. package/dist/wallet/read/project.js +300 -0
  248. package/dist/wallet/read/types.d.ts +144 -0
  249. package/dist/wallet/read/types.js +1 -0
  250. package/dist/wallet/runtime.d.ts +26 -0
  251. package/dist/wallet/runtime.js +28 -0
  252. package/dist/wallet/state/crypto.d.ts +31 -0
  253. package/dist/wallet/state/crypto.js +127 -0
  254. package/dist/wallet/state/provider.d.ts +37 -0
  255. package/dist/wallet/state/provider.js +312 -0
  256. package/dist/wallet/state/session.d.ts +12 -0
  257. package/dist/wallet/state/session.js +23 -0
  258. package/dist/wallet/state/storage.d.ts +19 -0
  259. package/dist/wallet/state/storage.js +55 -0
  260. package/dist/wallet/tx/anchor.d.ts +40 -0
  261. package/dist/wallet/tx/anchor.js +1210 -0
  262. package/dist/wallet/tx/cog.d.ts +92 -0
  263. package/dist/wallet/tx/cog.js +1055 -0
  264. package/dist/wallet/tx/common.d.ts +89 -0
  265. package/dist/wallet/tx/common.js +156 -0
  266. package/dist/wallet/tx/confirm.d.ts +15 -0
  267. package/dist/wallet/tx/confirm.js +24 -0
  268. package/dist/wallet/tx/domain-admin.d.ts +105 -0
  269. package/dist/wallet/tx/domain-admin.js +869 -0
  270. package/dist/wallet/tx/domain-market.d.ts +112 -0
  271. package/dist/wallet/tx/domain-market.js +1365 -0
  272. package/dist/wallet/tx/field.d.ts +101 -0
  273. package/dist/wallet/tx/field.js +1853 -0
  274. package/dist/wallet/tx/identity-selector.d.ts +12 -0
  275. package/dist/wallet/tx/identity-selector.js +52 -0
  276. package/dist/wallet/tx/index.d.ts +7 -0
  277. package/dist/wallet/tx/index.js +7 -0
  278. package/dist/wallet/tx/journal.d.ts +5 -0
  279. package/dist/wallet/tx/journal.js +31 -0
  280. package/dist/wallet/tx/register.d.ts +68 -0
  281. package/dist/wallet/tx/register.js +952 -0
  282. package/dist/wallet/tx/reputation.d.ts +72 -0
  283. package/dist/wallet/tx/reputation.js +693 -0
  284. package/dist/wallet/tx/targets.d.ts +7 -0
  285. package/dist/wallet/tx/targets.js +122 -0
  286. package/dist/wallet/types.d.ts +249 -0
  287. package/dist/wallet/types.js +1 -0
  288. package/dist/writing_quotes.json +1654 -0
  289. package/package.json +78 -0
@@ -0,0 +1,971 @@
1
+ import { isJsonOutputSupportedCommand, isPreviewJsonOutputSupportedCommand, } from "./output.js";
2
+ export const HELP_TEXT = `Usage: cogcoin <command> [options]
3
+
4
+ Commands:
5
+ status Show wallet-aware local service and chain status
6
+ status --output json Emit the stable v1 machine-readable status envelope
7
+ init Initialize a new local wallet root
8
+ init --output json Emit the stable v1 machine-readable init result envelope
9
+ repair Recover bounded wallet/indexer/runtime state
10
+ unlock Unlock the local wallet for a limited duration
11
+ wallet address Alias for address
12
+ wallet ids Alias for ids
13
+ hooks enable mining Enable a validated custom mining hook
14
+ hooks disable mining Return to built-in mining hooks
15
+ hooks status Show mining hook validation and trust status
16
+ mine Run the miner in the foreground
17
+ mine start Start the miner as a background worker
18
+ mine stop Stop the active background miner
19
+ mine setup Configure the built-in mining provider
20
+ mine setup --output json
21
+ Emit the stable v1 machine-readable mine setup result envelope
22
+ mine status Show mining control-plane health and readiness
23
+ mine log Show recent mining control-plane events
24
+ anchor <domain> Anchor an owned unanchored domain with the Tx1/Tx2 family
25
+ register <domain> [--from <identity>]
26
+ Register a root domain or subdomain
27
+ transfer <domain> --to <btc-target>
28
+ Transfer an unanchored domain to another BTC identity
29
+ sell <domain> <price> List an unanchored domain for sale in COG
30
+ unsell <domain> Clear an active domain listing
31
+ buy <domain> [--from <identity>]
32
+ Buy an unanchored listed domain in COG
33
+ send <amount> --to <btc-target>
34
+ Send COG from one local identity to another BTC target
35
+ claim <lock-id> --preimage <32-byte-hex>
36
+ Claim an active COG lock before timeout
37
+ reclaim <lock-id> Reclaim an expired COG lock as the original locker
38
+ cog lock <amount> --to-domain <domain> (--for <blocks-or-duration> | --until-height <height>) --condition <sha256hex>
39
+ Lock COG to an anchored recipient domain
40
+ wallet status Show detailed wallet-local status and service health
41
+ wallet init Initialize a new local wallet root
42
+ wallet unlock Unlock the local wallet for a limited duration
43
+ wallet lock Lock the local wallet immediately
44
+ wallet export <path> Export a portable encrypted wallet archive
45
+ wallet import <path> Import a portable encrypted wallet archive
46
+ address Show the BTC funding identity for this wallet
47
+ ids List locally controlled identities
48
+ balance Show per-identity COG balances
49
+ locks Show locally related active COG locks
50
+ domain list Alias for domains
51
+ domain show <domain> Alias for show <domain>
52
+ domains [--anchored] [--listed] [--mineable]
53
+ Show locally related domains
54
+ show <domain> Show one domain and its local-wallet relationship
55
+ fields <domain> List current fields on a domain
56
+ field <domain> <field> Show one current field value
57
+ field create <domain> <field>
58
+ Create a new anchored field, optionally with an initial value
59
+ field set <domain> <field>
60
+ Update an existing anchored field value
61
+ field clear <domain> <field>
62
+ Clear an existing anchored field value
63
+ rep give <source-domain> <target-domain> <amount>
64
+ Burn COG as anchored-domain reputation support
65
+ rep revoke <source-domain> <target-domain> <amount>
66
+ Revoke visible support without refunding burned COG
67
+
68
+ Options:
69
+ --db <path> Override the SQLite database path
70
+ --data-dir <path> Override the managed bitcoin datadir
71
+ --for <duration> Unlock duration like 15m, 2h, or 1d
72
+ --message <text> Founding message text for anchor
73
+ --to <btc-target> Transfer or send target as an address or spk:<hex>
74
+ --from <identity> Resolve sender identity as id:<n>, domain:<name>, address, or spk:<hex>
75
+ --to-domain <domain>
76
+ Recipient domain for cog lock
77
+ --condition <sha256hex>
78
+ 32-byte lock condition hash
79
+ --until-height <height>
80
+ Absolute timeout height for cog lock
81
+ --preimage <32-byte-hex>
82
+ Claim preimage for an active lock
83
+ --review <text> Optional public review text for reputation operations
84
+ --text <utf8> UTF-8 payload text for endpoint or field writes
85
+ --json <json> UTF-8 payload JSON text for endpoint or field writes
86
+ --bytes <spec> Payload bytes as hex:<hex> or @<path>
87
+ --permanent Create the field as permanent
88
+ --format <spec> Advanced field format as raw:<u8>
89
+ --value <spec> Advanced field value as hex:<hex>, @<path>, or utf8:<text>
90
+ --claimable Show only currently claimable locks
91
+ --reclaimable Show only currently reclaimable locks
92
+ --anchored Show only anchored domains
93
+ --listed Show only currently listed domains
94
+ --mineable Show only locally mineable root domains
95
+ --limit <n> Limit list rows (1..1000)
96
+ --all Show all rows for list commands
97
+ --verify Run full custom-hook verification
98
+ --follow Follow mining log output
99
+ --output <mode> Output mode: text, json, or preview-json
100
+ --progress <mode> Progress output mode: auto, tty, or none
101
+ --force-race Allow a visible root registration race
102
+ --yes Approve eligible plain yes/no mutation confirmations non-interactively
103
+ --help Show help
104
+ --version Show package version
105
+
106
+ Quickstart:
107
+ 1. Run \`cogcoin init\` to create the wallet.
108
+ 2. Run \`cogcoin sync\` to bootstrap assumeutxo and the managed Bitcoin/indexer state.
109
+ 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.
110
+
111
+ Examples:
112
+ cogcoin status --output json
113
+ cogcoin init --output json
114
+ cogcoin wallet address
115
+ cogcoin domain list --mineable
116
+ cogcoin register alpha-child
117
+ cogcoin register weatherbot --from id:1
118
+ cogcoin anchor alpha
119
+ cogcoin buy alpha
120
+ cogcoin buy alpha --from id:1
121
+ cogcoin field create alpha bio --text "hello"
122
+ cogcoin rep give alpha beta 10 --review "great operator"
123
+ cogcoin hooks status
124
+ cogcoin mine setup --output json
125
+ cogcoin register alpha-child --output preview-json
126
+ cogcoin mine status
127
+ `;
128
+ function supportsYesFlag(command) {
129
+ switch (command) {
130
+ case "repair":
131
+ case "register":
132
+ case "domain-register":
133
+ case "transfer":
134
+ case "domain-transfer":
135
+ case "sell":
136
+ case "domain-sell":
137
+ case "unsell":
138
+ case "domain-unsell":
139
+ case "buy":
140
+ case "domain-buy":
141
+ case "send":
142
+ case "cog-send":
143
+ case "claim":
144
+ case "cog-claim":
145
+ case "reclaim":
146
+ case "cog-reclaim":
147
+ case "cog-lock":
148
+ case "field-create":
149
+ case "field-set":
150
+ case "field-clear":
151
+ case "domain-endpoint-set":
152
+ case "domain-endpoint-clear":
153
+ case "domain-delegate-set":
154
+ case "domain-delegate-clear":
155
+ case "domain-miner-set":
156
+ case "domain-miner-clear":
157
+ case "domain-canonical":
158
+ case "rep-give":
159
+ case "rep-revoke":
160
+ return true;
161
+ default:
162
+ return false;
163
+ }
164
+ }
165
+ export function parseCliArgs(argv) {
166
+ let command = null;
167
+ const args = [];
168
+ let help = false;
169
+ let version = false;
170
+ let outputMode = "text";
171
+ let dbPath = null;
172
+ let dataDir = null;
173
+ let progressOutput = "auto";
174
+ let unlockFor = null;
175
+ let assumeYes = false;
176
+ let forceRace = false;
177
+ let anchorMessage = null;
178
+ let transferTarget = null;
179
+ let endpointText = null;
180
+ let endpointJson = null;
181
+ let endpointBytes = null;
182
+ let fieldPermanent = false;
183
+ let fieldFormat = null;
184
+ let fieldValue = null;
185
+ let fromIdentity = null;
186
+ let lockRecipientDomain = null;
187
+ let conditionHex = null;
188
+ let untilHeight = null;
189
+ let preimageHex = null;
190
+ let reviewText = null;
191
+ let locksClaimableOnly = false;
192
+ let locksReclaimableOnly = false;
193
+ let domainsAnchoredOnly = false;
194
+ let domainsListedOnly = false;
195
+ let domainsMineableOnly = false;
196
+ let listLimit = null;
197
+ let listAll = false;
198
+ let verify = false;
199
+ let follow = false;
200
+ for (let index = 0; index < argv.length; index += 1) {
201
+ const token = argv[index];
202
+ if (token === "--help") {
203
+ help = true;
204
+ continue;
205
+ }
206
+ if (token === "--version") {
207
+ version = true;
208
+ continue;
209
+ }
210
+ if (token === "--output") {
211
+ index += 1;
212
+ const value = argv[index] ?? null;
213
+ if (value !== "text" && value !== "json" && value !== "preview-json") {
214
+ throw new Error("cli_invalid_output_mode");
215
+ }
216
+ outputMode = value;
217
+ continue;
218
+ }
219
+ if (token === "--db") {
220
+ index += 1;
221
+ dbPath = argv[index] ?? null;
222
+ if (dbPath === null) {
223
+ throw new Error("cli_missing_db_path");
224
+ }
225
+ continue;
226
+ }
227
+ if (token === "--data-dir") {
228
+ index += 1;
229
+ dataDir = argv[index] ?? null;
230
+ if (dataDir === null) {
231
+ throw new Error("cli_missing_data_dir");
232
+ }
233
+ continue;
234
+ }
235
+ if (token === "--progress") {
236
+ index += 1;
237
+ const value = argv[index] ?? null;
238
+ if (value !== "auto" && value !== "tty" && value !== "none") {
239
+ throw new Error("cli_invalid_progress_output");
240
+ }
241
+ progressOutput = value;
242
+ continue;
243
+ }
244
+ if (token === "--for") {
245
+ index += 1;
246
+ unlockFor = argv[index] ?? null;
247
+ if (unlockFor === null) {
248
+ throw new Error("cli_missing_unlock_duration");
249
+ }
250
+ continue;
251
+ }
252
+ if (token === "--to") {
253
+ index += 1;
254
+ transferTarget = argv[index] ?? null;
255
+ if (transferTarget === null) {
256
+ throw new Error("cli_missing_transfer_target");
257
+ }
258
+ continue;
259
+ }
260
+ if (token === "--text") {
261
+ index += 1;
262
+ endpointText = argv[index] ?? null;
263
+ if (endpointText === null) {
264
+ throw new Error("cli_missing_endpoint_text");
265
+ }
266
+ continue;
267
+ }
268
+ if (token === "--json") {
269
+ index += 1;
270
+ endpointJson = argv[index] ?? null;
271
+ if (endpointJson === null) {
272
+ throw new Error("cli_missing_endpoint_json");
273
+ }
274
+ continue;
275
+ }
276
+ if (token === "--bytes") {
277
+ index += 1;
278
+ endpointBytes = argv[index] ?? null;
279
+ if (endpointBytes === null) {
280
+ throw new Error("cli_missing_endpoint_bytes");
281
+ }
282
+ continue;
283
+ }
284
+ if (token === "--permanent") {
285
+ fieldPermanent = true;
286
+ continue;
287
+ }
288
+ if (token === "--format") {
289
+ index += 1;
290
+ fieldFormat = argv[index] ?? null;
291
+ if (fieldFormat === null) {
292
+ throw new Error("cli_missing_field_format");
293
+ }
294
+ continue;
295
+ }
296
+ if (token === "--value") {
297
+ index += 1;
298
+ fieldValue = argv[index] ?? null;
299
+ if (fieldValue === null) {
300
+ throw new Error("cli_missing_field_value");
301
+ }
302
+ continue;
303
+ }
304
+ if (token === "--message") {
305
+ index += 1;
306
+ anchorMessage = argv[index] ?? null;
307
+ if (anchorMessage === null) {
308
+ throw new Error("cli_missing_anchor_message");
309
+ }
310
+ continue;
311
+ }
312
+ if (token === "--from") {
313
+ index += 1;
314
+ fromIdentity = argv[index] ?? null;
315
+ if (fromIdentity === null) {
316
+ throw new Error("cli_missing_from_identity");
317
+ }
318
+ continue;
319
+ }
320
+ if (token === "--to-domain") {
321
+ index += 1;
322
+ lockRecipientDomain = argv[index] ?? null;
323
+ if (lockRecipientDomain === null) {
324
+ throw new Error("cli_missing_lock_domain");
325
+ }
326
+ continue;
327
+ }
328
+ if (token === "--condition") {
329
+ index += 1;
330
+ conditionHex = argv[index] ?? null;
331
+ if (conditionHex === null) {
332
+ throw new Error("cli_missing_lock_condition");
333
+ }
334
+ continue;
335
+ }
336
+ if (token === "--until-height") {
337
+ index += 1;
338
+ untilHeight = argv[index] ?? null;
339
+ if (untilHeight === null) {
340
+ throw new Error("cli_missing_until_height");
341
+ }
342
+ continue;
343
+ }
344
+ if (token === "--preimage") {
345
+ index += 1;
346
+ preimageHex = argv[index] ?? null;
347
+ if (preimageHex === null) {
348
+ throw new Error("cli_missing_claim_preimage");
349
+ }
350
+ continue;
351
+ }
352
+ if (token === "--review") {
353
+ index += 1;
354
+ reviewText = argv[index] ?? null;
355
+ if (reviewText === null) {
356
+ throw new Error("cli_missing_review_text");
357
+ }
358
+ continue;
359
+ }
360
+ if (token === "--claimable") {
361
+ locksClaimableOnly = true;
362
+ continue;
363
+ }
364
+ if (token === "--reclaimable") {
365
+ locksReclaimableOnly = true;
366
+ continue;
367
+ }
368
+ if (token === "--anchored") {
369
+ domainsAnchoredOnly = true;
370
+ continue;
371
+ }
372
+ if (token === "--listed") {
373
+ domainsListedOnly = true;
374
+ continue;
375
+ }
376
+ if (token === "--mineable") {
377
+ domainsMineableOnly = true;
378
+ continue;
379
+ }
380
+ if (token === "--limit") {
381
+ index += 1;
382
+ const value = argv[index] ?? null;
383
+ if (value === null || !/^[1-9]\d*$/.test(value)) {
384
+ throw new Error("cli_invalid_limit");
385
+ }
386
+ listLimit = Number(value);
387
+ if (listLimit < 1 || listLimit > 1000) {
388
+ throw new Error("cli_invalid_limit");
389
+ }
390
+ continue;
391
+ }
392
+ if (token === "--all") {
393
+ listAll = true;
394
+ continue;
395
+ }
396
+ if (token === "--verify") {
397
+ verify = true;
398
+ continue;
399
+ }
400
+ if (token === "--follow") {
401
+ follow = true;
402
+ continue;
403
+ }
404
+ if (token === "--yes") {
405
+ assumeYes = true;
406
+ continue;
407
+ }
408
+ if (token === "--force-race") {
409
+ forceRace = true;
410
+ continue;
411
+ }
412
+ if (token?.startsWith("--")) {
413
+ throw new Error(`cli_unknown_flag_${token.slice(2)}`);
414
+ }
415
+ if (command === null) {
416
+ if (token === "wallet") {
417
+ const subcommand = argv[index + 1] ?? null;
418
+ if (subcommand === "status") {
419
+ command = "wallet-status";
420
+ index += 1;
421
+ continue;
422
+ }
423
+ if (subcommand === "address") {
424
+ command = "wallet-address";
425
+ index += 1;
426
+ continue;
427
+ }
428
+ if (subcommand === "ids") {
429
+ command = "wallet-ids";
430
+ index += 1;
431
+ continue;
432
+ }
433
+ if (subcommand === "init") {
434
+ command = "wallet-init";
435
+ index += 1;
436
+ continue;
437
+ }
438
+ if (subcommand === "unlock") {
439
+ command = "wallet-unlock";
440
+ index += 1;
441
+ continue;
442
+ }
443
+ if (subcommand === "lock") {
444
+ command = "wallet-lock";
445
+ index += 1;
446
+ continue;
447
+ }
448
+ if (subcommand === "export") {
449
+ command = "wallet-export";
450
+ index += 1;
451
+ continue;
452
+ }
453
+ if (subcommand === "import") {
454
+ command = "wallet-import";
455
+ index += 1;
456
+ continue;
457
+ }
458
+ throw new Error(`cli_unknown_command_wallet${subcommand === null ? "" : `_${subcommand}`}`);
459
+ }
460
+ if (token === "hooks") {
461
+ const subcommand = argv[index + 1] ?? null;
462
+ if (subcommand === "status") {
463
+ command = "hooks-mining-status";
464
+ index += 1;
465
+ continue;
466
+ }
467
+ if (subcommand === "enable" || subcommand === "disable") {
468
+ const target = argv[index + 2] ?? null;
469
+ if (target !== "mining") {
470
+ throw new Error(`cli_unknown_command_hooks_${subcommand}${target === null ? "" : `_${target}`}`);
471
+ }
472
+ command = subcommand === "enable" ? "hooks-mining-enable" : "hooks-mining-disable";
473
+ index += 2;
474
+ continue;
475
+ }
476
+ throw new Error(`cli_unknown_command_hooks${subcommand === null ? "" : `_${subcommand}`}`);
477
+ }
478
+ if (token === "mine") {
479
+ const subcommand = argv[index + 1] ?? null;
480
+ if (subcommand === null || subcommand.startsWith("--")) {
481
+ command = "mine";
482
+ continue;
483
+ }
484
+ if (subcommand === "start") {
485
+ command = "mine-start";
486
+ index += 1;
487
+ continue;
488
+ }
489
+ if (subcommand === "stop") {
490
+ command = "mine-stop";
491
+ index += 1;
492
+ continue;
493
+ }
494
+ if (subcommand === "setup") {
495
+ command = "mine-setup";
496
+ index += 1;
497
+ continue;
498
+ }
499
+ if (subcommand === "status") {
500
+ command = "mine-status";
501
+ index += 1;
502
+ continue;
503
+ }
504
+ if (subcommand === "log") {
505
+ command = "mine-log";
506
+ index += 1;
507
+ continue;
508
+ }
509
+ throw new Error(`cli_unknown_command_mine${subcommand === null ? "" : `_${subcommand}`}`);
510
+ }
511
+ if (token === "domain") {
512
+ const subcommand = argv[index + 1] ?? null;
513
+ if (subcommand === "register") {
514
+ command = "domain-register";
515
+ index += 1;
516
+ continue;
517
+ }
518
+ if (subcommand === "list") {
519
+ command = "domain-list";
520
+ index += 1;
521
+ continue;
522
+ }
523
+ if (subcommand === "show") {
524
+ command = "domain-show";
525
+ index += 1;
526
+ continue;
527
+ }
528
+ if (subcommand === "anchor") {
529
+ command = "domain-anchor";
530
+ index += 1;
531
+ continue;
532
+ }
533
+ if (subcommand === "transfer") {
534
+ command = "domain-transfer";
535
+ index += 1;
536
+ continue;
537
+ }
538
+ if (subcommand === "sell") {
539
+ command = "domain-sell";
540
+ index += 1;
541
+ continue;
542
+ }
543
+ if (subcommand === "unsell") {
544
+ command = "domain-unsell";
545
+ index += 1;
546
+ continue;
547
+ }
548
+ if (subcommand === "buy") {
549
+ command = "domain-buy";
550
+ index += 1;
551
+ continue;
552
+ }
553
+ if (subcommand === "endpoint") {
554
+ const action = argv[index + 2] ?? null;
555
+ if (action === "set") {
556
+ command = "domain-endpoint-set";
557
+ index += 2;
558
+ continue;
559
+ }
560
+ if (action === "clear") {
561
+ command = "domain-endpoint-clear";
562
+ index += 2;
563
+ continue;
564
+ }
565
+ throw new Error(`cli_unknown_command_domain_endpoint${action === null ? "" : `_${action}`}`);
566
+ }
567
+ if (subcommand === "delegate") {
568
+ const action = argv[index + 2] ?? null;
569
+ if (action === "set") {
570
+ command = "domain-delegate-set";
571
+ index += 2;
572
+ continue;
573
+ }
574
+ if (action === "clear") {
575
+ command = "domain-delegate-clear";
576
+ index += 2;
577
+ continue;
578
+ }
579
+ throw new Error(`cli_unknown_command_domain_delegate${action === null ? "" : `_${action}`}`);
580
+ }
581
+ if (subcommand === "miner") {
582
+ const action = argv[index + 2] ?? null;
583
+ if (action === "set") {
584
+ command = "domain-miner-set";
585
+ index += 2;
586
+ continue;
587
+ }
588
+ if (action === "clear") {
589
+ command = "domain-miner-clear";
590
+ index += 2;
591
+ continue;
592
+ }
593
+ throw new Error(`cli_unknown_command_domain_miner${action === null ? "" : `_${action}`}`);
594
+ }
595
+ if (subcommand === "canonical") {
596
+ command = "domain-canonical";
597
+ index += 1;
598
+ continue;
599
+ }
600
+ throw new Error(`cli_unknown_command_domain${subcommand === null ? "" : `_${subcommand}`}`);
601
+ }
602
+ if (token === "cog") {
603
+ const subcommand = argv[index + 1] ?? null;
604
+ if (subcommand === "send") {
605
+ command = "cog-send";
606
+ index += 1;
607
+ continue;
608
+ }
609
+ if (subcommand === "claim") {
610
+ command = "cog-claim";
611
+ index += 1;
612
+ continue;
613
+ }
614
+ if (subcommand === "reclaim") {
615
+ command = "cog-reclaim";
616
+ index += 1;
617
+ continue;
618
+ }
619
+ if (subcommand === "lock") {
620
+ command = "cog-lock";
621
+ index += 1;
622
+ continue;
623
+ }
624
+ if (subcommand === "balance") {
625
+ command = "cog-balance";
626
+ index += 1;
627
+ continue;
628
+ }
629
+ if (subcommand === "locks") {
630
+ command = "cog-locks";
631
+ index += 1;
632
+ continue;
633
+ }
634
+ throw new Error(`cli_unknown_command_cog${subcommand === null ? "" : `_${subcommand}`}`);
635
+ }
636
+ if (token === "rep") {
637
+ const subcommand = argv[index + 1] ?? null;
638
+ if (subcommand === "give") {
639
+ command = "rep-give";
640
+ index += 1;
641
+ continue;
642
+ }
643
+ if (subcommand === "revoke") {
644
+ command = "rep-revoke";
645
+ index += 1;
646
+ continue;
647
+ }
648
+ throw new Error(`cli_unknown_command_rep${subcommand === null ? "" : `_${subcommand}`}`);
649
+ }
650
+ if (token === "field") {
651
+ const subcommand = argv[index + 1] ?? null;
652
+ if (subcommand === "list") {
653
+ command = "field-list";
654
+ index += 1;
655
+ continue;
656
+ }
657
+ if (subcommand === "show") {
658
+ command = "field-show";
659
+ index += 1;
660
+ continue;
661
+ }
662
+ if (subcommand === "create") {
663
+ command = "field-create";
664
+ index += 1;
665
+ continue;
666
+ }
667
+ if (subcommand === "set") {
668
+ command = "field-set";
669
+ index += 1;
670
+ continue;
671
+ }
672
+ if (subcommand === "clear") {
673
+ command = "field-clear";
674
+ index += 1;
675
+ continue;
676
+ }
677
+ command = "field";
678
+ continue;
679
+ }
680
+ if (token === "init"
681
+ || token === "repair"
682
+ || token === "sync"
683
+ || token === "status"
684
+ || token === "follow"
685
+ || token === "unlock"
686
+ || token === "anchor"
687
+ || token === "register"
688
+ || token === "transfer"
689
+ || token === "sell"
690
+ || token === "unsell"
691
+ || token === "buy"
692
+ || token === "send"
693
+ || token === "claim"
694
+ || token === "reclaim"
695
+ || token === "address"
696
+ || token === "ids"
697
+ || token === "balance"
698
+ || token === "locks"
699
+ || token === "domains"
700
+ || token === "show"
701
+ || token === "fields") {
702
+ command = token;
703
+ continue;
704
+ }
705
+ throw new Error(`cli_unknown_command_${token}`);
706
+ }
707
+ args.push(token);
708
+ }
709
+ if ((command === "status"
710
+ || command === "init"
711
+ || command === "unlock"
712
+ || command === "wallet-init"
713
+ || command === "wallet-lock"
714
+ || command === "wallet-unlock"
715
+ || command === "wallet-status"
716
+ || command === "repair"
717
+ || command === "sync"
718
+ || command === "follow"
719
+ || command === "hooks-mining-enable"
720
+ || command === "hooks-mining-disable"
721
+ || command === "hooks-mining-status"
722
+ || command === "mine"
723
+ || command === "mine-start"
724
+ || command === "mine-stop"
725
+ || command === "mine-setup"
726
+ || command === "mine-status"
727
+ || command === "mine-log"
728
+ || command === "wallet-address"
729
+ || command === "wallet-ids"
730
+ || command === "address"
731
+ || command === "ids"
732
+ || command === "balance"
733
+ || command === "cog-balance"
734
+ || command === "locks"
735
+ || command === "cog-locks"
736
+ || command === "domain-list"
737
+ || command === "domains")
738
+ && args.length !== 0) {
739
+ throw new Error(`cli_unexpected_argument_${args[0]}`);
740
+ }
741
+ if ((command === "register" || command === "domain-register") && args.length !== 1) {
742
+ throw new Error("cli_missing_domain_argument");
743
+ }
744
+ if ((command === "anchor" || command === "domain-anchor") && args.length !== 1) {
745
+ throw new Error("cli_missing_domain_argument");
746
+ }
747
+ if ((command === "domain-endpoint-set"
748
+ || command === "domain-endpoint-clear"
749
+ || command === "domain-delegate-clear"
750
+ || command === "domain-miner-clear"
751
+ || command === "domain-canonical")
752
+ && args.length !== 1) {
753
+ throw new Error("cli_missing_domain_argument");
754
+ }
755
+ if (command === "domain-delegate-set" && args.length !== 2) {
756
+ throw new Error("cli_missing_delegate_arguments");
757
+ }
758
+ if (command === "domain-miner-set" && args.length !== 2) {
759
+ throw new Error("cli_missing_miner_arguments");
760
+ }
761
+ if ((command === "transfer" || command === "domain-transfer") && args.length !== 1) {
762
+ throw new Error("cli_missing_domain_argument");
763
+ }
764
+ if ((command === "sell" || command === "domain-sell") && args.length !== 2) {
765
+ throw new Error("cli_missing_sell_arguments");
766
+ }
767
+ if ((command === "unsell" || command === "domain-unsell" || command === "buy" || command === "domain-buy") && args.length !== 1) {
768
+ throw new Error("cli_missing_domain_argument");
769
+ }
770
+ if ((command === "send" || command === "cog-send" || command === "cog-lock") && args.length !== 1) {
771
+ throw new Error("cli_missing_amount_argument");
772
+ }
773
+ if ((command === "claim" || command === "cog-claim" || command === "reclaim" || command === "cog-reclaim") && args.length !== 1) {
774
+ throw new Error("cli_missing_lock_argument");
775
+ }
776
+ if ((command === "rep-give" || command === "rep-revoke") && args.length !== 3) {
777
+ throw new Error("cli_missing_reputation_arguments");
778
+ }
779
+ if ((command === "show" || command === "domain-show" || command === "fields") && args.length !== 1) {
780
+ throw new Error(command === "show" ? "cli_missing_domain_argument" : "cli_missing_domain_argument");
781
+ }
782
+ if (command === "field-list" && args.length !== 1) {
783
+ throw new Error("cli_missing_domain_argument");
784
+ }
785
+ if ((command === "wallet-export" || command === "wallet-import") && args.length !== 1) {
786
+ throw new Error(command === "wallet-export" ? "cli_missing_export_path" : "cli_missing_import_path");
787
+ }
788
+ if ((command === "field" || command === "field-show" || command === "field-create" || command === "field-set" || command === "field-clear") && args.length !== 2) {
789
+ throw new Error("cli_missing_field_arguments");
790
+ }
791
+ if (unlockFor !== null
792
+ && command !== "unlock"
793
+ && command !== "wallet-unlock"
794
+ && command !== "cog-lock") {
795
+ throw new Error("cli_unlock_duration_not_supported_for_command");
796
+ }
797
+ if (assumeYes && !supportsYesFlag(command)) {
798
+ throw new Error("cli_yes_not_supported_for_command");
799
+ }
800
+ if (forceRace && command !== "register" && command !== "domain-register") {
801
+ throw new Error("cli_force_race_not_supported_for_command");
802
+ }
803
+ if (anchorMessage !== null && command !== "anchor" && command !== "domain-anchor") {
804
+ throw new Error("cli_message_not_supported_for_command");
805
+ }
806
+ const namedPayloadFlagCount = Number(endpointText !== null) + Number(endpointJson !== null) + Number(endpointBytes !== null);
807
+ const hasRawPayloadFlags = fieldFormat !== null || fieldValue !== null;
808
+ if ((endpointText !== null || endpointJson !== null || endpointBytes !== null)
809
+ && command !== "domain-endpoint-set"
810
+ && command !== "field-create"
811
+ && command !== "field-set") {
812
+ throw new Error("cli_endpoint_payload_not_supported_for_command");
813
+ }
814
+ if (command === "domain-endpoint-set" && namedPayloadFlagCount !== 1) {
815
+ throw new Error("cli_endpoint_requires_exactly_one_payload_flag");
816
+ }
817
+ if (fieldPermanent && command !== "field-create") {
818
+ throw new Error("cli_permanent_not_supported_for_command");
819
+ }
820
+ if (hasRawPayloadFlags && command !== "field-create" && command !== "field-set") {
821
+ throw new Error("cli_field_value_not_supported_for_command");
822
+ }
823
+ if ((command === "field-create" || command === "field-set") && namedPayloadFlagCount > 0 && hasRawPayloadFlags) {
824
+ throw new Error("cli_field_conflicting_payload_flags");
825
+ }
826
+ if ((command === "field-create" || command === "field-set") && namedPayloadFlagCount > 1) {
827
+ throw new Error("cli_field_requires_exactly_one_named_payload_flag");
828
+ }
829
+ if ((command === "field-create" || command === "field-set") && fieldFormat !== null && fieldValue === null) {
830
+ throw new Error("cli_missing_field_value");
831
+ }
832
+ if ((command === "field-create" || command === "field-set") && fieldFormat === null && fieldValue !== null) {
833
+ throw new Error("cli_missing_field_format");
834
+ }
835
+ if (command === "field-set" && namedPayloadFlagCount === 0 && !hasRawPayloadFlags) {
836
+ throw new Error("cli_field_set_requires_value");
837
+ }
838
+ if ((command === "field-clear" || command === "field" || command === "field-show" || command === "field-list")
839
+ && (namedPayloadFlagCount > 0 || hasRawPayloadFlags || fieldPermanent)) {
840
+ throw new Error("cli_field_flags_not_supported_for_command");
841
+ }
842
+ if (transferTarget !== null && command !== "transfer" && command !== "domain-transfer") {
843
+ if (command !== "send" && command !== "cog-send") {
844
+ throw new Error("cli_to_not_supported_for_command");
845
+ }
846
+ }
847
+ if ((command === "transfer" || command === "domain-transfer" || command === "send" || command === "cog-send") && transferTarget === null) {
848
+ throw new Error("cli_missing_transfer_target");
849
+ }
850
+ if (fromIdentity !== null
851
+ && command !== "register"
852
+ && command !== "domain-register"
853
+ && command !== "buy"
854
+ && command !== "domain-buy"
855
+ && command !== "send"
856
+ && command !== "cog-send"
857
+ && command !== "cog-lock") {
858
+ throw new Error("cli_from_not_supported_for_command");
859
+ }
860
+ if (lockRecipientDomain !== null && command !== "cog-lock") {
861
+ throw new Error("cli_to_domain_not_supported_for_command");
862
+ }
863
+ if (conditionHex !== null && command !== "cog-lock") {
864
+ throw new Error("cli_condition_not_supported_for_command");
865
+ }
866
+ if (untilHeight !== null && command !== "cog-lock") {
867
+ throw new Error("cli_until_height_not_supported_for_command");
868
+ }
869
+ if (preimageHex !== null && command !== "claim" && command !== "cog-claim") {
870
+ throw new Error("cli_preimage_not_supported_for_command");
871
+ }
872
+ if (reviewText !== null && command !== "rep-give" && command !== "rep-revoke") {
873
+ throw new Error("cli_review_not_supported_for_command");
874
+ }
875
+ if ((locksClaimableOnly || locksReclaimableOnly)
876
+ && command !== "locks"
877
+ && command !== "cog-locks") {
878
+ throw new Error("cli_lock_filters_not_supported_for_command");
879
+ }
880
+ if (locksClaimableOnly && locksReclaimableOnly) {
881
+ throw new Error("cli_conflicting_lock_filters");
882
+ }
883
+ if ((domainsAnchoredOnly || domainsListedOnly || domainsMineableOnly)
884
+ && command !== "domain-list"
885
+ && command !== "domains") {
886
+ throw new Error("cli_domain_filters_not_supported_for_command");
887
+ }
888
+ if ((listLimit !== null || listAll)
889
+ && command !== "locks"
890
+ && command !== "cog-locks"
891
+ && command !== "wallet-ids"
892
+ && command !== "ids"
893
+ && command !== "domain-list"
894
+ && command !== "domains"
895
+ && command !== "fields"
896
+ && command !== "field-list"
897
+ && command !== "mine-log") {
898
+ throw new Error("cli_lock_filters_not_supported_for_command");
899
+ }
900
+ if (listAll && listLimit !== null) {
901
+ throw new Error("cli_conflicting_lock_limits");
902
+ }
903
+ if (verify && command !== "hooks-mining-status") {
904
+ throw new Error("cli_verify_not_supported_for_command");
905
+ }
906
+ if (follow && command !== "mine-log") {
907
+ throw new Error("cli_follow_not_supported_for_command");
908
+ }
909
+ if (command === "mine-log" && follow && outputMode !== "text") {
910
+ throw new Error("cli_follow_json_not_supported");
911
+ }
912
+ if (command === "mine-log" && follow && (listAll || listLimit !== null)) {
913
+ throw new Error("cli_follow_limit_not_supported");
914
+ }
915
+ if (outputMode === "json" && !isJsonOutputSupportedCommand(command)) {
916
+ throw new Error("cli_output_not_supported_for_command");
917
+ }
918
+ if (outputMode === "preview-json" && !isPreviewJsonOutputSupportedCommand(command)) {
919
+ throw new Error("cli_output_not_supported_for_command");
920
+ }
921
+ if (command === "cog-lock") {
922
+ if (lockRecipientDomain === null) {
923
+ throw new Error("cli_missing_lock_domain");
924
+ }
925
+ if (conditionHex === null) {
926
+ throw new Error("cli_missing_lock_condition");
927
+ }
928
+ if ((unlockFor === null) === (untilHeight === null)) {
929
+ throw new Error("cli_lock_timeout_requires_exactly_one_mode");
930
+ }
931
+ }
932
+ if ((command === "claim" || command === "cog-claim") && preimageHex === null) {
933
+ throw new Error("cli_missing_claim_preimage");
934
+ }
935
+ return {
936
+ command,
937
+ args,
938
+ help,
939
+ version,
940
+ outputMode,
941
+ dbPath,
942
+ dataDir,
943
+ progressOutput,
944
+ unlockFor,
945
+ assumeYes,
946
+ forceRace,
947
+ anchorMessage,
948
+ transferTarget,
949
+ endpointText,
950
+ endpointJson,
951
+ endpointBytes,
952
+ fieldPermanent,
953
+ fieldFormat,
954
+ fieldValue,
955
+ fromIdentity,
956
+ lockRecipientDomain,
957
+ conditionHex,
958
+ untilHeight,
959
+ preimageHex,
960
+ reviewText,
961
+ locksClaimableOnly,
962
+ locksReclaimableOnly,
963
+ domainsAnchoredOnly,
964
+ domainsListedOnly,
965
+ domainsMineableOnly,
966
+ listLimit,
967
+ listAll,
968
+ verify,
969
+ follow,
970
+ };
971
+ }