@babylonlabs-io/ts-sdk 3.1.2 → 3.2.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 (168) hide show
  1. package/dist/BTCVaultRegistry.abi-BH2-LHxN.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-BH2-LHxN.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-BmHpMUWD.js → BTCVaultRegistry.abi-BzNTa_EU.js} +19 -1
  4. package/dist/BTCVaultRegistry.abi-BzNTa_EU.js.map +1 -0
  5. package/dist/{PayoutManager-DOdsgcUR.cjs → PayoutManager-B1Ev0r7o.cjs} +2 -2
  6. package/dist/{PayoutManager-DOdsgcUR.cjs.map → PayoutManager-B1Ev0r7o.cjs.map} +1 -1
  7. package/dist/{PayoutManager-BZ212yml.js → PayoutManager-xEGvTbhL.js} +3 -3
  8. package/dist/{PayoutManager-BZ212yml.js.map → PayoutManager-xEGvTbhL.js.map} +1 -1
  9. package/dist/{PeginManager-PyKbfy5q.cjs → PeginManager-BCRtUqyX.cjs} +2 -2
  10. package/dist/{PeginManager-PyKbfy5q.cjs.map → PeginManager-BCRtUqyX.cjs.map} +1 -1
  11. package/dist/{PeginManager-Dfr5Qe1g.js → PeginManager-sizm3dlw.js} +7 -7
  12. package/dist/{PeginManager-Dfr5Qe1g.js.map → PeginManager-sizm3dlw.js.map} +1 -1
  13. package/dist/buildAndBroadcastReclaim-CE77jzTp.cjs +2 -0
  14. package/dist/buildAndBroadcastReclaim-CE77jzTp.cjs.map +1 -0
  15. package/dist/{buildAndBroadcastReclaim-R0HNpLMD.js → buildAndBroadcastReclaim-rQyAiAUS.js} +901 -867
  16. package/dist/buildAndBroadcastReclaim-rQyAiAUS.js.map +1 -0
  17. package/dist/challengeAssert-B2otuf7y.js +509 -0
  18. package/dist/challengeAssert-B2otuf7y.js.map +1 -0
  19. package/dist/challengeAssert-C3eMcM5Y.cjs +2 -0
  20. package/dist/challengeAssert-C3eMcM5Y.cjs.map +1 -0
  21. package/dist/constants-CAm10Qwp.cjs +2 -0
  22. package/dist/constants-CAm10Qwp.cjs.map +1 -0
  23. package/dist/constants-CvQZuxKv.js +48 -0
  24. package/dist/constants-CvQZuxKv.js.map +1 -0
  25. package/dist/{index-CVBtBjQ5.js → index-BRsWXDlv.js} +6 -6
  26. package/dist/{index-CVBtBjQ5.js.map → index-BRsWXDlv.js.map} +1 -1
  27. package/dist/{index-DpjYs5yr.cjs → index-C6avwx1s.cjs} +2 -2
  28. package/dist/{index-DpjYs5yr.cjs.map → index-C6avwx1s.cjs.map} +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +297 -298
  31. package/dist/index.js.map +1 -1
  32. package/dist/{pegin-registration-client-kdz4fT5_.js → pegin-registration-client-8tzSRDaq.js} +46 -45
  33. package/dist/pegin-registration-client-8tzSRDaq.js.map +1 -0
  34. package/dist/pegin-registration-client-Bmkh1OZ9.cjs +2 -0
  35. package/dist/pegin-registration-client-Bmkh1OZ9.cjs.map +1 -0
  36. package/dist/peginState-CIibG9S_.js +75 -0
  37. package/dist/peginState-CIibG9S_.js.map +1 -0
  38. package/dist/peginState-IyE22wWh.cjs +2 -0
  39. package/dist/peginState-IyE22wWh.cjs.map +1 -0
  40. package/dist/{primeVpAuth-BPj2TPdD.cjs → primeVpAuth-CXNXYKrh.cjs} +2 -2
  41. package/dist/{primeVpAuth-BPj2TPdD.cjs.map → primeVpAuth-CXNXYKrh.cjs.map} +1 -1
  42. package/dist/{primeVpAuth-CiCdRNGf.js → primeVpAuth-D4UWXQ76.js} +2 -2
  43. package/dist/{primeVpAuth-CiCdRNGf.js.map → primeVpAuth-D4UWXQ76.js.map} +1 -1
  44. package/dist/{registration-records-CKLAv3gw.js → registration-records-BBOz21Dm.js} +15 -15
  45. package/dist/{registration-records-CKLAv3gw.js.map → registration-records-BBOz21Dm.js.map} +1 -1
  46. package/dist/{registration-records-DFQgBaYi.cjs → registration-records-DaBufozs.cjs} +2 -2
  47. package/dist/{registration-records-DFQgBaYi.cjs.map → registration-records-DaBufozs.cjs.map} +1 -1
  48. package/dist/{reservation-DOAHVT3B.js → reservation-BZQABu4g.js} +2 -2
  49. package/dist/{reservation-DOAHVT3B.js.map → reservation-BZQABu4g.js.map} +1 -1
  50. package/dist/{reservation-ECxjZi5t.cjs → reservation-CA5knoQ0.cjs} +2 -2
  51. package/dist/{reservation-ECxjZi5t.cjs.map → reservation-CA5knoQ0.cjs.map} +1 -1
  52. package/dist/{signer-set-reader-DFAu6I-v.cjs → signer-set-reader-D-CyIYR5.cjs} +2 -2
  53. package/dist/{signer-set-reader-DFAu6I-v.cjs.map → signer-set-reader-D-CyIYR5.cjs.map} +1 -1
  54. package/dist/{signer-set-reader-BCtmSKUM.js → signer-set-reader-DFF9MgQN.js} +2 -2
  55. package/dist/{signer-set-reader-BCtmSKUM.js.map → signer-set-reader-DFF9MgQN.js.map} +1 -1
  56. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  57. package/dist/tbv/core/clients/eth/index.js +4 -4
  58. package/dist/tbv/core/clients/eth/types.d.ts +8 -0
  59. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  60. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  61. package/dist/tbv/core/clients/index.cjs +1 -1
  62. package/dist/tbv/core/clients/index.js +6 -6
  63. package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
  64. package/dist/tbv/core/clients/vault-provider/status/index.js +1 -1
  65. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +14 -0
  66. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  67. package/dist/tbv/core/contracts/index.cjs +1 -1
  68. package/dist/tbv/core/contracts/index.js +1 -1
  69. package/dist/tbv/core/index.cjs +1 -1
  70. package/dist/tbv/core/index.js +293 -294
  71. package/dist/tbv/core/index.js.map +1 -1
  72. package/dist/tbv/core/managers/index.cjs +1 -1
  73. package/dist/tbv/core/managers/index.js +2 -2
  74. package/dist/tbv/core/primitives/index.cjs +1 -1
  75. package/dist/tbv/core/primitives/index.js +29 -30
  76. package/dist/tbv/core/primitives/index.js.map +1 -1
  77. package/dist/tbv/core/primitives/psbt/__tests__/challengeAssert.test.d.ts +2 -0
  78. package/dist/tbv/core/primitives/psbt/__tests__/challengeAssert.test.d.ts.map +1 -0
  79. package/dist/tbv/core/primitives/psbt/__tests__/noPayout.test.d.ts +2 -0
  80. package/dist/tbv/core/primitives/psbt/__tests__/noPayout.test.d.ts.map +1 -0
  81. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +43 -0
  82. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
  83. package/dist/tbv/core/primitives/psbt/constants.d.ts +50 -2
  84. package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
  85. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +42 -0
  86. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
  87. package/dist/tbv/core/services/activation/activateVault.d.ts +50 -0
  88. package/dist/tbv/core/services/activation/activateVault.d.ts.map +1 -1
  89. package/dist/tbv/core/services/activation/index.d.ts +1 -1
  90. package/dist/tbv/core/services/activation/index.d.ts.map +1 -1
  91. package/dist/tbv/core/services/delegated-claim/__tests__/realWasmWatchtowerArtifacts.test.d.ts +9 -0
  92. package/dist/tbv/core/services/delegated-claim/__tests__/realWasmWatchtowerArtifacts.test.d.ts.map +1 -0
  93. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +5 -7
  94. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -1
  95. package/dist/tbv/core/services/delegated-claim/index.d.ts +3 -4
  96. package/dist/tbv/core/services/delegated-claim/index.d.ts.map +1 -1
  97. package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts.map +1 -1
  98. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +14 -8
  99. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -1
  100. package/dist/tbv/core/services/delegated-claim/types.d.ts +32 -19
  101. package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -1
  102. package/dist/tbv/core/services/deposit/__tests__/signDepositorGraph.realGraph.test.d.ts +12 -0
  103. package/dist/tbv/core/services/deposit/__tests__/signDepositorGraph.realGraph.test.d.ts.map +1 -0
  104. package/dist/tbv/core/services/deposit/peginState.d.ts +20 -1
  105. package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
  106. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +7 -0
  107. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  108. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +46 -1
  109. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  110. package/dist/tbv/core/services/index.cjs +1 -1
  111. package/dist/tbv/core/services/index.js +59 -59
  112. package/dist/tbv/core/utils/index.cjs +1 -1
  113. package/dist/tbv/core/utils/index.js +1 -1
  114. package/dist/tbv/core/wasm/__tests__/challengeAssertOutputConnector.test.d.ts +2 -0
  115. package/dist/tbv/core/wasm/__tests__/challengeAssertOutputConnector.test.d.ts.map +1 -0
  116. package/dist/tbv/core/wasm/index.cjs +1 -1
  117. package/dist/tbv/core/wasm/index.cjs.map +1 -1
  118. package/dist/tbv/core/wasm/index.d.ts +14 -2
  119. package/dist/tbv/core/wasm/index.d.ts.map +1 -1
  120. package/dist/tbv/core/wasm/index.js +81 -77
  121. package/dist/tbv/core/wasm/index.js.map +1 -1
  122. package/dist/tbv/index.cjs +1 -1
  123. package/dist/tbv/index.js +293 -294
  124. package/dist/tbv/index.js.map +1 -1
  125. package/dist/{toRefundInputs-BbAOOUg6.cjs → toRefundInputs-DOCLxqC1.cjs} +2 -2
  126. package/dist/{toRefundInputs-BbAOOUg6.cjs.map → toRefundInputs-DOCLxqC1.cjs.map} +1 -1
  127. package/dist/{toRefundInputs-DW14g6wH.js → toRefundInputs-Dso_QEr-.js} +5 -5
  128. package/dist/{toRefundInputs-DW14g6wH.js.map → toRefundInputs-Dso_QEr-.js.map} +1 -1
  129. package/dist/{types-Bda75Od0.cjs → types-DGr5HWwD.cjs} +2 -2
  130. package/dist/types-DGr5HWwD.cjs.map +1 -0
  131. package/dist/{types-C5jj3Cc-.js → types-Dbs--c2M.js} +2 -2
  132. package/dist/types-Dbs--c2M.js.map +1 -0
  133. package/dist/{verifyKeyPathSchnorrSignature-CQUut2-O.cjs → verifyKeyPathSchnorrSignature-BRTpEH9X.cjs} +2 -2
  134. package/dist/{verifyKeyPathSchnorrSignature-CQUut2-O.cjs.map → verifyKeyPathSchnorrSignature-BRTpEH9X.cjs.map} +1 -1
  135. package/dist/{verifyKeyPathSchnorrSignature-DxPbeSdQ.js → verifyKeyPathSchnorrSignature-IIj3Z2se.js} +2 -2
  136. package/dist/{verifyKeyPathSchnorrSignature-DxPbeSdQ.js.map → verifyKeyPathSchnorrSignature-IIj3Z2se.js.map} +1 -1
  137. package/dist/{verifyScriptPathSchnorrSignature-D2t1yACC.cjs → verifyScriptPathSchnorrSignature-CahYx5Td.cjs} +2 -2
  138. package/dist/{verifyScriptPathSchnorrSignature-D2t1yACC.cjs.map → verifyScriptPathSchnorrSignature-CahYx5Td.cjs.map} +1 -1
  139. package/dist/{verifyScriptPathSchnorrSignature-B3-VkvnK.js → verifyScriptPathSchnorrSignature-owu3BfyT.js} +2 -2
  140. package/dist/{verifyScriptPathSchnorrSignature-B3-VkvnK.js.map → verifyScriptPathSchnorrSignature-owu3BfyT.js.map} +1 -1
  141. package/package.json +3 -3
  142. package/dist/BTCVaultRegistry.abi-BmHpMUWD.js.map +0 -1
  143. package/dist/BTCVaultRegistry.abi-DffWFdpA.cjs +0 -2
  144. package/dist/BTCVaultRegistry.abi-DffWFdpA.cjs.map +0 -1
  145. package/dist/buildAndBroadcastReclaim-Da8rD5Z7.cjs +0 -2
  146. package/dist/buildAndBroadcastReclaim-Da8rD5Z7.cjs.map +0 -1
  147. package/dist/buildAndBroadcastReclaim-R0HNpLMD.js.map +0 -1
  148. package/dist/challengeAssert-Cp_GeRg8.js +0 -64
  149. package/dist/challengeAssert-Cp_GeRg8.js.map +0 -1
  150. package/dist/challengeAssert-Z7_YULBb.cjs +0 -2
  151. package/dist/challengeAssert-Z7_YULBb.cjs.map +0 -1
  152. package/dist/constants-BeYquVd-.js +0 -36
  153. package/dist/constants-BeYquVd-.js.map +0 -1
  154. package/dist/constants-BwCg5K6R.cjs +0 -2
  155. package/dist/constants-BwCg5K6R.cjs.map +0 -1
  156. package/dist/noPayout-B-vGXJ-V.js +0 -361
  157. package/dist/noPayout-B-vGXJ-V.js.map +0 -1
  158. package/dist/noPayout-DOHak0ui.cjs +0 -2
  159. package/dist/noPayout-DOHak0ui.cjs.map +0 -1
  160. package/dist/pegin-registration-client-C-abxMWq.cjs +0 -2
  161. package/dist/pegin-registration-client-C-abxMWq.cjs.map +0 -1
  162. package/dist/pegin-registration-client-kdz4fT5_.js.map +0 -1
  163. package/dist/peginState-BU2ONFXF.js +0 -68
  164. package/dist/peginState-BU2ONFXF.js.map +0 -1
  165. package/dist/peginState-DUv10EJR.cjs +0 -2
  166. package/dist/peginState-DUv10EJR.cjs.map +0 -1
  167. package/dist/types-Bda75Od0.cjs.map +0 -1
  168. package/dist/types-C5jj3Cc-.js.map +0 -1
@@ -1,58 +1,58 @@
1
- var Jt = Object.defineProperty;
2
- var Zt = (e, t, r) => t in e ? Jt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var z = (e, t, r) => Zt(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { B as ft } from "./BTCVaultRegistry.abi-BmHpMUWD.js";
5
- import { e as Be, s as b, i as er, u as Ie, c as _, v as tr, p as he, f as N } from "./bitcoin-C-TuHb-v.js";
6
- import { v as rr, s as yt, b as vt, P as or, d as sr } from "./PayoutManager-BZ212yml.js";
7
- import { verifyWatchtowerArtifacts as nr, buildClaimPsbt as ir, buildAssertClaimerPsbt as ar, buildPayoutClaimerPsbt as ur, buildWronglyChallengedPsbts as cr, buildPayoutDepositorPsbt as lr, finalizeClaimTx as dr, buildWatchtowerArtifacts as hr, extractTapScriptSig as bt, expandWotsSeed as pr, wotsKeypairFromSeed as gr, validateWotsKeypairAgainstGraph as fr, deriveVaultId as yr } from "./tbv/core/wasm/index.js";
8
- import { m as vr, d as Pt, k as br, a as _e, V as Me, i as Pr, g as mr, f as wr, r as xr, h as Er } from "./registration-records-CKLAv3gw.js";
1
+ var Zt = Object.defineProperty;
2
+ var er = (e, t, r) => t in e ? Zt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var W = (e, t, r) => er(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { B as Be } from "./BTCVaultRegistry.abi-BzNTa_EU.js";
5
+ import { e as Ie, s as b, i as tr, u as yt, c as _, v as rr, g as or, p as pe, f as N } from "./bitcoin-C-TuHb-v.js";
6
+ import { v as sr, s as vt, b as bt, P as nr, d as ir } from "./PayoutManager-xEGvTbhL.js";
7
+ import { verifyWatchtowerArtifacts as ar, buildClaimPsbt as ur, buildAssertClaimerPsbt as cr, buildPayoutClaimerPsbt as lr, buildWronglyChallengedPsbts as dr, buildPayoutDepositorPsbt as hr, finalizeClaimTx as pr, buildWatchtowerArtifacts as gr, extractTapScriptSig as mt, expandWotsSeed as fr, wotsKeypairFromSeed as yr, validateWotsKeypairAgainstGraph as vr, getChallengeAssertOutputScriptPubKey as br, deriveVaultId as mr } from "./tbv/core/wasm/index.js";
8
+ import { m as Pr, d as Pt, k as wr, a as _e, V as Le, i as xr, g as Er, f as kr, r as $r, h as Cr } from "./registration-records-BBOz21Dm.js";
9
9
  import { Psbt as q, Transaction as S } from "bitcoinjs-lib";
10
- import { q as F, r as A, s as ee, C as Y, A as te, p as Q, t as pe, l as Le, N as J, u as Ve, m as Fe, n as Ue, o as qe, W as $r, D as Xe } from "./constants-BeYquVd-.js";
11
- import { p as kr, q as Cr, r as mt, P as X, j as re, f as Tr, i as ie, g as ae } from "./verifyScriptPathSchnorrSignature-B3-VkvnK.js";
10
+ import { z as F, E as A, F as re, G as Q, A as G, x as Z, H as ge, t as Me, y as ee, I as Ve, u as Fe, v as Ue, w as qe, W as Tr, D as Ge, C as Xe, J as _r, K as Sr, L as Ar } from "./constants-CvQZuxKv.js";
11
+ import { p as Br, q as Ir, r as wt, P as X, j as oe, f as Vr, i as ae, g as ue } from "./verifyScriptPathSchnorrSignature-owu3BfyT.js";
12
12
  import { Buffer as H } from "buffer";
13
- import { C as wt, X as xt } from "./validation-OSC0xTHB.js";
14
- import { a as Et, c as ue } from "./signing-C1rR4tqs.js";
13
+ import { C as xt, X as Et } from "./validation-OSC0xTHB.js";
14
+ import { a as kt, c as ce } from "./signing-C1rR4tqs.js";
15
15
  import { d as $t } from "./deriveVaultRoot-BcvmER1E.js";
16
- import { O as Ge, d as _r } from "./types-C5jj3Cc-.js";
17
- import { zeroAddress as Sr, isAddress as Ar, isAddressEqual as Br } from "viem";
18
- import { v as ze, D as R, c as Ir, b as Vr, R as Rr, d as kt } from "./state-CFn1rT74.js";
19
- import { h as je, b as Kr, s as Hr, j as Or } from "./sha2-YqVHJiFj.js";
20
- import { d as Nr, c as Dr, b as Mr, f as Ct, e as Lr, a as Fr } from "./noPayout-B-vGXJ-V.js";
21
- import { a as Ur } from "./secp256k1-BuxBFUHm.js";
22
- import { c as qr } from "./btcTxHash-BRZ8_EZq.js";
23
- const Xr = /^0x[0-9a-fA-F]{64}$/, Gr = /^0x[0-9a-fA-F]{40}$/, zr = /^0x([0-9a-fA-F]{2})*$/;
24
- function fe(e, t) {
16
+ import { O as ze, d as Rr } from "./types-Dbs--c2M.js";
17
+ import { zeroAddress as Kr, isAddress as Hr, isAddressEqual as Or } from "viem";
18
+ import { v as je, D as R, c as Nr, b as Dr, R as Lr, d as Ct } from "./state-CFn1rT74.js";
19
+ import { h as We, b as Mr, s as Fr, j as Ur } from "./sha2-YqVHJiFj.js";
20
+ import { c as qr, g as Gr, h as Xr, i as zr, b as jr, f as Tt, e as Wr, a as Yr } from "./challengeAssert-B2otuf7y.js";
21
+ import { a as Jr } from "./secp256k1-BuxBFUHm.js";
22
+ import { c as Qr } from "./btcTxHash-BRZ8_EZq.js";
23
+ const Zr = /^0x[0-9a-fA-F]{64}$/, eo = /^0x[0-9a-fA-F]{40}$/, to = /^0x([0-9a-fA-F]{2})*$/;
24
+ function ye(e, t) {
25
25
  if (e.length !== 66)
26
26
  throw new Error(
27
27
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
28
28
  );
29
- if (!Xr.test(e))
29
+ if (!Zr.test(e))
30
30
  throw new Error(
31
31
  `${t} must contain only hex characters after the 0x prefix`
32
32
  );
33
33
  }
34
- function jr(e, t) {
35
- if (!Gr.test(e))
34
+ function ro(e, t) {
35
+ if (!eo.test(e))
36
36
  throw new Error(
37
37
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
38
38
  );
39
39
  }
40
- function Wr(e, t) {
41
- if (!zr.test(e))
40
+ function oo(e, t) {
41
+ if (!to.test(e))
42
42
  throw new Error(
43
43
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
44
44
  );
45
45
  }
46
- function Tt(e) {
47
- jr(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), fe(e.vaultId, "vaultId");
48
- const t = Be(e.secret);
49
- if (fe(t, "secret"), e.hashlock !== void 0 && (fe(e.hashlock, "hashlock"), !rr(t, e.hashlock)))
46
+ function Re(e) {
47
+ ro(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), ye(e.vaultId, "vaultId");
48
+ const t = Ie(e.secret);
49
+ if (ye(t, "secret"), e.hashlock !== void 0 && (ye(e.hashlock, "hashlock"), !sr(t, e.hashlock)))
50
50
  throw new Error(
51
51
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
52
52
  );
53
53
  return t;
54
54
  }
55
- async function Ys(e) {
55
+ async function nn(e) {
56
56
  const {
57
57
  btcVaultRegistryAddress: t,
58
58
  vaultId: r,
@@ -62,23 +62,23 @@ async function Ys(e) {
62
62
  signal: a
63
63
  } = e;
64
64
  a == null || a.throwIfAborted();
65
- const i = Tt({
65
+ const i = Re({
66
66
  btcVaultRegistryAddress: t,
67
67
  vaultId: r,
68
68
  secret: e.secret,
69
69
  hashlock: o
70
70
  });
71
- return Wr(s, "activationMetadata"), n({
71
+ return oo(s, "activationMetadata"), n({
72
72
  address: t,
73
- abi: ft,
73
+ abi: Be,
74
74
  functionName: "activateVaultWithSecret",
75
75
  args: [r, i, s]
76
76
  });
77
77
  }
78
- async function Qs(e) {
78
+ async function an(e) {
79
79
  const { btcVaultRegistryAddress: t, vaultId: r, hashlock: o, writeContract: s, signal: n } = e;
80
80
  n == null || n.throwIfAborted();
81
- const a = Tt({
81
+ const a = Re({
82
82
  btcVaultRegistryAddress: t,
83
83
  vaultId: r,
84
84
  secret: e.secret,
@@ -86,35 +86,52 @@ async function Qs(e) {
86
86
  });
87
87
  return s({
88
88
  address: t,
89
- abi: ft,
89
+ abi: Be,
90
90
  functionName: "activateVaultWithSecretAndRedeem",
91
91
  args: [r, a]
92
92
  });
93
93
  }
94
+ async function un(e) {
95
+ const { btcVaultRegistryAddress: t, vaultId: r, hashlock: o, writeContract: s, signal: n } = e;
96
+ if (n == null || n.throwIfAborted(), typeof o != "string")
97
+ throw new Error("hashlock is required to claim an expired vault");
98
+ const a = Re({
99
+ btcVaultRegistryAddress: t,
100
+ vaultId: r,
101
+ secret: e.secret,
102
+ hashlock: o
103
+ });
104
+ return s({
105
+ address: t,
106
+ abi: Be,
107
+ functionName: "claimExpiredVault",
108
+ args: [r, a]
109
+ });
110
+ }
94
111
  class K extends Error {
95
112
  constructor(t, r) {
96
113
  super(t, r), this.name = "AssertBindingError";
97
114
  }
98
115
  }
99
- function ye(e, t) {
116
+ function ve(e, t) {
100
117
  try {
101
118
  return q.fromBase64(t);
102
119
  } catch (r) {
103
120
  throw new K(`${e} PSBT cannot be parsed.`, { cause: r });
104
121
  }
105
122
  }
106
- function Yr(e, t, r) {
123
+ function so(e, t, r) {
107
124
  const o = t.txInputs[r];
108
125
  if (!o)
109
126
  throw new K(`${e} PSBT has no input ${r}.`);
110
127
  return o.hash;
111
128
  }
112
- function We(e) {
129
+ function Ye(e) {
113
130
  return S.fromBuffer(
114
131
  e.data.globalMap.unsignedTx.toBuffer()
115
132
  ).getHash();
116
133
  }
117
- function ve(e, t, r, o, s, n) {
134
+ function be(e, t, r, o, s, n) {
118
135
  const a = t.txInputs[r];
119
136
  if (!a)
120
137
  throw new K(`${e} PSBT has no input ${r}.`);
@@ -123,71 +140,71 @@ function ve(e, t, r, o, s, n) {
123
140
  `${e} input ${r} does not spend ${n}: the graph pairs this ${e} with a different transaction.`
124
141
  );
125
142
  }
126
- function Qr(e, t) {
143
+ function no(e, t) {
127
144
  var s;
128
145
  const r = (s = e.data.inputs[F]) == null ? void 0 : s.witnessUtxo;
129
146
  if (r === void 0)
130
147
  throw new K(
131
148
  `Assert input ${F} carries no witnessUtxo, so the amount and script its signature commits to cannot be checked; refusing to sign assert.`
132
149
  );
133
- const o = t.txOutputs[Y];
150
+ const o = t.txOutputs[Q];
134
151
  if (!o)
135
152
  throw new K(
136
- `Claim PSBT has no output ${Y} for the Assert to spend; refusing to sign assert.`
153
+ `Claim PSBT has no output ${Q} for the Assert to spend; refusing to sign assert.`
137
154
  );
138
155
  if (r.value !== o.value)
139
156
  throw new K(
140
- `Assert input ${F} declares a prevout of ${r.value} sats but the Claim's output ${Y} is worth ${o.value}; refusing to sign assert.`
157
+ `Assert input ${F} declares a prevout of ${r.value} sats but the Claim's output ${Q} is worth ${o.value}; refusing to sign assert.`
141
158
  );
142
159
  if (!r.script.equals(o.script))
143
160
  throw new K(
144
- `Assert input ${F} declares a prevout script that is not the Claim's output ${Y} script; refusing to sign assert.`
161
+ `Assert input ${F} declares a prevout script that is not the Claim's output ${Q} script; refusing to sign assert.`
145
162
  );
146
163
  }
147
- function Jr(e) {
148
- const t = ye("Claim", e.claimPsbtBase64), r = ye("Assert", e.assertPsbtBase64), o = ye("Payout", e.payoutClaimerPsbtBase64);
149
- ve(
164
+ function io(e) {
165
+ const t = ve("Claim", e.claimPsbtBase64), r = ve("Assert", e.assertPsbtBase64), o = ve("Payout", e.payoutClaimerPsbtBase64);
166
+ be(
150
167
  "Assert",
151
168
  r,
152
169
  F,
153
- We(t),
154
- Y,
170
+ Ye(t),
171
+ Q,
155
172
  "Claim:0"
156
- ), Qr(r, t), ve(
173
+ ), no(r, t), be(
157
174
  "Payout",
158
175
  o,
159
176
  A,
160
- We(r),
161
- te,
177
+ Ye(r),
178
+ G,
162
179
  "Assert:0"
163
- ), ve(
180
+ ), be(
164
181
  "Payout",
165
182
  o,
166
- ee,
167
- Yr("Claim", t, pe),
168
- Q,
183
+ re,
184
+ so("Claim", t, ge),
185
+ Z,
169
186
  "this vault's PegIn:0"
170
187
  );
171
188
  }
172
- function be(e, t) {
189
+ function me(e, t) {
173
190
  try {
174
191
  return q.fromBase64(t);
175
192
  } catch (r) {
176
193
  throw new Error(`${e} PSBT cannot be parsed.`, { cause: r });
177
194
  }
178
195
  }
179
- function Ye(e, t, r, o) {
196
+ function Je(e, t, r, o) {
180
197
  var a;
181
198
  const s = [
182
199
  {
183
- inputIndex: ee,
200
+ inputIndex: re,
184
201
  expectedSats: r,
185
- source: `the vault's PegIn output ${Q}`
202
+ source: `the vault's PegIn output ${Z}`
186
203
  },
187
204
  {
188
205
  inputIndex: A,
189
206
  expectedSats: o.value,
190
- source: `the Assert's output ${te}`
207
+ source: `the Assert's output ${G}`
191
208
  }
192
209
  ];
193
210
  for (const { inputIndex: i, expectedSats: u, source: l } of s) {
@@ -204,10 +221,10 @@ function Ye(e, t, r, o) {
204
221
  const n = t.data.inputs[A].witnessUtxo;
205
222
  if (!(n != null && n.script.equals(o.script)))
206
223
  throw new Error(
207
- `${e} Payout input ${A} declares a prevout script that is not the Assert's output ${te} script; refusing to sign payout.`
224
+ `${e} Payout input ${A} declares a prevout script that is not the Assert's output ${G} script; refusing to sign payout.`
208
225
  );
209
226
  }
210
- async function Zr(e) {
227
+ async function ao(e) {
211
228
  const { vault: t } = e, r = {
212
229
  vaultCoreVersion: t.vaultCoreVersion,
213
230
  numVaultKeepers: t.vaultKeeperBtcPubkeys.length,
@@ -215,71 +232,71 @@ async function Zr(e) {
215
232
  councilSize: t.councilSize,
216
233
  protocolFeeRate: t.protocolFeeRate
217
234
  };
218
- kr(r);
219
- const o = be("Claimer Payout", e.payoutClaimerPsbtBase64), s = be(
235
+ Br(r);
236
+ const o = me("Claimer Payout", e.payoutClaimerPsbtBase64), s = me(
220
237
  "Depositor Payout",
221
238
  e.payoutDepositorPsbtBase64
222
- ), n = be("Assert", e.assertPsbtBase64);
239
+ ), n = me("Assert", e.assertPsbtBase64);
223
240
  if (!s.data.globalMap.unsignedTx.toBuffer().equals(o.data.globalMap.unsignedTx.toBuffer()))
224
241
  throw new Error(
225
242
  "Depositor and claimer Payout PSBTs describe different transactions; refusing to sign payout."
226
243
  );
227
- const a = n.txOutputs[te];
244
+ const a = n.txOutputs[G];
228
245
  if (a === void 0)
229
246
  throw new Error(
230
- `Assert transaction has no output ${te}; the Payout's implicit fee cannot be measured.`
247
+ `Assert transaction has no output ${G}; the Payout's implicit fee cannot be measured.`
231
248
  );
232
- if (o.txInputs.length !== Le)
249
+ if (o.txInputs.length !== Me)
233
250
  throw new Error(
234
- `Payout transaction must have exactly ${Le} inputs, got ${o.txInputs.length}`
251
+ `Payout transaction must have exactly ${Me} inputs, got ${o.txInputs.length}`
235
252
  );
236
- const i = o.txInputs[ee].sequence;
253
+ const i = o.txInputs[re].sequence;
237
254
  if (i !== t.timelockPegin)
238
255
  throw new Error(
239
- `Payout input ${ee} sequence ${i} must equal the PegIn CSV timelock ${t.timelockPegin}; refusing to sign payout.`
256
+ `Payout input ${re} sequence ${i} must equal the PegIn CSV timelock ${t.timelockPegin}; refusing to sign payout.`
240
257
  );
241
258
  const u = o.txInputs[A].sequence;
242
259
  if (u !== t.timelockAssert)
243
260
  throw new Error(
244
261
  `Payout input ${A} sequence ${u} must equal the Assert CSV timelock ${t.timelockAssert}; refusing to sign payout.`
245
262
  );
246
- Ye(
263
+ Je(
247
264
  "Claimer",
248
265
  o,
249
266
  t.peginVaultOutputValueSats,
250
267
  a
251
- ), Ye(
268
+ ), Je(
252
269
  "Depositor",
253
270
  s,
254
271
  t.peginVaultOutputValueSats,
255
272
  a
256
273
  );
257
274
  const l = t.peginVaultOutputValueSats + a.value, c = o.txOutputs;
258
- if (c.length !== J)
275
+ if (c.length !== ee)
259
276
  throw new Error(
260
- `Payout transaction has ${c.length} output(s), expected exactly ${J} for a depositor-as-claimer payout.`
277
+ `Payout transaction has ${c.length} output(s), expected exactly ${ee} for a depositor-as-claimer payout.`
261
278
  );
262
- let d = 0;
263
- for (const h of c) d += h.value;
264
- if (d > l)
279
+ let h = 0;
280
+ for (const d of c) h += d.value;
281
+ if (h > l)
265
282
  throw new Error(
266
- `Payout outputs (${d} sats) exceed inputs (${l} sats); invalid transaction.`
283
+ `Payout outputs (${h} sats) exceed inputs (${l} sats); invalid transaction.`
267
284
  );
268
- await Cr(r, {
269
- implicitFeeSats: l - d,
285
+ await Ir(r, {
286
+ implicitFeeSats: l - h,
270
287
  out0Len: c[Ve].script.length,
271
288
  out1Len: void 0
272
289
  });
273
290
  }
274
- class eo extends Error {
291
+ class uo extends Error {
275
292
  constructor(t, r) {
276
293
  super(
277
294
  "Transaction graph's challenger set does not match the vault's (local ∪ universal)" + (t.length > 0 ? ` (missing: ${t.join(", ")})` : "") + (r.length > 0 ? ` (unexpected: ${r.join(", ")})` : "") + ". Refusing to sign an incomplete or padded challenger set."
278
295
  ), this.missing = t, this.unexpected = r, this.name = "ChallengerSetMismatchError";
279
296
  }
280
297
  }
281
- function to(e) {
282
- const t = mt({
298
+ function co(e) {
299
+ const t = wt({
283
300
  claimerBtcPubkey: e.depositorBtcPubkey,
284
301
  depositorBtcPubkey: e.depositorBtcPubkey,
285
302
  vaultProviderBtcPubkey: e.vaultProviderBtcPubkey,
@@ -296,33 +313,33 @@ function to(e) {
296
313
  );
297
314
  const a = [...t, ...r], i = new Set(a), u = a.filter((c) => !n.has(c)), l = s.filter((c) => !i.has(c));
298
315
  if (u.length > 0 || l.length > 0)
299
- throw new eo(u, l);
316
+ throw new uo(u, l);
300
317
  }
301
318
  function Qe(e) {
302
319
  return b(e).toLowerCase();
303
320
  }
304
- class ro extends Error {
321
+ class lo extends Error {
305
322
  constructor(t, r) {
306
323
  super(
307
324
  `Payout transaction output ${Ve} pays ${r}, not the vault's registered payout script ${t}. Refusing to sign a payout to another destination.`
308
325
  ), this.expectedScriptHex = t, this.actualScriptHex = r, this.name = "PayoutDestinationError";
309
326
  }
310
327
  }
311
- function oo(e) {
328
+ function ho(e) {
312
329
  let t;
313
330
  try {
314
331
  t = q.fromBase64(e.payoutPsbtBase64);
315
332
  } catch (c) {
316
333
  throw new Error("Payout PSBT cannot be parsed.", { cause: c });
317
334
  }
318
- const { version: r, locktime: o, outs: s } = so(t);
335
+ const { version: r, locktime: o, outs: s } = po(t);
319
336
  if (r !== Fe || o !== Ue)
320
337
  throw new Error(
321
338
  `Payout transaction has version ${r} and locktime ${o}, expected ${Fe} and ${Ue}.`
322
339
  );
323
- if (s.length !== J)
340
+ if (s.length !== ee)
324
341
  throw new Error(
325
- `Payout transaction has ${s.length} output(s), expected exactly ${J} for a depositor-as-claimer payout.`
342
+ `Payout transaction has ${s.length} output(s), expected exactly ${ee} for a depositor-as-claimer payout.`
326
343
  );
327
344
  const n = b(
328
345
  e.registeredPayoutScriptPubKey
@@ -333,21 +350,21 @@ function oo(e) {
333
350
  );
334
351
  const a = s[Ve].script.toString("hex").toLowerCase();
335
352
  if (a !== n)
336
- throw new ro(n, a);
337
- const i = s[J - 1];
353
+ throw new lo(n, a);
354
+ const i = s[ee - 1];
338
355
  if (i.value !== qe)
339
356
  throw new Error(
340
357
  `Payout CPFP anchor value ${i.value} sats must equal ${qe} sats.`
341
358
  );
342
359
  const u = b(
343
- vr(b(e.depositorBtcPubkey).toLowerCase())
360
+ Pr(b(e.depositorBtcPubkey).toLowerCase())
344
361
  ), l = i.script.toString("hex").toLowerCase();
345
362
  if (l !== u)
346
363
  throw new Error(
347
364
  `Payout CPFP anchor pays ${l}, not the depositor's BIP-86 P2TR ${u}. Refusing to sign a payout whose fee-bump output is spendable by somebody else.`
348
365
  );
349
366
  }
350
- function so(e) {
367
+ function po(e) {
351
368
  return {
352
369
  version: e.version,
353
370
  locktime: e.locktime,
@@ -357,28 +374,28 @@ function so(e) {
357
374
  }))
358
375
  };
359
376
  }
360
- class se extends Error {
377
+ class ne extends Error {
361
378
  constructor(t) {
362
379
  super(t), this.name = "PayoutInputLeafError";
363
380
  }
364
381
  }
365
- function no(e) {
382
+ function go(e) {
366
383
  const t = q.fromBase64(e.payoutDepositorPsbtBase64), r = q.fromBase64(e.payoutClaimerPsbtBase64), o = t.data.globalMap.unsignedTx.toBuffer(), s = r.data.globalMap.unsignedTx.toBuffer();
367
384
  if (!o.equals(s))
368
- throw new se(
385
+ throw new ne(
369
386
  "Depositor and claimer Payout PSBTs describe different transactions; the graph is inconsistent."
370
387
  );
371
388
  const n = r.data.inputs[A], a = t.data.inputs[A];
372
389
  if (!n || !a)
373
- throw new se(
390
+ throw new ne(
374
391
  "Payout PSBT has no Assert-connector input."
375
392
  );
376
393
  if (!n.tapLeafScript || n.tapLeafScript.length !== 1)
377
- throw new se(
394
+ throw new ne(
378
395
  "Claimer Payout PSBT must carry exactly one leaf on the Assert-connector input."
379
396
  );
380
397
  if (a.tapLeafScript && a.tapLeafScript.length > 0)
381
- throw new se(
398
+ throw new ne(
382
399
  "Depositor Payout PSBT already carries an Assert-connector leaf; refusing to overwrite it."
383
400
  );
384
401
  return t.updateInput(A, {
@@ -387,32 +404,31 @@ function no(e) {
387
404
  ...n.tapMerkleRoot ? { tapMerkleRoot: n.tapMerkleRoot } : {}
388
405
  }), t.toBase64();
389
406
  }
390
- const io = "00";
391
- class ao extends Error {
407
+ class fo extends Error {
392
408
  constructor(t, r, o) {
393
409
  super(
394
410
  `Transaction graph does not belong to vault ${t}: its Claim spends PegIn ${o}, which derives vault ${r}. Refusing to sign for a graph served for another vault.`
395
411
  ), this.expectedVaultId = t, this.derivedVaultId = r, this.peginTxid = o, this.name = "VaultIdBindingError";
396
412
  }
397
413
  }
398
- function uo(e) {
414
+ function yo(e) {
399
415
  let t;
400
416
  try {
401
417
  t = q.fromBase64(e);
402
418
  } catch (o) {
403
419
  throw new Error("Claim PSBT cannot be parsed.", { cause: o });
404
420
  }
405
- const r = t.txInputs[pe];
421
+ const r = t.txInputs[ge];
406
422
  if (!r)
407
423
  throw new Error("Claim PSBT carries no PegIn input to bind the vault to.");
408
424
  return _t(
409
425
  "Claim PSBT",
410
426
  t.txInputs.length,
411
427
  r.index
412
- ), Re(r.hash);
428
+ ), Ke(r.hash);
413
429
  }
414
- function co(e) {
415
- const t = e.ins[pe];
430
+ function vo(e) {
431
+ const t = e.ins[ge];
416
432
  if (!t)
417
433
  throw new Error(
418
434
  "Artifacts file's claim_tx carries no PegIn input to bind the vault to."
@@ -421,7 +437,7 @@ function co(e) {
421
437
  "Artifacts file's claim_tx",
422
438
  e.ins.length,
423
439
  t.index
424
- ), Re(t.hash);
440
+ ), Ke(t.hash);
425
441
  }
426
442
  function _t(e, t, r) {
427
443
  if (t !== 1 || r !== X)
@@ -430,29 +446,29 @@ function _t(e, t, r) {
430
446
  );
431
447
  }
432
448
  function St(e) {
433
- const t = G(
449
+ const t = z(
434
450
  Pt(e.peginTxid, e.depositorEthAddress)
435
- ), r = G(e.expectedVaultId);
451
+ ), r = z(e.expectedVaultId);
436
452
  if (t !== r)
437
- throw new ao(r, t, e.peginTxid);
453
+ throw new fo(r, t, e.peginTxid);
438
454
  }
439
- function G(e) {
455
+ function z(e) {
440
456
  return `0x${(e.startsWith("0x") ? e.slice(2) : e).toLowerCase()}`;
441
457
  }
442
- function Re(e) {
458
+ function Ke(e) {
443
459
  return H.from(e).reverse().toString("hex");
444
460
  }
445
- function ce(e, t) {
461
+ function le(e, t) {
446
462
  const r = b(e);
447
463
  if (!/^(?:[0-9a-fA-F]{2})+$/.test(r))
448
464
  throw new Error(`${t} must be non-empty, even-length hex.`);
449
465
  return r.toLowerCase();
450
466
  }
451
467
  function At(e) {
452
- const t = ce(
468
+ const t = le(
453
469
  e.servedVerifyingKeyHex,
454
470
  "source.verifyingKeyHex"
455
- ), r = ce(
471
+ ), r = le(
456
472
  e.trustedVerifyingKeyHex,
457
473
  "trustedVerifyingKeyHex"
458
474
  );
@@ -462,63 +478,61 @@ function At(e) {
462
478
  );
463
479
  }
464
480
  const U = 3;
465
- class lo extends Error {
481
+ class bo extends Error {
466
482
  constructor(t, r) {
467
483
  super(
468
484
  `Artifacts belong to vault ${r}, not ${t}. Select the artifacts file saved for this vault.`
469
485
  ), this.expectedVaultId = t, this.actualVaultId = r, this.name = "ArtifactsVaultMismatchError";
470
486
  }
471
487
  }
472
- function ho(e) {
473
- const t = fo(e, "babe_sessions"), r = [];
488
+ const mo = /^(?:[0-9a-fA-F]{2})+$/;
489
+ function Po(e) {
490
+ const t = Eo(e, "babe_sessions"), r = Object.keys(t);
491
+ if (r.length === 0)
492
+ return { joined: !1 };
474
493
  for (const [o, s] of Object.entries(t)) {
475
494
  const n = typeof s == "object" && s !== null ? s.decryptor_artifacts_hex : void 0;
476
- if (typeof n != "string" || n.length === 0)
495
+ if (typeof n != "string" || !mo.test(n))
477
496
  throw new Error(
478
- `Artifacts file is missing a usable "babe_sessions": the entry for ${o} carries no "decryptor_artifacts_hex" string.`
497
+ `Artifacts file is missing a usable "babe_sessions": the entry for ${o} carries no non-empty hex "decryptor_artifacts_hex".`
479
498
  );
480
- n === io && r.push(o);
481
499
  }
482
- return {
483
- challengerPubkeys: Object.keys(t),
484
- placeholderChallengerPubkeys: r
485
- };
500
+ return { joined: !0, challengerPubkeys: r };
486
501
  }
487
- function po(e) {
502
+ function wo(e) {
488
503
  let t;
489
504
  try {
490
505
  t = JSON.parse(e);
491
- } catch (i) {
492
- throw new Error("Artifacts file is not valid JSON.", { cause: i });
506
+ } catch (a) {
507
+ throw new Error("Artifacts file is not valid JSON.", { cause: a });
493
508
  }
494
- const r = Pe(t.vault_id, "vault_id"), o = go(Pe(t.claim_tx, "claim_tx")), s = me(
509
+ const r = Pe(t.vault_id, "vault_id"), o = xo(Pe(t.claim_tx, "claim_tx")), s = we(
495
510
  t.prover_circuit_version,
496
511
  "prover_circuit_version"
497
512
  ), n = t.claimable_event_block_number === void 0 ? 0n : BigInt(
498
- me(
513
+ we(
499
514
  t.claimable_event_block_number,
500
515
  "claimable_event_block_number"
501
516
  )
502
- ), a = ho(t.babe_sessions);
517
+ );
503
518
  return {
504
- vaultCoreVersion: t.vault_core_version === void 0 ? void 0 : me(t.vault_core_version, "vault_core_version"),
519
+ vaultCoreVersion: t.vault_core_version === void 0 ? void 0 : we(t.vault_core_version, "vault_core_version"),
505
520
  vaultId: r,
506
521
  claimTxid: o.getId(),
507
- peginTxid: co(o),
522
+ peginTxid: vo(o),
508
523
  proverCircuitVersion: s,
509
524
  claimableEventBlockNumber: n,
510
525
  // Required: btc-vault's builder always writes it
511
- // (`delegated_claim.rs:514` @ ac4954e7), so an absent one is not a file
526
+ // (`delegated_claim.rs:874` @ b534ff9e), so an absent one is not a file
512
527
  // this SDK or the CLI produced.
513
528
  verifyingKeyHex: Pe(t.verifying_key, "verifying_key"),
514
- babeSessionChallengerPubkeys: a.challengerPubkeys,
515
- babeSessionPlaceholderChallengerPubkeys: a.placeholderChallengerPubkeys
529
+ babeSessions: Po(t.babe_sessions)
516
530
  };
517
531
  }
518
- async function Js(e) {
519
- const t = po(e.artifactsJson), r = G(e.expectedVaultId), o = G(t.vaultId);
532
+ async function cn(e) {
533
+ const t = wo(e.artifactsJson), r = z(e.expectedVaultId), o = z(t.vaultId);
520
534
  if (r !== o)
521
- throw new lo(r, o);
535
+ throw new bo(r, o);
522
536
  St({
523
537
  peginTxid: t.peginTxid,
524
538
  depositorEthAddress: e.depositorEthAddress,
@@ -541,10 +555,10 @@ async function Js(e) {
541
555
  throw new Error(
542
556
  `Artifacts record prover circuit version ${t.proverCircuitVersion} but the vault's stamped params say ${e.expectedProverCircuitVersion}; a proof for the wrong circuit fails at start-claim, so refusing the file.`
543
557
  );
544
- const n = ce(
558
+ const n = le(
545
559
  t.verifyingKeyHex,
546
560
  'Artifacts file "verifying_key"'
547
- ), a = ce(
561
+ ), a = le(
548
562
  e.trustedVerifyingKeyHex,
549
563
  "trustedVerifyingKeyHex"
550
564
  );
@@ -552,14 +566,9 @@ async function Js(e) {
552
566
  throw new Error(
553
567
  `Artifacts carry Groth16 verifying key ${n} but the trusted key for prover circuit version ${e.expectedProverCircuitVersion} is ${a}; refusing a file whose proof would verify under a substituted key.`
554
568
  );
555
- const [i] = t.babeSessionPlaceholderChallengerPubkeys;
556
- if (i !== void 0)
557
- throw new Error(
558
- `Artifacts carry a placeholder BaBe session for challenger ${i}; join the real sessions into the file before using it (#2598).`
559
- );
560
- return await nr(s, e.artifactsJson), t;
569
+ return await ar(s, e.artifactsJson), t;
561
570
  }
562
- function go(e) {
571
+ function xo(e) {
563
572
  try {
564
573
  return S.fromHex(e);
565
574
  } catch (t) {
@@ -573,12 +582,12 @@ function Pe(e, t) {
573
582
  throw new Error(`Artifacts file is missing a usable "${t}".`);
574
583
  return e;
575
584
  }
576
- function me(e, t) {
585
+ function we(e, t) {
577
586
  if (typeof e != "number" || !Number.isSafeInteger(e) || e < 0)
578
587
  throw new Error(`Artifacts file is missing a usable "${t}".`);
579
588
  return e;
580
589
  }
581
- function fo(e, t) {
590
+ function Eo(e, t) {
582
591
  if (e === void 0) return {};
583
592
  if (typeof e != "object" || e === null || Array.isArray(e))
584
593
  throw new Error(`Artifacts file is missing a usable "${t}".`);
@@ -593,7 +602,7 @@ function It(e) {
593
602
  id: "claim",
594
603
  kind: "claim",
595
604
  psbtBase64: e.claim,
596
- inputIndex: pe
605
+ inputIndex: ge
597
606
  },
598
607
  {
599
608
  id: "assert",
@@ -611,7 +620,7 @@ function It(e) {
611
620
  id: "payoutDepositor",
612
621
  kind: "payoutDepositor",
613
622
  psbtBase64: e.payoutDepositor,
614
- inputIndex: ee
623
+ inputIndex: re
615
624
  }
616
625
  ];
617
626
  for (const r of Object.keys(e.wronglyChallenged))
@@ -620,29 +629,29 @@ function It(e) {
620
629
  id: Bt(r, s),
621
630
  kind: "wronglyChallenged",
622
631
  psbtBase64: o,
623
- inputIndex: $r
632
+ inputIndex: Tr
624
633
  });
625
634
  });
626
635
  return t;
627
636
  }
628
- const yo = wt - xt;
637
+ const ko = "{}", $o = xt - Et;
629
638
  function V(e) {
630
639
  const t = e.replace(/^0x/, "").toLowerCase();
631
- if (t.length === wt)
632
- return t.slice(yo);
633
- if (t.length === xt) return t;
640
+ if (t.length === xt)
641
+ return t.slice($o);
642
+ if (t.length === Et) return t;
634
643
  throw new Error(
635
644
  `Public key must be 33-byte compressed or 32-byte x-only hex, got ${t.length / 2} bytes.`
636
645
  );
637
646
  }
638
- async function Je(e, t, r) {
647
+ async function Ze(e, t, r) {
639
648
  const o = await e.getPublicKeyHex();
640
649
  if (V(o) !== V(t))
641
650
  throw new Error(
642
651
  "Connected wallet does not hold the vault's depositor key. Select the account that made the deposit, then try again."
643
652
  );
644
653
  const s = await e.getAddress();
645
- if (!er(s, o, r))
654
+ if (!tr(s, o, r))
646
655
  throw new Error(
647
656
  `Connected wallet reports address "${s}", which is not derived from the vault's depositor key. Select the account that made the deposit, then try again.`
648
657
  );
@@ -655,15 +664,15 @@ async function Vt(e, t, r, o) {
655
664
  `Depositor key ${s} is not the vault's registered depositor key ${r.depositorBtcPubkey}; refusing to plan a claim for another key.`
656
665
  );
657
666
  try {
658
- br(
659
- Be(r.registeredPayoutScriptPubKey),
667
+ wr(
668
+ Ie(r.registeredPayoutScriptPubKey),
660
669
  r.depositorBtcPubkey,
661
670
  o
662
671
  );
663
- } catch (d) {
672
+ } catch (h) {
664
673
  throw new Error(
665
- `Registered payout script ${r.registeredPayoutScriptPubKey} failed the depositor-key derivation check: ${d instanceof Error ? d.message : String(d)}. This SDK registers only P2TR of the depositor's x-only key or P2WPKH of the compressed key (the contract bounds the script's length alone, PeginLogic.sol:237-240 @ c559f5c2); refusing to sign a claim that pays it.`,
666
- { cause: d }
674
+ `Registered payout script ${r.registeredPayoutScriptPubKey} failed the depositor-key derivation check: ${h instanceof Error ? h.message : String(h)}. This SDK registers only P2TR of the depositor's x-only key or P2WPKH of the compressed key (the contract bounds the script's length alone, PeginLogic.sol:237-240 @ c559f5c2); refusing to sign a claim that pays it.`,
675
+ { cause: h }
667
676
  );
668
677
  }
669
678
  if (e !== U)
@@ -675,37 +684,37 @@ async function Vt(e, t, r, o) {
675
684
  `Graph version ${e} does not match the vault context's vault core version ${r.vaultCoreVersion}; they are one axis and must agree.`
676
685
  );
677
686
  const [n, a, i, u, l] = await Promise.all([
678
- ir(e, t),
679
- ar(e, t),
680
687
  ur(e, t),
681
688
  cr(e, t),
682
- lr(e, t)
689
+ lr(e, t),
690
+ dr(e, t),
691
+ hr(e, t)
683
692
  ]);
684
693
  St({
685
- peginTxid: uo(n),
694
+ peginTxid: yo(n),
686
695
  depositorEthAddress: r.depositorEthAddress,
687
696
  expectedVaultId: r.vaultId
688
- }), Jr({
697
+ }), io({
689
698
  claimPsbtBase64: n,
690
699
  assertPsbtBase64: a,
691
700
  payoutClaimerPsbtBase64: i
692
701
  });
693
- for (const d of [i, l])
694
- oo({
695
- payoutPsbtBase64: d,
702
+ for (const h of [i, l])
703
+ ho({
704
+ payoutPsbtBase64: h,
696
705
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
697
706
  depositorBtcPubkey: r.depositorBtcPubkey
698
707
  });
699
- const c = no({
708
+ const c = go({
700
709
  payoutDepositorPsbtBase64: l,
701
710
  payoutClaimerPsbtBase64: i
702
711
  });
703
- return await Zr({
712
+ return await ao({
704
713
  payoutClaimerPsbtBase64: i,
705
714
  payoutDepositorPsbtBase64: c,
706
715
  assertPsbtBase64: a,
707
716
  vault: r
708
- }), to({
717
+ }), co({
709
718
  graphChallengerPubkeys: Object.keys(u),
710
719
  depositorBtcPubkey: o,
711
720
  vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
@@ -713,7 +722,7 @@ async function Vt(e, t, r, o) {
713
722
  universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys
714
723
  }), { claim: n, assert: a, payoutClaimer: i, payoutDepositor: c, wronglyChallenged: u };
715
724
  }
716
- async function vo(e) {
725
+ async function Co(e) {
717
726
  At({
718
727
  servedVerifyingKeyHex: e.source.verifyingKeyHex,
719
728
  trustedVerifyingKeyHex: e.trustedVerifyingKeyHex,
@@ -731,55 +740,56 @@ async function vo(e) {
731
740
  trustedVerifyingKeyHex: e.trustedVerifyingKeyHex,
732
741
  source: e.source,
733
742
  vault: e.vault,
734
- babeSessionsJson: e.babeSessionsJson,
743
+ // Omitted means unjoined: the browser cannot hold the real sessions.
744
+ babeSessionsJson: e.babeSessionsJson === void 0 ? ko : e.babeSessionsJson,
735
745
  requests: It(t)
736
746
  };
737
747
  }
738
- function ge(e, t, r) {
739
- re({
740
- requestedPsbtHex: Ke(t.psbtBase64),
748
+ function fe(e, t, r) {
749
+ oe({
750
+ requestedPsbtHex: He(t.psbtBase64),
741
751
  signatureHex: r,
742
752
  signerXOnlyPubkeyHex: V(e.depositorPublicKey),
743
753
  inputIndex: t.inputIndex
744
754
  });
745
755
  }
746
- function Ke(e) {
756
+ function He(e) {
747
757
  return H.from(e, "base64").toString("hex");
748
758
  }
749
759
  function Rt(e) {
750
760
  return H.from(e, "hex").toString("base64");
751
761
  }
752
- class j extends Error {
762
+ class Y extends Error {
753
763
  constructor(t) {
754
764
  super(t), this.name = "SigningPlanMismatchError";
755
765
  }
756
766
  }
757
- function bo(e, t) {
767
+ function To(e, t) {
758
768
  if (e.length !== t.length)
759
- throw new j(
769
+ throw new Y(
760
770
  `Plan has ${e.length} requests but the graph builds ${t.length}; the plan was altered after planning.`
761
771
  );
762
772
  for (let r = 0; r < t.length; r++) {
763
773
  const o = t[r], s = e[r];
764
774
  if (s.id !== o.id)
765
- throw new j(
775
+ throw new Y(
766
776
  `Plan request at position ${r} is "${s.id}" but the graph builds "${o.id}" there; the plan was altered after planning.`
767
777
  );
768
778
  if (s.kind !== o.kind)
769
- throw new j(
779
+ throw new Y(
770
780
  `Plan request "${s.id}" has kind "${s.kind}" but the graph builds "${o.kind}"; the plan was altered after planning.`
771
781
  );
772
782
  if (s.inputIndex !== o.inputIndex)
773
- throw new j(
783
+ throw new Y(
774
784
  `Plan request "${s.id}" signs inputIndex ${s.inputIndex} but the graph builds ${o.inputIndex}; the plan was altered after planning.`
775
785
  );
776
786
  if (s.psbtBase64 !== o.psbtBase64)
777
- throw new j(
787
+ throw new Y(
778
788
  `Plan request "${s.id}" carries a psbt that differs from the one the graph builds; the plan was altered after planning.`
779
789
  );
780
790
  }
781
791
  }
782
- function Po(e, t) {
792
+ function _o(e, t) {
783
793
  const r = new Set(e.map((a) => a.id)), o = [...r].filter((a) => !t.has(a)), s = [...t.keys()].filter((a) => !r.has(a));
784
794
  if (o.length === 0 && s.length === 0) return;
785
795
  const n = (a) => a.map((i) => `"${i}"`).join(", ");
@@ -787,7 +797,7 @@ function Po(e, t) {
787
797
  `Signatures do not cover the plan: ${t.size} signatures for ${e.length} requests` + (o.length > 0 ? `; missing ${n(o)}` : "") + (s.length > 0 ? `; extra ${n(s)}` : "") + "."
788
798
  );
789
799
  }
790
- function M(e, t) {
800
+ function L(e, t) {
791
801
  const r = e.get(t);
792
802
  if (r === void 0)
793
803
  throw new Error(
@@ -795,7 +805,7 @@ function M(e, t) {
795
805
  );
796
806
  return r;
797
807
  }
798
- async function mo(e) {
808
+ async function So(e) {
799
809
  const { plan: t, signatures: r } = e, { txGraphVersion: o } = t.vault, s = t.source.txGraphJson, n = At({
800
810
  servedVerifyingKeyHex: t.source.verifyingKeyHex,
801
811
  trustedVerifyingKeyHex: t.trustedVerifyingKeyHex,
@@ -806,34 +816,34 @@ async function mo(e) {
806
816
  t.vault,
807
817
  t.depositorPublicKey
808
818
  ), i = It(a);
809
- bo(t.requests, i), Po(i, r);
819
+ To(t.requests, i), _o(i, r);
810
820
  for (const c of i)
811
- ge(
821
+ fe(
812
822
  t,
813
823
  c,
814
- M(r, c.id)
824
+ L(r, c.id)
815
825
  );
816
826
  const u = {};
817
827
  for (const c of Object.keys(a.wronglyChallenged))
818
828
  u[c] = a.wronglyChallenged[c].map(
819
- (d, h) => M(
829
+ (h, d) => L(
820
830
  r,
821
- Bt(c, h)
831
+ Bt(c, d)
822
832
  )
823
833
  );
824
- const l = await dr(
834
+ const l = await pr(
825
835
  o,
826
836
  s,
827
- M(r, "claim")
837
+ L(r, "claim")
828
838
  );
829
- return hr({
839
+ return gr({
830
840
  txGraphVersion: o,
831
841
  graphJson: s,
832
842
  signedClaimTxHex: l,
833
- assertClaimerSigHex: M(r, "assert"),
834
- payoutClaimerSigHex: M(r, "payoutClaimer"),
843
+ assertClaimerSigHex: L(r, "assert"),
844
+ payoutClaimerSigHex: L(r, "payoutClaimer"),
835
845
  wronglyChallengedSigs: u,
836
- depositorPayoutSigHex: M(r, "payoutDepositor"),
846
+ depositorPayoutSigHex: L(r, "payoutDepositor"),
837
847
  verifyingKeyHex: n,
838
848
  claimableEventBlockNumber: t.vault.claimableEventBlockNumber,
839
849
  proverCircuitVersion: t.vault.proverCircuitVersion,
@@ -842,10 +852,10 @@ async function mo(e) {
842
852
  expectedVaultCoreVersion: t.vault.vaultCoreVersion
843
853
  });
844
854
  }
845
- function wo(e) {
855
+ function Ao(e) {
846
856
  return typeof e.signDelegatedClaimPsbt == "function";
847
857
  }
848
- class xo extends Error {
858
+ class Bo extends Error {
849
859
  constructor(t, r, o, s) {
850
860
  super(t, s), this.signatures = r, this.failedRequestId = o, this.name = "DelegatedClaimSigningIncompleteError";
851
861
  }
@@ -856,30 +866,30 @@ const Kt = {
856
866
  payoutClaimer: "standalone",
857
867
  claim: "standalone",
858
868
  wronglyChallenged: "standalone"
859
- }, Eo = [
869
+ }, Io = [
860
870
  "payoutClaimer",
861
871
  "claim",
862
872
  "wronglyChallenged"
863
873
  ];
864
- async function $o(e, t, r = {}) {
874
+ async function Vo(e, t, r = {}) {
865
875
  var s;
866
- if ((s = r.signal) == null || s.throwIfAborted(), ko(e), V(e.depositorPublicKey) !== e.vault.depositorBtcPubkey)
876
+ if ((s = r.signal) == null || s.throwIfAborted(), Ro(e), V(e.depositorPublicKey) !== e.vault.depositorBtcPubkey)
867
877
  throw new Error(
868
878
  `Plan depositor key ${V(e.depositorPublicKey)} is not the vault's registered depositor key ${e.vault.depositorBtcPubkey}; the plan was not built for this vault.`
869
879
  );
870
- if (yt(t)) {
871
- if (!wo(t))
880
+ if (vt(t)) {
881
+ if (!Ao(t))
872
882
  throw new Error(
873
883
  "Approval wallet does not implement signDelegatedClaimPsbt; the claim ceremony needs it because the device signs some claim PSBTs with no loaded intent and needs its own derivation fields on them."
874
884
  );
875
- const n = To(r, e);
876
- _o(n.depositTerms, e.vault);
877
- const a = Co(e), i = await Je(
885
+ const n = Ho(r, e);
886
+ Oo(n.depositTerms, e.vault);
887
+ const a = Ko(e), i = await Ze(
878
888
  t,
879
889
  e.depositorPublicKey,
880
890
  e.btcNetwork
881
891
  );
882
- return So(
892
+ return No(
883
893
  e,
884
894
  t,
885
895
  i,
@@ -888,14 +898,14 @@ async function $o(e, t, r = {}) {
888
898
  r
889
899
  );
890
900
  }
891
- const o = await Je(
901
+ const o = await Ze(
892
902
  t,
893
903
  e.depositorPublicKey,
894
904
  e.btcNetwork
895
905
  );
896
- return Bo(e, t, o, r.signal);
906
+ return Lo(e, t, o, r.signal);
897
907
  }
898
- function ko(e) {
908
+ function Ro(e) {
899
909
  const t = /* @__PURE__ */ new Set();
900
910
  for (const r of e.requests) {
901
911
  if (t.has(r.id))
@@ -905,10 +915,10 @@ function ko(e) {
905
915
  t.add(r.id);
906
916
  }
907
917
  }
908
- function Co(e) {
918
+ function Ko(e) {
909
919
  const t = e.requests.filter(
910
920
  (s) => Kt[s.kind] === "intentBound"
911
- ), r = Eo.flatMap(
921
+ ), r = Io.flatMap(
912
922
  (s) => e.requests.filter((n) => n.kind === s)
913
923
  ), o = t.length + r.length;
914
924
  if (o !== e.requests.length)
@@ -923,7 +933,7 @@ function Ht(e, t) {
923
933
  `Delegated-claim signing ended with ${t.size} signatures for ${e.requests.length} requests; the set is incomplete and must not be treated as signed.`
924
934
  );
925
935
  }
926
- function To(e, t) {
936
+ function Ho(e, t) {
927
937
  if (e.depositTerms === void 0)
928
938
  throw new Error(
929
939
  "An approval wallet signs Assert and the depositor Payout only under this vault's loaded intent; pass depositTerms (rebuilt from on-chain state) so it can be approved."
@@ -932,14 +942,14 @@ function To(e, t) {
932
942
  throw new Error(
933
943
  "An approval wallet releases a loaded intent only through the vault-root derivation; pass vaultContext so that derivation can run before and after the intent-bound signatures."
934
944
  );
935
- const r = Ie(e.vaultContext.depositorBtcPubkey);
945
+ const r = yt(e.vaultContext.depositorBtcPubkey);
936
946
  if (r !== t.vault.depositorBtcPubkey)
937
947
  throw new Error(
938
948
  `vaultContext derives from depositor key ${r} but this plan's vault is registered to ${t.vault.depositorBtcPubkey}; the device would derive for another depositor.`
939
949
  );
940
950
  return { depositTerms: e.depositTerms, vaultContext: e.vaultContext };
941
951
  }
942
- function _o(e, t) {
952
+ function Oo(e, t) {
943
953
  const r = (s) => s.map((n) => V(n)).sort().join(",");
944
954
  if (r(e.vaultKeeperBtcPubkeys) !== r(t.vaultKeeperBtcPubkeys) || r(e.universalChallengerBtcPubkeys) !== r(t.universalChallengerBtcPubkeys))
945
955
  throw new Error(
@@ -972,44 +982,44 @@ function _o(e, t) {
972
982
  `Deposit terms group at htlcVout ${s.htlcVout} names a different vault provider than the vault context this claim signs for; the device would bind the Assert to the wrong intent.`
973
983
  );
974
984
  }
975
- async function So(e, t, r, o, { intentBound: s, standalone: n }, a) {
985
+ async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
976
986
  var g;
977
- const i = Ao(e, a.resume), u = [...s, ...n];
987
+ const i = Do(e, a.resume), u = [...s, ...n];
978
988
  let l = 0;
979
989
  const c = {
980
990
  phase: "clearing any loaded intent"
981
- }, d = async (p) => {
982
- var P;
983
- c.phase = "signing", (P = a.signal) == null || P.throwIfAborted();
991
+ }, h = async (p) => {
992
+ var m;
993
+ c.phase = "signing", (m = a.signal) == null || m.throwIfAborted();
984
994
  const y = await t.signDelegatedClaimPsbt(
985
- Ke(p.psbtBase64),
986
- Et(
995
+ He(p.psbtBase64),
996
+ kt(
987
997
  e.depositorPublicKey,
988
998
  p.inputIndex,
989
999
  r
990
1000
  )
991
- ), f = await bt(
1001
+ ), f = await mt(
992
1002
  Rt(y),
993
1003
  p.inputIndex
994
1004
  );
995
- ge(e, p, f), i.set(p.id, f);
996
- }, h = async (p) => {
1005
+ fe(e, p, f), i.set(p.id, f);
1006
+ }, d = async (p) => {
997
1007
  var f;
998
1008
  c.phase = p, (f = a.signal) == null || f.throwIfAborted(), (await $t(t, o.vaultContext)).fill(0);
999
1009
  };
1000
1010
  typeof t.validateDepositTerms == "function" && await t.validateDepositTerms(o.depositTerms);
1001
1011
  try {
1002
- await h("clearing any loaded intent"), c.phase = "approving the deposit terms", (g = a.signal) == null || g.throwIfAborted(), await t.approveDepositTerms(o.depositTerms);
1012
+ await d("clearing any loaded intent"), c.phase = "approving the deposit terms", (g = a.signal) == null || g.throwIfAborted(), await t.approveDepositTerms(o.depositTerms);
1003
1013
  for (const p of s)
1004
- await d(p), l++;
1005
- await h("releasing the loaded intent");
1014
+ await h(p), l++;
1015
+ await d("releasing the loaded intent");
1006
1016
  for (const p of n)
1007
- i.has(p.id) || await d(p), l++;
1017
+ i.has(p.id) || await h(p), l++;
1008
1018
  } catch (p) {
1009
1019
  const y = u[l];
1010
1020
  if (i.size === 0 || y === void 0) throw p;
1011
1021
  const f = c.phase === "signing" ? `stopped at "${y.id}"` : `stopped before "${y.id}" while ${c.phase}`;
1012
- throw new xo(
1022
+ throw new Bo(
1013
1023
  `Delegated-claim signing ${f}; ${i.size} of ${e.requests.length} signatures were collected.`,
1014
1024
  i,
1015
1025
  y.id,
@@ -1018,14 +1028,14 @@ async function So(e, t, r, o, { intentBound: s, standalone: n }, a) {
1018
1028
  }
1019
1029
  return Ht(e, i), i;
1020
1030
  }
1021
- function Ao(e, t) {
1031
+ function Do(e, t) {
1022
1032
  const r = /* @__PURE__ */ new Map();
1023
1033
  if (!t) return r;
1024
1034
  for (const o of e.requests) {
1025
1035
  const s = t.get(o.id);
1026
1036
  if (!(s === void 0 || Kt[o.kind] === "intentBound")) {
1027
1037
  try {
1028
- ge(e, o, s);
1038
+ fe(e, o, s);
1029
1039
  } catch {
1030
1040
  continue;
1031
1041
  }
@@ -1034,12 +1044,12 @@ function Ao(e, t) {
1034
1044
  }
1035
1045
  return r;
1036
1046
  }
1037
- async function Bo(e, t, r, o) {
1038
- const s = e.requests, n = await vt(
1047
+ async function Lo(e, t, r, o) {
1048
+ const s = e.requests, n = await bt(
1039
1049
  t,
1040
- s.map((i) => Ke(i.psbtBase64)),
1050
+ s.map((i) => He(i.psbtBase64)),
1041
1051
  s.map(
1042
- (i) => Et(
1052
+ (i) => kt(
1043
1053
  e.depositorPublicKey,
1044
1054
  i.inputIndex,
1045
1055
  r
@@ -1048,43 +1058,43 @@ async function Bo(e, t, r, o) {
1048
1058
  o
1049
1059
  ), a = /* @__PURE__ */ new Map();
1050
1060
  for (let i = 0; i < s.length; i++) {
1051
- const u = await bt(
1061
+ const u = await mt(
1052
1062
  Rt(n[i]),
1053
1063
  s[i].inputIndex
1054
1064
  );
1055
- ge(e, s[i], u), a.set(s[i].id, u);
1065
+ fe(e, s[i], u), a.set(s[i].id, u);
1056
1066
  }
1057
1067
  return Ht(e, a), a;
1058
1068
  }
1059
- async function Zs(e) {
1060
- const t = await vo({
1069
+ async function ln(e) {
1070
+ const t = await Co({
1061
1071
  depositorPublicKey: e.depositorPublicKey,
1062
1072
  btcNetwork: e.btcNetwork,
1063
1073
  source: e.source,
1064
1074
  trustedVerifyingKeyHex: e.trustedVerifyingKeyHex,
1065
1075
  vault: e.vault,
1066
1076
  babeSessionsJson: e.babeSessionsJson
1067
- }), r = await $o(t, e.btcWallet, {
1077
+ }), r = await Vo(t, e.btcWallet, {
1068
1078
  depositTerms: e.depositTerms,
1069
1079
  vaultContext: e.vaultContext
1070
1080
  });
1071
- return mo({ plan: t, signatures: r });
1081
+ return So({ plan: t, signatures: r });
1072
1082
  }
1073
- async function en(e) {
1083
+ async function dn(e) {
1074
1084
  const t = await $t(e.btcWallet, e.vaultContext);
1075
1085
  let r;
1076
1086
  try {
1077
- r = await pr(t, e.htlcVout);
1087
+ r = await fr(t, e.htlcVout);
1078
1088
  } finally {
1079
1089
  t.fill(0);
1080
1090
  }
1081
1091
  let o;
1082
1092
  try {
1083
- o = await gr(r);
1093
+ o = await yr(r);
1084
1094
  } finally {
1085
1095
  r.fill(0);
1086
1096
  }
1087
- return Io(o.pk_hash, e.expectedWotsPkHash), await fr(
1097
+ return Mo(o.pk_hash, e.expectedWotsPkHash), await vr(
1088
1098
  e.txGraphVersion,
1089
1099
  o.keypair,
1090
1100
  e.txGraphJson
@@ -1093,16 +1103,16 @@ async function en(e) {
1093
1103
  pkHash: o.pk_hash
1094
1104
  };
1095
1105
  }
1096
- function Io(e, t) {
1097
- if (ne(e) !== ne(t))
1106
+ function Mo(e, t) {
1107
+ if (ie(e) !== ie(t))
1098
1108
  throw new Error(
1099
- `Derived WOTS public-key hash ${ne(e)} does not match the vault's on-chain depositorWotsPkHash ${ne(t)}. The wallet, the HTLC output index, or the derivation itself is not the one this vault was created with.`
1109
+ `Derived WOTS public-key hash ${ie(e)} does not match the vault's on-chain depositorWotsPkHash ${ie(t)}. The wallet, the HTLC output index, or the derivation itself is not the one this vault was created with.`
1100
1110
  );
1101
1111
  }
1102
- function ne(e) {
1112
+ function ie(e) {
1103
1113
  return `0x${(e.startsWith("0x") ? e.slice(2) : e).toLowerCase()}`;
1104
1114
  }
1105
- function we(e, t, r) {
1115
+ function xe(e, t, r) {
1106
1116
  const o = `${e} operation key (admin=${t.ethAddress})`, s = _e(
1107
1117
  t.btcPubKey,
1108
1118
  `${e} roster key (admin=${t.ethAddress})`
@@ -1114,7 +1124,7 @@ function we(e, t, r) {
1114
1124
  rotated: n !== s
1115
1125
  };
1116
1126
  }
1117
- function Vo(e) {
1127
+ function Fo(e) {
1118
1128
  const t = /* @__PURE__ */ new Map();
1119
1129
  for (const r of e) {
1120
1130
  const o = t.get(r.operationBtcPubkey);
@@ -1130,7 +1140,7 @@ function Ot(e, t, r) {
1130
1140
  throw new Error(
1131
1141
  `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`
1132
1142
  );
1133
- const o = we(
1143
+ const o = xe(
1134
1144
  "vault provider",
1135
1145
  {
1136
1146
  ethAddress: e.vaultProviderEthAddress,
@@ -1138,11 +1148,11 @@ function Ot(e, t, r) {
1138
1148
  },
1139
1149
  t.vaultProvider
1140
1150
  ), s = e.vaultKeepers.map(
1141
- (a, i) => we("vault keeper", a, t.vaultKeepers[i])
1151
+ (a, i) => xe("vault keeper", a, t.vaultKeepers[i])
1142
1152
  ), n = e.universalChallengers.map(
1143
- (a, i) => we("universal challenger", a, t.universalChallengers[i])
1153
+ (a, i) => xe("universal challenger", a, t.universalChallengers[i])
1144
1154
  );
1145
- return Vo([
1155
+ return Fo([
1146
1156
  o,
1147
1157
  ...s,
1148
1158
  ...n
@@ -1157,7 +1167,7 @@ function Ot(e, t, r) {
1157
1167
  query: e
1158
1168
  };
1159
1169
  }
1160
- async function Ro(e) {
1170
+ async function Uo(e) {
1161
1171
  const t = await e.operationKeyReader.getCurrentOperationKeys(
1162
1172
  e.query,
1163
1173
  e.blockNumber
@@ -1174,7 +1184,7 @@ async function Nt(e) {
1174
1184
  epochs: e.epochs
1175
1185
  });
1176
1186
  }
1177
- async function Ko(e) {
1187
+ async function qo(e) {
1178
1188
  const { basic: t, protocol: r } = e.vault, {
1179
1189
  registryReader: o,
1180
1190
  vaultKeeperReader: s,
@@ -1216,7 +1226,7 @@ async function Ko(e) {
1216
1226
  epochs: c
1217
1227
  });
1218
1228
  }
1219
- async function tn(e) {
1229
+ async function hn(e) {
1220
1230
  const { vaultId: t, readers: r } = e, o = await r.registryReader.getVaultData(t), { basic: s, protocol: n } = o;
1221
1231
  if (n.vaultCoreVersion !== U)
1222
1232
  throw new Error(
@@ -1226,19 +1236,19 @@ async function tn(e) {
1226
1236
  s.depositorBtcPubKey,
1227
1237
  `getBtcVaultBasicInfo(${t}).depositorBtcPubKey`
1228
1238
  );
1229
- if (s.status !== Ge.REDEEMED)
1230
- throw new Me(
1239
+ if (s.status !== ze.REDEEMED)
1240
+ throw new Le(
1231
1241
  t,
1232
1242
  s.depositorBtcPubKey,
1233
1243
  s.createdAt,
1234
1244
  s.createdAt,
1235
- `the vault's status is ${s.status}, not Redeemed (${Ge.REDEEMED}); no scan was made`
1245
+ `the vault's status is ${s.status}, not Redeemed (${ze.REDEEMED}); no scan was made`
1236
1246
  );
1237
1247
  const [i, u, l, c] = await Promise.all([
1238
- Ko({ vaultId: t, vault: o, readers: r }),
1248
+ qo({ vaultId: t, vault: o, readers: r }),
1239
1249
  r.registryReader.getRegistrationRecordsAtBlock(s.createdAt),
1240
1250
  r.registryReader.getVaultClaimableBy(t, s.depositorBtcPubKey, s.createdAt).catch((v) => {
1241
- throw Pr(v) ? new Me(
1251
+ throw xr(v) ? new Le(
1242
1252
  t,
1243
1253
  s.depositorBtcPubKey,
1244
1254
  v.fromBlock,
@@ -1250,54 +1260,54 @@ async function tn(e) {
1250
1260
  r.protocolParamsReader.getOffchainParamsByVersion(
1251
1261
  n.offchainParamsVersion
1252
1262
  )
1253
- ]), d = _r(c.timelockAssert), h = mr(u, t, s.createdAt);
1254
- wr(h);
1255
- const g = xr(h);
1263
+ ]), h = Rr(c.timelockAssert), d = Er(u, t, s.createdAt);
1264
+ kr(d);
1265
+ const g = $r(d);
1256
1266
  if (g.toLowerCase() !== n.prePeginTxHash.toLowerCase())
1257
1267
  throw new Error(
1258
1268
  `Registration log of vault ${t} records prePeginTxHash ${g} but the vault record says ${n.prePeginTxHash}; refusing an inconsistent node.`
1259
1269
  );
1260
- if (h.vaultCoreVersion !== n.vaultCoreVersion)
1270
+ if (d.vaultCoreVersion !== n.vaultCoreVersion)
1261
1271
  throw new Error(
1262
- `Registration log of vault ${t} records vault core version ${h.vaultCoreVersion} but the vault record says ${n.vaultCoreVersion}; refusing an inconsistent node.`
1272
+ `Registration log of vault ${t} records vault core version ${d.vaultCoreVersion} but the vault record says ${n.vaultCoreVersion}; refusing an inconsistent node.`
1263
1273
  );
1264
- if (h.amount !== s.amount)
1274
+ if (d.amount !== s.amount)
1265
1275
  throw new Error(
1266
- `Registration log of vault ${t} records amount ${h.amount} sats but the vault record says ${s.amount}; refusing an inconsistent node.`
1276
+ `Registration log of vault ${t} records amount ${d.amount} sats but the vault record says ${s.amount}; refusing an inconsistent node.`
1267
1277
  );
1268
- if (h.depositor.toLowerCase() !== s.depositor.toLowerCase())
1278
+ if (d.depositor.toLowerCase() !== s.depositor.toLowerCase())
1269
1279
  throw new Error(
1270
- `Registration log of vault ${t} records depositor ${h.depositor} but the vault record says ${s.depositor}; refusing an inconsistent node.`
1280
+ `Registration log of vault ${t} records depositor ${d.depositor} but the vault record says ${s.depositor}; refusing an inconsistent node.`
1271
1281
  );
1272
- if (h.vaultProvider.toLowerCase() !== s.vaultProvider.toLowerCase())
1282
+ if (d.vaultProvider.toLowerCase() !== s.vaultProvider.toLowerCase())
1273
1283
  throw new Error(
1274
- `Registration log of vault ${t} records vaultProvider ${h.vaultProvider} but the vault record says ${s.vaultProvider}; refusing an inconsistent node.`
1284
+ `Registration log of vault ${t} records vaultProvider ${d.vaultProvider} but the vault record says ${s.vaultProvider}; refusing an inconsistent node.`
1275
1285
  );
1276
1286
  if (l.vaultCoreVersion !== n.vaultCoreVersion)
1277
1287
  throw new Error(
1278
1288
  `Redemption log of vault ${t} records vault core version ${l.vaultCoreVersion} but the vault record says ${n.vaultCoreVersion}; refusing an inconsistent node.`
1279
1289
  );
1280
- if (l.proverCircuitVersion !== h.proverCircuitVersion)
1290
+ if (l.proverCircuitVersion !== d.proverCircuitVersion)
1281
1291
  throw new Error(
1282
- `Redemption log of vault ${t} records proverCircuitVersion ${l.proverCircuitVersion} but the registration log says ${h.proverCircuitVersion}; refusing an inconsistent node.`
1292
+ `Redemption log of vault ${t} records proverCircuitVersion ${l.proverCircuitVersion} but the registration log says ${d.proverCircuitVersion}; refusing an inconsistent node.`
1283
1293
  );
1284
- if (h.proverCircuitVersion !== c.proverCircuitVersion)
1294
+ if (d.proverCircuitVersion !== c.proverCircuitVersion)
1285
1295
  throw new Error(
1286
- `Registration log of vault ${t} records proverCircuitVersion ${h.proverCircuitVersion} but the stamped offchain params say ${c.proverCircuitVersion}; refusing an inconsistent node.`
1296
+ `Registration log of vault ${t} records proverCircuitVersion ${d.proverCircuitVersion} but the stamped offchain params say ${c.proverCircuitVersion}; refusing an inconsistent node.`
1287
1297
  );
1288
- const p = Er(n.depositorSignedPeginTx);
1298
+ const p = Cr(n.depositorSignedPeginTx);
1289
1299
  for (const [v, E] of [
1290
- ["Registration", h.peginTxHash],
1300
+ ["Registration", d.peginTxHash],
1291
1301
  ["Redemption", l.peginTxHash]
1292
1302
  ])
1293
1303
  if (E.toLowerCase() !== p.toLowerCase())
1294
1304
  throw new Error(
1295
1305
  `${v} log of vault ${t} records peginTxHash ${E} but the vault's depositor-signed PegIn hashes to ${p}; refusing an inconsistent node.`
1296
1306
  );
1297
- const y = G(
1307
+ const y = z(
1298
1308
  Pt(p, s.depositor)
1299
1309
  );
1300
- if (y !== G(t))
1310
+ if (y !== z(t))
1301
1311
  throw new Error(
1302
1312
  `Depositor-signed PegIn of vault ${t} derives vault id ${y} with depositor ${s.depositor}; refusing an inconsistent node.`
1303
1313
  );
@@ -1306,9 +1316,9 @@ async function tn(e) {
1306
1316
  "universalChallengersVersion",
1307
1317
  "appVaultKeepersVersion"
1308
1318
  ]) {
1309
- if (h[v] !== n[v])
1319
+ if (d[v] !== n[v])
1310
1320
  throw new Error(
1311
- `Registration log of vault ${t} records ${v} ${h[v]} but the vault record says ${n[v]}; refusing an inconsistent node.`
1321
+ `Registration log of vault ${t} records ${v} ${d[v]} but the vault record says ${n[v]}; refusing an inconsistent node.`
1312
1322
  );
1313
1323
  if (l[v] !== n[v])
1314
1324
  throw new Error(
@@ -1322,19 +1332,19 @@ async function tn(e) {
1322
1332
  throw new Error(
1323
1333
  `Depositor-signed PegIn of vault ${t} has ${f.ins.length} inputs; it spends Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout} with exactly one; refusing an inconsistent node.`
1324
1334
  );
1325
- const P = Re(f.ins[0].hash), k = f.ins[0].index;
1326
- if (P !== b(n.prePeginTxHash).toLowerCase() || k !== n.htlcVout)
1335
+ const m = Ke(f.ins[0].hash), $ = f.ins[0].index;
1336
+ if (m !== b(n.prePeginTxHash).toLowerCase() || $ !== n.htlcVout)
1327
1337
  throw new Error(
1328
- `Depositor-signed PegIn of vault ${t} spends ${P}:${k} but the vault record says Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout}; refusing an inconsistent node.`
1338
+ `Depositor-signed PegIn of vault ${t} spends ${m}:${$} but the vault record says Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout}; refusing an inconsistent node.`
1329
1339
  );
1330
- const x = f.outs[Q];
1340
+ const x = f.outs[Z];
1331
1341
  if (x === void 0)
1332
1342
  throw new Error(
1333
- `Depositor-signed PegIn of vault ${t} has no output ${Q}; the Payout cannot spend the Vault UTXO.`
1343
+ `Depositor-signed PegIn of vault ${t} has no output ${Z}; the Payout cannot spend the Vault UTXO.`
1334
1344
  );
1335
1345
  if (BigInt(x.value) !== s.amount)
1336
1346
  throw new Error(
1337
- `Depositor-signed PegIn of vault ${t} pays ${x.value} sats to output ${Q} but the vault record says ${s.amount}; refusing an inconsistent node.`
1347
+ `Depositor-signed PegIn of vault ${t} pays ${x.value} sats to output ${Z} but the vault record says ${s.amount}; refusing an inconsistent node.`
1338
1348
  );
1339
1349
  return {
1340
1350
  context: {
@@ -1342,7 +1352,7 @@ async function tn(e) {
1342
1352
  depositorEthAddress: s.depositor,
1343
1353
  depositorBtcPubkey: a,
1344
1354
  registeredPayoutScriptPubKey: b(
1345
- h.depositorPayoutScriptPubKey
1355
+ d.depositorPayoutScriptPubKey
1346
1356
  ),
1347
1357
  vaultProviderBtcPubkey: i.vaultProvider.operationBtcPubkey,
1348
1358
  vaultKeeperBtcPubkeys: [
@@ -1358,11 +1368,11 @@ async function tn(e) {
1358
1368
  peginVaultOutputValueSats: x.value,
1359
1369
  protocolFeeRate: c.feeRate,
1360
1370
  councilSize: c.securityCouncilKeys.length,
1361
- timelockPegin: d,
1371
+ timelockPegin: h,
1362
1372
  timelockAssert: Number(c.timelockAssert)
1363
1373
  },
1364
1374
  vault: o,
1365
- registrationRecord: h,
1375
+ registrationRecord: d,
1366
1376
  registrationRecords: u,
1367
1377
  participantKeys: i,
1368
1378
  offchainParams: c,
@@ -1374,35 +1384,35 @@ async function tn(e) {
1374
1384
  htlcVout: n.htlcVout
1375
1385
  };
1376
1386
  }
1377
- const Ho = 8, Oo = 6e3, No = 10 * 6e4, Do = 10;
1387
+ const Go = 8, Xo = 6e3, zo = 10 * 6e4, jo = 10;
1378
1388
  class Dt extends Error {
1379
1389
  constructor(t) {
1380
1390
  super(t), this.name = "PeginRegistrationMissingError";
1381
1391
  }
1382
1392
  }
1383
- class Mt extends Error {
1393
+ class Lt extends Error {
1384
1394
  constructor(t) {
1385
1395
  super(t), this.name = "PeginRegistrationNotFinalError";
1386
1396
  }
1387
1397
  }
1388
- function Mo(e) {
1398
+ function Wo(e) {
1389
1399
  return e instanceof Dt || e instanceof Error && e.name === "PeginRegistrationMissingError";
1390
1400
  }
1391
- function rn(e) {
1392
- return e instanceof Mt || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
1401
+ function pn(e) {
1402
+ return e instanceof Lt || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
1393
1403
  }
1394
- function Ze(e) {
1404
+ function et(e) {
1395
1405
  const { currentBlock: t, createdAtBlock: r } = e, o = t - r + 1n;
1396
1406
  return o < 0n ? 0 : Number(o);
1397
1407
  }
1398
- async function on(e) {
1408
+ async function gn(e) {
1399
1409
  const {
1400
1410
  vaultRegistryReader: t,
1401
1411
  getBlockNumber: r,
1402
1412
  vaultIds: o,
1403
- required: s = Ho,
1404
- pollIntervalMs: n = Oo,
1405
- timeoutMs: a = No,
1413
+ required: s = Go,
1414
+ pollIntervalMs: n = Xo,
1415
+ timeoutMs: a = zo,
1406
1416
  signal: i,
1407
1417
  onProgress: u
1408
1418
  } = e;
@@ -1411,52 +1421,52 @@ async function on(e) {
1411
1421
  "waitForPeginRegistrationDepth requires at least one vault ID"
1412
1422
  );
1413
1423
  const l = Date.now();
1414
- let c = !1, d = 0, h;
1424
+ let c = !1, h = 0, d;
1415
1425
  for (; ; ) {
1416
1426
  if (i != null && i.aborted)
1417
1427
  throw new Error(
1418
1428
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
1419
1429
  );
1420
1430
  if (Date.now() - l >= a)
1421
- throw new Mt(
1422
- `Peg-in registration did not reach ${s} Ethereum confirmations within ${a}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.` + (h instanceof Error ? ` Last read error: ${h.message}` : "")
1431
+ throw new Lt(
1432
+ `Peg-in registration did not reach ${s} Ethereum confirmations within ${a}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}` : "")
1423
1433
  );
1424
1434
  try {
1425
1435
  const g = await r(), p = await Promise.all(
1426
1436
  o.map((f) => t.getVaultBasicInfo(f))
1427
1437
  ), y = p.findIndex(
1428
- (f) => f.depositor === Sr || f.createdAt === 0n
1438
+ (f) => f.depositor === Kr || f.createdAt === 0n
1429
1439
  );
1430
1440
  if (y !== -1) {
1431
- if (d += 1, !c && d > Do)
1441
+ if (h += 1, !c && h > jo)
1432
1442
  throw new Dt(
1433
- `Vault ${o[y]} is still not visible on-chain after ${d} reads — the registration does not exist.`
1443
+ `Vault ${o[y]} is still not visible on-chain after ${h} reads — the registration does not exist.`
1434
1444
  );
1435
1445
  console.warn(
1436
1446
  `Peg-in registration for vault ${o[y]} is not visible in chain state at block ${g} — a lagging RPC backend or an Ethereum reorg. Still polling.`
1437
1447
  ), u == null || u({ confirmations: 0, required: s });
1438
1448
  } else {
1439
- c = !0, d = 0, h = void 0;
1440
- let f = p[0], P = Ze({
1449
+ c = !0, h = 0, d = void 0;
1450
+ let f = p[0], m = et({
1441
1451
  currentBlock: g,
1442
1452
  createdAtBlock: p[0].createdAt
1443
1453
  });
1444
- for (const k of p.slice(1)) {
1445
- const x = Ze({
1454
+ for (const $ of p.slice(1)) {
1455
+ const x = et({
1446
1456
  currentBlock: g,
1447
- createdAtBlock: k.createdAt
1457
+ createdAtBlock: $.createdAt
1448
1458
  });
1449
- x < P && (P = x, f = k);
1459
+ x < m && (m = x, f = $);
1450
1460
  }
1451
- if (u == null || u({ confirmations: P, required: s }), P >= s)
1452
- return { confirmations: P, basicInfo: f };
1461
+ if (u == null || u({ confirmations: m, required: s }), m >= s)
1462
+ return { confirmations: m, basicInfo: f };
1453
1463
  }
1454
1464
  } catch (g) {
1455
- if (Mo(g))
1465
+ if (Wo(g))
1456
1466
  throw g;
1457
1467
  console.warn(
1458
1468
  `Registration-depth read failed (retrying in ${n}ms): ` + (g instanceof Error ? g.message : String(g))
1459
- ), h = g;
1469
+ ), d = g;
1460
1470
  }
1461
1471
  await new Promise((g, p) => {
1462
1472
  const y = () => {
@@ -1472,82 +1482,82 @@ async function on(e) {
1472
1482
  });
1473
1483
  }
1474
1484
  }
1475
- const Lo = /^(?:[0-9a-f]{2})*$/, Fo = /^[0-9a-f]{64}$/, Uo = /^([0-9a-f]{64}):(0|[1-9][0-9]*)$/, qo = -2147483648, Xo = 2147483647, xe = 4294967295, et = 2, tt = 2, le = 0;
1476
- class m extends Error {
1485
+ const Yo = /^(?:[0-9a-f]{2})*$/, Jo = /^[0-9a-f]{64}$/, Qo = /^([0-9a-f]{64}):(0|[1-9][0-9]*)$/, Zo = -2147483648, es = 2147483647, Ee = 4294967295, tt = 2, rt = 2, de = 0;
1486
+ class P extends Error {
1477
1487
  constructor(t) {
1478
1488
  super(t), this.name = "GraphFingerprintError";
1479
1489
  }
1480
1490
  }
1481
- function $(e, t, r) {
1491
+ function k(e, t, r) {
1482
1492
  const o = e[t];
1483
1493
  if (o === void 0)
1484
- throw new m(`Graph tx ${r} is missing "${t}"`);
1494
+ throw new P(`Graph tx ${r} is missing "${t}"`);
1485
1495
  return o;
1486
1496
  }
1487
- function Z(e, t) {
1497
+ function te(e, t) {
1488
1498
  if (!Array.isArray(e))
1489
- throw new m(`Graph tx ${t} is not an array`);
1499
+ throw new P(`Graph tx ${t} is not an array`);
1490
1500
  return e;
1491
1501
  }
1492
1502
  function B(e, t) {
1493
1503
  if (e === null || typeof e != "object" || Array.isArray(e))
1494
- throw new m(`Graph tx ${t} is not an object`);
1504
+ throw new P(`Graph tx ${t} is not an object`);
1495
1505
  return e;
1496
1506
  }
1497
- function W(e, t, r, o) {
1507
+ function J(e, t, r, o) {
1498
1508
  if (typeof e != "number" || !Number.isSafeInteger(e) || e < r || e > o)
1499
- throw new m(
1509
+ throw new P(
1500
1510
  `Graph tx ${t} is not an integer in [${r}, ${o}]`
1501
1511
  );
1502
1512
  return e;
1503
1513
  }
1504
- function Ee(e, t) {
1505
- if (typeof e != "string" || !Lo.test(e))
1506
- throw new m(
1514
+ function ke(e, t) {
1515
+ if (typeof e != "string" || !Yo.test(e))
1516
+ throw new P(
1507
1517
  `Graph tx ${t} is not lowercase hex without a prefix`
1508
1518
  );
1509
1519
  return H.from(e, "hex");
1510
1520
  }
1511
- function de(e, t) {
1512
- if (typeof e != "string" || !Fo.test(e))
1513
- throw new m(
1521
+ function he(e, t) {
1522
+ if (typeof e != "string" || !Jo.test(e))
1523
+ throw new P(
1514
1524
  `Graph ${t} is not 32 bytes of lowercase hex`
1515
1525
  );
1516
1526
  return e;
1517
1527
  }
1518
- function rt(e, t) {
1528
+ function ot(e, t) {
1519
1529
  const r = B(e, t), o = new S();
1520
- return o.version = W(
1521
- $(r, "version", t),
1530
+ return o.version = J(
1531
+ k(r, "version", t),
1522
1532
  `${t}.version`,
1523
- qo,
1524
- Xo
1525
- ), o.locktime = W(
1526
- $(r, "lock_time", t),
1533
+ Zo,
1534
+ es
1535
+ ), o.locktime = J(
1536
+ k(r, "lock_time", t),
1527
1537
  `${t}.lock_time`,
1528
1538
  0,
1529
- xe
1530
- ), Z($(r, "input", t), `${t}.input`).forEach((s, n) => {
1531
- const a = `${t}.input[${n}]`, i = B(s, a), u = $(i, "previous_output", a), l = typeof u == "string" && Uo.exec(u);
1539
+ Ee
1540
+ ), te(k(r, "input", t), `${t}.input`).forEach((s, n) => {
1541
+ const a = `${t}.input[${n}]`, i = B(s, a), u = k(i, "previous_output", a), l = typeof u == "string" && Qo.exec(u);
1532
1542
  if (!l)
1533
- throw new m(
1543
+ throw new P(
1534
1544
  `Graph tx ${a}.previous_output is not "<txid>:<vout>"`
1535
1545
  );
1536
- const c = W(Number(l[2]), `${a}.previous_output vout`, 0, xe);
1546
+ const c = J(Number(l[2]), `${a}.previous_output vout`, 0, Ee);
1537
1547
  o.addInput(
1538
1548
  H.from(l[1], "hex").reverse(),
1539
1549
  c,
1540
- W($(i, "sequence", a), `${a}.sequence`, 0, xe),
1541
- Ee($(i, "script_sig", a), `${a}.script_sig`)
1542
- ), o.ins[n].witness = Z(
1543
- $(i, "witness", a),
1550
+ J(k(i, "sequence", a), `${a}.sequence`, 0, Ee),
1551
+ ke(k(i, "script_sig", a), `${a}.script_sig`)
1552
+ ), o.ins[n].witness = te(
1553
+ k(i, "witness", a),
1544
1554
  `${a}.witness`
1545
- ).map((d, h) => Ee(d, `${a}.witness[${h}]`));
1546
- }), Z($(r, "output", t), `${t}.output`).forEach((s, n) => {
1555
+ ).map((h, d) => ke(h, `${a}.witness[${d}]`));
1556
+ }), te(k(r, "output", t), `${t}.output`).forEach((s, n) => {
1547
1557
  const a = `${t}.output[${n}]`, i = B(s, a);
1548
1558
  o.addOutput(
1549
- Ee($(i, "script_pubkey", a), `${a}.script_pubkey`),
1550
- W($(i, "value", a), `${a}.value`, 0, Number.MAX_SAFE_INTEGER)
1559
+ ke(k(i, "script_pubkey", a), `${a}.script_pubkey`),
1560
+ J(k(i, "value", a), `${a}.value`, 0, Number.MAX_SAFE_INTEGER)
1551
1561
  );
1552
1562
  }), new Uint8Array(o.toBuffer());
1553
1563
  }
@@ -1557,17 +1567,17 @@ function D(e, t) {
1557
1567
  try {
1558
1568
  o = S.fromHex(r);
1559
1569
  } catch (s) {
1560
- throw new m(
1570
+ throw new P(
1561
1571
  `Presign ${t} is not one transaction: ${s instanceof Error ? s.message : String(s)}`
1562
1572
  );
1563
1573
  }
1564
1574
  if (o.toHex() !== r)
1565
- throw new m(
1575
+ throw new P(
1566
1576
  `Presign ${t} is not a canonical transaction encoding`
1567
1577
  );
1568
1578
  return o;
1569
1579
  }
1570
- function Lt(e, t) {
1580
+ function Mt(e, t) {
1571
1581
  const r = e.ins[t];
1572
1582
  if (r)
1573
1583
  return {
@@ -1576,31 +1586,31 @@ function Lt(e, t) {
1576
1586
  };
1577
1587
  }
1578
1588
  function Ft(e, t) {
1579
- if (!e.outs[le])
1580
- throw new m(
1581
- `Presign ${t}.claim_tx must have output ${le}`
1589
+ if (!e.outs[de])
1590
+ throw new P(
1591
+ `Presign ${t}.claim_tx must have output ${de}`
1582
1592
  );
1583
1593
  }
1584
- function Go(e, t, r) {
1594
+ function ts(e, t, r) {
1585
1595
  if (e.ins.length !== 1)
1586
- throw new m(
1596
+ throw new P(
1587
1597
  `Presign ${r}.claim_tx must have exactly one input, got ${e.ins.length}`
1588
1598
  );
1589
1599
  Ft(e, r);
1590
- const o = Lt(e, 0);
1600
+ const o = Mt(e, 0);
1591
1601
  if ((o == null ? void 0 : o.txid) !== t || o.vout !== X) {
1592
1602
  const s = o ? `${o.txid}:${o.vout}` : "no input";
1593
- throw new m(
1603
+ throw new P(
1594
1604
  `Presign ${r}.claim_tx must spend ${t}:${X}, got ${s}`
1595
1605
  );
1596
1606
  }
1597
1607
  }
1598
- function He(e, t, r) {
1599
- const o = Lt(e, 0);
1600
- if ((o == null ? void 0 : o.txid) !== t || o.vout !== le) {
1608
+ function Oe(e, t, r) {
1609
+ const o = Mt(e, 0);
1610
+ if ((o == null ? void 0 : o.txid) !== t || o.vout !== de) {
1601
1611
  const s = o ? `${o.txid}:${o.vout}` : "no input";
1602
- throw new m(
1603
- `Presign ${r}.assert_tx input 0 must spend ${t}:${le}, got ${s}`
1612
+ throw new P(
1613
+ `Presign ${r}.assert_tx input 0 must spend ${t}:${de}, got ${s}`
1604
1614
  );
1605
1615
  }
1606
1616
  }
@@ -1608,36 +1618,36 @@ function Ut(e) {
1608
1618
  const t = D(e.peginTxHex, `${e.path}.pegin_tx`), r = D(e.claimTxHex, `${e.path}.claim_tx`), o = D(e.assertTxHex, `${e.path}.assert_tx`);
1609
1619
  return { peginTx: t, claimTx: r, assertTx: o };
1610
1620
  }
1611
- function zo(e) {
1621
+ function rs(e) {
1612
1622
  const t = D(e.claimTxHex, `${e.path}.claim_tx`), r = D(e.assertTxHex, `${e.path}.assert_tx`);
1613
- Ft(t, e.path), He(r, t.getId(), e.path);
1623
+ Ft(t, e.path), Oe(r, t.getId(), e.path);
1614
1624
  }
1615
- function jo(e) {
1625
+ function os(e) {
1616
1626
  const { peginTx: t, claimTx: r, assertTx: o } = Ut(e);
1617
- Go(r, t.getId(), e.path), He(o, r.getId(), e.path);
1627
+ ts(r, t.getId(), e.path), Oe(o, r.getId(), e.path);
1618
1628
  }
1619
- function Wo(e, t) {
1629
+ function ss(e, t) {
1620
1630
  const [r, ...o] = e.ins;
1621
1631
  if (!r || o.length > 0)
1622
- throw new m(
1632
+ throw new P(
1623
1633
  `Presign claim_tx must have exactly one input, got ${e.ins.length}`
1624
1634
  );
1625
1635
  const s = H.from(r.hash).reverse().toString("hex");
1626
1636
  if (s !== t || r.index !== X)
1627
- throw new m(
1637
+ throw new P(
1628
1638
  `Presign claim_tx must spend ${t}:${X}, got ${s}:${r.index}`
1629
1639
  );
1630
- if (e.version !== et)
1631
- throw new m(
1632
- `Presign claim_tx version must be ${et}, got ${e.version}`
1640
+ if (e.version !== tt)
1641
+ throw new P(
1642
+ `Presign claim_tx version must be ${tt}, got ${e.version}`
1633
1643
  );
1634
1644
  if (r.witness.length > 0)
1635
- throw new m(
1645
+ throw new P(
1636
1646
  `Presign claim_tx input must have an empty witness, got ${r.witness.length} item(s)`
1637
1647
  );
1638
- if (e.outs.length !== tt)
1639
- throw new m(
1640
- `Presign claim_tx must have exactly ${tt} outputs, got ${e.outs.length}`
1648
+ if (e.outs.length !== rt)
1649
+ throw new P(
1650
+ `Presign claim_tx must have exactly ${rt} outputs, got ${e.outs.length}`
1641
1651
  );
1642
1652
  }
1643
1653
  function qt(e) {
@@ -1645,15 +1655,15 @@ function qt(e) {
1645
1655
  (o, s) => o.pubkey < s.pubkey ? -1 : o.pubkey > s.pubkey ? 1 : 0
1646
1656
  ), r = [e.peginTx, e.claimTx, e.assertTx, e.payoutTx];
1647
1657
  return t.forEach((o, s) => {
1648
- const n = de(o.pubkey, "challenger pubkey");
1658
+ const n = he(o.pubkey, "challenger pubkey");
1649
1659
  if (s > 0 && t[s - 1].pubkey === n)
1650
- throw new m(`Graph lists challenger ${n} twice`);
1651
- r.push(je(n), o.nopayoutTx);
1660
+ throw new P(`Graph lists challenger ${n} twice`);
1661
+ r.push(We(n), o.nopayoutTx);
1652
1662
  for (const a of o.outputLabelHashes)
1653
- r.push(je(de(a, "output_label_hashes entry")));
1654
- }), Kr(Hr(Or(...r)));
1663
+ r.push(We(he(a, "output_label_hashes entry")));
1664
+ }), Mr(Fr(Ur(...r)));
1655
1665
  }
1656
- function Yo(e) {
1666
+ function ns(e) {
1657
1667
  const t = b(e.peginTxid).toLowerCase(), { peginTx: r, claimTx: o, assertTx: s } = Ut({
1658
1668
  peginTxHex: e.peginTxHex,
1659
1669
  claimTxHex: e.claimTxHex,
@@ -1661,10 +1671,10 @@ function Yo(e) {
1661
1671
  path: "depositor_graph"
1662
1672
  });
1663
1673
  if (r.getId() !== t)
1664
- throw new m(
1674
+ throw new P(
1665
1675
  `Presign pegin_tx hashes to ${r.getId()}, expected ${t}`
1666
1676
  );
1667
- Wo(o, t), He(s, o.getId(), "depositor_graph");
1677
+ ss(o, t), Oe(s, o.getId(), "depositor_graph");
1668
1678
  const n = (a) => new Uint8Array(a.toBuffer());
1669
1679
  return qt({
1670
1680
  peginTx: n(r),
@@ -1680,9 +1690,9 @@ function Yo(e) {
1680
1690
  }))
1681
1691
  });
1682
1692
  }
1683
- function Qo(e) {
1684
- const t = (o) => rt(B($(e, o, "graph"), o).tx, o), r = B(
1685
- $(e, "challenger_subgraphs", "graph"),
1693
+ function is(e) {
1694
+ const t = (o) => ot(B(k(e, o, "graph"), o).tx, o), r = B(
1695
+ k(e, "challenger_subgraphs", "graph"),
1686
1696
  "challenger_subgraphs"
1687
1697
  );
1688
1698
  return qt({
@@ -1694,104 +1704,185 @@ function Qo(e) {
1694
1704
  const n = `challenger_subgraphs[${o}]`, a = B(s, n);
1695
1705
  return {
1696
1706
  pubkey: o,
1697
- nopayoutTx: rt(
1698
- B($(a, "nopayout_tx", n), `${n}.nopayout_tx`).tx,
1707
+ nopayoutTx: ot(
1708
+ B(k(a, "nopayout_tx", n), `${n}.nopayout_tx`).tx,
1699
1709
  `${n}.nopayout_tx`
1700
1710
  ),
1701
- outputLabelHashes: Z(
1702
- $(a, "output_label_hashes", n),
1711
+ outputLabelHashes: te(
1712
+ k(a, "output_label_hashes", n),
1703
1713
  `${n}.output_label_hashes`
1704
1714
  ).map(
1705
- (i, u) => de(i, `${n}.output_label_hashes[${u}]`)
1715
+ (i, u) => he(i, `${n}.output_label_hashes[${u}]`)
1706
1716
  )
1707
1717
  };
1708
1718
  })
1709
1719
  });
1710
1720
  }
1711
- function Jo(e) {
1721
+ function as(e) {
1712
1722
  const t = B(
1713
- $(e, "challenger_pubkeys", "graph"),
1723
+ k(e, "challenger_pubkeys", "graph"),
1714
1724
  "challenger_pubkeys"
1715
1725
  ), r = /* @__PURE__ */ new Set();
1716
1726
  for (const o of ["local", "universal"])
1717
- Z(
1718
- $(t, o, "challenger_pubkeys"),
1727
+ te(
1728
+ k(t, o, "challenger_pubkeys"),
1719
1729
  `challenger_pubkeys.${o}`
1720
1730
  ).forEach((s, n) => {
1721
- const a = de(s, `challenger_pubkeys.${o}[${n}]`);
1731
+ const a = he(s, `challenger_pubkeys.${o}[${n}]`);
1722
1732
  if (r.has(a))
1723
- throw new m(
1733
+ throw new P(
1724
1734
  `Graph declares challenger ${a} more than once`
1725
1735
  );
1726
1736
  r.add(a);
1727
1737
  });
1728
1738
  return r;
1729
1739
  }
1730
- function sn(e, t) {
1731
- const r = Qo(e);
1740
+ function fn(e, t) {
1741
+ const r = is(e);
1732
1742
  if (r !== t)
1733
- throw new m(
1743
+ throw new P(
1734
1744
  `Graph fingerprint ${r} does not match the presign fingerprint ${t}`
1735
1745
  );
1736
1746
  const o = Object.keys(
1737
1747
  B(e.challenger_subgraphs, "challenger_subgraphs")
1738
- ), s = Jo(e);
1748
+ ), s = as(e);
1739
1749
  if (o.length !== s.size || o.some((n) => !s.has(n)))
1740
- throw new m(
1750
+ throw new P(
1741
1751
  `Graph challenger_subgraphs keys ${o.join(", ")} do not match challenger_pubkeys ${[...s].join(", ")}`
1742
1752
  );
1743
1753
  }
1744
- const Zo = 1;
1745
- function es(e, t, r) {
1754
+ const us = 1;
1755
+ function cs(e, t, r) {
1746
1756
  const o = r.map(
1747
- (d) => b(d).toLowerCase()
1748
- ), s = t.filter((d) => o.includes(d));
1757
+ (h) => b(h).toLowerCase()
1758
+ ), s = t.filter((h) => o.includes(h));
1749
1759
  if (s.length > 0)
1750
1760
  throw new Error(
1751
1761
  `Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
1752
1762
  );
1753
1763
  const n = [...t, ...o], a = e.map(
1754
- (d) => b(d.challenger_pubkey).toLowerCase()
1764
+ (h) => b(h.challenger_pubkey).toLowerCase()
1755
1765
  ), i = new Set(a);
1756
1766
  if (i.size !== a.length)
1757
1767
  throw new Error(
1758
1768
  "Depositor graph contains duplicate challenger entries in challenger_presign_data"
1759
1769
  );
1760
- const u = new Set(n), l = n.filter((d) => !i.has(d)), c = a.filter((d) => !u.has(d));
1770
+ const u = new Set(n), l = n.filter((h) => !i.has(h)), c = a.filter((h) => !u.has(h));
1761
1771
  if (l.length > 0 || c.length > 0)
1762
1772
  throw new Error(
1763
1773
  "Depositor graph challenger set does not match expected (local ∪ universal)" + (l.length > 0 ? ` (missing: ${l.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
1764
1774
  );
1775
+ return or(n);
1765
1776
  }
1766
- function ts(e, t) {
1767
- const r = e.ins[t];
1768
- return Ie(new Uint8Array(r.hash).slice().reverse());
1769
- }
1770
- function $e(e, t, r, o, s) {
1771
- const n = e.ins[t];
1772
- if (n.index !== 0)
1773
- throw new Error(
1774
- `NoPayout (challenger ${s}) input ${t} expected to spend ${o} vout 0, got vout ${n.index}`
1775
- );
1776
- const a = r.getId(), i = ts(e, t);
1777
- if (i !== a)
1777
+ function ls(e, t, r) {
1778
+ const o = r >= Ar ? 1 : 0, s = _r + Sr * t + o;
1779
+ if (e.outs.length !== s)
1778
1780
  throw new Error(
1779
- `NoPayout (challenger ${s}) input ${t} does not reference ${o} (expected txid ${a}, got ${i})`
1781
+ `Assert must have ${s} outputs for ${t} challengers (vault core version ${r}), got ${e.outs.length}`
1780
1782
  );
1781
1783
  }
1782
- async function rs(e, t, r) {
1783
- const o = [], s = [], n = [], a = mt({
1784
- claimerBtcPubkey: r.depositorBtcPubkey,
1785
- depositorBtcPubkey: r.depositorBtcPubkey,
1786
- vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
1787
- vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys
1788
- });
1789
- es(
1784
+ async function Gt(e, t) {
1785
+ const r = wt({
1786
+ claimerBtcPubkey: t.depositorBtcPubkey,
1787
+ depositorBtcPubkey: t.depositorBtcPubkey,
1788
+ vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
1789
+ vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys
1790
+ }), o = cs(
1790
1791
  e.challenger_presign_data,
1791
- a,
1792
- r.universalChallengerBtcPubkeys
1792
+ r,
1793
+ t.universalChallengerBtcPubkeys
1794
+ ), s = b(t.depositorBtcPubkey), n = S.fromHex(
1795
+ b(e.assert_tx.tx_hex)
1796
+ );
1797
+ ls(
1798
+ n,
1799
+ o.length,
1800
+ t.vaultCoreVersion
1801
+ );
1802
+ const a = [];
1803
+ for (const i of e.challenger_presign_data) {
1804
+ const u = b(i.challenger_pubkey), l = o.indexOf(
1805
+ u.toLowerCase()
1806
+ ), c = await ds({
1807
+ challenger: i,
1808
+ challengerPubkey: u,
1809
+ challengerIndex: l,
1810
+ challengerCount: o.length,
1811
+ claimerPubkey: s,
1812
+ assertTx: n,
1813
+ ctx: t
1814
+ });
1815
+ a.push({ challenger: i, challengerPubkey: u, prevouts: c });
1816
+ }
1817
+ return { localChallengers: r, noPayouts: a };
1818
+ }
1819
+ async function ds(e) {
1820
+ const {
1821
+ challenger: t,
1822
+ challengerPubkey: r,
1823
+ challengerIndex: o,
1824
+ challengerCount: s,
1825
+ claimerPubkey: n,
1826
+ assertTx: a,
1827
+ ctx: i
1828
+ } = e;
1829
+ Gr(
1830
+ t.nopayout_tx.tx_hex,
1831
+ r,
1832
+ i.network
1793
1833
  );
1794
- const i = await Tr({
1834
+ const u = S.fromHex(
1835
+ b(t.nopayout_tx.tx_hex)
1836
+ ), l = S.fromHex(
1837
+ b(t.challenge_assert_x_tx.tx_hex)
1838
+ ), c = S.fromHex(
1839
+ b(t.challenge_assert_y_tx.tx_hex)
1840
+ ), h = await br({
1841
+ txGraphVersion: i.vaultCoreVersion,
1842
+ claimer: n,
1843
+ challenger: r,
1844
+ timelockChallengeAssert: i.timelockChallengeAssert,
1845
+ outputLabelHashes: t.output_label_hashes.map(
1846
+ (g) => g.toLowerCase()
1847
+ ),
1848
+ network: i.network
1849
+ });
1850
+ for (const [g, p] of [
1851
+ ["X", l],
1852
+ ["Y", c]
1853
+ ])
1854
+ Xr({
1855
+ challengeAssertTx: p,
1856
+ assertTx: a,
1857
+ half: g,
1858
+ challengerIndex: o,
1859
+ challengerCount: s,
1860
+ challengerPubkey: r,
1861
+ outputConnectorScriptPubKey: h
1862
+ });
1863
+ const d = [
1864
+ a.outs[G],
1865
+ l.outs[Xe],
1866
+ c.outs[Xe]
1867
+ ];
1868
+ return zr({
1869
+ noPayoutTx: u,
1870
+ assertTxid: a.getId(),
1871
+ challengeAssertXTxid: l.getId(),
1872
+ challengeAssertYTxid: c.getId(),
1873
+ timelockChallengeAssert: i.timelockChallengeAssert,
1874
+ prevoutValues: [
1875
+ d[0].value,
1876
+ d[1].value,
1877
+ d[2].value
1878
+ ]
1879
+ }), d.map((g) => ({
1880
+ script_pubkey: yt(new Uint8Array(g.script)),
1881
+ value: g.value
1882
+ }));
1883
+ }
1884
+ async function hs(e, t, r) {
1885
+ const o = [], s = [], n = [], { localChallengers: a, noPayouts: i } = await Gt(e, r), u = await Vr({
1795
1886
  vaultCoreVersion: r.vaultCoreVersion,
1796
1887
  vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
1797
1888
  vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
@@ -1807,115 +1898,52 @@ async function rs(e, t, r) {
1807
1898
  network: r.network,
1808
1899
  claimerBtcPubkey: r.depositorBtcPubkey,
1809
1900
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
1810
- commissionBps: Zo,
1901
+ commissionBps: us,
1811
1902
  protocolFeeRate: r.protocolFeeRate,
1812
1903
  councilMembers: r.councilMembers,
1813
1904
  councilQuorum: r.councilQuorum
1814
1905
  });
1815
- o.push(i.psbtHex), s.push(
1816
- ue(
1906
+ o.push(u.psbtHex), s.push(
1907
+ ce(
1817
1908
  t,
1818
- Xe
1909
+ Ge
1819
1910
  )
1820
1911
  );
1821
- const u = b(r.depositorBtcPubkey), l = S.fromHex(
1822
- b(e.assert_tx.tx_hex)
1823
- );
1824
- for (const c of e.challenger_presign_data) {
1825
- const d = b(c.challenger_pubkey), h = o.length, g = await os({
1826
- challenger: c,
1827
- challengerPubkey: d,
1828
- claimerPubkey: u,
1829
- localChallengers: a,
1830
- assertTxParsed: l,
1831
- ctx: r
1912
+ const l = b(r.depositorBtcPubkey);
1913
+ for (const { challenger: c, challengerPubkey: h, prevouts: d } of i) {
1914
+ const g = o.length, p = await qr({
1915
+ noPayoutTxHex: c.nopayout_tx.tx_hex,
1916
+ challengerPubkey: h,
1917
+ prevouts: d,
1918
+ connectorParams: {
1919
+ txGraphVersion: r.vaultCoreVersion,
1920
+ claimer: l,
1921
+ localChallengers: a,
1922
+ universalChallengers: r.universalChallengerBtcPubkeys,
1923
+ timelockAssert: r.timelockAssert,
1924
+ councilMembers: r.councilMembers,
1925
+ councilQuorum: r.councilQuorum
1926
+ }
1832
1927
  });
1833
- o.push(g), s.push(
1834
- ue(
1928
+ o.push(p), s.push(
1929
+ ce(
1835
1930
  t,
1836
- Xe
1931
+ Ge
1837
1932
  )
1838
1933
  ), n.push({
1839
- challengerPubkey: d,
1840
- noPayoutIdx: h
1934
+ challengerPubkey: h,
1935
+ noPayoutIdx: g
1841
1936
  });
1842
1937
  }
1843
1938
  return { psbtHexes: o, signOptions: s, challengerEntries: n };
1844
1939
  }
1845
- async function os(e) {
1846
- const {
1847
- challenger: t,
1848
- challengerPubkey: r,
1849
- claimerPubkey: o,
1850
- localChallengers: s,
1851
- assertTxParsed: n,
1852
- ctx: a
1853
- } = e;
1854
- Nr(
1855
- t.nopayout_tx.tx_hex,
1856
- r,
1857
- a.network
1858
- );
1859
- const i = S.fromHex(
1860
- b(t.nopayout_tx.tx_hex)
1861
- ), u = S.fromHex(
1862
- b(t.challenge_assert_x_tx.tx_hex)
1863
- ), l = S.fromHex(
1864
- b(t.challenge_assert_y_tx.tx_hex)
1865
- );
1866
- if (i.ins.length !== 3)
1867
- throw new Error(
1868
- `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
1869
- );
1870
- $e(
1871
- i,
1872
- 0,
1873
- n,
1874
- "Assert",
1875
- r
1876
- ), $e(
1877
- i,
1878
- 1,
1879
- u,
1880
- "ChallengeAssertX",
1881
- r
1882
- ), $e(
1883
- i,
1884
- 2,
1885
- l,
1886
- "ChallengeAssertY",
1887
- r
1888
- );
1889
- const c = [
1890
- n.outs[0],
1891
- u.outs[0],
1892
- l.outs[0]
1893
- ].map((d) => ({
1894
- script_pubkey: Ie(new Uint8Array(d.script)),
1895
- value: d.value
1896
- }));
1897
- return Dr({
1898
- noPayoutTxHex: t.nopayout_tx.tx_hex,
1899
- challengerPubkey: r,
1900
- prevouts: c,
1901
- connectorParams: {
1902
- txGraphVersion: a.vaultCoreVersion,
1903
- claimer: o,
1904
- localChallengers: s,
1905
- universalChallengers: a.universalChallengerBtcPubkeys,
1906
- timelockAssert: a.timelockAssert,
1907
- councilMembers: a.councilMembers,
1908
- councilQuorum: a.councilQuorum
1909
- }
1910
- });
1911
- }
1912
- function ss(e, t, r) {
1913
- ie(e[0]);
1914
- const s = ae(
1940
+ function ps(e, t, r) {
1941
+ ae(e[0]);
1942
+ const s = ue(
1915
1943
  e[0].returnedPsbtHex,
1916
1944
  r
1917
1945
  );
1918
- re({
1946
+ oe({
1919
1947
  requestedPsbtHex: e[0].requestedPsbtHex,
1920
1948
  signatureHex: s,
1921
1949
  signerXOnlyPubkeyHex: r,
@@ -1923,12 +1951,12 @@ function ss(e, t, r) {
1923
1951
  });
1924
1952
  const n = {};
1925
1953
  for (const a of t) {
1926
- ie(e[a.noPayoutIdx]);
1927
- const i = ae(
1954
+ ae(e[a.noPayoutIdx]);
1955
+ const i = ue(
1928
1956
  e[a.noPayoutIdx].returnedPsbtHex,
1929
1957
  r
1930
1958
  );
1931
- re({
1959
+ oe({
1932
1960
  requestedPsbtHex: e[a.noPayoutIdx].requestedPsbtHex,
1933
1961
  signatureHex: i,
1934
1962
  signerXOnlyPubkeyHex: r,
@@ -1944,36 +1972,36 @@ function ss(e, t, r) {
1944
1972
  per_challenger: n
1945
1973
  };
1946
1974
  }
1947
- async function ns(e) {
1975
+ async function gs(e) {
1948
1976
  const { depositorGraph: t, btcWallet: r, signingContext: o } = e;
1949
- jo({
1977
+ os({
1950
1978
  peginTxHex: o.peginTxHex,
1951
1979
  claimTxHex: t.claim_tx.tx_hex,
1952
1980
  assertTxHex: t.assert_tx.tx_hex,
1953
1981
  path: "depositor_graph"
1954
1982
  });
1955
- const s = await r.getPublicKeyHex(), { depositorPubkey: n } = tr(
1983
+ const s = await r.getPublicKeyHex(), { depositorPubkey: n } = rr(
1956
1984
  s,
1957
1985
  b(o.depositorBtcPubkey)
1958
- ), { psbtHexes: a, signOptions: i, challengerEntries: u } = await rs(
1986
+ ), { psbtHexes: a, signOptions: i, challengerEntries: u } = await hs(
1959
1987
  t,
1960
1988
  s,
1961
1989
  o
1962
- ), l = await vt(
1990
+ ), l = await bt(
1963
1991
  r,
1964
1992
  a,
1965
1993
  i
1966
- ), c = a.map((d, h) => ({
1967
- requestedPsbtHex: d,
1968
- returnedPsbtHex: l[h]
1994
+ ), c = a.map((h, d) => ({
1995
+ requestedPsbtHex: h,
1996
+ returnedPsbtHex: l[d]
1969
1997
  }));
1970
- return ss(
1998
+ return ps(
1971
1999
  c,
1972
2000
  u,
1973
2001
  n
1974
2002
  );
1975
2003
  }
1976
- const is = 1e4, L = 10;
2004
+ const fs = 1e4, M = 10;
1977
2005
  async function Xt(e) {
1978
2006
  const {
1979
2007
  statusReader: t,
@@ -1981,26 +2009,26 @@ async function Xt(e) {
1981
2009
  peginTxid: o,
1982
2010
  targetStatuses: s,
1983
2011
  timeoutMs: n,
1984
- pollIntervalMs: a = is,
2012
+ pollIntervalMs: a = fs,
1985
2013
  signal: i
1986
2014
  } = e, u = Date.now();
1987
2015
  for (; ; ) {
1988
2016
  if (i != null && i.aborted)
1989
2017
  throw new Error(
1990
- `Polling aborted for vault ${r.slice(0, L)}… (target: ${[...s].join(", ")})`
2018
+ `Polling aborted for vault ${r.slice(0, M)}… (target: ${[...s].join(", ")})`
1991
2019
  );
1992
2020
  if (Date.now() - u >= n)
1993
2021
  throw new Error(
1994
- `Polling timeout after ${n}ms for vault ${r.slice(0, L)}… (target: ${[...s].join(", ")})`
2022
+ `Polling timeout after ${n}ms for vault ${r.slice(0, M)}… (target: ${[...s].join(", ")})`
1995
2023
  );
1996
2024
  try {
1997
2025
  const l = await t.getPeginStatusByVaultId(
1998
2026
  { vault_id: r },
1999
2027
  i
2000
2028
  );
2001
- if (ze(l.vault_id) !== ze(r))
2029
+ if (je(l.vault_id) !== je(r))
2002
2030
  throw new Error(
2003
- `getPeginStatusByVaultId returned status for vault ${l.vault_id.slice(0, L)}…, requested ${r.slice(0, L)}…`
2031
+ `getPeginStatusByVaultId returned status for vault ${l.vault_id.slice(0, M)}…, requested ${r.slice(0, M)}…`
2004
2032
  );
2005
2033
  if (l.pegin_txid.toLowerCase() !== o.toLowerCase())
2006
2034
  throw new Error(
@@ -2009,48 +2037,48 @@ async function Xt(e) {
2009
2037
  const c = l.status;
2010
2038
  if (s.has(c) || c === R.ACTIVATED)
2011
2039
  return c;
2012
- if (c === R.EXPIRED || Ir.has(c))
2040
+ if (c === R.EXPIRED || Nr.has(c))
2013
2041
  throw new Error(
2014
- `Vault ${r.slice(0, L)}… reached terminal status "${c}" while waiting for ${[...s].join(", ")}`
2042
+ `Vault ${r.slice(0, M)}… reached terminal status "${c}" while waiting for ${[...s].join(", ")}`
2015
2043
  );
2016
2044
  } catch (l) {
2017
- if (!(l instanceof Vr && l.code === Rr.PEGIN_NOT_FOUND))
2045
+ if (!(l instanceof Dr && l.code === Lr.PEGIN_NOT_FOUND))
2018
2046
  throw l;
2019
2047
  }
2020
2048
  await new Promise((l, c) => {
2021
- const d = () => {
2022
- clearTimeout(h), c(
2049
+ const h = () => {
2050
+ clearTimeout(d), c(
2023
2051
  new Error(
2024
- `Polling aborted for vault ${r.slice(0, L)}… (target: ${[...s].join(", ")})`
2052
+ `Polling aborted for vault ${r.slice(0, M)}… (target: ${[...s].join(", ")})`
2025
2053
  )
2026
2054
  );
2027
- }, h = setTimeout(() => {
2028
- i == null || i.removeEventListener("abort", d), l();
2055
+ }, d = setTimeout(() => {
2056
+ i == null || i.removeEventListener("abort", h), l();
2029
2057
  }, a);
2030
- i == null || i.addEventListener("abort", d, { once: !0 });
2058
+ i == null || i.addEventListener("abort", h, { once: !0 });
2031
2059
  });
2032
2060
  }
2033
2061
  }
2034
- const as = 1200 * 1e3, Gt = /* @__PURE__ */ new Set([
2062
+ const ys = 1200 * 1e3, zt = /* @__PURE__ */ new Set([
2035
2063
  R.PENDING_ACKS,
2036
2064
  R.PENDING_ACTIVATION,
2037
2065
  R.ACTIVATED_PENDING_BROADCAST,
2038
2066
  R.ACTIVATED
2039
- ]), us = /* @__PURE__ */ new Set([
2067
+ ]), vs = /* @__PURE__ */ new Set([
2040
2068
  R.PENDING_DEPOSITOR_SIGNATURES,
2041
- ...Gt
2069
+ ...zt
2042
2070
  ]);
2043
- function cs(e) {
2071
+ function bs(e) {
2044
2072
  return e.map((t) => ({
2045
- claimerPubkeyXOnly: he(t.claimer_pubkey),
2073
+ claimerPubkeyXOnly: pe(t.claimer_pubkey),
2046
2074
  payoutTxHex: t.payout_tx.tx_hex,
2047
2075
  assertTxHex: t.assert_tx.tx_hex
2048
2076
  }));
2049
2077
  }
2050
2078
  function I(e) {
2051
- return he(e).toLowerCase();
2079
+ return pe(e).toLowerCase();
2052
2080
  }
2053
- function ls(e, t) {
2081
+ function ms(e, t) {
2054
2082
  const r = (u, l, c) => {
2055
2083
  throw new Error(
2056
2084
  `Deposit terms ${u} (${String(l)}) does not match the vault's version-locked signing context (${String(c)}); refusing to sign payouts against terms that describe a different graph.`
@@ -2064,8 +2092,8 @@ function ls(e, t) {
2064
2092
  for (const [u, l, c] of o)
2065
2093
  l !== c && r(u, l, c);
2066
2094
  const s = (u) => u.map(I).sort(), n = (u, l) => {
2067
- const c = s(u), d = s(l);
2068
- return c.length === d.length && c.every((h, g) => h === d[g]);
2095
+ const c = s(u), h = s(l);
2096
+ return c.length === h.length && c.every((d, g) => d === h[g]);
2069
2097
  };
2070
2098
  n(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
2071
2099
  "vaultKeeperBtcPubkeys",
@@ -2088,7 +2116,7 @@ function ls(e, t) {
2088
2116
  t.vaultProviderBtcPubkey
2089
2117
  );
2090
2118
  }
2091
- function ds(e, t, r, o) {
2119
+ function Ps(e, t, r, o) {
2092
2120
  const s = I(o), n = [
2093
2121
  I(t),
2094
2122
  ...r.map(I)
@@ -2102,17 +2130,17 @@ function ds(e, t, r, o) {
2102
2130
  "Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
2103
2131
  );
2104
2132
  const i = e.map(
2105
- (h) => I(h.claimer_pubkey)
2133
+ (d) => I(d.claimer_pubkey)
2106
2134
  );
2107
2135
  if (new Set(i).size !== i.length)
2108
2136
  throw new Error("Presign response contains duplicate claimer entries");
2109
- const u = i.filter((h) => h !== s), l = new Set(u), c = n.filter((h) => !l.has(h)), d = u.filter((h) => !a.has(h));
2110
- if (c.length > 0 || d.length > 0)
2137
+ const u = i.filter((d) => d !== s), l = new Set(u), c = n.filter((d) => !l.has(d)), h = u.filter((d) => !a.has(d));
2138
+ if (c.length > 0 || h.length > 0)
2111
2139
  throw new Error(
2112
- "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (c.length > 0 ? ` (missing: ${c.join(", ")})` : "") + (d.length > 0 ? ` (unexpected: ${d.join(", ")})` : "")
2140
+ "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (c.length > 0 ? ` (missing: ${c.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
2113
2141
  );
2114
2142
  }
2115
- function ot(e, t) {
2143
+ function st(e, t) {
2116
2144
  return {
2117
2145
  vaultCoreVersion: t.vaultCoreVersion,
2118
2146
  payoutTxHex: e.payoutTxHex,
@@ -2134,8 +2162,8 @@ function ot(e, t) {
2134
2162
  vpCommissionScriptPubKey: t.vpCommissionScriptPubKey
2135
2163
  };
2136
2164
  }
2137
- async function hs(e, t, r, o) {
2138
- const s = new or({
2165
+ async function ws(e, t, r, o) {
2166
+ const s = new nr({
2139
2167
  network: t.network,
2140
2168
  btcWallet: e
2141
2169
  }), n = r.length;
@@ -2143,14 +2171,14 @@ async function hs(e, t, r, o) {
2143
2171
  let a;
2144
2172
  if (s.supportsBatchSigning())
2145
2173
  a = (await s.signPayoutTransactionsBatch(
2146
- r.map((l) => ot(l, t))
2174
+ r.map((l) => st(l, t))
2147
2175
  )).map((l) => l.payoutSignature);
2148
2176
  else {
2149
2177
  a = [];
2150
2178
  for (let u = 0; u < r.length; u++) {
2151
2179
  o == null || o(u, n);
2152
2180
  const l = await s.signPayoutTransaction(
2153
- ot(r[u], t)
2181
+ st(r[u], t)
2154
2182
  );
2155
2183
  a.push(l.signature);
2156
2184
  }
@@ -2162,7 +2190,7 @@ async function hs(e, t, r, o) {
2162
2190
  };
2163
2191
  return o == null || o(n, n), i;
2164
2192
  }
2165
- async function nn(e) {
2193
+ async function yn(e) {
2166
2194
  const {
2167
2195
  statusReader: t,
2168
2196
  presignClient: r,
@@ -2172,22 +2200,22 @@ async function nn(e) {
2172
2200
  depositorPk: a,
2173
2201
  signingContext: i,
2174
2202
  depositTerms: u,
2175
- timeoutMs: l = as,
2203
+ timeoutMs: l = ys,
2176
2204
  signal: c,
2177
- onProgress: d,
2178
- recordGraphFingerprint: h
2205
+ onProgress: h,
2206
+ recordGraphFingerprint: d
2179
2207
  } = e, g = await Xt({
2180
2208
  statusReader: t,
2181
2209
  vaultId: s,
2182
2210
  peginTxid: n,
2183
- targetStatuses: us,
2211
+ targetStatuses: vs,
2184
2212
  timeoutMs: l,
2185
2213
  signal: c
2186
2214
  });
2187
- if (Gt.has(g))
2215
+ if (zt.has(g))
2188
2216
  return;
2189
- c == null || c.throwIfAborted(), u !== void 0 && ls(u, i);
2190
- const p = yt(o) ? o : void 0;
2217
+ c == null || c.throwIfAborted(), u !== void 0 && ms(u, i);
2218
+ const p = vt(o) ? o : void 0;
2191
2219
  let y;
2192
2220
  if (p) {
2193
2221
  if (!u)
@@ -2203,76 +2231,82 @@ async function nn(e) {
2203
2231
  },
2204
2232
  c
2205
2233
  );
2206
- c == null || c.throwIfAborted(), f.txs.forEach((O, oe) => {
2207
- zo({
2234
+ c == null || c.throwIfAborted(), f.txs.forEach((O, se) => {
2235
+ rs({
2208
2236
  claimTxHex: O.claim_tx.tx_hex,
2209
2237
  assertTxHex: O.assert_tx.tx_hex,
2210
- path: `txs[${oe}]`
2238
+ path: `txs[${se}]`
2211
2239
  });
2212
2240
  });
2213
- const P = Yo({
2241
+ const m = ns({
2214
2242
  peginTxid: n,
2215
2243
  peginTxHex: i.peginTxHex,
2216
2244
  claimTxHex: f.depositor_graph.claim_tx.tx_hex,
2217
2245
  assertTxHex: f.depositor_graph.assert_tx.tx_hex,
2218
2246
  payoutTxHex: f.depositor_graph.payout_tx.tx_hex,
2219
2247
  challengers: f.depositor_graph.challenger_presign_data
2220
- }), k = I(a);
2221
- ds(
2248
+ }), $ = {
2249
+ vaultCoreVersion: i.vaultCoreVersion,
2250
+ peginTxHex: i.peginTxHex,
2251
+ depositorBtcPubkey: a,
2252
+ vaultProviderBtcPubkey: i.vaultProviderBtcPubkey,
2253
+ vaultKeeperBtcPubkeys: i.vaultKeeperBtcPubkeys,
2254
+ universalChallengerBtcPubkeys: i.universalChallengerBtcPubkeys,
2255
+ timelockPegin: i.timelockPegin,
2256
+ timelockAssert: i.timelockAssert,
2257
+ timelockChallengeAssert: i.timelockChallengeAssert,
2258
+ councilMembers: i.councilMembers,
2259
+ councilQuorum: i.councilQuorum,
2260
+ network: i.network,
2261
+ registeredPayoutScriptPubKey: i.registeredPayoutScriptPubKey,
2262
+ protocolFeeRate: i.protocolFeeRate,
2263
+ vkClaimerPayoutScriptPubKeys: i.vkClaimerPayoutScriptPubKeys,
2264
+ vpCommissionScriptPubKey: i.vpCommissionScriptPubKey
2265
+ };
2266
+ await Gt(
2267
+ f.depositor_graph,
2268
+ $
2269
+ ), c == null || c.throwIfAborted();
2270
+ const x = I(a);
2271
+ Ps(
2222
2272
  f.txs,
2223
2273
  i.vaultProviderBtcPubkey,
2224
2274
  i.vaultKeeperBtcPubkeys,
2225
2275
  a
2226
2276
  );
2227
- const x = f.txs.filter(
2228
- (O) => I(O.claimer_pubkey) !== k
2229
- ), v = cs(x);
2277
+ const v = f.txs.filter(
2278
+ (O) => I(O.claimer_pubkey) !== x
2279
+ ), E = bs(v);
2230
2280
  p && y && (typeof p.validateDepositTerms == "function" && await p.validateDepositTerms(y), await p.approveDepositTerms(y)), c == null || c.throwIfAborted();
2231
- const E = await hs(
2281
+ const T = await ws(
2232
2282
  o,
2233
2283
  i,
2234
- v,
2235
- d
2284
+ E,
2285
+ h
2236
2286
  );
2237
2287
  c == null || c.throwIfAborted();
2238
- const C = await ns({
2288
+ const w = await gs({
2239
2289
  depositorGraph: f.depositor_graph,
2240
2290
  btcWallet: o,
2241
- signingContext: {
2242
- vaultCoreVersion: i.vaultCoreVersion,
2243
- peginTxHex: i.peginTxHex,
2244
- depositorBtcPubkey: a,
2245
- vaultProviderBtcPubkey: i.vaultProviderBtcPubkey,
2246
- vaultKeeperBtcPubkeys: i.vaultKeeperBtcPubkeys,
2247
- universalChallengerBtcPubkeys: i.universalChallengerBtcPubkeys,
2248
- timelockPegin: i.timelockPegin,
2249
- timelockAssert: i.timelockAssert,
2250
- councilMembers: i.councilMembers,
2251
- councilQuorum: i.councilQuorum,
2252
- network: i.network,
2253
- registeredPayoutScriptPubKey: i.registeredPayoutScriptPubKey,
2254
- protocolFeeRate: i.protocolFeeRate,
2255
- vkClaimerPayoutScriptPubKeys: i.vkClaimerPayoutScriptPubKeys,
2256
- vpCommissionScriptPubKey: i.vpCommissionScriptPubKey
2257
- }
2291
+ signingContext: $
2258
2292
  });
2259
- c == null || c.throwIfAborted(), await h(P), c == null || c.throwIfAborted();
2260
- const w = { ...E };
2261
- w[b(a)] = C.payout_signatures, await r.submitDepositorPresignatures(
2293
+ c == null || c.throwIfAborted(), await d(m), c == null || c.throwIfAborted();
2294
+ const j = { ...T };
2295
+ j[b(a)] = w.payout_signatures, await r.submitDepositorPresignatures(
2262
2296
  {
2263
2297
  pegin_txid: n,
2264
2298
  depositor_pk: a,
2265
- signatures: w,
2266
- depositor_claimer_presignatures: C
2299
+ signatures: j,
2300
+ depositor_claimer_presignatures: w
2267
2301
  },
2268
2302
  c
2269
2303
  );
2270
2304
  }
2271
- const ps = 300 * 1e3, gs = /* @__PURE__ */ new Set([
2305
+ const xs = 300 * 1e3, Es = /* @__PURE__ */ new Set([
2272
2306
  R.PENDING_DEPOSITOR_WOTS_PK,
2273
- ...kt
2307
+ ...Ct
2274
2308
  ]);
2275
- async function an(e) {
2309
+ async function vn(e) {
2276
2310
  const {
2277
2311
  statusReader: t,
2278
2312
  wotsSubmitter: r,
@@ -2280,7 +2314,7 @@ async function an(e) {
2280
2314
  peginTxid: s,
2281
2315
  depositorPk: n,
2282
2316
  wotsPublicKeys: a,
2283
- timeoutMs: i = ps,
2317
+ timeoutMs: i = xs,
2284
2318
  signal: u
2285
2319
  } = e;
2286
2320
  u == null || u.throwIfAborted();
@@ -2288,11 +2322,11 @@ async function an(e) {
2288
2322
  statusReader: t,
2289
2323
  vaultId: o,
2290
2324
  peginTxid: s,
2291
- targetStatuses: gs,
2325
+ targetStatuses: Es,
2292
2326
  timeoutMs: i,
2293
2327
  signal: u
2294
2328
  });
2295
- kt.has(l) || (u == null || u.throwIfAborted(), await r.submitDepositorWotsKey(
2329
+ Ct.has(l) || (u == null || u.throwIfAborted(), await r.submitDepositorWotsKey(
2296
2330
  {
2297
2331
  pegin_txid: s,
2298
2332
  depositor_pk: n,
@@ -2301,30 +2335,30 @@ async function an(e) {
2301
2335
  u
2302
2336
  ));
2303
2337
  }
2304
- function ke(e) {
2338
+ function $e(e) {
2305
2339
  return e.registration || e.operation;
2306
2340
  }
2307
- function fs(e, t, r) {
2341
+ function ks(e, t, r) {
2308
2342
  const o = _(e);
2309
2343
  return {
2310
2344
  registration: o === _(t),
2311
2345
  operation: o === _(r)
2312
2346
  };
2313
2347
  }
2314
- function st(e, t, r) {
2348
+ function nt(e, t, r) {
2315
2349
  const o = Ce(e);
2316
2350
  return {
2317
- registration: nt(o, Ce(t)),
2318
- operation: nt(o, Ce(r))
2351
+ registration: it(o, Ce(t)),
2352
+ operation: it(o, Ce(r))
2319
2353
  };
2320
2354
  }
2321
2355
  function Ce(e) {
2322
2356
  return e.map(_).sort();
2323
2357
  }
2324
- function nt(e, t) {
2358
+ function it(e, t) {
2325
2359
  return e.length === t.length && e.every((r, o) => r === t[o]);
2326
2360
  }
2327
- async function un(e) {
2361
+ async function bn(e) {
2328
2362
  const {
2329
2363
  vaultProviderEthAddress: t,
2330
2364
  hintBtcPubkey: r,
@@ -2348,11 +2382,11 @@ class Se extends Error {
2348
2382
  super(t), this.name = "ApplicationEntryPointMismatchError";
2349
2383
  }
2350
2384
  }
2351
- function cn(e) {
2385
+ function mn(e) {
2352
2386
  return e instanceof Se || e instanceof Error && e.name === "ApplicationEntryPointMismatchError";
2353
2387
  }
2354
- const it = (e) => e.map(_).sort();
2355
- async function ln(e) {
2388
+ const at = (e) => e.map(_).sort();
2389
+ async function Pn(e) {
2356
2390
  const {
2357
2391
  vaultRegistryReader: t,
2358
2392
  vaultKeeperReader: r,
@@ -2364,8 +2398,8 @@ async function ln(e) {
2364
2398
  expectedUniversalChallengerBtcPubkeys: u,
2365
2399
  operationKeyReader: l,
2366
2400
  onIndexerServingOperationKeys: c,
2367
- onIndexerHintsInconsistent: d,
2368
- blockNumber: h
2401
+ onIndexerHintsInconsistent: h,
2402
+ blockNumber: d
2369
2403
  } = e, [
2370
2404
  g,
2371
2405
  p,
@@ -2374,49 +2408,49 @@ async function ln(e) {
2374
2408
  ] = await Promise.all([
2375
2409
  t.getVaultProviderApplication(
2376
2410
  s,
2377
- h
2411
+ d
2378
2412
  ),
2379
2413
  t.getVaultProviderGenesisBtcPubKey(
2380
2414
  s,
2381
- h
2415
+ d
2382
2416
  ),
2383
- o.getLatestUniversalChallengersVersion(h),
2384
- o.getCurrentUcKeyEpoch(h)
2417
+ o.getLatestUniversalChallengersVersion(d),
2418
+ o.getCurrentUcKeyEpoch(d)
2385
2419
  ]);
2386
- if (!Ar(n, { strict: !1 }))
2420
+ if (!Hr(n, { strict: !1 }))
2387
2421
  throw new Se(
2388
2422
  `The application entry point this deposit was prepared for is not a valid address: ${n}`
2389
2423
  );
2390
- if (!Br(g, n))
2424
+ if (!Or(g, n))
2391
2425
  throw new Se(
2392
2426
  `Vault provider ${s} is registered to application ${g}, but this deposit was prepared for ${n}. Refusing to build: the vault keeper roster, its version, and the keeper key epoch would all resolve against a different application than the one selected.`
2393
2427
  );
2394
- const [P, k] = await Promise.all(
2428
+ const [m, $] = await Promise.all(
2395
2429
  [
2396
2430
  r.getCurrentVaultKeepersVersion(
2397
2431
  g,
2398
- h
2432
+ d
2399
2433
  ),
2400
2434
  r.getCurrentAppKeeperKeyEpoch(
2401
2435
  g,
2402
- h
2436
+ d
2403
2437
  )
2404
2438
  ]
2405
2439
  ), [x, v] = await Promise.all([
2406
2440
  r.getVaultKeepersByVersion(
2407
2441
  g,
2408
- P,
2409
- h
2442
+ m,
2443
+ d
2410
2444
  ),
2411
2445
  o.getUniversalChallengersByVersion(
2412
2446
  y,
2413
- h
2447
+ d
2414
2448
  )
2415
2449
  ]), E = {
2416
2450
  vaultProvider: _(p),
2417
- vaultKeepers: it(x.map((T) => T.btcPubKey)),
2418
- universalChallengers: it(v.map((T) => T.btcPubKey))
2419
- }, C = await Ro({
2451
+ vaultKeepers: at(x.map((C) => C.btcPubKey)),
2452
+ universalChallengers: at(v.map((C) => C.btcPubKey))
2453
+ }, T = await Uo({
2420
2454
  operationKeyReader: l,
2421
2455
  query: {
2422
2456
  vaultProviderEthAddress: s,
@@ -2425,42 +2459,42 @@ async function ln(e) {
2425
2459
  vaultKeepers: x,
2426
2460
  universalChallengers: v
2427
2461
  },
2428
- blockNumber: h
2462
+ blockNumber: d
2429
2463
  }), w = {
2430
- vaultProvider: C.vaultProvider.operationBtcPubkey,
2431
- vaultKeepers: [...C.vaultKeeperOperationKeysSorted],
2464
+ vaultProvider: T.vaultProvider.operationBtcPubkey,
2465
+ vaultKeepers: [...T.vaultKeeperOperationKeysSorted],
2432
2466
  universalChallengers: [
2433
- ...C.universalChallengerOperationKeysSorted
2467
+ ...T.universalChallengerOperationKeysSorted
2434
2468
  ]
2435
- }, O = fs(
2469
+ }, j = ks(
2436
2470
  a,
2437
2471
  E.vaultProvider,
2438
2472
  w.vaultProvider
2439
- ), oe = st(
2473
+ ), O = nt(
2440
2474
  i,
2441
2475
  E.vaultKeepers,
2442
2476
  w.vaultKeepers
2443
- ), Oe = st(
2477
+ ), se = nt(
2444
2478
  u,
2445
2479
  E.universalChallengers,
2446
2480
  w.universalChallengers
2447
2481
  );
2448
- if (!ke(O))
2482
+ if (!$e(j))
2449
2483
  throw new Error(
2450
2484
  `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
2451
2485
  );
2452
- if (!ke(oe))
2486
+ if (!$e(O))
2453
2487
  throw new Error(
2454
- `Vault keeper BTC pubkeys (v${P}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
2488
+ `Vault keeper BTC pubkeys (v${m}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
2455
2489
  );
2456
- if (!ke(Oe))
2490
+ if (!$e(se))
2457
2491
  throw new Error(
2458
2492
  `Universal challenger BTC pubkeys (v${y}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
2459
2493
  );
2460
- const Ne = [O, oe, Oe], Qt = Ne.some((T) => T.registration && !T.operation), De = Ne.some((T) => T.operation && !T.registration);
2494
+ const Ne = [j, O, se], Qt = Ne.some((C) => C.registration && !C.operation), De = Ne.some((C) => C.operation && !C.registration);
2461
2495
  if (Qt && De) {
2462
- const T = `Indexer participant hints are internally inconsistent for vault provider ${s}: some roles match the registration keys while others match the rotated operation keys.`;
2463
- throw d == null || d(T), new Error(`${T} Refresh and try again.`);
2496
+ const C = `Indexer participant hints are internally inconsistent for vault provider ${s}: some roles match the registration keys while others match the rotated operation keys.`;
2497
+ throw h == null || h(C), new Error(`${C} Refresh and try again.`);
2464
2498
  }
2465
2499
  return De && (c == null || c(
2466
2500
  `Indexer is serving rotated operation keys for vault provider ${s}`
@@ -2468,18 +2502,18 @@ async function ln(e) {
2468
2502
  vaultProviderBtcPubkeyXOnly: w.vaultProvider,
2469
2503
  vaultKeeperBtcPubkeysSorted: w.vaultKeepers,
2470
2504
  universalChallengerBtcPubkeysSorted: w.universalChallengers,
2471
- expectedAppVaultKeepersVersion: P,
2505
+ expectedAppVaultKeepersVersion: m,
2472
2506
  expectedUniversalChallengersVersion: y,
2473
- appKeeperKeyEpoch: k,
2507
+ appKeeperKeyEpoch: $,
2474
2508
  ucKeyEpoch: f,
2475
2509
  registrationKeys: E,
2476
- participantKeys: C
2510
+ participantKeys: T
2477
2511
  };
2478
2512
  }
2479
- function ys(e) {
2513
+ function $s(e) {
2480
2514
  return /^[0-9a-fA-F]{64}$/.test(e);
2481
2515
  }
2482
- function dn(e) {
2516
+ function wn(e) {
2483
2517
  const {
2484
2518
  amountSats: t,
2485
2519
  minDeposit: r,
@@ -2490,7 +2524,7 @@ function dn(e) {
2490
2524
  } = e;
2491
2525
  return !(t <= 0n || t < r || o && o > 0n && t > o || n == null || a == null || t + n + a > s);
2492
2526
  }
2493
- function hn(e, t, r) {
2527
+ function xn(e, t, r) {
2494
2528
  return e <= 0n ? {
2495
2529
  valid: !1,
2496
2530
  error: "Deposit amount must be greater than zero"
@@ -2502,7 +2536,7 @@ function hn(e, t, r) {
2502
2536
  error: `Maximum deposit is ${N(r)} BTC`
2503
2537
  } : { valid: !0 };
2504
2538
  }
2505
- function pn(e) {
2539
+ function En(e) {
2506
2540
  const { amount: t, effectiveRemaining: r } = e;
2507
2541
  return r === null ? { valid: !0 } : r === 0n ? {
2508
2542
  valid: !1,
@@ -2512,7 +2546,7 @@ function pn(e) {
2512
2546
  error: `Vault size exceeds remaining capacity (${N(r)} BTC)`
2513
2547
  } : { valid: !0 };
2514
2548
  }
2515
- function gn(e, t) {
2549
+ function kn(e, t) {
2516
2550
  if (!e || e.length === 0)
2517
2551
  return {
2518
2552
  valid: !1,
@@ -2528,7 +2562,7 @@ function gn(e, t) {
2528
2562
  error: "Invalid vault provider selected"
2529
2563
  } : { valid: !0 };
2530
2564
  }
2531
- function vs(e, t, r) {
2565
+ function Cs(e, t, r) {
2532
2566
  if (!e || e.length === 0)
2533
2567
  return {
2534
2568
  valid: !1,
@@ -2554,30 +2588,30 @@ function vs(e, t, r) {
2554
2588
  }
2555
2589
  return { valid: !0 };
2556
2590
  }
2557
- function bs(e) {
2591
+ function Ts(e) {
2558
2592
  const t = b(e);
2559
- return ys(t) ? { valid: !0 } : {
2593
+ return $s(t) ? { valid: !0 } : {
2560
2594
  valid: !1,
2561
2595
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
2562
2596
  };
2563
2597
  }
2564
- function Ps(e) {
2598
+ function _s(e) {
2565
2599
  if (!e || e.length === 0)
2566
2600
  throw new Error(
2567
2601
  "No vault keepers available. The system requires at least one vault keeper to create a deposit."
2568
2602
  );
2569
2603
  }
2570
- function ms(e) {
2604
+ function Ss(e) {
2571
2605
  if (!e || e.length === 0)
2572
2606
  throw new Error(
2573
2607
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
2574
2608
  );
2575
2609
  }
2576
- function ws(e) {
2610
+ function As(e) {
2577
2611
  if (e.length === 0)
2578
2612
  throw new Error("No spendable UTXOs available");
2579
2613
  }
2580
- function fn(e) {
2614
+ function $n(e) {
2581
2615
  const {
2582
2616
  vaultAmounts: t,
2583
2617
  confirmedUTXOs: r,
@@ -2586,38 +2620,38 @@ function fn(e) {
2586
2620
  universalChallengerBtcPubkeys: n,
2587
2621
  minDeposit: a,
2588
2622
  maxDeposit: i
2589
- } = e, u = vs(
2623
+ } = e, u = Cs(
2590
2624
  t,
2591
2625
  a,
2592
2626
  i
2593
2627
  );
2594
2628
  if (!u.valid)
2595
2629
  throw new Error(u.error);
2596
- const l = bs(o);
2630
+ const l = Ts(o);
2597
2631
  if (!l.valid)
2598
2632
  throw new Error(l.error);
2599
- Ps(s), ms(n), ws(r);
2633
+ _s(s), Ss(n), As(r);
2600
2634
  }
2601
- class zt extends Error {
2635
+ class jt extends Error {
2602
2636
  constructor(t) {
2603
2637
  super(t), this.name = "ParticipantKeyDriftError";
2604
2638
  }
2605
2639
  }
2606
- function yn(e) {
2607
- return e instanceof zt || e instanceof Error && e.name === "ParticipantKeyDriftError";
2640
+ function Cn(e) {
2641
+ return e instanceof jt || e instanceof Error && e.name === "ParticipantKeyDriftError";
2608
2642
  }
2609
- function at(e, t, r) {
2643
+ function ut(e, t, r) {
2610
2644
  return t.length === r.length && t.every((o, s) => o === r[s]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
2611
2645
  }
2612
- async function vn(e) {
2646
+ async function Tn(e) {
2613
2647
  const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: o, expected: s } = e, n = s.query;
2614
2648
  if (o.length === 0) return;
2615
2649
  const a = await t.getVaultKeyEpochsBatch(o), i = [];
2616
2650
  for (const [u, l] of a.entries()) {
2617
2651
  const c = o[u];
2618
- let d;
2652
+ let h;
2619
2653
  try {
2620
- d = await Nt({
2654
+ h = await Nt({
2621
2655
  operationKeyReader: r,
2622
2656
  query: n,
2623
2657
  epochs: l
@@ -2628,36 +2662,36 @@ async function vn(e) {
2628
2662
  );
2629
2663
  continue;
2630
2664
  }
2631
- d.vaultProvider.operationBtcPubkey !== s.vaultProvider.operationBtcPubkey && i.push(
2632
- `vault ${c}: vault provider key expected ${s.vaultProvider.operationBtcPubkey}, got ${d.vaultProvider.operationBtcPubkey}`
2665
+ h.vaultProvider.operationBtcPubkey !== s.vaultProvider.operationBtcPubkey && i.push(
2666
+ `vault ${c}: vault provider key expected ${s.vaultProvider.operationBtcPubkey}, got ${h.vaultProvider.operationBtcPubkey}`
2633
2667
  );
2634
- const h = at(
2668
+ const d = ut(
2635
2669
  `vault ${c}: vault keeper keys`,
2636
2670
  s.vaultKeeperOperationKeysSorted,
2637
- d.vaultKeeperOperationKeysSorted
2671
+ h.vaultKeeperOperationKeysSorted
2638
2672
  );
2639
- h && i.push(h);
2640
- const g = at(
2673
+ d && i.push(d);
2674
+ const g = ut(
2641
2675
  `vault ${c}: universal challenger keys`,
2642
2676
  s.universalChallengerOperationKeysSorted,
2643
- d.universalChallengerOperationKeysSorted
2677
+ h.universalChallengerOperationKeysSorted
2644
2678
  );
2645
2679
  g && i.push(g);
2646
2680
  }
2647
2681
  if (i.length > 0)
2648
- throw new zt(
2682
+ throw new jt(
2649
2683
  `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.`
2650
2684
  );
2651
2685
  }
2652
- class jt extends Error {
2686
+ class Wt extends Error {
2653
2687
  constructor(t) {
2654
2688
  super(t), this.name = "RegisteredVaultVersionMismatchError";
2655
2689
  }
2656
2690
  }
2657
- function bn(e) {
2658
- return e instanceof jt || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
2691
+ function _n(e) {
2692
+ return e instanceof Wt || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
2659
2693
  }
2660
- async function Pn(e) {
2694
+ async function Sn(e) {
2661
2695
  const {
2662
2696
  vaultRegistryReader: t,
2663
2697
  vaultIds: r,
@@ -2667,44 +2701,44 @@ async function Pn(e) {
2667
2701
  expectedVaultCoreVersion: a
2668
2702
  } = e, i = await t.getProtocolInfoBatch(r), u = [];
2669
2703
  if (i.forEach((l, c) => {
2670
- const d = r[c];
2704
+ const h = r[c];
2671
2705
  l.offchainParamsVersion !== o && u.push(
2672
- `vault ${d}: offchainParams expected v${o}, got v${l.offchainParamsVersion}`
2706
+ `vault ${h}: offchainParams expected v${o}, got v${l.offchainParamsVersion}`
2673
2707
  ), l.appVaultKeepersVersion !== s && u.push(
2674
- `vault ${d}: appVaultKeepers expected v${s}, got v${l.appVaultKeepersVersion}`
2708
+ `vault ${h}: appVaultKeepers expected v${s}, got v${l.appVaultKeepersVersion}`
2675
2709
  ), l.universalChallengersVersion !== n && u.push(
2676
- `vault ${d}: universalChallengers expected v${n}, got v${l.universalChallengersVersion}`
2710
+ `vault ${h}: universalChallengers expected v${n}, got v${l.universalChallengersVersion}`
2677
2711
  ), l.vaultCoreVersion !== a && u.push(
2678
- `vault ${d}: vaultCoreVersion expected v${a} (build-time active), got v${l.vaultCoreVersion}`
2712
+ `vault ${h}: vaultCoreVersion expected v${a} (build-time active), got v${l.vaultCoreVersion}`
2679
2713
  );
2680
2714
  }), u.length > 0)
2681
- throw new jt(
2715
+ throw new Wt(
2682
2716
  `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${u.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
2683
2717
  );
2684
2718
  }
2685
- class xs extends Error {
2719
+ class Bs extends Error {
2686
2720
  constructor(r, o) {
2687
2721
  super(`Refund not yet mature (BIP68 not final): ${o.message}`);
2688
- z(this, "vaultId");
2689
- z(this, "cause");
2722
+ W(this, "vaultId");
2723
+ W(this, "cause");
2690
2724
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
2691
2725
  }
2692
2726
  }
2693
- const Es = /^0x[0-9a-fA-F]{64}$/, $s = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Wt = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Yt = 160, ut = 2e3, ct = 10n, lt = 100n;
2694
- function mn(e) {
2727
+ const Is = /^0x[0-9a-fA-F]{64}$/, Vs = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Yt = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Jt = 160, ct = 2e3, lt = 10n, dt = 100n;
2728
+ function An(e) {
2695
2729
  if (!Number.isFinite(e) || e <= 0)
2696
2730
  throw new Error(
2697
2731
  `feeRateSatsVb must be a positive finite number, got ${e}`
2698
2732
  );
2699
- return BigInt(Math.ceil(e * Yt));
2733
+ return BigInt(Math.ceil(e * Jt));
2700
2734
  }
2701
- const ks = 1, Cs = /non-BIP68-final/i;
2735
+ const Rs = 1, Ks = /non-BIP68-final/i;
2702
2736
  function Ae(e, t) {
2703
2737
  if (e.length !== 66)
2704
2738
  throw new Error(
2705
2739
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
2706
2740
  );
2707
- if (!Es.test(e))
2741
+ if (!Is.test(e))
2708
2742
  throw new Error(
2709
2743
  `${t} must contain only hex characters after the 0x prefix`
2710
2744
  );
@@ -2713,7 +2747,7 @@ function Te(e, t) {
2713
2747
  if (!Number.isInteger(e) || e < 0)
2714
2748
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
2715
2749
  }
2716
- function Ts(e) {
2750
+ function Hs(e) {
2717
2751
  if (Ae(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
2718
2752
  throw new Error(
2719
2753
  `htlcVout must be a non-negative integer, got ${e.htlcVout}`
@@ -2747,24 +2781,24 @@ function Ts(e) {
2747
2781
  if (Te(e.offchainParamsVersion, "offchainParamsVersion"), Te(e.appVaultKeepersVersion, "appVaultKeepersVersion"), Te(
2748
2782
  e.universalChallengersVersion,
2749
2783
  "universalChallengersVersion"
2750
- ), Ur(
2784
+ ), Jr(
2751
2785
  e.vaultCoreVersion,
2752
2786
  "VaultRefundData.vaultCoreVersion"
2753
2787
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
2754
2788
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
2755
- if (!$s.test(e.unsignedPrePeginTxHex))
2789
+ if (!Vs.test(e.unsignedPrePeginTxHex))
2756
2790
  throw new Error(
2757
2791
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
2758
2792
  );
2759
- if (!e.depositorBtcPubkey || !Wt.test(e.depositorBtcPubkey))
2793
+ if (!e.depositorBtcPubkey || !Yt.test(e.depositorBtcPubkey))
2760
2794
  throw new Error(
2761
2795
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
2762
2796
  );
2763
2797
  if (typeof e.amount != "bigint" || e.amount <= 0n)
2764
2798
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
2765
2799
  }
2766
- function _s(e) {
2767
- if (!e.vaultProviderPubkey || !Wt.test(e.vaultProviderPubkey))
2800
+ function Os(e) {
2801
+ if (!e.vaultProviderPubkey || !Yt.test(e.vaultProviderPubkey))
2768
2802
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
2769
2803
  if (e.vaultKeeperPubkeys.length === 0)
2770
2804
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -2789,7 +2823,7 @@ function _s(e) {
2789
2823
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
2790
2824
  );
2791
2825
  }
2792
- async function wn(e) {
2826
+ async function Bn(e) {
2793
2827
  const {
2794
2828
  vaultId: t,
2795
2829
  readVault: r,
@@ -2801,23 +2835,23 @@ async function wn(e) {
2801
2835
  } = e;
2802
2836
  i == null || i.throwIfAborted(), Ae(t, "vaultId");
2803
2837
  const u = await r();
2804
- Ts(u), i == null || i.throwIfAborted();
2838
+ Hs(u), i == null || i.throwIfAborted();
2805
2839
  const l = await o(u);
2806
- if (_s(l), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
2840
+ if (Os(l), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
2807
2841
  throw new Error(`feeRate must be a positive number, got ${s}`);
2808
- if (s > ut)
2842
+ if (s > ct)
2809
2843
  throw new Error(
2810
- `feeRate ${s} sat/vB exceeds refund safety cap ${ut} sat/vB; refusing to sign refund.`
2844
+ `feeRate ${s} sat/vB exceeds refund safety cap ${ct} sat/vB; refusing to sign refund.`
2811
2845
  );
2812
- const c = BigInt(Math.ceil(s * Yt)), d = u.amount * ct / lt;
2813
- if (c > d)
2846
+ const c = BigInt(Math.ceil(s * Jt)), h = u.amount * lt / dt;
2847
+ if (c > h)
2814
2848
  throw new Error(
2815
- `Refund fee ${c} sats exceeds the per-vault safety cap of ${d} sats (${ct}/${lt} of vault.amount=${u.amount}); refusing to sign refund.`
2849
+ `Refund fee ${c} sats exceeds the per-vault safety cap of ${h} sats (${lt}/${dt} of vault.amount=${u.amount}); refusing to sign refund.`
2816
2850
  );
2817
2851
  i == null || i.throwIfAborted();
2818
- const h = he(
2852
+ const d = pe(
2819
2853
  u.depositorBtcPubkey
2820
- ), g = b(u.unsignedPrePeginTxHex), p = sr(g);
2854
+ ), g = b(u.unsignedPrePeginTxHex), p = ir(g);
2821
2855
  if (p !== void 0 && p.vout !== u.batch.length)
2822
2856
  throw new Error(
2823
2857
  `Auth-anchor OP_RETURN at vout ${p.vout} does not match batch size (${u.batch.length} HTLC outputs expect the anchor at vout ${u.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
@@ -2835,10 +2869,10 @@ async function wn(e) {
2835
2869
  throw new Error(
2836
2870
  `Funded Pre-PegIn tx has ${f.outs.length} outputs but batch requires at least ${u.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
2837
2871
  );
2838
- const { psbtHex: P } = await Mr({
2872
+ const { psbtHex: m } = await jr({
2839
2873
  prePeginParams: {
2840
2874
  vaultCoreVersion: u.vaultCoreVersion,
2841
- depositorPubkey: h,
2875
+ depositorPubkey: d,
2842
2876
  vaultProviderPubkey: b(l.vaultProviderPubkey),
2843
2877
  vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(b),
2844
2878
  universalChallengerPubkeys: l.universalChallengerPubkeys.map(b),
@@ -2869,52 +2903,52 @@ async function wn(e) {
2869
2903
  hashlock: b(u.hashlock)
2870
2904
  });
2871
2905
  i == null || i.throwIfAborted();
2872
- const k = ue(
2906
+ const $ = ce(
2873
2907
  u.depositorBtcPubkey,
2874
- ks
2875
- ), x = await n(P, k);
2876
- ie({
2877
- requestedPsbtHex: P,
2908
+ Rs
2909
+ ), x = await n(m, $);
2910
+ ae({
2911
+ requestedPsbtHex: m,
2878
2912
  returnedPsbtHex: x
2879
2913
  });
2880
- const v = 0, E = ae(
2914
+ const v = 0, E = ue(
2881
2915
  x,
2882
- h,
2916
+ d,
2883
2917
  v
2884
2918
  );
2885
- re({
2886
- requestedPsbtHex: P,
2919
+ oe({
2920
+ requestedPsbtHex: m,
2887
2921
  signatureHex: E,
2888
- signerXOnlyPubkeyHex: h,
2922
+ signerXOnlyPubkeyHex: d,
2889
2923
  inputIndex: v
2890
2924
  });
2891
- const C = Ct({
2892
- requestedPsbtHex: P,
2925
+ const T = Tt({
2926
+ requestedPsbtHex: m,
2893
2927
  signaturesHex: [E],
2894
- signerXOnlyPubkeyHex: h
2928
+ signerXOnlyPubkeyHex: d
2895
2929
  });
2896
2930
  i == null || i.throwIfAborted();
2897
2931
  try {
2898
- return await a(C);
2932
+ return await a(T);
2899
2933
  } catch (w) {
2900
- throw w instanceof Error && Cs.test(w.message) ? new xs(t, w) : w;
2934
+ throw w instanceof Error && Ks.test(w.message) ? new Bs(t, w) : w;
2901
2935
  }
2902
2936
  }
2903
- class dt extends Error {
2937
+ class ht extends Error {
2904
2938
  constructor(r, o, s) {
2905
2939
  super(r);
2906
2940
  /** Fee the reclaim would have paid, in satoshis. */
2907
- z(this, "feeSats");
2941
+ W(this, "feeSats");
2908
2942
  /** Sum of the reserves the reclaim would have swept, in satoshis. */
2909
- z(this, "sweptTotalSats");
2943
+ W(this, "sweptTotalSats");
2910
2944
  this.name = "ReclaimUneconomicalError", this.feeSats = o, this.sweptTotalSats = s;
2911
2945
  }
2912
2946
  }
2913
- const ht = 2e3, pt = 25n, gt = 100n, xn = 10n;
2914
- async function Ss(e, t, r) {
2947
+ const pt = 2e3, gt = 25n, ft = 100n, In = 10n;
2948
+ async function Ns(e, t, r) {
2915
2949
  for (let o = 0; o < e.length; o++) {
2916
- const s = qr(e[o].depositorSignedPeginTxHex), n = Be(
2917
- await yr(
2950
+ const s = Qr(e[o].depositorSignedPeginTxHex), n = Ie(
2951
+ await mr(
2918
2952
  b(s),
2919
2953
  b(r)
2920
2954
  )
@@ -2925,7 +2959,7 @@ async function Ss(e, t, r) {
2925
2959
  );
2926
2960
  }
2927
2961
  }
2928
- async function En(e) {
2962
+ async function Vn(e) {
2929
2963
  const {
2930
2964
  vaultIds: t,
2931
2965
  depositorEthAddress: r,
@@ -2940,9 +2974,9 @@ async function En(e) {
2940
2974
  throw new Error("Reclaim requires at least one vault id; got none.");
2941
2975
  if (!Number.isFinite(n) || n <= 0)
2942
2976
  throw new Error(`feeRate must be a positive number, got ${n}`);
2943
- if (n > ht)
2944
- throw new dt(
2945
- `Fee rate ${n} sat/vB exceeds the reclaim safety cap of ${ht} sat/vB; refusing to sign.`,
2977
+ if (n > pt)
2978
+ throw new ht(
2979
+ `Fee rate ${n} sat/vB exceeds the reclaim safety cap of ${pt} sat/vB; refusing to sign.`,
2946
2980
  0n,
2947
2981
  0n
2948
2982
  );
@@ -2951,127 +2985,127 @@ async function En(e) {
2951
2985
  throw new Error(
2952
2986
  `readVaults returned ${l.length} reserves for ${t.length} vault id(s); refusing to sweep a set that does not match the request.`
2953
2987
  );
2954
- await Ss(l, t, r), u == null || u.throwIfAborted();
2955
- const c = he(o), d = l.map((v) => ({
2988
+ await Ns(l, t, r), u == null || u.throwIfAborted();
2989
+ const c = pe(o), h = l.map((v) => ({
2956
2990
  depositorSignedPeginTxHex: v.depositorSignedPeginTxHex,
2957
2991
  observed: v.observed,
2958
2992
  expectedValue: v.expectedClaimValue
2959
- })), h = Lr(n, d.length), g = d.reduce((v, E) => v + E.expectedValue, 0n), p = g * pt / gt;
2960
- if (h > p)
2961
- throw new dt(
2962
- `Reclaim fee ${h} sats exceeds ${pt}/${gt} of the swept total (${g} sats, cap ${p} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
2963
- h,
2993
+ })), d = Wr(n, h.length), g = h.reduce((v, E) => v + E.expectedValue, 0n), p = g * gt / ft;
2994
+ if (d > p)
2995
+ throw new ht(
2996
+ `Reclaim fee ${d} sats exceeds ${gt}/${ft} of the swept total (${g} sats, cap ${p} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
2997
+ d,
2964
2998
  g
2965
2999
  );
2966
3000
  u == null || u.throwIfAborted();
2967
- const { psbtHex: y } = Fr({
3001
+ const { psbtHex: y } = Yr({
2968
3002
  depositorPubkey: c,
2969
- inputs: d,
2970
- feeSats: h
3003
+ inputs: h,
3004
+ feeSats: d
2971
3005
  });
2972
3006
  u == null || u.throwIfAborted();
2973
- const f = ue(
3007
+ const f = ce(
2974
3008
  o,
2975
- d.length
2976
- ), P = await a(y, f);
2977
- ie({
3009
+ h.length
3010
+ ), m = await a(y, f);
3011
+ ae({
2978
3012
  requestedPsbtHex: y,
2979
- returnedPsbtHex: P
3013
+ returnedPsbtHex: m
2980
3014
  });
2981
- const k = d.map((v, E) => {
2982
- const C = ae(
2983
- P,
3015
+ const $ = h.map((v, E) => {
3016
+ const T = ue(
3017
+ m,
2984
3018
  c,
2985
3019
  E
2986
3020
  );
2987
- return re({
3021
+ return oe({
2988
3022
  requestedPsbtHex: y,
2989
- signatureHex: C,
3023
+ signatureHex: T,
2990
3024
  signerXOnlyPubkeyHex: c,
2991
3025
  inputIndex: E
2992
- }), C;
2993
- }), x = Ct({
3026
+ }), T;
3027
+ }), x = Tt({
2994
3028
  requestedPsbtHex: y,
2995
- signaturesHex: k,
3029
+ signaturesHex: $,
2996
3030
  signerXOnlyPubkeyHex: c
2997
3031
  });
2998
3032
  return u == null || u.throwIfAborted(), i(x);
2999
3033
  }
3000
3034
  export {
3001
- Pn as $,
3035
+ Sn as $,
3002
3036
  K as A,
3003
- io as B,
3004
- eo as C,
3037
+ fn as B,
3038
+ uo as C,
3005
3039
  U as D,
3006
- Qo as E,
3007
- nn as F,
3008
- m as G,
3009
- ns as H,
3010
- an as I,
3040
+ is as E,
3041
+ yn as F,
3042
+ P as G,
3043
+ gs as H,
3044
+ vn as I,
3011
3045
  Se as J,
3012
- cn as K,
3013
- ln as L,
3014
- dn as M,
3015
- hn as N,
3016
- fn as O,
3017
- ro as P,
3018
- gn as Q,
3019
- pn as R,
3020
- j as S,
3021
- vs as T,
3022
- bs as U,
3023
- ao as V,
3024
- zt as W,
3025
- yn as X,
3026
- vn as Y,
3027
- jt as Z,
3028
- bn as _,
3029
- Ys as a,
3046
+ mn as K,
3047
+ Pn as L,
3048
+ wn as M,
3049
+ xn as N,
3050
+ $n as O,
3051
+ lo as P,
3052
+ kn as Q,
3053
+ En as R,
3054
+ Y as S,
3055
+ Cs as T,
3056
+ Ts as U,
3057
+ fo as V,
3058
+ jt as W,
3059
+ Cn as X,
3060
+ Tn as Y,
3061
+ Wt as Z,
3062
+ _n as _,
3063
+ nn as a,
3030
3064
  Xt as a0,
3031
- un as a1,
3032
- ke as a2,
3033
- fs as a3,
3034
- st as a4,
3035
- Ko as a5,
3036
- Ro as a6,
3065
+ bn as a1,
3066
+ $e as a2,
3067
+ ks as a3,
3068
+ nt as a4,
3069
+ qo as a5,
3070
+ Uo as a6,
3037
3071
  Nt as a7,
3038
- xs as a8,
3039
- wn as a9,
3040
- mn as aa,
3041
- lt as ab,
3042
- ct as ac,
3043
- ut as ad,
3044
- Yt as ae,
3045
- dt as af,
3046
- En as ag,
3047
- gt as ah,
3048
- pt as ai,
3049
- ht as aj,
3050
- xn as ak,
3051
- Qs as b,
3052
- Zs as c,
3053
- mo as d,
3054
- Jr as e,
3055
- to as f,
3056
- en as g,
3057
- oo as h,
3058
- se as i,
3059
- no as j,
3060
- lo as k,
3061
- Js as l,
3062
- xo as m,
3063
- _o as n,
3064
- $o as o,
3065
- vo as p,
3066
- St as q,
3067
- tn as r,
3068
- po as s,
3069
- Ho as t,
3070
- Dt as u,
3071
- Mt as v,
3072
- Mo as w,
3073
- rn as x,
3074
- on as y,
3075
- sn as z
3072
+ Bs as a8,
3073
+ Bn as a9,
3074
+ An as aa,
3075
+ dt as ab,
3076
+ lt as ac,
3077
+ ct as ad,
3078
+ Jt as ae,
3079
+ ht as af,
3080
+ Vn as ag,
3081
+ ft as ah,
3082
+ gt as ai,
3083
+ pt as aj,
3084
+ In as ak,
3085
+ an as b,
3086
+ un as c,
3087
+ ln as d,
3088
+ So as e,
3089
+ io as f,
3090
+ co as g,
3091
+ dn as h,
3092
+ ho as i,
3093
+ ne as j,
3094
+ go as k,
3095
+ bo as l,
3096
+ cn as m,
3097
+ Bo as n,
3098
+ Oo as o,
3099
+ Co as p,
3100
+ Vo as q,
3101
+ hn as r,
3102
+ wo as s,
3103
+ St as t,
3104
+ Go as u,
3105
+ Dt as v,
3106
+ Lt as w,
3107
+ Wo as x,
3108
+ pn as y,
3109
+ gn as z
3076
3110
  };
3077
- //# sourceMappingURL=buildAndBroadcastReclaim-R0HNpLMD.js.map
3111
+ //# sourceMappingURL=buildAndBroadcastReclaim-rQyAiAUS.js.map