@cogcoin/client 1.1.7 → 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 (284) hide show
  1. package/README.md +1 -1
  2. package/dist/bitcoind/service.js +1 -1
  3. package/dist/cli/commands/mining-read.js +1 -1
  4. package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
  5. package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
  6. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
  7. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
  8. package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
  9. package/dist/cli/commands/wallet-mutation/cog.js +131 -0
  10. package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
  11. package/dist/cli/commands/wallet-mutation/context.js +18 -0
  12. package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
  13. package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
  14. package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
  15. package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
  16. package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
  17. package/dist/cli/commands/wallet-mutation/field.js +125 -0
  18. package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
  19. package/dist/cli/commands/wallet-mutation/register.js +38 -0
  20. package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
  21. package/dist/cli/commands/wallet-mutation/registry.js +39 -0
  22. package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
  23. package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
  24. package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
  25. package/dist/cli/commands/wallet-mutation/types.js +1 -0
  26. package/dist/cli/commands/wallet-mutation.js +13 -765
  27. package/dist/cli/commands/wallet-read.js +4 -4
  28. package/dist/cli/mutation-success.d.ts +0 -2
  29. package/dist/cli/output/classify.d.ts +7 -0
  30. package/dist/cli/output/classify.js +94 -0
  31. package/dist/cli/output/render.d.ts +2 -0
  32. package/dist/cli/output/render.js +13 -0
  33. package/dist/cli/output/rules/cli-surface.d.ts +2 -0
  34. package/dist/cli/output/rules/cli-surface.js +110 -0
  35. package/dist/cli/output/rules/generic.d.ts +2 -0
  36. package/dist/cli/output/rules/generic.js +13 -0
  37. package/dist/cli/output/rules/index.d.ts +2 -0
  38. package/dist/cli/output/rules/index.js +24 -0
  39. package/dist/cli/output/rules/mining-update.d.ts +2 -0
  40. package/dist/cli/output/rules/mining-update.js +68 -0
  41. package/dist/cli/output/rules/services.d.ts +2 -0
  42. package/dist/cli/output/rules/services.js +110 -0
  43. package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
  44. package/dist/cli/output/rules/wallet-admin.js +224 -0
  45. package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
  46. package/dist/cli/output/rules/wallet-mutations.js +274 -0
  47. package/dist/cli/output/types.d.ts +16 -0
  48. package/dist/cli/output/types.js +1 -0
  49. package/dist/cli/output.d.ts +2 -168
  50. package/dist/cli/output.js +6 -989
  51. package/dist/cli/pagination.d.ts +15 -0
  52. package/dist/cli/pagination.js +16 -0
  53. package/dist/cli/recommendations.d.ts +4 -0
  54. package/dist/cli/recommendations.js +108 -0
  55. package/dist/cli/wallet-format/availability.d.ts +5 -0
  56. package/dist/cli/wallet-format/availability.js +96 -0
  57. package/dist/cli/wallet-format/balance.d.ts +2 -0
  58. package/dist/cli/wallet-format/balance.js +162 -0
  59. package/dist/cli/wallet-format/domains.d.ts +8 -0
  60. package/dist/cli/wallet-format/domains.js +84 -0
  61. package/dist/cli/wallet-format/fields.d.ts +6 -0
  62. package/dist/cli/wallet-format/fields.js +61 -0
  63. package/dist/cli/wallet-format/identity.d.ts +5 -0
  64. package/dist/cli/wallet-format/identity.js +19 -0
  65. package/dist/cli/wallet-format/locks.d.ts +7 -0
  66. package/dist/cli/wallet-format/locks.js +52 -0
  67. package/dist/cli/wallet-format/overview.d.ts +2 -0
  68. package/dist/cli/wallet-format/overview.js +122 -0
  69. package/dist/cli/wallet-format/pending.d.ts +13 -0
  70. package/dist/cli/wallet-format/pending.js +101 -0
  71. package/dist/cli/wallet-format/shared.d.ts +7 -0
  72. package/dist/cli/wallet-format/shared.js +31 -0
  73. package/dist/cli/wallet-format/status.d.ts +3 -0
  74. package/dist/cli/wallet-format/status.js +27 -0
  75. package/dist/cli/wallet-format.d.ts +8 -30
  76. package/dist/cli/wallet-format.js +8 -830
  77. package/dist/cli/wallet-read-helpers.d.ts +6 -0
  78. package/dist/cli/wallet-read-helpers.js +17 -0
  79. package/dist/wallet/mining/candidate.d.ts +1 -1
  80. package/dist/wallet/mining/candidate.js +3 -3
  81. package/dist/wallet/mining/constants.d.ts +2 -2
  82. package/dist/wallet/mining/constants.js +2 -2
  83. package/dist/wallet/mining/engine-state.js +10 -0
  84. package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
  85. package/dist/wallet/mining/sentences.js +8 -8
  86. package/dist/wallet/mining/visualizer-sync.js +79 -15
  87. package/dist/wallet/read/context.js +1 -1
  88. package/dist/wallet/reset/artifacts.d.ts +16 -0
  89. package/dist/wallet/reset/artifacts.js +141 -0
  90. package/dist/wallet/reset/execution.d.ts +38 -0
  91. package/dist/wallet/reset/execution.js +458 -0
  92. package/dist/wallet/reset/preflight.d.ts +7 -0
  93. package/dist/wallet/reset/preflight.js +116 -0
  94. package/dist/wallet/reset/preview.d.ts +2 -0
  95. package/dist/wallet/reset/preview.js +50 -0
  96. package/dist/wallet/reset/process-cleanup.d.ts +12 -0
  97. package/dist/wallet/reset/process-cleanup.js +179 -0
  98. package/dist/wallet/reset/types.d.ts +189 -0
  99. package/dist/wallet/reset/types.js +1 -0
  100. package/dist/wallet/reset.d.ts +4 -119
  101. package/dist/wallet/reset.js +4 -882
  102. package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
  103. package/dist/wallet/tx/anchor/confirm.js +60 -0
  104. package/dist/wallet/tx/anchor/draft.d.ts +39 -0
  105. package/dist/wallet/tx/anchor/draft.js +167 -0
  106. package/dist/wallet/tx/anchor/index.d.ts +5 -0
  107. package/dist/wallet/tx/anchor/index.js +148 -0
  108. package/dist/wallet/tx/anchor/intent.d.ts +61 -0
  109. package/dist/wallet/tx/anchor/intent.js +101 -0
  110. package/dist/wallet/tx/anchor/plan.d.ts +3 -0
  111. package/dist/wallet/tx/anchor/plan.js +18 -0
  112. package/dist/wallet/tx/anchor/result.d.ts +25 -0
  113. package/dist/wallet/tx/anchor/result.js +20 -0
  114. package/dist/wallet/tx/anchor.d.ts +1 -39
  115. package/dist/wallet/tx/anchor.js +1 -494
  116. package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
  117. package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
  118. package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
  119. package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
  120. package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
  121. package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
  122. package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
  123. package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
  124. package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
  125. package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
  126. package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
  127. package/dist/wallet/tx/bitcoin-transfer.js +1 -200
  128. package/dist/wallet/tx/cog/confirm.d.ts +13 -0
  129. package/dist/wallet/tx/cog/confirm.js +59 -0
  130. package/dist/wallet/tx/cog/draft.d.ts +20 -0
  131. package/dist/wallet/tx/cog/draft.js +114 -0
  132. package/dist/wallet/tx/cog/index.d.ts +6 -0
  133. package/dist/wallet/tx/cog/index.js +117 -0
  134. package/dist/wallet/tx/cog/intent.d.ts +30 -0
  135. package/dist/wallet/tx/cog/intent.js +169 -0
  136. package/dist/wallet/tx/cog/plan.d.ts +19 -0
  137. package/dist/wallet/tx/cog/plan.js +65 -0
  138. package/dist/wallet/tx/cog/result.d.ts +27 -0
  139. package/dist/wallet/tx/cog/result.js +28 -0
  140. package/dist/wallet/tx/cog/types.d.ts +186 -0
  141. package/dist/wallet/tx/cog/types.js +2 -0
  142. package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
  143. package/dist/wallet/tx/cog/variants/claim.js +92 -0
  144. package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
  145. package/dist/wallet/tx/cog/variants/lock.js +102 -0
  146. package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
  147. package/dist/wallet/tx/cog/variants/send.js +77 -0
  148. package/dist/wallet/tx/cog.d.ts +1 -96
  149. package/dist/wallet/tx/cog.js +1 -824
  150. package/dist/wallet/tx/common.d.ts +14 -199
  151. package/dist/wallet/tx/common.js +10 -493
  152. package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
  153. package/dist/wallet/tx/domain-admin/confirm.js +58 -0
  154. package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
  155. package/dist/wallet/tx/domain-admin/draft.js +161 -0
  156. package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
  157. package/dist/wallet/tx/domain-admin/index.js +150 -0
  158. package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
  159. package/dist/wallet/tx/domain-admin/intent.js +61 -0
  160. package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
  161. package/dist/wallet/tx/domain-admin/plan.js +64 -0
  162. package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
  163. package/dist/wallet/tx/domain-admin/result.js +33 -0
  164. package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
  165. package/dist/wallet/tx/domain-admin/types.js +1 -0
  166. package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
  167. package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
  168. package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
  169. package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
  170. package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
  171. package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
  172. package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
  173. package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
  174. package/dist/wallet/tx/domain-admin.d.ts +1 -107
  175. package/dist/wallet/tx/domain-admin.js +1 -729
  176. package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
  177. package/dist/wallet/tx/domain-market/confirm.js +52 -0
  178. package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
  179. package/dist/wallet/tx/domain-market/draft.js +286 -0
  180. package/dist/wallet/tx/domain-market/index.d.ts +6 -0
  181. package/dist/wallet/tx/domain-market/index.js +145 -0
  182. package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
  183. package/dist/wallet/tx/domain-market/intent.js +131 -0
  184. package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
  185. package/dist/wallet/tx/domain-market/plan.js +98 -0
  186. package/dist/wallet/tx/domain-market/result.d.ts +45 -0
  187. package/dist/wallet/tx/domain-market/result.js +88 -0
  188. package/dist/wallet/tx/domain-market/types.d.ts +221 -0
  189. package/dist/wallet/tx/domain-market/types.js +1 -0
  190. package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
  191. package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
  192. package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
  193. package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
  194. package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
  195. package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
  196. package/dist/wallet/tx/domain-market.d.ts +1 -116
  197. package/dist/wallet/tx/domain-market.js +1 -1078
  198. package/dist/wallet/tx/draft-build.d.ts +60 -0
  199. package/dist/wallet/tx/draft-build.js +127 -0
  200. package/dist/wallet/tx/executor.d.ts +6 -40
  201. package/dist/wallet/tx/executor.js +6 -100
  202. package/dist/wallet/tx/fee.d.ts +30 -0
  203. package/dist/wallet/tx/fee.js +98 -0
  204. package/dist/wallet/tx/field/confirm.d.ts +11 -0
  205. package/dist/wallet/tx/field/confirm.js +19 -0
  206. package/dist/wallet/tx/field/draft.d.ts +23 -0
  207. package/dist/wallet/tx/field/draft.js +202 -0
  208. package/dist/wallet/tx/field/index.d.ts +5 -0
  209. package/dist/wallet/tx/field/index.js +140 -0
  210. package/dist/wallet/tx/field/intent.d.ts +5 -0
  211. package/dist/wallet/tx/field/intent.js +50 -0
  212. package/dist/wallet/tx/field/plan.d.ts +20 -0
  213. package/dist/wallet/tx/field/plan.js +65 -0
  214. package/dist/wallet/tx/field/result.d.ts +29 -0
  215. package/dist/wallet/tx/field/result.js +103 -0
  216. package/dist/wallet/tx/field/types.d.ts +163 -0
  217. package/dist/wallet/tx/field/types.js +1 -0
  218. package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
  219. package/dist/wallet/tx/field/variants/clear.js +60 -0
  220. package/dist/wallet/tx/field/variants/create.d.ts +2 -0
  221. package/dist/wallet/tx/field/variants/create.js +67 -0
  222. package/dist/wallet/tx/field/variants/set.d.ts +2 -0
  223. package/dist/wallet/tx/field/variants/set.js +195 -0
  224. package/dist/wallet/tx/field.d.ts +1 -95
  225. package/dist/wallet/tx/field.js +1 -920
  226. package/dist/wallet/tx/mining-preemption.d.ts +6 -0
  227. package/dist/wallet/tx/mining-preemption.js +7 -0
  228. package/dist/wallet/tx/primitives.d.ts +13 -0
  229. package/dist/wallet/tx/primitives.js +42 -0
  230. package/dist/wallet/tx/psbt-assert.d.ts +14 -0
  231. package/dist/wallet/tx/psbt-assert.js +39 -0
  232. package/dist/wallet/tx/publish.d.ts +37 -0
  233. package/dist/wallet/tx/publish.js +88 -0
  234. package/dist/wallet/tx/readiness.d.ts +7 -0
  235. package/dist/wallet/tx/readiness.js +61 -0
  236. package/dist/wallet/tx/reconcile.d.ts +24 -0
  237. package/dist/wallet/tx/reconcile.js +72 -0
  238. package/dist/wallet/tx/register/confirm.d.ts +6 -0
  239. package/dist/wallet/tx/register/confirm.js +66 -0
  240. package/dist/wallet/tx/register/draft.d.ts +42 -0
  241. package/dist/wallet/tx/register/draft.js +181 -0
  242. package/dist/wallet/tx/register/index.d.ts +6 -0
  243. package/dist/wallet/tx/register/index.js +158 -0
  244. package/dist/wallet/tx/register/intent.d.ts +74 -0
  245. package/dist/wallet/tx/register/intent.js +119 -0
  246. package/dist/wallet/tx/register/plan.d.ts +43 -0
  247. package/dist/wallet/tx/register/plan.js +168 -0
  248. package/dist/wallet/tx/register/result.d.ts +78 -0
  249. package/dist/wallet/tx/register/result.js +41 -0
  250. package/dist/wallet/tx/register.d.ts +1 -70
  251. package/dist/wallet/tx/register.js +1 -681
  252. package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
  253. package/dist/wallet/tx/reputation/confirm.js +51 -0
  254. package/dist/wallet/tx/reputation/draft.d.ts +20 -0
  255. package/dist/wallet/tx/reputation/draft.js +130 -0
  256. package/dist/wallet/tx/reputation/index.d.ts +4 -0
  257. package/dist/wallet/tx/reputation/index.js +162 -0
  258. package/dist/wallet/tx/reputation/intent.d.ts +36 -0
  259. package/dist/wallet/tx/reputation/intent.js +157 -0
  260. package/dist/wallet/tx/reputation/plan.d.ts +19 -0
  261. package/dist/wallet/tx/reputation/plan.js +64 -0
  262. package/dist/wallet/tx/reputation/result.d.ts +21 -0
  263. package/dist/wallet/tx/reputation/result.js +31 -0
  264. package/dist/wallet/tx/reputation/types.d.ts +130 -0
  265. package/dist/wallet/tx/reputation/types.js +1 -0
  266. package/dist/wallet/tx/reputation.d.ts +1 -74
  267. package/dist/wallet/tx/reputation.js +1 -556
  268. package/dist/wallet/tx/signing.d.ts +18 -0
  269. package/dist/wallet/tx/signing.js +31 -0
  270. package/dist/wallet/tx/state-persist.d.ts +27 -0
  271. package/dist/wallet/tx/state-persist.js +54 -0
  272. package/dist/wallet/tx/types.d.ts +44 -0
  273. package/dist/wallet/tx/types.js +1 -0
  274. package/package.json +1 -1
  275. package/dist/cli/mining-json.d.ts +0 -20
  276. package/dist/cli/mining-json.js +0 -46
  277. package/dist/cli/mutation-json.d.ts +0 -325
  278. package/dist/cli/mutation-json.js +0 -269
  279. package/dist/cli/mutation-resolved-json.d.ts +0 -117
  280. package/dist/cli/mutation-resolved-json.js +0 -123
  281. package/dist/cli/preview-json.d.ts +0 -319
  282. package/dist/cli/preview-json.js +0 -254
  283. package/dist/cli/read-json.d.ts +0 -190
  284. package/dist/cli/read-json.js +0 -627
@@ -0,0 +1,117 @@
1
+ import { mergeFixedWalletInputs } from "../common.js";
2
+ import { executeWalletMutationOperation, publishWalletMutation, resolveExistingWalletMutation, } from "../executor.js";
3
+ import { reconcilePendingCogMutation } from "./draft.js";
4
+ import { buildPlanForCogOperation, buildCogTransaction, } from "./plan.js";
5
+ import { createClaimCogVariant, createReclaimCogVariant } from "./variants/claim.js";
6
+ import { createLockCogVariant } from "./variants/lock.js";
7
+ import { createSendCogVariant } from "./variants/send.js";
8
+ async function executeCogMutation(options, variant) {
9
+ const execution = await executeWalletMutationOperation({
10
+ ...options,
11
+ controlLockPurpose: variant.controlLockPurpose,
12
+ preemptionReason: variant.preemptionReason,
13
+ resolveOperation(readContext) {
14
+ return variant.resolveOperation(readContext);
15
+ },
16
+ createIntentFingerprint(operation) {
17
+ return variant.createIntentFingerprint(operation);
18
+ },
19
+ async resolveExistingMutation({ operation, existingMutation, execution }) {
20
+ if (existingMutation === null) {
21
+ return { state: operation.state, replacementFixedInputs: null, result: null };
22
+ }
23
+ return resolveExistingWalletMutation({
24
+ existingMutation,
25
+ execution,
26
+ repairRequiredErrorCode: variant.repairRequiredErrorCode,
27
+ reconcileExistingMutation: (mutation) => reconcilePendingCogMutation({
28
+ state: operation.state,
29
+ mutation,
30
+ provider: execution.provider,
31
+ nowUnixMs: execution.nowUnixMs,
32
+ paths: execution.paths,
33
+ rpc: execution.rpc,
34
+ walletName: execution.walletName,
35
+ context: execution.readContext,
36
+ }),
37
+ createReuseResult: ({ mutation, resolution, fees }) => variant.createReuseResult({
38
+ operation,
39
+ mutation,
40
+ resolution,
41
+ fees,
42
+ }),
43
+ });
44
+ },
45
+ confirm({ operation }) {
46
+ return variant.confirm(operation);
47
+ },
48
+ createDraftMutation({ operation, existingMutation, execution, intentFingerprintHex }) {
49
+ return {
50
+ mutation: variant.createDraftMutation({
51
+ operation,
52
+ existingMutation,
53
+ feeSelection: execution.feeSelection,
54
+ intentFingerprintHex,
55
+ nowUnixMs: execution.nowUnixMs,
56
+ }),
57
+ prepared: null,
58
+ };
59
+ },
60
+ async build({ operation, state, execution, replacementFixedInputs }) {
61
+ const plan = buildPlanForCogOperation({
62
+ state,
63
+ allUtxos: await execution.rpc.listUnspent(execution.walletName, 1),
64
+ sender: operation.sender,
65
+ opReturnData: variant.createOpReturnData(operation),
66
+ errorPrefix: variant.errorPrefix,
67
+ });
68
+ return buildCogTransaction({
69
+ rpc: execution.rpc,
70
+ walletName: execution.walletName,
71
+ state,
72
+ plan: {
73
+ ...plan,
74
+ fixedInputs: mergeFixedWalletInputs(plan.fixedInputs, replacementFixedInputs),
75
+ },
76
+ feeRateSatVb: execution.feeSelection.feeRateSatVb,
77
+ });
78
+ },
79
+ publish({ state, execution, built, mutation }) {
80
+ return publishWalletMutation({
81
+ rpc: execution.rpc,
82
+ walletName: execution.walletName,
83
+ snapshotHeight: execution.readContext.snapshot?.tip?.height ?? null,
84
+ built,
85
+ mutation,
86
+ state,
87
+ provider: execution.provider,
88
+ nowUnixMs: execution.nowUnixMs,
89
+ paths: execution.paths,
90
+ errorPrefix: variant.errorPrefix,
91
+ });
92
+ },
93
+ createResult({ operation, mutation, built, status, reusedExisting, fees }) {
94
+ return variant.createResult({
95
+ operation,
96
+ mutation,
97
+ builtTxid: built?.txid ?? null,
98
+ status: status,
99
+ reusedExisting,
100
+ fees,
101
+ });
102
+ },
103
+ });
104
+ return execution.result;
105
+ }
106
+ export async function sendCog(options) {
107
+ return executeCogMutation(options, createSendCogVariant(options));
108
+ }
109
+ export async function lockCogToDomain(options) {
110
+ return executeCogMutation(options, createLockCogVariant(options));
111
+ }
112
+ export async function claimCogLock(options) {
113
+ return executeCogMutation(options, createClaimCogVariant(options));
114
+ }
115
+ export async function reclaimCogLock(options) {
116
+ return executeCogMutation(options, createReclaimCogVariant(options));
117
+ }
@@ -0,0 +1,30 @@
1
+ import { resolveIdentityBySelector } from "../identity-selector.js";
2
+ import type { ClaimCogMutationOperation, CogResolvedSenderSummary, CogResolvedSummary, LockCogMutationOperation, SendCogOperation } from "./types.js";
3
+ import { MAX_LOCK_DURATION_BLOCKS, ZERO_PREIMAGE_HEX } from "./types.js";
4
+ export declare function normalizeCogDomainName(value: string): string;
5
+ export declare function normalizePositiveCogAmount(amountCogtoshi: bigint, errorCode: string): bigint;
6
+ export declare function createCogIntentFingerprint(parts: Array<string | number | bigint>): string;
7
+ export declare function parseHex32(value: string, errorCode: string): Buffer;
8
+ export declare function sha256Hex(value: Uint8Array): string;
9
+ export declare function createResolvedSenderSummary(identity: ReturnType<typeof resolveIdentityBySelector>): CogResolvedSenderSummary;
10
+ export declare function resolveIdentitySender(context: WalletReadContext, errorPrefix: string, amountCogtoshi: bigint, selector: string | null | undefined): {
11
+ state: WalletStateV1;
12
+ sender: MutationSender;
13
+ resolved: CogResolvedSummary;
14
+ };
15
+ export declare function resolveClaimSender(context: WalletReadContext, lockId: number, preimageHex: string, reclaim: boolean): {
16
+ state: WalletStateV1;
17
+ sender: MutationSender;
18
+ recipientDomainName: string | null;
19
+ amountCogtoshi: bigint;
20
+ lockId: number;
21
+ resolved: CogResolvedSummary;
22
+ };
23
+ export declare function parseTimeoutHeight(currentHeight: number, rawRelative: string | null | undefined, rawAbsolute: number | null | undefined): number;
24
+ export declare function createSendCogOpReturnData(operation: SendCogOperation): Uint8Array;
25
+ export declare function createLockCogOpReturnData(operation: LockCogMutationOperation): Uint8Array;
26
+ export declare function createClaimCogOpReturnData(operation: ClaimCogMutationOperation): Uint8Array;
27
+ export { MAX_LOCK_DURATION_BLOCKS, ZERO_PREIMAGE_HEX, };
28
+ import type { WalletReadContext } from "../../read/index.js";
29
+ import type { WalletStateV1 } from "../../types.js";
30
+ import type { MutationSender } from "../common.js";
@@ -0,0 +1,169 @@
1
+ import { createHash } from "node:crypto";
2
+ import { getLock, lookupDomain, } from "@cogcoin/indexer/queries";
3
+ import { serializeCogClaim, serializeCogLock, serializeCogTransfer, } from "../../cogop/index.js";
4
+ import { assertWalletMutationContextReady, createFundingMutationSender, } from "../common.js";
5
+ import { getCanonicalIdentitySelector, resolveIdentityBySelector, } from "../identity-selector.js";
6
+ import { MAX_LOCK_DURATION_BLOCKS, ZERO_PREIMAGE_HEX, } from "./types.js";
7
+ export function normalizeCogDomainName(value) {
8
+ const normalized = value.trim().toLowerCase();
9
+ if (normalized.length === 0) {
10
+ throw new Error("wallet_cog_missing_domain");
11
+ }
12
+ return normalized;
13
+ }
14
+ export function normalizePositiveCogAmount(amountCogtoshi, errorCode) {
15
+ if (amountCogtoshi <= 0n) {
16
+ throw new Error(errorCode);
17
+ }
18
+ return amountCogtoshi;
19
+ }
20
+ export function createCogIntentFingerprint(parts) {
21
+ return createHash("sha256")
22
+ .update(parts.map((part) => String(part)).join("\n"))
23
+ .digest("hex");
24
+ }
25
+ export function parseHex32(value, errorCode) {
26
+ const normalized = value.trim().toLowerCase();
27
+ if (!/^[0-9a-f]{64}$/.test(normalized)) {
28
+ throw new Error(errorCode);
29
+ }
30
+ return Buffer.from(normalized, "hex");
31
+ }
32
+ export function sha256Hex(value) {
33
+ return createHash("sha256").update(value).digest("hex");
34
+ }
35
+ function ensureUsableSender(sender, errorPrefix, amountCogtoshi) {
36
+ if (sender.address === null) {
37
+ throw new Error(`${errorPrefix}_sender_address_unavailable`);
38
+ }
39
+ if (sender.readOnly) {
40
+ throw new Error(`${errorPrefix}_sender_read_only`);
41
+ }
42
+ if (sender.observedCogBalance === null || sender.observedCogBalance < amountCogtoshi) {
43
+ throw new Error(`${errorPrefix}_insufficient_cog_balance`);
44
+ }
45
+ }
46
+ export function createResolvedSenderSummary(identity) {
47
+ return {
48
+ selector: getCanonicalIdentitySelector(identity),
49
+ localIndex: identity.index,
50
+ scriptPubKeyHex: identity.scriptPubKeyHex,
51
+ address: identity.address,
52
+ };
53
+ }
54
+ export function resolveIdentitySender(context, errorPrefix, amountCogtoshi, selector) {
55
+ assertWalletMutationContextReady(context, errorPrefix);
56
+ const identity = resolveIdentityBySelector(context, selector ?? context.model.walletAddress ?? "", errorPrefix);
57
+ ensureUsableSender(identity, errorPrefix, amountCogtoshi);
58
+ return {
59
+ state: context.localState.state,
60
+ sender: createFundingMutationSender(context.localState.state),
61
+ resolved: {
62
+ sender: createResolvedSenderSummary(identity),
63
+ claimPath: null,
64
+ },
65
+ };
66
+ }
67
+ export function resolveClaimSender(context, lockId, preimageHex, reclaim) {
68
+ const errorPrefix = reclaim ? "wallet_reclaim" : "wallet_claim";
69
+ assertWalletMutationContextReady(context, errorPrefix);
70
+ const currentHeight = context.snapshot.state.history.currentHeight;
71
+ if (currentHeight === null) {
72
+ throw new Error(`${errorPrefix}_current_height_unavailable`);
73
+ }
74
+ const lock = getLock(context.snapshot.state, lockId);
75
+ if (lock === null || lock.status !== "active") {
76
+ throw new Error(`${errorPrefix}_lock_not_found`);
77
+ }
78
+ const recipientDomain = lookupDomain(context.snapshot.state, context.model.domains.find((domain) => domain.domainId === lock.recipientDomainId)?.name ?? "") ?? [...context.snapshot.state.consensus.domainsById.values()].find((entry) => entry.domainId === lock.recipientDomainId)
79
+ ?? null;
80
+ const recipientDomainName = recipientDomain?.name ?? null;
81
+ if (reclaim) {
82
+ if (currentHeight < lock.timeoutHeight) {
83
+ throw new Error("wallet_reclaim_before_timeout");
84
+ }
85
+ const lockerHex = Buffer.from(lock.lockerScriptPubKey).toString("hex");
86
+ if (lockerHex !== context.localState.state.funding.scriptPubKeyHex || context.model.walletAddress == null) {
87
+ throw new Error("wallet_reclaim_sender_not_local");
88
+ }
89
+ const senderIdentity = resolveIdentityBySelector(context, context.model.walletAddress, errorPrefix);
90
+ ensureUsableSender(senderIdentity, errorPrefix, 0n);
91
+ return {
92
+ state: context.localState.state,
93
+ sender: createFundingMutationSender(context.localState.state),
94
+ recipientDomainName,
95
+ amountCogtoshi: lock.amount,
96
+ lockId: lock.lockId,
97
+ resolved: {
98
+ sender: createResolvedSenderSummary(senderIdentity),
99
+ claimPath: "timeout-reclaim",
100
+ },
101
+ };
102
+ }
103
+ if (currentHeight >= lock.timeoutHeight) {
104
+ throw new Error("wallet_claim_lock_expired");
105
+ }
106
+ const preimage = parseHex32(preimageHex, "wallet_claim_invalid_preimage");
107
+ if (sha256Hex(preimage) !== Buffer.from(lock.condition).toString("hex")) {
108
+ throw new Error("wallet_claim_preimage_mismatch");
109
+ }
110
+ if (recipientDomain === null) {
111
+ throw new Error("wallet_claim_recipient_domain_missing");
112
+ }
113
+ const recipientOwnerHex = Buffer.from(recipientDomain.ownerScriptPubKey).toString("hex");
114
+ if (recipientOwnerHex !== context.localState.state.funding.scriptPubKeyHex || context.model.walletAddress == null) {
115
+ throw new Error("wallet_claim_sender_not_local");
116
+ }
117
+ const senderIdentity = resolveIdentityBySelector(context, context.model.walletAddress, errorPrefix);
118
+ ensureUsableSender(senderIdentity, errorPrefix, 0n);
119
+ return {
120
+ state: context.localState.state,
121
+ sender: createFundingMutationSender(context.localState.state),
122
+ recipientDomainName,
123
+ amountCogtoshi: lock.amount,
124
+ lockId: lock.lockId,
125
+ resolved: {
126
+ sender: createResolvedSenderSummary(senderIdentity),
127
+ claimPath: "recipient-claim",
128
+ },
129
+ };
130
+ }
131
+ export function parseTimeoutHeight(currentHeight, rawRelative, rawAbsolute) {
132
+ if ((rawRelative == null) === (rawAbsolute == null)) {
133
+ throw new Error("wallet_lock_timeout_requires_exactly_one_mode");
134
+ }
135
+ if (rawAbsolute != null) {
136
+ if (!Number.isInteger(rawAbsolute)) {
137
+ throw new Error("wallet_lock_invalid_timeout_height");
138
+ }
139
+ return rawAbsolute;
140
+ }
141
+ const trimmed = rawRelative.trim().toLowerCase();
142
+ let blocks;
143
+ if (/^[1-9]\d*$/.test(trimmed)) {
144
+ blocks = Number.parseInt(trimmed, 10);
145
+ }
146
+ else {
147
+ const match = /^(\d+)(m|h|d|w)$/.exec(trimmed);
148
+ if (match == null) {
149
+ throw new Error("wallet_lock_invalid_timeout_duration");
150
+ }
151
+ const value = Number.parseInt(match[1], 10);
152
+ const minutesPerUnit = match[2] === "m" ? 1
153
+ : match[2] === "h" ? 60
154
+ : match[2] === "d" ? 24 * 60
155
+ : 7 * 24 * 60;
156
+ blocks = Math.ceil((value * minutesPerUnit) / 10);
157
+ }
158
+ return currentHeight + blocks;
159
+ }
160
+ export function createSendCogOpReturnData(operation) {
161
+ return serializeCogTransfer(operation.amountCogtoshi, Buffer.from(operation.recipient.scriptPubKeyHex, "hex")).opReturnData;
162
+ }
163
+ export function createLockCogOpReturnData(operation) {
164
+ return serializeCogLock(operation.amountCogtoshi, operation.timeoutHeight, operation.recipientDomain.domainId, Buffer.from(operation.conditionHex, "hex")).opReturnData;
165
+ }
166
+ export function createClaimCogOpReturnData(operation) {
167
+ return serializeCogClaim(operation.lockId, Buffer.from(operation.preimageHex, "hex")).opReturnData;
168
+ }
169
+ export { MAX_LOCK_DURATION_BLOCKS, ZERO_PREIMAGE_HEX, };
@@ -0,0 +1,19 @@
1
+ import type { RpcDecodedPsbt, RpcListUnspentEntry } from "../../../bitcoind/types.js";
2
+ import { type MutationSender } from "../common.js";
3
+ import type { BuiltCogMutationTransaction, CogMutationPlan, WalletCogRpcClient } from "./types.js";
4
+ import type { WalletStateV1 } from "../../types.js";
5
+ export declare function buildPlanForCogOperation(options: {
6
+ state: WalletStateV1;
7
+ allUtxos: RpcListUnspentEntry[];
8
+ sender: MutationSender;
9
+ opReturnData: Uint8Array;
10
+ errorPrefix: string;
11
+ }): CogMutationPlan;
12
+ export declare function validateFundedCogDraft(decoded: RpcDecodedPsbt, funded: BuiltCogMutationTransaction["funded"], plan: CogMutationPlan): void;
13
+ export declare function buildCogTransaction(options: {
14
+ rpc: WalletCogRpcClient;
15
+ walletName: string;
16
+ state: WalletStateV1;
17
+ plan: CogMutationPlan;
18
+ feeRateSatVb: number;
19
+ }): Promise<BuiltCogMutationTransaction>;
@@ -0,0 +1,65 @@
1
+ import { buildWalletMutationTransactionWithReserveFallback, outpointKey, } from "../common.js";
2
+ function encodeOpReturnScript(payload) {
3
+ if (payload.length <= 75) {
4
+ return Buffer.concat([
5
+ Buffer.from([0x6a, payload.length]),
6
+ Buffer.from(payload),
7
+ ]).toString("hex");
8
+ }
9
+ return Buffer.concat([
10
+ Buffer.from([0x6a, 0x4c, payload.length]),
11
+ Buffer.from(payload),
12
+ ]).toString("hex");
13
+ }
14
+ export function buildPlanForCogOperation(options) {
15
+ const fundingUtxos = options.allUtxos.filter((entry) => entry.scriptPubKey === options.state.funding.scriptPubKeyHex
16
+ && entry.confirmations >= 1
17
+ && entry.spendable !== false
18
+ && entry.safe !== false);
19
+ return {
20
+ sender: options.sender,
21
+ changeAddress: options.state.funding.address,
22
+ fixedInputs: [],
23
+ outputs: [{ data: Buffer.from(options.opReturnData).toString("hex") }],
24
+ changePosition: 1,
25
+ expectedOpReturnScriptHex: encodeOpReturnScript(options.opReturnData),
26
+ allowedFundingScriptPubKeyHex: options.state.funding.scriptPubKeyHex,
27
+ eligibleFundingOutpointKeys: new Set(fundingUtxos.map((entry) => outpointKey({ txid: entry.txid, vout: entry.vout }))),
28
+ errorPrefix: options.errorPrefix,
29
+ };
30
+ }
31
+ export function validateFundedCogDraft(decoded, funded, plan) {
32
+ const inputs = decoded.tx.vin;
33
+ const outputs = decoded.tx.vout;
34
+ if (inputs.length === 0) {
35
+ throw new Error(`${plan.errorPrefix}_missing_sender_input`);
36
+ }
37
+ if (outputs[0]?.scriptPubKey?.hex !== plan.expectedOpReturnScriptHex) {
38
+ throw new Error(`${plan.errorPrefix}_opreturn_mismatch`);
39
+ }
40
+ const expectedWithoutChange = 1;
41
+ if (funded.changepos === -1) {
42
+ if (outputs.length !== expectedWithoutChange) {
43
+ throw new Error(`${plan.errorPrefix}_unexpected_output_count`);
44
+ }
45
+ return;
46
+ }
47
+ if (funded.changepos !== plan.changePosition || outputs.length !== expectedWithoutChange + 1) {
48
+ throw new Error(`${plan.errorPrefix}_change_position_mismatch`);
49
+ }
50
+ if (outputs[funded.changepos]?.scriptPubKey?.hex !== plan.allowedFundingScriptPubKeyHex) {
51
+ throw new Error(`${plan.errorPrefix}_change_output_mismatch`);
52
+ }
53
+ }
54
+ export async function buildCogTransaction(options) {
55
+ return buildWalletMutationTransactionWithReserveFallback({
56
+ rpc: options.rpc,
57
+ walletName: options.walletName,
58
+ state: options.state,
59
+ plan: options.plan,
60
+ validateFundedDraft: validateFundedCogDraft,
61
+ finalizeErrorCode: `${options.plan.errorPrefix}_finalize_failed`,
62
+ mempoolRejectPrefix: `${options.plan.errorPrefix}_mempool_rejected`,
63
+ feeRate: options.feeRateSatVb,
64
+ });
65
+ }
@@ -0,0 +1,27 @@
1
+ import type { PendingMutationRecord } from "../../types.js";
2
+ import type { WalletMutationFeeSummary } from "../common.js";
3
+ import type { CogMutationResult, CogResolvedSummary } from "./types.js";
4
+ export declare function createCogReuseResult(options: {
5
+ kind: CogMutationResult["kind"];
6
+ mutation: PendingMutationRecord;
7
+ resolution: "confirmed" | "live";
8
+ fees: WalletMutationFeeSummary;
9
+ amountCogtoshi?: bigint;
10
+ recipientScriptPubKeyHex?: string | null;
11
+ recipientDomainName?: string | null;
12
+ lockId?: number | null;
13
+ resolved: CogResolvedSummary;
14
+ }): CogMutationResult;
15
+ export declare function createCogResult(options: {
16
+ kind: CogMutationResult["kind"];
17
+ mutation: PendingMutationRecord;
18
+ builtTxid: string | null;
19
+ status: "live" | "confirmed";
20
+ reusedExisting: boolean;
21
+ fees: WalletMutationFeeSummary;
22
+ amountCogtoshi?: bigint;
23
+ recipientScriptPubKeyHex?: string | null;
24
+ recipientDomainName?: string | null;
25
+ lockId?: number | null;
26
+ resolved: CogResolvedSummary;
27
+ }): CogMutationResult;
@@ -0,0 +1,28 @@
1
+ export function createCogReuseResult(options) {
2
+ return {
3
+ kind: options.kind,
4
+ txid: options.mutation.attemptedTxid ?? "unknown",
5
+ status: options.resolution,
6
+ reusedExisting: true,
7
+ amountCogtoshi: options.amountCogtoshi,
8
+ recipientScriptPubKeyHex: options.recipientScriptPubKeyHex,
9
+ recipientDomainName: options.recipientDomainName,
10
+ lockId: options.lockId,
11
+ resolved: options.resolved,
12
+ fees: options.fees,
13
+ };
14
+ }
15
+ export function createCogResult(options) {
16
+ return {
17
+ kind: options.kind,
18
+ txid: options.mutation.attemptedTxid ?? options.builtTxid ?? "unknown",
19
+ status: options.status,
20
+ reusedExisting: options.reusedExisting,
21
+ amountCogtoshi: options.amountCogtoshi,
22
+ recipientScriptPubKeyHex: options.recipientScriptPubKeyHex,
23
+ recipientDomainName: options.recipientDomainName,
24
+ lockId: options.lockId,
25
+ resolved: options.resolved,
26
+ fees: options.fees,
27
+ };
28
+ }
@@ -0,0 +1,186 @@
1
+ import type { lookupDomain } from "@cogcoin/indexer/queries";
2
+ import type { RpcTransaction } from "../../../bitcoind/types.js";
3
+ import type { WalletPrompter } from "../../lifecycle.js";
4
+ import type { WalletReadContext } from "../../read/index.js";
5
+ import type { WalletRuntimePaths } from "../../runtime.js";
6
+ import type { WalletSecretProvider } from "../../state/provider.js";
7
+ import type { PendingMutationRecord, WalletStateV1 } from "../../types.js";
8
+ import type { BuiltWalletMutationTransaction, FixedWalletInput, MutationSender, WalletMutationFeeSummary, WalletMutationRpcClient } from "../common.js";
9
+ export declare const MAX_LOCK_DURATION_BLOCKS = 262800;
10
+ export declare const ZERO_PREIMAGE_HEX: string;
11
+ export type CogMutationKind = "send" | "lock" | "claim";
12
+ export interface WalletCogRpcClient extends WalletMutationRpcClient {
13
+ getBlockchainInfo(): Promise<{
14
+ blocks: number;
15
+ }>;
16
+ sendRawTransaction(hex: string): Promise<string>;
17
+ getRawTransaction(txid: string, verbose?: boolean): Promise<RpcTransaction>;
18
+ }
19
+ export interface CogMutationPlan {
20
+ sender: MutationSender;
21
+ changeAddress: string;
22
+ fixedInputs: FixedWalletInput[];
23
+ outputs: unknown[];
24
+ changePosition: number;
25
+ expectedOpReturnScriptHex: string;
26
+ allowedFundingScriptPubKeyHex: string;
27
+ eligibleFundingOutpointKeys: Set<string>;
28
+ errorPrefix: string;
29
+ }
30
+ export type BuiltCogMutationTransaction = BuiltWalletMutationTransaction;
31
+ export interface SendCogOperation {
32
+ state: WalletStateV1;
33
+ sender: MutationSender;
34
+ resolved: CogResolvedSummary;
35
+ amountCogtoshi: bigint;
36
+ recipient: ReturnType<typeof import("../targets.js").normalizeBtcTarget>;
37
+ }
38
+ export interface LockCogMutationOperation {
39
+ state: WalletStateV1;
40
+ sender: MutationSender;
41
+ resolved: CogResolvedSummary;
42
+ amountCogtoshi: bigint;
43
+ normalizedRecipientDomainName: string;
44
+ recipientDomain: NonNullable<ReturnType<typeof lookupDomain>>;
45
+ timeoutHeight: number;
46
+ conditionHex: string;
47
+ }
48
+ export interface ClaimCogMutationOperation {
49
+ state: WalletStateV1;
50
+ sender: MutationSender;
51
+ resolved: CogResolvedSummary;
52
+ amountCogtoshi: bigint;
53
+ recipientDomainName: string | null;
54
+ lockId: number;
55
+ preimageHex: string;
56
+ errorPrefix: string;
57
+ }
58
+ export type CogMutationOperation = SendCogOperation | LockCogMutationOperation | ClaimCogMutationOperation;
59
+ export type CogResolvedClaimPath = "recipient-claim" | "timeout-reclaim";
60
+ export interface CogResolvedSenderSummary {
61
+ selector: string;
62
+ localIndex: number;
63
+ scriptPubKeyHex: string;
64
+ address: string;
65
+ }
66
+ export interface CogResolvedSummary {
67
+ sender: CogResolvedSenderSummary;
68
+ claimPath: CogResolvedClaimPath | null;
69
+ }
70
+ export interface CogMutationResult {
71
+ kind: CogMutationKind;
72
+ txid: string;
73
+ status: "live" | "confirmed";
74
+ reusedExisting: boolean;
75
+ amountCogtoshi?: bigint;
76
+ recipientScriptPubKeyHex?: string | null;
77
+ recipientDomainName?: string | null;
78
+ lockId?: number | null;
79
+ resolved: CogResolvedSummary;
80
+ fees: WalletMutationFeeSummary;
81
+ }
82
+ export interface SendCogOptions {
83
+ amountCogtoshi: bigint;
84
+ target: string;
85
+ fromIdentity?: string | null;
86
+ feeRateSatVb?: number | null;
87
+ dataDir: string;
88
+ databasePath: string;
89
+ provider?: WalletSecretProvider;
90
+ prompter: WalletPrompter;
91
+ assumeYes?: boolean;
92
+ nowUnixMs?: number;
93
+ paths?: WalletRuntimePaths;
94
+ openReadContext?: typeof import("../../read/index.js").openWalletReadContext;
95
+ attachService?: typeof import("../../../bitcoind/service.js").attachOrStartManagedBitcoindService;
96
+ rpcFactory?: (config: Parameters<typeof import("../../../bitcoind/node.js").createRpcClient>[0]) => WalletCogRpcClient;
97
+ }
98
+ export interface LockCogToDomainOptions {
99
+ amountCogtoshi: bigint;
100
+ recipientDomainName: string;
101
+ fromIdentity?: string | null;
102
+ feeRateSatVb?: number | null;
103
+ timeoutHeight?: number | null;
104
+ timeoutBlocksOrDuration?: string | null;
105
+ conditionHex: string;
106
+ dataDir: string;
107
+ databasePath: string;
108
+ provider?: WalletSecretProvider;
109
+ prompter: WalletPrompter;
110
+ assumeYes?: boolean;
111
+ nowUnixMs?: number;
112
+ paths?: WalletRuntimePaths;
113
+ openReadContext?: typeof import("../../read/index.js").openWalletReadContext;
114
+ attachService?: typeof import("../../../bitcoind/service.js").attachOrStartManagedBitcoindService;
115
+ rpcFactory?: (config: Parameters<typeof import("../../../bitcoind/node.js").createRpcClient>[0]) => WalletCogRpcClient;
116
+ }
117
+ export interface ClaimCogLockOptions {
118
+ lockId: number;
119
+ preimageHex: string;
120
+ feeRateSatVb?: number | null;
121
+ dataDir: string;
122
+ databasePath: string;
123
+ provider?: WalletSecretProvider;
124
+ prompter: WalletPrompter;
125
+ assumeYes?: boolean;
126
+ nowUnixMs?: number;
127
+ paths?: WalletRuntimePaths;
128
+ openReadContext?: typeof import("../../read/index.js").openWalletReadContext;
129
+ attachService?: typeof import("../../../bitcoind/service.js").attachOrStartManagedBitcoindService;
130
+ rpcFactory?: (config: Parameters<typeof import("../../../bitcoind/node.js").createRpcClient>[0]) => WalletCogRpcClient;
131
+ }
132
+ export interface ReclaimCogLockOptions extends Omit<ClaimCogLockOptions, "preimageHex"> {
133
+ }
134
+ export interface CogDraftMutationOptions {
135
+ kind: CogMutationKind;
136
+ sender: MutationSender;
137
+ intentFingerprintHex: string;
138
+ nowUnixMs: number;
139
+ feeSelection: {
140
+ feeRateSatVb: number;
141
+ source: "custom-satvb" | "estimated-next-block-plus-one" | "fallback-default";
142
+ };
143
+ domainName?: string | null;
144
+ recipientScriptPubKeyHex?: string | null;
145
+ recipientDomainName?: string | null;
146
+ amountCogtoshi?: bigint | null;
147
+ timeoutHeight?: number | null;
148
+ conditionHex?: string | null;
149
+ lockId?: number | null;
150
+ preimageHex?: string | null;
151
+ existing?: PendingMutationRecord | null;
152
+ }
153
+ export interface CogMutationVariant<TOperation extends CogMutationOperation> {
154
+ controlLockPurpose: string;
155
+ preemptionReason: string;
156
+ errorPrefix: string;
157
+ repairRequiredErrorCode: string;
158
+ resolveOperation(readContext: WalletReadContext): TOperation;
159
+ createIntentFingerprint(operation: TOperation): string;
160
+ confirm(operation: TOperation): Promise<void>;
161
+ createDraftMutation(options: {
162
+ operation: TOperation;
163
+ existingMutation: PendingMutationRecord | null;
164
+ feeSelection: {
165
+ feeRateSatVb: number;
166
+ source: "custom-satvb" | "estimated-next-block-plus-one" | "fallback-default";
167
+ };
168
+ intentFingerprintHex: string;
169
+ nowUnixMs: number;
170
+ }): PendingMutationRecord;
171
+ createOpReturnData(operation: TOperation): Uint8Array;
172
+ createReuseResult(options: {
173
+ operation: TOperation;
174
+ mutation: PendingMutationRecord;
175
+ resolution: "confirmed" | "live";
176
+ fees: WalletMutationFeeSummary;
177
+ }): CogMutationResult;
178
+ createResult(options: {
179
+ operation: TOperation;
180
+ mutation: PendingMutationRecord;
181
+ builtTxid: string | null;
182
+ status: "live" | "confirmed";
183
+ reusedExisting: boolean;
184
+ fees: WalletMutationFeeSummary;
185
+ }): CogMutationResult;
186
+ }
@@ -0,0 +1,2 @@
1
+ export const MAX_LOCK_DURATION_BLOCKS = 262_800;
2
+ export const ZERO_PREIMAGE_HEX = "00".repeat(32);
@@ -0,0 +1,3 @@
1
+ import type { ClaimCogLockOptions, ClaimCogMutationOperation, CogMutationVariant, ReclaimCogLockOptions } from "../types.js";
2
+ export declare function createClaimCogVariant(options: ClaimCogLockOptions): CogMutationVariant<ClaimCogMutationOperation>;
3
+ export declare function createReclaimCogVariant(options: ReclaimCogLockOptions): CogMutationVariant<ClaimCogMutationOperation>;