@babylonlabs-io/ts-sdk 0.70.1 → 0.71.1

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 (228) hide show
  1. package/dist/PeginManager-Bn8FxM35.cjs +2 -0
  2. package/dist/PeginManager-Bn8FxM35.cjs.map +1 -0
  3. package/dist/{PeginManager-BNtg6jgY.js → PeginManager-C3ojNTlv.js} +12 -12
  4. package/dist/PeginManager-C3ojNTlv.js.map +1 -0
  5. package/dist/abortSignals-BPpAUL1Z.js +18 -0
  6. package/dist/abortSignals-BPpAUL1Z.js.map +1 -0
  7. package/dist/abortSignals-msbmbqFe.cjs +2 -0
  8. package/dist/abortSignals-msbmbqFe.cjs.map +1 -0
  9. package/dist/{bitcoin-Ch_jxnDa.js → bitcoin-C-TuHb-v.js} +21 -22
  10. package/dist/bitcoin-C-TuHb-v.js.map +1 -0
  11. package/dist/bitcoin-D-O2GjbC.cjs +2 -0
  12. package/dist/bitcoin-D-O2GjbC.cjs.map +1 -0
  13. package/dist/{buildAndBroadcastReclaim-kBHwOL02.js → buildAndBroadcastReclaim-YvWDRAN8.js} +493 -489
  14. package/dist/{buildAndBroadcastReclaim-kBHwOL02.js.map → buildAndBroadcastReclaim-YvWDRAN8.js.map} +1 -1
  15. package/dist/buildAndBroadcastReclaim-zfjDI5__.cjs +2 -0
  16. package/dist/{buildAndBroadcastReclaim-iNJfx0ZG.cjs.map → buildAndBroadcastReclaim-zfjDI5__.cjs.map} +1 -1
  17. package/dist/{challengeAssert-BNQ8sToz.js → challengeAssert-Cp_GeRg8.js} +3 -3
  18. package/dist/challengeAssert-Cp_GeRg8.js.map +1 -0
  19. package/dist/challengeAssert-Z7_YULBb.cjs +2 -0
  20. package/dist/challengeAssert-Z7_YULBb.cjs.map +1 -0
  21. package/dist/constants-Bh38W9mq.cjs +2 -0
  22. package/dist/constants-Bh38W9mq.cjs.map +1 -0
  23. package/dist/constants-CPzppOdq.js +17 -0
  24. package/dist/constants-CPzppOdq.js.map +1 -0
  25. package/dist/index-Cs7_Evtk.cjs +2 -0
  26. package/dist/index-Cs7_Evtk.cjs.map +1 -0
  27. package/dist/index-LgmJhdEN.js +505 -0
  28. package/dist/index-LgmJhdEN.js.map +1 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +244 -239
  31. package/dist/index.js.map +1 -1
  32. package/dist/{mempoolApi-CfOFmov6.js → mempoolApi-CKD_IbrM.js} +59 -59
  33. package/dist/mempoolApi-CKD_IbrM.js.map +1 -0
  34. package/dist/mempoolApi-DronQ5xn.cjs +2 -0
  35. package/dist/mempoolApi-DronQ5xn.cjs.map +1 -0
  36. package/dist/noPayout-DpGRzidi.js +353 -0
  37. package/dist/noPayout-DpGRzidi.js.map +1 -0
  38. package/dist/noPayout-zEifyecV.cjs +2 -0
  39. package/dist/noPayout-zEifyecV.cjs.map +1 -0
  40. package/dist/{onChainBtcPubkey-C_a2L3kL.cjs → onChainBtcPubkey-B5ZvWCCF.cjs} +2 -2
  41. package/dist/{onChainBtcPubkey-C_a2L3kL.cjs.map → onChainBtcPubkey-B5ZvWCCF.cjs.map} +1 -1
  42. package/dist/{onChainBtcPubkey-BAHZyKQL.js → onChainBtcPubkey-DATNfAAl.js} +2 -2
  43. package/dist/{onChainBtcPubkey-BAHZyKQL.js.map → onChainBtcPubkey-DATNfAAl.js.map} +1 -1
  44. package/dist/parseFundingOutpoints-BkgGihaY.cjs +2 -0
  45. package/dist/parseFundingOutpoints-BkgGihaY.cjs.map +1 -0
  46. package/dist/{parseFundingOutpoints-CO-f6IHK.js → parseFundingOutpoints-DlINgQ3X.js} +30 -29
  47. package/dist/parseFundingOutpoints-DlINgQ3X.js.map +1 -0
  48. package/dist/primeVpAuth-Cjq6qFHq.cjs +2 -0
  49. package/dist/primeVpAuth-Cjq6qFHq.cjs.map +1 -0
  50. package/dist/{batchPoll-BM4iQ9jT.js → primeVpAuth-tLRjdHwZ.js} +311 -803
  51. package/dist/primeVpAuth-tLRjdHwZ.js.map +1 -0
  52. package/dist/{reservation-CBAvoF3U.js → reservation-Cj9F0rP9.js} +2 -2
  53. package/dist/{reservation-CBAvoF3U.js.map → reservation-Cj9F0rP9.js.map} +1 -1
  54. package/dist/{reservation-CDbInVw0.cjs → reservation-Dr2HLCxx.cjs} +2 -2
  55. package/dist/{reservation-CDbInVw0.cjs.map → reservation-Dr2HLCxx.cjs.map} +1 -1
  56. package/dist/{signPsbtsWithFallback-X6ivsbh7.js → signPsbtsWithFallback-CCFTzE0o.js} +19 -20
  57. package/dist/{signPsbtsWithFallback-X6ivsbh7.js.map → signPsbtsWithFallback-CCFTzE0o.js.map} +1 -1
  58. package/dist/signPsbtsWithFallback-CrkvpSJz.cjs +2 -0
  59. package/dist/{signPsbtsWithFallback-Bo1PJX90.cjs.map → signPsbtsWithFallback-CrkvpSJz.cjs.map} +1 -1
  60. package/dist/signing-BJ3X66b-.cjs +2 -0
  61. package/dist/signing-BJ3X66b-.cjs.map +1 -0
  62. package/dist/signing-Cm-McVR2.js +22 -0
  63. package/dist/signing-Cm-McVR2.js.map +1 -0
  64. package/dist/tbv/core/clients/eth/types.d.ts +0 -2
  65. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  66. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  67. package/dist/tbv/core/clients/index.cjs +1 -1
  68. package/dist/tbv/core/clients/index.js +36 -35
  69. package/dist/tbv/core/clients/index.js.map +1 -1
  70. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts +9 -1
  71. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
  72. package/dist/tbv/core/clients/vault-provider/auth/serverIdentity.d.ts.map +1 -1
  73. package/dist/tbv/core/clients/vault-provider/auth/verifyDepositorCwt.d.ts.map +1 -1
  74. package/dist/tbv/core/clients/vault-provider/status/index.cjs +2 -0
  75. package/dist/tbv/core/clients/vault-provider/status/index.cjs.map +1 -0
  76. package/dist/tbv/core/clients/vault-provider/status/index.d.ts +18 -0
  77. package/dist/tbv/core/clients/vault-provider/status/index.d.ts.map +1 -0
  78. package/dist/tbv/core/clients/vault-provider/status/index.js +17 -0
  79. package/dist/tbv/core/clients/vault-provider/status/index.js.map +1 -0
  80. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  81. package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts +1 -1
  82. package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts.map +1 -1
  83. package/dist/tbv/core/index.cjs +1 -1
  84. package/dist/tbv/core/index.js +237 -232
  85. package/dist/tbv/core/index.js.map +1 -1
  86. package/dist/tbv/core/managers/index.cjs +1 -1
  87. package/dist/tbv/core/managers/index.js +2 -2
  88. package/dist/tbv/core/primitives/index.cjs +1 -1
  89. package/dist/tbv/core/primitives/index.d.ts +4 -2
  90. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  91. package/dist/tbv/core/primitives/index.js +26 -25
  92. package/dist/tbv/core/primitives/psbt/__tests__/finalizeScriptPathWithSignatures.test.d.ts +11 -0
  93. package/dist/tbv/core/primitives/psbt/__tests__/finalizeScriptPathWithSignatures.test.d.ts.map +1 -0
  94. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +1 -1
  95. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  96. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +1 -1
  97. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
  98. package/dist/tbv/core/primitives/psbt/finalizeScriptPathWithSignatures.d.ts +52 -0
  99. package/dist/tbv/core/primitives/psbt/finalizeScriptPathWithSignatures.d.ts.map +1 -0
  100. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +1 -1
  101. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
  102. package/dist/tbv/core/primitives/psbt/payout.d.ts +1 -1
  103. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  104. package/dist/tbv/core/primitives/psbt/pegin.d.ts +1 -1
  105. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  106. package/dist/tbv/core/primitives/psbt/peginInput.d.ts +1 -1
  107. package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
  108. package/dist/tbv/core/primitives/psbt/reclaim.d.ts +23 -1
  109. package/dist/tbv/core/primitives/psbt/reclaim.d.ts.map +1 -1
  110. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  111. package/dist/tbv/core/primitives/scripts/payout.d.ts +1 -1
  112. package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -1
  113. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +0 -10
  114. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
  115. package/dist/tbv/core/recovery/reconstructPeginParams.d.ts.map +1 -1
  116. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  117. package/dist/tbv/core/services/index.cjs +1 -1
  118. package/dist/tbv/core/services/index.js +2 -2
  119. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.walletPsbt.test.d.ts +14 -0
  120. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.walletPsbt.test.d.ts.map +1 -0
  121. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts +14 -2
  122. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts.map +1 -1
  123. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  124. package/dist/tbv/core/utils/index.cjs +1 -1
  125. package/dist/tbv/core/utils/index.js +47 -44
  126. package/dist/tbv/core/utils/index.js.map +1 -1
  127. package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
  128. package/dist/tbv/core/utils/validation.d.ts +4 -0
  129. package/dist/tbv/core/utils/validation.d.ts.map +1 -1
  130. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -1
  131. package/dist/tbv/core/vault-secrets/index.cjs +1 -1
  132. package/dist/tbv/core/vault-secrets/index.d.ts +1 -1
  133. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  134. package/dist/tbv/core/vault-secrets/index.js +2 -2
  135. package/dist/tbv/core/wasm/__tests__/constants.test.d.ts +2 -0
  136. package/dist/tbv/core/wasm/__tests__/constants.test.d.ts.map +1 -0
  137. package/dist/tbv/core/wasm/__tests__/loader.test.d.ts +2 -0
  138. package/dist/tbv/core/wasm/__tests__/loader.test.d.ts.map +1 -0
  139. package/dist/tbv/core/wasm/__tests__/value-guards.test.d.ts +2 -0
  140. package/dist/tbv/core/wasm/__tests__/value-guards.test.d.ts.map +1 -0
  141. package/dist/tbv/core/wasm/constants.d.ts +11 -0
  142. package/dist/tbv/core/wasm/constants.d.ts.map +1 -0
  143. package/dist/tbv/core/wasm/index.cjs +2 -0
  144. package/dist/tbv/core/wasm/index.cjs.map +1 -0
  145. package/dist/tbv/core/wasm/index.d.ts +191 -0
  146. package/dist/tbv/core/wasm/index.d.ts.map +1 -0
  147. package/dist/tbv/core/wasm/index.js +144 -0
  148. package/dist/tbv/core/wasm/index.js.map +1 -0
  149. package/dist/tbv/core/wasm/value-guards.d.ts +30 -0
  150. package/dist/tbv/core/wasm/value-guards.d.ts.map +1 -0
  151. package/dist/tbv/index.cjs +1 -1
  152. package/dist/tbv/index.js +237 -232
  153. package/dist/tbv/index.js.map +1 -1
  154. package/dist/testing/index.cjs +1 -1
  155. package/dist/testing/index.js +1 -1
  156. package/dist/toRefundInputs-CY9u84U9.cjs +2 -0
  157. package/dist/toRefundInputs-CY9u84U9.cjs.map +1 -0
  158. package/dist/{toRefundInputs-DPNYBFkP.js → toRefundInputs-Df1vi23S.js} +8 -8
  159. package/dist/toRefundInputs-Df1vi23S.js.map +1 -0
  160. package/dist/validation-C6XTfZak.cjs +2 -0
  161. package/dist/validation-C6XTfZak.cjs.map +1 -0
  162. package/dist/validation-OSC0xTHB.js +17 -0
  163. package/dist/validation-OSC0xTHB.js.map +1 -0
  164. package/dist/vaultCoreVersion-DYfw3qed.cjs +2 -0
  165. package/dist/vaultCoreVersion-DYfw3qed.cjs.map +1 -0
  166. package/dist/vaultCoreVersion-D_fP9P3C.js +10 -0
  167. package/dist/vaultCoreVersion-D_fP9P3C.js.map +1 -0
  168. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs +2 -0
  169. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs.map +1 -0
  170. package/dist/{verifyKeyPathSchnorrSignature-C6Cmk0R1.js → verifyKeyPathSchnorrSignature-BrgUJmV0.js} +3 -3
  171. package/dist/verifyKeyPathSchnorrSignature-BrgUJmV0.js.map +1 -0
  172. package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs +2 -0
  173. package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs.map +1 -0
  174. package/dist/{verifyScriptPathSchnorrSignature-CQYucnJA.js → verifyScriptPathSchnorrSignature-Ciq_xZhw.js} +39 -37
  175. package/dist/verifyScriptPathSchnorrSignature-Ciq_xZhw.js.map +1 -0
  176. package/dist/waitForTransactionReceiptSmartAware-DpQ69ySe.cjs +2 -0
  177. package/dist/waitForTransactionReceiptSmartAware-DpQ69ySe.cjs.map +1 -0
  178. package/dist/{waitForTransactionReceiptSmartAware-B6oYRdFO.js → waitForTransactionReceiptSmartAware-z3Xfmo44.js} +42 -47
  179. package/dist/waitForTransactionReceiptSmartAware-z3Xfmo44.js.map +1 -0
  180. package/package.json +12 -2
  181. package/dist/PeginManager-BNtg6jgY.js.map +0 -1
  182. package/dist/PeginManager-CvI99Uhd.cjs +0 -2
  183. package/dist/PeginManager-CvI99Uhd.cjs.map +0 -1
  184. package/dist/batchPoll-BM4iQ9jT.js.map +0 -1
  185. package/dist/batchPoll-cqpEfBjr.cjs +0 -2
  186. package/dist/batchPoll-cqpEfBjr.cjs.map +0 -1
  187. package/dist/bitcoin-Ch_jxnDa.js.map +0 -1
  188. package/dist/bitcoin-m84N5a8o.cjs +0 -2
  189. package/dist/bitcoin-m84N5a8o.cjs.map +0 -1
  190. package/dist/buildAndBroadcastReclaim-iNJfx0ZG.cjs +0 -2
  191. package/dist/challengeAssert-BNQ8sToz.js.map +0 -1
  192. package/dist/challengeAssert-BrpC3-cQ.cjs +0 -2
  193. package/dist/challengeAssert-BrpC3-cQ.cjs.map +0 -1
  194. package/dist/constants-BCdDRd_Y.cjs +0 -2
  195. package/dist/constants-BCdDRd_Y.cjs.map +0 -1
  196. package/dist/constants-DRiWbItj.js +0 -24
  197. package/dist/constants-DRiWbItj.js.map +0 -1
  198. package/dist/mempoolApi-CfOFmov6.js.map +0 -1
  199. package/dist/mempoolApi-Q90mz17e.cjs +0 -2
  200. package/dist/mempoolApi-Q90mz17e.cjs.map +0 -1
  201. package/dist/noPayout-BKP3mRu3.cjs +0 -2
  202. package/dist/noPayout-BKP3mRu3.cjs.map +0 -1
  203. package/dist/noPayout-BdATUPjF.js +0 -280
  204. package/dist/noPayout-BdATUPjF.js.map +0 -1
  205. package/dist/parseFundingOutpoints-CIO9Ok1L.cjs +0 -2
  206. package/dist/parseFundingOutpoints-CIO9Ok1L.cjs.map +0 -1
  207. package/dist/parseFundingOutpoints-CO-f6IHK.js.map +0 -1
  208. package/dist/signPsbtsWithFallback-Bo1PJX90.cjs +0 -2
  209. package/dist/signing-Bnsro0hE.cjs +0 -2
  210. package/dist/signing-Bnsro0hE.cjs.map +0 -1
  211. package/dist/signing-DaLvGwQe.js +0 -16
  212. package/dist/signing-DaLvGwQe.js.map +0 -1
  213. package/dist/toRefundInputs-BJojfg3k.cjs +0 -2
  214. package/dist/toRefundInputs-BJojfg3k.cjs.map +0 -1
  215. package/dist/toRefundInputs-DPNYBFkP.js.map +0 -1
  216. package/dist/validation-CDbOaDj7.cjs +0 -2
  217. package/dist/validation-CDbOaDj7.cjs.map +0 -1
  218. package/dist/validation-Dj3dqYtl.js +0 -30
  219. package/dist/validation-Dj3dqYtl.js.map +0 -1
  220. package/dist/verifyKeyPathSchnorrSignature-C6Cmk0R1.js.map +0 -1
  221. package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs +0 -2
  222. package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs.map +0 -1
  223. package/dist/verifyScriptPathSchnorrSignature-CQYucnJA.js.map +0 -1
  224. package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs +0 -2
  225. package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs.map +0 -1
  226. package/dist/waitForTransactionReceiptSmartAware-B6oYRdFO.js.map +0 -1
  227. package/dist/waitForTransactionReceiptSmartAware-Ct7LPwPI.cjs +0 -2
  228. package/dist/waitForTransactionReceiptSmartAware-Ct7LPwPI.cjs.map +0 -1
@@ -1,50 +1,52 @@
1
1
  var Ee = Object.defineProperty;
2
- var ke = (e, t, r) => t in e ? Ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var C = (e, t, r) => ke(e, typeof t != "symbol" ? t + "" : t, r);
2
+ var xe = (e, t, r) => t in e ? Ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var S = (e, t, r) => xe(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { B as ae } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
5
- import { e as xe, v as Te, s as y, u as ie, p as O, c as x, f as R } from "./bitcoin-Ch_jxnDa.js";
6
- import { v as Ae, d as Re, s as Ce, P as _e, a as Se } from "./signPsbtsWithFallback-X6ivsbh7.js";
5
+ import { e as ie, v as Te, s as v, u as ue, p as O, c as R, f as _ } from "./bitcoin-C-TuHb-v.js";
6
+ import { v as Re, d as Ce, s as Ae, P as _e, a as Se } from "./signPsbtsWithFallback-CCFTzE0o.js";
7
7
  import { zeroAddress as $e } from "viem";
8
- import { D as T, c as Be, b as Ie, R as Ve, d as ue } from "./json-rpc-client-DuUARJvV.js";
9
- import { Transaction as _, Psbt as le } from "bitcoinjs-lib";
10
- import { m as Ke, f as Oe, i as B, g as I, j as V } from "./verifyScriptPathSchnorrSignature-CQYucnJA.js";
11
- import { D as X, a as Ne } from "./constants-DRiWbItj.js";
12
- import { d as He, c as De, b as Fe, e as Me, a as Ue } from "./noPayout-BdATUPjF.js";
13
- import { c as K } from "./signing-DaLvGwQe.js";
14
- import { a as G } from "./onChainBtcPubkey-BAHZyKQL.js";
15
- const Le = /^0x[0-9a-fA-F]{64}$/, ze = /^0x[0-9a-fA-F]{40}$/, Xe = /^0x([0-9a-fA-F]{2})*$/;
16
- function N(e, t) {
8
+ import { D as C, c as Be, b as Ie, R as Ve, d as le } from "./json-rpc-client-DuUARJvV.js";
9
+ import { Transaction as $ } from "bitcoinjs-lib";
10
+ import { o as Ke, f as Oe, i as B, g as I, j as V } from "./verifyScriptPathSchnorrSignature-Ciq_xZhw.js";
11
+ import { D as G } from "./constants-CPzppOdq.js";
12
+ import { d as He, c as Ne, b as De, f as ce, e as Fe, a as Me } from "./noPayout-DpGRzidi.js";
13
+ import { a as K, c as Le } from "./signing-Cm-McVR2.js";
14
+ import { a as q } from "./onChainBtcPubkey-DATNfAAl.js";
15
+ import { a as Ue } from "./vaultCoreVersion-D_fP9P3C.js";
16
+ import { deriveVaultId as Xe } from "./tbv/core/wasm/index.js";
17
+ const Ge = /^0x[0-9a-fA-F]{64}$/, qe = /^0x[0-9a-fA-F]{40}$/, ze = /^0x([0-9a-fA-F]{2})*$/;
18
+ function H(e, t) {
17
19
  if (e.length !== 66)
18
20
  throw new Error(
19
21
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
20
22
  );
21
- if (!Le.test(e))
23
+ if (!Ge.test(e))
22
24
  throw new Error(
23
25
  `${t} must contain only hex characters after the 0x prefix`
24
26
  );
25
27
  }
26
- function Ge(e, t) {
27
- if (!ze.test(e))
28
+ function je(e, t) {
29
+ if (!qe.test(e))
28
30
  throw new Error(
29
31
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
30
32
  );
31
33
  }
32
- function qe(e, t) {
33
- if (!Xe.test(e))
34
+ function Qe(e, t) {
35
+ if (!ze.test(e))
34
36
  throw new Error(
35
37
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
36
38
  );
37
39
  }
38
- function ce(e) {
39
- Ge(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), N(e.vaultId, "vaultId");
40
- const t = xe(e.secret);
41
- if (N(t, "secret"), e.hashlock !== void 0 && (N(e.hashlock, "hashlock"), !Ae(t, e.hashlock)))
40
+ function he(e) {
41
+ je(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), H(e.vaultId, "vaultId");
42
+ const t = ie(e.secret);
43
+ if (H(t, "secret"), e.hashlock !== void 0 && (H(e.hashlock, "hashlock"), !Re(t, e.hashlock)))
42
44
  throw new Error(
43
45
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
44
46
  );
45
47
  return t;
46
48
  }
47
- async function qt(e) {
49
+ async function Wt(e) {
48
50
  const {
49
51
  btcVaultRegistryAddress: t,
50
52
  vaultId: r,
@@ -54,23 +56,23 @@ async function qt(e) {
54
56
  signal: s
55
57
  } = e;
56
58
  s == null || s.throwIfAborted();
57
- const n = ce({
59
+ const i = he({
58
60
  btcVaultRegistryAddress: t,
59
61
  vaultId: r,
60
62
  secret: e.secret,
61
63
  hashlock: o
62
64
  });
63
- return qe(a, "activationMetadata"), l({
65
+ return Qe(a, "activationMetadata"), l({
64
66
  address: t,
65
67
  abi: ae,
66
68
  functionName: "activateVaultWithSecret",
67
- args: [r, n, a]
69
+ args: [r, i, a]
68
70
  });
69
71
  }
70
- async function jt(e) {
72
+ async function Yt(e) {
71
73
  const { btcVaultRegistryAddress: t, vaultId: r, hashlock: o, writeContract: a, signal: l } = e;
72
74
  l == null || l.throwIfAborted();
73
- const s = ce({
75
+ const s = he({
74
76
  btcVaultRegistryAddress: t,
75
77
  vaultId: r,
76
78
  secret: e.secret,
@@ -83,37 +85,37 @@ async function jt(e) {
83
85
  args: [r, s]
84
86
  });
85
87
  }
86
- const je = 8, Qe = 6e3, We = 10 * 6e4, Ye = 10;
87
- class he extends Error {
88
+ const We = 8, Ye = 6e3, Je = 10 * 6e4, Ze = 10;
89
+ class de extends Error {
88
90
  constructor(t) {
89
91
  super(t), this.name = "PeginRegistrationMissingError";
90
92
  }
91
93
  }
92
- class de extends Error {
94
+ class pe extends Error {
93
95
  constructor(t) {
94
96
  super(t), this.name = "PeginRegistrationNotFinalError";
95
97
  }
96
98
  }
97
- function Je(e) {
98
- return e instanceof he || e instanceof Error && e.name === "PeginRegistrationMissingError";
99
+ function et(e) {
100
+ return e instanceof de || e instanceof Error && e.name === "PeginRegistrationMissingError";
99
101
  }
100
- function Qt(e) {
101
- return e instanceof de || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
102
+ function Jt(e) {
103
+ return e instanceof pe || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
102
104
  }
103
- function q(e) {
105
+ function z(e) {
104
106
  const { currentBlock: t, createdAtBlock: r } = e, o = t - r + 1n;
105
107
  return o < 0n ? 0 : Number(o);
106
108
  }
107
- async function Wt(e) {
109
+ async function Zt(e) {
108
110
  const {
109
111
  vaultRegistryReader: t,
110
112
  getBlockNumber: r,
111
113
  vaultIds: o,
112
- required: a = je,
113
- pollIntervalMs: l = Qe,
114
- timeoutMs: s = We,
115
- signal: n,
116
- onProgress: i
114
+ required: a = We,
115
+ pollIntervalMs: l = Ye,
116
+ timeoutMs: s = Je,
117
+ signal: i,
118
+ onProgress: n
117
119
  } = e;
118
120
  if (o.length === 0)
119
121
  throw new Error(
@@ -122,116 +124,116 @@ async function Wt(e) {
122
124
  const u = Date.now();
123
125
  let h = !1, c = 0, d;
124
126
  for (; ; ) {
125
- if (n != null && n.aborted)
127
+ if (i != null && i.aborted)
126
128
  throw new Error(
127
129
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
128
130
  );
129
131
  if (Date.now() - u >= s)
130
- throw new de(
132
+ throw new pe(
131
133
  `Peg-in registration did not reach ${a} Ethereum confirmations within ${s}ms. The registration transaction was submitted but is not yet final, so the Pre-PegIn Bitcoin transaction was never sent and no funds are at risk. Resume this deposit from the dashboard once the network settles.` + (d instanceof Error ? ` Last read error: ${d.message}` : "")
132
134
  );
133
135
  try {
134
136
  const p = await r(), g = await Promise.all(
135
- o.map((f) => t.getVaultBasicInfo(f))
136
- ), b = g.findIndex(
137
- (f) => f.depositor === $e || f.createdAt === 0n
137
+ o.map((m) => t.getVaultBasicInfo(m))
138
+ ), P = g.findIndex(
139
+ (m) => m.depositor === $e || m.createdAt === 0n
138
140
  );
139
- if (b !== -1) {
140
- if (c += 1, !h && c > Ye)
141
- throw new he(
142
- `Vault ${o[b]} is still not visible on-chain after ${c} reads — the registration does not exist.`
141
+ if (P !== -1) {
142
+ if (c += 1, !h && c > Ze)
143
+ throw new de(
144
+ `Vault ${o[P]} is still not visible on-chain after ${c} reads — the registration does not exist.`
143
145
  );
144
146
  console.warn(
145
- `Peg-in registration for vault ${o[b]} is not visible in chain state at block ${p} — a lagging RPC backend or an Ethereum reorg. Still polling.`
146
- ), i == null || i({ confirmations: 0, required: a });
147
+ `Peg-in registration for vault ${o[P]} is not visible in chain state at block ${p} — a lagging RPC backend or an Ethereum reorg. Still polling.`
148
+ ), n == null || n({ confirmations: 0, required: a });
147
149
  } else {
148
150
  h = !0, c = 0, d = void 0;
149
- let f = g[0], P = q({
151
+ let m = g[0], f = z({
150
152
  currentBlock: p,
151
153
  createdAtBlock: g[0].createdAt
152
154
  });
153
- for (const v of g.slice(1)) {
154
- const m = q({
155
+ for (const w of g.slice(1)) {
156
+ const y = z({
155
157
  currentBlock: p,
156
- createdAtBlock: v.createdAt
158
+ createdAtBlock: w.createdAt
157
159
  });
158
- m < P && (P = m, f = v);
160
+ y < f && (f = y, m = w);
159
161
  }
160
- if (i == null || i({ confirmations: P, required: a }), P >= a)
161
- return { confirmations: P, basicInfo: f };
162
+ if (n == null || n({ confirmations: f, required: a }), f >= a)
163
+ return { confirmations: f, basicInfo: m };
162
164
  }
163
165
  } catch (p) {
164
- if (Je(p))
166
+ if (et(p))
165
167
  throw p;
166
168
  console.warn(
167
169
  `Registration-depth read failed (retrying in ${l}ms): ` + (p instanceof Error ? p.message : String(p))
168
170
  ), d = p;
169
171
  }
170
172
  await new Promise((p, g) => {
171
- const b = () => {
172
- clearTimeout(f), g(
173
+ const P = () => {
174
+ clearTimeout(m), g(
173
175
  new Error(
174
176
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
175
177
  )
176
178
  );
177
- }, f = setTimeout(() => {
178
- n == null || n.removeEventListener("abort", b), p();
179
+ }, m = setTimeout(() => {
180
+ i == null || i.removeEventListener("abort", P), p();
179
181
  }, l);
180
- n == null || n.addEventListener("abort", b, { once: !0 });
182
+ i == null || i.addEventListener("abort", P, { once: !0 });
181
183
  });
182
184
  }
183
185
  }
184
- const Ze = 1;
185
- function et(e, t, r) {
186
+ const tt = 1;
187
+ function rt(e, t, r) {
186
188
  const o = r.map(
187
- (c) => y(c).toLowerCase()
189
+ (c) => v(c).toLowerCase()
188
190
  ), a = t.filter((c) => o.includes(c));
189
191
  if (a.length > 0)
190
192
  throw new Error(
191
193
  `Cannot validate challenger set: vault keepers and universal challengers overlap (${a.join(", ")})`
192
194
  );
193
195
  const l = [...t, ...o], s = e.map(
194
- (c) => y(c.challenger_pubkey).toLowerCase()
195
- ), n = new Set(s);
196
- if (n.size !== s.length)
196
+ (c) => v(c.challenger_pubkey).toLowerCase()
197
+ ), i = new Set(s);
198
+ if (i.size !== s.length)
197
199
  throw new Error(
198
200
  "Depositor graph contains duplicate challenger entries in challenger_presign_data"
199
201
  );
200
- const i = new Set(l), u = l.filter((c) => !n.has(c)), h = s.filter((c) => !i.has(c));
202
+ const n = new Set(l), u = l.filter((c) => !i.has(c)), h = s.filter((c) => !n.has(c));
201
203
  if (u.length > 0 || h.length > 0)
202
204
  throw new Error(
203
205
  "Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
204
206
  );
205
207
  }
206
- function tt(e, t) {
208
+ function ot(e, t) {
207
209
  const r = e.ins[t];
208
- return ie(new Uint8Array(r.hash).slice().reverse());
210
+ return ue(new Uint8Array(r.hash).slice().reverse());
209
211
  }
210
- function H(e, t, r, o, a) {
212
+ function N(e, t, r, o, a) {
211
213
  const l = e.ins[t];
212
214
  if (l.index !== 0)
213
215
  throw new Error(
214
216
  `NoPayout (challenger ${a}) input ${t} expected to spend ${o} vout 0, got vout ${l.index}`
215
217
  );
216
- const s = r.getId(), n = tt(e, t);
217
- if (n !== s)
218
+ const s = r.getId(), i = ot(e, t);
219
+ if (i !== s)
218
220
  throw new Error(
219
- `NoPayout (challenger ${a}) input ${t} does not reference ${o} (expected txid ${s}, got ${n})`
221
+ `NoPayout (challenger ${a}) input ${t} does not reference ${o} (expected txid ${s}, got ${i})`
220
222
  );
221
223
  }
222
- async function rt(e, t, r) {
224
+ async function nt(e, t, r) {
223
225
  const o = [], a = [], l = [], s = Ke({
224
226
  claimerBtcPubkey: r.depositorBtcPubkey,
225
227
  depositorBtcPubkey: r.depositorBtcPubkey,
226
228
  vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
227
229
  vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys
228
230
  });
229
- et(
231
+ rt(
230
232
  e.challenger_presign_data,
231
233
  s,
232
234
  r.universalChallengerBtcPubkeys
233
235
  );
234
- const n = await Oe({
236
+ const i = await Oe({
235
237
  vaultCoreVersion: r.vaultCoreVersion,
236
238
  vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
237
239
  vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
@@ -247,25 +249,25 @@ async function rt(e, t, r) {
247
249
  network: r.network,
248
250
  claimerBtcPubkey: r.depositorBtcPubkey,
249
251
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
250
- commissionBps: Ze,
252
+ commissionBps: tt,
251
253
  protocolFeeRate: r.protocolFeeRate,
252
254
  councilMembers: r.councilMembers,
253
255
  councilQuorum: r.councilQuorum
254
256
  });
255
- o.push(n.psbtHex), a.push(
257
+ o.push(i.psbtHex), a.push(
256
258
  K(
257
259
  t,
258
- X
260
+ G
259
261
  )
260
262
  );
261
- const i = y(r.depositorBtcPubkey), u = _.fromHex(
262
- y(e.assert_tx.tx_hex)
263
+ const n = v(r.depositorBtcPubkey), u = $.fromHex(
264
+ v(e.assert_tx.tx_hex)
263
265
  );
264
266
  for (const h of e.challenger_presign_data) {
265
- const c = y(h.challenger_pubkey), d = o.length, p = await ot({
267
+ const c = v(h.challenger_pubkey), d = o.length, p = await st({
266
268
  challenger: h,
267
269
  challengerPubkey: c,
268
- claimerPubkey: i,
270
+ claimerPubkey: n,
269
271
  localChallengers: s,
270
272
  assertTxParsed: u,
271
273
  ctx: r
@@ -273,7 +275,7 @@ async function rt(e, t, r) {
273
275
  o.push(p), a.push(
274
276
  K(
275
277
  t,
276
- X
278
+ G
277
279
  )
278
280
  ), l.push({
279
281
  challengerPubkey: c,
@@ -282,7 +284,7 @@ async function rt(e, t, r) {
282
284
  }
283
285
  return { psbtHexes: o, signOptions: a, challengerEntries: l };
284
286
  }
285
- async function ot(e) {
287
+ async function st(e) {
286
288
  const {
287
289
  challenger: t,
288
290
  challengerPubkey: r,
@@ -296,31 +298,31 @@ async function ot(e) {
296
298
  r,
297
299
  s.network
298
300
  );
299
- const n = _.fromHex(
300
- y(t.nopayout_tx.tx_hex)
301
- ), i = _.fromHex(
302
- y(t.challenge_assert_x_tx.tx_hex)
303
- ), u = _.fromHex(
304
- y(t.challenge_assert_y_tx.tx_hex)
301
+ const i = $.fromHex(
302
+ v(t.nopayout_tx.tx_hex)
303
+ ), n = $.fromHex(
304
+ v(t.challenge_assert_x_tx.tx_hex)
305
+ ), u = $.fromHex(
306
+ v(t.challenge_assert_y_tx.tx_hex)
305
307
  );
306
- if (n.ins.length !== 3)
308
+ if (i.ins.length !== 3)
307
309
  throw new Error(
308
- `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${n.ins.length}`
310
+ `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
309
311
  );
310
- H(
311
- n,
312
+ N(
313
+ i,
312
314
  0,
313
315
  l,
314
316
  "Assert",
315
317
  r
316
- ), H(
317
- n,
318
- 1,
318
+ ), N(
319
319
  i,
320
+ 1,
321
+ n,
320
322
  "ChallengeAssertX",
321
323
  r
322
- ), H(
323
- n,
324
+ ), N(
325
+ i,
324
326
  2,
325
327
  u,
326
328
  "ChallengeAssertY",
@@ -328,13 +330,13 @@ async function ot(e) {
328
330
  );
329
331
  const h = [
330
332
  l.outs[0],
331
- i.outs[0],
333
+ n.outs[0],
332
334
  u.outs[0]
333
335
  ].map((c) => ({
334
- script_pubkey: ie(new Uint8Array(c.script)),
336
+ script_pubkey: ue(new Uint8Array(c.script)),
335
337
  value: c.value
336
338
  }));
337
- return De({
339
+ return Ne({
338
340
  noPayoutTxHex: t.nopayout_tx.tx_hex,
339
341
  challengerPubkey: r,
340
342
  prevouts: h,
@@ -349,7 +351,7 @@ async function ot(e) {
349
351
  }
350
352
  });
351
353
  }
352
- function nt(e, t, r) {
354
+ function at(e, t, r) {
353
355
  B(e[0]);
354
356
  const a = I(
355
357
  e[0].returnedPsbtHex,
@@ -364,17 +366,17 @@ function nt(e, t, r) {
364
366
  const l = {};
365
367
  for (const s of t) {
366
368
  B(e[s.noPayoutIdx]);
367
- const n = I(
369
+ const i = I(
368
370
  e[s.noPayoutIdx].returnedPsbtHex,
369
371
  r
370
372
  );
371
373
  V({
372
374
  requestedPsbtHex: e[s.noPayoutIdx].requestedPsbtHex,
373
- signatureHex: n,
375
+ signatureHex: i,
374
376
  signerXOnlyPubkeyHex: r,
375
377
  inputIndex: 0
376
378
  }), l[s.challengerPubkey] = {
377
- nopayout_signature: n
379
+ nopayout_signature: i
378
380
  };
379
381
  }
380
382
  return {
@@ -384,68 +386,68 @@ function nt(e, t, r) {
384
386
  per_challenger: l
385
387
  };
386
388
  }
387
- async function st(e) {
389
+ async function it(e) {
388
390
  const { depositorGraph: t, btcWallet: r, signingContext: o } = e, a = await r.getPublicKeyHex(), { depositorPubkey: l } = Te(
389
391
  a,
390
- y(o.depositorBtcPubkey)
391
- ), { psbtHexes: s, signOptions: n, challengerEntries: i } = await rt(
392
+ v(o.depositorBtcPubkey)
393
+ ), { psbtHexes: s, signOptions: i, challengerEntries: n } = await nt(
392
394
  t,
393
395
  a,
394
396
  o
395
- ), u = await Re(
397
+ ), u = await Ce(
396
398
  r,
397
399
  s,
398
- n
400
+ i
399
401
  ), h = s.map((c, d) => ({
400
402
  requestedPsbtHex: c,
401
403
  returnedPsbtHex: u[d]
402
404
  }));
403
- return nt(
405
+ return at(
404
406
  h,
405
- i,
407
+ n,
406
408
  l
407
409
  );
408
410
  }
409
- const at = 1e4;
410
- async function pe(e) {
411
+ const ut = 1e4;
412
+ async function ge(e) {
411
413
  const {
412
414
  statusReader: t,
413
415
  peginTxid: r,
414
416
  targetStatuses: o,
415
417
  timeoutMs: a,
416
- pollIntervalMs: l = at,
418
+ pollIntervalMs: l = ut,
417
419
  signal: s
418
- } = e, n = Date.now();
420
+ } = e, i = Date.now();
419
421
  for (; ; ) {
420
422
  if (s != null && s.aborted)
421
423
  throw new Error(
422
424
  `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
423
425
  );
424
- if (Date.now() - n >= a)
426
+ if (Date.now() - i >= a)
425
427
  throw new Error(
426
428
  `Polling timeout after ${a}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
427
429
  );
428
430
  try {
429
- const i = await t.getPeginStatus(
431
+ const n = await t.getPeginStatus(
430
432
  { pegin_txid: r },
431
433
  s
432
434
  );
433
- if (i.pegin_txid.toLowerCase() !== r.toLowerCase())
435
+ if (n.pegin_txid.toLowerCase() !== r.toLowerCase())
434
436
  throw new Error(
435
- `getPeginStatus returned status for pegin ${i.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
437
+ `getPeginStatus returned status for pegin ${n.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
436
438
  );
437
- const u = i.status;
438
- if (o.has(u) || u === T.ACTIVATED)
439
+ const u = n.status;
440
+ if (o.has(u) || u === C.ACTIVATED)
439
441
  return u;
440
- if (u === T.EXPIRED || Be.has(u))
442
+ if (u === C.EXPIRED || Be.has(u))
441
443
  throw new Error(
442
444
  `Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...o].join(", ")}`
443
445
  );
444
- } catch (i) {
445
- if (!(i instanceof Ie && i.code === Ve.PEGIN_NOT_FOUND))
446
- throw i;
446
+ } catch (n) {
447
+ if (!(n instanceof Ie && n.code === Ve.PEGIN_NOT_FOUND))
448
+ throw n;
447
449
  }
448
- await new Promise((i, u) => {
450
+ await new Promise((n, u) => {
449
451
  const h = () => {
450
452
  clearTimeout(c), u(
451
453
  new Error(
@@ -453,35 +455,35 @@ async function pe(e) {
453
455
  )
454
456
  );
455
457
  }, c = setTimeout(() => {
456
- s == null || s.removeEventListener("abort", h), i();
458
+ s == null || s.removeEventListener("abort", h), n();
457
459
  }, l);
458
460
  s == null || s.addEventListener("abort", h, { once: !0 });
459
461
  });
460
462
  }
461
463
  }
462
- const it = 1200 * 1e3, ge = /* @__PURE__ */ new Set([
463
- T.PENDING_ACKS,
464
- T.PENDING_ACTIVATION,
465
- T.ACTIVATED_PENDING_BROADCAST,
466
- T.ACTIVATED
467
- ]), ut = /* @__PURE__ */ new Set([
468
- T.PENDING_DEPOSITOR_SIGNATURES,
469
- ...ge
464
+ const lt = 1200 * 1e3, fe = /* @__PURE__ */ new Set([
465
+ C.PENDING_ACKS,
466
+ C.PENDING_ACTIVATION,
467
+ C.ACTIVATED_PENDING_BROADCAST,
468
+ C.ACTIVATED
469
+ ]), ct = /* @__PURE__ */ new Set([
470
+ C.PENDING_DEPOSITOR_SIGNATURES,
471
+ ...fe
470
472
  ]);
471
- function lt(e) {
473
+ function ht(e) {
472
474
  return e.map((t) => ({
473
475
  claimerPubkeyXOnly: O(t.claimer_pubkey),
474
476
  payoutTxHex: t.payout_tx.tx_hex,
475
477
  assertTxHex: t.assert_tx.tx_hex
476
478
  }));
477
479
  }
478
- function k(e) {
480
+ function T(e) {
479
481
  return O(e).toLowerCase();
480
482
  }
481
- function ct(e, t) {
482
- const r = (i, u, h) => {
483
+ function dt(e, t) {
484
+ const r = (n, u, h) => {
483
485
  throw new Error(
484
- `Deposit terms ${i} (${String(u)}) does not match the vault's version-locked signing context (${String(h)}); refusing to sign payouts against terms that describe a different graph.`
486
+ `Deposit terms ${n} (${String(u)}) does not match the vault's version-locked signing context (${String(h)}); refusing to sign payouts against terms that describe a different graph.`
485
487
  );
486
488
  }, o = [
487
489
  ["protocolFeeRate", e.protocolFeeRate, t.protocolFeeRate],
@@ -489,10 +491,10 @@ function ct(e, t) {
489
491
  ["timelockPegin", e.timelockPegin, t.timelockPegin],
490
492
  ["timelockAssert", e.timelockAssert, t.timelockAssert]
491
493
  ];
492
- for (const [i, u, h] of o)
493
- u !== h && r(i, u, h);
494
- const a = (i) => i.map(k).sort(), l = (i, u) => {
495
- const h = a(i), c = a(u);
494
+ for (const [n, u, h] of o)
495
+ u !== h && r(n, u, h);
496
+ const a = (n) => n.map(T).sort(), l = (n, u) => {
497
+ const h = a(n), c = a(u);
496
498
  return h.length === c.length && h.every((d, p) => d === c[p]);
497
499
  };
498
500
  l(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
@@ -507,19 +509,19 @@ function ct(e, t) {
507
509
  e.universalChallengerBtcPubkeys.join(","),
508
510
  t.universalChallengerBtcPubkeys.join(",")
509
511
  );
510
- const s = k(t.vaultProviderBtcPubkey), n = e.vaults.map(
511
- (i) => k(i.vaultProviderBtcPubkey)
512
+ const s = T(t.vaultProviderBtcPubkey), i = e.vaults.map(
513
+ (n) => T(n.vaultProviderBtcPubkey)
512
514
  );
513
- n.includes(s) || r(
515
+ i.includes(s) || r(
514
516
  "vaults[].vaultProviderBtcPubkey",
515
- n.join(",") || "<no vaults>",
517
+ i.join(",") || "<no vaults>",
516
518
  t.vaultProviderBtcPubkey
517
519
  );
518
520
  }
519
- function ht(e, t, r, o) {
520
- const a = k(o), l = [
521
- k(t),
522
- ...r.map(k)
521
+ function pt(e, t, r, o) {
522
+ const a = T(o), l = [
523
+ T(t),
524
+ ...r.map(T)
523
525
  ], s = new Set(l);
524
526
  if (s.size !== l.length)
525
527
  throw new Error(
@@ -529,12 +531,12 @@ function ht(e, t, r, o) {
529
531
  throw new Error(
530
532
  "Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
531
533
  );
532
- const n = e.map(
533
- (d) => k(d.claimer_pubkey)
534
+ const i = e.map(
535
+ (d) => T(d.claimer_pubkey)
534
536
  );
535
- if (new Set(n).size !== n.length)
537
+ if (new Set(i).size !== i.length)
536
538
  throw new Error("Presign response contains duplicate claimer entries");
537
- const i = n.filter((d) => d !== a), u = new Set(i), h = l.filter((d) => !u.has(d)), c = i.filter((d) => !s.has(d));
539
+ const n = i.filter((d) => d !== a), u = new Set(n), h = l.filter((d) => !u.has(d)), c = n.filter((d) => !s.has(d));
538
540
  if (h.length > 0 || c.length > 0)
539
541
  throw new Error(
540
542
  "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (h.length > 0 ? ` (missing: ${h.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
@@ -562,7 +564,7 @@ function j(e, t) {
562
564
  vpCommissionScriptPubKey: t.vpCommissionScriptPubKey
563
565
  };
564
566
  }
565
- async function dt(e, t, r, o) {
567
+ async function gt(e, t, r, o) {
566
568
  const a = new _e({
567
569
  network: t.network,
568
570
  btcWallet: e
@@ -575,22 +577,22 @@ async function dt(e, t, r, o) {
575
577
  )).map((u) => u.payoutSignature);
576
578
  else {
577
579
  s = [];
578
- for (let i = 0; i < r.length; i++) {
579
- o == null || o(i, l);
580
+ for (let n = 0; n < r.length; n++) {
581
+ o == null || o(n, l);
580
582
  const u = await a.signPayoutTransaction(
581
- j(r[i], t)
583
+ j(r[n], t)
582
584
  );
583
585
  s.push(u.signature);
584
586
  }
585
587
  }
586
- const n = {};
587
- for (let i = 0; i < r.length; i++)
588
- n[r[i].claimerPubkeyXOnly] = {
589
- payout_signature: s[i]
588
+ const i = {};
589
+ for (let n = 0; n < r.length; n++)
590
+ i[r[n].claimerPubkeyXOnly] = {
591
+ payout_signature: s[n]
590
592
  };
591
- return o == null || o(l, l), n;
593
+ return o == null || o(l, l), i;
592
594
  }
593
- async function Yt(e) {
595
+ async function er(e) {
594
596
  const {
595
597
  statusReader: t,
596
598
  presignClient: r,
@@ -598,25 +600,25 @@ async function Yt(e) {
598
600
  peginTxid: a,
599
601
  depositorPk: l,
600
602
  signingContext: s,
601
- depositTerms: n,
602
- timeoutMs: i = it,
603
+ depositTerms: i,
604
+ timeoutMs: n = lt,
603
605
  signal: u,
604
606
  onProgress: h
605
- } = e, c = await pe({
607
+ } = e, c = await ge({
606
608
  statusReader: t,
607
609
  peginTxid: a,
608
- targetStatuses: ut,
609
- timeoutMs: i,
610
+ targetStatuses: ct,
611
+ timeoutMs: n,
610
612
  signal: u
611
613
  });
612
- if (ge.has(c))
614
+ if (fe.has(c))
613
615
  return;
614
- if (u == null || u.throwIfAborted(), n !== void 0 && ct(n, s), Ce(o)) {
615
- if (!n)
616
+ if (u == null || u.throwIfAborted(), i !== void 0 && dt(i, s), Ae(o)) {
617
+ if (!i)
616
618
  throw new Error(
617
619
  "runDepositorPresignFlow: this wallet requires approved deposit terms but none were provided. Fresh deposits must pass PreparePeginResult.depositTerms; resume flows must rebuild them from on-chain state (the vault app's rebuildDepositTerms)."
618
620
  );
619
- typeof o.validateDepositTerms == "function" && await o.validateDepositTerms(n), await o.approveDepositTerms(n);
621
+ typeof o.validateDepositTerms == "function" && await o.validateDepositTerms(i), await o.approveDepositTerms(i);
620
622
  }
621
623
  const d = await r.requestDepositorPresignTransactions(
622
624
  {
@@ -626,23 +628,23 @@ async function Yt(e) {
626
628
  u
627
629
  );
628
630
  u == null || u.throwIfAborted();
629
- const p = k(l);
630
- ht(
631
+ const p = T(l);
632
+ pt(
631
633
  d.txs,
632
634
  s.vaultProviderBtcPubkey,
633
635
  s.vaultKeeperBtcPubkeys,
634
636
  l
635
637
  );
636
638
  const g = d.txs.filter(
637
- (m) => k(m.claimer_pubkey) !== p
638
- ), b = lt(g), f = await dt(
639
+ (y) => T(y.claimer_pubkey) !== p
640
+ ), P = ht(g), m = await gt(
639
641
  o,
640
642
  s,
641
- b,
643
+ P,
642
644
  h
643
645
  );
644
646
  u == null || u.throwIfAborted();
645
- const P = await st({
647
+ const f = await it({
646
648
  depositorGraph: d.depositor_graph,
647
649
  btcWallet: o,
648
650
  signingContext: {
@@ -664,56 +666,56 @@ async function Yt(e) {
664
666
  }
665
667
  });
666
668
  u == null || u.throwIfAborted();
667
- const v = { ...f };
668
- v[y(l)] = P.payout_signatures, await r.submitDepositorPresignatures(
669
+ const w = { ...m };
670
+ w[v(l)] = f.payout_signatures, await r.submitDepositorPresignatures(
669
671
  {
670
672
  pegin_txid: a,
671
673
  depositor_pk: l,
672
- signatures: v,
673
- depositor_claimer_presignatures: P
674
+ signatures: w,
675
+ depositor_claimer_presignatures: f
674
676
  },
675
677
  u
676
678
  );
677
679
  }
678
- const pt = 300 * 1e3, gt = /* @__PURE__ */ new Set([
679
- T.PENDING_DEPOSITOR_WOTS_PK,
680
- ...ue
680
+ const ft = 300 * 1e3, mt = /* @__PURE__ */ new Set([
681
+ C.PENDING_DEPOSITOR_WOTS_PK,
682
+ ...le
681
683
  ]);
682
- async function Jt(e) {
684
+ async function tr(e) {
683
685
  const {
684
686
  statusReader: t,
685
687
  wotsSubmitter: r,
686
688
  peginTxid: o,
687
689
  depositorPk: a,
688
690
  wotsPublicKeys: l,
689
- timeoutMs: s = pt,
690
- signal: n
691
+ timeoutMs: s = ft,
692
+ signal: i
691
693
  } = e;
692
- n == null || n.throwIfAborted();
693
- const i = await pe({
694
+ i == null || i.throwIfAborted();
695
+ const n = await ge({
694
696
  statusReader: t,
695
697
  peginTxid: o,
696
- targetStatuses: gt,
698
+ targetStatuses: mt,
697
699
  timeoutMs: s,
698
- signal: n
700
+ signal: i
699
701
  });
700
- ue.has(i) || (n == null || n.throwIfAborted(), await r.submitDepositorWotsKey(
702
+ le.has(n) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
701
703
  {
702
704
  pegin_txid: o,
703
705
  depositor_pk: a,
704
706
  wots_public_keys: l
705
707
  },
706
- n
708
+ i
707
709
  ));
708
710
  }
709
711
  function D(e) {
710
712
  return e.registration || e.operation;
711
713
  }
712
- function ft(e, t, r) {
713
- const o = x(e);
714
+ function vt(e, t, r) {
715
+ const o = R(e);
714
716
  return {
715
- registration: o === x(t),
716
- operation: o === x(r)
717
+ registration: o === R(t),
718
+ operation: o === R(r)
717
719
  };
718
720
  }
719
721
  function Q(e, t, r) {
@@ -724,12 +726,12 @@ function Q(e, t, r) {
724
726
  };
725
727
  }
726
728
  function F(e) {
727
- return e.map(x).sort();
729
+ return e.map(R).sort();
728
730
  }
729
731
  function W(e, t) {
730
732
  return e.length === t.length && e.every((r, o) => r === t[o]);
731
733
  }
732
- async function Zt(e) {
734
+ async function rr(e) {
733
735
  const {
734
736
  vaultProviderEthAddress: t,
735
737
  hintBtcPubkey: r,
@@ -738,21 +740,21 @@ async function Zt(e) {
738
740
  context: l
739
741
  } = e;
740
742
  if (!r) return;
741
- const s = x(r);
742
- if (s === x(o)) return;
743
- const n = x(
743
+ const s = R(r);
744
+ if (s === R(o)) return;
745
+ const i = R(
744
746
  await a()
745
747
  );
746
- if (s !== n)
748
+ if (s !== i)
747
749
  throw new Error(
748
750
  `Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${l ? ` ${l}` : ""}`
749
751
  );
750
752
  }
751
753
  function M(e, t, r) {
752
- const o = `${e} operation key (admin=${t.ethAddress})`, a = G(
754
+ const o = `${e} operation key (admin=${t.ethAddress})`, a = q(
753
755
  t.btcPubKey,
754
756
  `${e} roster key (admin=${t.ethAddress})`
755
- ), l = G(r, o);
757
+ ), l = q(r, o);
756
758
  return {
757
759
  adminAddress: t.ethAddress,
758
760
  genesisBtcPubkey: a,
@@ -760,7 +762,7 @@ function M(e, t, r) {
760
762
  rotated: l !== a
761
763
  };
762
764
  }
763
- function mt(e) {
765
+ function Pt(e) {
764
766
  const t = /* @__PURE__ */ new Map();
765
767
  for (const r of e) {
766
768
  const o = t.get(r.operationBtcPubkey);
@@ -771,7 +773,7 @@ function mt(e) {
771
773
  t.set(r.operationBtcPubkey, r.adminAddress);
772
774
  }
773
775
  }
774
- function fe(e, t, r) {
776
+ function me(e, t, r) {
775
777
  if (t.vaultKeepers.length !== e.vaultKeepers.length || t.universalChallengers.length !== e.universalChallengers.length)
776
778
  throw new Error(
777
779
  `Operation-key resolution returned ${t.vaultKeepers.length} keeper and ${t.universalChallengers.length} challenger keys for a roster of ${e.vaultKeepers.length} keepers and ${e.universalChallengers.length} challengers`
@@ -784,11 +786,11 @@ function fe(e, t, r) {
784
786
  },
785
787
  t.vaultProvider
786
788
  ), a = e.vaultKeepers.map(
787
- (s, n) => M("vault keeper", s, t.vaultKeepers[n])
789
+ (s, i) => M("vault keeper", s, t.vaultKeepers[i])
788
790
  ), l = e.universalChallengers.map(
789
- (s, n) => M("universal challenger", s, t.universalChallengers[n])
791
+ (s, i) => M("universal challenger", s, t.universalChallengers[i])
790
792
  );
791
- return mt([
793
+ return Pt([
792
794
  o,
793
795
  ...a,
794
796
  ...l
@@ -803,24 +805,24 @@ function fe(e, t, r) {
803
805
  query: e
804
806
  };
805
807
  }
806
- async function Pt(e) {
808
+ async function yt(e) {
807
809
  const t = await e.operationKeyReader.getCurrentOperationKeys(
808
810
  e.query
809
811
  );
810
- return fe(e.query, t, { mode: "current" });
812
+ return me(e.query, t, { mode: "current" });
811
813
  }
812
- async function vt(e) {
814
+ async function bt(e) {
813
815
  const t = await e.operationKeyReader.getOperationKeysAtEpochs(
814
816
  e.query,
815
817
  e.epochs
816
818
  );
817
- return fe(e.query, t, {
819
+ return me(e.query, t, {
818
820
  mode: "epochs",
819
821
  epochs: e.epochs
820
822
  });
821
823
  }
822
- const Y = (e) => e.map(x).sort();
823
- async function er(e) {
824
+ const Y = (e) => e.map(R).sort();
825
+ async function or(e) {
824
826
  const {
825
827
  vaultRegistryReader: t,
826
828
  vaultKeeperReader: r,
@@ -828,8 +830,8 @@ async function er(e) {
828
830
  vaultProviderEthAddress: a,
829
831
  applicationEntryPoint: l,
830
832
  expectedVaultProviderBtcPubkey: s,
831
- expectedVaultKeeperBtcPubkeys: n,
832
- expectedUniversalChallengerBtcPubkeys: i,
833
+ expectedVaultKeeperBtcPubkeys: i,
834
+ expectedUniversalChallengerBtcPubkeys: n,
833
835
  operationKeyReader: u,
834
836
  onIndexerServingOperationKeys: h,
835
837
  onIndexerHintsInconsistent: c
@@ -843,7 +845,7 @@ async function er(e) {
843
845
  ),
844
846
  r.getCurrentVaultKeepersVersion(l),
845
847
  o.getLatestUniversalChallengersVersion()
846
- ]), [b, f] = await Promise.all([
848
+ ]), [P, m] = await Promise.all([
847
849
  r.getVaultKeepersByVersion(
848
850
  l,
849
851
  p
@@ -851,71 +853,71 @@ async function er(e) {
851
853
  o.getUniversalChallengersByVersion(
852
854
  g
853
855
  )
854
- ]), P = {
855
- vaultProvider: x(d),
856
- vaultKeepers: Y(b.map((E) => E.btcPubKey)),
857
- universalChallengers: Y(f.map((E) => E.btcPubKey))
858
- }, v = await Pt({
856
+ ]), f = {
857
+ vaultProvider: R(d),
858
+ vaultKeepers: Y(P.map((E) => E.btcPubKey)),
859
+ universalChallengers: Y(m.map((E) => E.btcPubKey))
860
+ }, w = await yt({
859
861
  operationKeyReader: u,
860
862
  query: {
861
863
  vaultProviderEthAddress: a,
862
864
  vaultProviderGenesisBtcPubkey: `0x${d}`,
863
865
  applicationEntryPoint: l,
864
- vaultKeepers: b,
865
- universalChallengers: f
866
+ vaultKeepers: P,
867
+ universalChallengers: m
866
868
  }
867
- }), m = {
868
- vaultProvider: v.vaultProvider.operationBtcPubkey,
869
- vaultKeepers: [...v.vaultKeeperOperationKeysSorted],
869
+ }), y = {
870
+ vaultProvider: w.vaultProvider.operationBtcPubkey,
871
+ vaultKeepers: [...w.vaultKeeperOperationKeysSorted],
870
872
  universalChallengers: [
871
- ...v.universalChallengerOperationKeysSorted
873
+ ...w.universalChallengerOperationKeysSorted
872
874
  ]
873
- }, A = ft(
875
+ }, k = vt(
874
876
  s,
875
- P.vaultProvider,
876
- m.vaultProvider
877
- ), S = Q(
878
- n,
879
- P.vaultKeepers,
880
- m.vaultKeepers
881
- ), $ = Q(
877
+ f.vaultProvider,
878
+ y.vaultProvider
879
+ ), x = Q(
882
880
  i,
883
- P.universalChallengers,
884
- m.universalChallengers
881
+ f.vaultKeepers,
882
+ y.vaultKeepers
883
+ ), A = Q(
884
+ n,
885
+ f.universalChallengers,
886
+ y.universalChallengers
885
887
  );
886
- if (!D(A))
888
+ if (!D(k))
887
889
  throw new Error(
888
890
  `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${a}. Refresh and try again.`
889
891
  );
890
- if (!D(S))
892
+ if (!D(x))
891
893
  throw new Error(
892
894
  `Vault keeper BTC pubkeys (v${p}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
893
895
  );
894
- if (!D($))
896
+ if (!D(A))
895
897
  throw new Error(
896
898
  `Universal challenger BTC pubkeys (v${g}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
897
899
  );
898
- const w = [A, S, $], we = w.some((E) => E.registration && !E.operation), z = w.some((E) => E.operation && !E.registration);
899
- if (we && z) {
900
+ const b = [k, x, A], ke = b.some((E) => E.registration && !E.operation), X = b.some((E) => E.operation && !E.registration);
901
+ if (ke && X) {
900
902
  const E = `Indexer participant hints are internally inconsistent for vault provider ${a}: some roles match the registration keys while others match the rotated operation keys.`;
901
903
  throw c == null || c(E), new Error(`${E} Refresh and try again.`);
902
904
  }
903
- return z && (h == null || h(
905
+ return X && (h == null || h(
904
906
  `Indexer is serving rotated operation keys for vault provider ${a}`
905
907
  )), {
906
- vaultProviderBtcPubkeyXOnly: m.vaultProvider,
907
- vaultKeeperBtcPubkeysSorted: m.vaultKeepers,
908
- universalChallengerBtcPubkeysSorted: m.universalChallengers,
908
+ vaultProviderBtcPubkeyXOnly: y.vaultProvider,
909
+ vaultKeeperBtcPubkeysSorted: y.vaultKeepers,
910
+ universalChallengerBtcPubkeysSorted: y.universalChallengers,
909
911
  expectedAppVaultKeepersVersion: p,
910
912
  expectedUniversalChallengersVersion: g,
911
- registrationKeys: P,
912
- participantKeys: v
913
+ registrationKeys: f,
914
+ participantKeys: w
913
915
  };
914
916
  }
915
- function yt(e) {
917
+ function wt(e) {
916
918
  return /^[0-9a-fA-F]{64}$/.test(e);
917
919
  }
918
- function tr(e) {
920
+ function nr(e) {
919
921
  const {
920
922
  amountSats: t,
921
923
  minDeposit: r,
@@ -926,29 +928,29 @@ function tr(e) {
926
928
  } = e;
927
929
  return !(t <= 0n || t < r || o && o > 0n && t > o || l == null || s == null || t + l + s > a);
928
930
  }
929
- function rr(e, t, r) {
931
+ function sr(e, t, r) {
930
932
  return e <= 0n ? {
931
933
  valid: !1,
932
934
  error: "Deposit amount must be greater than zero"
933
935
  } : e < t ? {
934
936
  valid: !1,
935
- error: `Minimum deposit is ${R(t)} BTC`
937
+ error: `Minimum deposit is ${_(t)} BTC`
936
938
  } : r && r > 0n && e > r ? {
937
939
  valid: !1,
938
- error: `Maximum deposit is ${R(r)} BTC`
940
+ error: `Maximum deposit is ${_(r)} BTC`
939
941
  } : { valid: !0 };
940
942
  }
941
- function or(e) {
943
+ function ar(e) {
942
944
  const { amount: t, effectiveRemaining: r } = e;
943
945
  return r === null ? { valid: !0 } : r === 0n ? {
944
946
  valid: !1,
945
947
  error: "Supply cap reached — deposits temporarily paused"
946
948
  } : t > r ? {
947
949
  valid: !1,
948
- error: `Vault size exceeds remaining capacity (${R(r)} BTC)`
950
+ error: `Vault size exceeds remaining capacity (${_(r)} BTC)`
949
951
  } : { valid: !0 };
950
952
  }
951
- function nr(e, t) {
953
+ function ir(e, t) {
952
954
  if (!e || e.length === 0)
953
955
  return {
954
956
  valid: !1,
@@ -964,7 +966,7 @@ function nr(e, t) {
964
966
  error: "Invalid vault provider selected"
965
967
  } : { valid: !0 };
966
968
  }
967
- function bt(e, t, r) {
969
+ function kt(e, t, r) {
968
970
  if (!e || e.length === 0)
969
971
  return {
970
972
  valid: !1,
@@ -980,40 +982,40 @@ function bt(e, t, r) {
980
982
  if (t && a < t)
981
983
  return {
982
984
  valid: !1,
983
- error: `Vault ${o + 1} amount ${R(a)} BTC is below minimum deposit ${R(t)} BTC`
985
+ error: `Vault ${o + 1} amount ${_(a)} BTC is below minimum deposit ${_(t)} BTC`
984
986
  };
985
987
  if (r && a > r)
986
988
  return {
987
989
  valid: !1,
988
- error: `Vault ${o + 1} amount ${R(a)} BTC exceeds maximum deposit ${R(r)} BTC`
990
+ error: `Vault ${o + 1} amount ${_(a)} BTC exceeds maximum deposit ${_(r)} BTC`
989
991
  };
990
992
  }
991
993
  return { valid: !0 };
992
994
  }
993
- function wt(e) {
994
- const t = y(e);
995
- return yt(t) ? { valid: !0 } : {
995
+ function Et(e) {
996
+ const t = v(e);
997
+ return wt(t) ? { valid: !0 } : {
996
998
  valid: !1,
997
999
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
998
1000
  };
999
1001
  }
1000
- function Et(e) {
1002
+ function xt(e) {
1001
1003
  if (!e || e.length === 0)
1002
1004
  throw new Error(
1003
1005
  "No vault keepers available. The system requires at least one vault keeper to create a deposit."
1004
1006
  );
1005
1007
  }
1006
- function kt(e) {
1008
+ function Tt(e) {
1007
1009
  if (!e || e.length === 0)
1008
1010
  throw new Error(
1009
1011
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
1010
1012
  );
1011
1013
  }
1012
- function xt(e) {
1014
+ function Rt(e) {
1013
1015
  if (e.length === 0)
1014
1016
  throw new Error("No spendable UTXOs available");
1015
1017
  }
1016
- function sr(e) {
1018
+ function ur(e) {
1017
1019
  const {
1018
1020
  vaultAmounts: t,
1019
1021
  confirmedUTXOs: r,
@@ -1021,50 +1023,50 @@ function sr(e) {
1021
1023
  vaultKeeperBtcPubkeys: a,
1022
1024
  universalChallengerBtcPubkeys: l,
1023
1025
  minDeposit: s,
1024
- maxDeposit: n
1025
- } = e, i = bt(
1026
+ maxDeposit: i
1027
+ } = e, n = kt(
1026
1028
  t,
1027
1029
  s,
1028
- n
1030
+ i
1029
1031
  );
1030
- if (!i.valid)
1031
- throw new Error(i.error);
1032
- const u = wt(o);
1032
+ if (!n.valid)
1033
+ throw new Error(n.error);
1034
+ const u = Et(o);
1033
1035
  if (!u.valid)
1034
1036
  throw new Error(u.error);
1035
- Et(a), kt(l), xt(r);
1037
+ xt(a), Tt(l), Rt(r);
1036
1038
  }
1037
- class me extends Error {
1039
+ class ve extends Error {
1038
1040
  constructor(t) {
1039
1041
  super(t), this.name = "ParticipantKeyDriftError";
1040
1042
  }
1041
1043
  }
1042
- function ar(e) {
1043
- return e instanceof me || e instanceof Error && e.name === "ParticipantKeyDriftError";
1044
+ function lr(e) {
1045
+ return e instanceof ve || e instanceof Error && e.name === "ParticipantKeyDriftError";
1044
1046
  }
1045
1047
  function J(e, t, r) {
1046
1048
  return t.length === r.length && t.every((o, a) => o === r[a]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
1047
1049
  }
1048
- async function ir(e) {
1050
+ async function cr(e) {
1049
1051
  const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: o, expected: a } = e, l = a.query;
1050
1052
  if (o.length === 0) return;
1051
- const s = await t.getVaultKeyEpochsBatch(o), n = [];
1052
- for (const [i, u] of s.entries()) {
1053
- const h = o[i];
1053
+ const s = await t.getVaultKeyEpochsBatch(o), i = [];
1054
+ for (const [n, u] of s.entries()) {
1055
+ const h = o[n];
1054
1056
  let c;
1055
1057
  try {
1056
- c = await vt({
1058
+ c = await bt({
1057
1059
  operationKeyReader: r,
1058
1060
  query: l,
1059
1061
  epochs: u
1060
1062
  });
1061
1063
  } catch (g) {
1062
- n.push(
1064
+ i.push(
1063
1065
  `vault ${h}: could not resolve participants at frozen epochs (vp=${u.vpKeyEpoch}, keeper=${u.appKeeperKeyEpoch}, uc=${u.ucKeyEpoch}): ${g.message}`
1064
1066
  );
1065
1067
  continue;
1066
1068
  }
1067
- c.vaultProvider.operationBtcPubkey !== a.vaultProvider.operationBtcPubkey && n.push(
1069
+ c.vaultProvider.operationBtcPubkey !== a.vaultProvider.operationBtcPubkey && i.push(
1068
1070
  `vault ${h}: vault provider key expected ${a.vaultProvider.operationBtcPubkey}, got ${c.vaultProvider.operationBtcPubkey}`
1069
1071
  );
1070
1072
  const d = J(
@@ -1072,17 +1074,17 @@ async function ir(e) {
1072
1074
  a.vaultKeeperOperationKeysSorted,
1073
1075
  c.vaultKeeperOperationKeysSorted
1074
1076
  );
1075
- d && n.push(d);
1077
+ d && i.push(d);
1076
1078
  const p = J(
1077
1079
  `vault ${h}: universal challenger keys`,
1078
1080
  a.universalChallengerOperationKeysSorted,
1079
1081
  c.universalChallengerOperationKeysSorted
1080
1082
  );
1081
- p && n.push(p);
1083
+ p && i.push(p);
1082
1084
  }
1083
- if (n.length > 0)
1084
- throw new me(
1085
- `Aborting BTC broadcast: participant operation keys changed during registration (${n.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
1085
+ if (i.length > 0)
1086
+ throw new ve(
1087
+ `Aborting BTC broadcast: participant operation keys changed during registration (${i.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
1086
1088
  );
1087
1089
  }
1088
1090
  class Pe extends Error {
@@ -1090,10 +1092,10 @@ class Pe extends Error {
1090
1092
  super(t), this.name = "RegisteredVaultVersionMismatchError";
1091
1093
  }
1092
1094
  }
1093
- function ur(e) {
1095
+ function hr(e) {
1094
1096
  return e instanceof Pe || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
1095
1097
  }
1096
- async function lr(e) {
1098
+ async function dr(e) {
1097
1099
  const {
1098
1100
  vaultRegistryReader: t,
1099
1101
  vaultIds: r,
@@ -1101,70 +1103,70 @@ async function lr(e) {
1101
1103
  expectedAppVaultKeepersVersion: a,
1102
1104
  expectedUniversalChallengersVersion: l,
1103
1105
  expectedVaultCoreVersion: s
1104
- } = e, n = await t.getProtocolInfoBatch(r), i = [];
1105
- if (n.forEach((u, h) => {
1106
+ } = e, i = await t.getProtocolInfoBatch(r), n = [];
1107
+ if (i.forEach((u, h) => {
1106
1108
  const c = r[h];
1107
- u.offchainParamsVersion !== o && i.push(
1109
+ u.offchainParamsVersion !== o && n.push(
1108
1110
  `vault ${c}: offchainParams expected v${o}, got v${u.offchainParamsVersion}`
1109
- ), u.appVaultKeepersVersion !== a && i.push(
1111
+ ), u.appVaultKeepersVersion !== a && n.push(
1110
1112
  `vault ${c}: appVaultKeepers expected v${a}, got v${u.appVaultKeepersVersion}`
1111
- ), u.universalChallengersVersion !== l && i.push(
1113
+ ), u.universalChallengersVersion !== l && n.push(
1112
1114
  `vault ${c}: universalChallengers expected v${l}, got v${u.universalChallengersVersion}`
1113
- ), u.vaultCoreVersion !== s && i.push(
1115
+ ), u.vaultCoreVersion !== s && n.push(
1114
1116
  `vault ${c}: vaultCoreVersion expected v${s} (build-time active), got v${u.vaultCoreVersion}`
1115
1117
  );
1116
- }), i.length > 0)
1118
+ }), n.length > 0)
1117
1119
  throw new Pe(
1118
- `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${i.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
1120
+ `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${n.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
1119
1121
  );
1120
1122
  }
1121
- var ve = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(ve || {});
1122
- const Tt = /* @__PURE__ */ new Set([
1123
+ var ye = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(ye || {});
1124
+ const Ct = /* @__PURE__ */ new Set([
1123
1125
  "PayoutBroadcast",
1124
1126
  "PayoutBlocked"
1125
1127
  /* PAYOUT_BLOCKED */
1126
1128
  ]);
1127
- function cr(e) {
1128
- return Object.values(ve).includes(
1129
+ function pr(e) {
1130
+ return Object.values(ye).includes(
1129
1131
  e
1130
1132
  );
1131
1133
  }
1132
- function hr(e) {
1133
- return !!e && Tt.has(e);
1134
+ function gr(e) {
1135
+ return !!e && Ct.has(e);
1134
1136
  }
1135
1137
  class At extends Error {
1136
1138
  constructor(r, o) {
1137
1139
  super(`Refund not yet mature (BIP68 not final): ${o.message}`);
1138
- C(this, "vaultId");
1139
- C(this, "cause");
1140
+ S(this, "vaultId");
1141
+ S(this, "cause");
1140
1142
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
1141
1143
  }
1142
1144
  }
1143
- const Rt = /^0x[0-9a-fA-F]{64}$/, Ct = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, ye = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, be = 160, Z = 2e3, ee = 10n, te = 100n;
1144
- function dr(e) {
1145
+ const _t = /^0x[0-9a-fA-F]{64}$/, St = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, be = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, we = 160, Z = 2e3, ee = 10n, te = 100n;
1146
+ function fr(e) {
1145
1147
  if (!Number.isFinite(e) || e <= 0)
1146
1148
  throw new Error(
1147
1149
  `feeRateSatsVb must be a positive finite number, got ${e}`
1148
1150
  );
1149
- return BigInt(Math.ceil(e * be));
1151
+ return BigInt(Math.ceil(e * we));
1150
1152
  }
1151
- const _t = 1, St = /non-BIP68-final/i;
1152
- function L(e, t) {
1153
+ const $t = 1, Bt = /non-BIP68-final/i;
1154
+ function U(e, t) {
1153
1155
  if (e.length !== 66)
1154
1156
  throw new Error(
1155
1157
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
1156
1158
  );
1157
- if (!Rt.test(e))
1159
+ if (!_t.test(e))
1158
1160
  throw new Error(
1159
1161
  `${t} must contain only hex characters after the 0x prefix`
1160
1162
  );
1161
1163
  }
1162
- function U(e, t) {
1164
+ function L(e, t) {
1163
1165
  if (!Number.isInteger(e) || e < 0)
1164
1166
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
1165
1167
  }
1166
- function $t(e) {
1167
- if (L(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
1168
+ function It(e) {
1169
+ if (U(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
1168
1170
  throw new Error(
1169
1171
  `htlcVout must be a non-negative integer, got ${e.htlcVout}`
1170
1172
  );
@@ -1176,7 +1178,7 @@ function $t(e) {
1176
1178
  );
1177
1179
  for (let r = 0; r < e.batch.length; r++) {
1178
1180
  const o = e.batch[r];
1179
- if (L(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
1181
+ if (U(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
1180
1182
  throw new Error(
1181
1183
  `batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${o.htlcVout}`
1182
1184
  );
@@ -1194,27 +1196,27 @@ function $t(e) {
1194
1196
  throw new Error(
1195
1197
  `batch[${e.htlcVout}].amount (${t.amount}) does not match target amount (${e.amount})`
1196
1198
  );
1197
- if (U(e.offchainParamsVersion, "offchainParamsVersion"), U(e.appVaultKeepersVersion, "appVaultKeepersVersion"), U(
1199
+ if (L(e.offchainParamsVersion, "offchainParamsVersion"), L(e.appVaultKeepersVersion, "appVaultKeepersVersion"), L(
1198
1200
  e.universalChallengersVersion,
1199
1201
  "universalChallengersVersion"
1200
- ), Ne(
1202
+ ), Ue(
1201
1203
  e.vaultCoreVersion,
1202
1204
  "VaultRefundData.vaultCoreVersion"
1203
1205
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
1204
1206
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
1205
- if (!Ct.test(e.unsignedPrePeginTxHex))
1207
+ if (!St.test(e.unsignedPrePeginTxHex))
1206
1208
  throw new Error(
1207
1209
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
1208
1210
  );
1209
- if (!e.depositorBtcPubkey || !ye.test(e.depositorBtcPubkey))
1211
+ if (!e.depositorBtcPubkey || !be.test(e.depositorBtcPubkey))
1210
1212
  throw new Error(
1211
1213
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
1212
1214
  );
1213
1215
  if (typeof e.amount != "bigint" || e.amount <= 0n)
1214
1216
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
1215
1217
  }
1216
- function Bt(e) {
1217
- if (!e.vaultProviderPubkey || !ye.test(e.vaultProviderPubkey))
1218
+ function Vt(e) {
1219
+ if (!e.vaultProviderPubkey || !be.test(e.vaultProviderPubkey))
1218
1220
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
1219
1221
  if (e.vaultKeeperPubkeys.length === 0)
1220
1222
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -1239,18 +1241,7 @@ function Bt(e) {
1239
1241
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
1240
1242
  );
1241
1243
  }
1242
- function It(e) {
1243
- const t = le.fromHex(e);
1244
- try {
1245
- t.finalizeAllInputs();
1246
- } catch (r) {
1247
- const o = r instanceof Error ? r.message : String(r);
1248
- if (!o.includes("already finalized"))
1249
- throw new Error(`Failed to finalize refund PSBT: ${o}`);
1250
- }
1251
- return t.extractTransaction().toHex();
1252
- }
1253
- async function pr(e) {
1244
+ async function mr(e) {
1254
1245
  const {
1255
1246
  vaultId: t,
1256
1247
  readVault: r,
@@ -1258,52 +1249,52 @@ async function pr(e) {
1258
1249
  feeRate: a,
1259
1250
  signPsbt: l,
1260
1251
  broadcastTx: s,
1261
- signal: n
1252
+ signal: i
1262
1253
  } = e;
1263
- n == null || n.throwIfAborted(), L(t, "vaultId");
1264
- const i = await r();
1265
- $t(i), n == null || n.throwIfAborted();
1266
- const u = await o(i);
1267
- if (Bt(u), n == null || n.throwIfAborted(), !Number.isFinite(a) || a <= 0)
1254
+ i == null || i.throwIfAborted(), U(t, "vaultId");
1255
+ const n = await r();
1256
+ It(n), i == null || i.throwIfAborted();
1257
+ const u = await o(n);
1258
+ if (Vt(u), i == null || i.throwIfAborted(), !Number.isFinite(a) || a <= 0)
1268
1259
  throw new Error(`feeRate must be a positive number, got ${a}`);
1269
1260
  if (a > Z)
1270
1261
  throw new Error(
1271
1262
  `feeRate ${a} sat/vB exceeds refund safety cap ${Z} sat/vB; refusing to sign refund.`
1272
1263
  );
1273
- const h = BigInt(Math.ceil(a * be)), c = i.amount * ee / te;
1264
+ const h = BigInt(Math.ceil(a * we)), c = n.amount * ee / te;
1274
1265
  if (h > c)
1275
1266
  throw new Error(
1276
- `Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${ee}/${te} of vault.amount=${i.amount}); refusing to sign refund.`
1267
+ `Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${ee}/${te} of vault.amount=${n.amount}); refusing to sign refund.`
1277
1268
  );
1278
- n == null || n.throwIfAborted();
1269
+ i == null || i.throwIfAborted();
1279
1270
  const d = O(
1280
- i.depositorBtcPubkey
1281
- ), p = y(i.unsignedPrePeginTxHex), g = Se(p);
1282
- if (g !== void 0 && g.vout !== i.batch.length)
1271
+ n.depositorBtcPubkey
1272
+ ), p = v(n.unsignedPrePeginTxHex), g = Se(p);
1273
+ if (g !== void 0 && g.vout !== n.batch.length)
1283
1274
  throw new Error(
1284
- `Auth-anchor OP_RETURN at vout ${g.vout} does not match batch size (${i.batch.length} HTLC outputs expect the anchor at vout ${i.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
1275
+ `Auth-anchor OP_RETURN at vout ${g.vout} does not match batch size (${n.batch.length} HTLC outputs expect the anchor at vout ${n.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
1285
1276
  );
1286
- const b = g == null ? void 0 : g.hash;
1287
- let f;
1277
+ const P = g == null ? void 0 : g.hash;
1278
+ let m;
1288
1279
  try {
1289
- f = _.fromHex(p);
1290
- } catch (w) {
1280
+ m = $.fromHex(p);
1281
+ } catch (b) {
1291
1282
  throw new Error(
1292
- `Failed to parse funded Pre-PegIn transaction hex: ${w instanceof Error ? w.message : String(w)}`
1283
+ `Failed to parse funded Pre-PegIn transaction hex: ${b instanceof Error ? b.message : String(b)}`
1293
1284
  );
1294
1285
  }
1295
- if (f.outs.length < i.batch.length)
1286
+ if (m.outs.length < n.batch.length)
1296
1287
  throw new Error(
1297
- `Funded Pre-PegIn tx has ${f.outs.length} outputs but batch requires at least ${i.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
1288
+ `Funded Pre-PegIn tx has ${m.outs.length} outputs but batch requires at least ${n.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
1298
1289
  );
1299
- const { psbtHex: P } = await Fe({
1290
+ const { psbtHex: f } = await De({
1300
1291
  prePeginParams: {
1301
- vaultCoreVersion: i.vaultCoreVersion,
1292
+ vaultCoreVersion: n.vaultCoreVersion,
1302
1293
  depositorPubkey: d,
1303
- vaultProviderPubkey: y(u.vaultProviderPubkey),
1304
- vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(y),
1305
- universalChallengerPubkeys: u.universalChallengerPubkeys.map(y),
1306
- hashlocks: i.batch.map((w) => y(w.hashlock)),
1294
+ vaultProviderPubkey: v(u.vaultProviderPubkey),
1295
+ vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(v),
1296
+ universalChallengerPubkeys: u.universalChallengerPubkeys.map(v),
1297
+ hashlocks: n.batch.map((b) => v(b.hashlock)),
1307
1298
  timelockRefund: u.timelockRefund,
1308
1299
  // `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
1309
1300
  // is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
@@ -1311,188 +1302,201 @@ async function pr(e) {
1311
1302
  // HTLC output. `buildRefundPsbt`'s value cross-check then binds the result
1312
1303
  // to the funded tx bytes, refusing the refund if the template's HTLC value
1313
1304
  // disagrees with the on-chain commitment.
1314
- pegInAmounts: i.batch.map((w) => w.amount),
1305
+ pegInAmounts: n.batch.map((b) => b.amount),
1315
1306
  feeRate: u.feeRate,
1316
1307
  minPeginFeeRate: u.minPeginFeeRate,
1317
1308
  numLocalChallengers: u.numLocalChallengers,
1318
1309
  councilQuorum: u.councilQuorum,
1319
1310
  councilSize: u.councilSize,
1320
1311
  network: u.network,
1321
- authAnchorHash: b
1312
+ authAnchorHash: P
1322
1313
  },
1323
1314
  fundedPrePeginTxHex: p,
1324
- htlcVout: i.htlcVout,
1315
+ htlcVout: n.htlcVout,
1325
1316
  refundFee: h,
1326
1317
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
1327
1318
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
1328
1319
  // value would derive the wrong refund script leaf and yield an
1329
1320
  // unspendable PSBT. Match the `hashlocks` array handling above.
1330
- hashlock: y(i.hashlock)
1321
+ hashlock: v(n.hashlock)
1331
1322
  });
1332
- n == null || n.throwIfAborted();
1333
- const v = K(
1334
- i.depositorBtcPubkey,
1335
- _t
1336
- ), m = await l(P, v);
1323
+ i == null || i.throwIfAborted();
1324
+ const w = K(
1325
+ n.depositorBtcPubkey,
1326
+ $t
1327
+ ), y = await l(f, w);
1337
1328
  B({
1338
- requestedPsbtHex: P,
1339
- returnedPsbtHex: m
1329
+ requestedPsbtHex: f,
1330
+ returnedPsbtHex: y
1340
1331
  });
1341
- const A = 0, S = I(
1342
- m,
1332
+ const k = 0, x = I(
1333
+ y,
1343
1334
  d,
1344
- A
1335
+ k
1345
1336
  );
1346
1337
  V({
1347
- requestedPsbtHex: P,
1348
- signatureHex: S,
1338
+ requestedPsbtHex: f,
1339
+ signatureHex: x,
1349
1340
  signerXOnlyPubkeyHex: d,
1350
- inputIndex: A
1341
+ inputIndex: k
1351
1342
  });
1352
- const $ = It(m);
1353
- n == null || n.throwIfAborted();
1343
+ const A = ce({
1344
+ requestedPsbtHex: f,
1345
+ signaturesHex: [x],
1346
+ signerXOnlyPubkeyHex: d
1347
+ });
1348
+ i == null || i.throwIfAborted();
1354
1349
  try {
1355
- return await s($);
1356
- } catch (w) {
1357
- throw w instanceof Error && St.test(w.message) ? new At(t, w) : w;
1350
+ return await s(A);
1351
+ } catch (b) {
1352
+ throw b instanceof Error && Bt.test(b.message) ? new At(t, b) : b;
1358
1353
  }
1359
1354
  }
1360
1355
  class re extends Error {
1361
1356
  constructor(r, o, a) {
1362
1357
  super(r);
1363
1358
  /** Fee the reclaim would have paid, in satoshis. */
1364
- C(this, "feeSats");
1359
+ S(this, "feeSats");
1365
1360
  /** Sum of the reserves the reclaim would have swept, in satoshis. */
1366
- C(this, "sweptTotalSats");
1361
+ S(this, "sweptTotalSats");
1367
1362
  this.name = "ReclaimUneconomicalError", this.feeSats = o, this.sweptTotalSats = a;
1368
1363
  }
1369
1364
  }
1370
- const oe = 2e3, ne = 25n, se = 100n, gr = 10n;
1371
- function Vt(e) {
1372
- const t = le.fromHex(e);
1373
- try {
1374
- t.finalizeAllInputs();
1375
- } catch (r) {
1376
- const o = r instanceof Error ? r.message : String(r);
1377
- if (!o.includes("already finalized"))
1378
- throw new Error(`Failed to finalize reclaim PSBT: ${o}`);
1365
+ const oe = 2e3, ne = 25n, se = 100n, vr = 10n;
1366
+ async function Kt(e, t, r) {
1367
+ for (let o = 0; o < e.length; o++) {
1368
+ const a = Le(e[o].depositorSignedPeginTxHex), l = ie(
1369
+ await Xe(
1370
+ v(a),
1371
+ v(r)
1372
+ )
1373
+ ).toLowerCase();
1374
+ if (l !== t[o].toLowerCase())
1375
+ throw new Error(
1376
+ `Reserve ${o} belongs to vault ${l}, not the requested ${t[o].toLowerCase()}. Refusing to sweep a reserve whose vault is not the one the caller asked for — the reserve funds that vault's claim transaction and cannot be replaced.`
1377
+ );
1379
1378
  }
1380
- return t.extractTransaction().toHex();
1381
1379
  }
1382
- async function fr(e) {
1380
+ async function Pr(e) {
1383
1381
  const {
1384
1382
  vaultIds: t,
1385
- depositorBtcPubkey: r,
1386
- readVaults: o,
1387
- feeRate: a,
1388
- signPsbt: l,
1389
- broadcastTx: s,
1383
+ depositorEthAddress: r,
1384
+ depositorBtcPubkey: o,
1385
+ readVaults: a,
1386
+ feeRate: l,
1387
+ signPsbt: s,
1388
+ broadcastTx: i,
1390
1389
  signal: n
1391
1390
  } = e;
1392
1391
  if (n == null || n.throwIfAborted(), t.length === 0)
1393
1392
  throw new Error("Reclaim requires at least one vault id; got none.");
1394
- if (!Number.isFinite(a) || a <= 0)
1395
- throw new Error(`feeRate must be a positive number, got ${a}`);
1396
- if (a > oe)
1393
+ if (!Number.isFinite(l) || l <= 0)
1394
+ throw new Error(`feeRate must be a positive number, got ${l}`);
1395
+ if (l > oe)
1397
1396
  throw new re(
1398
- `Fee rate ${a} sat/vB exceeds the reclaim safety cap of ${oe} sat/vB; refusing to sign.`,
1397
+ `Fee rate ${l} sat/vB exceeds the reclaim safety cap of ${oe} sat/vB; refusing to sign.`,
1399
1398
  0n,
1400
1399
  0n
1401
1400
  );
1402
- const i = await o();
1403
- if (n == null || n.throwIfAborted(), i.length !== t.length)
1401
+ const u = await a();
1402
+ if (n == null || n.throwIfAborted(), u.length !== t.length)
1404
1403
  throw new Error(
1405
- `readVaults returned ${i.length} reserves for ${t.length} vault id(s); refusing to sweep a set that does not match the request.`
1404
+ `readVaults returned ${u.length} reserves for ${t.length} vault id(s); refusing to sweep a set that does not match the request.`
1406
1405
  );
1407
- const u = O(r), h = i.map((v) => ({
1408
- depositorSignedPeginTxHex: v.depositorSignedPeginTxHex,
1409
- observed: v.observed,
1410
- expectedValue: v.expectedClaimValue
1411
- })), c = Me(a, h.length), d = h.reduce((v, m) => v + m.expectedValue, 0n), p = d * ne / se;
1412
- if (c > p)
1406
+ await Kt(u, t, r), n == null || n.throwIfAborted();
1407
+ const h = O(o), c = u.map((k) => ({
1408
+ depositorSignedPeginTxHex: k.depositorSignedPeginTxHex,
1409
+ observed: k.observed,
1410
+ expectedValue: k.expectedClaimValue
1411
+ })), d = Fe(l, c.length), p = c.reduce((k, x) => k + x.expectedValue, 0n), g = p * ne / se;
1412
+ if (d > g)
1413
1413
  throw new re(
1414
- `Reclaim fee ${c} sats exceeds ${ne}/${se} of the swept total (${d} sats, cap ${p} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
1415
- c,
1416
- d
1414
+ `Reclaim fee ${d} sats exceeds ${ne}/${se} of the swept total (${p} sats, cap ${g} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
1415
+ d,
1416
+ p
1417
1417
  );
1418
1418
  n == null || n.throwIfAborted();
1419
- const { psbtHex: g } = Ue({
1420
- depositorPubkey: u,
1421
- inputs: h,
1422
- feeSats: c
1419
+ const { psbtHex: P } = Me({
1420
+ depositorPubkey: h,
1421
+ inputs: c,
1422
+ feeSats: d
1423
1423
  });
1424
1424
  n == null || n.throwIfAborted();
1425
- const b = K(
1426
- r,
1427
- h.length
1428
- ), f = await l(g, b);
1425
+ const m = K(
1426
+ o,
1427
+ c.length
1428
+ ), f = await s(P, m);
1429
1429
  B({
1430
- requestedPsbtHex: g,
1430
+ requestedPsbtHex: P,
1431
1431
  returnedPsbtHex: f
1432
- }), h.forEach((v, m) => {
1432
+ });
1433
+ const w = c.map((k, x) => {
1433
1434
  const A = I(
1434
1435
  f,
1435
- u,
1436
- m
1436
+ h,
1437
+ x
1437
1438
  );
1438
- V({
1439
- requestedPsbtHex: g,
1439
+ return V({
1440
+ requestedPsbtHex: P,
1440
1441
  signatureHex: A,
1441
- signerXOnlyPubkeyHex: u,
1442
- inputIndex: m
1443
- });
1442
+ signerXOnlyPubkeyHex: h,
1443
+ inputIndex: x
1444
+ }), A;
1445
+ }), y = ce({
1446
+ requestedPsbtHex: P,
1447
+ signaturesHex: w,
1448
+ signerXOnlyPubkeyHex: h
1444
1449
  });
1445
- const P = Vt(f);
1446
- return n == null || n.throwIfAborted(), s(P);
1450
+ return n == null || n.throwIfAborted(), i(y);
1447
1451
  }
1448
1452
  export {
1449
- ft as A,
1453
+ vt as A,
1450
1454
  Q as B,
1451
- Pt as C,
1452
- vt as D,
1453
- ve as E,
1454
- cr as F,
1455
- hr as G,
1455
+ yt as C,
1456
+ bt as D,
1457
+ ye as E,
1458
+ pr as F,
1459
+ gr as G,
1456
1460
  At as H,
1457
- pr as I,
1458
- dr as J,
1461
+ mr as I,
1462
+ fr as J,
1459
1463
  te as K,
1460
1464
  ee as L,
1461
1465
  Z as M,
1462
- be as N,
1466
+ we as N,
1463
1467
  re as O,
1464
- je as P,
1465
- fr as Q,
1468
+ We as P,
1469
+ Pr as Q,
1466
1470
  Pe as R,
1467
1471
  se as S,
1468
1472
  ne as T,
1469
1473
  oe as U,
1470
- gr as V,
1471
- qt as a,
1472
- jt as b,
1473
- he as c,
1474
- de as d,
1475
- Qt as e,
1476
- Jt as f,
1477
- tr as g,
1478
- rr as h,
1479
- Je as i,
1480
- sr as j,
1481
- nr as k,
1482
- or as l,
1483
- bt as m,
1484
- wt as n,
1485
- me as o,
1486
- ar as p,
1487
- ir as q,
1488
- Yt as r,
1489
- st as s,
1490
- ur as t,
1491
- lr as u,
1492
- er as v,
1493
- Wt as w,
1494
- pe as x,
1495
- Zt as y,
1474
+ vr as V,
1475
+ Wt as a,
1476
+ Yt as b,
1477
+ de as c,
1478
+ pe as d,
1479
+ Jt as e,
1480
+ tr as f,
1481
+ nr as g,
1482
+ sr as h,
1483
+ et as i,
1484
+ ur as j,
1485
+ ir as k,
1486
+ ar as l,
1487
+ kt as m,
1488
+ Et as n,
1489
+ ve as o,
1490
+ lr as p,
1491
+ cr as q,
1492
+ er as r,
1493
+ it as s,
1494
+ hr as t,
1495
+ dr as u,
1496
+ or as v,
1497
+ Zt as w,
1498
+ ge as x,
1499
+ rr as y,
1496
1500
  D as z
1497
1501
  };
1498
- //# sourceMappingURL=buildAndBroadcastReclaim-kBHwOL02.js.map
1502
+ //# sourceMappingURL=buildAndBroadcastReclaim-YvWDRAN8.js.map