@babylonlabs-io/ts-sdk 0.22.0 → 0.23.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 (36) hide show
  1. package/dist/{buildAndBroadcastRefund-DWEQvj9T.cjs → buildAndBroadcastRefund-BDGGbGeK.cjs} +2 -2
  2. package/dist/buildAndBroadcastRefund-BDGGbGeK.cjs.map +1 -0
  3. package/dist/{buildAndBroadcastRefund-DnTQkCgG.js → buildAndBroadcastRefund-D7NCbgtv.js} +79 -77
  4. package/dist/buildAndBroadcastRefund-D7NCbgtv.js.map +1 -0
  5. package/dist/errors-BcpQEG62.cjs +2 -0
  6. package/dist/errors-BcpQEG62.cjs.map +1 -0
  7. package/dist/errors-D3a9XcIX.js +1275 -0
  8. package/dist/errors-D3a9XcIX.js.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/tbv/core/index.cjs +1 -1
  12. package/dist/tbv/core/index.js +2 -2
  13. package/dist/tbv/core/managers/PayoutManager.d.ts +1 -1
  14. package/dist/tbv/core/managers/PeginManager.d.ts +57 -51
  15. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  16. package/dist/tbv/core/managers/index.d.ts +7 -6
  17. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  18. package/dist/tbv/core/services/index.cjs +1 -1
  19. package/dist/tbv/core/services/index.js +1 -1
  20. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts +5 -1
  21. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  22. package/dist/tbv/index.cjs +1 -1
  23. package/dist/tbv/index.js +2 -2
  24. package/dist/testing/MockBitcoinWallet.d.ts +2 -2
  25. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  26. package/dist/testing/index.cjs +1 -1
  27. package/dist/testing/index.cjs.map +1 -1
  28. package/dist/testing/index.js +14 -14
  29. package/dist/testing/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/buildAndBroadcastRefund-DWEQvj9T.cjs.map +0 -1
  32. package/dist/buildAndBroadcastRefund-DnTQkCgG.js.map +0 -1
  33. package/dist/errors-CkkL1ztr.js +0 -1236
  34. package/dist/errors-CkkL1ztr.js.map +0 -1
  35. package/dist/errors-D2H46Yut.cjs +0 -2
  36. package/dist/errors-D2H46Yut.cjs.map +0 -1
@@ -2,13 +2,13 @@ var ke = Object.defineProperty;
2
2
  var Be = (e, t, r) => t in e ? ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var f = (e, t, r) => Be(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { B as He, c as _e, a as Ie, R as Ce, d as be, D as O } from "./types-DWjaqVfP.js";
5
- import { v as ne, b as Le, s as g, e as $e, p as J, f as L } from "./bitcoin-nOOgeRyl.js";
5
+ import { v as ne, b as Le, s as w, e as $e, p as M, f as L } from "./bitcoin-nOOgeRyl.js";
6
6
  import * as Re from "bitcoinjs-lib";
7
7
  import { Transaction as Oe, Psbt as ee } from "bitcoinjs-lib";
8
8
  import { Buffer as xe } from "buffer";
9
- import { c as M } from "./signing-DeWVBl7m.js";
9
+ import { c as G } from "./signing-DeWVBl7m.js";
10
10
  import "@babylonlabs-io/babylon-tbv-rust-wasm";
11
- import { a as se, e as G, b as Ne } from "./payout-DzGsAnhf.js";
11
+ import { a as se, e as W, b as Ne } from "./payout-DzGsAnhf.js";
12
12
  class Ue {
13
13
  /**
14
14
  * Creates a new PayoutManager instance.
@@ -61,10 +61,10 @@ class Ue {
61
61
  network: this.config.network
62
62
  }), c = await this.config.btcWallet.signPsbt(
63
63
  s.psbtHex,
64
- M(r, 1)
64
+ G(r, 1)
65
65
  );
66
66
  return {
67
- signature: G(c, n),
67
+ signature: W(c, n),
68
68
  depositorBtcPubkey: n
69
69
  };
70
70
  }
@@ -120,7 +120,7 @@ class Ue {
120
120
  timelockPegin: o.timelockPegin,
121
121
  network: this.config.network
122
122
  });
123
- n.push(h.psbtHex), s.push(M(r, 1));
123
+ n.push(h.psbtHex), s.push(G(r, 1));
124
124
  }
125
125
  const a = await this.config.btcWallet.signPsbts(
126
126
  n,
@@ -132,7 +132,7 @@ class Ue {
132
132
  );
133
133
  const i = [];
134
134
  for (let o = 0; o < t.length; o++) {
135
- const u = c[o], h = G(
135
+ const u = c[o], h = W(
136
136
  a[o],
137
137
  u
138
138
  );
@@ -163,9 +163,9 @@ class Ue {
163
163
  "Invalid registeredPayoutScriptPubKey: not valid hex"
164
164
  );
165
165
  const n = xe.from(
166
- g(r),
166
+ w(r),
167
167
  "hex"
168
- ), s = Oe.fromHex(g(t));
168
+ ), s = Oe.fromHex(w(t));
169
169
  if (s.outs.length === 0)
170
170
  throw new Error("Payout transaction has no outputs");
171
171
  if (!s.outs.reduce(
@@ -217,7 +217,7 @@ function N(...e) {
217
217
  for (let t = 0; t < e.length; t++)
218
218
  e[t].fill(0);
219
219
  }
220
- function Y(e) {
220
+ function q(e) {
221
221
  return new DataView(e.buffer, e.byteOffset, e.byteLength);
222
222
  }
223
223
  function m(e, t) {
@@ -275,7 +275,7 @@ class ye {
275
275
  f(this, "length", 0);
276
276
  f(this, "pos", 0);
277
277
  f(this, "destroyed", !1);
278
- this.blockLen = t, this.outputLen = r, this.padOffset = n, this.isLE = s, this.buffer = new Uint8Array(t), this.view = Y(this.buffer);
278
+ this.blockLen = t, this.outputLen = r, this.padOffset = n, this.isLE = s, this.buffer = new Uint8Array(t), this.view = q(this.buffer);
279
279
  }
280
280
  update(t) {
281
281
  ie(this), te(t);
@@ -283,7 +283,7 @@ class ye {
283
283
  for (let a = 0; a < c; ) {
284
284
  const i = Math.min(s - this.pos, c - a);
285
285
  if (i === s) {
286
- const o = Y(t);
286
+ const o = q(t);
287
287
  for (; s <= c - a; a += s)
288
288
  this.process(o, a);
289
289
  continue;
@@ -300,7 +300,7 @@ class ye {
300
300
  for (let l = a; l < s; l++)
301
301
  r[l] = 0;
302
302
  n.setBigUint64(s - 8, BigInt(this.length * 8), c), this.process(n, 0);
303
- const i = Y(t), o = this.outputLen;
303
+ const i = q(t), o = this.outputLen;
304
304
  if (o % 4)
305
305
  throw new Error("_sha2: outputLen must be aligned to 32bit");
306
306
  const u = o / 4, h = this.get();
@@ -333,7 +333,7 @@ const B = /* @__PURE__ */ Uint32Array.from([
333
333
  2600822924,
334
334
  528734635,
335
335
  1541459225
336
- ]), w = /* @__PURE__ */ Uint32Array.from([
336
+ ]), P = /* @__PURE__ */ Uint32Array.from([
337
337
  1779033703,
338
338
  4089235720,
339
339
  3144134277,
@@ -570,28 +570,28 @@ class it extends ye {
570
570
  }
571
571
  // prettier-ignore
572
572
  get() {
573
- const { Ah: t, Al: r, Bh: n, Bl: s, Ch: c, Cl: a, Dh: i, Dl: o, Eh: u, El: h, Fh: l, Fl: d, Gh: x, Gl: y, Hh: p, Hl: P } = this;
574
- return [t, r, n, s, c, a, i, o, u, h, l, d, x, y, p, P];
573
+ const { Ah: t, Al: r, Bh: n, Bl: s, Ch: c, Cl: a, Dh: i, Dl: o, Eh: u, El: h, Fh: l, Fl: d, Gh: x, Gl: y, Hh: p, Hl: g } = this;
574
+ return [t, r, n, s, c, a, i, o, u, h, l, d, x, y, p, g];
575
575
  }
576
576
  // prettier-ignore
577
- set(t, r, n, s, c, a, i, o, u, h, l, d, x, y, p, P) {
578
- this.Ah = t | 0, this.Al = r | 0, this.Bh = n | 0, this.Bl = s | 0, this.Ch = c | 0, this.Cl = a | 0, this.Dh = i | 0, this.Dl = o | 0, this.Eh = u | 0, this.El = h | 0, this.Fh = l | 0, this.Fl = d | 0, this.Gh = x | 0, this.Gl = y | 0, this.Hh = p | 0, this.Hl = P | 0;
577
+ set(t, r, n, s, c, a, i, o, u, h, l, d, x, y, p, g) {
578
+ this.Ah = t | 0, this.Al = r | 0, this.Bh = n | 0, this.Bl = s | 0, this.Ch = c | 0, this.Cl = a | 0, this.Dh = i | 0, this.Dl = o | 0, this.Eh = u | 0, this.El = h | 0, this.Fh = l | 0, this.Fl = d | 0, this.Gh = x | 0, this.Gl = y | 0, this.Hh = p | 0, this.Hl = g | 0;
579
579
  }
580
580
  process(t, r) {
581
581
  for (let b = 0; b < 16; b++, r += 4)
582
582
  _[b] = t.getUint32(r), I[b] = t.getUint32(r += 4);
583
583
  for (let b = 16; b < 80; b++) {
584
- const v = _[b - 15] | 0, k = I[b - 15] | 0, W = $(v, k, 1) ^ $(v, k, 8) ^ ce(v, k, 7), z = R(v, k, 1) ^ R(v, k, 8) ^ ue(v, k, 7), E = _[b - 2] | 0, T = I[b - 2] | 0, U = $(E, T, 19) ^ F(E, T, 61) ^ ce(E, T, 6), X = R(E, T, 19) ^ K(E, T, 61) ^ ue(E, T, 6), D = Qe(z, X, I[b - 7], I[b - 16]), j = Je(D, W, U, _[b - 7], _[b - 16]);
585
- _[b] = j | 0, I[b] = D | 0;
584
+ const v = _[b - 15] | 0, k = I[b - 15] | 0, z = $(v, k, 1) ^ $(v, k, 8) ^ ce(v, k, 7), X = R(v, k, 1) ^ R(v, k, 8) ^ ue(v, k, 7), E = _[b - 2] | 0, T = I[b - 2] | 0, U = $(E, T, 19) ^ F(E, T, 61) ^ ce(E, T, 6), j = R(E, T, 19) ^ K(E, T, 61) ^ ue(E, T, 6), D = Qe(X, j, I[b - 7], I[b - 16]), Y = Je(D, z, U, _[b - 7], _[b - 16]);
585
+ _[b] = Y | 0, I[b] = D | 0;
586
586
  }
587
- let { Ah: n, Al: s, Bh: c, Bl: a, Ch: i, Cl: o, Dh: u, Dl: h, Eh: l, El: d, Fh: x, Fl: y, Gh: p, Gl: P, Hh: A, Hl: C } = this;
587
+ let { Ah: n, Al: s, Bh: c, Bl: a, Ch: i, Cl: o, Dh: u, Dl: h, Eh: l, El: d, Fh: x, Fl: y, Gh: p, Gl: g, Hh: A, Hl: C } = this;
588
588
  for (let b = 0; b < 80; b++) {
589
- const v = $(l, d, 14) ^ $(l, d, 18) ^ F(l, d, 41), k = R(l, d, 14) ^ R(l, d, 18) ^ K(l, d, 41), W = l & x ^ ~l & p, z = d & y ^ ~d & P, E = Ze(C, k, z, ot[b], I[b]), T = et(E, A, v, W, st[b], _[b]), U = E | 0, X = $(n, s, 28) ^ F(n, s, 34) ^ F(n, s, 39), D = R(n, s, 28) ^ K(n, s, 34) ^ K(n, s, 39), j = n & c ^ n & i ^ c & i, ve = s & a ^ s & o ^ a & o;
590
- A = p | 0, C = P | 0, p = x | 0, P = y | 0, x = l | 0, y = d | 0, { h: l, l: d } = S(u | 0, h | 0, T | 0, U | 0), u = i | 0, h = o | 0, i = c | 0, o = a | 0, c = n | 0, a = s | 0;
589
+ const v = $(l, d, 14) ^ $(l, d, 18) ^ F(l, d, 41), k = R(l, d, 14) ^ R(l, d, 18) ^ K(l, d, 41), z = l & x ^ ~l & p, X = d & y ^ ~d & g, E = Ze(C, k, X, ot[b], I[b]), T = et(E, A, v, z, st[b], _[b]), U = E | 0, j = $(n, s, 28) ^ F(n, s, 34) ^ F(n, s, 39), D = R(n, s, 28) ^ K(n, s, 34) ^ K(n, s, 39), Y = n & c ^ n & i ^ c & i, ve = s & a ^ s & o ^ a & o;
590
+ A = p | 0, C = g | 0, p = x | 0, g = y | 0, x = l | 0, y = d | 0, { h: l, l: d } = S(u | 0, h | 0, T | 0, U | 0), u = i | 0, h = o | 0, i = c | 0, o = a | 0, c = n | 0, a = s | 0;
591
591
  const re = Ye(U, D, ve);
592
- n = qe(re, T, X, j), s = re | 0;
592
+ n = qe(re, T, j, Y), s = re | 0;
593
593
  }
594
- ({ h: n, l: s } = S(this.Ah | 0, this.Al | 0, n | 0, s | 0)), { h: c, l: a } = S(this.Bh | 0, this.Bl | 0, c | 0, a | 0), { h: i, l: o } = S(this.Ch | 0, this.Cl | 0, i | 0, o | 0), { h: u, l: h } = S(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: l, l: d } = S(this.Eh | 0, this.El | 0, l | 0, d | 0), { h: x, l: y } = S(this.Fh | 0, this.Fl | 0, x | 0, y | 0), { h: p, l: P } = S(this.Gh | 0, this.Gl | 0, p | 0, P | 0), { h: A, l: C } = S(this.Hh | 0, this.Hl | 0, A | 0, C | 0), this.set(n, s, c, a, i, o, u, h, l, d, x, y, p, P, A, C);
594
+ ({ h: n, l: s } = S(this.Ah | 0, this.Al | 0, n | 0, s | 0)), { h: c, l: a } = S(this.Bh | 0, this.Bl | 0, c | 0, a | 0), { h: i, l: o } = S(this.Ch | 0, this.Cl | 0, i | 0, o | 0), { h: u, l: h } = S(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: l, l: d } = S(this.Eh | 0, this.El | 0, l | 0, d | 0), { h: x, l: y } = S(this.Fh | 0, this.Fl | 0, x | 0, y | 0), { h: p, l: g } = S(this.Gh | 0, this.Gl | 0, p | 0, g | 0), { h: A, l: C } = S(this.Hh | 0, this.Hl | 0, A | 0, C | 0), this.set(n, s, c, a, i, o, u, h, l, d, x, y, p, g, A, C);
595
595
  }
596
596
  roundClean() {
597
597
  N(_, I);
@@ -603,22 +603,22 @@ class it extends ye {
603
603
  class at extends it {
604
604
  constructor() {
605
605
  super(64);
606
- f(this, "Ah", w[0] | 0);
607
- f(this, "Al", w[1] | 0);
608
- f(this, "Bh", w[2] | 0);
609
- f(this, "Bl", w[3] | 0);
610
- f(this, "Ch", w[4] | 0);
611
- f(this, "Cl", w[5] | 0);
612
- f(this, "Dh", w[6] | 0);
613
- f(this, "Dl", w[7] | 0);
614
- f(this, "Eh", w[8] | 0);
615
- f(this, "El", w[9] | 0);
616
- f(this, "Fh", w[10] | 0);
617
- f(this, "Fl", w[11] | 0);
618
- f(this, "Gh", w[12] | 0);
619
- f(this, "Gl", w[13] | 0);
620
- f(this, "Hh", w[14] | 0);
621
- f(this, "Hl", w[15] | 0);
606
+ f(this, "Ah", P[0] | 0);
607
+ f(this, "Al", P[1] | 0);
608
+ f(this, "Bh", P[2] | 0);
609
+ f(this, "Bl", P[3] | 0);
610
+ f(this, "Ch", P[4] | 0);
611
+ f(this, "Cl", P[5] | 0);
612
+ f(this, "Dh", P[6] | 0);
613
+ f(this, "Dl", P[7] | 0);
614
+ f(this, "Eh", P[8] | 0);
615
+ f(this, "El", P[9] | 0);
616
+ f(this, "Fh", P[10] | 0);
617
+ f(this, "Fl", P[11] | 0);
618
+ f(this, "Gh", P[12] | 0);
619
+ f(this, "Gl", P[13] | 0);
620
+ f(this, "Hh", P[14] | 0);
621
+ f(this, "Hl", P[15] | 0);
622
622
  }
623
623
  }
624
624
  const ct = /* @__PURE__ */ pe(
@@ -659,7 +659,7 @@ function ft(e, t) {
659
659
  return Z(e, "Secret"), Z(t, "Hashlock"), Pe(t), lt(e).toLowerCase() === t.toLowerCase();
660
660
  }
661
661
  const ht = /^0x[0-9a-fA-F]{64}$/, dt = /^0x[0-9a-fA-F]{40}$/, bt = /^0x([0-9a-fA-F]{2})*$/;
662
- function q(e, t) {
662
+ function Q(e, t) {
663
663
  if (e.length !== 66)
664
664
  throw new Error(
665
665
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
@@ -690,9 +690,9 @@ async function br(e) {
690
690
  writeContract: c,
691
691
  signal: a
692
692
  } = e;
693
- a == null || a.throwIfAborted(), xt(t, "btcVaultRegistryAddress"), q(r, "vaultId");
693
+ a == null || a.throwIfAborted(), xt(t, "btcVaultRegistryAddress"), Q(r, "vaultId");
694
694
  const i = $e(e.secret);
695
- if (q(i, "secret"), n !== void 0 && (q(n, "hashlock"), !ft(i, n)))
695
+ if (Q(i, "secret"), n !== void 0 && (Q(n, "hashlock"), !ft(i, n)))
696
696
  throw new Error(
697
697
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
698
698
  );
@@ -784,7 +784,7 @@ async function xr(e) {
784
784
  }
785
785
  const Pt = 1;
786
786
  function mt(e, t, r) {
787
- const n = ee.fromBase64(e), s = n.data.getTransaction().toString("hex").toLowerCase(), c = g(t).toLowerCase();
787
+ const n = ee.fromBase64(e), s = n.data.getTransaction().toString("hex").toLowerCase(), c = w(t).toLowerCase();
788
788
  if (s !== c)
789
789
  throw new Error(
790
790
  `PSBT integrity check failed for ${r}: unsigned transaction does not match tx_hex`
@@ -804,7 +804,7 @@ function fe(e, t, r) {
804
804
  return Et(n).toHex();
805
805
  }
806
806
  function Tt(e, t) {
807
- const r = [], n = [], s = [], c = M(
807
+ const r = [], n = [], s = [], c = G(
808
808
  t,
809
809
  Pt
810
810
  ), a = fe(
@@ -814,7 +814,7 @@ function Tt(e, t) {
814
814
  );
815
815
  r.push(a), n.push(c);
816
816
  for (const i of e.challenger_presign_data) {
817
- const o = g(i.challenger_pubkey), u = r.length, h = fe(
817
+ const o = w(i.challenger_pubkey), u = r.length, h = fe(
818
818
  i.nopayout_psbt,
819
819
  i.nopayout_tx.tx_hex,
820
820
  `nopayout (challenger ${o})`
@@ -827,13 +827,13 @@ function Tt(e, t) {
827
827
  return { psbtHexes: r, signOptions: n, challengerEntries: s };
828
828
  }
829
829
  function St(e, t, r) {
830
- const n = G(
830
+ const n = W(
831
831
  e[0],
832
832
  r
833
833
  ), s = {};
834
834
  for (const c of t)
835
835
  s[c.challengerPubkey] = {
836
- nopayout_signature: G(
836
+ nopayout_signature: W(
837
837
  e[c.noPayoutIdx],
838
838
  r
839
839
  )
@@ -854,7 +854,7 @@ async function At(e, t, r) {
854
854
  return n;
855
855
  }
856
856
  async function vt(e) {
857
- const { depositorGraph: t, depositorBtcPubkey: r, btcWallet: n } = e, s = g(r), c = await n.getPublicKeyHex(), { psbtHexes: a, signOptions: i, challengerEntries: o } = Tt(t, c), u = await At(
857
+ const { depositorGraph: t, depositorBtcPubkey: r, btcWallet: n } = e, s = w(r), c = await n.getPublicKeyHex(), { psbtHexes: a, signOptions: i, challengerEntries: o } = Tt(t, c), u = await At(
858
858
  n,
859
859
  a,
860
860
  i
@@ -879,7 +879,7 @@ const kt = 1200 * 1e3, Ee = /* @__PURE__ */ new Set([
879
879
  ]);
880
880
  function Ht(e) {
881
881
  return e.map((t) => ({
882
- claimerPubkeyXOnly: J(t.claimer_pubkey),
882
+ claimerPubkeyXOnly: M(t.claimer_pubkey),
883
883
  payoutTxHex: t.payout_tx.tx_hex,
884
884
  assertTxHex: t.assert_tx.tx_hex
885
885
  }));
@@ -893,15 +893,15 @@ function _t(e) {
893
893
  return t.toString("hex");
894
894
  }
895
895
  function It(e, t) {
896
- const r = g(e).toLowerCase(), n = g(
896
+ const r = w(e).toLowerCase(), n = w(
897
897
  t.vaultProviderBtcPubkey
898
- ).toLowerCase(), s = g(
898
+ ).toLowerCase(), s = w(
899
899
  t.depositorBtcPubkey
900
900
  ).toLowerCase();
901
901
  if (r === n || r === s)
902
902
  return t.registeredPayoutScriptPubKey;
903
903
  if (!t.vaultKeeperBtcPubkeys.some(
904
- (i) => g(i).toLowerCase() === r
904
+ (i) => w(i).toLowerCase() === r
905
905
  ))
906
906
  throw new Error(
907
907
  `Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
@@ -981,8 +981,8 @@ async function pr(e) {
981
981
  o
982
982
  );
983
983
  o == null || o.throwIfAborted();
984
- const d = J(c), x = l.txs.filter(
985
- (C) => J(C.claimer_pubkey) !== d
984
+ const d = M(c), x = l.txs.filter(
985
+ (C) => M(C.claimer_pubkey) !== d
986
986
  ), y = Ht(x), p = await Ct(
987
987
  n,
988
988
  a,
@@ -990,19 +990,19 @@ async function pr(e) {
990
990
  u
991
991
  );
992
992
  o == null || o.throwIfAborted();
993
- const P = await vt({
993
+ const g = await vt({
994
994
  depositorGraph: l.depositor_graph,
995
995
  depositorBtcPubkey: c,
996
996
  btcWallet: n
997
997
  });
998
998
  o == null || o.throwIfAborted();
999
999
  const A = { ...p };
1000
- A[g(c)] = P.payout_signatures, await r.submitDepositorPresignatures(
1000
+ A[w(c)] = g.payout_signatures, await r.submitDepositorPresignatures(
1001
1001
  {
1002
1002
  pegin_txid: s,
1003
1003
  depositor_pk: c,
1004
1004
  signatures: A,
1005
- depositor_claimer_presignatures: P
1005
+ depositor_claimer_presignatures: g
1006
1006
  },
1007
1007
  o
1008
1008
  );
@@ -1086,7 +1086,7 @@ function $t(e, t, r) {
1086
1086
  return { valid: !0 };
1087
1087
  }
1088
1088
  function Rt(e) {
1089
- const t = g(e);
1089
+ const t = w(e);
1090
1090
  return Lt(t) ? { valid: !0 } : {
1091
1091
  valid: !1,
1092
1092
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
@@ -1173,7 +1173,7 @@ function Ae(e, t) {
1173
1173
  `${t} must contain only hex characters after the 0x prefix`
1174
1174
  );
1175
1175
  }
1176
- function Q(e, t) {
1176
+ function J(e, t) {
1177
1177
  if (!Number.isInteger(e) || e < 0)
1178
1178
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
1179
1179
  }
@@ -1182,7 +1182,7 @@ function zt(e) {
1182
1182
  throw new Error(
1183
1183
  `htlcVout must be an integer 0-${de}, got ${e.htlcVout}`
1184
1184
  );
1185
- if (Q(e.offchainParamsVersion, "offchainParamsVersion"), Q(e.appVaultKeepersVersion, "appVaultKeepersVersion"), Q(
1185
+ if (J(e.offchainParamsVersion, "offchainParamsVersion"), J(e.appVaultKeepersVersion, "appVaultKeepersVersion"), J(
1186
1186
  e.universalChallengersVersion,
1187
1187
  "universalChallengersVersion"
1188
1188
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
@@ -1249,13 +1249,15 @@ async function Sr(e) {
1249
1249
  throw new Error(`feeRate must be a positive number, got ${s}`);
1250
1250
  const h = BigInt(Math.ceil(s * Mt));
1251
1251
  i == null || i.throwIfAborted();
1252
- const { psbtHex: l } = await Ne({
1252
+ const l = M(
1253
+ o.depositorBtcPubkey
1254
+ ), { psbtHex: d } = await Ne({
1253
1255
  prePeginParams: {
1254
- depositorPubkey: g(o.depositorBtcPubkey),
1255
- vaultProviderPubkey: g(u.vaultProviderPubkey),
1256
- vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(g),
1257
- universalChallengerPubkeys: u.universalChallengerPubkeys.map(g),
1258
- hashlocks: [g(o.hashlock)],
1256
+ depositorPubkey: l,
1257
+ vaultProviderPubkey: w(u.vaultProviderPubkey),
1258
+ vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(w),
1259
+ universalChallengerPubkeys: u.universalChallengerPubkeys.map(w),
1260
+ hashlocks: [w(o.hashlock)],
1259
1261
  timelockRefund: u.timelockRefund,
1260
1262
  pegInAmounts: [o.amount],
1261
1263
  feeRate: u.feeRate,
@@ -1264,25 +1266,25 @@ async function Sr(e) {
1264
1266
  councilSize: u.councilSize,
1265
1267
  network: u.network
1266
1268
  },
1267
- fundedPrePeginTxHex: g(o.unsignedPrePeginTxHex),
1269
+ fundedPrePeginTxHex: w(o.unsignedPrePeginTxHex),
1268
1270
  htlcVout: o.htlcVout,
1269
1271
  refundFee: h,
1270
1272
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
1271
1273
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
1272
1274
  // value would derive the wrong refund script leaf and yield an
1273
1275
  // unspendable PSBT. Match the `hashlocks` array handling above.
1274
- hashlock: g(o.hashlock)
1276
+ hashlock: w(o.hashlock)
1275
1277
  });
1276
1278
  i == null || i.throwIfAborted();
1277
- const d = M(
1279
+ const x = G(
1278
1280
  o.depositorBtcPubkey,
1279
1281
  Gt
1280
- ), x = await c(l, d), y = jt(x);
1282
+ ), y = await c(d, x), p = jt(y);
1281
1283
  i == null || i.throwIfAborted();
1282
1284
  try {
1283
- return await a(y);
1284
- } catch (p) {
1285
- throw p instanceof Error && Wt.test(p.message) ? new Vt(t, p) : p;
1285
+ return await a(p);
1286
+ } catch (g) {
1287
+ throw g instanceof Error && Wt.test(g.message) ? new Vt(t, g) : g;
1286
1288
  }
1287
1289
  }
1288
1290
  export {
@@ -1295,7 +1297,7 @@ export {
1295
1297
  fr as G,
1296
1298
  ye as H,
1297
1299
  hr as I,
1298
- Y as J,
1300
+ q as J,
1299
1301
  cr as K,
1300
1302
  ar as L,
1301
1303
  dr as M,
@@ -1328,4 +1330,4 @@ export {
1328
1330
  oe as y,
1329
1331
  sr as z
1330
1332
  };
1331
- //# sourceMappingURL=buildAndBroadcastRefund-DnTQkCgG.js.map
1333
+ //# sourceMappingURL=buildAndBroadcastRefund-D7NCbgtv.js.map