@babylonlabs-io/ts-sdk 0.33.4 → 0.33.5

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 (52) hide show
  1. package/dist/buildAndBroadcastRefund-B332dykQ.cjs +2 -0
  2. package/dist/buildAndBroadcastRefund-B332dykQ.cjs.map +1 -0
  3. package/dist/{buildAndBroadcastRefund-D_QlvCsw.js → buildAndBroadcastRefund-CPjXNaMi.js} +126 -121
  4. package/dist/buildAndBroadcastRefund-CPjXNaMi.js.map +1 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +89 -87
  7. package/dist/tbv/core/clients/index.cjs +1 -1
  8. package/dist/tbv/core/clients/index.js +23 -21
  9. package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts +2 -0
  10. package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts.map +1 -0
  11. package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts +2 -0
  12. package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts.map +1 -0
  13. package/dist/tbv/core/clients/vault-provider/api.d.ts +13 -4
  14. package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
  15. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts +45 -0
  16. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts.map +1 -0
  17. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts +55 -0
  18. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts.map +1 -0
  19. package/dist/tbv/core/clients/vault-provider/index.d.ts +2 -0
  20. package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
  21. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +3 -3
  22. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  23. package/dist/tbv/core/clients/vault-provider/types.d.ts +68 -24
  24. package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
  25. package/dist/tbv/core/clients/vault-provider/validators.d.ts +12 -2
  26. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  27. package/dist/tbv/core/index.cjs +1 -1
  28. package/dist/tbv/core/index.js +73 -71
  29. package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -1
  30. package/dist/tbv/core/services/index.cjs +1 -1
  31. package/dist/tbv/core/services/index.js +1 -1
  32. package/dist/tbv/core/services/pegout/state.d.ts +1 -1
  33. package/dist/tbv/index.cjs +1 -1
  34. package/dist/tbv/index.js +73 -71
  35. package/dist/types-DnyyBNcC.cjs +2 -0
  36. package/dist/types-DnyyBNcC.cjs.map +1 -0
  37. package/dist/{types-ByW6nSLj.js → types-TiIjyo2b.js} +32 -30
  38. package/dist/types-TiIjyo2b.js.map +1 -0
  39. package/dist/{vault-registry-reader-WiNVOsnD.js → vault-registry-reader-BDFpXeH7.js} +425 -263
  40. package/dist/vault-registry-reader-BDFpXeH7.js.map +1 -0
  41. package/dist/vault-registry-reader-ejm2UYzk.cjs +2 -0
  42. package/dist/vault-registry-reader-ejm2UYzk.cjs.map +1 -0
  43. package/package.json +1 -1
  44. package/dist/buildAndBroadcastRefund-CIPPpchL.cjs +0 -2
  45. package/dist/buildAndBroadcastRefund-CIPPpchL.cjs.map +0 -1
  46. package/dist/buildAndBroadcastRefund-D_QlvCsw.js.map +0 -1
  47. package/dist/types-ByW6nSLj.js.map +0 -1
  48. package/dist/types-CfCZyfid.cjs +0 -2
  49. package/dist/types-CfCZyfid.cjs.map +0 -1
  50. package/dist/vault-registry-reader-OK2V08tk.cjs +0 -2
  51. package/dist/vault-registry-reader-OK2V08tk.cjs.map +0 -1
  52. package/dist/vault-registry-reader-WiNVOsnD.js.map +0 -1
@@ -2,16 +2,16 @@ var M = Object.defineProperty;
2
2
  var U = (e, t, r) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var v = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { B as F } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
5
- import { e as X, s as c, u as R, p as m, f as p } from "./bitcoin-B0S8SHCX.js";
5
+ import { e as X, s as c, u as R, p as m, f as h } from "./bitcoin-B0S8SHCX.js";
6
6
  import { v as z, P as G } from "./PayoutManager-C9XHKZ5j.js";
7
- import { c as Q, a as W, R as Y, d as $, D as b } from "./types-ByW6nSLj.js";
8
- import * as j from "bitcoinjs-lib";
9
- import { Transaction as y, Psbt as q } from "bitcoinjs-lib";
7
+ import { c as Q, a as W, R as Y, d as $, D as b } from "./types-TiIjyo2b.js";
8
+ import * as q from "bitcoinjs-lib";
9
+ import { Transaction as y, Psbt as j } from "bitcoinjs-lib";
10
10
  import { Buffer as J } from "buffer";
11
11
  import { c as Z, a as ee, b as te } from "./noPayout-DBX6G96_.js";
12
12
  import { a as re, b as oe, e as A } from "./payout-BNFMBXS6.js";
13
13
  import { c as _ } from "./signing-DaLvGwQe.js";
14
- const ne = /^0x[0-9a-fA-F]{64}$/, ae = /^0x[0-9a-fA-F]{40}$/, se = /^0x([0-9a-fA-F]{2})*$/;
14
+ const ne = /^0x[0-9a-fA-F]{64}$/, ie = /^0x[0-9a-fA-F]{40}$/, se = /^0x([0-9a-fA-F]{2})*$/;
15
15
  function T(e, t) {
16
16
  if (e.length !== 66)
17
17
  throw new Error(
@@ -22,8 +22,8 @@ function T(e, t) {
22
22
  `${t} must contain only hex characters after the 0x prefix`
23
23
  );
24
24
  }
25
- function ie(e, t) {
26
- if (!ae.test(e))
25
+ function ae(e, t) {
26
+ if (!ie.test(e))
27
27
  throw new Error(
28
28
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
29
29
  );
@@ -34,7 +34,7 @@ function ue(e, t) {
34
34
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
35
35
  );
36
36
  }
37
- async function je(e) {
37
+ async function qe(e) {
38
38
  const {
39
39
  btcVaultRegistryAddress: t,
40
40
  vaultId: r,
@@ -43,9 +43,9 @@ async function je(e) {
43
43
  writeContract: u,
44
44
  signal: n
45
45
  } = e;
46
- n == null || n.throwIfAborted(), ie(t, "btcVaultRegistryAddress"), T(r, "vaultId");
47
- const i = X(e.secret);
48
- if (T(i, "secret"), o !== void 0 && (T(o, "hashlock"), !z(i, o)))
46
+ n == null || n.throwIfAborted(), ae(t, "btcVaultRegistryAddress"), T(r, "vaultId");
47
+ const a = X(e.secret);
48
+ if (T(a, "secret"), o !== void 0 && (T(o, "hashlock"), !z(a, o)))
49
49
  throw new Error(
50
50
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
51
51
  );
@@ -53,7 +53,7 @@ async function je(e) {
53
53
  address: t,
54
54
  abi: F,
55
55
  functionName: "activateVaultWithSecret",
56
- args: [r, i, s]
56
+ args: [r, a, s]
57
57
  });
58
58
  }
59
59
  const le = 1e4;
@@ -65,32 +65,37 @@ async function N(e) {
65
65
  timeoutMs: s,
66
66
  pollIntervalMs: u = le,
67
67
  signal: n
68
- } = e, i = Date.now();
68
+ } = e, a = Date.now();
69
69
  for (; ; ) {
70
70
  if (n != null && n.aborted)
71
71
  throw new Error(
72
72
  `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
73
73
  );
74
- if (Date.now() - i >= s)
74
+ if (Date.now() - a >= s)
75
75
  throw new Error(
76
76
  `Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
77
77
  );
78
78
  try {
79
- const l = (await t.getPeginStatus(
79
+ const i = await t.getPeginStatus(
80
80
  { pegin_txid: r },
81
81
  n
82
- )).status;
82
+ );
83
+ if (i.pegin_txid.toLowerCase() !== r.toLowerCase())
84
+ throw new Error(
85
+ `getPeginStatus returned status for pegin ${i.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
86
+ );
87
+ const l = i.status;
83
88
  if (o.has(l))
84
89
  return l;
85
90
  if (Q.has(l) && !o.has(l))
86
91
  throw new Error(
87
92
  `Pegin ${r.slice(0, 8)}… reached terminal status "${l}" while waiting for ${[...o].join(", ")}`
88
93
  );
89
- } catch (a) {
90
- if (!(a instanceof W && a.code === Y.NOT_FOUND || a instanceof Error && a.message.includes("PegIn not found")))
91
- throw a;
94
+ } catch (i) {
95
+ if (!(i instanceof W && i.code === Y.NOT_FOUND || i instanceof Error && i.message.includes("PegIn not found")))
96
+ throw i;
92
97
  }
93
- await new Promise((a, l) => {
98
+ await new Promise((i, l) => {
94
99
  const f = () => {
95
100
  clearTimeout(d), l(
96
101
  new Error(
@@ -98,7 +103,7 @@ async function N(e) {
98
103
  )
99
104
  );
100
105
  }, d = setTimeout(() => {
101
- n == null || n.removeEventListener("abort", f), a();
106
+ n == null || n.removeEventListener("abort", f), i();
102
107
  }, u);
103
108
  n == null || n.addEventListener("abort", f, { once: !0 });
104
109
  });
@@ -108,7 +113,7 @@ const ce = 300 * 1e3, de = /* @__PURE__ */ new Set([
108
113
  b.PENDING_DEPOSITOR_WOTS_PK,
109
114
  ...$
110
115
  ]);
111
- async function qe(e) {
116
+ async function je(e) {
112
117
  const {
113
118
  statusReader: t,
114
119
  wotsSubmitter: r,
@@ -116,23 +121,23 @@ async function qe(e) {
116
121
  depositorPk: s,
117
122
  wotsPublicKeys: u,
118
123
  timeoutMs: n = ce,
119
- signal: i
124
+ signal: a
120
125
  } = e;
121
- i == null || i.throwIfAborted();
122
- const a = await N({
126
+ a == null || a.throwIfAborted();
127
+ const i = await N({
123
128
  statusReader: t,
124
129
  peginTxid: o,
125
130
  targetStatuses: de,
126
131
  timeoutMs: n,
127
- signal: i
132
+ signal: a
128
133
  });
129
- $.has(a) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
134
+ $.has(i) || (a == null || a.throwIfAborted(), await r.submitDepositorWotsKey(
130
135
  {
131
136
  pegin_txid: o,
132
137
  depositor_pk: s,
133
138
  wots_public_keys: u
134
139
  },
135
- i
140
+ a
136
141
  ));
137
142
  }
138
143
  const B = 1;
@@ -146,7 +151,7 @@ function fe(e, t, r) {
146
151
  );
147
152
  return u;
148
153
  }
149
- function he(e, t) {
154
+ function pe(e, t) {
150
155
  const r = e.ins[t];
151
156
  return R(new Uint8Array(r.hash).slice().reverse());
152
157
  }
@@ -156,13 +161,13 @@ function k(e, t, r, o, s) {
156
161
  throw new Error(
157
162
  `NoPayout (challenger ${s}) input ${t} expected to spend ${o} vout 0, got vout ${u.index}`
158
163
  );
159
- const n = r.getId(), i = he(e, t);
160
- if (i !== n)
164
+ const n = r.getId(), a = pe(e, t);
165
+ if (a !== n)
161
166
  throw new Error(
162
- `NoPayout (challenger ${s}) input ${t} does not reference ${o} (expected txid ${n}, got ${i})`
167
+ `NoPayout (challenger ${s}) input ${t} does not reference ${o} (expected txid ${n}, got ${a})`
163
168
  );
164
169
  }
165
- async function pe(e, t, r) {
170
+ async function he(e, t, r) {
166
171
  const o = [], s = [], u = [];
167
172
  re(
168
173
  e.payout_tx.tx_hex,
@@ -185,19 +190,19 @@ async function pe(e, t, r) {
185
190
  B
186
191
  )
187
192
  );
188
- const i = fe(
193
+ const a = fe(
189
194
  r.vaultProviderBtcPubkey,
190
195
  r.vaultKeeperBtcPubkeys,
191
196
  r.depositorBtcPubkey
192
- ), a = c(r.depositorBtcPubkey), l = y.fromHex(
197
+ ), i = c(r.depositorBtcPubkey), l = y.fromHex(
193
198
  c(e.assert_tx.tx_hex)
194
199
  );
195
200
  for (const f of e.challenger_presign_data) {
196
201
  const d = c(f.challenger_pubkey), g = o.length, P = await ge({
197
202
  challenger: f,
198
203
  challengerPubkey: d,
199
- claimerPubkey: a,
200
- localChallengers: i,
204
+ claimerPubkey: i,
205
+ localChallengers: a,
201
206
  assertTxParsed: l,
202
207
  ctx: r
203
208
  });
@@ -227,31 +232,31 @@ async function ge(e) {
227
232
  r,
228
233
  n.network
229
234
  );
230
- const i = y.fromHex(
235
+ const a = y.fromHex(
231
236
  c(t.nopayout_tx.tx_hex)
232
- ), a = y.fromHex(
237
+ ), i = y.fromHex(
233
238
  c(t.challenge_assert_x_tx.tx_hex)
234
239
  ), l = y.fromHex(
235
240
  c(t.challenge_assert_y_tx.tx_hex)
236
241
  );
237
- if (i.ins.length !== 3)
242
+ if (a.ins.length !== 3)
238
243
  throw new Error(
239
- `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
244
+ `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${a.ins.length}`
240
245
  );
241
246
  k(
242
- i,
247
+ a,
243
248
  0,
244
249
  u,
245
250
  "Assert",
246
251
  r
247
252
  ), k(
248
- i,
249
- 1,
250
253
  a,
254
+ 1,
255
+ i,
251
256
  "ChallengeAssertX",
252
257
  r
253
258
  ), k(
254
- i,
259
+ a,
255
260
  2,
256
261
  l,
257
262
  "ChallengeAssertY",
@@ -259,7 +264,7 @@ async function ge(e) {
259
264
  );
260
265
  const f = [
261
266
  u.outs[0],
262
- a.outs[0],
267
+ i.outs[0],
263
268
  l.outs[0]
264
269
  ].map((d) => ({
265
270
  script_pubkey: R(new Uint8Array(d.script)),
@@ -307,14 +312,14 @@ async function be(e, t, r) {
307
312
  return o;
308
313
  }
309
314
  async function ye(e) {
310
- const { depositorGraph: t, btcWallet: r, signingContext: o } = e, s = c(o.depositorBtcPubkey), u = await r.getPublicKeyHex(), { psbtHexes: n, signOptions: i, challengerEntries: a } = await pe(
315
+ const { depositorGraph: t, btcWallet: r, signingContext: o } = e, s = c(o.depositorBtcPubkey), u = await r.getPublicKeyHex(), { psbtHexes: n, signOptions: a, challengerEntries: i } = await he(
311
316
  t,
312
317
  u,
313
318
  o
314
319
  ), l = await be(
315
320
  r,
316
321
  n,
317
- i
322
+ a
318
323
  );
319
324
  if (l.length !== n.length)
320
325
  throw new Error(
@@ -322,7 +327,7 @@ async function ye(e) {
322
327
  );
323
328
  return Pe(
324
329
  l,
325
- a,
330
+ i,
326
331
  s
327
332
  );
328
333
  }
@@ -342,7 +347,7 @@ function xe(e) {
342
347
  }));
343
348
  }
344
349
  function ve(e) {
345
- const { output: t } = j.payments.p2tr({
350
+ const { output: t } = q.payments.p2tr({
346
351
  internalPubkey: J.from(e, "hex")
347
352
  });
348
353
  if (!t)
@@ -358,14 +363,14 @@ function Te(e, t) {
358
363
  if (r === o || r === s)
359
364
  return t.registeredPayoutScriptPubKey;
360
365
  if (!t.vaultKeeperBtcPubkeys.some(
361
- (i) => c(i).toLowerCase() === r
366
+ (a) => c(a).toLowerCase() === r
362
367
  ))
363
368
  throw new Error(
364
369
  `Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
365
370
  );
366
371
  return `0x${ve(r)}`;
367
372
  }
368
- function I(e, t) {
373
+ function C(e, t) {
369
374
  return {
370
375
  payoutTxHex: e.payoutTxHex,
371
376
  peginTxHex: t.peginTxHex,
@@ -390,24 +395,24 @@ async function ke(e, t, r, o) {
390
395
  let n;
391
396
  if (s.supportsBatchSigning())
392
397
  n = (await s.signPayoutTransactionsBatch(
393
- r.map((l) => I(l, t))
398
+ r.map((l) => C(l, t))
394
399
  )).map((l) => l.payoutSignature);
395
400
  else {
396
401
  n = [];
397
- for (let a = 0; a < r.length; a++) {
398
- o == null || o(a, u);
402
+ for (let i = 0; i < r.length; i++) {
403
+ o == null || o(i, u);
399
404
  const l = await s.signPayoutTransaction(
400
- I(r[a], t)
405
+ C(r[i], t)
401
406
  );
402
407
  n.push(l.signature);
403
408
  }
404
409
  }
405
- const i = {};
406
- for (let a = 0; a < r.length; a++)
407
- i[r[a].claimerPubkeyXOnly] = {
408
- payout_signature: n[a]
410
+ const a = {};
411
+ for (let i = 0; i < r.length; i++)
412
+ a[r[i].claimerPubkeyXOnly] = {
413
+ payout_signature: n[i]
409
414
  };
410
- return o == null || o(u, u), i;
415
+ return o == null || o(u, u), a;
411
416
  }
412
417
  async function Je(e) {
413
418
  const {
@@ -417,37 +422,37 @@ async function Je(e) {
417
422
  peginTxid: s,
418
423
  depositorPk: u,
419
424
  signingContext: n,
420
- timeoutMs: i = me,
421
- signal: a,
425
+ timeoutMs: a = me,
426
+ signal: i,
422
427
  onProgress: l
423
428
  } = e, f = await N({
424
429
  statusReader: t,
425
430
  peginTxid: s,
426
431
  targetStatuses: we,
427
- timeoutMs: i,
428
- signal: a
432
+ timeoutMs: a,
433
+ signal: i
429
434
  });
430
435
  if (H.has(f))
431
436
  return;
432
- a == null || a.throwIfAborted();
437
+ i == null || i.throwIfAborted();
433
438
  const d = await r.requestDepositorPresignTransactions(
434
439
  {
435
440
  pegin_txid: s,
436
441
  depositor_pk: u
437
442
  },
438
- a
443
+ i
439
444
  );
440
- a == null || a.throwIfAborted();
445
+ i == null || i.throwIfAborted();
441
446
  const g = m(u), P = d.txs.filter(
442
- (L) => m(L.claimer_pubkey) !== g
447
+ (K) => m(K.claimer_pubkey) !== g
443
448
  ), w = xe(P), x = await ke(
444
449
  o,
445
450
  n,
446
451
  w,
447
452
  l
448
453
  );
449
- a == null || a.throwIfAborted();
450
- const h = await ye({
454
+ i == null || i.throwIfAborted();
455
+ const p = await ye({
451
456
  depositorGraph: d.depositor_graph,
452
457
  btcWallet: o,
453
458
  signingContext: {
@@ -464,16 +469,16 @@ async function Je(e) {
464
469
  registeredPayoutScriptPubKey: n.registeredPayoutScriptPubKey
465
470
  }
466
471
  });
467
- a == null || a.throwIfAborted();
472
+ i == null || i.throwIfAborted();
468
473
  const S = { ...x };
469
- S[c(u)] = h.payout_signatures, await r.submitDepositorPresignatures(
474
+ S[c(u)] = p.payout_signatures, await r.submitDepositorPresignatures(
470
475
  {
471
476
  pegin_txid: s,
472
477
  depositor_pk: u,
473
478
  signatures: S,
474
- depositor_claimer_presignatures: h
479
+ depositor_claimer_presignatures: p
475
480
  },
476
- a
481
+ i
477
482
  );
478
483
  }
479
484
  function Ee(e) {
@@ -496,10 +501,10 @@ function et(e, t, r) {
496
501
  error: "Deposit amount must be greater than zero"
497
502
  } : e < t ? {
498
503
  valid: !1,
499
- error: `Minimum deposit is ${p(t)} BTC`
504
+ error: `Minimum deposit is ${h(t)} BTC`
500
505
  } : r && r > 0n && e > r ? {
501
506
  valid: !1,
502
- error: `Maximum deposit is ${p(r)} BTC`
507
+ error: `Maximum deposit is ${h(r)} BTC`
503
508
  } : { valid: !0 };
504
509
  }
505
510
  function tt(e) {
@@ -509,7 +514,7 @@ function tt(e) {
509
514
  error: "Supply cap reached — deposits temporarily paused"
510
515
  } : t > r ? {
511
516
  valid: !1,
512
- error: `Vault size exceeds remaining capacity (${p(r)} BTC)`
517
+ error: `Vault size exceeds remaining capacity (${h(r)} BTC)`
513
518
  } : { valid: !0 };
514
519
  }
515
520
  function rt(e, t) {
@@ -544,12 +549,12 @@ function _e(e, t, r) {
544
549
  if (t && s < t)
545
550
  return {
546
551
  valid: !1,
547
- error: `Vault ${o + 1} amount ${p(s)} BTC is below minimum deposit ${p(t)} BTC`
552
+ error: `Vault ${o + 1} amount ${h(s)} BTC is below minimum deposit ${h(t)} BTC`
548
553
  };
549
554
  if (r && s > r)
550
555
  return {
551
556
  valid: !1,
552
- error: `Vault ${o + 1} amount ${p(s)} BTC exceeds maximum deposit ${p(r)} BTC`
557
+ error: `Vault ${o + 1} amount ${h(s)} BTC exceeds maximum deposit ${h(r)} BTC`
553
558
  };
554
559
  }
555
560
  return { valid: !0 };
@@ -573,7 +578,7 @@ function Be(e) {
573
578
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
574
579
  );
575
580
  }
576
- function Ie(e) {
581
+ function Ce(e) {
577
582
  if (e.length === 0)
578
583
  throw new Error("No spendable UTXOs available");
579
584
  }
@@ -585,21 +590,21 @@ function ot(e) {
585
590
  vaultKeeperBtcPubkeys: s,
586
591
  universalChallengerBtcPubkeys: u,
587
592
  minDeposit: n,
588
- maxDeposit: i
589
- } = e, a = _e(
593
+ maxDeposit: a
594
+ } = e, i = _e(
590
595
  t,
591
596
  n,
592
- i
597
+ a
593
598
  );
594
- if (!a.valid)
595
- throw new Error(a.error);
599
+ if (!i.valid)
600
+ throw new Error(i.error);
596
601
  const l = Se(o);
597
602
  if (!l.valid)
598
603
  throw new Error(l.error);
599
- Ae(s), Be(u), Ie(r);
604
+ Ae(s), Be(u), Ce(r);
600
605
  }
601
606
  var O = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.CHALLENGE_ASSERT_OBSERVED = "ChallengeAssertObserved", e.WRONGLY_CHALLENGED_BROADCAST = "WronglyChallengedBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.FAILED = "Failed", e))(O || {});
602
- const Ce = /* @__PURE__ */ new Set([
607
+ const Ie = /* @__PURE__ */ new Set([
603
608
  "PayoutBroadcast",
604
609
  "Failed"
605
610
  /* FAILED */
@@ -609,8 +614,8 @@ function nt(e) {
609
614
  e
610
615
  );
611
616
  }
612
- function at(e) {
613
- return !!e && Ce.has(e);
617
+ function it(e) {
618
+ return !!e && Ie.has(e);
614
619
  }
615
620
  class Re extends Error {
616
621
  constructor(r, o) {
@@ -628,8 +633,8 @@ function st(e) {
628
633
  );
629
634
  return BigInt(Math.ceil(e * D));
630
635
  }
631
- const He = 1, C = 65535, Oe = /non-BIP68-final/i;
632
- function K(e, t) {
636
+ const He = 1, I = 65535, Oe = /non-BIP68-final/i;
637
+ function L(e, t) {
633
638
  if (e.length !== 66)
634
639
  throw new Error(
635
640
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
@@ -644,9 +649,9 @@ function E(e, t) {
644
649
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
645
650
  }
646
651
  function Ve(e) {
647
- if (K(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > C)
652
+ if (L(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > I)
648
653
  throw new Error(
649
- `htlcVout must be an integer 0-${C}, got ${e.htlcVout}`
654
+ `htlcVout must be an integer 0-${I}, got ${e.htlcVout}`
650
655
  );
651
656
  if (E(e.offchainParamsVersion, "offchainParamsVersion"), E(e.appVaultKeepersVersion, "appVaultKeepersVersion"), E(
652
657
  e.universalChallengersVersion,
@@ -686,8 +691,8 @@ function De(e) {
686
691
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
687
692
  );
688
693
  }
689
- function Ke(e) {
690
- const t = q.fromHex(e);
694
+ function Le(e) {
695
+ const t = j.fromHex(e);
691
696
  try {
692
697
  t.finalizeAllInputs();
693
698
  } catch (r) {
@@ -697,7 +702,7 @@ function Ke(e) {
697
702
  }
698
703
  return t.extractTransaction().toHex();
699
704
  }
700
- async function it(e) {
705
+ async function at(e) {
701
706
  const {
702
707
  vaultId: t,
703
708
  readVault: r,
@@ -705,59 +710,59 @@ async function it(e) {
705
710
  feeRate: s,
706
711
  signPsbt: u,
707
712
  broadcastTx: n,
708
- signal: i
713
+ signal: a
709
714
  } = e;
710
- i == null || i.throwIfAborted(), K(t, "vaultId");
711
- const a = await r();
712
- Ve(a), i == null || i.throwIfAborted();
713
- const l = await o(a);
714
- if (De(l), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
715
+ a == null || a.throwIfAborted(), L(t, "vaultId");
716
+ const i = await r();
717
+ Ve(i), a == null || a.throwIfAborted();
718
+ const l = await o(i);
719
+ if (De(l), a == null || a.throwIfAborted(), !Number.isFinite(s) || s <= 0)
715
720
  throw new Error(`feeRate must be a positive number, got ${s}`);
716
721
  const f = BigInt(Math.ceil(s * D));
717
- i == null || i.throwIfAborted();
722
+ a == null || a.throwIfAborted();
718
723
  const d = m(
719
- a.depositorBtcPubkey
724
+ i.depositorBtcPubkey
720
725
  ), { psbtHex: g } = await te({
721
726
  prePeginParams: {
722
727
  depositorPubkey: d,
723
728
  vaultProviderPubkey: c(l.vaultProviderPubkey),
724
729
  vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(c),
725
730
  universalChallengerPubkeys: l.universalChallengerPubkeys.map(c),
726
- hashlocks: [c(a.hashlock)],
731
+ hashlocks: [c(i.hashlock)],
727
732
  timelockRefund: l.timelockRefund,
728
- pegInAmounts: [a.amount],
733
+ pegInAmounts: [i.amount],
729
734
  feeRate: l.feeRate,
730
735
  numLocalChallengers: l.numLocalChallengers,
731
736
  councilQuorum: l.councilQuorum,
732
737
  councilSize: l.councilSize,
733
738
  network: l.network
734
739
  },
735
- fundedPrePeginTxHex: c(a.unsignedPrePeginTxHex),
736
- htlcVout: a.htlcVout,
740
+ fundedPrePeginTxHex: c(i.unsignedPrePeginTxHex),
741
+ htlcVout: i.htlcVout,
737
742
  refundFee: f,
738
743
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
739
744
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
740
745
  // value would derive the wrong refund script leaf and yield an
741
746
  // unspendable PSBT. Match the `hashlocks` array handling above.
742
- hashlock: c(a.hashlock)
747
+ hashlock: c(i.hashlock)
743
748
  });
744
- i == null || i.throwIfAborted();
749
+ a == null || a.throwIfAborted();
745
750
  const P = _(
746
- a.depositorBtcPubkey,
751
+ i.depositorBtcPubkey,
747
752
  He
748
- ), w = await u(g, P), x = Ke(w);
749
- i == null || i.throwIfAborted();
753
+ ), w = await u(g, P), x = Le(w);
754
+ a == null || a.throwIfAborted();
750
755
  try {
751
756
  return await n(x);
752
- } catch (h) {
753
- throw h instanceof Error && Oe.test(h.message) ? new Re(t, h) : h;
757
+ } catch (p) {
758
+ throw p instanceof Error && Oe.test(p.message) ? new Re(t, p) : p;
754
759
  }
755
760
  }
756
761
  export {
757
762
  Re as B,
758
763
  O as C,
759
764
  D as R,
760
- je as a,
765
+ qe as a,
761
766
  ye as b,
762
767
  tt as c,
763
768
  rt as d,
@@ -766,12 +771,12 @@ export {
766
771
  ot as g,
767
772
  nt as h,
768
773
  Ze as i,
769
- at as j,
770
- it as k,
774
+ it as j,
775
+ at as k,
771
776
  st as l,
772
777
  Je as r,
773
- qe as s,
778
+ je as s,
774
779
  et as v,
775
780
  N as w
776
781
  };
777
- //# sourceMappingURL=buildAndBroadcastRefund-D_QlvCsw.js.map
782
+ //# sourceMappingURL=buildAndBroadcastRefund-CPjXNaMi.js.map