@babylonlabs-io/ts-sdk 0.52.0 → 0.55.0

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 (160) hide show
  1. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs +2 -0
  2. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs.map +1 -0
  3. package/dist/{ApplicationRegistry.abi-Dn2qk6JG.js → ApplicationRegistry.abi-w5prf7Ig.js} +14 -1
  4. package/dist/ApplicationRegistry.abi-w5prf7Ig.js.map +1 -0
  5. package/dist/PayoutManager-BJmPnyRP.js +260 -0
  6. package/dist/PayoutManager-BJmPnyRP.js.map +1 -0
  7. package/dist/PayoutManager-aqtsj60t.cjs +2 -0
  8. package/dist/PayoutManager-aqtsj60t.cjs.map +1 -0
  9. package/dist/{PeginManager-BGWNJYPk.js → PeginManager-D22MLWfM.js} +132 -144
  10. package/dist/PeginManager-D22MLWfM.js.map +1 -0
  11. package/dist/PeginManager-vUUfZCzj.cjs +2 -0
  12. package/dist/PeginManager-vUUfZCzj.cjs.map +1 -0
  13. package/dist/{buildAndBroadcastRefund-BAT5A6MP.js → buildAndBroadcastRefund-BiSO4zg2.js} +358 -360
  14. package/dist/buildAndBroadcastRefund-BiSO4zg2.js.map +1 -0
  15. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs +2 -0
  16. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs.map +1 -0
  17. package/dist/{challengeAssert-HNbugpqL.cjs → challengeAssert-DLQfNcfU.cjs} +2 -2
  18. package/dist/{challengeAssert-HNbugpqL.cjs.map → challengeAssert-DLQfNcfU.cjs.map} +1 -1
  19. package/dist/{challengeAssert-csvYXBJB.js → challengeAssert-DvdbpEDY.js} +2 -2
  20. package/dist/{challengeAssert-csvYXBJB.js.map → challengeAssert-DvdbpEDY.js.map} +1 -1
  21. package/dist/constants-BhclpREj.js +19 -0
  22. package/dist/constants-BhclpREj.js.map +1 -0
  23. package/dist/constants-CvbARMl-.cjs +2 -0
  24. package/dist/constants-CvbARMl-.cjs.map +1 -0
  25. package/dist/{fundPeginTransaction-96FxwYYJ.js → fundPeginTransaction-B2wyjqp0.js} +21 -22
  26. package/dist/fundPeginTransaction-B2wyjqp0.js.map +1 -0
  27. package/dist/fundPeginTransaction-BLD8FRL9.cjs +2 -0
  28. package/dist/fundPeginTransaction-BLD8FRL9.cjs.map +1 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +192 -190
  31. package/dist/index.js.map +1 -1
  32. package/dist/{mempoolApi-Dc1KSVNI.js → mempoolApi-CB7bHuwi.js} +106 -101
  33. package/dist/mempoolApi-CB7bHuwi.js.map +1 -0
  34. package/dist/mempoolApi-DqJByvqR.cjs +2 -0
  35. package/dist/mempoolApi-DqJByvqR.cjs.map +1 -0
  36. package/dist/noPayout-CNMqNNpc.cjs +2 -0
  37. package/dist/noPayout-CNMqNNpc.cjs.map +1 -0
  38. package/dist/{noPayout-DVx3zxUz.js → noPayout-CfBg3HzC.js} +30 -30
  39. package/dist/noPayout-CfBg3HzC.js.map +1 -0
  40. package/dist/{peginInput-B5XDDHpy.js → peginInput-BKD_b3gq.js} +10 -11
  41. package/dist/peginInput-BKD_b3gq.js.map +1 -0
  42. package/dist/{peginInput-De0C6aSj.cjs → peginInput-CAiiDZeO.cjs} +2 -2
  43. package/dist/peginInput-CAiiDZeO.cjs.map +1 -0
  44. package/dist/primeVpAuth-CF4cH5_e.cjs +2 -0
  45. package/dist/primeVpAuth-CF4cH5_e.cjs.map +1 -0
  46. package/dist/{primeVpAuth-DxMuWQCi.js → primeVpAuth-l-5x_2UV.js} +91 -85
  47. package/dist/{primeVpAuth-yTddDmGy.cjs.map → primeVpAuth-l-5x_2UV.js.map} +1 -1
  48. package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -1
  49. package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts.map +1 -1
  50. package/dist/tbv/core/clients/eth/types.d.ts +8 -0
  51. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  52. package/dist/tbv/core/clients/index.cjs +1 -1
  53. package/dist/tbv/core/clients/index.js +2 -2
  54. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +10 -0
  55. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  56. package/dist/tbv/core/contracts/index.cjs +1 -1
  57. package/dist/tbv/core/contracts/index.js +1 -1
  58. package/dist/tbv/core/index.cjs +1 -1
  59. package/dist/tbv/core/index.js +190 -188
  60. package/dist/tbv/core/index.js.map +1 -1
  61. package/dist/tbv/core/managers/PayoutManager.d.ts +6 -0
  62. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  63. package/dist/tbv/core/managers/PeginManager.d.ts +10 -2
  64. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  65. package/dist/tbv/core/managers/index.cjs +1 -1
  66. package/dist/tbv/core/managers/index.js +2 -2
  67. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts +10 -6
  68. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts.map +1 -1
  69. package/dist/tbv/core/primitives/__tests__/vaultCoreVersion.test.d.ts +8 -0
  70. package/dist/tbv/core/primitives/__tests__/vaultCoreVersion.test.d.ts.map +1 -0
  71. package/dist/tbv/core/primitives/index.cjs +1 -1
  72. package/dist/tbv/core/primitives/index.d.ts +3 -3
  73. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  74. package/dist/tbv/core/primitives/index.js +40 -37
  75. package/dist/tbv/core/primitives/index.js.map +1 -1
  76. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +11 -0
  77. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -0
  78. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +11 -10
  79. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  80. package/dist/tbv/core/primitives/psbt/payout.d.ts +6 -0
  81. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  82. package/dist/tbv/core/primitives/psbt/pegin.d.ts +17 -2
  83. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  84. package/dist/tbv/core/primitives/psbt/peginInput.d.ts +6 -0
  85. package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
  86. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  87. package/dist/tbv/core/primitives/scripts/payout.d.ts +6 -0
  88. package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -1
  89. package/dist/tbv/core/primitives/vaultCoreVersion.d.ts +26 -0
  90. package/dist/tbv/core/primitives/vaultCoreVersion.d.ts.map +1 -0
  91. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +7 -0
  92. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  93. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +6 -0
  94. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  95. package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.d.ts +8 -0
  96. package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.d.ts.map +1 -1
  97. package/dist/tbv/core/services/index.cjs +1 -1
  98. package/dist/tbv/core/services/index.js +2 -2
  99. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts +6 -0
  100. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  101. package/dist/tbv/core/utils/fee/constants.d.ts +6 -14
  102. package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -1
  103. package/dist/tbv/core/utils/index.cjs +1 -1
  104. package/dist/tbv/core/utils/index.js +35 -36
  105. package/dist/tbv/index.cjs +1 -1
  106. package/dist/tbv/index.js +190 -188
  107. package/dist/tbv/index.js.map +1 -1
  108. package/dist/testing/MockBitcoinWallet.d.ts +1 -1
  109. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  110. package/dist/testing/index.cjs +1 -1
  111. package/dist/testing/index.cjs.map +1 -1
  112. package/dist/testing/index.js +3 -3
  113. package/dist/testing/index.js.map +1 -1
  114. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs +2 -0
  115. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs.map +1 -0
  116. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js +658 -0
  117. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js.map +1 -0
  118. package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs} +2 -2
  119. package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs.map → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs.map} +1 -1
  120. package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js → waitForTransactionReceiptSmartAware-lobLm0q0.js} +2 -2
  121. package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js.map → waitForTransactionReceiptSmartAware-lobLm0q0.js.map} +1 -1
  122. package/package.json +2 -2
  123. package/dist/ApplicationRegistry.abi-BAPhJch3.cjs +0 -2
  124. package/dist/ApplicationRegistry.abi-BAPhJch3.cjs.map +0 -1
  125. package/dist/ApplicationRegistry.abi-Dn2qk6JG.js.map +0 -1
  126. package/dist/PayoutManager-BwrV3xFW.js +0 -241
  127. package/dist/PayoutManager-BwrV3xFW.js.map +0 -1
  128. package/dist/PayoutManager-CBfHfLfz.cjs +0 -2
  129. package/dist/PayoutManager-CBfHfLfz.cjs.map +0 -1
  130. package/dist/PeginManager-BGWNJYPk.js.map +0 -1
  131. package/dist/PeginManager-DDp-ZRIa.cjs +0 -2
  132. package/dist/PeginManager-DDp-ZRIa.cjs.map +0 -1
  133. package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs +0 -2
  134. package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs.map +0 -1
  135. package/dist/buildAndBroadcastRefund-BAT5A6MP.js.map +0 -1
  136. package/dist/constants-CSG2XeD8.cjs +0 -2
  137. package/dist/constants-CSG2XeD8.cjs.map +0 -1
  138. package/dist/constants-Cd_fN8VT.js +0 -12
  139. package/dist/constants-Cd_fN8VT.js.map +0 -1
  140. package/dist/fundPeginTransaction-96FxwYYJ.js.map +0 -1
  141. package/dist/fundPeginTransaction-DuMwnytD.cjs +0 -2
  142. package/dist/fundPeginTransaction-DuMwnytD.cjs.map +0 -1
  143. package/dist/mempoolApi-Dc1KSVNI.js.map +0 -1
  144. package/dist/mempoolApi-NMiYQAXI.cjs +0 -2
  145. package/dist/mempoolApi-NMiYQAXI.cjs.map +0 -1
  146. package/dist/noPayout-ChPNKTbm.cjs +0 -2
  147. package/dist/noPayout-ChPNKTbm.cjs.map +0 -1
  148. package/dist/noPayout-DVx3zxUz.js.map +0 -1
  149. package/dist/peginInput-B5XDDHpy.js.map +0 -1
  150. package/dist/peginInput-De0C6aSj.cjs.map +0 -1
  151. package/dist/primeVpAuth-DxMuWQCi.js.map +0 -1
  152. package/dist/primeVpAuth-yTddDmGy.cjs +0 -2
  153. package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts +0 -7
  154. package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts.map +0 -1
  155. package/dist/tbv/core/primitives/txGraphVersion.d.ts +0 -11
  156. package/dist/tbv/core/primitives/txGraphVersion.d.ts.map +0 -1
  157. package/dist/verifyScriptPathSchnorrSignature-BKECXOpa.js +0 -572
  158. package/dist/verifyScriptPathSchnorrSignature-BKECXOpa.js.map +0 -1
  159. package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs +0 -2
  160. package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs.map +0 -1
@@ -1,146 +1,147 @@
1
1
  var J = Object.defineProperty;
2
- var Z = (e, r, t) => r in e ? J(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var R = (e, r, t) => Z(e, typeof r != "symbol" ? r + "" : r, t);
2
+ var Z = (e, t, r) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var $ = (e, t, r) => Z(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { B as ee } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
5
5
  import { e as te, v as re, s as p, u as X, p as A, f as E } from "./bitcoin-B5aNKtsk.js";
6
- import { v as ne, P as oe, f as ae } from "./PayoutManager-BwrV3xFW.js";
7
- import { D as w, c as se, a as ie, R as ue, d as z } from "./types-CQDRQvV-.js";
8
- import { Transaction as C, Psbt as le } from "bitcoinjs-lib";
9
- import { c as ce, d as V, e as N, f as H, T as he } from "./verifyScriptPathSchnorrSignature-BKECXOpa.js";
10
- import { c as de, a as pe, b as ge } from "./noPayout-DVx3zxUz.js";
6
+ import { v as ne, s as oe, P as ae, f as se } from "./PayoutManager-BJmPnyRP.js";
7
+ import { D as w, c as ie, a as ue, R as le, d as z } from "./types-CQDRQvV-.js";
8
+ import { Transaction as S, Psbt as ce } from "bitcoinjs-lib";
9
+ import { c as he, d as I, e as N, f as H } from "./verifyScriptPathSchnorrSignature-DA4Z4yZ3.js";
10
+ import { c as de, a as pe, b as ge } from "./noPayout-CfBg3HzC.js";
11
11
  import { c as O } from "./signing-DaLvGwQe.js";
12
- const fe = /^0x[0-9a-fA-F]{64}$/, me = /^0x[0-9a-fA-F]{40}$/, Pe = /^0x([0-9a-fA-F]{2})*$/;
13
- function $(e, r) {
12
+ import { a as fe } from "./constants-BhclpREj.js";
13
+ const me = /^0x[0-9a-fA-F]{64}$/, Pe = /^0x[0-9a-fA-F]{40}$/, be = /^0x([0-9a-fA-F]{2})*$/;
14
+ function V(e, t) {
14
15
  if (e.length !== 66)
15
16
  throw new Error(
16
- `${r} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
17
+ `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
17
18
  );
18
- if (!fe.test(e))
19
+ if (!me.test(e))
19
20
  throw new Error(
20
- `${r} must contain only hex characters after the 0x prefix`
21
+ `${t} must contain only hex characters after the 0x prefix`
21
22
  );
22
23
  }
23
- function be(e, r) {
24
- if (!me.test(e))
24
+ function ye(e, t) {
25
+ if (!Pe.test(e))
25
26
  throw new Error(
26
- `${r} must be a 20-byte 0x-prefixed hex address (42 chars)`
27
+ `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
27
28
  );
28
29
  }
29
- function ye(e, r) {
30
- if (!Pe.test(e))
30
+ function we(e, t) {
31
+ if (!be.test(e))
31
32
  throw new Error(
32
- `${r} must be a 0x-prefixed hex string with an even number of hex chars`
33
+ `${t} must be a 0x-prefixed hex string with an even number of hex chars`
33
34
  );
34
35
  }
35
- async function it(e) {
36
+ async function ut(e) {
36
37
  const {
37
- btcVaultRegistryAddress: r,
38
- vaultId: t,
38
+ btcVaultRegistryAddress: t,
39
+ vaultId: r,
39
40
  hashlock: n,
40
41
  activationMetadata: s,
41
- writeContract: u,
42
+ writeContract: l,
42
43
  signal: a
43
44
  } = e;
44
- a == null || a.throwIfAborted(), be(r, "btcVaultRegistryAddress"), $(t, "vaultId");
45
+ a == null || a.throwIfAborted(), ye(t, "btcVaultRegistryAddress"), V(r, "vaultId");
45
46
  const i = te(e.secret);
46
- if ($(i, "secret"), n !== void 0 && ($(n, "hashlock"), !ne(i, n)))
47
+ if (V(i, "secret"), n !== void 0 && (V(n, "hashlock"), !ne(i, n)))
47
48
  throw new Error(
48
49
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
49
50
  );
50
- return ye(s, "activationMetadata"), u({
51
- address: r,
51
+ return we(s, "activationMetadata"), l({
52
+ address: t,
52
53
  abi: ee,
53
54
  functionName: "activateVaultWithSecret",
54
- args: [t, i, s]
55
+ args: [r, i, s]
55
56
  });
56
57
  }
57
- const we = 1e4;
58
+ const xe = 1e4;
58
59
  async function G(e) {
59
60
  const {
60
- statusReader: r,
61
- peginTxid: t,
61
+ statusReader: t,
62
+ peginTxid: r,
62
63
  targetStatuses: n,
63
64
  timeoutMs: s,
64
- pollIntervalMs: u = we,
65
+ pollIntervalMs: l = xe,
65
66
  signal: a
66
67
  } = e, i = Date.now();
67
68
  for (; ; ) {
68
69
  if (a != null && a.aborted)
69
70
  throw new Error(
70
- `Polling aborted for pegin ${t.slice(0, 8)}… (target: ${[...n].join(", ")})`
71
+ `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
71
72
  );
72
73
  if (Date.now() - i >= s)
73
74
  throw new Error(
74
- `Polling timeout after ${s}ms for pegin ${t.slice(0, 8)}… (target: ${[...n].join(", ")})`
75
+ `Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
75
76
  );
76
77
  try {
77
- const o = await r.getPeginStatus(
78
- { pegin_txid: t },
78
+ const o = await t.getPeginStatus(
79
+ { pegin_txid: r },
79
80
  a
80
81
  );
81
- if (o.pegin_txid.toLowerCase() !== t.toLowerCase())
82
+ if (o.pegin_txid.toLowerCase() !== r.toLowerCase())
82
83
  throw new Error(
83
- `getPeginStatus returned status for pegin ${o.pegin_txid.slice(0, 8)}…, requested ${t.slice(0, 8)}…`
84
+ `getPeginStatus returned status for pegin ${o.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
84
85
  );
85
- const l = o.status;
86
- if (n.has(l) || l === w.ACTIVATED)
87
- return l;
88
- if (l === w.EXPIRED || se.has(l))
86
+ const u = o.status;
87
+ if (n.has(u) || u === w.ACTIVATED)
88
+ return u;
89
+ if (u === w.EXPIRED || ie.has(u))
89
90
  throw new Error(
90
- `Pegin ${t.slice(0, 8)}… reached terminal status "${l}" while waiting for ${[...n].join(", ")}`
91
+ `Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...n].join(", ")}`
91
92
  );
92
93
  } catch (o) {
93
- if (!(o instanceof ie && o.code === ue.PEGIN_NOT_FOUND))
94
+ if (!(o instanceof ue && o.code === le.PEGIN_NOT_FOUND))
94
95
  throw o;
95
96
  }
96
- await new Promise((o, l) => {
97
+ await new Promise((o, u) => {
97
98
  const h = () => {
98
- clearTimeout(c), l(
99
+ clearTimeout(c), u(
99
100
  new Error(
100
- `Polling aborted for pegin ${t.slice(0, 8)}… (target: ${[...n].join(", ")})`
101
+ `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
101
102
  )
102
103
  );
103
104
  }, c = setTimeout(() => {
104
105
  a == null || a.removeEventListener("abort", h), o();
105
- }, u);
106
+ }, l);
106
107
  a == null || a.addEventListener("abort", h, { once: !0 });
107
108
  });
108
109
  }
109
110
  }
110
- const xe = 300 * 1e3, ve = /* @__PURE__ */ new Set([
111
+ const ve = 300 * 1e3, Ee = /* @__PURE__ */ new Set([
111
112
  w.PENDING_DEPOSITOR_WOTS_PK,
112
113
  ...z
113
114
  ]);
114
- async function ut(e) {
115
+ async function lt(e) {
115
116
  const {
116
- statusReader: r,
117
- wotsSubmitter: t,
117
+ statusReader: t,
118
+ wotsSubmitter: r,
118
119
  peginTxid: n,
119
120
  depositorPk: s,
120
- wotsPublicKeys: u,
121
- timeoutMs: a = xe,
121
+ wotsPublicKeys: l,
122
+ timeoutMs: a = ve,
122
123
  signal: i
123
124
  } = e;
124
125
  i == null || i.throwIfAborted();
125
126
  const o = await G({
126
- statusReader: r,
127
+ statusReader: t,
127
128
  peginTxid: n,
128
- targetStatuses: ve,
129
+ targetStatuses: Ee,
129
130
  timeoutMs: a,
130
131
  signal: i
131
132
  });
132
- z.has(o) || (i == null || i.throwIfAborted(), await t.submitDepositorWotsKey(
133
+ z.has(o) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
133
134
  {
134
135
  pegin_txid: n,
135
136
  depositor_pk: s,
136
- wots_public_keys: u
137
+ wots_public_keys: l
137
138
  },
138
139
  i
139
140
  ));
140
141
  }
141
- const K = 1, Ee = 1;
142
- function Te(e, r) {
143
- const t = p(r).toLowerCase(), s = e.map((u) => p(u).toLowerCase()).filter((u) => u !== t);
142
+ const K = 1, Te = 1;
143
+ function ke(e, t) {
144
+ const r = p(t).toLowerCase(), s = e.map((l) => p(l).toLowerCase()).filter((l) => l !== r);
144
145
  if (s.length === 0)
145
146
  throw new Error(
146
147
  "Cannot derive localChallengers: vault keeper set is empty (or contains only the depositor)"
@@ -151,155 +152,156 @@ function Te(e, r) {
151
152
  );
152
153
  return s;
153
154
  }
154
- function ke(e, r, t) {
155
- const n = t.map(
155
+ function _e(e, t, r) {
156
+ const n = r.map(
156
157
  (c) => p(c).toLowerCase()
157
- ), s = r.filter((c) => n.includes(c));
158
+ ), s = t.filter((c) => n.includes(c));
158
159
  if (s.length > 0)
159
160
  throw new Error(
160
161
  `Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
161
162
  );
162
- const u = [...r, ...n], a = e.map(
163
+ const l = [...t, ...n], a = e.map(
163
164
  (c) => p(c.challenger_pubkey).toLowerCase()
164
165
  ), i = new Set(a);
165
166
  if (i.size !== a.length)
166
167
  throw new Error(
167
168
  "Depositor graph contains duplicate challenger entries in challenger_presign_data"
168
169
  );
169
- const o = new Set(u), l = u.filter((c) => !i.has(c)), h = a.filter((c) => !o.has(c));
170
- if (l.length > 0 || h.length > 0)
170
+ const o = new Set(l), u = l.filter((c) => !i.has(c)), h = a.filter((c) => !o.has(c));
171
+ if (u.length > 0 || h.length > 0)
171
172
  throw new Error(
172
- "Depositor graph challenger set does not match expected (local ∪ universal)" + (l.length > 0 ? ` (missing: ${l.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
173
+ "Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
173
174
  );
174
175
  }
175
- function _e(e, r) {
176
- const t = e.ins[r];
177
- return X(new Uint8Array(t.hash).slice().reverse());
176
+ function Ce(e, t) {
177
+ const r = e.ins[t];
178
+ return X(new Uint8Array(r.hash).slice().reverse());
178
179
  }
179
- function B(e, r, t, n, s) {
180
- const u = e.ins[r];
181
- if (u.index !== 0)
180
+ function R(e, t, r, n, s) {
181
+ const l = e.ins[t];
182
+ if (l.index !== 0)
182
183
  throw new Error(
183
- `NoPayout (challenger ${s}) input ${r} expected to spend ${n} vout 0, got vout ${u.index}`
184
+ `NoPayout (challenger ${s}) input ${t} expected to spend ${n} vout 0, got vout ${l.index}`
184
185
  );
185
- const a = t.getId(), i = _e(e, r);
186
+ const a = r.getId(), i = Ce(e, t);
186
187
  if (i !== a)
187
188
  throw new Error(
188
- `NoPayout (challenger ${s}) input ${r} does not reference ${n} (expected txid ${a}, got ${i})`
189
+ `NoPayout (challenger ${s}) input ${t} does not reference ${n} (expected txid ${a}, got ${i})`
189
190
  );
190
191
  }
191
- async function Se(e, r, t) {
192
- const n = [], s = [], u = [], a = Te(
193
- t.vaultKeeperBtcPubkeys,
194
- t.depositorBtcPubkey
192
+ async function Se(e, t, r) {
193
+ const n = [], s = [], l = [], a = ke(
194
+ r.vaultKeeperBtcPubkeys,
195
+ r.depositorBtcPubkey
195
196
  );
196
- ke(
197
+ _e(
197
198
  e.challenger_presign_data,
198
199
  a,
199
- t.universalChallengerBtcPubkeys
200
+ r.universalChallengerBtcPubkeys
200
201
  );
201
- const i = await ce({
202
+ const i = await he({
203
+ vaultCoreVersion: r.vaultCoreVersion,
202
204
  payoutTxHex: e.payout_tx.tx_hex,
203
- peginTxHex: t.peginTxHex,
205
+ peginTxHex: r.peginTxHex,
204
206
  assertTxHex: e.assert_tx.tx_hex,
205
- depositorBtcPubkey: t.depositorBtcPubkey,
206
- vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
207
- vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
208
- universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
209
- timelockPegin: t.timelockPegin,
210
- network: t.network,
211
- claimerBtcPubkey: t.depositorBtcPubkey,
212
- registeredPayoutScriptPubKey: t.registeredPayoutScriptPubKey,
213
- commissionBps: Ee
207
+ depositorBtcPubkey: r.depositorBtcPubkey,
208
+ vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
209
+ vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
210
+ universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
211
+ timelockPegin: r.timelockPegin,
212
+ network: r.network,
213
+ claimerBtcPubkey: r.depositorBtcPubkey,
214
+ registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
215
+ commissionBps: Te
214
216
  });
215
217
  n.push(i.psbtHex), s.push(
216
218
  O(
217
- r,
219
+ t,
218
220
  K
219
221
  )
220
222
  );
221
- const o = p(t.depositorBtcPubkey), l = C.fromHex(
223
+ const o = p(r.depositorBtcPubkey), u = S.fromHex(
222
224
  p(e.assert_tx.tx_hex)
223
225
  );
224
226
  for (const h of e.challenger_presign_data) {
225
- const c = p(h.challenger_pubkey), d = n.length, P = await Ce({
227
+ const c = p(h.challenger_pubkey), d = n.length, P = await Ae({
226
228
  challenger: h,
227
229
  challengerPubkey: c,
228
230
  claimerPubkey: o,
229
231
  localChallengers: a,
230
- assertTxParsed: l,
231
- ctx: t
232
+ assertTxParsed: u,
233
+ ctx: r
232
234
  });
233
235
  n.push(P), s.push(
234
236
  O(
235
- r,
237
+ t,
236
238
  K
237
239
  )
238
- ), u.push({
240
+ ), l.push({
239
241
  challengerPubkey: c,
240
242
  noPayoutIdx: d
241
243
  });
242
244
  }
243
- return { psbtHexes: n, signOptions: s, challengerEntries: u };
245
+ return { psbtHexes: n, signOptions: s, challengerEntries: l };
244
246
  }
245
- async function Ce(e) {
247
+ async function Ae(e) {
246
248
  const {
247
- challenger: r,
248
- challengerPubkey: t,
249
+ challenger: t,
250
+ challengerPubkey: r,
249
251
  claimerPubkey: n,
250
252
  localChallengers: s,
251
- assertTxParsed: u,
253
+ assertTxParsed: l,
252
254
  ctx: a
253
255
  } = e;
254
256
  de(
255
- r.nopayout_tx.tx_hex,
256
- t,
257
+ t.nopayout_tx.tx_hex,
258
+ r,
257
259
  a.network
258
260
  );
259
- const i = C.fromHex(
260
- p(r.nopayout_tx.tx_hex)
261
- ), o = C.fromHex(
262
- p(r.challenge_assert_x_tx.tx_hex)
263
- ), l = C.fromHex(
264
- p(r.challenge_assert_y_tx.tx_hex)
261
+ const i = S.fromHex(
262
+ p(t.nopayout_tx.tx_hex)
263
+ ), o = S.fromHex(
264
+ p(t.challenge_assert_x_tx.tx_hex)
265
+ ), u = S.fromHex(
266
+ p(t.challenge_assert_y_tx.tx_hex)
265
267
  );
266
268
  if (i.ins.length !== 3)
267
269
  throw new Error(
268
- `NoPayout (challenger ${t}) must have exactly 3 inputs, got ${i.ins.length}`
270
+ `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
269
271
  );
270
- B(
272
+ R(
271
273
  i,
272
274
  0,
273
- u,
275
+ l,
274
276
  "Assert",
275
- t
276
- ), B(
277
+ r
278
+ ), R(
277
279
  i,
278
280
  1,
279
281
  o,
280
282
  "ChallengeAssertX",
281
- t
282
- ), B(
283
+ r
284
+ ), R(
283
285
  i,
284
286
  2,
285
- l,
287
+ u,
286
288
  "ChallengeAssertY",
287
- t
289
+ r
288
290
  );
289
291
  const h = [
290
- u.outs[0],
292
+ l.outs[0],
291
293
  o.outs[0],
292
- l.outs[0]
294
+ u.outs[0]
293
295
  ].map((c) => ({
294
296
  script_pubkey: X(new Uint8Array(c.script)),
295
297
  value: c.value
296
298
  }));
297
299
  return pe({
298
- noPayoutTxHex: r.nopayout_tx.tx_hex,
299
- challengerPubkey: t,
300
+ noPayoutTxHex: t.nopayout_tx.tx_hex,
301
+ challengerPubkey: r,
300
302
  prevouts: h,
301
303
  connectorParams: {
302
- txGraphVersion: he,
304
+ txGraphVersion: a.vaultCoreVersion,
303
305
  claimer: n,
304
306
  localChallengers: s,
305
307
  universalChallengers: a.universalChallengerBtcPubkeys,
@@ -309,31 +311,31 @@ async function Ce(e) {
309
311
  }
310
312
  });
311
313
  }
312
- function Ae(e, r, t) {
313
- V(e[0]);
314
+ function $e(e, t, r) {
315
+ I(e[0]);
314
316
  const s = N(
315
317
  e[0].returnedPsbtHex,
316
- t
318
+ r
317
319
  );
318
320
  H({
319
321
  requestedPsbtHex: e[0].requestedPsbtHex,
320
322
  signatureHex: s,
321
- signerXOnlyPubkeyHex: t,
323
+ signerXOnlyPubkeyHex: r,
322
324
  inputIndex: 0
323
325
  });
324
- const u = {};
325
- for (const a of r) {
326
- V(e[a.noPayoutIdx]);
326
+ const l = {};
327
+ for (const a of t) {
328
+ I(e[a.noPayoutIdx]);
327
329
  const i = N(
328
330
  e[a.noPayoutIdx].returnedPsbtHex,
329
- t
331
+ r
330
332
  );
331
333
  H({
332
334
  requestedPsbtHex: e[a.noPayoutIdx].requestedPsbtHex,
333
335
  signatureHex: i,
334
- signerXOnlyPubkeyHex: t,
336
+ signerXOnlyPubkeyHex: r,
335
337
  inputIndex: 0
336
- }), u[a.challengerPubkey] = {
338
+ }), l[a.challengerPubkey] = {
337
339
  nopayout_signature: i
338
340
  };
339
341
  }
@@ -341,69 +343,56 @@ function Ae(e, r, t) {
341
343
  payout_signatures: {
342
344
  payout_signature: s
343
345
  },
344
- per_challenger: u
346
+ per_challenger: l
345
347
  };
346
348
  }
347
- async function Re(e, r, t) {
348
- if (typeof e.signPsbts == "function")
349
- return e.signPsbts(r, t);
350
- const n = [];
351
- for (let s = 0; s < r.length; s++)
352
- n.push(await e.signPsbt(r[s], t == null ? void 0 : t[s]));
353
- return n;
354
- }
355
- async function $e(e) {
356
- const { depositorGraph: r, btcWallet: t, signingContext: n } = e, s = await t.getPublicKeyHex(), { depositorPubkey: u } = re(
349
+ async function Ve(e) {
350
+ const { depositorGraph: t, btcWallet: r, signingContext: n } = e, s = await r.getPublicKeyHex(), { depositorPubkey: l } = re(
357
351
  s,
358
352
  p(n.depositorBtcPubkey)
359
353
  ), { psbtHexes: a, signOptions: i, challengerEntries: o } = await Se(
360
- r,
354
+ t,
361
355
  s,
362
356
  n
363
- ), l = await Re(
364
- t,
357
+ ), u = await oe(
358
+ r,
365
359
  a,
366
360
  i
367
- );
368
- if (l.length !== a.length)
369
- throw new Error(
370
- `Wallet returned ${l.length} signed PSBTs, expected ${a.length}`
371
- );
372
- const h = a.map((c, d) => ({
361
+ ), h = a.map((c, d) => ({
373
362
  requestedPsbtHex: c,
374
- returnedPsbtHex: l[d]
363
+ returnedPsbtHex: u[d]
375
364
  }));
376
- return Ae(
365
+ return $e(
377
366
  h,
378
367
  o,
379
- u
368
+ l
380
369
  );
381
370
  }
382
- const Be = 1200 * 1e3, q = /* @__PURE__ */ new Set([
371
+ const Re = 1200 * 1e3, q = /* @__PURE__ */ new Set([
383
372
  w.PENDING_ACKS,
384
373
  w.PENDING_ACTIVATION,
385
374
  w.ACTIVATED_PENDING_BROADCAST,
386
375
  w.ACTIVATED
387
- ]), Ie = /* @__PURE__ */ new Set([
376
+ ]), Be = /* @__PURE__ */ new Set([
388
377
  w.PENDING_DEPOSITOR_SIGNATURES,
389
378
  ...q
390
379
  ]);
391
- function Ve(e) {
392
- return e.map((r) => ({
393
- claimerPubkeyXOnly: A(r.claimer_pubkey),
394
- payoutTxHex: r.payout_tx.tx_hex,
395
- assertTxHex: r.assert_tx.tx_hex
380
+ function Ie(e) {
381
+ return e.map((t) => ({
382
+ claimerPubkeyXOnly: A(t.claimer_pubkey),
383
+ payoutTxHex: t.payout_tx.tx_hex,
384
+ assertTxHex: t.assert_tx.tx_hex
396
385
  }));
397
386
  }
398
387
  function _(e) {
399
388
  return A(e).toLowerCase();
400
389
  }
401
- function Ne(e, r, t, n) {
402
- const s = _(n), u = [
403
- _(r),
404
- ...t.map(_)
405
- ], a = new Set(u);
406
- if (a.size !== u.length)
390
+ function Ne(e, t, r, n) {
391
+ const s = _(n), l = [
392
+ _(t),
393
+ ...r.map(_)
394
+ ], a = new Set(l);
395
+ if (a.size !== l.length)
407
396
  throw new Error(
408
397
  "Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
409
398
  );
@@ -418,106 +407,108 @@ function Ne(e, r, t, n) {
418
407
  throw new Error(
419
408
  "Presign response contains duplicate claimer entries"
420
409
  );
421
- const o = i.filter((d) => d !== s), l = new Set(o), h = u.filter((d) => !l.has(d)), c = o.filter((d) => !a.has(d));
410
+ const o = i.filter((d) => d !== s), u = new Set(o), h = l.filter((d) => !u.has(d)), c = o.filter((d) => !a.has(d));
422
411
  if (h.length > 0 || c.length > 0)
423
412
  throw new Error(
424
413
  "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (h.length > 0 ? ` (missing: ${h.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
425
414
  );
426
415
  }
427
- function U(e, r) {
416
+ function U(e, t) {
428
417
  return {
418
+ vaultCoreVersion: t.vaultCoreVersion,
429
419
  payoutTxHex: e.payoutTxHex,
430
- peginTxHex: r.peginTxHex,
420
+ peginTxHex: t.peginTxHex,
431
421
  assertTxHex: e.assertTxHex,
432
- vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
433
- vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
434
- universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
435
- depositorBtcPubkey: r.depositorBtcPubkey,
436
- timelockPegin: r.timelockPegin,
437
- registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
422
+ vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
423
+ vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
424
+ universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
425
+ depositorBtcPubkey: t.depositorBtcPubkey,
426
+ timelockPegin: t.timelockPegin,
427
+ registeredPayoutScriptPubKey: t.registeredPayoutScriptPubKey,
438
428
  claimerBtcPubkey: e.claimerPubkeyXOnly,
439
- commissionBps: r.commissionBps
429
+ commissionBps: t.commissionBps
440
430
  };
441
431
  }
442
- async function He(e, r, t, n) {
443
- const s = new oe({
444
- network: r.network,
432
+ async function He(e, t, r, n) {
433
+ const s = new ae({
434
+ network: t.network,
445
435
  btcWallet: e
446
- }), u = t.length;
447
- n == null || n(0, u);
436
+ }), l = r.length;
437
+ n == null || n(0, l);
448
438
  let a;
449
439
  if (s.supportsBatchSigning())
450
440
  a = (await s.signPayoutTransactionsBatch(
451
- t.map((l) => U(l, r))
452
- )).map((l) => l.payoutSignature);
441
+ r.map((u) => U(u, t))
442
+ )).map((u) => u.payoutSignature);
453
443
  else {
454
444
  a = [];
455
- for (let o = 0; o < t.length; o++) {
456
- n == null || n(o, u);
457
- const l = await s.signPayoutTransaction(
458
- U(t[o], r)
445
+ for (let o = 0; o < r.length; o++) {
446
+ n == null || n(o, l);
447
+ const u = await s.signPayoutTransaction(
448
+ U(r[o], t)
459
449
  );
460
- a.push(l.signature);
450
+ a.push(u.signature);
461
451
  }
462
452
  }
463
453
  const i = {};
464
- for (let o = 0; o < t.length; o++)
465
- i[t[o].claimerPubkeyXOnly] = {
454
+ for (let o = 0; o < r.length; o++)
455
+ i[r[o].claimerPubkeyXOnly] = {
466
456
  payout_signature: a[o]
467
457
  };
468
- return n == null || n(u, u), i;
458
+ return n == null || n(l, l), i;
469
459
  }
470
- async function lt(e) {
460
+ async function ct(e) {
471
461
  const {
472
- statusReader: r,
473
- presignClient: t,
462
+ statusReader: t,
463
+ presignClient: r,
474
464
  btcWallet: n,
475
465
  peginTxid: s,
476
- depositorPk: u,
466
+ depositorPk: l,
477
467
  signingContext: a,
478
- timeoutMs: i = Be,
468
+ timeoutMs: i = Re,
479
469
  signal: o,
480
- onProgress: l
470
+ onProgress: u
481
471
  } = e, h = await G({
482
- statusReader: r,
472
+ statusReader: t,
483
473
  peginTxid: s,
484
- targetStatuses: Ie,
474
+ targetStatuses: Be,
485
475
  timeoutMs: i,
486
476
  signal: o
487
477
  });
488
478
  if (q.has(h))
489
479
  return;
490
480
  o == null || o.throwIfAborted();
491
- const c = await t.requestDepositorPresignTransactions(
481
+ const c = await r.requestDepositorPresignTransactions(
492
482
  {
493
483
  pegin_txid: s,
494
- depositor_pk: u
484
+ depositor_pk: l
495
485
  },
496
486
  o
497
487
  );
498
488
  o == null || o.throwIfAborted();
499
- const d = _(u);
489
+ const d = _(l);
500
490
  Ne(
501
491
  c.txs,
502
492
  a.vaultProviderBtcPubkey,
503
493
  a.vaultKeeperBtcPubkeys,
504
- u
494
+ l
505
495
  );
506
496
  const P = c.txs.filter(
507
497
  (v) => _(v.claimer_pubkey) !== d
508
- ), m = Ve(P), y = await He(
498
+ ), m = Ie(P), y = await He(
509
499
  n,
510
500
  a,
511
501
  m,
512
- l
502
+ u
513
503
  );
514
504
  o == null || o.throwIfAborted();
515
- const x = await $e({
505
+ const x = await Ve({
516
506
  depositorGraph: c.depositor_graph,
517
507
  btcWallet: n,
518
508
  signingContext: {
509
+ vaultCoreVersion: a.vaultCoreVersion,
519
510
  peginTxHex: a.peginTxHex,
520
- depositorBtcPubkey: u,
511
+ depositorBtcPubkey: l,
521
512
  vaultProviderBtcPubkey: a.vaultProviderBtcPubkey,
522
513
  vaultKeeperBtcPubkeys: a.vaultKeeperBtcPubkeys,
523
514
  universalChallengerBtcPubkeys: a.universalChallengerBtcPubkeys,
@@ -531,10 +522,10 @@ async function lt(e) {
531
522
  });
532
523
  o == null || o.throwIfAborted();
533
524
  const b = { ...y };
534
- b[p(u)] = x.payout_signatures, await t.submitDepositorPresignatures(
525
+ b[p(l)] = x.payout_signatures, await r.submitDepositorPresignatures(
535
526
  {
536
527
  pegin_txid: s,
537
- depositor_pk: u,
528
+ depositor_pk: l,
538
529
  signatures: b,
539
530
  depositor_claimer_presignatures: x
540
531
  },
@@ -544,56 +535,56 @@ async function lt(e) {
544
535
  function Oe(e) {
545
536
  return /^[0-9a-fA-F]{64}$/.test(e);
546
537
  }
547
- function ct(e) {
538
+ function ht(e) {
548
539
  const {
549
- amountSats: r,
550
- minDeposit: t,
540
+ amountSats: t,
541
+ minDeposit: r,
551
542
  maxDeposit: n,
552
543
  btcBalance: s,
553
- estimatedFeeSats: u,
544
+ estimatedFeeSats: l,
554
545
  depositorClaimValue: a
555
546
  } = e;
556
- return !(r <= 0n || r < t || n && n > 0n && r > n || u == null || a == null || r + u + a > s);
547
+ return !(t <= 0n || t < r || n && n > 0n && t > n || l == null || a == null || t + l + a > s);
557
548
  }
558
- function ht(e, r, t) {
549
+ function dt(e, t, r) {
559
550
  return e <= 0n ? {
560
551
  valid: !1,
561
552
  error: "Deposit amount must be greater than zero"
562
- } : e < r ? {
553
+ } : e < t ? {
563
554
  valid: !1,
564
- error: `Minimum deposit is ${E(r)} BTC`
565
- } : t && t > 0n && e > t ? {
555
+ error: `Minimum deposit is ${E(t)} BTC`
556
+ } : r && r > 0n && e > r ? {
566
557
  valid: !1,
567
- error: `Maximum deposit is ${E(t)} BTC`
558
+ error: `Maximum deposit is ${E(r)} BTC`
568
559
  } : { valid: !0 };
569
560
  }
570
- function dt(e) {
571
- const { amount: r, effectiveRemaining: t } = e;
572
- return t === null ? { valid: !0 } : t === 0n ? {
561
+ function pt(e) {
562
+ const { amount: t, effectiveRemaining: r } = e;
563
+ return r === null ? { valid: !0 } : r === 0n ? {
573
564
  valid: !1,
574
565
  error: "Supply cap reached — deposits temporarily paused"
575
- } : r > t ? {
566
+ } : t > r ? {
576
567
  valid: !1,
577
- error: `Vault size exceeds remaining capacity (${E(t)} BTC)`
568
+ error: `Vault size exceeds remaining capacity (${E(r)} BTC)`
578
569
  } : { valid: !0 };
579
570
  }
580
- function pt(e, r) {
571
+ function gt(e, t) {
581
572
  if (!e || e.length === 0)
582
573
  return {
583
574
  valid: !1,
584
575
  error: "At least one vault provider must be selected"
585
576
  };
586
- const t = r.map(
577
+ const r = t.map(
587
578
  (s) => s.toLowerCase()
588
579
  );
589
580
  return e.filter(
590
- (s) => !t.includes(s.toLowerCase())
581
+ (s) => !r.includes(s.toLowerCase())
591
582
  ).length > 0 ? {
592
583
  valid: !1,
593
584
  error: "Invalid vault provider selected"
594
585
  } : { valid: !0 };
595
586
  }
596
- function De(e, r, t) {
587
+ function De(e, t, r) {
597
588
  if (!e || e.length === 0)
598
589
  return {
599
590
  valid: !1,
@@ -606,22 +597,22 @@ function De(e, r, t) {
606
597
  valid: !1,
607
598
  error: `Vault ${n + 1} amount must be positive`
608
599
  };
609
- if (r && s < r)
600
+ if (t && s < t)
610
601
  return {
611
602
  valid: !1,
612
- error: `Vault ${n + 1} amount ${E(s)} BTC is below minimum deposit ${E(r)} BTC`
603
+ error: `Vault ${n + 1} amount ${E(s)} BTC is below minimum deposit ${E(t)} BTC`
613
604
  };
614
- if (t && s > t)
605
+ if (r && s > r)
615
606
  return {
616
607
  valid: !1,
617
- error: `Vault ${n + 1} amount ${E(s)} BTC exceeds maximum deposit ${E(t)} BTC`
608
+ error: `Vault ${n + 1} amount ${E(s)} BTC exceeds maximum deposit ${E(r)} BTC`
618
609
  };
619
610
  }
620
611
  return { valid: !0 };
621
612
  }
622
613
  function Ke(e) {
623
- const r = p(e);
624
- return Oe(r) ? { valid: !0 } : {
614
+ const t = p(e);
615
+ return Oe(t) ? { valid: !0 } : {
625
616
  valid: !1,
626
617
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
627
618
  };
@@ -642,74 +633,74 @@ function Me(e) {
642
633
  if (e.length === 0)
643
634
  throw new Error("No spendable UTXOs available");
644
635
  }
645
- function gt(e) {
636
+ function ft(e) {
646
637
  const {
647
- vaultAmounts: r,
648
- confirmedUTXOs: t,
638
+ vaultAmounts: t,
639
+ confirmedUTXOs: r,
649
640
  vaultProviderBtcPubkey: n,
650
641
  vaultKeeperBtcPubkeys: s,
651
- universalChallengerBtcPubkeys: u,
642
+ universalChallengerBtcPubkeys: l,
652
643
  minDeposit: a,
653
644
  maxDeposit: i
654
645
  } = e, o = De(
655
- r,
646
+ t,
656
647
  a,
657
648
  i
658
649
  );
659
650
  if (!o.valid)
660
651
  throw new Error(o.error);
661
- const l = Ke(n);
662
- if (!l.valid)
663
- throw new Error(l.error);
664
- Ue(s), Fe(u), Me(t);
652
+ const u = Ke(n);
653
+ if (!u.valid)
654
+ throw new Error(u.error);
655
+ Ue(s), Fe(l), Me(r);
665
656
  }
666
- async function ft(e) {
657
+ async function mt(e) {
667
658
  const {
668
- vaultRegistryReader: r,
669
- vaultKeeperReader: t,
659
+ vaultRegistryReader: t,
660
+ vaultKeeperReader: r,
670
661
  universalChallengerReader: n,
671
662
  vaultProviderEthAddress: s,
672
- applicationEntryPoint: u,
663
+ applicationEntryPoint: l,
673
664
  expectedVaultProviderBtcPubkey: a,
674
665
  expectedVaultKeeperBtcPubkeys: i,
675
666
  expectedUniversalChallengerBtcPubkeys: o
676
667
  } = e, [
677
- l,
668
+ u,
678
669
  h,
679
670
  c
680
671
  ] = await Promise.all([
681
- r.getVaultProviderBtcPubKey(s),
682
- t.getCurrentVaultKeepersVersion(u),
672
+ t.getVaultProviderBtcPubKey(s),
673
+ r.getCurrentVaultKeepersVersion(l),
683
674
  n.getLatestUniversalChallengersVersion()
684
675
  ]), [d, P] = await Promise.all([
685
- t.getVaultKeepersByVersion(
686
- u,
676
+ r.getVaultKeepersByVersion(
677
+ l,
687
678
  h
688
679
  ),
689
680
  n.getUniversalChallengersByVersion(
690
681
  c
691
682
  )
692
683
  ]), m = (g) => A(g).toLowerCase(), y = (g) => g.map(m).sort();
693
- if (m(a) !== l)
684
+ if (m(a) !== u)
694
685
  throw new Error(
695
686
  `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
696
687
  );
697
688
  const b = y(i), v = y(
698
689
  d.map((g) => g.btcPubKey)
699
690
  );
700
- if (b.length !== v.length || b.some((g, S) => g !== v[S]))
691
+ if (b.length !== v.length || b.some((g, C) => g !== v[C]))
701
692
  throw new Error(
702
693
  `Vault keeper BTC pubkeys (v${h}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
703
694
  );
704
695
  const T = y(o), k = y(
705
696
  P.map((g) => g.btcPubKey)
706
697
  );
707
- if (T.length !== k.length || T.some((g, S) => g !== k[S]))
698
+ if (T.length !== k.length || T.some((g, C) => g !== k[C]))
708
699
  throw new Error(
709
700
  `Universal challenger BTC pubkeys (v${c}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
710
701
  );
711
702
  return {
712
- vaultProviderBtcPubkeyXOnly: l,
703
+ vaultProviderBtcPubkeyXOnly: u,
713
704
  vaultKeeperBtcPubkeysSorted: v,
714
705
  universalChallengerBtcPubkeysSorted: k,
715
706
  expectedAppVaultKeepersVersion: h,
@@ -717,33 +708,36 @@ async function ft(e) {
717
708
  };
718
709
  }
719
710
  class j extends Error {
720
- constructor(r) {
721
- super(r), this.name = "RegisteredVaultVersionMismatchError";
711
+ constructor(t) {
712
+ super(t), this.name = "RegisteredVaultVersionMismatchError";
722
713
  }
723
714
  }
724
- function mt(e) {
715
+ function Pt(e) {
725
716
  return e instanceof j || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
726
717
  }
727
- async function Pt(e) {
718
+ async function bt(e) {
728
719
  const {
729
- vaultRegistryReader: r,
730
- vaultIds: t,
720
+ vaultRegistryReader: t,
721
+ vaultIds: r,
731
722
  expectedOffchainParamsVersion: n,
732
723
  expectedAppVaultKeepersVersion: s,
733
- expectedUniversalChallengersVersion: u
734
- } = e, a = await r.getProtocolInfoBatch(t), i = [];
735
- if (a.forEach((o, l) => {
736
- const h = t[l];
737
- o.offchainParamsVersion !== n && i.push(
738
- `vault ${h}: offchainParams expected v${n}, got v${o.offchainParamsVersion}`
739
- ), o.appVaultKeepersVersion !== s && i.push(
740
- `vault ${h}: appVaultKeepers expected v${s}, got v${o.appVaultKeepersVersion}`
741
- ), o.universalChallengersVersion !== u && i.push(
742
- `vault ${h}: universalChallengers expected v${u}, got v${o.universalChallengersVersion}`
743
- );
744
- }), i.length > 0)
724
+ expectedUniversalChallengersVersion: l,
725
+ expectedVaultCoreVersion: a
726
+ } = e, i = await t.getProtocolInfoBatch(r), o = [];
727
+ if (i.forEach((u, h) => {
728
+ const c = r[h];
729
+ u.offchainParamsVersion !== n && o.push(
730
+ `vault ${c}: offchainParams expected v${n}, got v${u.offchainParamsVersion}`
731
+ ), u.appVaultKeepersVersion !== s && o.push(
732
+ `vault ${c}: appVaultKeepers expected v${s}, got v${u.appVaultKeepersVersion}`
733
+ ), u.universalChallengersVersion !== l && o.push(
734
+ `vault ${c}: universalChallengers expected v${l}, got v${u.universalChallengersVersion}`
735
+ ), u.vaultCoreVersion !== a && o.push(
736
+ `vault ${c}: vaultCoreVersion expected v${a} (build-time active), got v${u.vaultCoreVersion}`
737
+ );
738
+ }), o.length > 0)
745
739
  throw new j(
746
- `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${i.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
740
+ `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${o.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
747
741
  );
748
742
  }
749
743
  var Q = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(Q || {});
@@ -752,44 +746,44 @@ const Le = /* @__PURE__ */ new Set([
752
746
  "PayoutBlocked"
753
747
  /* PAYOUT_BLOCKED */
754
748
  ]);
755
- function bt(e) {
749
+ function yt(e) {
756
750
  return Object.values(Q).includes(
757
751
  e
758
752
  );
759
753
  }
760
- function yt(e) {
754
+ function wt(e) {
761
755
  return !!e && Le.has(e);
762
756
  }
763
757
  class Xe extends Error {
764
- constructor(t, n) {
758
+ constructor(r, n) {
765
759
  super(`Refund not yet mature (BIP68 not final): ${n.message}`);
766
- R(this, "vaultId");
767
- R(this, "cause");
768
- this.name = "BIP68NotMatureError", this.vaultId = t, this.cause = n;
760
+ $(this, "vaultId");
761
+ $(this, "cause");
762
+ this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
769
763
  }
770
764
  }
771
- const ze = /^0x[0-9a-fA-F]{64}$/, Ge = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, W = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Y = 160, F = 2e3, M = 10n, L = 100n;
772
- function wt(e) {
765
+ const ze = /^0x[0-9a-fA-F]{64}$/, Ge = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Y = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, W = 160, F = 2e3, M = 10n, L = 100n;
766
+ function xt(e) {
773
767
  if (!Number.isFinite(e) || e <= 0)
774
768
  throw new Error(
775
769
  `feeRateSatsVb must be a positive finite number, got ${e}`
776
770
  );
777
- return BigInt(Math.ceil(e * Y));
771
+ return BigInt(Math.ceil(e * W));
778
772
  }
779
773
  const qe = 1, je = /non-BIP68-final/i;
780
- function D(e, r) {
774
+ function D(e, t) {
781
775
  if (e.length !== 66)
782
776
  throw new Error(
783
- `${r} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
777
+ `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
784
778
  );
785
779
  if (!ze.test(e))
786
780
  throw new Error(
787
- `${r} must contain only hex characters after the 0x prefix`
781
+ `${t} must contain only hex characters after the 0x prefix`
788
782
  );
789
783
  }
790
- function I(e, r) {
784
+ function B(e, t) {
791
785
  if (!Number.isInteger(e) || e < 0)
792
- throw new Error(`${r} must be a non-negative integer, got ${e}`);
786
+ throw new Error(`${t} must be a non-negative integer, got ${e}`);
793
787
  }
794
788
  function Qe(e) {
795
789
  if (D(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
@@ -802,44 +796,47 @@ function Qe(e) {
802
796
  throw new Error(
803
797
  `htlcVout ${e.htlcVout} is out of range for batch of size ${e.batch.length}`
804
798
  );
805
- for (let t = 0; t < e.batch.length; t++) {
806
- const n = e.batch[t];
807
- if (D(n.hashlock, `batch[${t}].hashlock`), !Number.isInteger(n.htlcVout) || n.htlcVout !== t)
799
+ for (let r = 0; r < e.batch.length; r++) {
800
+ const n = e.batch[r];
801
+ if (D(n.hashlock, `batch[${r}].hashlock`), !Number.isInteger(n.htlcVout) || n.htlcVout !== r)
808
802
  throw new Error(
809
- `batch[${t}].htlcVout must equal ${t} (contiguous vout-ordered vector), got ${n.htlcVout}`
803
+ `batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${n.htlcVout}`
810
804
  );
811
805
  if (typeof n.amount != "bigint" || n.amount <= 0n)
812
806
  throw new Error(
813
- `batch[${t}].amount must be a positive bigint, got ${n.amount}`
807
+ `batch[${r}].amount must be a positive bigint, got ${n.amount}`
814
808
  );
815
809
  }
816
- const r = e.batch[e.htlcVout];
817
- if (r.hashlock.toLowerCase() !== e.hashlock.toLowerCase())
810
+ const t = e.batch[e.htlcVout];
811
+ if (t.hashlock.toLowerCase() !== e.hashlock.toLowerCase())
818
812
  throw new Error(
819
- `batch[${e.htlcVout}].hashlock (${r.hashlock}) does not match target hashlock (${e.hashlock})`
813
+ `batch[${e.htlcVout}].hashlock (${t.hashlock}) does not match target hashlock (${e.hashlock})`
820
814
  );
821
- if (r.amount !== e.amount)
815
+ if (t.amount !== e.amount)
822
816
  throw new Error(
823
- `batch[${e.htlcVout}].amount (${r.amount}) does not match target amount (${e.amount})`
817
+ `batch[${e.htlcVout}].amount (${t.amount}) does not match target amount (${e.amount})`
824
818
  );
825
- if (I(e.offchainParamsVersion, "offchainParamsVersion"), I(e.appVaultKeepersVersion, "appVaultKeepersVersion"), I(
819
+ if (B(e.offchainParamsVersion, "offchainParamsVersion"), B(e.appVaultKeepersVersion, "appVaultKeepersVersion"), B(
826
820
  e.universalChallengersVersion,
827
821
  "universalChallengersVersion"
822
+ ), fe(
823
+ e.vaultCoreVersion,
824
+ "VaultRefundData.vaultCoreVersion"
828
825
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
829
826
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
830
827
  if (!Ge.test(e.unsignedPrePeginTxHex))
831
828
  throw new Error(
832
829
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
833
830
  );
834
- if (!e.depositorBtcPubkey || !W.test(e.depositorBtcPubkey))
831
+ if (!e.depositorBtcPubkey || !Y.test(e.depositorBtcPubkey))
835
832
  throw new Error(
836
833
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
837
834
  );
838
835
  if (typeof e.amount != "bigint" || e.amount <= 0n)
839
836
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
840
837
  }
841
- function We(e) {
842
- if (!e.vaultProviderPubkey || !W.test(e.vaultProviderPubkey))
838
+ function Ye(e) {
839
+ if (!e.vaultProviderPubkey || !Y.test(e.vaultProviderPubkey))
843
840
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
844
841
  if (e.vaultKeeperPubkeys.length === 0)
845
842
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -864,38 +861,38 @@ function We(e) {
864
861
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
865
862
  );
866
863
  }
867
- function Ye(e) {
868
- const r = le.fromHex(e);
864
+ function We(e) {
865
+ const t = ce.fromHex(e);
869
866
  try {
870
- r.finalizeAllInputs();
871
- } catch (t) {
872
- const n = t instanceof Error ? t.message : String(t);
867
+ t.finalizeAllInputs();
868
+ } catch (r) {
869
+ const n = r instanceof Error ? r.message : String(r);
873
870
  if (!n.includes("already finalized"))
874
871
  throw new Error(`Failed to finalize refund PSBT: ${n}`);
875
872
  }
876
- return r.extractTransaction().toHex();
873
+ return t.extractTransaction().toHex();
877
874
  }
878
- async function xt(e) {
875
+ async function vt(e) {
879
876
  const {
880
- vaultId: r,
881
- readVault: t,
877
+ vaultId: t,
878
+ readVault: r,
882
879
  readPrePeginContext: n,
883
880
  feeRate: s,
884
- signPsbt: u,
881
+ signPsbt: l,
885
882
  broadcastTx: a,
886
883
  signal: i
887
884
  } = e;
888
- i == null || i.throwIfAborted(), D(r, "vaultId");
889
- const o = await t();
885
+ i == null || i.throwIfAborted(), D(t, "vaultId");
886
+ const o = await r();
890
887
  Qe(o), i == null || i.throwIfAborted();
891
- const l = await n(o);
892
- if (We(l), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
888
+ const u = await n(o);
889
+ if (Ye(u), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
893
890
  throw new Error(`feeRate must be a positive number, got ${s}`);
894
891
  if (s > F)
895
892
  throw new Error(
896
893
  `feeRate ${s} sat/vB exceeds refund safety cap ${F} sat/vB; refusing to sign refund.`
897
894
  );
898
- const h = BigInt(Math.ceil(s * Y)), c = o.amount * M / L;
895
+ const h = BigInt(Math.ceil(s * W)), c = o.amount * M / L;
899
896
  if (h > c)
900
897
  throw new Error(
901
898
  `Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${M}/${L} of vault.amount=${o.amount}); refusing to sign refund.`
@@ -903,7 +900,7 @@ async function xt(e) {
903
900
  i == null || i.throwIfAborted();
904
901
  const d = A(
905
902
  o.depositorBtcPubkey
906
- ), P = p(o.unsignedPrePeginTxHex), m = ae(P);
903
+ ), P = p(o.unsignedPrePeginTxHex), m = se(P);
907
904
  if (m !== void 0 && m.vout !== o.batch.length)
908
905
  throw new Error(
909
906
  `Auth-anchor OP_RETURN at vout ${m.vout} does not match batch size (${o.batch.length} HTLC outputs expect the anchor at vout ${o.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
@@ -911,7 +908,7 @@ async function xt(e) {
911
908
  const y = m == null ? void 0 : m.hash;
912
909
  let x;
913
910
  try {
914
- x = C.fromHex(P);
911
+ x = S.fromHex(P);
915
912
  } catch (f) {
916
913
  throw new Error(
917
914
  `Failed to parse funded Pre-PegIn transaction hex: ${f instanceof Error ? f.message : String(f)}`
@@ -923,12 +920,13 @@ async function xt(e) {
923
920
  );
924
921
  const { psbtHex: b } = await ge({
925
922
  prePeginParams: {
923
+ vaultCoreVersion: o.vaultCoreVersion,
926
924
  depositorPubkey: d,
927
- vaultProviderPubkey: p(l.vaultProviderPubkey),
928
- vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(p),
929
- universalChallengerPubkeys: l.universalChallengerPubkeys.map(p),
925
+ vaultProviderPubkey: p(u.vaultProviderPubkey),
926
+ vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(p),
927
+ universalChallengerPubkeys: u.universalChallengerPubkeys.map(p),
930
928
  hashlocks: o.batch.map((f) => p(f.hashlock)),
931
- timelockRefund: l.timelockRefund,
929
+ timelockRefund: u.timelockRefund,
932
930
  // `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
933
931
  // is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
934
932
  // reserve (`depositorClaimValue + minPeginFee`) internally when sizing the
@@ -936,12 +934,12 @@ async function xt(e) {
936
934
  // to the funded tx bytes, refusing the refund if the template's HTLC value
937
935
  // disagrees with the on-chain commitment.
938
936
  pegInAmounts: o.batch.map((f) => f.amount),
939
- feeRate: l.feeRate,
940
- minPeginFeeRate: l.minPeginFeeRate,
941
- numLocalChallengers: l.numLocalChallengers,
942
- councilQuorum: l.councilQuorum,
943
- councilSize: l.councilSize,
944
- network: l.network,
937
+ feeRate: u.feeRate,
938
+ minPeginFeeRate: u.minPeginFeeRate,
939
+ numLocalChallengers: u.numLocalChallengers,
940
+ councilQuorum: u.councilQuorum,
941
+ councilSize: u.councilSize,
942
+ network: u.network,
945
943
  authAnchorHash: y
946
944
  },
947
945
  fundedPrePeginTxHex: P,
@@ -957,8 +955,8 @@ async function xt(e) {
957
955
  const v = O(
958
956
  o.depositorBtcPubkey,
959
957
  qe
960
- ), T = await u(b, v);
961
- V({
958
+ ), T = await l(b, v);
959
+ I({
962
960
  requestedPsbtHex: b,
963
961
  returnedPsbtHex: T
964
962
  });
@@ -973,40 +971,40 @@ async function xt(e) {
973
971
  signerXOnlyPubkeyHex: d,
974
972
  inputIndex: k
975
973
  });
976
- const S = Ye(T);
974
+ const C = We(T);
977
975
  i == null || i.throwIfAborted();
978
976
  try {
979
- return await a(S);
977
+ return await a(C);
980
978
  } catch (f) {
981
- throw f instanceof Error && je.test(f.message) ? new Xe(r, f) : f;
979
+ throw f instanceof Error && je.test(f.message) ? new Xe(t, f) : f;
982
980
  }
983
981
  }
984
982
  export {
985
983
  Xe as B,
986
984
  Q as C,
987
985
  j as R,
988
- it as a,
989
- $e as b,
990
- dt as c,
991
- pt as d,
986
+ ut as a,
987
+ Ve as b,
988
+ pt as c,
989
+ gt as d,
992
990
  De as e,
993
991
  Ke as f,
994
- gt as g,
995
- ft as h,
996
- ct as i,
997
- mt as j,
998
- Pt as k,
999
- bt as l,
1000
- yt as m,
1001
- xt as n,
1002
- wt as o,
992
+ ft as g,
993
+ mt as h,
994
+ ht as i,
995
+ Pt as j,
996
+ bt as k,
997
+ yt as l,
998
+ wt as m,
999
+ vt as n,
1000
+ xt as o,
1003
1001
  L as p,
1004
1002
  M as q,
1005
- lt as r,
1006
- ut as s,
1003
+ ct as r,
1004
+ lt as s,
1007
1005
  F as t,
1008
- Y as u,
1009
- ht as v,
1006
+ W as u,
1007
+ dt as v,
1010
1008
  G as w
1011
1009
  };
1012
- //# sourceMappingURL=buildAndBroadcastRefund-BAT5A6MP.js.map
1010
+ //# sourceMappingURL=buildAndBroadcastRefund-BiSO4zg2.js.map