@cogcoin/client 1.1.8 → 1.1.10

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 (295) hide show
  1. package/README.md +1 -1
  2. package/dist/bitcoind/managed-bitcoind-service-config.d.ts +13 -0
  3. package/dist/bitcoind/managed-bitcoind-service-config.js +165 -0
  4. package/dist/bitcoind/managed-bitcoind-service-lifecycle.d.ts +28 -0
  5. package/dist/bitcoind/managed-bitcoind-service-lifecycle.js +290 -0
  6. package/dist/bitcoind/managed-bitcoind-service-process.d.ts +8 -0
  7. package/dist/bitcoind/managed-bitcoind-service-process.js +48 -0
  8. package/dist/bitcoind/managed-bitcoind-service-replica.d.ts +8 -0
  9. package/dist/bitcoind/managed-bitcoind-service-replica.js +142 -0
  10. package/dist/bitcoind/managed-bitcoind-service-status.d.ts +42 -0
  11. package/dist/bitcoind/managed-bitcoind-service-status.js +178 -0
  12. package/dist/bitcoind/managed-bitcoind-service-types.d.ts +36 -0
  13. package/dist/bitcoind/managed-bitcoind-service-types.js +1 -0
  14. package/dist/bitcoind/service.d.ts +7 -63
  15. package/dist/bitcoind/service.js +7 -797
  16. package/dist/cli/commands/mining-read.js +1 -1
  17. package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
  18. package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
  19. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
  20. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
  21. package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
  22. package/dist/cli/commands/wallet-mutation/cog.js +131 -0
  23. package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
  24. package/dist/cli/commands/wallet-mutation/context.js +18 -0
  25. package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
  26. package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
  27. package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
  28. package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
  29. package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
  30. package/dist/cli/commands/wallet-mutation/field.js +125 -0
  31. package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
  32. package/dist/cli/commands/wallet-mutation/register.js +38 -0
  33. package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
  34. package/dist/cli/commands/wallet-mutation/registry.js +39 -0
  35. package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
  36. package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
  37. package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
  38. package/dist/cli/commands/wallet-mutation/types.js +1 -0
  39. package/dist/cli/commands/wallet-mutation.js +13 -765
  40. package/dist/cli/commands/wallet-read.js +4 -4
  41. package/dist/cli/mutation-success.d.ts +0 -2
  42. package/dist/cli/output/classify.d.ts +7 -0
  43. package/dist/cli/output/classify.js +94 -0
  44. package/dist/cli/output/render.d.ts +2 -0
  45. package/dist/cli/output/render.js +13 -0
  46. package/dist/cli/output/rules/cli-surface.d.ts +2 -0
  47. package/dist/cli/output/rules/cli-surface.js +110 -0
  48. package/dist/cli/output/rules/generic.d.ts +2 -0
  49. package/dist/cli/output/rules/generic.js +13 -0
  50. package/dist/cli/output/rules/index.d.ts +2 -0
  51. package/dist/cli/output/rules/index.js +24 -0
  52. package/dist/cli/output/rules/mining-update.d.ts +2 -0
  53. package/dist/cli/output/rules/mining-update.js +68 -0
  54. package/dist/cli/output/rules/services.d.ts +2 -0
  55. package/dist/cli/output/rules/services.js +110 -0
  56. package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
  57. package/dist/cli/output/rules/wallet-admin.js +224 -0
  58. package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
  59. package/dist/cli/output/rules/wallet-mutations.js +274 -0
  60. package/dist/cli/output/types.d.ts +16 -0
  61. package/dist/cli/output/types.js +1 -0
  62. package/dist/cli/output.d.ts +2 -168
  63. package/dist/cli/output.js +6 -989
  64. package/dist/cli/pagination.d.ts +15 -0
  65. package/dist/cli/pagination.js +16 -0
  66. package/dist/cli/recommendations.d.ts +4 -0
  67. package/dist/cli/recommendations.js +108 -0
  68. package/dist/cli/wallet-format/availability.d.ts +5 -0
  69. package/dist/cli/wallet-format/availability.js +96 -0
  70. package/dist/cli/wallet-format/balance.d.ts +2 -0
  71. package/dist/cli/wallet-format/balance.js +162 -0
  72. package/dist/cli/wallet-format/domains.d.ts +8 -0
  73. package/dist/cli/wallet-format/domains.js +84 -0
  74. package/dist/cli/wallet-format/fields.d.ts +6 -0
  75. package/dist/cli/wallet-format/fields.js +61 -0
  76. package/dist/cli/wallet-format/identity.d.ts +5 -0
  77. package/dist/cli/wallet-format/identity.js +19 -0
  78. package/dist/cli/wallet-format/locks.d.ts +7 -0
  79. package/dist/cli/wallet-format/locks.js +52 -0
  80. package/dist/cli/wallet-format/overview.d.ts +2 -0
  81. package/dist/cli/wallet-format/overview.js +122 -0
  82. package/dist/cli/wallet-format/pending.d.ts +13 -0
  83. package/dist/cli/wallet-format/pending.js +101 -0
  84. package/dist/cli/wallet-format/shared.d.ts +7 -0
  85. package/dist/cli/wallet-format/shared.js +31 -0
  86. package/dist/cli/wallet-format/status.d.ts +3 -0
  87. package/dist/cli/wallet-format/status.js +27 -0
  88. package/dist/cli/wallet-format.d.ts +8 -30
  89. package/dist/cli/wallet-format.js +8 -830
  90. package/dist/cli/wallet-read-helpers.d.ts +6 -0
  91. package/dist/cli/wallet-read-helpers.js +17 -0
  92. package/dist/wallet/mining/candidate.d.ts +1 -1
  93. package/dist/wallet/mining/candidate.js +3 -3
  94. package/dist/wallet/mining/constants.d.ts +2 -2
  95. package/dist/wallet/mining/constants.js +2 -2
  96. package/dist/wallet/mining/engine-types.d.ts +1 -0
  97. package/dist/wallet/mining/engine-types.js +9 -1
  98. package/dist/wallet/mining/publish.js +3 -6
  99. package/dist/wallet/mining/runner.js +30 -18
  100. package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
  101. package/dist/wallet/mining/sentences.js +8 -8
  102. package/dist/wallet/mining/visualizer.js +7 -6
  103. package/dist/wallet/read/context.d.ts +4 -10
  104. package/dist/wallet/read/context.js +4 -227
  105. package/dist/wallet/read/local-state.d.ts +28 -0
  106. package/dist/wallet/read/local-state.js +233 -0
  107. package/dist/wallet/read/managed-bitcoind.d.ts +30 -0
  108. package/dist/wallet/read/managed-bitcoind.js +138 -0
  109. package/dist/wallet/read/managed-indexer.d.ts +23 -0
  110. package/dist/wallet/read/managed-indexer.js +87 -0
  111. package/dist/wallet/read/managed-services.d.ts +6 -21
  112. package/dist/wallet/read/managed-services.js +23 -196
  113. package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
  114. package/dist/wallet/tx/anchor/confirm.js +60 -0
  115. package/dist/wallet/tx/anchor/draft.d.ts +39 -0
  116. package/dist/wallet/tx/anchor/draft.js +167 -0
  117. package/dist/wallet/tx/anchor/index.d.ts +5 -0
  118. package/dist/wallet/tx/anchor/index.js +148 -0
  119. package/dist/wallet/tx/anchor/intent.d.ts +61 -0
  120. package/dist/wallet/tx/anchor/intent.js +101 -0
  121. package/dist/wallet/tx/anchor/plan.d.ts +3 -0
  122. package/dist/wallet/tx/anchor/plan.js +18 -0
  123. package/dist/wallet/tx/anchor/result.d.ts +25 -0
  124. package/dist/wallet/tx/anchor/result.js +20 -0
  125. package/dist/wallet/tx/anchor.d.ts +1 -39
  126. package/dist/wallet/tx/anchor.js +1 -494
  127. package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
  128. package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
  129. package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
  130. package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
  131. package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
  132. package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
  133. package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
  134. package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
  135. package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
  136. package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
  137. package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
  138. package/dist/wallet/tx/bitcoin-transfer.js +1 -200
  139. package/dist/wallet/tx/cog/confirm.d.ts +13 -0
  140. package/dist/wallet/tx/cog/confirm.js +59 -0
  141. package/dist/wallet/tx/cog/draft.d.ts +20 -0
  142. package/dist/wallet/tx/cog/draft.js +114 -0
  143. package/dist/wallet/tx/cog/index.d.ts +6 -0
  144. package/dist/wallet/tx/cog/index.js +117 -0
  145. package/dist/wallet/tx/cog/intent.d.ts +30 -0
  146. package/dist/wallet/tx/cog/intent.js +169 -0
  147. package/dist/wallet/tx/cog/plan.d.ts +19 -0
  148. package/dist/wallet/tx/cog/plan.js +65 -0
  149. package/dist/wallet/tx/cog/result.d.ts +27 -0
  150. package/dist/wallet/tx/cog/result.js +28 -0
  151. package/dist/wallet/tx/cog/types.d.ts +186 -0
  152. package/dist/wallet/tx/cog/types.js +2 -0
  153. package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
  154. package/dist/wallet/tx/cog/variants/claim.js +92 -0
  155. package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
  156. package/dist/wallet/tx/cog/variants/lock.js +102 -0
  157. package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
  158. package/dist/wallet/tx/cog/variants/send.js +77 -0
  159. package/dist/wallet/tx/cog.d.ts +1 -96
  160. package/dist/wallet/tx/cog.js +1 -824
  161. package/dist/wallet/tx/common.d.ts +14 -199
  162. package/dist/wallet/tx/common.js +10 -493
  163. package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
  164. package/dist/wallet/tx/domain-admin/confirm.js +58 -0
  165. package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
  166. package/dist/wallet/tx/domain-admin/draft.js +161 -0
  167. package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
  168. package/dist/wallet/tx/domain-admin/index.js +150 -0
  169. package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
  170. package/dist/wallet/tx/domain-admin/intent.js +61 -0
  171. package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
  172. package/dist/wallet/tx/domain-admin/plan.js +64 -0
  173. package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
  174. package/dist/wallet/tx/domain-admin/result.js +33 -0
  175. package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
  176. package/dist/wallet/tx/domain-admin/types.js +1 -0
  177. package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
  178. package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
  179. package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
  180. package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
  181. package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
  182. package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
  183. package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
  184. package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
  185. package/dist/wallet/tx/domain-admin.d.ts +1 -107
  186. package/dist/wallet/tx/domain-admin.js +1 -729
  187. package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
  188. package/dist/wallet/tx/domain-market/confirm.js +52 -0
  189. package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
  190. package/dist/wallet/tx/domain-market/draft.js +286 -0
  191. package/dist/wallet/tx/domain-market/index.d.ts +6 -0
  192. package/dist/wallet/tx/domain-market/index.js +145 -0
  193. package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
  194. package/dist/wallet/tx/domain-market/intent.js +131 -0
  195. package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
  196. package/dist/wallet/tx/domain-market/plan.js +98 -0
  197. package/dist/wallet/tx/domain-market/result.d.ts +45 -0
  198. package/dist/wallet/tx/domain-market/result.js +88 -0
  199. package/dist/wallet/tx/domain-market/types.d.ts +221 -0
  200. package/dist/wallet/tx/domain-market/types.js +1 -0
  201. package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
  202. package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
  203. package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
  204. package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
  205. package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
  206. package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
  207. package/dist/wallet/tx/domain-market.d.ts +1 -116
  208. package/dist/wallet/tx/domain-market.js +1 -1078
  209. package/dist/wallet/tx/draft-build.d.ts +60 -0
  210. package/dist/wallet/tx/draft-build.js +127 -0
  211. package/dist/wallet/tx/executor.d.ts +6 -40
  212. package/dist/wallet/tx/executor.js +6 -100
  213. package/dist/wallet/tx/fee.d.ts +30 -0
  214. package/dist/wallet/tx/fee.js +98 -0
  215. package/dist/wallet/tx/field/confirm.d.ts +11 -0
  216. package/dist/wallet/tx/field/confirm.js +19 -0
  217. package/dist/wallet/tx/field/draft.d.ts +23 -0
  218. package/dist/wallet/tx/field/draft.js +202 -0
  219. package/dist/wallet/tx/field/index.d.ts +5 -0
  220. package/dist/wallet/tx/field/index.js +140 -0
  221. package/dist/wallet/tx/field/intent.d.ts +5 -0
  222. package/dist/wallet/tx/field/intent.js +50 -0
  223. package/dist/wallet/tx/field/plan.d.ts +20 -0
  224. package/dist/wallet/tx/field/plan.js +65 -0
  225. package/dist/wallet/tx/field/result.d.ts +29 -0
  226. package/dist/wallet/tx/field/result.js +103 -0
  227. package/dist/wallet/tx/field/types.d.ts +163 -0
  228. package/dist/wallet/tx/field/types.js +1 -0
  229. package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
  230. package/dist/wallet/tx/field/variants/clear.js +60 -0
  231. package/dist/wallet/tx/field/variants/create.d.ts +2 -0
  232. package/dist/wallet/tx/field/variants/create.js +67 -0
  233. package/dist/wallet/tx/field/variants/set.d.ts +2 -0
  234. package/dist/wallet/tx/field/variants/set.js +195 -0
  235. package/dist/wallet/tx/field.d.ts +1 -95
  236. package/dist/wallet/tx/field.js +1 -920
  237. package/dist/wallet/tx/mining-preemption.d.ts +6 -0
  238. package/dist/wallet/tx/mining-preemption.js +7 -0
  239. package/dist/wallet/tx/primitives.d.ts +13 -0
  240. package/dist/wallet/tx/primitives.js +42 -0
  241. package/dist/wallet/tx/psbt-assert.d.ts +14 -0
  242. package/dist/wallet/tx/psbt-assert.js +39 -0
  243. package/dist/wallet/tx/publish.d.ts +37 -0
  244. package/dist/wallet/tx/publish.js +88 -0
  245. package/dist/wallet/tx/readiness.d.ts +7 -0
  246. package/dist/wallet/tx/readiness.js +61 -0
  247. package/dist/wallet/tx/reconcile.d.ts +24 -0
  248. package/dist/wallet/tx/reconcile.js +72 -0
  249. package/dist/wallet/tx/register/confirm.d.ts +6 -0
  250. package/dist/wallet/tx/register/confirm.js +66 -0
  251. package/dist/wallet/tx/register/draft.d.ts +42 -0
  252. package/dist/wallet/tx/register/draft.js +181 -0
  253. package/dist/wallet/tx/register/index.d.ts +6 -0
  254. package/dist/wallet/tx/register/index.js +158 -0
  255. package/dist/wallet/tx/register/intent.d.ts +74 -0
  256. package/dist/wallet/tx/register/intent.js +119 -0
  257. package/dist/wallet/tx/register/plan.d.ts +43 -0
  258. package/dist/wallet/tx/register/plan.js +168 -0
  259. package/dist/wallet/tx/register/result.d.ts +78 -0
  260. package/dist/wallet/tx/register/result.js +41 -0
  261. package/dist/wallet/tx/register.d.ts +1 -70
  262. package/dist/wallet/tx/register.js +1 -681
  263. package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
  264. package/dist/wallet/tx/reputation/confirm.js +51 -0
  265. package/dist/wallet/tx/reputation/draft.d.ts +20 -0
  266. package/dist/wallet/tx/reputation/draft.js +130 -0
  267. package/dist/wallet/tx/reputation/index.d.ts +4 -0
  268. package/dist/wallet/tx/reputation/index.js +162 -0
  269. package/dist/wallet/tx/reputation/intent.d.ts +36 -0
  270. package/dist/wallet/tx/reputation/intent.js +157 -0
  271. package/dist/wallet/tx/reputation/plan.d.ts +19 -0
  272. package/dist/wallet/tx/reputation/plan.js +64 -0
  273. package/dist/wallet/tx/reputation/result.d.ts +21 -0
  274. package/dist/wallet/tx/reputation/result.js +31 -0
  275. package/dist/wallet/tx/reputation/types.d.ts +130 -0
  276. package/dist/wallet/tx/reputation/types.js +1 -0
  277. package/dist/wallet/tx/reputation.d.ts +1 -74
  278. package/dist/wallet/tx/reputation.js +1 -556
  279. package/dist/wallet/tx/signing.d.ts +18 -0
  280. package/dist/wallet/tx/signing.js +31 -0
  281. package/dist/wallet/tx/state-persist.d.ts +27 -0
  282. package/dist/wallet/tx/state-persist.js +54 -0
  283. package/dist/wallet/tx/types.d.ts +44 -0
  284. package/dist/wallet/tx/types.js +1 -0
  285. package/package.json +1 -1
  286. package/dist/cli/mining-json.d.ts +0 -20
  287. package/dist/cli/mining-json.js +0 -46
  288. package/dist/cli/mutation-json.d.ts +0 -325
  289. package/dist/cli/mutation-json.js +0 -269
  290. package/dist/cli/mutation-resolved-json.d.ts +0 -117
  291. package/dist/cli/mutation-resolved-json.js +0 -123
  292. package/dist/cli/preview-json.d.ts +0 -319
  293. package/dist/cli/preview-json.js +0 -254
  294. package/dist/cli/read-json.d.ts +0 -190
  295. package/dist/cli/read-json.js +0 -627
@@ -1,729 +1 @@
1
- import { createHash, randomBytes } from "node:crypto";
2
- import { readFile } from "node:fs/promises";
3
- import { resolve as resolvePath } from "node:path";
4
- import { lookupDomain, resolveCanonical } from "@cogcoin/indexer/queries";
5
- import { attachOrStartManagedBitcoindService } from "../../bitcoind/service.js";
6
- import { createRpcClient } from "../../bitcoind/node.js";
7
- import {} from "../runtime.js";
8
- import {} from "../state/provider.js";
9
- import { serializeSetCanonical, serializeSetDelegate, serializeSetEndpoint, serializeSetMiner, validateDomainName, } from "../cogop/index.js";
10
- import { openWalletReadContext } from "../read/index.js";
11
- import { assertFixedInputPrefixMatches, assertFundingInputsAfterFixedPrefix, assertWalletMutationContextReady, buildWalletMutationTransactionWithReserveFallback, createFundingMutationSender, createWalletMutationFeeMetadata, getDecodedInputScriptPubKeyHex, isLocalWalletScript, mergeFixedWalletInputs, outpointKey, unlockTemporaryBuilderLocks, updateMutationRecord, } from "./common.js";
12
- import { confirmYesNo } from "./confirm.js";
13
- import { executeWalletMutationOperation, persistWalletMutationState, publishWalletMutation, resolveExistingWalletMutation, } from "./executor.js";
14
- import { getCanonicalIdentitySelector } from "./identity-selector.js";
15
- import { upsertPendingMutation } from "./journal.js";
16
- import { normalizeBtcTarget } from "./targets.js";
17
- function normalizeDomainName(domainName) {
18
- const normalized = domainName.trim().toLowerCase();
19
- if (normalized.length === 0) {
20
- throw new Error("wallet_domain_admin_missing_domain");
21
- }
22
- validateDomainName(normalized);
23
- return normalized;
24
- }
25
- function bytesToHex(value) {
26
- return Buffer.from(value ?? new Uint8Array()).toString("hex");
27
- }
28
- function encodeOpReturnScript(payload) {
29
- if (payload.length <= 75) {
30
- return Buffer.concat([
31
- Buffer.from([0x6a, payload.length]),
32
- Buffer.from(payload),
33
- ]).toString("hex");
34
- }
35
- return Buffer.concat([
36
- Buffer.from([0x6a, 0x4c, payload.length]),
37
- Buffer.from(payload),
38
- ]).toString("hex");
39
- }
40
- function satsToBtcNumber(value) {
41
- return Number(value) / 100_000_000;
42
- }
43
- function valueToSats(value) {
44
- const text = typeof value === "number" ? value.toFixed(8) : value;
45
- const match = /^(-?)(\d+)(?:\.(\d{0,8}))?$/.exec(text.trim());
46
- if (match == null) {
47
- throw new Error(`wallet_domain_admin_invalid_amount_${text}`);
48
- }
49
- const sign = match[1] === "-" ? -1n : 1n;
50
- const whole = BigInt(match[2] ?? "0");
51
- const fraction = BigInt((match[3] ?? "").padEnd(8, "0"));
52
- return sign * ((whole * 100000000n) + fraction);
53
- }
54
- function createResolvedDomainAdminSenderSummary(sender, selector) {
55
- return {
56
- selector,
57
- localIndex: sender.localIndex,
58
- scriptPubKeyHex: sender.scriptPubKeyHex,
59
- address: sender.address,
60
- };
61
- }
62
- function createResolvedDomainAdminTargetSummary(target) {
63
- return {
64
- scriptPubKeyHex: target.scriptPubKeyHex,
65
- address: target.address,
66
- opaque: target.opaque,
67
- };
68
- }
69
- function createIntentFingerprint(parts) {
70
- return createHash("sha256")
71
- .update(parts.map((part) => String(part)).join("\n"))
72
- .digest("hex");
73
- }
74
- function resolveAnchoredDomainOperation(context, domainName, errorPrefix, options = {}) {
75
- assertWalletMutationContextReady(context, errorPrefix);
76
- const chainDomain = lookupDomain(context.snapshot.state, domainName);
77
- if (chainDomain === null) {
78
- throw new Error(`${errorPrefix}_domain_not_found`);
79
- }
80
- if (!chainDomain.anchored) {
81
- throw new Error(`${errorPrefix}_domain_not_anchored`);
82
- }
83
- if (options.requireRoot && domainName.includes("-")) {
84
- throw new Error(`${errorPrefix}_root_domain_required`);
85
- }
86
- const ownerHex = Buffer.from(chainDomain.ownerScriptPubKey).toString("hex");
87
- if (ownerHex !== context.localState.state.funding.scriptPubKeyHex || context.model.walletAddress == null) {
88
- throw new Error(`${errorPrefix}_owner_not_locally_controlled`);
89
- }
90
- return {
91
- readContext: context,
92
- state: context.localState.state,
93
- sender: createFundingMutationSender(context.localState.state),
94
- senderSelector: context.model.walletAddress,
95
- chainDomain,
96
- };
97
- }
98
- function buildPlanForDomainAdminOperation(options) {
99
- const fundingUtxos = options.allUtxos.filter((entry) => entry.scriptPubKey === options.state.funding.scriptPubKeyHex
100
- && entry.confirmations >= 1
101
- && entry.spendable !== false
102
- && entry.safe !== false);
103
- return {
104
- sender: options.sender,
105
- changeAddress: options.state.funding.address,
106
- fixedInputs: [],
107
- outputs: [{ data: Buffer.from(options.opReturnData).toString("hex") }],
108
- changePosition: 1,
109
- expectedOpReturnScriptHex: encodeOpReturnScript(options.opReturnData),
110
- allowedFundingScriptPubKeyHex: options.state.funding.scriptPubKeyHex,
111
- eligibleFundingOutpointKeys: new Set(fundingUtxos.map((entry) => outpointKey({ txid: entry.txid, vout: entry.vout }))),
112
- errorPrefix: options.errorPrefix,
113
- };
114
- }
115
- function validateFundedDraft(decoded, funded, plan) {
116
- const inputs = decoded.tx.vin;
117
- const outputs = decoded.tx.vout;
118
- if (inputs.length === 0) {
119
- throw new Error(`${plan.errorPrefix}_missing_sender_input`);
120
- }
121
- if (outputs[0]?.scriptPubKey?.hex !== plan.expectedOpReturnScriptHex) {
122
- throw new Error(`${plan.errorPrefix}_opreturn_mismatch`);
123
- }
124
- if (funded.changepos === -1) {
125
- if (outputs.length !== 1) {
126
- throw new Error(`${plan.errorPrefix}_unexpected_output_count`);
127
- }
128
- return;
129
- }
130
- if (funded.changepos !== plan.changePosition || outputs.length !== 2) {
131
- throw new Error(`${plan.errorPrefix}_change_position_mismatch`);
132
- }
133
- if (outputs[funded.changepos]?.scriptPubKey?.hex !== plan.allowedFundingScriptPubKeyHex) {
134
- throw new Error(`${plan.errorPrefix}_change_output_mismatch`);
135
- }
136
- }
137
- async function buildTransaction(options) {
138
- return buildWalletMutationTransactionWithReserveFallback({
139
- rpc: options.rpc,
140
- walletName: options.walletName,
141
- state: options.state,
142
- plan: options.plan,
143
- validateFundedDraft,
144
- finalizeErrorCode: `${options.plan.errorPrefix}_finalize_failed`,
145
- mempoolRejectPrefix: `${options.plan.errorPrefix}_mempool_rejected`,
146
- feeRate: options.feeRateSatVb,
147
- });
148
- }
149
- function createDraftMutation(options) {
150
- if (options.existing !== null && options.existing !== undefined) {
151
- return {
152
- ...options.existing,
153
- kind: options.kind,
154
- domainName: options.domainName,
155
- senderScriptPubKeyHex: options.sender.scriptPubKeyHex,
156
- senderLocalIndex: options.sender.localIndex,
157
- recipientScriptPubKeyHex: options.recipientScriptPubKeyHex ?? null,
158
- endpointValueHex: options.endpointValueHex ?? null,
159
- status: "draft",
160
- lastUpdatedAtUnixMs: options.nowUnixMs,
161
- attemptedTxid: null,
162
- attemptedWtxid: null,
163
- ...createWalletMutationFeeMetadata(options.feeSelection),
164
- temporaryBuilderLockedOutpoints: [],
165
- };
166
- }
167
- return {
168
- mutationId: randomBytes(12).toString("hex"),
169
- kind: options.kind,
170
- domainName: options.domainName,
171
- parentDomainName: null,
172
- senderScriptPubKeyHex: options.sender.scriptPubKeyHex,
173
- senderLocalIndex: options.sender.localIndex,
174
- recipientScriptPubKeyHex: options.recipientScriptPubKeyHex ?? null,
175
- endpointValueHex: options.endpointValueHex ?? null,
176
- intentFingerprintHex: options.intentFingerprintHex,
177
- status: "draft",
178
- createdAtUnixMs: options.nowUnixMs,
179
- lastUpdatedAtUnixMs: options.nowUnixMs,
180
- attemptedTxid: null,
181
- attemptedWtxid: null,
182
- ...createWalletMutationFeeMetadata(options.feeSelection),
183
- temporaryBuilderLockedOutpoints: [],
184
- };
185
- }
186
- async function saveUpdatedMutationState(options) {
187
- return persistWalletMutationState(options);
188
- }
189
- function mutationConfirmedOnChain(mutation, context) {
190
- if (context.snapshot === null) {
191
- return false;
192
- }
193
- const chainDomain = lookupDomain(context.snapshot.state, mutation.domainName);
194
- if (chainDomain === null || !chainDomain.anchored) {
195
- return false;
196
- }
197
- const ownerHex = Buffer.from(chainDomain.ownerScriptPubKey).toString("hex");
198
- if (ownerHex !== mutation.senderScriptPubKeyHex) {
199
- return false;
200
- }
201
- if (mutation.kind === "endpoint") {
202
- return bytesToHex(chainDomain.endpoint) === (mutation.endpointValueHex ?? "");
203
- }
204
- if (mutation.kind === "delegate") {
205
- return bytesToHex(chainDomain.delegate) === (mutation.recipientScriptPubKeyHex ?? "");
206
- }
207
- if (mutation.kind === "miner") {
208
- return bytesToHex(chainDomain.miner) === (mutation.recipientScriptPubKeyHex ?? "");
209
- }
210
- if (chainDomain.domainId === null) {
211
- return false;
212
- }
213
- return resolveCanonical(context.snapshot.state, Buffer.from(mutation.senderScriptPubKeyHex, "hex")) === chainDomain.domainId;
214
- }
215
- function mutationNeedsRepair(mutation, context) {
216
- if (context.snapshot === null) {
217
- return false;
218
- }
219
- const chainDomain = lookupDomain(context.snapshot.state, mutation.domainName);
220
- if (chainDomain === null) {
221
- return false;
222
- }
223
- return !chainDomain.anchored || Buffer.from(chainDomain.ownerScriptPubKey).toString("hex") !== mutation.senderScriptPubKeyHex;
224
- }
225
- async function reconcilePendingAdminMutation(options) {
226
- if (options.mutation.status === "confirmed" || options.mutation.status === "live") {
227
- return {
228
- state: options.state,
229
- mutation: options.mutation,
230
- resolution: options.mutation.status,
231
- };
232
- }
233
- if (options.mutation.status === "repair-required") {
234
- return {
235
- state: options.state,
236
- mutation: options.mutation,
237
- resolution: "repair-required",
238
- };
239
- }
240
- if (mutationConfirmedOnChain(options.mutation, options.context)) {
241
- await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
242
- const confirmed = updateMutationRecord(options.mutation, "confirmed", options.nowUnixMs, {
243
- temporaryBuilderLockedOutpoints: [],
244
- });
245
- let nextState = upsertPendingMutation(options.state, confirmed);
246
- nextState = await saveUpdatedMutationState({
247
- state: nextState,
248
- provider: options.provider,
249
- nowUnixMs: options.nowUnixMs,
250
- paths: options.paths,
251
- });
252
- return { state: nextState, mutation: confirmed, resolution: "confirmed" };
253
- }
254
- if (mutationNeedsRepair(options.mutation, options.context)) {
255
- await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
256
- const repair = updateMutationRecord(options.mutation, "repair-required", options.nowUnixMs, {
257
- temporaryBuilderLockedOutpoints: [],
258
- });
259
- let nextState = upsertPendingMutation(options.state, repair);
260
- nextState = await saveUpdatedMutationState({
261
- state: nextState,
262
- provider: options.provider,
263
- nowUnixMs: options.nowUnixMs,
264
- paths: options.paths,
265
- });
266
- return { state: nextState, mutation: repair, resolution: "repair-required" };
267
- }
268
- const known = options.mutation.attemptedTxid === null
269
- ? false
270
- : await options.rpc.getRawTransaction(options.mutation.attemptedTxid, true).then(() => true).catch(() => false);
271
- if (known) {
272
- await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
273
- const live = updateMutationRecord(options.mutation, "live", options.nowUnixMs, {
274
- temporaryBuilderLockedOutpoints: [],
275
- });
276
- let nextState = upsertPendingMutation(options.state, live);
277
- nextState = await saveUpdatedMutationState({
278
- state: nextState,
279
- provider: options.provider,
280
- nowUnixMs: options.nowUnixMs,
281
- paths: options.paths,
282
- });
283
- return { state: nextState, mutation: live, resolution: "live" };
284
- }
285
- if (options.mutation.status === "broadcast-unknown"
286
- || options.mutation.status === "draft"
287
- || options.mutation.status === "broadcasting") {
288
- await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
289
- const canceled = updateMutationRecord(options.mutation, "canceled", options.nowUnixMs, {
290
- temporaryBuilderLockedOutpoints: [],
291
- });
292
- let nextState = upsertPendingMutation(options.state, canceled);
293
- nextState = await saveUpdatedMutationState({
294
- state: nextState,
295
- provider: options.provider,
296
- nowUnixMs: options.nowUnixMs,
297
- paths: options.paths,
298
- });
299
- return { state: nextState, mutation: canceled, resolution: "not-seen" };
300
- }
301
- return {
302
- state: options.state,
303
- mutation: options.mutation,
304
- resolution: "continue",
305
- };
306
- }
307
- async function confirmEndpointMutation(prompter, domainName, payload, options) {
308
- prompter.writeLine(`${options.clear ? "Clearing" : "Updating"} endpoint for "${domainName}".`);
309
- prompter.writeLine(`Resolved sender: ${options.sender.selector} (${options.sender.address})`);
310
- prompter.writeLine(options.clear
311
- ? "Effect: clear the endpoint payload."
312
- : `Effect: set the endpoint payload to ${payload.length} bytes.`);
313
- if (!options.clear) {
314
- prompter.writeLine(`Payload bytes: ${payload.length}`);
315
- if (options.sourceKind !== undefined) {
316
- prompter.writeLine(`Payload source: ${options.sourceKind}`);
317
- }
318
- prompter.writeLine("Warning: endpoint data is public in the mempool and on-chain.");
319
- }
320
- await confirmYesNo(prompter, options.clear
321
- ? "This publishes a standalone anchored endpoint clear."
322
- : "This publishes a standalone anchored endpoint update.", {
323
- assumeYes: options.assumeYes,
324
- errorCode: "wallet_domain_endpoint_confirmation_rejected",
325
- requiresTtyErrorCode: "wallet_domain_endpoint_requires_tty",
326
- });
327
- }
328
- async function confirmTargetMutation(prompter, options) {
329
- prompter.writeLine(`${options.target === null ? "Clearing" : "Updating"} ${options.kind} for "${options.domainName}".`);
330
- prompter.writeLine(`Resolved sender: ${options.sender.selector} (${options.sender.address})`);
331
- if (options.target === null) {
332
- prompter.writeLine(`Effect: clear the ${options.kind === "delegate" ? "delegate" : "designated miner"} target.`);
333
- await confirmYesNo(prompter, `This clears the current ${options.kind} target.`, {
334
- assumeYes: options.assumeYes,
335
- errorCode: `wallet_domain_${options.kind}_confirmation_rejected`,
336
- requiresTtyErrorCode: `wallet_domain_${options.kind}_requires_tty`,
337
- });
338
- return;
339
- }
340
- prompter.writeLine(`Resolved target: ${options.target.address ?? `spk:${options.target.scriptPubKeyHex}`}`);
341
- prompter.writeLine(`Effect: set the ${options.kind === "delegate" ? "delegate" : "designated miner"} target.`);
342
- if (options.kind === "miner" && options.target.scriptPubKeyHex === options.sender.scriptPubKeyHex) {
343
- prompter.writeLine("Warning: setting the designated miner to the current owner is usually redundant.");
344
- }
345
- await confirmYesNo(prompter, options.kind === "delegate"
346
- ? "This changes who may act for the domain as delegate."
347
- : "This changes who may mine for the domain as designated miner.", {
348
- assumeYes: options.assumeYes,
349
- errorCode: `wallet_domain_${options.kind}_confirmation_rejected`,
350
- requiresTtyErrorCode: `wallet_domain_${options.kind}_requires_tty`,
351
- });
352
- }
353
- async function confirmCanonical(prompter, domainName, sender, assumeYes = false) {
354
- prompter.writeLine(`Canonicalizing "${domainName}" as the anchored owner.`);
355
- prompter.writeLine(`Resolved sender: ${sender.selector} (${sender.address})`);
356
- prompter.writeLine("Effect: canonicalize the current anchored owner.");
357
- await confirmYesNo(prompter, "This publishes a standalone SET_CANONICAL operation.", {
358
- assumeYes,
359
- errorCode: "wallet_domain_canonical_confirmation_rejected",
360
- requiresTtyErrorCode: "wallet_domain_canonical_requires_tty",
361
- });
362
- }
363
- async function loadEndpointPayload(source) {
364
- if (source.kind === "text") {
365
- const value = source.value;
366
- if (value.length === 0) {
367
- throw new Error("wallet_domain_endpoint_payload_missing");
368
- }
369
- return new TextEncoder().encode(value);
370
- }
371
- if (source.kind === "json") {
372
- const value = source.value.trim();
373
- if (value.length === 0) {
374
- throw new Error("wallet_domain_endpoint_payload_missing");
375
- }
376
- try {
377
- JSON.parse(value);
378
- }
379
- catch {
380
- throw new Error("wallet_domain_endpoint_invalid_json");
381
- }
382
- return new TextEncoder().encode(value);
383
- }
384
- if (source.value.startsWith("hex:")) {
385
- const hex = source.value.slice(4);
386
- if (!/^[0-9a-f]+$/.test(hex) || hex.length % 2 !== 0) {
387
- throw new Error("wallet_domain_endpoint_invalid_bytes");
388
- }
389
- if (hex.length === 0) {
390
- throw new Error("wallet_domain_endpoint_payload_missing");
391
- }
392
- return Buffer.from(hex, "hex");
393
- }
394
- if (!source.value.startsWith("@")) {
395
- throw new Error("wallet_domain_endpoint_invalid_bytes");
396
- }
397
- const filePath = source.value.slice(1);
398
- if (filePath.trim() === "") {
399
- throw new Error("wallet_domain_endpoint_invalid_bytes");
400
- }
401
- const payload = await readFile(resolvePath(process.cwd(), filePath));
402
- if (payload.length === 0) {
403
- throw new Error("wallet_domain_endpoint_payload_missing");
404
- }
405
- return payload;
406
- }
407
- async function submitDomainAdminMutation(options) {
408
- const execution = await executeWalletMutationOperation({
409
- ...options,
410
- controlLockPurpose: options.errorPrefix,
411
- preemptionReason: options.errorPrefix,
412
- async resolveOperation(readContext) {
413
- const normalizedDomainName = normalizeDomainName(options.domainName);
414
- const operation = resolveAnchoredDomainOperation(readContext, normalizedDomainName, options.errorPrefix, { requireRoot: options.requireRoot });
415
- return {
416
- ...operation,
417
- normalizedDomainName,
418
- resolvedSender: createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector),
419
- payload: await options.createPayload(operation),
420
- };
421
- },
422
- createIntentFingerprint(operation) {
423
- return createIntentFingerprint([
424
- options.kind,
425
- operation.state.walletRootId,
426
- ...options.intentParts(operation),
427
- ]);
428
- },
429
- async resolveExistingMutation({ operation, existingMutation, execution }) {
430
- if (existingMutation === null) {
431
- return {
432
- state: operation.state,
433
- replacementFixedInputs: null,
434
- result: null,
435
- };
436
- }
437
- return resolveExistingWalletMutation({
438
- existingMutation,
439
- execution,
440
- repairRequiredErrorCode: `${options.errorPrefix}_repair_required`,
441
- reconcileExistingMutation: (mutation) => reconcilePendingAdminMutation({
442
- state: operation.state,
443
- mutation,
444
- provider: execution.provider,
445
- nowUnixMs: execution.nowUnixMs,
446
- paths: execution.paths,
447
- rpc: execution.rpc,
448
- walletName: execution.walletName,
449
- context: execution.readContext,
450
- }),
451
- createReuseResult: ({ mutation, resolution, fees }) => ({
452
- kind: options.kind,
453
- domainName: operation.normalizedDomainName,
454
- txid: mutation.attemptedTxid ?? "unknown",
455
- status: resolution,
456
- reusedExisting: true,
457
- recipientScriptPubKeyHex: operation.payload.recipientScriptPubKeyHex ?? null,
458
- endpointValueHex: operation.payload.endpointValueHex ?? null,
459
- resolved: {
460
- sender: operation.resolvedSender,
461
- target: operation.payload.resolvedTarget,
462
- effect: operation.payload.resolvedEffect,
463
- },
464
- fees,
465
- }),
466
- });
467
- },
468
- confirm({ operation }) {
469
- return options.confirm(operation);
470
- },
471
- createDraftMutation({ operation, existingMutation, execution, intentFingerprintHex }) {
472
- return {
473
- mutation: createDraftMutation({
474
- kind: options.kind,
475
- domainName: operation.normalizedDomainName,
476
- sender: operation.sender,
477
- intentFingerprintHex,
478
- nowUnixMs: execution.nowUnixMs,
479
- feeSelection: execution.feeSelection,
480
- recipientScriptPubKeyHex: operation.payload.recipientScriptPubKeyHex ?? null,
481
- endpointValueHex: operation.payload.endpointValueHex ?? null,
482
- existing: existingMutation,
483
- }),
484
- prepared: null,
485
- };
486
- },
487
- async build({ operation, state, execution, replacementFixedInputs }) {
488
- const adminPlan = buildPlanForDomainAdminOperation({
489
- state,
490
- allUtxos: await execution.rpc.listUnspent(execution.walletName, 1),
491
- sender: operation.sender,
492
- opReturnData: operation.payload.opReturnData,
493
- errorPrefix: options.errorPrefix,
494
- });
495
- return buildTransaction({
496
- rpc: execution.rpc,
497
- walletName: execution.walletName,
498
- state,
499
- plan: {
500
- ...adminPlan,
501
- fixedInputs: mergeFixedWalletInputs(adminPlan.fixedInputs, replacementFixedInputs),
502
- },
503
- feeRateSatVb: execution.feeSelection.feeRateSatVb,
504
- });
505
- },
506
- publish({ state, execution, built, mutation }) {
507
- return publishWalletMutation({
508
- rpc: execution.rpc,
509
- walletName: execution.walletName,
510
- snapshotHeight: execution.readContext.snapshot?.tip?.height ?? null,
511
- built,
512
- mutation,
513
- state,
514
- provider: execution.provider,
515
- nowUnixMs: execution.nowUnixMs,
516
- paths: execution.paths,
517
- errorPrefix: options.errorPrefix,
518
- });
519
- },
520
- createResult({ operation, mutation, built, status, reusedExisting, fees }) {
521
- return {
522
- kind: options.kind,
523
- domainName: operation.normalizedDomainName,
524
- txid: mutation.attemptedTxid ?? built?.txid ?? "unknown",
525
- status: status,
526
- reusedExisting,
527
- recipientScriptPubKeyHex: operation.payload.recipientScriptPubKeyHex ?? null,
528
- endpointValueHex: operation.payload.endpointValueHex ?? null,
529
- resolved: {
530
- sender: operation.resolvedSender,
531
- target: operation.payload.resolvedTarget,
532
- effect: operation.payload.resolvedEffect,
533
- },
534
- fees,
535
- };
536
- },
537
- });
538
- return execution.result;
539
- }
540
- export async function setDomainEndpoint(options) {
541
- const payloadBytes = await loadEndpointPayload(options.source);
542
- return submitDomainAdminMutation({
543
- ...options,
544
- kind: "endpoint",
545
- errorPrefix: "wallet_domain_endpoint",
546
- intentParts(operation) {
547
- return [operation.chainDomain.name, Buffer.from(payloadBytes).toString("hex")];
548
- },
549
- async createPayload(operation) {
550
- return {
551
- opReturnData: serializeSetEndpoint(operation.chainDomain.domainId, payloadBytes).opReturnData,
552
- endpointValueHex: Buffer.from(payloadBytes).toString("hex"),
553
- resolvedTarget: null,
554
- resolvedEffect: {
555
- kind: "endpoint-set",
556
- byteLength: payloadBytes.length,
557
- },
558
- };
559
- },
560
- async confirm(operation) {
561
- await confirmEndpointMutation(options.prompter, operation.chainDomain.name, payloadBytes, {
562
- clear: false,
563
- sender: createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector),
564
- sourceKind: options.source.kind,
565
- assumeYes: options.assumeYes,
566
- });
567
- },
568
- });
569
- }
570
- export async function clearDomainEndpoint(options) {
571
- return submitDomainAdminMutation({
572
- ...options,
573
- kind: "endpoint",
574
- errorPrefix: "wallet_domain_endpoint",
575
- intentParts(operation) {
576
- return [operation.chainDomain.name, "clear"];
577
- },
578
- async createPayload(operation) {
579
- return {
580
- opReturnData: serializeSetEndpoint(operation.chainDomain.domainId).opReturnData,
581
- endpointValueHex: "",
582
- resolvedTarget: null,
583
- resolvedEffect: { kind: "endpoint-clear" },
584
- };
585
- },
586
- async confirm(operation) {
587
- await confirmEndpointMutation(options.prompter, operation.chainDomain.name, new Uint8Array(), {
588
- clear: true,
589
- sender: createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector),
590
- assumeYes: options.assumeYes,
591
- });
592
- },
593
- });
594
- }
595
- export async function setDomainDelegate(options) {
596
- const target = normalizeBtcTarget(options.target);
597
- return submitDomainAdminMutation({
598
- ...options,
599
- kind: "delegate",
600
- errorPrefix: "wallet_domain_delegate",
601
- intentParts(operation) {
602
- return [operation.chainDomain.name, target.scriptPubKeyHex];
603
- },
604
- async createPayload(operation) {
605
- if (target.scriptPubKeyHex === operation.sender.scriptPubKeyHex) {
606
- throw new Error("wallet_domain_delegate_self_target");
607
- }
608
- return {
609
- opReturnData: serializeSetDelegate(operation.chainDomain.domainId, Buffer.from(target.scriptPubKeyHex, "hex")).opReturnData,
610
- recipientScriptPubKeyHex: target.scriptPubKeyHex,
611
- resolvedTarget: createResolvedDomainAdminTargetSummary(target),
612
- resolvedEffect: { kind: "delegate-set" },
613
- };
614
- },
615
- async confirm(operation) {
616
- await confirmTargetMutation(options.prompter, {
617
- kind: "delegate",
618
- domainName: operation.chainDomain.name,
619
- target,
620
- sender: createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector),
621
- assumeYes: options.assumeYes,
622
- });
623
- },
624
- });
625
- }
626
- export async function clearDomainDelegate(options) {
627
- return submitDomainAdminMutation({
628
- ...options,
629
- kind: "delegate",
630
- errorPrefix: "wallet_domain_delegate",
631
- intentParts(operation) {
632
- return [operation.chainDomain.name, "clear"];
633
- },
634
- async createPayload(operation) {
635
- return {
636
- opReturnData: serializeSetDelegate(operation.chainDomain.domainId).opReturnData,
637
- recipientScriptPubKeyHex: null,
638
- resolvedTarget: null,
639
- resolvedEffect: { kind: "delegate-clear" },
640
- };
641
- },
642
- async confirm(operation) {
643
- await confirmTargetMutation(options.prompter, {
644
- kind: "delegate",
645
- domainName: operation.chainDomain.name,
646
- target: null,
647
- sender: createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector),
648
- assumeYes: options.assumeYes,
649
- });
650
- },
651
- });
652
- }
653
- export async function setDomainMiner(options) {
654
- const target = normalizeBtcTarget(options.target);
655
- return submitDomainAdminMutation({
656
- ...options,
657
- kind: "miner",
658
- errorPrefix: "wallet_domain_miner",
659
- requireRoot: true,
660
- intentParts(operation) {
661
- return [operation.chainDomain.name, target.scriptPubKeyHex];
662
- },
663
- async createPayload(operation) {
664
- return {
665
- opReturnData: serializeSetMiner(operation.chainDomain.domainId, Buffer.from(target.scriptPubKeyHex, "hex")).opReturnData,
666
- recipientScriptPubKeyHex: target.scriptPubKeyHex,
667
- resolvedTarget: createResolvedDomainAdminTargetSummary(target),
668
- resolvedEffect: { kind: "miner-set" },
669
- };
670
- },
671
- async confirm(operation) {
672
- await confirmTargetMutation(options.prompter, {
673
- kind: "miner",
674
- domainName: operation.chainDomain.name,
675
- target,
676
- sender: createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector),
677
- assumeYes: options.assumeYes,
678
- });
679
- },
680
- });
681
- }
682
- export async function clearDomainMiner(options) {
683
- return submitDomainAdminMutation({
684
- ...options,
685
- kind: "miner",
686
- errorPrefix: "wallet_domain_miner",
687
- requireRoot: true,
688
- intentParts(operation) {
689
- return [operation.chainDomain.name, "clear"];
690
- },
691
- async createPayload(operation) {
692
- return {
693
- opReturnData: serializeSetMiner(operation.chainDomain.domainId).opReturnData,
694
- recipientScriptPubKeyHex: null,
695
- resolvedTarget: null,
696
- resolvedEffect: { kind: "miner-clear" },
697
- };
698
- },
699
- async confirm(operation) {
700
- await confirmTargetMutation(options.prompter, {
701
- kind: "miner",
702
- domainName: operation.chainDomain.name,
703
- target: null,
704
- sender: createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector),
705
- assumeYes: options.assumeYes,
706
- });
707
- },
708
- });
709
- }
710
- export async function setDomainCanonical(options) {
711
- return submitDomainAdminMutation({
712
- ...options,
713
- kind: "canonical",
714
- errorPrefix: "wallet_domain_canonical",
715
- intentParts(operation) {
716
- return [operation.chainDomain.name, operation.sender.scriptPubKeyHex];
717
- },
718
- async createPayload(operation) {
719
- return {
720
- opReturnData: serializeSetCanonical(operation.chainDomain.domainId).opReturnData,
721
- resolvedTarget: null,
722
- resolvedEffect: { kind: "canonicalize-owner" },
723
- };
724
- },
725
- async confirm(operation) {
726
- await confirmCanonical(options.prompter, operation.chainDomain.name, createResolvedDomainAdminSenderSummary(operation.sender, operation.senderSelector), options.assumeYes);
727
- },
728
- });
729
- }
1
+ export * from "./domain-admin/index.js";