@cogcoin/client 1.1.8 → 1.1.9

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 (266) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/commands/mining-read.js +1 -1
  3. package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
  4. package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
  5. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
  6. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
  7. package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
  8. package/dist/cli/commands/wallet-mutation/cog.js +131 -0
  9. package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
  10. package/dist/cli/commands/wallet-mutation/context.js +18 -0
  11. package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
  12. package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
  13. package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
  14. package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
  15. package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
  16. package/dist/cli/commands/wallet-mutation/field.js +125 -0
  17. package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
  18. package/dist/cli/commands/wallet-mutation/register.js +38 -0
  19. package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
  20. package/dist/cli/commands/wallet-mutation/registry.js +39 -0
  21. package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
  22. package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
  23. package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
  24. package/dist/cli/commands/wallet-mutation/types.js +1 -0
  25. package/dist/cli/commands/wallet-mutation.js +13 -765
  26. package/dist/cli/commands/wallet-read.js +4 -4
  27. package/dist/cli/mutation-success.d.ts +0 -2
  28. package/dist/cli/output/classify.d.ts +7 -0
  29. package/dist/cli/output/classify.js +94 -0
  30. package/dist/cli/output/render.d.ts +2 -0
  31. package/dist/cli/output/render.js +13 -0
  32. package/dist/cli/output/rules/cli-surface.d.ts +2 -0
  33. package/dist/cli/output/rules/cli-surface.js +110 -0
  34. package/dist/cli/output/rules/generic.d.ts +2 -0
  35. package/dist/cli/output/rules/generic.js +13 -0
  36. package/dist/cli/output/rules/index.d.ts +2 -0
  37. package/dist/cli/output/rules/index.js +24 -0
  38. package/dist/cli/output/rules/mining-update.d.ts +2 -0
  39. package/dist/cli/output/rules/mining-update.js +68 -0
  40. package/dist/cli/output/rules/services.d.ts +2 -0
  41. package/dist/cli/output/rules/services.js +110 -0
  42. package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
  43. package/dist/cli/output/rules/wallet-admin.js +224 -0
  44. package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
  45. package/dist/cli/output/rules/wallet-mutations.js +274 -0
  46. package/dist/cli/output/types.d.ts +16 -0
  47. package/dist/cli/output/types.js +1 -0
  48. package/dist/cli/output.d.ts +2 -168
  49. package/dist/cli/output.js +6 -989
  50. package/dist/cli/pagination.d.ts +15 -0
  51. package/dist/cli/pagination.js +16 -0
  52. package/dist/cli/recommendations.d.ts +4 -0
  53. package/dist/cli/recommendations.js +108 -0
  54. package/dist/cli/wallet-format/availability.d.ts +5 -0
  55. package/dist/cli/wallet-format/availability.js +96 -0
  56. package/dist/cli/wallet-format/balance.d.ts +2 -0
  57. package/dist/cli/wallet-format/balance.js +162 -0
  58. package/dist/cli/wallet-format/domains.d.ts +8 -0
  59. package/dist/cli/wallet-format/domains.js +84 -0
  60. package/dist/cli/wallet-format/fields.d.ts +6 -0
  61. package/dist/cli/wallet-format/fields.js +61 -0
  62. package/dist/cli/wallet-format/identity.d.ts +5 -0
  63. package/dist/cli/wallet-format/identity.js +19 -0
  64. package/dist/cli/wallet-format/locks.d.ts +7 -0
  65. package/dist/cli/wallet-format/locks.js +52 -0
  66. package/dist/cli/wallet-format/overview.d.ts +2 -0
  67. package/dist/cli/wallet-format/overview.js +122 -0
  68. package/dist/cli/wallet-format/pending.d.ts +13 -0
  69. package/dist/cli/wallet-format/pending.js +101 -0
  70. package/dist/cli/wallet-format/shared.d.ts +7 -0
  71. package/dist/cli/wallet-format/shared.js +31 -0
  72. package/dist/cli/wallet-format/status.d.ts +3 -0
  73. package/dist/cli/wallet-format/status.js +27 -0
  74. package/dist/cli/wallet-format.d.ts +8 -30
  75. package/dist/cli/wallet-format.js +8 -830
  76. package/dist/cli/wallet-read-helpers.d.ts +6 -0
  77. package/dist/cli/wallet-read-helpers.js +17 -0
  78. package/dist/wallet/mining/candidate.d.ts +1 -1
  79. package/dist/wallet/mining/candidate.js +3 -3
  80. package/dist/wallet/mining/constants.d.ts +2 -2
  81. package/dist/wallet/mining/constants.js +2 -2
  82. package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
  83. package/dist/wallet/mining/sentences.js +8 -8
  84. package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
  85. package/dist/wallet/tx/anchor/confirm.js +60 -0
  86. package/dist/wallet/tx/anchor/draft.d.ts +39 -0
  87. package/dist/wallet/tx/anchor/draft.js +167 -0
  88. package/dist/wallet/tx/anchor/index.d.ts +5 -0
  89. package/dist/wallet/tx/anchor/index.js +148 -0
  90. package/dist/wallet/tx/anchor/intent.d.ts +61 -0
  91. package/dist/wallet/tx/anchor/intent.js +101 -0
  92. package/dist/wallet/tx/anchor/plan.d.ts +3 -0
  93. package/dist/wallet/tx/anchor/plan.js +18 -0
  94. package/dist/wallet/tx/anchor/result.d.ts +25 -0
  95. package/dist/wallet/tx/anchor/result.js +20 -0
  96. package/dist/wallet/tx/anchor.d.ts +1 -39
  97. package/dist/wallet/tx/anchor.js +1 -494
  98. package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
  99. package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
  100. package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
  101. package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
  102. package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
  103. package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
  104. package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
  105. package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
  106. package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
  107. package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
  108. package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
  109. package/dist/wallet/tx/bitcoin-transfer.js +1 -200
  110. package/dist/wallet/tx/cog/confirm.d.ts +13 -0
  111. package/dist/wallet/tx/cog/confirm.js +59 -0
  112. package/dist/wallet/tx/cog/draft.d.ts +20 -0
  113. package/dist/wallet/tx/cog/draft.js +114 -0
  114. package/dist/wallet/tx/cog/index.d.ts +6 -0
  115. package/dist/wallet/tx/cog/index.js +117 -0
  116. package/dist/wallet/tx/cog/intent.d.ts +30 -0
  117. package/dist/wallet/tx/cog/intent.js +169 -0
  118. package/dist/wallet/tx/cog/plan.d.ts +19 -0
  119. package/dist/wallet/tx/cog/plan.js +65 -0
  120. package/dist/wallet/tx/cog/result.d.ts +27 -0
  121. package/dist/wallet/tx/cog/result.js +28 -0
  122. package/dist/wallet/tx/cog/types.d.ts +186 -0
  123. package/dist/wallet/tx/cog/types.js +2 -0
  124. package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
  125. package/dist/wallet/tx/cog/variants/claim.js +92 -0
  126. package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
  127. package/dist/wallet/tx/cog/variants/lock.js +102 -0
  128. package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
  129. package/dist/wallet/tx/cog/variants/send.js +77 -0
  130. package/dist/wallet/tx/cog.d.ts +1 -96
  131. package/dist/wallet/tx/cog.js +1 -824
  132. package/dist/wallet/tx/common.d.ts +14 -199
  133. package/dist/wallet/tx/common.js +10 -493
  134. package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
  135. package/dist/wallet/tx/domain-admin/confirm.js +58 -0
  136. package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
  137. package/dist/wallet/tx/domain-admin/draft.js +161 -0
  138. package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
  139. package/dist/wallet/tx/domain-admin/index.js +150 -0
  140. package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
  141. package/dist/wallet/tx/domain-admin/intent.js +61 -0
  142. package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
  143. package/dist/wallet/tx/domain-admin/plan.js +64 -0
  144. package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
  145. package/dist/wallet/tx/domain-admin/result.js +33 -0
  146. package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
  147. package/dist/wallet/tx/domain-admin/types.js +1 -0
  148. package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
  149. package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
  150. package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
  151. package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
  152. package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
  153. package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
  154. package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
  155. package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
  156. package/dist/wallet/tx/domain-admin.d.ts +1 -107
  157. package/dist/wallet/tx/domain-admin.js +1 -729
  158. package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
  159. package/dist/wallet/tx/domain-market/confirm.js +52 -0
  160. package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
  161. package/dist/wallet/tx/domain-market/draft.js +286 -0
  162. package/dist/wallet/tx/domain-market/index.d.ts +6 -0
  163. package/dist/wallet/tx/domain-market/index.js +145 -0
  164. package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
  165. package/dist/wallet/tx/domain-market/intent.js +131 -0
  166. package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
  167. package/dist/wallet/tx/domain-market/plan.js +98 -0
  168. package/dist/wallet/tx/domain-market/result.d.ts +45 -0
  169. package/dist/wallet/tx/domain-market/result.js +88 -0
  170. package/dist/wallet/tx/domain-market/types.d.ts +221 -0
  171. package/dist/wallet/tx/domain-market/types.js +1 -0
  172. package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
  173. package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
  174. package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
  175. package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
  176. package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
  177. package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
  178. package/dist/wallet/tx/domain-market.d.ts +1 -116
  179. package/dist/wallet/tx/domain-market.js +1 -1078
  180. package/dist/wallet/tx/draft-build.d.ts +60 -0
  181. package/dist/wallet/tx/draft-build.js +127 -0
  182. package/dist/wallet/tx/executor.d.ts +6 -40
  183. package/dist/wallet/tx/executor.js +6 -100
  184. package/dist/wallet/tx/fee.d.ts +30 -0
  185. package/dist/wallet/tx/fee.js +98 -0
  186. package/dist/wallet/tx/field/confirm.d.ts +11 -0
  187. package/dist/wallet/tx/field/confirm.js +19 -0
  188. package/dist/wallet/tx/field/draft.d.ts +23 -0
  189. package/dist/wallet/tx/field/draft.js +202 -0
  190. package/dist/wallet/tx/field/index.d.ts +5 -0
  191. package/dist/wallet/tx/field/index.js +140 -0
  192. package/dist/wallet/tx/field/intent.d.ts +5 -0
  193. package/dist/wallet/tx/field/intent.js +50 -0
  194. package/dist/wallet/tx/field/plan.d.ts +20 -0
  195. package/dist/wallet/tx/field/plan.js +65 -0
  196. package/dist/wallet/tx/field/result.d.ts +29 -0
  197. package/dist/wallet/tx/field/result.js +103 -0
  198. package/dist/wallet/tx/field/types.d.ts +163 -0
  199. package/dist/wallet/tx/field/types.js +1 -0
  200. package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
  201. package/dist/wallet/tx/field/variants/clear.js +60 -0
  202. package/dist/wallet/tx/field/variants/create.d.ts +2 -0
  203. package/dist/wallet/tx/field/variants/create.js +67 -0
  204. package/dist/wallet/tx/field/variants/set.d.ts +2 -0
  205. package/dist/wallet/tx/field/variants/set.js +195 -0
  206. package/dist/wallet/tx/field.d.ts +1 -95
  207. package/dist/wallet/tx/field.js +1 -920
  208. package/dist/wallet/tx/mining-preemption.d.ts +6 -0
  209. package/dist/wallet/tx/mining-preemption.js +7 -0
  210. package/dist/wallet/tx/primitives.d.ts +13 -0
  211. package/dist/wallet/tx/primitives.js +42 -0
  212. package/dist/wallet/tx/psbt-assert.d.ts +14 -0
  213. package/dist/wallet/tx/psbt-assert.js +39 -0
  214. package/dist/wallet/tx/publish.d.ts +37 -0
  215. package/dist/wallet/tx/publish.js +88 -0
  216. package/dist/wallet/tx/readiness.d.ts +7 -0
  217. package/dist/wallet/tx/readiness.js +61 -0
  218. package/dist/wallet/tx/reconcile.d.ts +24 -0
  219. package/dist/wallet/tx/reconcile.js +72 -0
  220. package/dist/wallet/tx/register/confirm.d.ts +6 -0
  221. package/dist/wallet/tx/register/confirm.js +66 -0
  222. package/dist/wallet/tx/register/draft.d.ts +42 -0
  223. package/dist/wallet/tx/register/draft.js +181 -0
  224. package/dist/wallet/tx/register/index.d.ts +6 -0
  225. package/dist/wallet/tx/register/index.js +158 -0
  226. package/dist/wallet/tx/register/intent.d.ts +74 -0
  227. package/dist/wallet/tx/register/intent.js +119 -0
  228. package/dist/wallet/tx/register/plan.d.ts +43 -0
  229. package/dist/wallet/tx/register/plan.js +168 -0
  230. package/dist/wallet/tx/register/result.d.ts +78 -0
  231. package/dist/wallet/tx/register/result.js +41 -0
  232. package/dist/wallet/tx/register.d.ts +1 -70
  233. package/dist/wallet/tx/register.js +1 -681
  234. package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
  235. package/dist/wallet/tx/reputation/confirm.js +51 -0
  236. package/dist/wallet/tx/reputation/draft.d.ts +20 -0
  237. package/dist/wallet/tx/reputation/draft.js +130 -0
  238. package/dist/wallet/tx/reputation/index.d.ts +4 -0
  239. package/dist/wallet/tx/reputation/index.js +162 -0
  240. package/dist/wallet/tx/reputation/intent.d.ts +36 -0
  241. package/dist/wallet/tx/reputation/intent.js +157 -0
  242. package/dist/wallet/tx/reputation/plan.d.ts +19 -0
  243. package/dist/wallet/tx/reputation/plan.js +64 -0
  244. package/dist/wallet/tx/reputation/result.d.ts +21 -0
  245. package/dist/wallet/tx/reputation/result.js +31 -0
  246. package/dist/wallet/tx/reputation/types.d.ts +130 -0
  247. package/dist/wallet/tx/reputation/types.js +1 -0
  248. package/dist/wallet/tx/reputation.d.ts +1 -74
  249. package/dist/wallet/tx/reputation.js +1 -556
  250. package/dist/wallet/tx/signing.d.ts +18 -0
  251. package/dist/wallet/tx/signing.js +31 -0
  252. package/dist/wallet/tx/state-persist.d.ts +27 -0
  253. package/dist/wallet/tx/state-persist.js +54 -0
  254. package/dist/wallet/tx/types.d.ts +44 -0
  255. package/dist/wallet/tx/types.js +1 -0
  256. package/package.json +1 -1
  257. package/dist/cli/mining-json.d.ts +0 -20
  258. package/dist/cli/mining-json.js +0 -46
  259. package/dist/cli/mutation-json.d.ts +0 -325
  260. package/dist/cli/mutation-json.js +0 -269
  261. package/dist/cli/mutation-resolved-json.d.ts +0 -117
  262. package/dist/cli/mutation-resolved-json.js +0 -123
  263. package/dist/cli/preview-json.d.ts +0 -319
  264. package/dist/cli/preview-json.js +0 -254
  265. package/dist/cli/read-json.d.ts +0 -190
  266. package/dist/cli/read-json.js +0 -627
@@ -1,681 +1 @@
1
- import { createHash, randomBytes } from "node:crypto";
2
- import { loadBundledGenesisParameters } from "@cogcoin/indexer";
3
- import { getBalance, getParent, lookupDomain } from "@cogcoin/indexer/queries";
4
- import { attachOrStartManagedBitcoindService } from "../../bitcoind/service.js";
5
- import { createRpcClient } from "../../bitcoind/node.js";
6
- import {} from "../runtime.js";
7
- import {} from "../state/provider.js";
8
- import { computeRootRegistrationPriceSats, serializeDomainReg } from "../cogop/index.js";
9
- import { openWalletReadContext } from "../read/index.js";
10
- import { assertFixedInputPrefixMatches, assertFundingInputsAfterFixedPrefix, assertWalletMutationContextReady, buildWalletMutationTransactionWithReserveFallback, createFundingMutationSender, createWalletMutationFeeMetadata, formatCogAmount, getDecodedInputScriptPubKeyHex, isLocalWalletScript, mergeFixedWalletInputs, outpointKey, saveWalletStatePreservingUnlock, unlockTemporaryBuilderLocks, updateMutationRecord, } from "./common.js";
11
- import { confirmTypedAcknowledgement, confirmYesNo } from "./confirm.js";
12
- import { executeWalletMutationOperation, publishWalletMutation, resolveExistingWalletMutation, } from "./executor.js";
13
- import { getCanonicalIdentitySelector, resolveIdentityBySelector, } from "./identity-selector.js";
14
- import { upsertPendingMutation } from "./journal.js";
15
- const SUBDOMAIN_REGISTRATION_FEE_COGTOSHI = 100n;
16
- function normalizeDomainName(domainName) {
17
- const normalized = domainName.trim().toLowerCase();
18
- if (normalized.length === 0) {
19
- throw new Error("wallet_register_missing_domain");
20
- }
21
- serializeDomainReg(normalized);
22
- return normalized;
23
- }
24
- function satsToBtcNumber(value) {
25
- return Number(value) / 100_000_000;
26
- }
27
- function valueToSats(value) {
28
- const text = typeof value === "number" ? value.toFixed(8) : value;
29
- const match = /^(-?)(\d+)(?:\.(\d{0,8}))?$/.exec(text.trim());
30
- if (match == null) {
31
- throw new Error(`wallet_register_invalid_amount_${text}`);
32
- }
33
- const sign = match[1] === "-" ? -1n : 1n;
34
- const whole = BigInt(match[2] ?? "0");
35
- const fraction = BigInt((match[3] ?? "").padEnd(8, "0"));
36
- return sign * ((whole * 100000000n) + fraction);
37
- }
38
- function createRegisterIntentFingerprint(options) {
39
- return createHash("sha256")
40
- .update([
41
- "register",
42
- options.walletRootId,
43
- options.domainName,
44
- options.registerKind,
45
- options.senderScriptPubKeyHex,
46
- ].join("\n"))
47
- .digest("hex");
48
- }
49
- function encodeOpReturnScript(payload) {
50
- if (payload.length <= 75) {
51
- return Buffer.concat([
52
- Buffer.from([0x6a, payload.length]),
53
- Buffer.from(payload),
54
- ]).toString("hex");
55
- }
56
- return Buffer.concat([
57
- Buffer.from([0x6a, 0x4c, payload.length]),
58
- Buffer.from(payload),
59
- ]).toString("hex");
60
- }
61
- export function extractOpReturnPayloadFromScriptHex(scriptHex) {
62
- const bytes = Buffer.from(scriptHex, "hex");
63
- if (bytes.length < 2 || bytes[0] !== 0x6a) {
64
- return null;
65
- }
66
- const opcode = bytes[1];
67
- if (opcode <= 75) {
68
- const end = 2 + opcode;
69
- return end === bytes.length ? bytes.subarray(2, end) : null;
70
- }
71
- if (opcode === 0x4c && bytes.length >= 3) {
72
- const length = bytes[2];
73
- const end = 3 + length;
74
- return end === bytes.length ? bytes.subarray(3, end) : null;
75
- }
76
- return null;
77
- }
78
- function isSpendableConfirmedUtxo(entry) {
79
- return entry.confirmations >= 1
80
- && entry.spendable !== false
81
- && entry.safe !== false;
82
- }
83
- function sortUtxos(entries) {
84
- return entries
85
- .slice()
86
- .sort((left, right) => right.amount - left.amount
87
- || left.txid.localeCompare(right.txid)
88
- || left.vout - right.vout);
89
- }
90
- function listFundingUtxos(entries, fundingScriptPubKeyHex) {
91
- return sortUtxos(entries.filter((entry) => isSpendableConfirmedUtxo(entry) && entry.scriptPubKey === fundingScriptPubKeyHex));
92
- }
93
- function buildRootRegisterOutputs(options) {
94
- const payload = serializeDomainReg(options.domainName).opReturnData;
95
- const outputs = [
96
- { data: Buffer.from(payload).toString("hex") },
97
- { [options.treasuryAddress]: satsToBtcNumber(options.priceSats) },
98
- ];
99
- return {
100
- outputs,
101
- changePosition: outputs.length,
102
- expectedOpReturnScriptHex: encodeOpReturnScript(payload),
103
- };
104
- }
105
- function buildSubdomainRegisterOutputs(options) {
106
- const payload = serializeDomainReg(options.domainName).opReturnData;
107
- return {
108
- outputs: [{ data: Buffer.from(payload).toString("hex") }],
109
- changePosition: 1,
110
- expectedOpReturnScriptHex: encodeOpReturnScript(payload),
111
- };
112
- }
113
- async function findCompetingRootRegistrationTxids(rpc, domainName) {
114
- const targetPayloadHex = Buffer.from(serializeDomainReg(domainName).opReturnData).toString("hex");
115
- const txids = await rpc.getRawMempool();
116
- const competitors = [];
117
- for (const txid of txids) {
118
- const transaction = await rpc.getRawTransaction(txid, true).catch(() => null);
119
- if (transaction === null) {
120
- continue;
121
- }
122
- const matches = transaction.vout.some((output) => {
123
- const scriptHex = output.scriptPubKey?.hex;
124
- if (scriptHex == null) {
125
- return false;
126
- }
127
- const payload = extractOpReturnPayloadFromScriptHex(scriptHex);
128
- return payload !== null && Buffer.from(payload).toString("hex") === targetPayloadHex;
129
- });
130
- if (matches) {
131
- competitors.push(txid);
132
- }
133
- }
134
- return competitors;
135
- }
136
- async function confirmRootRegistration(prompter, domainName, resolved, competitorVisible, assumeYes = false) {
137
- writeRegisterResolvedSummary(prompter, resolved);
138
- prompter.writeLine(competitorVisible
139
- ? `This is a root-domain race for "${domainName}".`
140
- : `You are registering the root domain "${domainName}".`);
141
- prompter.writeLine("Root domains contain no hyphen. Hyphenated names are subdomains and must not use this flow.");
142
- prompter.writeLine("If another valid registration confirms first, you may still pay BTC and receive no domain.");
143
- await confirmTypedAcknowledgement(prompter, {
144
- assumeYes,
145
- expected: domainName,
146
- prompt: "Type the domain name to continue: ",
147
- errorCode: "wallet_register_confirmation_rejected",
148
- requiresTtyErrorCode: "wallet_register_requires_tty",
149
- typedAckRequiredErrorCode: "wallet_register_typed_ack_required",
150
- });
151
- }
152
- async function confirmSubdomainRegistration(prompter, domainName, resolved, assumeYes = false) {
153
- writeRegisterResolvedSummary(prompter, resolved);
154
- prompter.writeLine(`You are registering the subdomain "${domainName}".`);
155
- await confirmYesNo(prompter, "This publishes a subdomain registration burn.", {
156
- assumeYes,
157
- errorCode: "wallet_register_confirmation_rejected",
158
- requiresTtyErrorCode: "wallet_register_requires_tty",
159
- });
160
- }
161
- function createRegisterResolvedSummary(options) {
162
- return {
163
- path: options.registerKind,
164
- parentDomainName: options.parentDomainName,
165
- sender: {
166
- selector: options.senderSelector,
167
- localIndex: options.sender.localIndex,
168
- scriptPubKeyHex: options.sender.scriptPubKeyHex,
169
- address: options.sender.address,
170
- },
171
- economicEffect: {
172
- kind: options.economicEffectKind,
173
- amount: options.economicEffectAmount,
174
- },
175
- };
176
- }
177
- function describeRegisterEconomicEffect(summary) {
178
- if (summary.economicEffect.kind === "treasury-payment") {
179
- return `send ${summary.economicEffect.amount.toString()} sats to the Cogcoin treasury.`;
180
- }
181
- return `burn ${formatCogAmount(summary.economicEffect.amount)} from the parent owner.`;
182
- }
183
- function writeRegisterResolvedSummary(prompter, summary) {
184
- prompter.writeLine(`Resolved path: ${summary.path} registration.`);
185
- if (summary.parentDomainName !== null) {
186
- prompter.writeLine(`Resolved parent: ${summary.parentDomainName}.`);
187
- }
188
- prompter.writeLine(`Resolved sender: ${summary.sender.selector} (${summary.sender.address})`);
189
- prompter.writeLine(`Economic effect: ${describeRegisterEconomicEffect(summary)}`);
190
- }
191
- function reserveLocalDomainRecord(options) {
192
- const existing = options.state.domains.find((domain) => domain.name === options.domainName) ?? null;
193
- const domains = options.state.domains.some((domain) => domain.name === options.domainName)
194
- ? options.state.domains.map((domain) => {
195
- if (domain.name !== options.domainName) {
196
- return domain;
197
- }
198
- return {
199
- ...domain,
200
- currentOwnerScriptPubKeyHex: options.sender.scriptPubKeyHex,
201
- birthTime: domain.birthTime ?? Math.floor(options.nowUnixMs / 1000),
202
- };
203
- })
204
- : [
205
- ...options.state.domains,
206
- {
207
- name: options.domainName,
208
- domainId: null,
209
- currentOwnerScriptPubKeyHex: options.sender.scriptPubKeyHex,
210
- canonicalChainStatus: "unknown",
211
- foundingMessageText: existing?.foundingMessageText ?? null,
212
- birthTime: Math.floor(options.nowUnixMs / 1000),
213
- },
214
- ];
215
- return {
216
- ...options.state,
217
- domains,
218
- };
219
- }
220
- function getMutationStatusAfterAcceptance(options) {
221
- const chainRecord = options.snapshot === null ? null : lookupDomain(options.snapshot.state, options.domainName);
222
- if (chainRecord === null) {
223
- return "live";
224
- }
225
- return Buffer.from(chainRecord.ownerScriptPubKey).toString("hex") === options.senderScriptPubKeyHex
226
- ? "confirmed"
227
- : "live";
228
- }
229
- function resolveRegisterSender(context, domainName, fromIdentity) {
230
- const state = context.localState.state;
231
- if (context.model.walletAddress === null) {
232
- throw new Error("wallet_register_funding_identity_unavailable");
233
- }
234
- void fromIdentity;
235
- if (!domainName.includes("-")) {
236
- return {
237
- registerKind: "root",
238
- parentDomainName: null,
239
- senderSelector: context.model.walletAddress,
240
- sender: createFundingMutationSender(state),
241
- };
242
- }
243
- const parent = getParent(context.snapshot.state, domainName);
244
- if (parent === null) {
245
- throw new Error("wallet_register_parent_not_found");
246
- }
247
- if (!parent.domain.anchored) {
248
- throw new Error("wallet_register_parent_not_anchored");
249
- }
250
- const parentDomain = context.model.domains.find((domain) => domain.name === parent.parentName) ?? null;
251
- if (!isLocalWalletScript(state, parentDomain?.ownerScriptPubKeyHex)) {
252
- throw new Error("wallet_register_parent_not_locally_controlled");
253
- }
254
- if (getBalance(context.snapshot.state, state.funding.scriptPubKeyHex) < SUBDOMAIN_REGISTRATION_FEE_COGTOSHI) {
255
- throw new Error("wallet_register_insufficient_cog_balance");
256
- }
257
- return {
258
- registerKind: "subdomain",
259
- parentDomainName: parent.parentName,
260
- senderSelector: context.model.walletAddress,
261
- sender: createFundingMutationSender(state),
262
- };
263
- }
264
- function createDraftMutation(options) {
265
- if (options.existing !== null && options.existing !== undefined) {
266
- return {
267
- ...options.existing,
268
- registerKind: options.registerKind,
269
- parentDomainName: options.parentDomainName,
270
- senderScriptPubKeyHex: options.sender.scriptPubKeyHex,
271
- senderLocalIndex: options.sender.localIndex,
272
- status: "draft",
273
- lastUpdatedAtUnixMs: options.nowUnixMs,
274
- attemptedTxid: null,
275
- attemptedWtxid: null,
276
- ...createWalletMutationFeeMetadata(options.feeSelection),
277
- temporaryBuilderLockedOutpoints: [],
278
- };
279
- }
280
- return {
281
- mutationId: randomBytes(12).toString("hex"),
282
- kind: "register",
283
- registerKind: options.registerKind,
284
- domainName: options.domainName,
285
- parentDomainName: options.parentDomainName,
286
- senderScriptPubKeyHex: options.sender.scriptPubKeyHex,
287
- senderLocalIndex: options.sender.localIndex,
288
- intentFingerprintHex: options.intentFingerprintHex,
289
- status: "draft",
290
- createdAtUnixMs: options.nowUnixMs,
291
- lastUpdatedAtUnixMs: options.nowUnixMs,
292
- attemptedTxid: null,
293
- attemptedWtxid: null,
294
- ...createWalletMutationFeeMetadata(options.feeSelection),
295
- temporaryBuilderLockedOutpoints: [],
296
- };
297
- }
298
- function validateFundedDraft(decoded, funded, plan) {
299
- const inputs = decoded.tx.vin;
300
- const outputs = decoded.tx.vout;
301
- if (inputs.length === 0) {
302
- throw new Error("wallet_register_missing_sender_input");
303
- }
304
- if (outputs[0]?.scriptPubKey?.hex !== plan.expectedOpReturnScriptHex) {
305
- throw new Error("wallet_register_opreturn_mismatch");
306
- }
307
- if (plan.expectedTreasuryScriptHex !== null && plan.expectedTreasuryOutputIndex !== null) {
308
- if (outputs[plan.expectedTreasuryOutputIndex]?.scriptPubKey?.hex !== plan.expectedTreasuryScriptHex) {
309
- throw new Error("wallet_register_treasury_output_mismatch");
310
- }
311
- if (valueToSats(outputs[plan.expectedTreasuryOutputIndex]?.value ?? 0) < (plan.expectedTreasuryValueSats ?? 0n)) {
312
- throw new Error("wallet_register_treasury_value_too_small");
313
- }
314
- }
315
- const expectedWithoutChange = 1 + Number(plan.expectedTreasuryOutputIndex !== null);
316
- if (funded.changepos === -1) {
317
- if (outputs.length !== expectedWithoutChange) {
318
- throw new Error("wallet_register_unexpected_output_count");
319
- }
320
- return;
321
- }
322
- if (funded.changepos !== plan.changePosition || outputs.length !== expectedWithoutChange + 1) {
323
- throw new Error("wallet_register_change_position_mismatch");
324
- }
325
- if (outputs[funded.changepos]?.scriptPubKey?.hex !== plan.allowedFundingScriptPubKeyHex) {
326
- throw new Error("wallet_register_change_output_mismatch");
327
- }
328
- }
329
- function buildRegisterPlan(options) {
330
- const fundingUtxos = listFundingUtxos(options.allUtxos, options.state.funding.scriptPubKeyHex);
331
- if (options.registerKind === "root") {
332
- const rootOutputs = buildRootRegisterOutputs({
333
- domainName: options.domainName,
334
- treasuryAddress: options.treasuryAddress,
335
- treasuryScriptPubKeyHex: options.treasuryScriptPubKeyHex,
336
- priceSats: options.rootPriceSats,
337
- });
338
- return {
339
- registerKind: "root",
340
- sender: options.sender,
341
- changeAddress: options.state.funding.address,
342
- fixedInputs: [],
343
- outputs: rootOutputs.outputs,
344
- changePosition: rootOutputs.changePosition,
345
- expectedOpReturnScriptHex: rootOutputs.expectedOpReturnScriptHex,
346
- expectedTreasuryOutputIndex: 1,
347
- expectedTreasuryScriptHex: options.treasuryScriptPubKeyHex,
348
- expectedTreasuryValueSats: options.rootPriceSats,
349
- allowedFundingScriptPubKeyHex: options.state.funding.scriptPubKeyHex,
350
- eligibleFundingOutpointKeys: new Set(fundingUtxos.map((entry) => outpointKey(entry))),
351
- };
352
- }
353
- const subdomainOutputs = buildSubdomainRegisterOutputs({
354
- domainName: options.domainName,
355
- });
356
- return {
357
- registerKind: "subdomain",
358
- sender: options.sender,
359
- changeAddress: options.state.funding.address,
360
- fixedInputs: [],
361
- outputs: subdomainOutputs.outputs,
362
- changePosition: subdomainOutputs.changePosition,
363
- expectedOpReturnScriptHex: subdomainOutputs.expectedOpReturnScriptHex,
364
- expectedTreasuryOutputIndex: null,
365
- expectedTreasuryScriptHex: null,
366
- expectedTreasuryValueSats: null,
367
- allowedFundingScriptPubKeyHex: options.state.funding.scriptPubKeyHex,
368
- eligibleFundingOutpointKeys: new Set(fundingUtxos.map((entry) => outpointKey(entry))),
369
- };
370
- }
371
- async function buildRegisterTransaction(options) {
372
- return buildWalletMutationTransactionWithReserveFallback({
373
- rpc: options.rpc,
374
- walletName: options.walletName,
375
- state: options.state,
376
- plan: options.plan,
377
- validateFundedDraft,
378
- finalizeErrorCode: "wallet_register_finalize_failed",
379
- mempoolRejectPrefix: "wallet_register_mempool_rejected",
380
- feeRate: options.feeRateSatVb,
381
- });
382
- }
383
- async function reconcilePendingRegisterMutation(options) {
384
- if (options.mutation.status === "repair-required") {
385
- return {
386
- state: options.state,
387
- mutation: options.mutation,
388
- resolution: "repair-required",
389
- };
390
- }
391
- const chainDomain = options.context.snapshot === null
392
- ? null
393
- : lookupDomain(options.context.snapshot.state, options.mutation.domainName);
394
- if (chainDomain !== null) {
395
- const chainOwnerHex = Buffer.from(chainDomain.ownerScriptPubKey).toString("hex");
396
- if (chainOwnerHex !== options.sender.scriptPubKeyHex) {
397
- const repairMutation = updateMutationRecord(options.mutation, "repair-required", options.nowUnixMs, {
398
- temporaryBuilderLockedOutpoints: [],
399
- });
400
- const nextState = upsertPendingMutation(options.state, repairMutation);
401
- await saveWalletStatePreservingUnlock({
402
- state: nextState,
403
- provider: options.provider,
404
- nowUnixMs: options.nowUnixMs,
405
- paths: options.paths,
406
- });
407
- return {
408
- state: nextState,
409
- mutation: repairMutation,
410
- resolution: "repair-required",
411
- };
412
- }
413
- await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
414
- const confirmedMutation = updateMutationRecord(options.mutation, "confirmed", options.nowUnixMs, {
415
- temporaryBuilderLockedOutpoints: [],
416
- });
417
- const nextState = reserveLocalDomainRecord({
418
- state: upsertPendingMutation(options.state, confirmedMutation),
419
- domainName: options.mutation.domainName,
420
- sender: options.sender,
421
- nowUnixMs: options.nowUnixMs,
422
- });
423
- await saveWalletStatePreservingUnlock({
424
- state: nextState,
425
- provider: options.provider,
426
- nowUnixMs: options.nowUnixMs,
427
- paths: options.paths,
428
- });
429
- return {
430
- state: nextState,
431
- mutation: confirmedMutation,
432
- resolution: "confirmed",
433
- };
434
- }
435
- if (options.mutation.attemptedTxid !== null) {
436
- const mempool = await options.rpc.getRawMempool().catch(() => []);
437
- if (mempool.includes(options.mutation.attemptedTxid)) {
438
- await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
439
- const liveMutation = updateMutationRecord(options.mutation, "live", options.nowUnixMs, {
440
- temporaryBuilderLockedOutpoints: [],
441
- });
442
- const nextState = reserveLocalDomainRecord({
443
- state: upsertPendingMutation(options.state, liveMutation),
444
- domainName: options.mutation.domainName,
445
- sender: options.sender,
446
- nowUnixMs: options.nowUnixMs,
447
- });
448
- await saveWalletStatePreservingUnlock({
449
- state: nextState,
450
- provider: options.provider,
451
- nowUnixMs: options.nowUnixMs,
452
- paths: options.paths,
453
- });
454
- return {
455
- state: nextState,
456
- mutation: liveMutation,
457
- resolution: "live",
458
- };
459
- }
460
- }
461
- if (options.mutation.status === "broadcast-unknown"
462
- || options.mutation.status === "live"
463
- || options.mutation.status === "draft"
464
- || options.mutation.status === "broadcasting") {
465
- await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
466
- const canceledMutation = updateMutationRecord(options.mutation, "canceled", options.nowUnixMs, {
467
- temporaryBuilderLockedOutpoints: [],
468
- });
469
- const nextState = upsertPendingMutation(options.state, canceledMutation);
470
- await saveWalletStatePreservingUnlock({
471
- state: nextState,
472
- provider: options.provider,
473
- nowUnixMs: options.nowUnixMs,
474
- paths: options.paths,
475
- });
476
- return {
477
- state: nextState,
478
- mutation: canceledMutation,
479
- resolution: "not-seen",
480
- };
481
- }
482
- return {
483
- state: options.state,
484
- mutation: options.mutation,
485
- resolution: "continue",
486
- };
487
- }
488
- export async function registerDomain(options) {
489
- if (!options.prompter.isInteractive && options.assumeYes !== true) {
490
- throw new Error("wallet_register_requires_tty");
491
- }
492
- const normalizedDomainName = normalizeDomainName(options.domainName);
493
- const execution = await executeWalletMutationOperation({
494
- ...options,
495
- controlLockPurpose: "wallet-register",
496
- preemptionReason: "wallet-register",
497
- async resolveOperation(readContext) {
498
- assertWalletMutationContextReady(readContext, "wallet_register");
499
- const state = readContext.localState.state;
500
- const senderResolution = resolveRegisterSender(readContext, normalizedDomainName, options.fromIdentity);
501
- if (lookupDomain(readContext.snapshot.state, normalizedDomainName) !== null) {
502
- throw new Error("wallet_register_domain_already_registered");
503
- }
504
- if (readContext.snapshot.state.consensus.nextDomainId === 0xffff_ffff) {
505
- throw new Error("wallet_register_next_domain_id_exhausted");
506
- }
507
- const rootPriceSats = computeRootRegistrationPriceSats(normalizedDomainName);
508
- const resolvedSummary = createRegisterResolvedSummary({
509
- registerKind: senderResolution.registerKind,
510
- parentDomainName: senderResolution.parentDomainName,
511
- senderSelector: senderResolution.senderSelector,
512
- sender: senderResolution.sender,
513
- economicEffectKind: senderResolution.registerKind === "root" ? "treasury-payment" : "cog-burn",
514
- economicEffectAmount: senderResolution.registerKind === "root" ? rootPriceSats : SUBDOMAIN_REGISTRATION_FEE_COGTOSHI,
515
- });
516
- const genesis = await (options.loadGenesisParameters ?? loadBundledGenesisParameters)();
517
- return {
518
- state,
519
- normalizedDomainName,
520
- senderResolution,
521
- rootPriceSats,
522
- resolvedSummary,
523
- genesis,
524
- };
525
- },
526
- createIntentFingerprint(operation) {
527
- return createRegisterIntentFingerprint({
528
- walletRootId: operation.state.walletRootId,
529
- domainName: operation.normalizedDomainName,
530
- registerKind: operation.senderResolution.registerKind,
531
- senderScriptPubKeyHex: operation.senderResolution.sender.scriptPubKeyHex,
532
- });
533
- },
534
- async resolveExistingMutation({ operation, existingMutation, execution }) {
535
- if (existingMutation === null) {
536
- return { state: operation.state, replacementFixedInputs: null, result: null };
537
- }
538
- return resolveExistingWalletMutation({
539
- existingMutation,
540
- execution,
541
- repairRequiredErrorCode: "wallet_register_repair_required",
542
- reconcileExistingMutation: (mutation) => reconcilePendingRegisterMutation({
543
- state: operation.state,
544
- mutation,
545
- provider: execution.provider,
546
- nowUnixMs: execution.nowUnixMs,
547
- paths: execution.paths,
548
- rpc: execution.rpc,
549
- walletName: execution.walletName,
550
- context: execution.readContext,
551
- sender: operation.senderResolution.sender,
552
- }),
553
- createReuseResult: ({ mutation, resolution, fees }) => ({
554
- domainName: operation.normalizedDomainName,
555
- registerKind: operation.senderResolution.registerKind,
556
- parentDomainName: operation.senderResolution.parentDomainName,
557
- senderSelector: operation.senderResolution.senderSelector,
558
- senderLocalIndex: operation.senderResolution.sender.localIndex,
559
- senderScriptPubKeyHex: operation.senderResolution.sender.scriptPubKeyHex,
560
- senderAddress: operation.senderResolution.sender.address,
561
- economicEffectKind: operation.senderResolution.registerKind === "root" ? "treasury-payment" : "cog-burn",
562
- economicEffectAmount: operation.senderResolution.registerKind === "root"
563
- ? operation.rootPriceSats
564
- : SUBDOMAIN_REGISTRATION_FEE_COGTOSHI,
565
- resolved: operation.resolvedSummary,
566
- txid: mutation.attemptedTxid ?? "unknown",
567
- status: resolution,
568
- reusedExisting: true,
569
- fees,
570
- }),
571
- });
572
- },
573
- async confirm({ operation, execution }) {
574
- if (operation.senderResolution.registerKind === "root") {
575
- const competingRootTxids = await findCompetingRootRegistrationTxids(execution.rpc, operation.normalizedDomainName);
576
- if (competingRootTxids.length > 0 && !options.forceRace) {
577
- throw new Error("wallet_register_root_race_detected");
578
- }
579
- await confirmRootRegistration(options.prompter, operation.normalizedDomainName, operation.resolvedSummary, competingRootTxids.length > 0, options.assumeYes);
580
- return;
581
- }
582
- await confirmSubdomainRegistration(options.prompter, operation.normalizedDomainName, operation.resolvedSummary, options.assumeYes);
583
- },
584
- createDraftMutation({ operation, existingMutation, execution, intentFingerprintHex }) {
585
- return {
586
- mutation: createDraftMutation({
587
- domainName: operation.normalizedDomainName,
588
- parentDomainName: operation.senderResolution.parentDomainName,
589
- sender: operation.senderResolution.sender,
590
- registerKind: operation.senderResolution.registerKind,
591
- intentFingerprintHex,
592
- nowUnixMs: execution.nowUnixMs,
593
- feeSelection: execution.feeSelection,
594
- existing: existingMutation,
595
- }),
596
- prepared: null,
597
- };
598
- },
599
- async build({ operation, state, execution, replacementFixedInputs }) {
600
- const plan = buildRegisterPlan({
601
- context: execution.readContext,
602
- state,
603
- allUtxos: await execution.rpc.listUnspent(execution.walletName, 1),
604
- sender: operation.senderResolution.sender,
605
- registerKind: operation.senderResolution.registerKind,
606
- domainName: operation.normalizedDomainName,
607
- parentDomainName: operation.senderResolution.parentDomainName,
608
- treasuryAddress: operation.genesis.treasuryAddress,
609
- treasuryScriptPubKeyHex: Buffer.from(operation.genesis.treasuryScriptPubKey).toString("hex"),
610
- rootPriceSats: operation.rootPriceSats,
611
- });
612
- return buildRegisterTransaction({
613
- rpc: execution.rpc,
614
- walletName: execution.walletName,
615
- state,
616
- plan: {
617
- ...plan,
618
- fixedInputs: mergeFixedWalletInputs(plan.fixedInputs, replacementFixedInputs),
619
- },
620
- feeRateSatVb: execution.feeSelection.feeRateSatVb,
621
- });
622
- },
623
- publish({ operation, state, execution, built, mutation }) {
624
- return publishWalletMutation({
625
- rpc: execution.rpc,
626
- walletName: execution.walletName,
627
- snapshotHeight: execution.readContext.snapshot?.tip?.height ?? null,
628
- built,
629
- mutation,
630
- state,
631
- provider: execution.provider,
632
- nowUnixMs: execution.nowUnixMs,
633
- paths: execution.paths,
634
- errorPrefix: "wallet_register",
635
- async afterAccepted({ state: acceptedState, broadcastingMutation, built, nowUnixMs }) {
636
- const finalStatus = getMutationStatusAfterAcceptance({
637
- snapshot: execution.readContext.snapshot,
638
- domainName: operation.normalizedDomainName,
639
- senderScriptPubKeyHex: operation.senderResolution.sender.scriptPubKeyHex,
640
- });
641
- const finalMutation = updateMutationRecord(broadcastingMutation, finalStatus, nowUnixMs, {
642
- attemptedTxid: built.txid,
643
- attemptedWtxid: built.wtxid,
644
- temporaryBuilderLockedOutpoints: [],
645
- });
646
- return {
647
- state: reserveLocalDomainRecord({
648
- state: upsertPendingMutation(acceptedState, finalMutation),
649
- domainName: operation.normalizedDomainName,
650
- sender: operation.senderResolution.sender,
651
- nowUnixMs,
652
- }),
653
- mutation: finalMutation,
654
- status: finalStatus,
655
- };
656
- },
657
- });
658
- },
659
- createResult({ operation, mutation, built, status, reusedExisting, fees }) {
660
- return {
661
- domainName: operation.normalizedDomainName,
662
- registerKind: operation.senderResolution.registerKind,
663
- parentDomainName: operation.senderResolution.parentDomainName,
664
- senderSelector: operation.senderResolution.senderSelector,
665
- senderLocalIndex: operation.senderResolution.sender.localIndex,
666
- senderScriptPubKeyHex: operation.senderResolution.sender.scriptPubKeyHex,
667
- senderAddress: operation.senderResolution.sender.address,
668
- economicEffectKind: operation.senderResolution.registerKind === "root" ? "treasury-payment" : "cog-burn",
669
- economicEffectAmount: operation.senderResolution.registerKind === "root"
670
- ? operation.rootPriceSats
671
- : SUBDOMAIN_REGISTRATION_FEE_COGTOSHI,
672
- resolved: operation.resolvedSummary,
673
- txid: mutation.attemptedTxid ?? built?.txid ?? "unknown",
674
- status: status,
675
- reusedExisting,
676
- fees,
677
- };
678
- },
679
- });
680
- return execution.result;
681
- }
1
+ export * from "./register/index.js";