@babylonlabs-io/ts-sdk 0.39.2 → 0.39.3

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