@babylonlabs-io/ts-sdk 0.53.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 (80) hide show
  1. package/dist/{PayoutManager-Ddo9_Ozc.js → PayoutManager-BJmPnyRP.js} +120 -103
  2. package/dist/PayoutManager-BJmPnyRP.js.map +1 -0
  3. package/dist/PayoutManager-aqtsj60t.cjs +2 -0
  4. package/dist/PayoutManager-aqtsj60t.cjs.map +1 -0
  5. package/dist/{PeginManager-CTU0wgkJ.js → PeginManager-D22MLWfM.js} +113 -128
  6. package/dist/PeginManager-D22MLWfM.js.map +1 -0
  7. package/dist/PeginManager-vUUfZCzj.cjs +2 -0
  8. package/dist/PeginManager-vUUfZCzj.cjs.map +1 -0
  9. package/dist/{buildAndBroadcastRefund-DjS9nf87.js → buildAndBroadcastRefund-BiSO4zg2.js} +222 -235
  10. package/dist/buildAndBroadcastRefund-BiSO4zg2.js.map +1 -0
  11. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs +2 -0
  12. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs.map +1 -0
  13. package/dist/{fundPeginTransaction-96FxwYYJ.js → fundPeginTransaction-B2wyjqp0.js} +21 -22
  14. package/dist/fundPeginTransaction-B2wyjqp0.js.map +1 -0
  15. package/dist/fundPeginTransaction-BLD8FRL9.cjs +2 -0
  16. package/dist/fundPeginTransaction-BLD8FRL9.cjs.map +1 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +176 -175
  19. package/dist/{noPayout-8dDKwi6n.cjs → noPayout-CNMqNNpc.cjs} +2 -2
  20. package/dist/{noPayout-8dDKwi6n.cjs.map → noPayout-CNMqNNpc.cjs.map} +1 -1
  21. package/dist/{noPayout-tZFoNun3.js → noPayout-CfBg3HzC.js} +2 -2
  22. package/dist/{noPayout-tZFoNun3.js.map → noPayout-CfBg3HzC.js.map} +1 -1
  23. package/dist/tbv/core/index.cjs +1 -1
  24. package/dist/tbv/core/index.js +176 -175
  25. package/dist/tbv/core/managers/PeginManager.d.ts +3 -2
  26. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  27. package/dist/tbv/core/managers/index.cjs +1 -1
  28. package/dist/tbv/core/managers/index.js +2 -2
  29. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts +10 -6
  30. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts.map +1 -1
  31. package/dist/tbv/core/primitives/index.cjs +1 -1
  32. package/dist/tbv/core/primitives/index.d.ts +2 -2
  33. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  34. package/dist/tbv/core/primitives/index.js +38 -36
  35. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +11 -0
  36. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -0
  37. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +11 -10
  38. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  39. package/dist/tbv/core/primitives/psbt/pegin.d.ts +10 -2
  40. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  41. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  42. package/dist/tbv/core/services/index.cjs +1 -1
  43. package/dist/tbv/core/services/index.js +2 -2
  44. package/dist/tbv/core/utils/fee/constants.d.ts +6 -14
  45. package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -1
  46. package/dist/tbv/core/utils/index.cjs +1 -1
  47. package/dist/tbv/core/utils/index.js +35 -36
  48. package/dist/tbv/index.cjs +1 -1
  49. package/dist/tbv/index.js +176 -175
  50. package/dist/testing/MockBitcoinWallet.d.ts +1 -1
  51. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  52. package/dist/testing/index.cjs +1 -1
  53. package/dist/testing/index.cjs.map +1 -1
  54. package/dist/testing/index.js +3 -3
  55. package/dist/testing/index.js.map +1 -1
  56. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs +2 -0
  57. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs.map +1 -0
  58. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js +658 -0
  59. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js.map +1 -0
  60. package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs} +2 -2
  61. package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs.map → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs.map} +1 -1
  62. package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js → waitForTransactionReceiptSmartAware-lobLm0q0.js} +2 -2
  63. package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js.map → waitForTransactionReceiptSmartAware-lobLm0q0.js.map} +1 -1
  64. package/package.json +3 -3
  65. package/dist/PayoutManager-1GWmbvI9.cjs +0 -2
  66. package/dist/PayoutManager-1GWmbvI9.cjs.map +0 -1
  67. package/dist/PayoutManager-Ddo9_Ozc.js.map +0 -1
  68. package/dist/PeginManager-CTU0wgkJ.js.map +0 -1
  69. package/dist/PeginManager-De-eHl3v.cjs +0 -2
  70. package/dist/PeginManager-De-eHl3v.cjs.map +0 -1
  71. package/dist/buildAndBroadcastRefund-BnD2qUDW.cjs +0 -2
  72. package/dist/buildAndBroadcastRefund-BnD2qUDW.cjs.map +0 -1
  73. package/dist/buildAndBroadcastRefund-DjS9nf87.js.map +0 -1
  74. package/dist/fundPeginTransaction-96FxwYYJ.js.map +0 -1
  75. package/dist/fundPeginTransaction-DuMwnytD.cjs +0 -2
  76. package/dist/fundPeginTransaction-DuMwnytD.cjs.map +0 -1
  77. package/dist/verifyScriptPathSchnorrSignature-DpWZx5J0.js +0 -567
  78. package/dist/verifyScriptPathSchnorrSignature-DpWZx5J0.js.map +0 -1
  79. package/dist/verifyScriptPathSchnorrSignature-a4Us7D3e.cjs +0 -2
  80. package/dist/verifyScriptPathSchnorrSignature-a4Us7D3e.cjs.map +0 -1
@@ -1,104 +1,104 @@
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 $ = (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-Ddo9_Ozc.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 S, Psbt as le } from "bitcoinjs-lib";
9
- import { c as ce, d as I, e as N, f as H } from "./verifyScriptPathSchnorrSignature-DpWZx5J0.js";
10
- import { c as he, a as de, b as pe } from "./noPayout-tZFoNun3.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
- import { a as ge } from "./constants-BhclpREj.js";
13
- const fe = /^0x[0-9a-fA-F]{64}$/, me = /^0x[0-9a-fA-F]{40}$/, Pe = /^0x([0-9a-fA-F]{2})*$/;
14
- function V(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) {
15
15
  if (e.length !== 66)
16
16
  throw new Error(
17
- `${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}`
18
18
  );
19
- if (!fe.test(e))
19
+ if (!me.test(e))
20
20
  throw new Error(
21
- `${r} must contain only hex characters after the 0x prefix`
21
+ `${t} must contain only hex characters after the 0x prefix`
22
22
  );
23
23
  }
24
- function be(e, r) {
25
- if (!me.test(e))
24
+ function ye(e, t) {
25
+ if (!Pe.test(e))
26
26
  throw new Error(
27
- `${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)`
28
28
  );
29
29
  }
30
- function ye(e, r) {
31
- if (!Pe.test(e))
30
+ function we(e, t) {
31
+ if (!be.test(e))
32
32
  throw new Error(
33
- `${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`
34
34
  );
35
35
  }
36
36
  async function ut(e) {
37
37
  const {
38
- btcVaultRegistryAddress: r,
39
- vaultId: t,
38
+ btcVaultRegistryAddress: t,
39
+ vaultId: r,
40
40
  hashlock: n,
41
41
  activationMetadata: s,
42
42
  writeContract: l,
43
43
  signal: a
44
44
  } = e;
45
- a == null || a.throwIfAborted(), be(r, "btcVaultRegistryAddress"), V(t, "vaultId");
45
+ a == null || a.throwIfAborted(), ye(t, "btcVaultRegistryAddress"), V(r, "vaultId");
46
46
  const i = te(e.secret);
47
47
  if (V(i, "secret"), n !== void 0 && (V(n, "hashlock"), !ne(i, n)))
48
48
  throw new Error(
49
49
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
50
50
  );
51
- return ye(s, "activationMetadata"), l({
52
- address: r,
51
+ return we(s, "activationMetadata"), l({
52
+ address: t,
53
53
  abi: ee,
54
54
  functionName: "activateVaultWithSecret",
55
- args: [t, i, s]
55
+ args: [r, i, s]
56
56
  });
57
57
  }
58
- const we = 1e4;
58
+ const xe = 1e4;
59
59
  async function G(e) {
60
60
  const {
61
- statusReader: r,
62
- peginTxid: t,
61
+ statusReader: t,
62
+ peginTxid: r,
63
63
  targetStatuses: n,
64
64
  timeoutMs: s,
65
- pollIntervalMs: l = we,
65
+ pollIntervalMs: l = xe,
66
66
  signal: a
67
67
  } = e, i = Date.now();
68
68
  for (; ; ) {
69
69
  if (a != null && a.aborted)
70
70
  throw new Error(
71
- `Polling aborted for pegin ${t.slice(0, 8)}… (target: ${[...n].join(", ")})`
71
+ `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
72
72
  );
73
73
  if (Date.now() - i >= s)
74
74
  throw new Error(
75
- `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(", ")})`
76
76
  );
77
77
  try {
78
- const o = await r.getPeginStatus(
79
- { pegin_txid: t },
78
+ const o = await t.getPeginStatus(
79
+ { pegin_txid: r },
80
80
  a
81
81
  );
82
- if (o.pegin_txid.toLowerCase() !== t.toLowerCase())
82
+ if (o.pegin_txid.toLowerCase() !== r.toLowerCase())
83
83
  throw new Error(
84
- `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)}…`
85
85
  );
86
86
  const u = o.status;
87
87
  if (n.has(u) || u === w.ACTIVATED)
88
88
  return u;
89
- if (u === w.EXPIRED || se.has(u))
89
+ if (u === w.EXPIRED || ie.has(u))
90
90
  throw new Error(
91
- `Pegin ${t.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...n].join(", ")}`
91
+ `Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...n].join(", ")}`
92
92
  );
93
93
  } catch (o) {
94
- if (!(o instanceof ie && o.code === ue.PEGIN_NOT_FOUND))
94
+ if (!(o instanceof ue && o.code === le.PEGIN_NOT_FOUND))
95
95
  throw o;
96
96
  }
97
97
  await new Promise((o, u) => {
98
98
  const h = () => {
99
99
  clearTimeout(c), u(
100
100
  new Error(
101
- `Polling aborted for pegin ${t.slice(0, 8)}… (target: ${[...n].join(", ")})`
101
+ `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
102
102
  )
103
103
  );
104
104
  }, c = setTimeout(() => {
@@ -108,29 +108,29 @@ async function G(e) {
108
108
  });
109
109
  }
110
110
  }
111
- const xe = 300 * 1e3, ve = /* @__PURE__ */ new Set([
111
+ const ve = 300 * 1e3, Ee = /* @__PURE__ */ new Set([
112
112
  w.PENDING_DEPOSITOR_WOTS_PK,
113
113
  ...z
114
114
  ]);
115
115
  async function lt(e) {
116
116
  const {
117
- statusReader: r,
118
- wotsSubmitter: t,
117
+ statusReader: t,
118
+ wotsSubmitter: r,
119
119
  peginTxid: n,
120
120
  depositorPk: s,
121
121
  wotsPublicKeys: l,
122
- timeoutMs: a = xe,
122
+ timeoutMs: a = ve,
123
123
  signal: i
124
124
  } = e;
125
125
  i == null || i.throwIfAborted();
126
126
  const o = await G({
127
- statusReader: r,
127
+ statusReader: t,
128
128
  peginTxid: n,
129
- targetStatuses: ve,
129
+ targetStatuses: Ee,
130
130
  timeoutMs: a,
131
131
  signal: i
132
132
  });
133
- z.has(o) || (i == null || i.throwIfAborted(), await t.submitDepositorWotsKey(
133
+ z.has(o) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
134
134
  {
135
135
  pegin_txid: n,
136
136
  depositor_pk: s,
@@ -139,9 +139,9 @@ async function lt(e) {
139
139
  i
140
140
  ));
141
141
  }
142
- const K = 1, Ee = 1;
143
- function Te(e, r) {
144
- const t = p(r).toLowerCase(), s = e.map((l) => p(l).toLowerCase()).filter((l) => l !== 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);
145
145
  if (s.length === 0)
146
146
  throw new Error(
147
147
  "Cannot derive localChallengers: vault keeper set is empty (or contains only the depositor)"
@@ -152,15 +152,15 @@ function Te(e, r) {
152
152
  );
153
153
  return s;
154
154
  }
155
- function ke(e, r, t) {
156
- const n = t.map(
155
+ function _e(e, t, r) {
156
+ const n = r.map(
157
157
  (c) => p(c).toLowerCase()
158
- ), s = r.filter((c) => n.includes(c));
158
+ ), s = t.filter((c) => n.includes(c));
159
159
  if (s.length > 0)
160
160
  throw new Error(
161
161
  `Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
162
162
  );
163
- const l = [...r, ...n], a = e.map(
163
+ const l = [...t, ...n], a = e.map(
164
164
  (c) => p(c.challenger_pubkey).toLowerCase()
165
165
  ), i = new Set(a);
166
166
  if (i.size !== a.length)
@@ -173,68 +173,68 @@ function ke(e, r, t) {
173
173
  "Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
174
174
  );
175
175
  }
176
- function _e(e, r) {
177
- const t = e.ins[r];
178
- 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());
179
179
  }
180
- function R(e, r, t, n, s) {
181
- const l = e.ins[r];
180
+ function R(e, t, r, n, s) {
181
+ const l = e.ins[t];
182
182
  if (l.index !== 0)
183
183
  throw new Error(
184
- `NoPayout (challenger ${s}) input ${r} expected to spend ${n} vout 0, got vout ${l.index}`
184
+ `NoPayout (challenger ${s}) input ${t} expected to spend ${n} vout 0, got vout ${l.index}`
185
185
  );
186
- const a = t.getId(), i = _e(e, r);
186
+ const a = r.getId(), i = Ce(e, t);
187
187
  if (i !== a)
188
188
  throw new Error(
189
- `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})`
190
190
  );
191
191
  }
192
- async function Ce(e, r, t) {
193
- const n = [], s = [], l = [], a = Te(
194
- t.vaultKeeperBtcPubkeys,
195
- t.depositorBtcPubkey
192
+ async function Se(e, t, r) {
193
+ const n = [], s = [], l = [], a = ke(
194
+ r.vaultKeeperBtcPubkeys,
195
+ r.depositorBtcPubkey
196
196
  );
197
- ke(
197
+ _e(
198
198
  e.challenger_presign_data,
199
199
  a,
200
- t.universalChallengerBtcPubkeys
200
+ r.universalChallengerBtcPubkeys
201
201
  );
202
- const i = await ce({
203
- vaultCoreVersion: t.vaultCoreVersion,
202
+ const i = await he({
203
+ vaultCoreVersion: r.vaultCoreVersion,
204
204
  payoutTxHex: e.payout_tx.tx_hex,
205
- peginTxHex: t.peginTxHex,
205
+ peginTxHex: r.peginTxHex,
206
206
  assertTxHex: e.assert_tx.tx_hex,
207
- depositorBtcPubkey: t.depositorBtcPubkey,
208
- vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
209
- vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
210
- universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
211
- timelockPegin: t.timelockPegin,
212
- network: t.network,
213
- claimerBtcPubkey: t.depositorBtcPubkey,
214
- registeredPayoutScriptPubKey: t.registeredPayoutScriptPubKey,
215
- 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
216
216
  });
217
217
  n.push(i.psbtHex), s.push(
218
218
  O(
219
- r,
219
+ t,
220
220
  K
221
221
  )
222
222
  );
223
- const o = p(t.depositorBtcPubkey), u = S.fromHex(
223
+ const o = p(r.depositorBtcPubkey), u = S.fromHex(
224
224
  p(e.assert_tx.tx_hex)
225
225
  );
226
226
  for (const h of e.challenger_presign_data) {
227
- const c = p(h.challenger_pubkey), d = n.length, P = await Se({
227
+ const c = p(h.challenger_pubkey), d = n.length, P = await Ae({
228
228
  challenger: h,
229
229
  challengerPubkey: c,
230
230
  claimerPubkey: o,
231
231
  localChallengers: a,
232
232
  assertTxParsed: u,
233
- ctx: t
233
+ ctx: r
234
234
  });
235
235
  n.push(P), s.push(
236
236
  O(
237
- r,
237
+ t,
238
238
  K
239
239
  )
240
240
  ), l.push({
@@ -244,49 +244,49 @@ async function Ce(e, r, t) {
244
244
  }
245
245
  return { psbtHexes: n, signOptions: s, challengerEntries: l };
246
246
  }
247
- async function Se(e) {
247
+ async function Ae(e) {
248
248
  const {
249
- challenger: r,
250
- challengerPubkey: t,
249
+ challenger: t,
250
+ challengerPubkey: r,
251
251
  claimerPubkey: n,
252
252
  localChallengers: s,
253
253
  assertTxParsed: l,
254
254
  ctx: a
255
255
  } = e;
256
- he(
257
- r.nopayout_tx.tx_hex,
258
- t,
256
+ de(
257
+ t.nopayout_tx.tx_hex,
258
+ r,
259
259
  a.network
260
260
  );
261
261
  const i = S.fromHex(
262
- p(r.nopayout_tx.tx_hex)
262
+ p(t.nopayout_tx.tx_hex)
263
263
  ), o = S.fromHex(
264
- p(r.challenge_assert_x_tx.tx_hex)
264
+ p(t.challenge_assert_x_tx.tx_hex)
265
265
  ), u = S.fromHex(
266
- p(r.challenge_assert_y_tx.tx_hex)
266
+ p(t.challenge_assert_y_tx.tx_hex)
267
267
  );
268
268
  if (i.ins.length !== 3)
269
269
  throw new Error(
270
- `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}`
271
271
  );
272
272
  R(
273
273
  i,
274
274
  0,
275
275
  l,
276
276
  "Assert",
277
- t
277
+ r
278
278
  ), R(
279
279
  i,
280
280
  1,
281
281
  o,
282
282
  "ChallengeAssertX",
283
- t
283
+ r
284
284
  ), R(
285
285
  i,
286
286
  2,
287
287
  u,
288
288
  "ChallengeAssertY",
289
- t
289
+ r
290
290
  );
291
291
  const h = [
292
292
  l.outs[0],
@@ -296,9 +296,9 @@ async function Se(e) {
296
296
  script_pubkey: X(new Uint8Array(c.script)),
297
297
  value: c.value
298
298
  }));
299
- return de({
300
- noPayoutTxHex: r.nopayout_tx.tx_hex,
301
- challengerPubkey: t,
299
+ return pe({
300
+ noPayoutTxHex: t.nopayout_tx.tx_hex,
301
+ challengerPubkey: r,
302
302
  prevouts: h,
303
303
  connectorParams: {
304
304
  txGraphVersion: a.vaultCoreVersion,
@@ -311,29 +311,29 @@ async function Se(e) {
311
311
  }
312
312
  });
313
313
  }
314
- function Ae(e, r, t) {
314
+ function $e(e, t, r) {
315
315
  I(e[0]);
316
316
  const s = N(
317
317
  e[0].returnedPsbtHex,
318
- t
318
+ r
319
319
  );
320
320
  H({
321
321
  requestedPsbtHex: e[0].requestedPsbtHex,
322
322
  signatureHex: s,
323
- signerXOnlyPubkeyHex: t,
323
+ signerXOnlyPubkeyHex: r,
324
324
  inputIndex: 0
325
325
  });
326
326
  const l = {};
327
- for (const a of r) {
327
+ for (const a of t) {
328
328
  I(e[a.noPayoutIdx]);
329
329
  const i = N(
330
330
  e[a.noPayoutIdx].returnedPsbtHex,
331
- t
331
+ r
332
332
  );
333
333
  H({
334
334
  requestedPsbtHex: e[a.noPayoutIdx].requestedPsbtHex,
335
335
  signatureHex: i,
336
- signerXOnlyPubkeyHex: t,
336
+ signerXOnlyPubkeyHex: r,
337
337
  inputIndex: 0
338
338
  }), l[a.challengerPubkey] = {
339
339
  nopayout_signature: i
@@ -346,36 +346,23 @@ function Ae(e, r, t) {
346
346
  per_challenger: l
347
347
  };
348
348
  }
349
- async function $e(e, r, t) {
350
- if (typeof e.signPsbts == "function")
351
- return e.signPsbts(r, t);
352
- const n = [];
353
- for (let s = 0; s < r.length; s++)
354
- n.push(await e.signPsbt(r[s], t == null ? void 0 : t[s]));
355
- return n;
356
- }
357
349
  async function Ve(e) {
358
- const { depositorGraph: r, btcWallet: t, signingContext: n } = e, s = await t.getPublicKeyHex(), { depositorPubkey: l } = re(
350
+ const { depositorGraph: t, btcWallet: r, signingContext: n } = e, s = await r.getPublicKeyHex(), { depositorPubkey: l } = re(
359
351
  s,
360
352
  p(n.depositorBtcPubkey)
361
- ), { psbtHexes: a, signOptions: i, challengerEntries: o } = await Ce(
362
- r,
353
+ ), { psbtHexes: a, signOptions: i, challengerEntries: o } = await Se(
354
+ t,
363
355
  s,
364
356
  n
365
- ), u = await $e(
366
- t,
357
+ ), u = await oe(
358
+ r,
367
359
  a,
368
360
  i
369
- );
370
- if (u.length !== a.length)
371
- throw new Error(
372
- `Wallet returned ${u.length} signed PSBTs, expected ${a.length}`
373
- );
374
- const h = a.map((c, d) => ({
361
+ ), h = a.map((c, d) => ({
375
362
  requestedPsbtHex: c,
376
363
  returnedPsbtHex: u[d]
377
364
  }));
378
- return Ae(
365
+ return $e(
379
366
  h,
380
367
  o,
381
368
  l
@@ -391,19 +378,19 @@ const Re = 1200 * 1e3, q = /* @__PURE__ */ new Set([
391
378
  ...q
392
379
  ]);
393
380
  function Ie(e) {
394
- return e.map((r) => ({
395
- claimerPubkeyXOnly: A(r.claimer_pubkey),
396
- payoutTxHex: r.payout_tx.tx_hex,
397
- assertTxHex: r.assert_tx.tx_hex
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
398
385
  }));
399
386
  }
400
387
  function _(e) {
401
388
  return A(e).toLowerCase();
402
389
  }
403
- function Ne(e, r, t, n) {
390
+ function Ne(e, t, r, n) {
404
391
  const s = _(n), l = [
405
- _(r),
406
- ...t.map(_)
392
+ _(t),
393
+ ...r.map(_)
407
394
  ], a = new Set(l);
408
395
  if (a.size !== l.length)
409
396
  throw new Error(
@@ -426,54 +413,54 @@ function Ne(e, r, t, n) {
426
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(", ")})` : "")
427
414
  );
428
415
  }
429
- function U(e, r) {
416
+ function U(e, t) {
430
417
  return {
431
- vaultCoreVersion: r.vaultCoreVersion,
418
+ vaultCoreVersion: t.vaultCoreVersion,
432
419
  payoutTxHex: e.payoutTxHex,
433
- peginTxHex: r.peginTxHex,
420
+ peginTxHex: t.peginTxHex,
434
421
  assertTxHex: e.assertTxHex,
435
- vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
436
- vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
437
- universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
438
- depositorBtcPubkey: r.depositorBtcPubkey,
439
- timelockPegin: r.timelockPegin,
440
- 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,
441
428
  claimerBtcPubkey: e.claimerPubkeyXOnly,
442
- commissionBps: r.commissionBps
429
+ commissionBps: t.commissionBps
443
430
  };
444
431
  }
445
- async function He(e, r, t, n) {
446
- const s = new oe({
447
- network: r.network,
432
+ async function He(e, t, r, n) {
433
+ const s = new ae({
434
+ network: t.network,
448
435
  btcWallet: e
449
- }), l = t.length;
436
+ }), l = r.length;
450
437
  n == null || n(0, l);
451
438
  let a;
452
439
  if (s.supportsBatchSigning())
453
440
  a = (await s.signPayoutTransactionsBatch(
454
- t.map((u) => U(u, r))
441
+ r.map((u) => U(u, t))
455
442
  )).map((u) => u.payoutSignature);
456
443
  else {
457
444
  a = [];
458
- for (let o = 0; o < t.length; o++) {
445
+ for (let o = 0; o < r.length; o++) {
459
446
  n == null || n(o, l);
460
447
  const u = await s.signPayoutTransaction(
461
- U(t[o], r)
448
+ U(r[o], t)
462
449
  );
463
450
  a.push(u.signature);
464
451
  }
465
452
  }
466
453
  const i = {};
467
- for (let o = 0; o < t.length; o++)
468
- i[t[o].claimerPubkeyXOnly] = {
454
+ for (let o = 0; o < r.length; o++)
455
+ i[r[o].claimerPubkeyXOnly] = {
469
456
  payout_signature: a[o]
470
457
  };
471
458
  return n == null || n(l, l), i;
472
459
  }
473
460
  async function ct(e) {
474
461
  const {
475
- statusReader: r,
476
- presignClient: t,
462
+ statusReader: t,
463
+ presignClient: r,
477
464
  btcWallet: n,
478
465
  peginTxid: s,
479
466
  depositorPk: l,
@@ -482,7 +469,7 @@ async function ct(e) {
482
469
  signal: o,
483
470
  onProgress: u
484
471
  } = e, h = await G({
485
- statusReader: r,
472
+ statusReader: t,
486
473
  peginTxid: s,
487
474
  targetStatuses: Be,
488
475
  timeoutMs: i,
@@ -491,7 +478,7 @@ async function ct(e) {
491
478
  if (q.has(h))
492
479
  return;
493
480
  o == null || o.throwIfAborted();
494
- const c = await t.requestDepositorPresignTransactions(
481
+ const c = await r.requestDepositorPresignTransactions(
495
482
  {
496
483
  pegin_txid: s,
497
484
  depositor_pk: l
@@ -535,7 +522,7 @@ async function ct(e) {
535
522
  });
536
523
  o == null || o.throwIfAborted();
537
524
  const b = { ...y };
538
- b[p(l)] = x.payout_signatures, await t.submitDepositorPresignatures(
525
+ b[p(l)] = x.payout_signatures, await r.submitDepositorPresignatures(
539
526
  {
540
527
  pegin_txid: s,
541
528
  depositor_pk: l,
@@ -550,54 +537,54 @@ function Oe(e) {
550
537
  }
551
538
  function ht(e) {
552
539
  const {
553
- amountSats: r,
554
- minDeposit: t,
540
+ amountSats: t,
541
+ minDeposit: r,
555
542
  maxDeposit: n,
556
543
  btcBalance: s,
557
544
  estimatedFeeSats: l,
558
545
  depositorClaimValue: a
559
546
  } = e;
560
- return !(r <= 0n || r < t || n && n > 0n && r > n || l == null || a == null || r + l + a > s);
547
+ return !(t <= 0n || t < r || n && n > 0n && t > n || l == null || a == null || t + l + a > s);
561
548
  }
562
- function dt(e, r, t) {
549
+ function dt(e, t, r) {
563
550
  return e <= 0n ? {
564
551
  valid: !1,
565
552
  error: "Deposit amount must be greater than zero"
566
- } : e < r ? {
553
+ } : e < t ? {
567
554
  valid: !1,
568
- error: `Minimum deposit is ${E(r)} BTC`
569
- } : t && t > 0n && e > t ? {
555
+ error: `Minimum deposit is ${E(t)} BTC`
556
+ } : r && r > 0n && e > r ? {
570
557
  valid: !1,
571
- error: `Maximum deposit is ${E(t)} BTC`
558
+ error: `Maximum deposit is ${E(r)} BTC`
572
559
  } : { valid: !0 };
573
560
  }
574
561
  function pt(e) {
575
- const { amount: r, effectiveRemaining: t } = e;
576
- return t === null ? { valid: !0 } : t === 0n ? {
562
+ const { amount: t, effectiveRemaining: r } = e;
563
+ return r === null ? { valid: !0 } : r === 0n ? {
577
564
  valid: !1,
578
565
  error: "Supply cap reached — deposits temporarily paused"
579
- } : r > t ? {
566
+ } : t > r ? {
580
567
  valid: !1,
581
- error: `Vault size exceeds remaining capacity (${E(t)} BTC)`
568
+ error: `Vault size exceeds remaining capacity (${E(r)} BTC)`
582
569
  } : { valid: !0 };
583
570
  }
584
- function gt(e, r) {
571
+ function gt(e, t) {
585
572
  if (!e || e.length === 0)
586
573
  return {
587
574
  valid: !1,
588
575
  error: "At least one vault provider must be selected"
589
576
  };
590
- const t = r.map(
577
+ const r = t.map(
591
578
  (s) => s.toLowerCase()
592
579
  );
593
580
  return e.filter(
594
- (s) => !t.includes(s.toLowerCase())
581
+ (s) => !r.includes(s.toLowerCase())
595
582
  ).length > 0 ? {
596
583
  valid: !1,
597
584
  error: "Invalid vault provider selected"
598
585
  } : { valid: !0 };
599
586
  }
600
- function De(e, r, t) {
587
+ function De(e, t, r) {
601
588
  if (!e || e.length === 0)
602
589
  return {
603
590
  valid: !1,
@@ -610,22 +597,22 @@ function De(e, r, t) {
610
597
  valid: !1,
611
598
  error: `Vault ${n + 1} amount must be positive`
612
599
  };
613
- if (r && s < r)
600
+ if (t && s < t)
614
601
  return {
615
602
  valid: !1,
616
- 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`
617
604
  };
618
- if (t && s > t)
605
+ if (r && s > r)
619
606
  return {
620
607
  valid: !1,
621
- 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`
622
609
  };
623
610
  }
624
611
  return { valid: !0 };
625
612
  }
626
613
  function Ke(e) {
627
- const r = p(e);
628
- return Oe(r) ? { valid: !0 } : {
614
+ const t = p(e);
615
+ return Oe(t) ? { valid: !0 } : {
629
616
  valid: !1,
630
617
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
631
618
  };
@@ -648,15 +635,15 @@ function Me(e) {
648
635
  }
649
636
  function ft(e) {
650
637
  const {
651
- vaultAmounts: r,
652
- confirmedUTXOs: t,
638
+ vaultAmounts: t,
639
+ confirmedUTXOs: r,
653
640
  vaultProviderBtcPubkey: n,
654
641
  vaultKeeperBtcPubkeys: s,
655
642
  universalChallengerBtcPubkeys: l,
656
643
  minDeposit: a,
657
644
  maxDeposit: i
658
645
  } = e, o = De(
659
- r,
646
+ t,
660
647
  a,
661
648
  i
662
649
  );
@@ -665,12 +652,12 @@ function ft(e) {
665
652
  const u = Ke(n);
666
653
  if (!u.valid)
667
654
  throw new Error(u.error);
668
- Ue(s), Fe(l), Me(t);
655
+ Ue(s), Fe(l), Me(r);
669
656
  }
670
657
  async function mt(e) {
671
658
  const {
672
- vaultRegistryReader: r,
673
- vaultKeeperReader: t,
659
+ vaultRegistryReader: t,
660
+ vaultKeeperReader: r,
674
661
  universalChallengerReader: n,
675
662
  vaultProviderEthAddress: s,
676
663
  applicationEntryPoint: l,
@@ -682,11 +669,11 @@ async function mt(e) {
682
669
  h,
683
670
  c
684
671
  ] = await Promise.all([
685
- r.getVaultProviderBtcPubKey(s),
686
- t.getCurrentVaultKeepersVersion(l),
672
+ t.getVaultProviderBtcPubKey(s),
673
+ r.getCurrentVaultKeepersVersion(l),
687
674
  n.getLatestUniversalChallengersVersion()
688
675
  ]), [d, P] = await Promise.all([
689
- t.getVaultKeepersByVersion(
676
+ r.getVaultKeepersByVersion(
690
677
  l,
691
678
  h
692
679
  ),
@@ -721,8 +708,8 @@ async function mt(e) {
721
708
  };
722
709
  }
723
710
  class j extends Error {
724
- constructor(r) {
725
- super(r), this.name = "RegisteredVaultVersionMismatchError";
711
+ constructor(t) {
712
+ super(t), this.name = "RegisteredVaultVersionMismatchError";
726
713
  }
727
714
  }
728
715
  function Pt(e) {
@@ -730,15 +717,15 @@ function Pt(e) {
730
717
  }
731
718
  async function bt(e) {
732
719
  const {
733
- vaultRegistryReader: r,
734
- vaultIds: t,
720
+ vaultRegistryReader: t,
721
+ vaultIds: r,
735
722
  expectedOffchainParamsVersion: n,
736
723
  expectedAppVaultKeepersVersion: s,
737
724
  expectedUniversalChallengersVersion: l,
738
725
  expectedVaultCoreVersion: a
739
- } = e, i = await r.getProtocolInfoBatch(t), o = [];
726
+ } = e, i = await t.getProtocolInfoBatch(r), o = [];
740
727
  if (i.forEach((u, h) => {
741
- const c = t[h];
728
+ const c = r[h];
742
729
  u.offchainParamsVersion !== n && o.push(
743
730
  `vault ${c}: offchainParams expected v${n}, got v${u.offchainParamsVersion}`
744
731
  ), u.appVaultKeepersVersion !== s && o.push(
@@ -768,35 +755,35 @@ function wt(e) {
768
755
  return !!e && Le.has(e);
769
756
  }
770
757
  class Xe extends Error {
771
- constructor(t, n) {
758
+ constructor(r, n) {
772
759
  super(`Refund not yet mature (BIP68 not final): ${n.message}`);
773
760
  $(this, "vaultId");
774
761
  $(this, "cause");
775
- this.name = "BIP68NotMatureError", this.vaultId = t, this.cause = n;
762
+ this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
776
763
  }
777
764
  }
778
- 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;
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;
779
766
  function xt(e) {
780
767
  if (!Number.isFinite(e) || e <= 0)
781
768
  throw new Error(
782
769
  `feeRateSatsVb must be a positive finite number, got ${e}`
783
770
  );
784
- return BigInt(Math.ceil(e * Y));
771
+ return BigInt(Math.ceil(e * W));
785
772
  }
786
773
  const qe = 1, je = /non-BIP68-final/i;
787
- function D(e, r) {
774
+ function D(e, t) {
788
775
  if (e.length !== 66)
789
776
  throw new Error(
790
- `${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}`
791
778
  );
792
779
  if (!ze.test(e))
793
780
  throw new Error(
794
- `${r} must contain only hex characters after the 0x prefix`
781
+ `${t} must contain only hex characters after the 0x prefix`
795
782
  );
796
783
  }
797
- function B(e, r) {
784
+ function B(e, t) {
798
785
  if (!Number.isInteger(e) || e < 0)
799
- 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}`);
800
787
  }
801
788
  function Qe(e) {
802
789
  if (D(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
@@ -809,30 +796,30 @@ function Qe(e) {
809
796
  throw new Error(
810
797
  `htlcVout ${e.htlcVout} is out of range for batch of size ${e.batch.length}`
811
798
  );
812
- for (let t = 0; t < e.batch.length; t++) {
813
- const n = e.batch[t];
814
- 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)
815
802
  throw new Error(
816
- `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}`
817
804
  );
818
805
  if (typeof n.amount != "bigint" || n.amount <= 0n)
819
806
  throw new Error(
820
- `batch[${t}].amount must be a positive bigint, got ${n.amount}`
807
+ `batch[${r}].amount must be a positive bigint, got ${n.amount}`
821
808
  );
822
809
  }
823
- const r = e.batch[e.htlcVout];
824
- if (r.hashlock.toLowerCase() !== e.hashlock.toLowerCase())
810
+ const t = e.batch[e.htlcVout];
811
+ if (t.hashlock.toLowerCase() !== e.hashlock.toLowerCase())
825
812
  throw new Error(
826
- `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})`
827
814
  );
828
- if (r.amount !== e.amount)
815
+ if (t.amount !== e.amount)
829
816
  throw new Error(
830
- `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})`
831
818
  );
832
819
  if (B(e.offchainParamsVersion, "offchainParamsVersion"), B(e.appVaultKeepersVersion, "appVaultKeepersVersion"), B(
833
820
  e.universalChallengersVersion,
834
821
  "universalChallengersVersion"
835
- ), ge(
822
+ ), fe(
836
823
  e.vaultCoreVersion,
837
824
  "VaultRefundData.vaultCoreVersion"
838
825
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
@@ -841,15 +828,15 @@ function Qe(e) {
841
828
  throw new Error(
842
829
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
843
830
  );
844
- if (!e.depositorBtcPubkey || !W.test(e.depositorBtcPubkey))
831
+ if (!e.depositorBtcPubkey || !Y.test(e.depositorBtcPubkey))
845
832
  throw new Error(
846
833
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
847
834
  );
848
835
  if (typeof e.amount != "bigint" || e.amount <= 0n)
849
836
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
850
837
  }
851
- function We(e) {
852
- if (!e.vaultProviderPubkey || !W.test(e.vaultProviderPubkey))
838
+ function Ye(e) {
839
+ if (!e.vaultProviderPubkey || !Y.test(e.vaultProviderPubkey))
853
840
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
854
841
  if (e.vaultKeeperPubkeys.length === 0)
855
842
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -874,38 +861,38 @@ function We(e) {
874
861
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
875
862
  );
876
863
  }
877
- function Ye(e) {
878
- const r = le.fromHex(e);
864
+ function We(e) {
865
+ const t = ce.fromHex(e);
879
866
  try {
880
- r.finalizeAllInputs();
881
- } catch (t) {
882
- 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);
883
870
  if (!n.includes("already finalized"))
884
871
  throw new Error(`Failed to finalize refund PSBT: ${n}`);
885
872
  }
886
- return r.extractTransaction().toHex();
873
+ return t.extractTransaction().toHex();
887
874
  }
888
875
  async function vt(e) {
889
876
  const {
890
- vaultId: r,
891
- readVault: t,
877
+ vaultId: t,
878
+ readVault: r,
892
879
  readPrePeginContext: n,
893
880
  feeRate: s,
894
881
  signPsbt: l,
895
882
  broadcastTx: a,
896
883
  signal: i
897
884
  } = e;
898
- i == null || i.throwIfAborted(), D(r, "vaultId");
899
- const o = await t();
885
+ i == null || i.throwIfAborted(), D(t, "vaultId");
886
+ const o = await r();
900
887
  Qe(o), i == null || i.throwIfAborted();
901
888
  const u = await n(o);
902
- if (We(u), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
889
+ if (Ye(u), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
903
890
  throw new Error(`feeRate must be a positive number, got ${s}`);
904
891
  if (s > F)
905
892
  throw new Error(
906
893
  `feeRate ${s} sat/vB exceeds refund safety cap ${F} sat/vB; refusing to sign refund.`
907
894
  );
908
- 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;
909
896
  if (h > c)
910
897
  throw new Error(
911
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.`
@@ -913,7 +900,7 @@ async function vt(e) {
913
900
  i == null || i.throwIfAborted();
914
901
  const d = A(
915
902
  o.depositorBtcPubkey
916
- ), P = p(o.unsignedPrePeginTxHex), m = ae(P);
903
+ ), P = p(o.unsignedPrePeginTxHex), m = se(P);
917
904
  if (m !== void 0 && m.vout !== o.batch.length)
918
905
  throw new Error(
919
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.`
@@ -931,7 +918,7 @@ async function vt(e) {
931
918
  throw new Error(
932
919
  `Funded Pre-PegIn tx has ${x.outs.length} outputs but batch requires at least ${o.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
933
920
  );
934
- const { psbtHex: b } = await pe({
921
+ const { psbtHex: b } = await ge({
935
922
  prePeginParams: {
936
923
  vaultCoreVersion: o.vaultCoreVersion,
937
924
  depositorPubkey: d,
@@ -984,12 +971,12 @@ async function vt(e) {
984
971
  signerXOnlyPubkeyHex: d,
985
972
  inputIndex: k
986
973
  });
987
- const C = Ye(T);
974
+ const C = We(T);
988
975
  i == null || i.throwIfAborted();
989
976
  try {
990
977
  return await a(C);
991
978
  } catch (f) {
992
- 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;
993
980
  }
994
981
  }
995
982
  export {
@@ -1016,8 +1003,8 @@ export {
1016
1003
  ct as r,
1017
1004
  lt as s,
1018
1005
  F as t,
1019
- Y as u,
1006
+ W as u,
1020
1007
  dt as v,
1021
1008
  G as w
1022
1009
  };
1023
- //# sourceMappingURL=buildAndBroadcastRefund-DjS9nf87.js.map
1010
+ //# sourceMappingURL=buildAndBroadcastRefund-BiSO4zg2.js.map