@babylonlabs-io/ts-sdk 0.33.3 → 0.33.5

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 (153) hide show
  1. package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js +417 -0
  2. package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js.map +1 -0
  3. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs +2 -0
  4. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs.map +1 -0
  5. package/dist/PayoutManager-C9XHKZ5j.js +200 -0
  6. package/dist/PayoutManager-C9XHKZ5j.js.map +1 -0
  7. package/dist/PayoutManager-DDnNB0mj.cjs +2 -0
  8. package/dist/PayoutManager-DDnNB0mj.cjs.map +1 -0
  9. package/dist/PeginManager-BXg2S1mH.cjs +2 -0
  10. package/dist/PeginManager-BXg2S1mH.cjs.map +1 -0
  11. package/dist/{PeginManager-C-L3huRO.js → PeginManager-C5HaMAcw.js} +328 -437
  12. package/dist/PeginManager-C5HaMAcw.js.map +1 -0
  13. package/dist/ProtocolParams.abi-BmvHwQJV.cjs +2 -0
  14. package/dist/ProtocolParams.abi-BmvHwQJV.cjs.map +1 -0
  15. package/dist/ProtocolParams.abi-DXu8L0Fn.js +382 -0
  16. package/dist/ProtocolParams.abi-DXu8L0Fn.js.map +1 -0
  17. package/dist/buildAndBroadcastRefund-B332dykQ.cjs +2 -0
  18. package/dist/buildAndBroadcastRefund-B332dykQ.cjs.map +1 -0
  19. package/dist/buildAndBroadcastRefund-CPjXNaMi.js +782 -0
  20. package/dist/buildAndBroadcastRefund-CPjXNaMi.js.map +1 -0
  21. package/dist/challengeAssert-BzxQmdZy.js +128 -0
  22. package/dist/challengeAssert-BzxQmdZy.js.map +1 -0
  23. package/dist/challengeAssert-Yyyj-EdR.cjs +2 -0
  24. package/dist/challengeAssert-Yyyj-EdR.cjs.map +1 -0
  25. package/dist/errors-9AkghWyk.js +22 -0
  26. package/dist/errors-9AkghWyk.js.map +1 -0
  27. package/dist/errors-BP73_stm.cjs +2 -0
  28. package/dist/errors-BP73_stm.cjs.map +1 -0
  29. package/dist/errors-Bu0H-dZD.cjs +2 -0
  30. package/dist/errors-Bu0H-dZD.cjs.map +1 -0
  31. package/dist/errors-CznAK5NB.js +96 -0
  32. package/dist/errors-CznAK5NB.js.map +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +159 -147
  35. package/dist/index.js.map +1 -1
  36. package/dist/mempoolApi-CAIge7Nj.js +205 -0
  37. package/dist/mempoolApi-CAIge7Nj.js.map +1 -0
  38. package/dist/mempoolApi-YNkKjQCU.cjs +2 -0
  39. package/dist/mempoolApi-YNkKjQCU.cjs.map +1 -0
  40. package/dist/noPayout-BXeUw0Qq.cjs +2 -0
  41. package/dist/noPayout-BXeUw0Qq.cjs.map +1 -0
  42. package/dist/noPayout-DBX6G96_.js +141 -0
  43. package/dist/noPayout-DBX6G96_.js.map +1 -0
  44. package/dist/payout-BNFMBXS6.js +193 -0
  45. package/dist/payout-BNFMBXS6.js.map +1 -0
  46. package/dist/payout-DQ_fmJUA.cjs +2 -0
  47. package/dist/payout-DQ_fmJUA.cjs.map +1 -0
  48. package/dist/peginInput-C2QPvuhR.js +177 -0
  49. package/dist/peginInput-C2QPvuhR.js.map +1 -0
  50. package/dist/peginInput-tbw9BpZy.cjs +2 -0
  51. package/dist/peginInput-tbw9BpZy.cjs.map +1 -0
  52. package/dist/peginState-BijNNT15.cjs +2 -0
  53. package/dist/peginState-BijNNT15.cjs.map +1 -0
  54. package/dist/peginState-CBAlxgXk.js +51 -0
  55. package/dist/peginState-CBAlxgXk.js.map +1 -0
  56. package/dist/psbtInputFields-2224j2ZY.js +128 -0
  57. package/dist/psbtInputFields-2224j2ZY.js.map +1 -0
  58. package/dist/psbtInputFields-B1lrwYzH.cjs +2 -0
  59. package/dist/psbtInputFields-B1lrwYzH.cjs.map +1 -0
  60. package/dist/reservation-CHUGW0F_.js +142 -0
  61. package/dist/reservation-CHUGW0F_.js.map +1 -0
  62. package/dist/reservation-ho7mjW3X.cjs +2 -0
  63. package/dist/reservation-ho7mjW3X.cjs.map +1 -0
  64. package/dist/signing-Bnsro0hE.cjs +2 -0
  65. package/dist/signing-Bnsro0hE.cjs.map +1 -0
  66. package/dist/signing-DaLvGwQe.js +16 -0
  67. package/dist/signing-DaLvGwQe.js.map +1 -0
  68. package/dist/tbv/core/clients/index.cjs +1 -1
  69. package/dist/tbv/core/clients/index.js +35 -32
  70. package/dist/tbv/core/clients/index.js.map +1 -1
  71. package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts +2 -0
  72. package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts.map +1 -0
  73. package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts +2 -0
  74. package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts.map +1 -0
  75. package/dist/tbv/core/clients/vault-provider/api.d.ts +13 -4
  76. package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
  77. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts +45 -0
  78. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts.map +1 -0
  79. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts +55 -0
  80. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts.map +1 -0
  81. package/dist/tbv/core/clients/vault-provider/index.d.ts +2 -0
  82. package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
  83. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +3 -3
  84. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  85. package/dist/tbv/core/clients/vault-provider/types.d.ts +68 -24
  86. package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
  87. package/dist/tbv/core/clients/vault-provider/validators.d.ts +12 -2
  88. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  89. package/dist/tbv/core/contracts/index.cjs +2 -0
  90. package/dist/tbv/core/contracts/index.cjs.map +1 -0
  91. package/dist/tbv/core/contracts/index.js +14 -0
  92. package/dist/tbv/core/contracts/index.js.map +1 -0
  93. package/dist/tbv/core/index.cjs +1 -1
  94. package/dist/tbv/core/index.js +157 -145
  95. package/dist/tbv/core/index.js.map +1 -1
  96. package/dist/tbv/core/managers/index.cjs +2 -0
  97. package/dist/tbv/core/managers/index.cjs.map +1 -0
  98. package/dist/tbv/core/managers/index.js +7 -0
  99. package/dist/tbv/core/managers/index.js.map +1 -0
  100. package/dist/tbv/core/primitives/index.cjs +1 -1
  101. package/dist/tbv/core/primitives/index.js +31 -29
  102. package/dist/tbv/core/primitives/index.js.map +1 -1
  103. package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -1
  104. package/dist/tbv/core/services/index.cjs +1 -1
  105. package/dist/tbv/core/services/index.js +28 -27
  106. package/dist/tbv/core/services/index.js.map +1 -1
  107. package/dist/tbv/core/services/pegout/state.d.ts +1 -1
  108. package/dist/tbv/core/utils/index.cjs +1 -1
  109. package/dist/tbv/core/utils/index.js +21 -20
  110. package/dist/tbv/core/utils/index.js.map +1 -1
  111. package/dist/tbv/index.cjs +1 -1
  112. package/dist/tbv/index.js +157 -145
  113. package/dist/tbv/index.js.map +1 -1
  114. package/dist/types-DnyyBNcC.cjs +2 -0
  115. package/dist/types-DnyyBNcC.cjs.map +1 -0
  116. package/dist/types-TiIjyo2b.js +320 -0
  117. package/dist/types-TiIjyo2b.js.map +1 -0
  118. package/dist/vault-registry-reader-BDFpXeH7.js +1152 -0
  119. package/dist/vault-registry-reader-BDFpXeH7.js.map +1 -0
  120. package/dist/vault-registry-reader-ejm2UYzk.cjs +2 -0
  121. package/dist/vault-registry-reader-ejm2UYzk.cjs.map +1 -0
  122. package/package.json +11 -1
  123. package/dist/PeginManager-C-L3huRO.js.map +0 -1
  124. package/dist/PeginManager-DmPmzPHz.cjs +0 -2
  125. package/dist/PeginManager-DmPmzPHz.cjs.map +0 -1
  126. package/dist/buildAndBroadcastRefund-Dx09Zbla.js +0 -965
  127. package/dist/buildAndBroadcastRefund-Dx09Zbla.js.map +0 -1
  128. package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs +0 -2
  129. package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs.map +0 -1
  130. package/dist/challengeAssert-D3tHnLWb.js +0 -298
  131. package/dist/challengeAssert-D3tHnLWb.js.map +0 -1
  132. package/dist/challengeAssert-Dp9d1bg1.cjs +0 -2
  133. package/dist/challengeAssert-Dp9d1bg1.cjs.map +0 -1
  134. package/dist/noPayout-BnsetBKW.js +0 -327
  135. package/dist/noPayout-BnsetBKW.js.map +0 -1
  136. package/dist/noPayout-DWaCtpMU.cjs +0 -2
  137. package/dist/noPayout-DWaCtpMU.cjs.map +0 -1
  138. package/dist/psbtInputFields-6sRcZqdb.cjs +0 -2
  139. package/dist/psbtInputFields-6sRcZqdb.cjs.map +0 -1
  140. package/dist/psbtInputFields-C5QPn1YK.js +0 -264
  141. package/dist/psbtInputFields-C5QPn1YK.js.map +0 -1
  142. package/dist/signing-BZigafm0.js +0 -64
  143. package/dist/signing-BZigafm0.js.map +0 -1
  144. package/dist/signing-DHSXjhLM.cjs +0 -2
  145. package/dist/signing-DHSXjhLM.cjs.map +0 -1
  146. package/dist/types-PthVHz5q.cjs +0 -2
  147. package/dist/types-PthVHz5q.cjs.map +0 -1
  148. package/dist/types-SYvSQWnc.js +0 -732
  149. package/dist/types-SYvSQWnc.js.map +0 -1
  150. package/dist/vault-registry-reader-CKe9TbX6.cjs +0 -2
  151. package/dist/vault-registry-reader-CKe9TbX6.cjs.map +0 -1
  152. package/dist/vault-registry-reader-CWGbw_wZ.js +0 -1567
  153. package/dist/vault-registry-reader-CWGbw_wZ.js.map +0 -1
@@ -0,0 +1,382 @@
1
+ const e = [
2
+ {
3
+ type: "function",
4
+ name: "getVaultKeepersByVersion",
5
+ inputs: [
6
+ {
7
+ name: "appEntryPoint",
8
+ type: "address",
9
+ internalType: "address"
10
+ },
11
+ {
12
+ name: "versionNumber",
13
+ type: "uint16",
14
+ internalType: "uint16"
15
+ }
16
+ ],
17
+ outputs: [
18
+ {
19
+ name: "",
20
+ type: "tuple[]",
21
+ internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
22
+ components: [
23
+ {
24
+ name: "ethAddress",
25
+ type: "address",
26
+ internalType: "address"
27
+ },
28
+ {
29
+ name: "btcPubKey",
30
+ type: "bytes32",
31
+ internalType: "bytes32"
32
+ }
33
+ ]
34
+ }
35
+ ],
36
+ stateMutability: "view"
37
+ },
38
+ {
39
+ type: "function",
40
+ name: "getCurrentVaultKeepers",
41
+ inputs: [
42
+ {
43
+ name: "appEntryPoint",
44
+ type: "address",
45
+ internalType: "address"
46
+ }
47
+ ],
48
+ outputs: [
49
+ {
50
+ name: "",
51
+ type: "tuple[]",
52
+ internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
53
+ components: [
54
+ {
55
+ name: "ethAddress",
56
+ type: "address",
57
+ internalType: "address"
58
+ },
59
+ {
60
+ name: "btcPubKey",
61
+ type: "bytes32",
62
+ internalType: "bytes32"
63
+ }
64
+ ]
65
+ }
66
+ ],
67
+ stateMutability: "view"
68
+ },
69
+ {
70
+ type: "function",
71
+ name: "getCurrentVaultKeepersVersion",
72
+ inputs: [
73
+ {
74
+ name: "appEntryPoint",
75
+ type: "address",
76
+ internalType: "address"
77
+ }
78
+ ],
79
+ outputs: [
80
+ {
81
+ name: "",
82
+ type: "uint16",
83
+ internalType: "uint16"
84
+ }
85
+ ],
86
+ stateMutability: "view"
87
+ }
88
+ ], t = [
89
+ {
90
+ type: "function",
91
+ name: "getTBVProtocolParams",
92
+ inputs: [],
93
+ outputs: [
94
+ {
95
+ name: "",
96
+ type: "tuple",
97
+ internalType: "struct IProtocolParams.TBVProtocolParams",
98
+ components: [
99
+ {
100
+ name: "minimumPegInAmount",
101
+ type: "uint64",
102
+ internalType: "uint64"
103
+ },
104
+ {
105
+ name: "maxPegInAmount",
106
+ type: "uint64",
107
+ internalType: "uint64"
108
+ },
109
+ {
110
+ name: "pegInAckTimeout",
111
+ type: "uint64",
112
+ internalType: "uint64"
113
+ },
114
+ {
115
+ name: "pegInActivationTimeout",
116
+ type: "uint64",
117
+ internalType: "uint64"
118
+ },
119
+ {
120
+ name: "maxHtlcOutputCount",
121
+ type: "uint8",
122
+ internalType: "uint8"
123
+ }
124
+ ]
125
+ }
126
+ ],
127
+ stateMutability: "view"
128
+ },
129
+ {
130
+ type: "function",
131
+ name: "getLatestOffchainParams",
132
+ inputs: [],
133
+ outputs: [
134
+ {
135
+ name: "",
136
+ type: "tuple",
137
+ internalType: "struct IProtocolParams.VersionedOffchainParams",
138
+ components: [
139
+ {
140
+ name: "timelockAssert",
141
+ type: "uint256",
142
+ internalType: "uint256"
143
+ },
144
+ {
145
+ name: "timelockChallengeAssert",
146
+ type: "uint256",
147
+ internalType: "uint256"
148
+ },
149
+ {
150
+ name: "securityCouncilKeys",
151
+ type: "bytes32[]",
152
+ internalType: "bytes32[]"
153
+ },
154
+ {
155
+ name: "councilQuorum",
156
+ type: "uint8",
157
+ internalType: "uint8"
158
+ },
159
+ {
160
+ name: "feeRate",
161
+ type: "uint64",
162
+ internalType: "uint64"
163
+ },
164
+ {
165
+ name: "babeTotalInstances",
166
+ type: "uint16",
167
+ internalType: "uint16"
168
+ },
169
+ {
170
+ name: "babeInstancesToFinalize",
171
+ type: "uint8",
172
+ internalType: "uint8"
173
+ },
174
+ {
175
+ name: "minVpCommissionBps",
176
+ type: "uint16",
177
+ internalType: "uint16"
178
+ },
179
+ {
180
+ name: "tRefund",
181
+ type: "uint32",
182
+ internalType: "uint32"
183
+ },
184
+ {
185
+ name: "tStale",
186
+ type: "uint32",
187
+ internalType: "uint32"
188
+ },
189
+ {
190
+ name: "minPeginFeeRate",
191
+ type: "uint64",
192
+ internalType: "uint64"
193
+ },
194
+ {
195
+ name: "proverProgramVersion",
196
+ type: "uint16",
197
+ internalType: "uint16"
198
+ },
199
+ {
200
+ name: "minPrepeginDepth",
201
+ type: "uint32",
202
+ internalType: "uint32"
203
+ }
204
+ ]
205
+ }
206
+ ],
207
+ stateMutability: "view"
208
+ },
209
+ {
210
+ type: "function",
211
+ name: "getOffchainParamsByVersion",
212
+ inputs: [
213
+ {
214
+ name: "versionNumber",
215
+ type: "uint16",
216
+ internalType: "uint16"
217
+ }
218
+ ],
219
+ outputs: [
220
+ {
221
+ name: "",
222
+ type: "tuple",
223
+ internalType: "struct IProtocolParams.VersionedOffchainParams",
224
+ components: [
225
+ {
226
+ name: "timelockAssert",
227
+ type: "uint256",
228
+ internalType: "uint256"
229
+ },
230
+ {
231
+ name: "timelockChallengeAssert",
232
+ type: "uint256",
233
+ internalType: "uint256"
234
+ },
235
+ {
236
+ name: "securityCouncilKeys",
237
+ type: "bytes32[]",
238
+ internalType: "bytes32[]"
239
+ },
240
+ {
241
+ name: "councilQuorum",
242
+ type: "uint8",
243
+ internalType: "uint8"
244
+ },
245
+ {
246
+ name: "feeRate",
247
+ type: "uint64",
248
+ internalType: "uint64"
249
+ },
250
+ {
251
+ name: "babeTotalInstances",
252
+ type: "uint16",
253
+ internalType: "uint16"
254
+ },
255
+ {
256
+ name: "babeInstancesToFinalize",
257
+ type: "uint8",
258
+ internalType: "uint8"
259
+ },
260
+ {
261
+ name: "minVpCommissionBps",
262
+ type: "uint16",
263
+ internalType: "uint16"
264
+ },
265
+ {
266
+ name: "tRefund",
267
+ type: "uint32",
268
+ internalType: "uint32"
269
+ },
270
+ {
271
+ name: "tStale",
272
+ type: "uint32",
273
+ internalType: "uint32"
274
+ },
275
+ {
276
+ name: "minPeginFeeRate",
277
+ type: "uint64",
278
+ internalType: "uint64"
279
+ },
280
+ {
281
+ name: "proverProgramVersion",
282
+ type: "uint16",
283
+ internalType: "uint16"
284
+ },
285
+ {
286
+ name: "minPrepeginDepth",
287
+ type: "uint32",
288
+ internalType: "uint32"
289
+ }
290
+ ]
291
+ }
292
+ ],
293
+ stateMutability: "view"
294
+ },
295
+ {
296
+ type: "function",
297
+ name: "latestOffchainParamsVersion",
298
+ inputs: [],
299
+ outputs: [
300
+ {
301
+ name: "",
302
+ type: "uint16",
303
+ internalType: "uint16"
304
+ }
305
+ ],
306
+ stateMutability: "view"
307
+ },
308
+ {
309
+ type: "function",
310
+ name: "getUniversalChallengersByVersion",
311
+ inputs: [
312
+ {
313
+ name: "versionNumber",
314
+ type: "uint16",
315
+ internalType: "uint16"
316
+ }
317
+ ],
318
+ outputs: [
319
+ {
320
+ name: "",
321
+ type: "tuple[]",
322
+ internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
323
+ components: [
324
+ {
325
+ name: "ethAddress",
326
+ type: "address",
327
+ internalType: "address"
328
+ },
329
+ {
330
+ name: "btcPubKey",
331
+ type: "bytes32",
332
+ internalType: "bytes32"
333
+ }
334
+ ]
335
+ }
336
+ ],
337
+ stateMutability: "view"
338
+ },
339
+ {
340
+ type: "function",
341
+ name: "getCurrentUniversalChallengers",
342
+ inputs: [],
343
+ outputs: [
344
+ {
345
+ name: "",
346
+ type: "tuple[]",
347
+ internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
348
+ components: [
349
+ {
350
+ name: "ethAddress",
351
+ type: "address",
352
+ internalType: "address"
353
+ },
354
+ {
355
+ name: "btcPubKey",
356
+ type: "bytes32",
357
+ internalType: "bytes32"
358
+ }
359
+ ]
360
+ }
361
+ ],
362
+ stateMutability: "view"
363
+ },
364
+ {
365
+ type: "function",
366
+ name: "latestUniversalChallengersVersion",
367
+ inputs: [],
368
+ outputs: [
369
+ {
370
+ name: "",
371
+ type: "uint16",
372
+ internalType: "uint16"
373
+ }
374
+ ],
375
+ stateMutability: "view"
376
+ }
377
+ ];
378
+ export {
379
+ e as A,
380
+ t as P
381
+ };
382
+ //# sourceMappingURL=ProtocolParams.abi-DXu8L0Fn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProtocolParams.abi-DXu8L0Fn.js","sources":["../src/tbv/core/contracts/abis/ApplicationRegistry.abi.ts","../src/tbv/core/contracts/abis/ProtocolParams.abi.ts"],"sourcesContent":["/**\n * ApplicationRegistry Contract ABI\n *\n * Minimal ABI containing only the vault keeper read functions needed by the SDK.\n * Generated from vault-contracts-aave-v4 IApplicationRegistry.sol interface.\n *\n * @module contracts/abis/ApplicationRegistry\n */\n\nexport const ApplicationRegistryABI = [\n {\n type: \"function\",\n name: \"getVaultKeepersByVersion\",\n inputs: [\n {\n name: \"appEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"versionNumber\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getCurrentVaultKeepers\",\n inputs: [\n {\n name: \"appEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getCurrentVaultKeepersVersion\",\n inputs: [\n {\n name: \"appEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n stateMutability: \"view\",\n },\n] as const;\n","/**\n * ProtocolParams Contract ABI\n *\n * Minimal ABI containing only the read functions needed by the SDK.\n * Generated from vault-contracts-aave-v4 IProtocolParams.sol interface.\n *\n * @module contracts/abis/ProtocolParams\n */\n\nexport const ProtocolParamsABI = [\n {\n type: \"function\",\n name: \"getTBVProtocolParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct IProtocolParams.TBVProtocolParams\",\n components: [\n {\n name: \"minimumPegInAmount\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"maxPegInAmount\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"pegInAckTimeout\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"pegInActivationTimeout\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"maxHtlcOutputCount\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getLatestOffchainParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct IProtocolParams.VersionedOffchainParams\",\n components: [\n {\n name: \"timelockAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"timelockChallengeAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"securityCouncilKeys\",\n type: \"bytes32[]\",\n internalType: \"bytes32[]\",\n },\n {\n name: \"councilQuorum\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"feeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"babeTotalInstances\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"babeInstancesToFinalize\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"minVpCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"tRefund\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"tStale\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"minPeginFeeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"proverProgramVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"minPrepeginDepth\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getOffchainParamsByVersion\",\n inputs: [\n {\n name: \"versionNumber\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct IProtocolParams.VersionedOffchainParams\",\n components: [\n {\n name: \"timelockAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"timelockChallengeAssert\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"securityCouncilKeys\",\n type: \"bytes32[]\",\n internalType: \"bytes32[]\",\n },\n {\n name: \"councilQuorum\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"feeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"babeTotalInstances\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"babeInstancesToFinalize\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"minVpCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"tRefund\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"tStale\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"minPeginFeeRate\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"proverProgramVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"minPrepeginDepth\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"latestOffchainParamsVersion\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getUniversalChallengersByVersion\",\n inputs: [\n {\n name: \"versionNumber\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getCurrentUniversalChallengers\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultTypes.AddressBTCKeyPair[]\",\n components: [\n {\n name: \"ethAddress\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"btcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"latestUniversalChallengersVersion\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n stateMutability: \"view\",\n },\n] as const;\n"],"names":["ApplicationRegistryABI","ProtocolParamsABI"],"mappings":"AASO,MAAMA,IAAyB;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,IAChB;AAAA,IAEF,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,QACd,YAAY;AAAA,UACV;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AA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A,UAAA;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEF,iBAAiB;AAAA,EAAA;AAAA,EAEnB;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ,CAAA;AAAA,IACR,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,IAChB;AAAA,IAEF,iBAAiB;AAAA,EAAA;AAErB;"}
@@ -0,0 +1,2 @@
1
+ "use strict";var U=Object.defineProperty;var X=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var w=(e,t,r)=>X(e,typeof t!="symbol"?t+"":t,r);const z=require("./BTCVaultRegistry.abi-ZdPpION2.cjs"),c=require("./bitcoin-B3aqjuMP.cjs"),$=require("./PayoutManager-DDnNB0mj.cjs"),p=require("./types-DnyyBNcC.cjs"),P=require("bitcoinjs-lib"),q=require("buffer"),k=require("./noPayout-BXeUw0Qq.cjs"),b=require("./payout-DQ_fmJUA.cjs"),E=require("./signing-Bnsro0hE.cjs");function G(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const W=G(P),Q=/^0x[0-9a-fA-F]{64}$/,Y=/^0x[0-9a-fA-F]{40}$/,j=/^0x([0-9a-fA-F]{2})*$/;function v(e,t){if(e.length!==66)throw new Error(`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`);if(!Q.test(e))throw new Error(`${t} must contain only hex characters after the 0x prefix`)}function Z(e,t){if(!Y.test(e))throw new Error(`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`)}function J(e,t){if(!j.test(e))throw new Error(`${t} must be a 0x-prefixed hex string with an even number of hex chars`)}async function ee(e){const{btcVaultRegistryAddress:t,vaultId:r,hashlock:o,activationMetadata:s,writeContract:u,signal:n}=e;n==null||n.throwIfAborted(),Z(t,"btcVaultRegistryAddress"),v(r,"vaultId");const a=c.ensureHexPrefix(e.secret);if(v(a,"secret"),o!==void 0&&(v(o,"hashlock"),!$.validateSecretAgainstHashlock(a,o)))throw new Error("Invalid secret: SHA256(secret) does not match the provided hashlock");return J(s,"activationMetadata"),u({address:t,abi:z.BTCVaultRegistryABI,functionName:"activateVaultWithSecret",args:[r,a,s]})}const te=1e4;async function _(e){const{statusReader:t,peginTxid:r,targetStatuses:o,timeoutMs:s,pollIntervalMs:u=te,signal:n}=e,a=Date.now();for(;;){if(n!=null&&n.aborted)throw new Error(`Polling aborted for pegin ${r.slice(0,8)}… (target: ${[...o].join(", ")})`);if(Date.now()-a>=s)throw new Error(`Polling timeout after ${s}ms for pegin ${r.slice(0,8)}… (target: ${[...o].join(", ")})`);try{const i=await t.getPeginStatus({pegin_txid:r},n);if(i.pegin_txid.toLowerCase()!==r.toLowerCase())throw new Error(`getPeginStatus returned status for pegin ${i.pegin_txid.slice(0,8)}…, requested ${r.slice(0,8)}…`);const l=i.status;if(o.has(l))return l;if(p.VP_TERMINAL_STATUSES.has(l)&&!o.has(l))throw new Error(`Pegin ${r.slice(0,8)}… reached terminal status "${l}" while waiting for ${[...o].join(", ")}`)}catch(i){if(!(i instanceof p.JsonRpcError&&i.code===p.RpcErrorCode.NOT_FOUND||i instanceof Error&&i.message.includes("PegIn not found")))throw i}await new Promise((i,l)=>{const f=()=>{clearTimeout(d),l(new Error(`Polling aborted for pegin ${r.slice(0,8)}… (target: ${[...o].join(", ")})`))},d=setTimeout(()=>{n==null||n.removeEventListener("abort",f),i()},u);n==null||n.addEventListener("abort",f,{once:!0})})}}const re=300*1e3,oe=new Set([p.DaemonStatus.PENDING_DEPOSITOR_WOTS_PK,...p.POST_WOTS_STATUSES]);async function ne(e){const{statusReader:t,wotsSubmitter:r,peginTxid:o,depositorPk:s,wotsPublicKeys:u,timeoutMs:n=re,signal:a}=e;a==null||a.throwIfAborted();const i=await _({statusReader:t,peginTxid:o,targetStatuses:oe,timeoutMs:n,signal:a});p.POST_WOTS_STATUSES.has(i)||(a==null||a.throwIfAborted(),await r.submitDepositorWotsKey({pegin_txid:o,depositor_pk:s,wots_public_keys:u},a))}const I=1;function ie(e,t,r){const o=c.stripHexPrefix(r).toLowerCase(),u=[e,...t].map(n=>c.stripHexPrefix(n).toLowerCase()).filter(n=>n!==o);if(u.length===0)throw new Error("Cannot derive localChallengers: removing depositor from {vaultProvider, vaultKeepers} left an empty set");return u}function se(e,t){const r=e.ins[t];return c.uint8ArrayToHex(new Uint8Array(r.hash).slice().reverse())}function T(e,t,r,o,s){const u=e.ins[t];if(u.index!==0)throw new Error(`NoPayout (challenger ${s}) input ${t} expected to spend ${o} vout 0, got vout ${u.index}`);const n=r.getId(),a=se(e,t);if(a!==n)throw new Error(`NoPayout (challenger ${s}) input ${t} does not reference ${o} (expected txid ${n}, got ${a})`)}async function ae(e,t,r){const o=[],s=[],u=[];b.assertPayoutOutputMatchesRegistered(e.payout_tx.tx_hex,r.registeredPayoutScriptPubKey);const n=await b.buildPayoutPsbt({payoutTxHex:e.payout_tx.tx_hex,peginTxHex:r.peginTxHex,assertTxHex:e.assert_tx.tx_hex,depositorBtcPubkey:r.depositorBtcPubkey,vaultProviderBtcPubkey:r.vaultProviderBtcPubkey,vaultKeeperBtcPubkeys:r.vaultKeeperBtcPubkeys,universalChallengerBtcPubkeys:r.universalChallengerBtcPubkeys,timelockPegin:r.timelockPegin,network:r.network});o.push(n.psbtHex),s.push(E.createTaprootScriptPathSignOptions(t,I));const a=ie(r.vaultProviderBtcPubkey,r.vaultKeeperBtcPubkeys,r.depositorBtcPubkey),i=c.stripHexPrefix(r.depositorBtcPubkey),l=P.Transaction.fromHex(c.stripHexPrefix(e.assert_tx.tx_hex));for(const f of e.challenger_presign_data){const d=c.stripHexPrefix(f.challenger_pubkey),g=o.length,y=await ue({challenger:f,challengerPubkey:d,claimerPubkey:i,localChallengers:a,assertTxParsed:l,ctx:r});o.push(y),s.push(E.createTaprootScriptPathSignOptions(t,I)),u.push({challengerPubkey:d,noPayoutIdx:g})}return{psbtHexes:o,signOptions:s,challengerEntries:u}}async function ue(e){const{challenger:t,challengerPubkey:r,claimerPubkey:o,localChallengers:s,assertTxParsed:u,ctx:n}=e;k.assertNoPayoutOutputMatchesChallenger(t.nopayout_tx.tx_hex,r,n.network);const a=P.Transaction.fromHex(c.stripHexPrefix(t.nopayout_tx.tx_hex)),i=P.Transaction.fromHex(c.stripHexPrefix(t.challenge_assert_x_tx.tx_hex)),l=P.Transaction.fromHex(c.stripHexPrefix(t.challenge_assert_y_tx.tx_hex));if(a.ins.length!==3)throw new Error(`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${a.ins.length}`);T(a,0,u,"Assert",r),T(a,1,i,"ChallengeAssertX",r),T(a,2,l,"ChallengeAssertY",r);const f=[u.outs[0],i.outs[0],l.outs[0]].map(d=>({script_pubkey:c.uint8ArrayToHex(new Uint8Array(d.script)),value:d.value}));return k.buildNoPayoutPsbt({noPayoutTxHex:t.nopayout_tx.tx_hex,challengerPubkey:r,prevouts:f,connectorParams:{claimer:o,localChallengers:s,universalChallengers:n.universalChallengerBtcPubkeys,timelockAssert:n.timelockAssert,councilMembers:n.councilMembers,councilQuorum:n.councilQuorum}})}function le(e,t,r){const o=b.extractPayoutSignature(e[0],r),s={};for(const u of t)s[u.challengerPubkey]={nopayout_signature:b.extractPayoutSignature(e[u.noPayoutIdx],r)};return{payout_signatures:{payout_signature:o},per_challenger:s}}async function ce(e,t,r){if(typeof e.signPsbts=="function")return e.signPsbts(t,r);const o=[];for(let s=0;s<t.length;s++)o.push(await e.signPsbt(t[s],r==null?void 0:r[s]));return o}async function O(e){const{depositorGraph:t,btcWallet:r,signingContext:o}=e,s=c.stripHexPrefix(o.depositorBtcPubkey),u=await r.getPublicKeyHex(),{psbtHexes:n,signOptions:a,challengerEntries:i}=await ae(t,u,o),l=await ce(r,n,a);if(l.length!==n.length)throw new Error(`Wallet returned ${l.length} signed PSBTs, expected ${n.length}`);return le(l,i,s)}const de=1200*1e3,N=new Set([p.DaemonStatus.PENDING_ACKS,p.DaemonStatus.PENDING_ACTIVATION,p.DaemonStatus.ACTIVATED]),fe=new Set([p.DaemonStatus.PENDING_DEPOSITOR_SIGNATURES,...N]);function pe(e){return e.map(t=>({claimerPubkeyXOnly:c.processPublicKeyToXOnly(t.claimer_pubkey),payoutTxHex:t.payout_tx.tx_hex,assertTxHex:t.assert_tx.tx_hex}))}function he(e){const{output:t}=W.payments.p2tr({internalPubkey:q.Buffer.from(e,"hex")});if(!t)throw new Error("Failed to derive BIP-86 P2TR scriptPubKey");return t.toString("hex")}function Pe(e,t){const r=c.stripHexPrefix(e).toLowerCase(),o=c.stripHexPrefix(t.vaultProviderBtcPubkey).toLowerCase(),s=c.stripHexPrefix(t.depositorBtcPubkey).toLowerCase();if(r===o||r===s)return t.registeredPayoutScriptPubKey;if(!t.vaultKeeperBtcPubkeys.some(a=>c.stripHexPrefix(a).toLowerCase()===r))throw new Error(`Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`);return`0x${he(r)}`}function R(e,t){return{payoutTxHex:e.payoutTxHex,peginTxHex:t.peginTxHex,assertTxHex:e.assertTxHex,vaultProviderBtcPubkey:t.vaultProviderBtcPubkey,vaultKeeperBtcPubkeys:t.vaultKeeperBtcPubkeys,universalChallengerBtcPubkeys:t.universalChallengerBtcPubkeys,depositorBtcPubkey:t.depositorBtcPubkey,timelockPegin:t.timelockPegin,registeredPayoutScriptPubKey:Pe(e.claimerPubkeyXOnly,t)}}async function ge(e,t,r,o){const s=new $.PayoutManager({network:t.network,btcWallet:e}),u=r.length;o==null||o(0,u);let n;if(s.supportsBatchSigning())n=(await s.signPayoutTransactionsBatch(r.map(l=>R(l,t)))).map(l=>l.payoutSignature);else{n=[];for(let i=0;i<r.length;i++){o==null||o(i,u);const l=await s.signPayoutTransaction(R(r[i],t));n.push(l.signature)}}const a={};for(let i=0;i<r.length;i++)a[r[i].claimerPubkeyXOnly]={payout_signature:n[i]};return o==null||o(u,u),a}async function ye(e){const{statusReader:t,presignClient:r,btcWallet:o,peginTxid:s,depositorPk:u,signingContext:n,timeoutMs:a=de,signal:i,onProgress:l}=e,f=await _({statusReader:t,peginTxid:s,targetStatuses:fe,timeoutMs:a,signal:i});if(N.has(f))return;i==null||i.throwIfAborted();const d=await r.requestDepositorPresignTransactions({pegin_txid:s,depositor_pk:u},i);i==null||i.throwIfAborted();const g=c.processPublicKeyToXOnly(u),y=d.txs.filter(F=>c.processPublicKeyToXOnly(F.claimer_pubkey)!==g),x=pe(y),m=await ge(o,n,x,l);i==null||i.throwIfAborted();const h=await O({depositorGraph:d.depositor_graph,btcWallet:o,signingContext:{peginTxHex:n.peginTxHex,depositorBtcPubkey:u,vaultProviderBtcPubkey:n.vaultProviderBtcPubkey,vaultKeeperBtcPubkeys:n.vaultKeeperBtcPubkeys,universalChallengerBtcPubkeys:n.universalChallengerBtcPubkeys,timelockPegin:n.timelockPegin,timelockAssert:n.timelockAssert,councilMembers:n.councilMembers,councilQuorum:n.councilQuorum,network:n.network,registeredPayoutScriptPubKey:n.registeredPayoutScriptPubKey}});i==null||i.throwIfAborted();const C={...m};C[c.stripHexPrefix(u)]=h.payout_signatures,await r.submitDepositorPresignatures({pegin_txid:s,depositor_pk:u,signatures:C,depositor_claimer_presignatures:h},i)}function be(e){return/^[0-9a-fA-F]{64}$/.test(e)}function xe(e){const{amountSats:t,minDeposit:r,maxDeposit:o,btcBalance:s,estimatedFeeSats:u,depositorClaimValue:n}=e;return!(t<=0n||t<r||o&&o>0n&&t>o||u==null||n==null||t+u+n>s)}function me(e,t,r){return e<=0n?{valid:!1,error:"Deposit amount must be greater than zero"}:e<t?{valid:!1,error:`Minimum deposit is ${c.formatSatoshisToBtc(t)} BTC`}:r&&r>0n&&e>r?{valid:!1,error:`Maximum deposit is ${c.formatSatoshisToBtc(r)} BTC`}:{valid:!0}}function we(e){const{amount:t,effectiveRemaining:r}=e;return r===null?{valid:!0}:r===0n?{valid:!1,error:"Supply cap reached — deposits temporarily paused"}:t>r?{valid:!1,error:`Vault size exceeds remaining capacity (${c.formatSatoshisToBtc(r)} BTC)`}:{valid:!0}}function ve(e,t){if(!e||e.length===0)return{valid:!1,error:"At least one vault provider must be selected"};const r=t.map(s=>s.toLowerCase());return e.filter(s=>!r.includes(s.toLowerCase())).length>0?{valid:!1,error:"Invalid vault provider selected"}:{valid:!0}}function D(e,t,r){if(!e||e.length===0)return{valid:!1,error:"At least one vault amount required"};for(let o=0;o<e.length;o++){const s=e[o];if(s<=0n)return{valid:!1,error:`Vault ${o+1} amount must be positive`};if(t&&s<t)return{valid:!1,error:`Vault ${o+1} amount ${c.formatSatoshisToBtc(s)} BTC is below minimum deposit ${c.formatSatoshisToBtc(t)} BTC`};if(r&&s>r)return{valid:!1,error:`Vault ${o+1} amount ${c.formatSatoshisToBtc(s)} BTC exceeds maximum deposit ${c.formatSatoshisToBtc(r)} BTC`}}return{valid:!0}}function V(e){const t=c.stripHexPrefix(e);return be(t)?{valid:!0}:{valid:!1,error:"Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"}}function Te(e){if(!e||e.length===0)throw new Error("No vault keepers available. The system requires at least one vault keeper to create a deposit.")}function Se(e){if(!e||e.length===0)throw new Error("No universal challengers available. The system requires at least one universal challenger to create a deposit.")}function ke(e){if(e.length===0)throw new Error("No spendable UTXOs available")}function Ee(e){const{vaultAmounts:t,confirmedUTXOs:r,vaultProviderBtcPubkey:o,vaultKeeperBtcPubkeys:s,universalChallengerBtcPubkeys:u,minDeposit:n,maxDeposit:a}=e,i=D(t,n,a);if(!i.valid)throw new Error(i.error);const l=V(o);if(!l.valid)throw new Error(l.error);Te(s),Se(u),ke(r)}var A=(e=>(e.CLAIM_EVENT_RECEIVED="ClaimEventReceived",e.CLAIM_BROADCAST="ClaimBroadcast",e.ASSERT_BROADCAST="AssertBroadcast",e.CHALLENGE_ASSERT_OBSERVED="ChallengeAssertObserved",e.WRONGLY_CHALLENGED_BROADCAST="WronglyChallengedBroadcast",e.PAYOUT_BROADCAST="PayoutBroadcast",e.FAILED="Failed",e))(A||{});const _e=new Set(["PayoutBroadcast","Failed"]);function Ae(e){return Object.values(A).includes(e)}function Be(e){return!!e&&_e.has(e)}class K extends Error{constructor(r,o){super(`Refund not yet mature (BIP68 not final): ${o.message}`);w(this,"vaultId");w(this,"cause");this.name="BIP68NotMatureError",this.vaultId=r,this.cause=o}}const Ce=/^0x[0-9a-fA-F]{64}$/,Ie=/^(?:0x)?(?:[0-9a-fA-F]{2})+$/,L=/^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/,B=160;function Re(e){if(!Number.isFinite(e)||e<=0)throw new Error(`feeRateSatsVb must be a positive finite number, got ${e}`);return BigInt(Math.ceil(e*B))}const He=1,H=65535,$e=/non-BIP68-final/i;function M(e,t){if(e.length!==66)throw new Error(`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`);if(!Ce.test(e))throw new Error(`${t} must contain only hex characters after the 0x prefix`)}function S(e,t){if(!Number.isInteger(e)||e<0)throw new Error(`${t} must be a non-negative integer, got ${e}`)}function Oe(e){if(M(e.hashlock,"hashlock"),!Number.isInteger(e.htlcVout)||e.htlcVout<0||e.htlcVout>H)throw new Error(`htlcVout must be an integer 0-${H}, got ${e.htlcVout}`);if(S(e.offchainParamsVersion,"offchainParamsVersion"),S(e.appVaultKeepersVersion,"appVaultKeepersVersion"),S(e.universalChallengersVersion,"universalChallengersVersion"),typeof e.unsignedPrePeginTxHex!="string"||e.unsignedPrePeginTxHex.length===0)throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");if(!Ie.test(e.unsignedPrePeginTxHex))throw new Error("unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)");if(!e.depositorBtcPubkey||!L.test(e.depositorBtcPubkey))throw new Error("depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)");if(typeof e.amount!="bigint"||e.amount<=0n)throw new Error(`amount must be a positive bigint, got ${e.amount}`)}function Ne(e){if(!e.vaultProviderPubkey||!L.test(e.vaultProviderPubkey))throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");if(e.vaultKeeperPubkeys.length===0)throw new Error("vaultKeeperPubkeys must be non-empty");if(e.universalChallengerPubkeys.length===0)throw new Error("universalChallengerPubkeys must be non-empty");if(!Number.isInteger(e.timelockRefund)||e.timelockRefund<=0)throw new Error(`timelockRefund must be a positive integer, got ${e.timelockRefund}`);if(typeof e.feeRate!="bigint"||e.feeRate<=0n)throw new Error(`protocol feeRate must be a positive bigint, got ${e.feeRate}`);if(!Number.isInteger(e.numLocalChallengers)||e.numLocalChallengers<0)throw new Error("numLocalChallengers must be a non-negative integer");if(!Number.isInteger(e.councilQuorum)||!Number.isInteger(e.councilSize)||e.councilQuorum<=0||e.councilSize<=0||e.councilQuorum>e.councilSize)throw new Error(`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`)}function De(e){const t=P.Psbt.fromHex(e);try{t.finalizeAllInputs()}catch(r){const o=r instanceof Error?r.message:String(r);if(!o.includes("already finalized"))throw new Error(`Failed to finalize refund PSBT: ${o}`)}return t.extractTransaction().toHex()}async function Ve(e){const{vaultId:t,readVault:r,readPrePeginContext:o,feeRate:s,signPsbt:u,broadcastTx:n,signal:a}=e;a==null||a.throwIfAborted(),M(t,"vaultId");const i=await r();Oe(i),a==null||a.throwIfAborted();const l=await o(i);if(Ne(l),a==null||a.throwIfAborted(),!Number.isFinite(s)||s<=0)throw new Error(`feeRate must be a positive number, got ${s}`);const f=BigInt(Math.ceil(s*B));a==null||a.throwIfAborted();const d=c.processPublicKeyToXOnly(i.depositorBtcPubkey),{psbtHex:g}=await k.buildRefundPsbt({prePeginParams:{depositorPubkey:d,vaultProviderPubkey:c.stripHexPrefix(l.vaultProviderPubkey),vaultKeeperPubkeys:l.vaultKeeperPubkeys.map(c.stripHexPrefix),universalChallengerPubkeys:l.universalChallengerPubkeys.map(c.stripHexPrefix),hashlocks:[c.stripHexPrefix(i.hashlock)],timelockRefund:l.timelockRefund,pegInAmounts:[i.amount],feeRate:l.feeRate,numLocalChallengers:l.numLocalChallengers,councilQuorum:l.councilQuorum,councilSize:l.councilSize,network:l.network},fundedPrePeginTxHex:c.stripHexPrefix(i.unsignedPrePeginTxHex),htlcVout:i.htlcVout,refundFee:f,hashlock:c.stripHexPrefix(i.hashlock)});a==null||a.throwIfAborted();const y=E.createTaprootScriptPathSignOptions(i.depositorBtcPubkey,He),x=await u(g,y),m=De(x);a==null||a.throwIfAborted();try{return await n(m)}catch(h){throw h instanceof Error&&$e.test(h.message)?new K(t,h):h}}exports.BIP68NotMatureError=K;exports.ClaimerPegoutStatusValue=A;exports.REFUND_VSIZE=B;exports.activateVault=ee;exports.buildAndBroadcastRefund=Ve;exports.estimateRefundFeeSats=Re;exports.isDepositAmountValid=xe;exports.isPegoutTerminalStatus=Be;exports.isRecognizedPegoutStatus=Ae;exports.runDepositorPresignFlow=ye;exports.signDepositorGraph=O;exports.submitWotsPublicKey=ne;exports.validateDepositAmount=me;exports.validateMultiVaultDepositInputs=Ee;exports.validateProviderSelection=ve;exports.validateRemainingCapacity=we;exports.validateVaultAmounts=D;exports.validateVaultProviderPubkey=V;exports.waitForPeginStatus=_;
2
+ //# sourceMappingURL=buildAndBroadcastRefund-B332dykQ.cjs.map