@babylonlabs-io/ts-sdk 3.3.0 → 3.3.1

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.
@@ -9,8 +9,8 @@ import { isAddressEqual as J } from "viem";
9
9
  import { c as Be, V as _e } from "./pegin-registration-client-Cvjk4ILq.js";
10
10
  import { pushTx as Ce, getUtxoInfo as Ae } from "./tbv/core/clients/mempool/index.js";
11
11
  import { expandWotsSeed as Ie, expandHashlockSecret as He, expandAuthAnchor as $e } from "./tbv/core/wasm/index.js";
12
- import { a as ee, b as Oe, i as te, j as Re } from "./verifyScriptPathSchnorrSignature-owu3BfyT.js";
13
- import { d as We, b as Fe, e as Ve, f as Me, c as Ke } from "./verifyKeyPathSchnorrSignature-IIj3Z2se.js";
12
+ import { a as ee, b as Re, i as te, j as Oe } from "./verifyScriptPathSchnorrSignature-owu3BfyT.js";
13
+ import { d as We, b as Fe, e as Ve, f as Ke, c as Me } from "./verifyKeyPathSchnorrSignature-IIj3Z2se.js";
14
14
  import { p as De, h as L, u as U, e as Ne, i as oe, s as x, k as se } from "./bitcoin-C-TuHb-v.js";
15
15
  import { c as Le } from "./signing-C1rR4tqs.js";
16
16
  import { M as ne, X as Ue } from "./validation-OSC0xTHB.js";
@@ -24,9 +24,9 @@ import { c as tt } from "./btcTxHash-BRZ8_EZq.js";
24
24
  import { p as ot } from "./parseFundingOutpoints-GSM-IaaK.js";
25
25
  import * as st from "@bitcoin-js/tiny-secp256k1-asmjs";
26
26
  import { v as nt, P as it, a as rt, b as at } from "./bip322Verify-BXYrHBh8.js";
27
- const O = /* @__PURE__ */ BigInt(2 ** 32 - 1), re = /* @__PURE__ */ BigInt(32);
27
+ const R = /* @__PURE__ */ BigInt(2 ** 32 - 1), re = /* @__PURE__ */ BigInt(32);
28
28
  function ct(o, e = !1) {
29
- return e ? { h: Number(o & O), l: Number(o >> re & O) } : { h: Number(o >> re & O) | 0, l: Number(o & O) | 0 };
29
+ return e ? { h: Number(o & R), l: Number(o >> re & R) } : { h: Number(o >> re & R) | 0, l: Number(o & R) | 0 };
30
30
  }
31
31
  function lt(o, e = !1) {
32
32
  const t = o.length;
@@ -79,13 +79,13 @@ function ft(o) {
79
79
  vaults: s
80
80
  };
81
81
  }
82
- const mt = /^0x[0-9a-f]+$/i, Pt = /^[0-9a-f]+$/i, bt = /^[A-Za-z0-9+/]+={0,2}$/;
82
+ const mt = /^0x[0-9a-f]+$/i, Pt = /^[0-9a-f]+$/i, wt = /^[A-Za-z0-9+/]+={0,2}$/;
83
83
  function B(o) {
84
84
  if (typeof o != "string" || o.length === 0)
85
85
  throw new Error("BTC wallet returned empty public key");
86
86
  return De(o).toLowerCase();
87
87
  }
88
- function wt(o) {
88
+ function bt(o) {
89
89
  if (typeof o != "string" || o.length === 0)
90
90
  throw new Error("BTC wallet returned empty BIP-322 signature");
91
91
  if (o.startsWith("0x") || o.startsWith("0X")) {
@@ -98,7 +98,7 @@ function wt(o) {
98
98
  throw new Error("BTC wallet returned malformed hex BIP-322 signature");
99
99
  return `0x${o.toLowerCase()}`;
100
100
  }
101
- if (!bt.test(o) || o.length % 4 !== 0)
101
+ if (!wt.test(o) || o.length % 4 !== 0)
102
102
  throw new Error("BTC wallet returned malformed base64 BIP-322 signature");
103
103
  const e = _.from(o, "base64");
104
104
  if (e.length === 0 || e.toString("base64") !== o)
@@ -109,10 +109,10 @@ async function yt(o) {
109
109
  const { wallet: e, depositTerms: t, fundedPrePeginTxHex: s, depositorBtcPubkey: r } = o, n = typeof e.approveDepositTerms == "function" ? e.approveDepositTerms : void 0;
110
110
  if (!n && !t)
111
111
  return;
112
- const i = s.startsWith("0x") ? s.slice(2) : s, c = ge.fromHex(i).getId();
113
- if (t && t.prepeginTxid.replace(/^0x/, "").toLowerCase() !== c)
112
+ const i = s.startsWith("0x") ? s.slice(2) : s, l = ge.fromHex(i).getId();
113
+ if (t && t.prepeginTxid.replace(/^0x/, "").toLowerCase() !== l)
114
114
  throw new Error(
115
- `Deposit terms do not match the transaction being broadcast: terms are for prepeginTxid ${t.prepeginTxid}, but this transaction is ${c}.`
115
+ `Deposit terms do not match the transaction being broadcast: terms are for prepeginTxid ${t.prepeginTxid}, but this transaction is ${l}.`
116
116
  );
117
117
  if (!n)
118
118
  return;
@@ -145,29 +145,29 @@ async function yt(o) {
145
145
  }
146
146
  )).fill(0), await n.call(e, t);
147
147
  }
148
- const xt = BigInt(0), A = BigInt(1), kt = BigInt(2), Tt = BigInt(7), vt = BigInt(256), Et = BigInt(113), me = [], Pe = [], be = [];
148
+ const xt = BigInt(0), A = BigInt(1), kt = BigInt(2), Tt = BigInt(7), vt = BigInt(256), Et = BigInt(113), me = [], Pe = [], we = [];
149
149
  for (let o = 0, e = A, t = 1, s = 0; o < 24; o++) {
150
150
  [t, s] = [s, (2 * t + 3 * s) % 5], me.push(2 * (5 * s + t)), Pe.push((o + 1) * (o + 2) / 2 % 64);
151
151
  let r = xt;
152
152
  for (let n = 0; n < 7; n++)
153
153
  e = (e << A ^ (e >> Tt) * Et) % vt, e & kt && (r ^= A << (A << BigInt(n)) - A);
154
- be.push(r);
154
+ we.push(r);
155
155
  }
156
- const we = lt(be, !0), St = we[0], Bt = we[1], ae = (o, e, t) => t > 32 ? pt(o, e, t) : ut(o, e, t), ce = (o, e, t) => t > 32 ? dt(o, e, t) : ht(o, e, t);
156
+ const be = lt(we, !0), St = be[0], Bt = be[1], ae = (o, e, t) => t > 32 ? pt(o, e, t) : ut(o, e, t), ce = (o, e, t) => t > 32 ? dt(o, e, t) : ht(o, e, t);
157
157
  function _t(o, e = 24) {
158
158
  const t = new Uint32Array(10);
159
159
  for (let s = 24 - e; s < 24; s++) {
160
160
  for (let i = 0; i < 10; i++)
161
161
  t[i] = o[i] ^ o[i + 10] ^ o[i + 20] ^ o[i + 30] ^ o[i + 40];
162
162
  for (let i = 0; i < 10; i += 2) {
163
- const a = (i + 8) % 10, c = (i + 2) % 10, h = t[c], p = t[c + 1], f = ae(h, p, 1) ^ t[a], y = ce(h, p, 1) ^ t[a + 1];
164
- for (let b = 0; b < 50; b += 10)
165
- o[i + b] ^= f, o[i + b + 1] ^= y;
163
+ const a = (i + 8) % 10, l = (i + 2) % 10, h = t[l], p = t[l + 1], f = ae(h, p, 1) ^ t[a], y = ce(h, p, 1) ^ t[a + 1];
164
+ for (let w = 0; w < 50; w += 10)
165
+ o[i + w] ^= f, o[i + w + 1] ^= y;
166
166
  }
167
167
  let r = o[2], n = o[3];
168
168
  for (let i = 0; i < 24; i++) {
169
- const a = Pe[i], c = ae(r, n, a), h = ce(r, n, a), p = me[i];
170
- r = o[p], n = o[p + 1], o[p] = c, o[p + 1] = h;
169
+ const a = Pe[i], l = ae(r, n, a), h = ce(r, n, a), p = me[i];
170
+ r = o[p], n = o[p + 1], o[p] = l, o[p + 1] = h;
171
171
  }
172
172
  for (let i = 0; i < 50; i += 10) {
173
173
  for (let a = 0; a < 10; a++)
@@ -255,21 +255,21 @@ class z {
255
255
  return e || (e = new z(t, s, r, i, n)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = n, e.suffix = s, e.outputLen = r, e.enableXOF = i, e.destroyed = this.destroyed, e;
256
256
  }
257
257
  }
258
- const Ct = (o, e, t, s = {}) => ve(() => new z(e, o, t), s), At = /* @__PURE__ */ Ct(1, 136, 32), le = 64, w = 20, X = 4, ye = 2, It = 0, Ht = 1, R = [64, 64], $t = (o) => Array.from(o).map((e) => e.toString(16).padStart(2, "0")).join("");
258
+ const Ct = (o, e, t, s = {}) => ve(() => new z(e, o, t), s), At = /* @__PURE__ */ Ct(1, 136, 32), le = 64, b = 20, X = 4, ye = 2, It = 0, Ht = 1, O = [64, 64], $t = (o) => Array.from(o).map((e) => e.toString(16).padStart(2, "0")).join("");
259
259
  function G(o) {
260
260
  return je(pe(o));
261
261
  }
262
262
  function xe(o) {
263
263
  return (1 << o) - 1;
264
264
  }
265
- function Ot(o) {
265
+ function Rt(o) {
266
266
  let e = 1;
267
267
  for (; e * e < o + 1; ) e++;
268
268
  return Math.max(e, 2);
269
269
  }
270
- function Rt(o) {
270
+ function Ot(o) {
271
271
  const e = X, t = o * xe(e);
272
- return { d: e, n: o, checksum_radix: Ot(t) };
272
+ return { d: e, n: o, checksum_radix: Rt(t) };
273
273
  }
274
274
  function V(o, e) {
275
275
  const t = [];
@@ -282,7 +282,7 @@ function V(o, e) {
282
282
  r[o.length + n] = t[n];
283
283
  return G(r);
284
284
  }
285
- function M(o, e) {
285
+ function K(o, e) {
286
286
  let t = o;
287
287
  for (let s = 0; s < e; s++)
288
288
  t = G(t);
@@ -291,20 +291,20 @@ function M(o, e) {
291
291
  function Wt(o, e) {
292
292
  const t = xe(e.d), s = e.checksum_radix - 1, r = Math.floor(e.n * t / e.checksum_radix), n = [];
293
293
  for (let p = 0; p < e.n; p++) {
294
- const f = V(o, p + ye), y = M(f, t);
294
+ const f = V(o, p + ye), y = K(f, t);
295
295
  n.push(Array.from(y));
296
296
  }
297
297
  const i = V(
298
298
  o,
299
299
  It
300
- ), a = M(
300
+ ), a = K(
301
301
  i,
302
302
  s
303
- ), c = V(
303
+ ), l = V(
304
304
  o,
305
305
  Ht
306
- ), h = M(
307
- c,
306
+ ), h = K(
307
+ l,
308
308
  r
309
309
  );
310
310
  return {
@@ -321,8 +321,8 @@ async function Ft(o) {
321
321
  `WOTS seed must be exactly ${le} bytes, got ${o.length}`
322
322
  );
323
323
  const e = [];
324
- for (let t = 0; t < R.length; t++) {
325
- const s = R[t], r = Rt(s), n = new Uint8Array(o.length + 1);
324
+ for (let t = 0; t < O.length; t++) {
325
+ const s = O[t], r = Ot(s), n = new Uint8Array(o.length + 1);
326
326
  n.set(o), n[o.length] = t;
327
327
  const i = G(n);
328
328
  try {
@@ -339,37 +339,37 @@ async function Ft(o) {
339
339
  throw new Error(
340
340
  `Block ${t}: expected ${s} message terminals, got ${a.message_terminals.length}`
341
341
  );
342
- for (let c = 0; c < a.message_terminals.length; c++)
343
- if (a.message_terminals[c].length !== w)
342
+ for (let l = 0; l < a.message_terminals.length; l++)
343
+ if (a.message_terminals[l].length !== b)
344
344
  throw new Error(
345
- `Block ${t} terminal ${c}: expected ${w} bytes, got ${a.message_terminals[c].length}`
345
+ `Block ${t} terminal ${l}: expected ${b} bytes, got ${a.message_terminals[l].length}`
346
346
  );
347
- if (a.checksum_minor_terminal.length !== w)
347
+ if (a.checksum_minor_terminal.length !== b)
348
348
  throw new Error(
349
- `Block ${t} checksum_minor: expected ${w} bytes`
349
+ `Block ${t} checksum_minor: expected ${b} bytes`
350
350
  );
351
- if (a.checksum_major_terminal.length !== w)
351
+ if (a.checksum_major_terminal.length !== b)
352
352
  throw new Error(
353
- `Block ${t} checksum_major: expected ${w} bytes`
353
+ `Block ${t} checksum_major: expected ${b} bytes`
354
354
  );
355
355
  e.push(a);
356
356
  } finally {
357
357
  n.fill(0), i.fill(0);
358
358
  }
359
359
  }
360
- if (e.length !== R.length)
360
+ if (e.length !== O.length)
361
361
  throw new Error(
362
- `Expected ${R.length} blocks, got ${e.length}`
362
+ `Expected ${O.length} blocks, got ${e.length}`
363
363
  );
364
364
  return e;
365
365
  } finally {
366
366
  o.fill(0);
367
367
  }
368
368
  }
369
- function K(o, e, t) {
370
- if (o.length !== w)
369
+ function M(o, e, t) {
370
+ if (o.length !== b)
371
371
  throw new Error(
372
- `Block ${e} ${t}: expected ${w} bytes, got ${o.length}`
372
+ `Block ${e} ${t}: expected ${b} bytes, got ${o.length}`
373
373
  );
374
374
  for (let s = 0; s < o.length; s++) {
375
375
  const r = o[s];
@@ -384,24 +384,24 @@ function Vt(o) {
384
384
  throw new Error("Public keys array must not be empty");
385
385
  for (let n = 0; n < o.length; n++) {
386
386
  const i = o[n];
387
- K(i.checksum_minor_terminal, n, "checksum_minor_terminal"), K(i.checksum_major_terminal, n, "checksum_major_terminal");
387
+ M(i.checksum_minor_terminal, n, "checksum_minor_terminal"), M(i.checksum_major_terminal, n, "checksum_major_terminal");
388
388
  for (let a = 0; a < i.message_terminals.length; a++)
389
- K(i.message_terminals[a], n, `message_terminal[${a}]`);
389
+ M(i.message_terminals[a], n, `message_terminal[${a}]`);
390
390
  }
391
391
  let e = 0;
392
392
  for (const n of o)
393
393
  e += ye + n.message_terminals.length;
394
- const t = new Uint8Array(e * w);
394
+ const t = new Uint8Array(e * b);
395
395
  let s = 0;
396
396
  for (const n of o) {
397
- t.set(n.checksum_minor_terminal, s), s += w, t.set(n.checksum_major_terminal, s), s += w;
397
+ t.set(n.checksum_minor_terminal, s), s += b, t.set(n.checksum_major_terminal, s), s += b;
398
398
  for (const i of n.message_terminals)
399
- t.set(i, s), s += w;
399
+ t.set(i, s), s += b;
400
400
  }
401
401
  const r = At(t);
402
402
  return `0x${$t(r)}`;
403
403
  }
404
- async function Mt(o, e) {
404
+ async function Kt(o, e) {
405
405
  const t = [], s = [], r = [], n = [];
406
406
  try {
407
407
  for (let i = 0; i < e; i++) {
@@ -412,12 +412,12 @@ async function Mt(o, e) {
412
412
  } finally {
413
413
  a.fill(0);
414
414
  }
415
- const c = await He(o, i);
415
+ const l = await He(o, i);
416
416
  try {
417
- const h = U(c);
417
+ const h = U(l);
418
418
  r.push(h), n.push(Xe(Ne(h)).slice(2));
419
419
  } finally {
420
- c.fill(0);
420
+ l.fill(0);
421
421
  }
422
422
  }
423
423
  } finally {
@@ -425,7 +425,7 @@ async function Mt(o, e) {
425
425
  }
426
426
  return { perVaultWotsKeys: t, wotsPkHashes: s, htlcSecretHexes: r, hashlocks: n };
427
427
  }
428
- const Kt = 1, Dt = 2, Nt = 33, Lt = 2, Ut = 3, Xt = 1, W = 64, zt = 0, D = 1, ue = /^[0-9a-f]{64}$/i, Gt = /^(?:[0-9a-f]{2})+$/;
428
+ const Mt = 1, Dt = 2, Nt = 33, Lt = 2, Ut = 3, Xt = 1, W = 64, zt = 0, D = 1, ue = /^[0-9a-f]{64}$/i, Gt = /^(?:[0-9a-f]{2})+$/;
429
429
  function qt(o) {
430
430
  const e = o.slice(2);
431
431
  if (!Gt.test(e))
@@ -440,7 +440,7 @@ function qt(o) {
440
440
  function jt(o, e, t) {
441
441
  var r;
442
442
  const s = qt(t);
443
- if (s.length === Kt) {
443
+ if (s.length === Mt) {
444
444
  const [n] = s;
445
445
  let i, a;
446
446
  if (n.length === W)
@@ -455,8 +455,8 @@ function jt(o, e, t) {
455
455
  throw new Error(
456
456
  `depositor public key must be bare 64-char x-only hex, got "${e}"`
457
457
  );
458
- const c = Uint8Array.from(_.from(e, "hex"));
459
- if (!nt(o, c, i, a))
458
+ const l = Uint8Array.from(_.from(e, "hex"));
459
+ if (!nt(o, l, i, a))
460
460
  throw new Error(
461
461
  "proof of possession signature does not verify against the depositor key"
462
462
  );
@@ -542,7 +542,8 @@ class ko {
542
542
  * split). Returns broadcast-ready txs, the pubkey snapshot, and the
543
543
  * sensitive derived material.
544
544
  *
545
- * @throws If the wallet rejects, insufficient funds, or an internal
545
+ * @throws If the wallet rejects, the BTC wallet account changes during
546
+ * vault-root derivation, insufficient funds, or an internal
546
547
  * invariant violation.
547
548
  */
548
549
  async preparePegin(e) {
@@ -550,10 +551,10 @@ class ko {
550
551
  throw new Error("amounts must contain at least one entry");
551
552
  const t = await this.config.btcWallet.getPublicKeyHex(), s = B(t);
552
553
  if (C(this.config.btcWallet)) {
553
- const l = (await ze(this.config.btcWallet)).trim();
554
- if (e.changeAddress.trim() !== l)
554
+ const c = (await ze(this.config.btcWallet)).trim();
555
+ if (e.changeAddress.trim() !== c)
555
556
  throw new Error(
556
- `Pre-PegIn changeAddress "${e.changeAddress}" is not the approval wallet's change address ("${l}"). Refusing to build a tx the signing device would reject.`
557
+ `Pre-PegIn changeAddress "${e.changeAddress}" is not the approval wallet's change address ("${c}"). Refusing to build a tx the signing device would reject.`
557
558
  );
558
559
  } else if (!oe(
559
560
  e.changeAddress,
@@ -565,8 +566,8 @@ class ko {
565
566
  );
566
567
  const r = await this.prepareSizing(s, e);
567
568
  if (C(this.config.btcWallet)) {
568
- const { validateDepositTerms: l } = this.config.btcWallet;
569
- typeof l == "function" && await l.call(
569
+ const { validateDepositTerms: c } = this.config.btcWallet;
570
+ typeof c == "function" && await c.call(
570
571
  this.config.btcWallet,
571
572
  this.buildPeginDepositTerms({
572
573
  params: e,
@@ -578,42 +579,52 @@ class ko {
578
579
  );
579
580
  }
580
581
  const n = r.selectedUTXOs.map(
581
- (l) => ({
582
- txid: L(l.txid),
583
- vout: l.vout
582
+ (c) => ({
583
+ txid: L(c.txid),
584
+ vout: c.vout
584
585
  })
585
586
  ), i = await fe(this.config.btcWallet, {
586
587
  depositorBtcPubkey: L(s),
587
588
  fundingOutpoints: n
588
589
  });
589
- let a, c;
590
590
  try {
591
- const l = await $e(i);
591
+ if (B(
592
+ await this.config.btcWallet.getPublicKeyHex()
593
+ ) !== s)
594
+ throw new Error(
595
+ "BTC wallet account changed during vault secret derivation. The wallet no longer reports the account this deposit started with, so the derived secrets cannot be used. Restart the deposit with the original account."
596
+ );
597
+ } catch (c) {
598
+ throw i.fill(0), c;
599
+ }
600
+ let a, l;
601
+ try {
602
+ const c = await $e(i);
592
603
  try {
593
- a = U(l), c = U(pe(l));
604
+ a = U(c), l = U(pe(c));
594
605
  } finally {
595
- l.fill(0);
606
+ c.fill(0);
596
607
  }
597
- } catch (l) {
598
- throw i.fill(0), l;
608
+ } catch (c) {
609
+ throw i.fill(0), c;
599
610
  }
600
- const h = await Mt(i, e.amounts.length), { perVaultWotsKeys: p, wotsPkHashes: f, htlcSecretHexes: y, hashlocks: b } = h, g = await this.preparePeginCommit({
611
+ const h = await Kt(i, e.amounts.length), { perVaultWotsKeys: p, wotsPkHashes: f, htlcSecretHexes: y, hashlocks: w } = h, g = await this.preparePeginCommit({
601
612
  depositorBtcPubkeyRaw: t,
602
613
  depositorBtcPubkey: s,
603
- hashlocks: b,
604
- authAnchorHash: c,
614
+ hashlocks: w,
615
+ authAnchorHash: l,
605
616
  sizing: r,
606
617
  params: e
607
618
  });
608
- for (let l = 0; l < g.perVault.length; l++)
609
- if (g.perVault[l].htlcVout !== l)
619
+ for (let c = 0; c < g.perVault.length; c++)
620
+ if (g.perVault[c].htlcVout !== c)
610
621
  throw new Error(
611
- `Internal invariant violation: htlcVout/index mismatch at vault ${l} (expected ${l}, got ${g.perVault[l].htlcVout})`
622
+ `Internal invariant violation: htlcVout/index mismatch at vault ${c} (expected ${c}, got ${g.perVault[c].htlcVout})`
612
623
  );
613
624
  Ge(
614
625
  g.fundedPrePeginTxHex,
615
626
  e.amounts.length,
616
- c
627
+ l
617
628
  );
618
629
  const { depositTerms: v, ...k } = g;
619
630
  return {
@@ -717,19 +728,19 @@ class ko {
717
728
  authAnchorHash: n,
718
729
  sizing: i,
719
730
  params: a
720
- } = e, c = N.toLowerCase();
731
+ } = e, l = N.toLowerCase();
721
732
  for (let u = 0; u < r.length; u++)
722
- if (r[u].toLowerCase() === c)
733
+ if (r[u].toLowerCase() === l)
723
734
  throw new Error(
724
735
  `preparePeginCommit refusing to build with sizing-pass placeholder hashlock at vault ${u} — internal substitution bug`
725
736
  );
726
- if (n.toLowerCase() === c)
737
+ if (n.toLowerCase() === l)
727
738
  throw new Error(
728
739
  "preparePeginCommit refusing to build with sizing-pass placeholder auth-anchor hash — internal substitution bug"
729
740
  );
730
741
  const h = x(
731
742
  a.vaultProviderBtcPubkey
732
- ), p = a.vaultKeeperBtcPubkeys.map(x), f = a.universalChallengerBtcPubkeys.map(x), y = p.length, b = {
743
+ ), p = a.vaultKeeperBtcPubkeys.map(x), f = a.universalChallengerBtcPubkeys.map(x), y = p.length, w = {
733
744
  vaultCoreVersion: a.vaultCoreVersion,
734
745
  depositorPubkey: s,
735
746
  vaultProviderPubkey: h,
@@ -745,7 +756,7 @@ class ko {
745
756
  councilSize: a.councilSize,
746
757
  network: this.config.btcNetwork,
747
758
  authAnchorHash: n
748
- }, g = await ee(b);
759
+ }, g = await ee(w);
749
760
  if (g.depositorClaimValue !== i.depositorClaimValue || g.minPeginFee !== i.minPeginFee)
750
761
  throw new Error(
751
762
  `Pre-PegIn sizing/commit divergence: depositorClaimValue ${i.depositorClaimValue} -> ${g.depositorClaimValue}, minPeginFee ${i.minPeginFee} -> ${g.minPeginFee}. The provisional deposit terms validated before derivation would not match the terms sent for approval; refusing to continue.`
@@ -756,17 +767,17 @@ class ko {
756
767
  changeAddress: a.changeAddress,
757
768
  changeAmount: i.changeAmount,
758
769
  network: v
759
- }), l = i.selectedUTXOs.reduce((u, S) => u + BigInt(S.value), 0n) - g.totalOutputValue - i.changeAmount;
760
- if (l !== i.fee)
770
+ }), c = i.selectedUTXOs.reduce((u, S) => u + BigInt(S.value), 0n) - g.totalOutputValue - i.changeAmount;
771
+ if (c !== i.fee)
761
772
  throw new Error(
762
- `Pre-PegIn funded fee ${l} does not match the sizing-pass fee ${i.fee}; refusing to publish a deposit-terms fee bound the funded transaction does not pay.`
773
+ `Pre-PegIn funded fee ${c} does not match the sizing-pass fee ${i.fee}; refusing to publish a deposit-terms fee bound the funded transaction does not pay.`
763
774
  );
764
775
  const I = x(
765
776
  tt(k)
766
777
  ), H = [], d = [], m = [];
767
778
  for (let u = 0; u < r.length; u++) {
768
- const S = await Oe({
769
- prePeginParams: b,
779
+ const S = await Re({
780
+ prePeginParams: w,
770
781
  timelockPegin: a.timelockPegin,
771
782
  fundedPrePeginTxHex: k,
772
783
  htlcVout: u
@@ -808,13 +819,13 @@ class ko {
808
819
  E[u],
809
820
  s
810
821
  );
811
- Re({
822
+ Oe({
812
823
  requestedPsbtHex: d[u],
813
824
  signatureHex: S,
814
825
  signerXOnlyPubkeyHex: s,
815
826
  inputIndex: 0
816
827
  });
817
- const F = Me(E[u]);
828
+ const F = Ke(E[u]);
818
829
  $.push({
819
830
  htlcVout: u,
820
831
  htlcValue: g.htlcValues[u],
@@ -863,9 +874,9 @@ class ko {
863
874
  const a = _.from(
864
875
  B(s),
865
876
  "hex"
866
- ), c = this.config.mempoolApiUrl, h = n.ins.map((d) => {
877
+ ), l = this.config.mempoolApiUrl, h = n.ins.map((d) => {
867
878
  const m = _.from(d.hash).reverse().toString("hex"), T = d.index;
868
- return Zt(m, T, e.localPrevouts, c).then(
879
+ return Zt(m, T, e.localPrevouts, l).then(
869
880
  (E) => ({ input: d, utxoData: E, txid: m, vout: T })
870
881
  );
871
882
  }), p = await Promise.all(h), f = p.reduce(
@@ -879,10 +890,10 @@ class ko {
879
890
  throw new Error(
880
891
  `UTXO value mismatch: total input value (${f} sat) is less than total output value (${y} sat). This may indicate the mempool API returned manipulated UTXO data.`
881
892
  );
882
- const b = f - y;
883
- if (b > ne)
893
+ const w = f - y;
894
+ if (w > ne)
884
895
  throw new Error(
885
- `Implied transaction fee (${b} sat) exceeds maximum reasonable fee (${ne} sat). This may indicate manipulated UTXO data.`
896
+ `Implied transaction fee (${w} sat) exceeds maximum reasonable fee (${ne} sat). This may indicate manipulated UTXO data.`
886
897
  );
887
898
  for (const { input: d, utxoData: m, txid: T, vout: E } of p) {
888
899
  const $ = Qe(
@@ -915,7 +926,7 @@ class ko {
915
926
  requestedPsbtHex: g,
916
927
  returnedPsbtHex: v
917
928
  });
918
- const k = Ke({
929
+ const k = Me({
919
930
  requestedPsbtHex: g,
920
931
  returnedPsbtHex: v
921
932
  });
@@ -923,19 +934,19 @@ class ko {
923
934
  throw new Error(
924
935
  `Key-path verification covered ${k} of ${i.data.inputs.length} Pre-PegIn inputs; an approval wallet signs every input key-path, so the unverified ones must not be broadcast.`
925
936
  );
926
- const l = Z.fromHex(v);
937
+ const c = Z.fromHex(v);
927
938
  try {
928
- l.finalizeAllInputs();
939
+ c.finalizeAllInputs();
929
940
  } catch (d) {
930
- if (!l.data.inputs.every(
941
+ if (!c.data.inputs.every(
931
942
  (T) => T.finalScriptWitness || T.finalScriptSig
932
943
  ))
933
944
  throw new Error(
934
945
  `PSBT finalization failed and wallet did not auto-finalize: ${d}`
935
946
  );
936
947
  }
937
- const I = l.extractTransaction().toHex();
938
- return await Ce(I, c);
948
+ const I = c.extractTransaction().toHex();
949
+ return await Ce(I, l);
939
950
  }
940
951
  /**
941
952
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -1109,7 +1120,7 @@ class ko {
1109
1120
  ), s = this.config.vaultContracts.btcVaultRegistry, r = `${e.toLowerCase()}:${this.config.ethChain.id}:pegin:${s.toLowerCase()}`, n = await this.config.btcWallet.signMessage(
1110
1121
  r,
1111
1122
  "bip322-simple"
1112
- ), i = wt(n);
1123
+ ), i = bt(n);
1113
1124
  return jt(
1114
1125
  new TextEncoder().encode(r),
1115
1126
  t,
@@ -1151,10 +1162,10 @@ class ko {
1151
1162
  }
1152
1163
  export {
1153
1164
  ko as P,
1154
- Mt as a,
1165
+ Kt as a,
1155
1166
  ft as b,
1156
1167
  Vt as c,
1157
1168
  Ft as d,
1158
1169
  yt as e
1159
1170
  };
1160
- //# sourceMappingURL=PeginManager-BJnUgW8C.js.map
1171
+ //# sourceMappingURL=PeginManager-CQ9bVPR3.js.map