@babylonlabs-io/ts-sdk 0.38.0 → 0.39.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 (85) hide show
  1. package/dist/PayoutManager-D29D-K-V.js +250 -0
  2. package/dist/PayoutManager-D29D-K-V.js.map +1 -0
  3. package/dist/PayoutManager-DERMRuUU.cjs +2 -0
  4. package/dist/PayoutManager-DERMRuUU.cjs.map +1 -0
  5. package/dist/{PeginManager-C1en2vwr.js → PeginManager-DXrfY4d6.js} +376 -344
  6. package/dist/PeginManager-DXrfY4d6.js.map +1 -0
  7. package/dist/PeginManager-zkTJOy_U.cjs +2 -0
  8. package/dist/PeginManager-zkTJOy_U.cjs.map +1 -0
  9. package/dist/assertPsbtUnsignedTxMatches-fNkAaZZm.cjs +2 -0
  10. package/dist/assertPsbtUnsignedTxMatches-fNkAaZZm.cjs.map +1 -0
  11. package/dist/assertPsbtUnsignedTxMatches-mTAnLhCz.js +340 -0
  12. package/dist/assertPsbtUnsignedTxMatches-mTAnLhCz.js.map +1 -0
  13. package/dist/{buildAndBroadcastRefund-vwfVgJeA.js → buildAndBroadcastRefund-B5cOyUzj.js} +138 -132
  14. package/dist/{buildAndBroadcastRefund-vwfVgJeA.js.map → buildAndBroadcastRefund-B5cOyUzj.js.map} +1 -1
  15. package/dist/buildAndBroadcastRefund-DVMT-pXQ.cjs +2 -0
  16. package/dist/{buildAndBroadcastRefund-CEKwFY8l.cjs.map → buildAndBroadcastRefund-DVMT-pXQ.cjs.map} +1 -1
  17. package/dist/{challengeAssert-D7OCrDIc.js → challengeAssert-CBp4mEs0.js} +2 -2
  18. package/dist/{challengeAssert-D7OCrDIc.js.map → challengeAssert-CBp4mEs0.js.map} +1 -1
  19. package/dist/{challengeAssert-CMb7r-je.cjs → challengeAssert-CNRdpCzm.cjs} +2 -2
  20. package/dist/{challengeAssert-CMb7r-je.cjs.map → challengeAssert-CNRdpCzm.cjs.map} +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +140 -139
  23. package/dist/noPayout-jtZsoOzY.cjs +2 -0
  24. package/dist/noPayout-jtZsoOzY.cjs.map +1 -0
  25. package/dist/noPayout-qbaSEKGC.js +145 -0
  26. package/dist/noPayout-qbaSEKGC.js.map +1 -0
  27. package/dist/peginInput-BPRB9tUi.js +104 -0
  28. package/dist/peginInput-BPRB9tUi.js.map +1 -0
  29. package/dist/peginInput-DH6X4ITS.cjs +2 -0
  30. package/dist/peginInput-DH6X4ITS.cjs.map +1 -0
  31. package/dist/tbv/core/clients/eth/types.d.ts +2 -0
  32. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  33. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +5 -0
  34. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  35. package/dist/tbv/core/clients/index.cjs +1 -1
  36. package/dist/tbv/core/clients/index.js +1 -1
  37. package/dist/tbv/core/index.cjs +1 -1
  38. package/dist/tbv/core/index.js +139 -138
  39. package/dist/tbv/core/managers/PeginManager.d.ts +25 -0
  40. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  41. package/dist/tbv/core/managers/index.cjs +1 -1
  42. package/dist/tbv/core/managers/index.d.ts +2 -2
  43. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  44. package/dist/tbv/core/managers/index.js +5 -4
  45. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts +37 -0
  46. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts.map +1 -1
  47. package/dist/tbv/core/managers/pegin/index.d.ts +1 -1
  48. package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -1
  49. package/dist/tbv/core/primitives/index.cjs +1 -1
  50. package/dist/tbv/core/primitives/index.js +17 -17
  51. package/dist/tbv/core/primitives/psbt/__tests__/refund.test.d.ts +12 -0
  52. package/dist/tbv/core/primitives/psbt/__tests__/refund.test.d.ts.map +1 -0
  53. package/dist/tbv/core/primitives/psbt/pegin.d.ts +5 -0
  54. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  55. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  56. package/dist/tbv/core/services/index.cjs +1 -1
  57. package/dist/tbv/core/services/index.js +2 -2
  58. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  59. package/dist/tbv/index.cjs +1 -1
  60. package/dist/tbv/index.js +139 -138
  61. package/dist/{vault-registry-reader-CbJHSxVe.cjs → vault-registry-reader-BM_993Lb.cjs} +2 -2
  62. package/dist/{vault-registry-reader-CbJHSxVe.cjs.map → vault-registry-reader-BM_993Lb.cjs.map} +1 -1
  63. package/dist/{vault-registry-reader-BrARgFre.js → vault-registry-reader-DXvw-1f6.js} +28 -16
  64. package/dist/{vault-registry-reader-BrARgFre.js.map → vault-registry-reader-DXvw-1f6.js.map} +1 -1
  65. package/package.json +3 -3
  66. package/dist/PayoutManager-BfT0V-tm.cjs +0 -2
  67. package/dist/PayoutManager-BfT0V-tm.cjs.map +0 -1
  68. package/dist/PayoutManager-Cf51DBcu.js +0 -208
  69. package/dist/PayoutManager-Cf51DBcu.js.map +0 -1
  70. package/dist/PeginManager-BRHJZYmE.cjs +0 -2
  71. package/dist/PeginManager-BRHJZYmE.cjs.map +0 -1
  72. package/dist/PeginManager-C1en2vwr.js.map +0 -1
  73. package/dist/assertPsbtUnsignedTxMatches-CagW7XqW.cjs +0 -2
  74. package/dist/assertPsbtUnsignedTxMatches-CagW7XqW.cjs.map +0 -1
  75. package/dist/assertPsbtUnsignedTxMatches-Dry5dTfl.js +0 -266
  76. package/dist/assertPsbtUnsignedTxMatches-Dry5dTfl.js.map +0 -1
  77. package/dist/buildAndBroadcastRefund-CEKwFY8l.cjs +0 -2
  78. package/dist/noPayout-B6s8vrW6.cjs +0 -2
  79. package/dist/noPayout-B6s8vrW6.cjs.map +0 -1
  80. package/dist/noPayout-BhgknZBx.js +0 -141
  81. package/dist/noPayout-BhgknZBx.js.map +0 -1
  82. package/dist/peginInput-57FK2O99.cjs +0 -2
  83. package/dist/peginInput-57FK2O99.cjs.map +0 -1
  84. package/dist/peginInput-CYJzbuwA.js +0 -177
  85. package/dist/peginInput-CYJzbuwA.js.map +0 -1
@@ -1,16 +1,16 @@
1
- var Q = Object.defineProperty;
2
- var j = (e, t, r) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var C = (e, t, r) => j(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { B as W } from "./BTCVaultRegistry.abi-Cq9-JlqT.js";
5
- import { e as Y, v as q, s as h, u as O, p as k, d as J, f as w } from "./bitcoin-B5aNKtsk.js";
6
- import { v as Z, P as ee } from "./PayoutManager-Cf51DBcu.js";
7
- import { D as y, c as te, a as re, R as ne, d as D } from "./types-TOmEvvRy.js";
8
- import { Transaction as T, Psbt as oe } from "bitcoinjs-lib";
9
- import { a as se, b as ae, c as V, e as I } from "./assertPsbtUnsignedTxMatches-Dry5dTfl.js";
10
- import { c as ie, a as ue, b as le } from "./noPayout-BhgknZBx.js";
11
- import { c as R } from "./signing-DaLvGwQe.js";
1
+ var G = Object.defineProperty;
2
+ var Q = (e, t, r) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var S = (e, t, r) => Q(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { B as j } from "./BTCVaultRegistry.abi-Cq9-JlqT.js";
5
+ import { e as q, v as W, s as h, u as N, p as k, d as Y, f as x } from "./bitcoin-B5aNKtsk.js";
6
+ import { v as J, P as Z, f as ee } from "./PayoutManager-D29D-K-V.js";
7
+ import { D as v, c as te, a as re, R as ne, d as O } from "./types-TOmEvvRy.js";
8
+ import { Transaction as _, Psbt as oe } from "bitcoinjs-lib";
9
+ import { c as se, d as ae, f as V, e as I } from "./assertPsbtUnsignedTxMatches-mTAnLhCz.js";
10
+ import { c as ie, a as ue, b as le } from "./noPayout-qbaSEKGC.js";
11
+ import { c as $ } from "./signing-DaLvGwQe.js";
12
12
  const ce = /^0x[0-9a-fA-F]{64}$/, de = /^0x[0-9a-fA-F]{40}$/, he = /^0x([0-9a-fA-F]{2})*$/;
13
- function S(e, t) {
13
+ function A(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}`
@@ -26,7 +26,7 @@ function pe(e, t) {
26
26
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
27
27
  );
28
28
  }
29
- function ge(e, t) {
29
+ function fe(e, t) {
30
30
  if (!he.test(e))
31
31
  throw new Error(
32
32
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
@@ -41,27 +41,27 @@ async function tt(e) {
41
41
  writeContract: u,
42
42
  signal: a
43
43
  } = e;
44
- a == null || a.throwIfAborted(), pe(t, "btcVaultRegistryAddress"), S(r, "vaultId");
45
- const i = Y(e.secret);
46
- if (S(i, "secret"), n !== void 0 && (S(n, "hashlock"), !Z(i, n)))
44
+ a == null || a.throwIfAborted(), pe(t, "btcVaultRegistryAddress"), A(r, "vaultId");
45
+ const i = q(e.secret);
46
+ if (A(i, "secret"), n !== void 0 && (A(n, "hashlock"), !J(i, n)))
47
47
  throw new Error(
48
48
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
49
49
  );
50
- return ge(o, "activationMetadata"), u({
50
+ return fe(o, "activationMetadata"), u({
51
51
  address: t,
52
- abi: W,
52
+ abi: j,
53
53
  functionName: "activateVaultWithSecret",
54
54
  args: [r, i, o]
55
55
  });
56
56
  }
57
- const fe = 1e4;
58
- async function U(e) {
57
+ const ge = 1e4;
58
+ async function D(e) {
59
59
  const {
60
60
  statusReader: t,
61
61
  peginTxid: r,
62
62
  targetStatuses: n,
63
63
  timeoutMs: o,
64
- pollIntervalMs: u = fe,
64
+ pollIntervalMs: u = ge,
65
65
  signal: a
66
66
  } = e, i = Date.now();
67
67
  for (; ; ) {
@@ -83,9 +83,9 @@ async function U(e) {
83
83
  `getPeginStatus returned status for pegin ${s.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
84
84
  );
85
85
  const l = s.status;
86
- if (n.has(l) || l === y.ACTIVATED)
86
+ if (n.has(l) || l === v.ACTIVATED)
87
87
  return l;
88
- if (l === y.EXPIRED || te.has(l))
88
+ if (l === v.EXPIRED || te.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
  );
@@ -108,8 +108,8 @@ async function U(e) {
108
108
  }
109
109
  }
110
110
  const Pe = 300 * 1e3, ye = /* @__PURE__ */ new Set([
111
- y.PENDING_DEPOSITOR_WOTS_PK,
112
- ...D
111
+ v.PENDING_DEPOSITOR_WOTS_PK,
112
+ ...O
113
113
  ]);
114
114
  async function rt(e) {
115
115
  const {
@@ -122,14 +122,14 @@ async function rt(e) {
122
122
  signal: i
123
123
  } = e;
124
124
  i == null || i.throwIfAborted();
125
- const s = await U({
125
+ const s = await D({
126
126
  statusReader: t,
127
127
  peginTxid: n,
128
128
  targetStatuses: ye,
129
129
  timeoutMs: a,
130
130
  signal: i
131
131
  });
132
- D.has(s) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
132
+ O.has(s) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
133
133
  {
134
134
  pegin_txid: n,
135
135
  depositor_pk: o,
@@ -139,7 +139,7 @@ async function rt(e) {
139
139
  ));
140
140
  }
141
141
  const H = 1;
142
- function me(e, t) {
142
+ function be(e, t) {
143
143
  const r = h(t).toLowerCase(), o = e.map((u) => h(u).toLowerCase()).filter((u) => u !== r);
144
144
  if (o.length === 0)
145
145
  throw new Error(
@@ -151,7 +151,7 @@ function me(e, t) {
151
151
  );
152
152
  return o;
153
153
  }
154
- function be(e, t, r) {
154
+ function me(e, t, r) {
155
155
  const n = r.map(
156
156
  (c) => h(c).toLowerCase()
157
157
  ), o = t.filter((c) => n.includes(c));
@@ -172,9 +172,9 @@ function be(e, t, r) {
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 we(e, t) {
175
+ function ve(e, t) {
176
176
  const r = e.ins[t];
177
- return O(new Uint8Array(r.hash).slice().reverse());
177
+ return N(new Uint8Array(r.hash).slice().reverse());
178
178
  }
179
179
  function B(e, t, r, n, o) {
180
180
  const u = e.ins[t];
@@ -182,18 +182,18 @@ function B(e, t, r, n, o) {
182
182
  throw new Error(
183
183
  `NoPayout (challenger ${o}) input ${t} expected to spend ${n} vout 0, got vout ${u.index}`
184
184
  );
185
- const a = r.getId(), i = we(e, t);
185
+ const a = r.getId(), i = ve(e, t);
186
186
  if (i !== a)
187
187
  throw new Error(
188
188
  `NoPayout (challenger ${o}) input ${t} does not reference ${n} (expected txid ${a}, got ${i})`
189
189
  );
190
190
  }
191
- async function xe(e, t, r) {
192
- const n = [], o = [], u = [], a = me(
191
+ async function we(e, t, r) {
192
+ const n = [], o = [], u = [], a = be(
193
193
  r.vaultKeeperBtcPubkeys,
194
194
  r.depositorBtcPubkey
195
195
  );
196
- be(
196
+ me(
197
197
  e.challenger_presign_data,
198
198
  a,
199
199
  r.universalChallengerBtcPubkeys
@@ -213,16 +213,16 @@ async function xe(e, t, r) {
213
213
  network: r.network
214
214
  });
215
215
  n.push(i.psbtHex), o.push(
216
- R(
216
+ $(
217
217
  t,
218
218
  H
219
219
  )
220
220
  );
221
- const s = h(r.depositorBtcPubkey), l = T.fromHex(
221
+ const s = h(r.depositorBtcPubkey), l = _.fromHex(
222
222
  h(e.assert_tx.tx_hex)
223
223
  );
224
224
  for (const d of e.challenger_presign_data) {
225
- const c = h(d.challenger_pubkey), g = n.length, m = await ve({
225
+ const c = h(d.challenger_pubkey), g = n.length, P = await xe({
226
226
  challenger: d,
227
227
  challengerPubkey: c,
228
228
  claimerPubkey: s,
@@ -230,8 +230,8 @@ async function xe(e, t, r) {
230
230
  assertTxParsed: l,
231
231
  ctx: r
232
232
  });
233
- n.push(m), o.push(
234
- R(
233
+ n.push(P), o.push(
234
+ $(
235
235
  t,
236
236
  H
237
237
  )
@@ -242,7 +242,7 @@ async function xe(e, t, r) {
242
242
  }
243
243
  return { psbtHexes: n, signOptions: o, challengerEntries: u };
244
244
  }
245
- async function ve(e) {
245
+ async function xe(e) {
246
246
  const {
247
247
  challenger: t,
248
248
  challengerPubkey: r,
@@ -256,11 +256,11 @@ async function ve(e) {
256
256
  r,
257
257
  a.network
258
258
  );
259
- const i = T.fromHex(
259
+ const i = _.fromHex(
260
260
  h(t.nopayout_tx.tx_hex)
261
- ), s = T.fromHex(
261
+ ), s = _.fromHex(
262
262
  h(t.challenge_assert_x_tx.tx_hex)
263
- ), l = T.fromHex(
263
+ ), l = _.fromHex(
264
264
  h(t.challenge_assert_y_tx.tx_hex)
265
265
  );
266
266
  if (i.ins.length !== 3)
@@ -291,7 +291,7 @@ async function ve(e) {
291
291
  s.outs[0],
292
292
  l.outs[0]
293
293
  ].map((c) => ({
294
- script_pubkey: O(new Uint8Array(c.script)),
294
+ script_pubkey: N(new Uint8Array(c.script)),
295
295
  value: c.value
296
296
  }));
297
297
  return ue({
@@ -308,7 +308,7 @@ async function ve(e) {
308
308
  }
309
309
  });
310
310
  }
311
- function ke(e, t, r) {
311
+ function Te(e, t, r) {
312
312
  V(e[0]);
313
313
  const n = I(
314
314
  e[0].returnedPsbtHex,
@@ -328,7 +328,7 @@ function ke(e, t, r) {
328
328
  per_challenger: o
329
329
  };
330
330
  }
331
- async function Te(e, t, r) {
331
+ async function ke(e, t, r) {
332
332
  if (typeof e.signPsbts == "function")
333
333
  return e.signPsbts(t, r);
334
334
  const n = [];
@@ -337,14 +337,14 @@ async function Te(e, t, r) {
337
337
  return n;
338
338
  }
339
339
  async function Ee(e) {
340
- const { depositorGraph: t, btcWallet: r, signingContext: n } = e, o = await r.getPublicKeyHex(), { depositorPubkey: u } = q(
340
+ const { depositorGraph: t, btcWallet: r, signingContext: n } = e, o = await r.getPublicKeyHex(), { depositorPubkey: u } = W(
341
341
  o,
342
342
  h(n.depositorBtcPubkey)
343
- ), { psbtHexes: a, signOptions: i, challengerEntries: s } = await xe(
343
+ ), { psbtHexes: a, signOptions: i, challengerEntries: s } = await we(
344
344
  t,
345
345
  o,
346
346
  n
347
- ), l = await Te(
347
+ ), l = await ke(
348
348
  r,
349
349
  a,
350
350
  i
@@ -357,19 +357,19 @@ async function Ee(e) {
357
357
  requestedPsbtHex: c,
358
358
  returnedPsbtHex: l[g]
359
359
  }));
360
- return ke(
360
+ return Te(
361
361
  d,
362
362
  s,
363
363
  u
364
364
  );
365
365
  }
366
366
  const _e = 1200 * 1e3, L = /* @__PURE__ */ new Set([
367
- y.PENDING_ACKS,
368
- y.PENDING_ACTIVATION,
369
- y.ACTIVATED_PENDING_BROADCAST,
370
- y.ACTIVATED
367
+ v.PENDING_ACKS,
368
+ v.PENDING_ACTIVATION,
369
+ v.ACTIVATED_PENDING_BROADCAST,
370
+ v.ACTIVATED
371
371
  ]), Ce = /* @__PURE__ */ new Set([
372
- y.PENDING_DEPOSITOR_SIGNATURES,
372
+ v.PENDING_DEPOSITOR_SIGNATURES,
373
373
  ...L
374
374
  ]);
375
375
  function Se(e) {
@@ -379,7 +379,7 @@ function Se(e) {
379
379
  assertTxHex: t.assert_tx.tx_hex
380
380
  }));
381
381
  }
382
- function Be(e, t) {
382
+ function Ae(e, t) {
383
383
  const r = h(e).toLowerCase(), n = h(
384
384
  t.vaultProviderBtcPubkey
385
385
  ).toLowerCase(), o = h(
@@ -393,7 +393,7 @@ function Be(e, t) {
393
393
  throw new Error(
394
394
  `Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
395
395
  );
396
- return J(r);
396
+ return Y(r);
397
397
  }
398
398
  function K(e, t) {
399
399
  return {
@@ -405,14 +405,14 @@ function K(e, t) {
405
405
  universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
406
406
  depositorBtcPubkey: t.depositorBtcPubkey,
407
407
  timelockPegin: t.timelockPegin,
408
- registeredPayoutScriptPubKey: Be(
408
+ registeredPayoutScriptPubKey: Ae(
409
409
  e.claimerPubkeyXOnly,
410
410
  t
411
411
  )
412
412
  };
413
413
  }
414
- async function Ae(e, t, r, n) {
415
- const o = new ee({
414
+ async function Be(e, t, r, n) {
415
+ const o = new Z({
416
416
  network: t.network,
417
417
  btcWallet: e
418
418
  }), u = r.length;
@@ -450,7 +450,7 @@ async function nt(e) {
450
450
  timeoutMs: i = _e,
451
451
  signal: s,
452
452
  onProgress: l
453
- } = e, d = await U({
453
+ } = e, d = await D({
454
454
  statusReader: t,
455
455
  peginTxid: o,
456
456
  targetStatuses: Ce,
@@ -468,16 +468,16 @@ async function nt(e) {
468
468
  s
469
469
  );
470
470
  s == null || s.throwIfAborted();
471
- const g = k(u), m = c.txs.filter(
472
- (v) => k(v.claimer_pubkey) !== g
473
- ), b = Se(m), f = await Ae(
471
+ const g = k(u), P = c.txs.filter(
472
+ (b) => k(b.claimer_pubkey) !== g
473
+ ), p = Se(P), y = await Be(
474
474
  n,
475
475
  a,
476
- b,
476
+ p,
477
477
  l
478
478
  );
479
479
  s == null || s.throwIfAborted();
480
- const P = await Ee({
480
+ const T = await Ee({
481
481
  depositorGraph: c.depositor_graph,
482
482
  btcWallet: n,
483
483
  signingContext: {
@@ -495,18 +495,18 @@ async function nt(e) {
495
495
  }
496
496
  });
497
497
  s == null || s.throwIfAborted();
498
- const x = { ...f };
499
- x[h(u)] = P.payout_signatures, await r.submitDepositorPresignatures(
498
+ const w = { ...y };
499
+ w[h(u)] = T.payout_signatures, await r.submitDepositorPresignatures(
500
500
  {
501
501
  pegin_txid: o,
502
502
  depositor_pk: u,
503
- signatures: x,
504
- depositor_claimer_presignatures: P
503
+ signatures: w,
504
+ depositor_claimer_presignatures: T
505
505
  },
506
506
  s
507
507
  );
508
508
  }
509
- function Ve(e) {
509
+ function Re(e) {
510
510
  return /^[0-9a-fA-F]{64}$/.test(e);
511
511
  }
512
512
  function ot(e) {
@@ -526,10 +526,10 @@ function st(e, t, r) {
526
526
  error: "Deposit amount must be greater than zero"
527
527
  } : e < t ? {
528
528
  valid: !1,
529
- error: `Minimum deposit is ${w(t)} BTC`
529
+ error: `Minimum deposit is ${x(t)} BTC`
530
530
  } : r && r > 0n && e > r ? {
531
531
  valid: !1,
532
- error: `Maximum deposit is ${w(r)} BTC`
532
+ error: `Maximum deposit is ${x(r)} BTC`
533
533
  } : { valid: !0 };
534
534
  }
535
535
  function at(e) {
@@ -539,7 +539,7 @@ function at(e) {
539
539
  error: "Supply cap reached — deposits temporarily paused"
540
540
  } : t > r ? {
541
541
  valid: !1,
542
- error: `Vault size exceeds remaining capacity (${w(r)} BTC)`
542
+ error: `Vault size exceeds remaining capacity (${x(r)} BTC)`
543
543
  } : { valid: !0 };
544
544
  }
545
545
  function it(e, t) {
@@ -558,7 +558,7 @@ function it(e, t) {
558
558
  error: "Invalid vault provider selected"
559
559
  } : { valid: !0 };
560
560
  }
561
- function Re(e, t, r) {
561
+ function Ve(e, t, r) {
562
562
  if (!e || e.length === 0)
563
563
  return {
564
564
  valid: !1,
@@ -574,19 +574,19 @@ function Re(e, t, r) {
574
574
  if (t && o < t)
575
575
  return {
576
576
  valid: !1,
577
- error: `Vault ${n + 1} amount ${w(o)} BTC is below minimum deposit ${w(t)} BTC`
577
+ error: `Vault ${n + 1} amount ${x(o)} BTC is below minimum deposit ${x(t)} BTC`
578
578
  };
579
579
  if (r && o > r)
580
580
  return {
581
581
  valid: !1,
582
- error: `Vault ${n + 1} amount ${w(o)} BTC exceeds maximum deposit ${w(r)} BTC`
582
+ error: `Vault ${n + 1} amount ${x(o)} BTC exceeds maximum deposit ${x(r)} BTC`
583
583
  };
584
584
  }
585
585
  return { valid: !0 };
586
586
  }
587
587
  function $e(e) {
588
588
  const t = h(e);
589
- return Ve(t) ? { valid: !0 } : {
589
+ return Re(t) ? { valid: !0 } : {
590
590
  valid: !1,
591
591
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
592
592
  };
@@ -616,7 +616,7 @@ function ut(e) {
616
616
  universalChallengerBtcPubkeys: u,
617
617
  minDeposit: a,
618
618
  maxDeposit: i
619
- } = e, s = Re(
619
+ } = e, s = Ve(
620
620
  t,
621
621
  a,
622
622
  i
@@ -646,7 +646,7 @@ async function lt(e) {
646
646
  t.getVaultProviderBtcPubKey(o),
647
647
  r.getCurrentVaultKeepersVersion(u),
648
648
  n.getLatestUniversalChallengersVersion()
649
- ]), [g, m] = await Promise.all([
649
+ ]), [g, P] = await Promise.all([
650
650
  r.getVaultKeepersByVersion(
651
651
  u,
652
652
  d
@@ -654,40 +654,40 @@ async function lt(e) {
654
654
  n.getUniversalChallengersByVersion(
655
655
  c
656
656
  )
657
- ]), b = (p) => k(p).toLowerCase(), f = (p) => p.map(b).sort();
658
- if (b(a) !== l)
657
+ ]), p = (f) => k(f).toLowerCase(), y = (f) => f.map(p).sort();
658
+ if (p(a) !== l)
659
659
  throw new Error(
660
660
  `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${o}. Refresh and try again.`
661
661
  );
662
- const x = f(i), v = f(
663
- g.map((p) => p.btcPubKey)
662
+ const w = y(i), b = y(
663
+ g.map((f) => f.btcPubKey)
664
664
  );
665
- if (x.length !== v.length || x.some((p, _) => p !== v[_]))
665
+ if (w.length !== b.length || w.some((f, C) => f !== b[C]))
666
666
  throw new Error(
667
667
  `Vault keeper BTC pubkeys (v${d}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
668
668
  );
669
- const $ = f(s), E = f(
670
- m.map((p) => p.btcPubKey)
669
+ const E = y(s), m = y(
670
+ P.map((f) => f.btcPubKey)
671
671
  );
672
- if ($.length !== E.length || $.some((p, _) => p !== E[_]))
672
+ if (E.length !== m.length || E.some((f, C) => f !== m[C]))
673
673
  throw new Error(
674
674
  `Universal challenger BTC pubkeys (v${c}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
675
675
  );
676
676
  return {
677
677
  vaultProviderBtcPubkeyXOnly: l,
678
- vaultKeeperBtcPubkeysSorted: v,
679
- universalChallengerBtcPubkeysSorted: E,
678
+ vaultKeeperBtcPubkeysSorted: b,
679
+ universalChallengerBtcPubkeysSorted: m,
680
680
  expectedAppVaultKeepersVersion: d,
681
681
  expectedUniversalChallengersVersion: c
682
682
  };
683
683
  }
684
- class M extends Error {
684
+ class U extends Error {
685
685
  constructor(t) {
686
686
  super(t), this.name = "RegisteredVaultVersionMismatchError";
687
687
  }
688
688
  }
689
689
  function ct(e) {
690
- return e instanceof M || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
690
+ return e instanceof U || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
691
691
  }
692
692
  async function dt(e) {
693
693
  const {
@@ -707,18 +707,18 @@ async function dt(e) {
707
707
  `vault ${d}: universalChallengers expected v${u}, got v${s.universalChallengersVersion}`
708
708
  );
709
709
  }), i.length > 0)
710
- throw new M(
710
+ throw new U(
711
711
  `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${i.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
712
712
  );
713
713
  }
714
- var F = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(F || {});
714
+ var M = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(M || {});
715
715
  const Ne = /* @__PURE__ */ new Set([
716
716
  "PayoutBroadcast",
717
717
  "PayoutBlocked"
718
718
  /* PAYOUT_BLOCKED */
719
719
  ]);
720
720
  function ht(e) {
721
- return Object.values(F).includes(
721
+ return Object.values(M).includes(
722
722
  e
723
723
  );
724
724
  }
@@ -728,21 +728,21 @@ function pt(e) {
728
728
  class Oe extends Error {
729
729
  constructor(r, n) {
730
730
  super(`Refund not yet mature (BIP68 not final): ${n.message}`);
731
- C(this, "vaultId");
732
- C(this, "cause");
731
+ S(this, "vaultId");
732
+ S(this, "cause");
733
733
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
734
734
  }
735
735
  }
736
- const De = /^0x[0-9a-fA-F]{64}$/, Ue = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, X = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, z = 160;
737
- function gt(e) {
736
+ const De = /^0x[0-9a-fA-F]{64}$/, Le = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, F = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, X = 160;
737
+ function ft(e) {
738
738
  if (!Number.isFinite(e) || e <= 0)
739
739
  throw new Error(
740
740
  `feeRateSatsVb must be a positive finite number, got ${e}`
741
741
  );
742
- return BigInt(Math.ceil(e * z));
742
+ return BigInt(Math.ceil(e * X));
743
743
  }
744
- const Le = 1, N = 65535, Me = /non-BIP68-final/i;
745
- function G(e, t) {
744
+ const Ue = 1, Me = /non-BIP68-final/i;
745
+ function z(e, t) {
746
746
  if (e.length !== 66)
747
747
  throw new Error(
748
748
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
@@ -752,25 +752,25 @@ function G(e, t) {
752
752
  `${t} must contain only hex characters after the 0x prefix`
753
753
  );
754
754
  }
755
- function A(e, t) {
755
+ function R(e, t) {
756
756
  if (!Number.isInteger(e) || e < 0)
757
757
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
758
758
  }
759
759
  function Fe(e) {
760
- if (G(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > N)
760
+ if (z(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout !== 0)
761
761
  throw new Error(
762
- `htlcVout must be an integer 0-${N}, got ${e.htlcVout}`
762
+ `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.`
763
763
  );
764
- if (A(e.offchainParamsVersion, "offchainParamsVersion"), A(e.appVaultKeepersVersion, "appVaultKeepersVersion"), A(
764
+ if (R(e.offchainParamsVersion, "offchainParamsVersion"), R(e.appVaultKeepersVersion, "appVaultKeepersVersion"), R(
765
765
  e.universalChallengersVersion,
766
766
  "universalChallengersVersion"
767
767
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
768
768
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
769
- if (!Ue.test(e.unsignedPrePeginTxHex))
769
+ if (!Le.test(e.unsignedPrePeginTxHex))
770
770
  throw new Error(
771
771
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
772
772
  );
773
- if (!e.depositorBtcPubkey || !X.test(e.depositorBtcPubkey))
773
+ if (!e.depositorBtcPubkey || !F.test(e.depositorBtcPubkey))
774
774
  throw new Error(
775
775
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
776
776
  );
@@ -778,7 +778,7 @@ function Fe(e) {
778
778
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
779
779
  }
780
780
  function Xe(e) {
781
- if (!e.vaultProviderPubkey || !X.test(e.vaultProviderPubkey))
781
+ if (!e.vaultProviderPubkey || !F.test(e.vaultProviderPubkey))
782
782
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
783
783
  if (e.vaultKeeperPubkeys.length === 0)
784
784
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -810,7 +810,7 @@ function ze(e) {
810
810
  }
811
811
  return t.extractTransaction().toHex();
812
812
  }
813
- async function ft(e) {
813
+ async function gt(e) {
814
814
  const {
815
815
  vaultId: t,
816
816
  readVault: r,
@@ -820,17 +820,22 @@ async function ft(e) {
820
820
  broadcastTx: a,
821
821
  signal: i
822
822
  } = e;
823
- i == null || i.throwIfAborted(), G(t, "vaultId");
823
+ i == null || i.throwIfAborted(), z(t, "vaultId");
824
824
  const s = await r();
825
825
  Fe(s), i == null || i.throwIfAborted();
826
826
  const l = await n(s);
827
827
  if (Xe(l), i == null || i.throwIfAborted(), !Number.isFinite(o) || o <= 0)
828
828
  throw new Error(`feeRate must be a positive number, got ${o}`);
829
- const d = BigInt(Math.ceil(o * z));
829
+ const d = BigInt(Math.ceil(o * X));
830
830
  i == null || i.throwIfAborted();
831
831
  const c = k(
832
832
  s.depositorBtcPubkey
833
- ), { psbtHex: g } = await le({
833
+ ), g = h(s.unsignedPrePeginTxHex), P = 1, p = ee(g);
834
+ if (p !== void 0 && p.vout !== P)
835
+ throw new Error(
836
+ `Multi-vault Pre-PegIn refund is not supported by this SDK call (auth-anchor OP_RETURN at vout ${p.vout}; single-vault refund expects vout ${P}). Refund of batched-deposit vaults requires reconstructing all sibling HTLCs.`
837
+ );
838
+ const y = p == null ? void 0 : p.hash, { psbtHex: T } = await le({
834
839
  prePeginParams: {
835
840
  depositorPubkey: c,
836
841
  vaultProviderPubkey: h(l.vaultProviderPubkey),
@@ -843,9 +848,10 @@ async function ft(e) {
843
848
  numLocalChallengers: l.numLocalChallengers,
844
849
  councilQuorum: l.councilQuorum,
845
850
  councilSize: l.councilSize,
846
- network: l.network
851
+ network: l.network,
852
+ authAnchorHash: y
847
853
  },
848
- fundedPrePeginTxHex: h(s.unsignedPrePeginTxHex),
854
+ fundedPrePeginTxHex: g,
849
855
  htlcVout: s.htlcVout,
850
856
  refundFee: d,
851
857
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
@@ -855,31 +861,31 @@ async function ft(e) {
855
861
  hashlock: h(s.hashlock)
856
862
  });
857
863
  i == null || i.throwIfAborted();
858
- const m = R(
864
+ const w = $(
859
865
  s.depositorBtcPubkey,
860
- Le
861
- ), b = await u(g, m);
866
+ Ue
867
+ ), b = await u(T, w);
862
868
  V({
863
- requestedPsbtHex: g,
869
+ requestedPsbtHex: T,
864
870
  returnedPsbtHex: b
865
871
  });
866
- const f = ze(b);
872
+ const E = ze(b);
867
873
  i == null || i.throwIfAborted();
868
874
  try {
869
- return await a(f);
870
- } catch (P) {
871
- throw P instanceof Error && Me.test(P.message) ? new Oe(t, P) : P;
875
+ return await a(E);
876
+ } catch (m) {
877
+ throw m instanceof Error && Me.test(m.message) ? new Oe(t, m) : m;
872
878
  }
873
879
  }
874
880
  export {
875
881
  Oe as B,
876
- F as C,
877
- M as R,
882
+ M as C,
883
+ U as R,
878
884
  tt as a,
879
885
  Ee as b,
880
886
  at as c,
881
887
  it as d,
882
- Re as e,
888
+ Ve as e,
883
889
  $e as f,
884
890
  ut as g,
885
891
  lt as h,
@@ -888,12 +894,12 @@ export {
888
894
  dt as k,
889
895
  ht as l,
890
896
  pt as m,
891
- ft as n,
892
- gt as o,
893
- z as p,
897
+ gt as n,
898
+ ft as o,
899
+ X as p,
894
900
  nt as r,
895
901
  rt as s,
896
902
  st as v,
897
- U as w
903
+ D as w
898
904
  };
899
- //# sourceMappingURL=buildAndBroadcastRefund-vwfVgJeA.js.map
905
+ //# sourceMappingURL=buildAndBroadcastRefund-B5cOyUzj.js.map