@babylonlabs-io/ts-sdk 0.55.0 → 0.55.2

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 (57) hide show
  1. package/dist/{PeginManager-D22MLWfM.js → PeginManager-CW03-M3T.js} +489 -555
  2. package/dist/PeginManager-CW03-M3T.js.map +1 -0
  3. package/dist/PeginManager-C_akOB1E.cjs +2 -0
  4. package/dist/PeginManager-C_akOB1E.cjs.map +1 -0
  5. package/dist/deriveVaultRoot-B_gEOTD6.js +72 -0
  6. package/dist/deriveVaultRoot-B_gEOTD6.js.map +1 -0
  7. package/dist/deriveVaultRoot-CebLadyJ.cjs +2 -0
  8. package/dist/deriveVaultRoot-CebLadyJ.cjs.map +1 -0
  9. package/dist/errors-B-H0seUG.js +8 -0
  10. package/dist/errors-B-H0seUG.js.map +1 -0
  11. package/dist/errors-Bfjxg_iJ.cjs +2 -0
  12. package/dist/errors-Bfjxg_iJ.cjs.map +1 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.js +145 -143
  15. package/dist/index.js.map +1 -1
  16. package/dist/parseFundingOutpoints-C_-PT9BT.cjs +2 -0
  17. package/dist/parseFundingOutpoints-C_-PT9BT.cjs.map +1 -0
  18. package/dist/parseFundingOutpoints-GSM-IaaK.js +17 -0
  19. package/dist/parseFundingOutpoints-GSM-IaaK.js.map +1 -0
  20. package/dist/tbv/core/index.cjs +1 -1
  21. package/dist/tbv/core/index.js +143 -141
  22. package/dist/tbv/core/index.js.map +1 -1
  23. package/dist/tbv/core/managers/index.cjs +1 -1
  24. package/dist/tbv/core/managers/index.js +1 -1
  25. package/dist/tbv/core/vault-secrets/index.cjs +2 -0
  26. package/dist/tbv/core/vault-secrets/index.cjs.map +1 -0
  27. package/dist/tbv/core/vault-secrets/index.js +14 -0
  28. package/dist/tbv/core/vault-secrets/index.js.map +1 -0
  29. package/dist/tbv/index.cjs +1 -1
  30. package/dist/tbv/index.js +143 -141
  31. package/dist/tbv/index.js.map +1 -1
  32. package/dist/tbv/integrations/aave/clients/abis/AaveAdapterPositionProxy.abi.json.d.ts +16 -0
  33. package/dist/tbv/integrations/aave/clients/abis/AaveIntegrationAdapter.abi.json.d.ts +2 -2
  34. package/dist/tbv/integrations/aave/clients/index.d.ts +1 -0
  35. package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
  36. package/dist/tbv/integrations/aave/clients/positionProxy.d.ts +8 -0
  37. package/dist/tbv/integrations/aave/clients/positionProxy.d.ts.map +1 -0
  38. package/dist/tbv/integrations/aave/clients/spoke.d.ts +11 -10
  39. package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
  40. package/dist/tbv/integrations/aave/clients/transaction.d.ts +6 -1
  41. package/dist/tbv/integrations/aave/clients/transaction.d.ts.map +1 -1
  42. package/dist/tbv/integrations/aave/constants.d.ts +6 -14
  43. package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
  44. package/dist/tbv/integrations/aave/index.cjs +1 -1
  45. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  46. package/dist/tbv/integrations/aave/index.d.ts +2 -2
  47. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  48. package/dist/tbv/integrations/aave/index.js +119 -85
  49. package/dist/tbv/integrations/aave/index.js.map +1 -1
  50. package/package.json +3 -3
  51. package/dist/PeginManager-D22MLWfM.js.map +0 -1
  52. package/dist/PeginManager-vUUfZCzj.cjs +0 -2
  53. package/dist/PeginManager-vUUfZCzj.cjs.map +0 -1
  54. package/dist/errors-9AkghWyk.js +0 -22
  55. package/dist/errors-9AkghWyk.js.map +0 -1
  56. package/dist/errors-Bu0H-dZD.cjs +0 -2
  57. package/dist/errors-Bu0H-dZD.cjs.map +0 -1
@@ -1,100 +1,38 @@
1
- var qt = Object.defineProperty;
2
- var zt = (n, t, e) => t in n ? qt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var x = (n, t, e) => zt(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { s as it, c as At, H as Yt, r as V, a as W, b as lt, u as jt, d as ut, e as ht, f as dt, g as Zt } from "./sha2-BYVxyZzX.js";
5
- import * as Ct from "bitcoinjs-lib";
6
- import { Transaction as Qt, Psbt as gt } from "bitcoinjs-lib";
7
- import { Buffer as J } from "buffer";
8
- import { isAddressEqual as ft, encodeFunctionData as tt, zeroAddress as Jt } from "viem";
9
- import { B as A } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
1
+ var Mt = Object.defineProperty;
2
+ var Nt = (s, e, t) => e in s ? Mt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var x = (s, e, t) => Nt(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { c as kt, H as Wt, r as U, a as F, b as st, u as Ft, d as nt, e as ot, f as rt, g as Lt, s as Tt } from "./sha2-BYVxyZzX.js";
5
+ import * as Et from "bitcoinjs-lib";
6
+ import { Transaction as Xt, Psbt as it } from "bitcoinjs-lib";
7
+ import { Buffer as Y } from "buffer";
8
+ import { isAddressEqual as at, encodeFunctionData as j, zeroAddress as Kt } from "viem";
9
+ import { B as I } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
10
10
  import { h as H } from "./errors-Blc-JWnI.js";
11
- import { expandWotsSeed as te, expandHashlockSecret as ee, expandAuthAnchor as ne, deriveVaultId as pt } from "@babylonlabs-io/babylon-tbv-rust-wasm";
12
- import { a as mt, b as se, d as bt, f as oe } from "./verifyScriptPathSchnorrSignature-DA4Z4yZ3.js";
13
- import { b as re, e as ie, f as ae } from "./peginInput-BKD_b3gq.js";
14
- import { u as X, h as et, e as v, p as ce, i as Pt, s as T, j as wt, X as le } from "./bitcoin-B5aNKtsk.js";
15
- import { c as ue } from "./signing-DaLvGwQe.js";
16
- import { M as yt } from "./validation-CxqROCno.js";
17
- import { c as he, a as de, s as ge } from "./PayoutManager-BJmPnyRP.js";
18
- import { s as fe, f as q, i as pe, w as xt } from "./waitForTransactionReceiptSmartAware-lobLm0q0.js";
19
- import { p as me, f as be } from "./fundPeginTransaction-B2wyjqp0.js";
20
- import { p as Pe, V as we, i as ye } from "./mempoolApi-CB7bHuwi.js";
21
- const M = /* @__PURE__ */ BigInt(2 ** 32 - 1), kt = /* @__PURE__ */ BigInt(32);
22
- function xe(n, t = !1) {
23
- return t ? { h: Number(n & M), l: Number(n >> kt & M) } : { h: Number(n >> kt & M) | 0, l: Number(n & M) | 0 };
11
+ import { expandWotsSeed as Dt, expandHashlockSecret as Gt, expandAuthAnchor as qt, deriveVaultId as ct } from "@babylonlabs-io/babylon-tbv-rust-wasm";
12
+ import { a as lt, b as zt, d as ut, f as Yt } from "./verifyScriptPathSchnorrSignature-DA4Z4yZ3.js";
13
+ import { b as jt, e as Qt, f as Zt } from "./peginInput-BKD_b3gq.js";
14
+ import { u as Q, e as v, p as Jt, i as ht, h as dt, s as E, j as ft, X as te } from "./bitcoin-B5aNKtsk.js";
15
+ import { c as ee } from "./signing-DaLvGwQe.js";
16
+ import { M as gt } from "./validation-CxqROCno.js";
17
+ import { d as se } from "./deriveVaultRoot-B_gEOTD6.js";
18
+ import { c as ne, a as oe, s as re } from "./PayoutManager-BJmPnyRP.js";
19
+ import { s as ie, f as K, i as ae, w as pt } from "./waitForTransactionReceiptSmartAware-lobLm0q0.js";
20
+ import { p as ce, f as le } from "./fundPeginTransaction-B2wyjqp0.js";
21
+ import { p as ue, V as he, i as de } from "./mempoolApi-CB7bHuwi.js";
22
+ const V = /* @__PURE__ */ BigInt(2 ** 32 - 1), mt = /* @__PURE__ */ BigInt(32);
23
+ function fe(s, e = !1) {
24
+ return e ? { h: Number(s & V), l: Number(s >> mt & V) } : { h: Number(s >> mt & V) | 0, l: Number(s & V) | 0 };
24
25
  }
25
- function ke(n, t = !1) {
26
- const e = n.length;
27
- let s = new Uint32Array(e), o = new Uint32Array(e);
28
- for (let r = 0; r < e; r++) {
29
- const { h: i, l: a } = xe(n[r], t);
30
- [s[r], o[r]] = [i, a];
26
+ function ge(s, e = !1) {
27
+ const t = s.length;
28
+ let n = new Uint32Array(t), o = new Uint32Array(t);
29
+ for (let r = 0; r < t; r++) {
30
+ const { h: i, l: a } = fe(s[r], e);
31
+ [n[r], o[r]] = [i, a];
31
32
  }
32
- return [s, o];
33
+ return [n, o];
33
34
  }
34
- const Ee = (n, t, e) => n << e | t >>> 32 - e, Te = (n, t, e) => t << e | n >>> 32 - e, _e = (n, t, e) => t << e - 32 | n >>> 64 - e, Be = (n, t, e) => n << e - 32 | t >>> 64 - e, U = 32, z = 32, nt = 36, Ht = 32, K = 4, ve = K + U + K + Ht;
35
- function st(n, t, e) {
36
- n[t] = e >>> 24 & 255, n[t + 1] = e >>> 16 & 255, n[t + 2] = e >>> 8 & 255, n[t + 3] = e & 255;
37
- }
38
- function Se(n) {
39
- if (n.txid.length !== z)
40
- throw new Error(
41
- `outpoint.txid must be exactly ${z} bytes, got ${n.txid.length}`
42
- );
43
- if (!Number.isInteger(n.vout) || n.vout < 0 || n.vout > 4294967295)
44
- throw new Error(`outpoint.vout must be a u32, got ${n.vout}`);
45
- const t = new Uint8Array(nt);
46
- return t.set(n.txid, 0), st(t, z, n.vout), t;
47
- }
48
- function Et(n, t) {
49
- const e = Math.min(n.length, t.length);
50
- for (let s = 0; s < e; s++)
51
- if (n[s] !== t[s]) return n[s] - t[s];
52
- return n.length - t.length;
53
- }
54
- function Ie(n) {
55
- if (n.length === 0)
56
- throw new Error(
57
- "buildFundingOutpointsCommitment: outpoints must be non-empty"
58
- );
59
- const t = n.map(Se);
60
- t.sort(Et);
61
- for (let s = 1; s < t.length; s++)
62
- if (Et(t[s - 1], t[s]) === 0)
63
- throw new Error(
64
- "buildFundingOutpointsCommitment: duplicate outpoint detected"
65
- );
66
- const e = new Uint8Array(t.length * nt);
67
- for (let s = 0; s < t.length; s++)
68
- e.set(t[s], s * nt);
69
- return it(e);
70
- }
71
- function Ae(n) {
72
- if (n.depositorBtcPubkey.length !== U)
73
- throw new Error(
74
- `vaultContext: depositorBtcPubkey must be exactly ${U} bytes, got ${n.depositorBtcPubkey.length}`
75
- );
76
- const t = Ie(n.fundingOutpoints), e = new Uint8Array(ve);
77
- let s = 0;
78
- return st(e, s, U), s += K, e.set(n.depositorBtcPubkey, s), s += U, st(e, s, Ht), s += K, e.set(t, s), e;
79
- }
80
- const Ce = "babylon-btc-vault", Ot = 32, Tt = Ot * 2, He = /^[0-9a-f]+$/;
81
- async function Oe(n, t) {
82
- const e = Ae(t), s = X(e), o = await n.deriveContextHash(Ce, s);
83
- if (typeof o != "string")
84
- throw new Error(
85
- `deriveVaultRoot: wallet must return a string, got ${typeof o}`
86
- );
87
- if (o.length !== Tt)
88
- throw new Error(
89
- `deriveVaultRoot: wallet must return a ${Tt}-character hex string (${Ot} bytes), got length ${o.length}`
90
- );
91
- if (!He.test(o))
92
- throw new Error(
93
- "deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters"
94
- );
95
- return et(o);
96
- }
97
- const Re = /* @__PURE__ */ Uint8Array.from([
35
+ const pe = (s, e, t) => s << t | e >>> 32 - t, me = (s, e, t) => e << t | s >>> 32 - t, Pe = (s, e, t) => e << t - 32 | s >>> 64 - t, be = (s, e, t) => s << t - 32 | e >>> 64 - t, we = /* @__PURE__ */ Uint8Array.from([
98
36
  7,
99
37
  4,
100
38
  13,
@@ -111,36 +49,36 @@ const Re = /* @__PURE__ */ Uint8Array.from([
111
49
  14,
112
50
  11,
113
51
  8
114
- ]), Rt = Uint8Array.from(new Array(16).fill(0).map((n, t) => t)), $e = Rt.map((n) => (9 * n + 5) % 16), $t = /* @__PURE__ */ (() => {
115
- const e = [[Rt], [$e]];
116
- for (let s = 0; s < 4; s++)
117
- for (let o of e)
118
- o.push(o[s].map((r) => Re[r]));
119
- return e;
120
- })(), Ut = $t[0], Vt = $t[1], Mt = /* @__PURE__ */ [
52
+ ]), Bt = Uint8Array.from(new Array(16).fill(0).map((s, e) => e)), ye = Bt.map((s) => (9 * s + 5) % 16), _t = /* @__PURE__ */ (() => {
53
+ const t = [[Bt], [ye]];
54
+ for (let n = 0; n < 4; n++)
55
+ for (let o of t)
56
+ o.push(o[n].map((r) => we[r]));
57
+ return t;
58
+ })(), vt = _t[0], St = _t[1], At = /* @__PURE__ */ [
121
59
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
122
60
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
123
61
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
124
62
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
125
63
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
126
- ].map((n) => Uint8Array.from(n)), Ue = /* @__PURE__ */ Ut.map((n, t) => n.map((e) => Mt[t][e])), Ve = /* @__PURE__ */ Vt.map((n, t) => n.map((e) => Mt[t][e])), Me = /* @__PURE__ */ Uint32Array.from([
64
+ ].map((s) => Uint8Array.from(s)), xe = /* @__PURE__ */ vt.map((s, e) => s.map((t) => At[e][t])), ke = /* @__PURE__ */ St.map((s, e) => s.map((t) => At[e][t])), Te = /* @__PURE__ */ Uint32Array.from([
127
65
  0,
128
66
  1518500249,
129
67
  1859775393,
130
68
  2400959708,
131
69
  2840853838
132
- ]), Ne = /* @__PURE__ */ Uint32Array.from([
70
+ ]), Ee = /* @__PURE__ */ Uint32Array.from([
133
71
  1352829926,
134
72
  1548603684,
135
73
  1836072691,
136
74
  2053994217,
137
75
  0
138
76
  ]);
139
- function _t(n, t, e, s) {
140
- return n === 0 ? t ^ e ^ s : n === 1 ? t & e | ~t & s : n === 2 ? (t | ~e) ^ s : n === 3 ? t & s | e & ~s : t ^ (e | ~s);
77
+ function Pt(s, e, t, n) {
78
+ return s === 0 ? e ^ t ^ n : s === 1 ? e & t | ~e & n : s === 2 ? (e | ~t) ^ n : s === 3 ? e & n | t & ~n : e ^ (t | ~n);
141
79
  }
142
- const N = /* @__PURE__ */ new Uint32Array(16);
143
- class Fe extends Yt {
80
+ const M = /* @__PURE__ */ new Uint32Array(16);
81
+ class Be extends Wt {
144
82
  constructor() {
145
83
  super(64, 20, 8, !0);
146
84
  x(this, "h0", 1732584193);
@@ -150,73 +88,73 @@ class Fe extends Yt {
150
88
  x(this, "h4", -1009589776);
151
89
  }
152
90
  get() {
153
- const { h0: e, h1: s, h2: o, h3: r, h4: i } = this;
154
- return [e, s, o, r, i];
91
+ const { h0: t, h1: n, h2: o, h3: r, h4: i } = this;
92
+ return [t, n, o, r, i];
155
93
  }
156
- set(e, s, o, r, i) {
157
- this.h0 = e | 0, this.h1 = s | 0, this.h2 = o | 0, this.h3 = r | 0, this.h4 = i | 0;
94
+ set(t, n, o, r, i) {
95
+ this.h0 = t | 0, this.h1 = n | 0, this.h2 = o | 0, this.h3 = r | 0, this.h4 = i | 0;
158
96
  }
159
- process(e, s) {
160
- for (let g = 0; g < 16; g++, s += 4)
161
- N[g] = e.getUint32(s, !0);
162
- let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, c = this.h2 | 0, h = c, l = this.h3 | 0, m = l, b = this.h4 | 0, P = b;
163
- for (let g = 0; g < 5; g++) {
164
- const f = 4 - g, k = Me[g], S = Ne[g], E = Ut[g], p = Vt[g], w = Ue[g], y = Ve[g];
97
+ process(t, n) {
98
+ for (let f = 0; f < 16; f++, n += 4)
99
+ M[f] = t.getUint32(n, !0);
100
+ let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, c = this.h2 | 0, h = c, l = this.h3 | 0, m = l, P = this.h4 | 0, b = P;
101
+ for (let f = 0; f < 5; f++) {
102
+ const g = 4 - f, k = Te[f], S = Ee[f], T = vt[f], p = St[f], w = xe[f], y = ke[f];
165
103
  for (let d = 0; d < 16; d++) {
166
- const u = V(o + _t(g, i, c, l) + N[E[d]] + k, w[d]) + b | 0;
167
- o = b, b = l, l = V(c, 10) | 0, c = i, i = u;
104
+ const u = U(o + Pt(f, i, c, l) + M[T[d]] + k, w[d]) + P | 0;
105
+ o = P, P = l, l = U(c, 10) | 0, c = i, i = u;
168
106
  }
169
107
  for (let d = 0; d < 16; d++) {
170
- const u = V(r + _t(f, a, h, m) + N[p[d]] + S, y[d]) + P | 0;
171
- r = P, P = m, m = V(h, 10) | 0, h = a, a = u;
108
+ const u = U(r + Pt(g, a, h, m) + M[p[d]] + S, y[d]) + b | 0;
109
+ r = b, b = m, m = U(h, 10) | 0, h = a, a = u;
172
110
  }
173
111
  }
174
- this.set(this.h1 + c + m | 0, this.h2 + l + P | 0, this.h3 + b + r | 0, this.h4 + o + a | 0, this.h0 + i + h | 0);
112
+ this.set(this.h1 + c + m | 0, this.h2 + l + b | 0, this.h3 + P + r | 0, this.h4 + o + a | 0, this.h0 + i + h | 0);
175
113
  }
176
114
  roundClean() {
177
- W(N);
115
+ F(M);
178
116
  }
179
117
  destroy() {
180
- this.destroyed = !0, W(this.buffer), this.set(0, 0, 0, 0, 0);
118
+ this.destroyed = !0, F(this.buffer), this.set(0, 0, 0, 0, 0);
181
119
  }
182
120
  }
183
- const Le = /* @__PURE__ */ At(() => new Fe()), We = BigInt(0), R = BigInt(1), Xe = BigInt(2), Ke = BigInt(7), De = BigInt(256), Ge = BigInt(113), Nt = [], Ft = [], Lt = [];
184
- for (let n = 0, t = R, e = 1, s = 0; n < 24; n++) {
185
- [e, s] = [s, (2 * e + 3 * s) % 5], Nt.push(2 * (5 * s + e)), Ft.push((n + 1) * (n + 2) / 2 % 64);
186
- let o = We;
121
+ const _e = /* @__PURE__ */ kt(() => new Be()), ve = BigInt(0), O = BigInt(1), Se = BigInt(2), Ae = BigInt(7), Ie = BigInt(256), Ce = BigInt(113), It = [], Ct = [], Ht = [];
122
+ for (let s = 0, e = O, t = 1, n = 0; s < 24; s++) {
123
+ [t, n] = [n, (2 * t + 3 * n) % 5], It.push(2 * (5 * n + t)), Ct.push((s + 1) * (s + 2) / 2 % 64);
124
+ let o = ve;
187
125
  for (let r = 0; r < 7; r++)
188
- t = (t << R ^ (t >> Ke) * Ge) % De, t & Xe && (o ^= R << (R << BigInt(r)) - R);
189
- Lt.push(o);
126
+ e = (e << O ^ (e >> Ae) * Ce) % Ie, e & Se && (o ^= O << (O << BigInt(r)) - O);
127
+ Ht.push(o);
190
128
  }
191
- const Wt = ke(Lt, !0), qe = Wt[0], ze = Wt[1], Bt = (n, t, e) => e > 32 ? _e(n, t, e) : Ee(n, t, e), vt = (n, t, e) => e > 32 ? Be(n, t, e) : Te(n, t, e);
192
- function Ye(n, t = 24) {
193
- const e = new Uint32Array(10);
194
- for (let s = 24 - t; s < 24; s++) {
129
+ const Rt = ge(Ht, !0), He = Rt[0], Re = Rt[1], bt = (s, e, t) => t > 32 ? Pe(s, e, t) : pe(s, e, t), wt = (s, e, t) => t > 32 ? be(s, e, t) : me(s, e, t);
130
+ function Oe(s, e = 24) {
131
+ const t = new Uint32Array(10);
132
+ for (let n = 24 - e; n < 24; n++) {
195
133
  for (let i = 0; i < 10; i++)
196
- e[i] = n[i] ^ n[i + 10] ^ n[i + 20] ^ n[i + 30] ^ n[i + 40];
134
+ t[i] = s[i] ^ s[i + 10] ^ s[i + 20] ^ s[i + 30] ^ s[i + 40];
197
135
  for (let i = 0; i < 10; i += 2) {
198
- const a = (i + 8) % 10, c = (i + 2) % 10, h = e[c], l = e[c + 1], m = Bt(h, l, 1) ^ e[a], b = vt(h, l, 1) ^ e[a + 1];
199
- for (let P = 0; P < 50; P += 10)
200
- n[i + P] ^= m, n[i + P + 1] ^= b;
136
+ const a = (i + 8) % 10, c = (i + 2) % 10, h = t[c], l = t[c + 1], m = bt(h, l, 1) ^ t[a], P = wt(h, l, 1) ^ t[a + 1];
137
+ for (let b = 0; b < 50; b += 10)
138
+ s[i + b] ^= m, s[i + b + 1] ^= P;
201
139
  }
202
- let o = n[2], r = n[3];
140
+ let o = s[2], r = s[3];
203
141
  for (let i = 0; i < 24; i++) {
204
- const a = Ft[i], c = Bt(o, r, a), h = vt(o, r, a), l = Nt[i];
205
- o = n[l], r = n[l + 1], n[l] = c, n[l + 1] = h;
142
+ const a = Ct[i], c = bt(o, r, a), h = wt(o, r, a), l = It[i];
143
+ o = s[l], r = s[l + 1], s[l] = c, s[l + 1] = h;
206
144
  }
207
145
  for (let i = 0; i < 50; i += 10) {
208
146
  for (let a = 0; a < 10; a++)
209
- e[a] = n[i + a];
147
+ t[a] = s[i + a];
210
148
  for (let a = 0; a < 10; a++)
211
- n[i + a] ^= ~e[(a + 2) % 10] & e[(a + 4) % 10];
149
+ s[i + a] ^= ~t[(a + 2) % 10] & t[(a + 4) % 10];
212
150
  }
213
- n[0] ^= qe[s], n[1] ^= ze[s];
151
+ s[0] ^= He[n], s[1] ^= Re[n];
214
152
  }
215
- W(e);
153
+ F(t);
216
154
  }
217
- class at {
155
+ class tt {
218
156
  // NOTE: we accept arguments in bytes instead of bits here.
219
- constructor(t, e, s, o = !1, r = 24) {
157
+ constructor(e, t, n, o = !1, r = 24) {
220
158
  x(this, "state");
221
159
  x(this, "pos", 0);
222
160
  x(this, "posOut", 0);
@@ -228,24 +166,24 @@ class at {
228
166
  x(this, "outputLen");
229
167
  x(this, "enableXOF", !1);
230
168
  x(this, "rounds");
231
- if (this.blockLen = t, this.suffix = e, this.outputLen = s, this.enableXOF = o, this.rounds = r, lt(s, "outputLen"), !(0 < t && t < 200))
169
+ if (this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = o, this.rounds = r, st(n, "outputLen"), !(0 < e && e < 200))
232
170
  throw new Error("only keccak-f1600 function is supported");
233
- this.state = new Uint8Array(200), this.state32 = jt(this.state);
171
+ this.state = new Uint8Array(200), this.state32 = Ft(this.state);
234
172
  }
235
173
  clone() {
236
174
  return this._cloneInto();
237
175
  }
238
176
  keccak() {
239
- ut(this.state32), Ye(this.state32, this.rounds), ut(this.state32), this.posOut = 0, this.pos = 0;
177
+ nt(this.state32), Oe(this.state32, this.rounds), nt(this.state32), this.posOut = 0, this.pos = 0;
240
178
  }
241
- update(t) {
242
- ht(this), dt(t);
243
- const { blockLen: e, state: s } = this, o = t.length;
179
+ update(e) {
180
+ ot(this), rt(e);
181
+ const { blockLen: t, state: n } = this, o = e.length;
244
182
  for (let r = 0; r < o; ) {
245
- const i = Math.min(e - this.pos, o - r);
183
+ const i = Math.min(t - this.pos, o - r);
246
184
  for (let a = 0; a < i; a++)
247
- s[this.pos++] ^= t[r++];
248
- this.pos === e && this.keccak();
185
+ n[this.pos++] ^= e[r++];
186
+ this.pos === t && this.keccak();
249
187
  }
250
188
  return this;
251
189
  }
@@ -253,273 +191,273 @@ class at {
253
191
  if (this.finished)
254
192
  return;
255
193
  this.finished = !0;
256
- const { state: t, suffix: e, pos: s, blockLen: o } = this;
257
- t[s] ^= e, (e & 128) !== 0 && s === o - 1 && this.keccak(), t[o - 1] ^= 128, this.keccak();
194
+ const { state: e, suffix: t, pos: n, blockLen: o } = this;
195
+ e[n] ^= t, (t & 128) !== 0 && n === o - 1 && this.keccak(), e[o - 1] ^= 128, this.keccak();
258
196
  }
259
- writeInto(t) {
260
- ht(this, !1), dt(t), this.finish();
261
- const e = this.state, { blockLen: s } = this;
262
- for (let o = 0, r = t.length; o < r; ) {
263
- this.posOut >= s && this.keccak();
264
- const i = Math.min(s - this.posOut, r - o);
265
- t.set(e.subarray(this.posOut, this.posOut + i), o), this.posOut += i, o += i;
197
+ writeInto(e) {
198
+ ot(this, !1), rt(e), this.finish();
199
+ const t = this.state, { blockLen: n } = this;
200
+ for (let o = 0, r = e.length; o < r; ) {
201
+ this.posOut >= n && this.keccak();
202
+ const i = Math.min(n - this.posOut, r - o);
203
+ e.set(t.subarray(this.posOut, this.posOut + i), o), this.posOut += i, o += i;
266
204
  }
267
- return t;
205
+ return e;
268
206
  }
269
- xofInto(t) {
207
+ xofInto(e) {
270
208
  if (!this.enableXOF)
271
209
  throw new Error("XOF is not possible for this instance");
272
- return this.writeInto(t);
210
+ return this.writeInto(e);
273
211
  }
274
- xof(t) {
275
- return lt(t), this.xofInto(new Uint8Array(t));
212
+ xof(e) {
213
+ return st(e), this.xofInto(new Uint8Array(e));
276
214
  }
277
- digestInto(t) {
278
- if (Zt(t, this), this.finished)
215
+ digestInto(e) {
216
+ if (Lt(e, this), this.finished)
279
217
  throw new Error("digest() was already called");
280
- return this.writeInto(t), this.destroy(), t;
218
+ return this.writeInto(e), this.destroy(), e;
281
219
  }
282
220
  digest() {
283
221
  return this.digestInto(new Uint8Array(this.outputLen));
284
222
  }
285
223
  destroy() {
286
- this.destroyed = !0, W(this.state);
224
+ this.destroyed = !0, F(this.state);
287
225
  }
288
- _cloneInto(t) {
289
- const { blockLen: e, suffix: s, outputLen: o, rounds: r, enableXOF: i } = this;
290
- return t || (t = new at(e, s, o, i, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = s, t.outputLen = o, t.enableXOF = i, t.destroyed = this.destroyed, t;
226
+ _cloneInto(e) {
227
+ const { blockLen: t, suffix: n, outputLen: o, rounds: r, enableXOF: i } = this;
228
+ return e || (e = new tt(t, n, o, i, r)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = r, e.suffix = n, e.outputLen = o, e.enableXOF = i, e.destroyed = this.destroyed, e;
291
229
  }
292
230
  }
293
- const je = (n, t, e, s = {}) => At(() => new at(t, n, e), s), Ze = /* @__PURE__ */ je(1, 136, 32), St = 64, _ = 20, ot = 4, Xt = 2, Qe = 0, Je = 1, F = [64, 64], tn = (n) => Array.from(n).map((t) => t.toString(16).padStart(2, "0")).join("");
294
- function ct(n) {
295
- return Le(it(n));
231
+ const $e = (s, e, t, n = {}) => kt(() => new tt(e, s, t), n), Ue = /* @__PURE__ */ $e(1, 136, 32), yt = 64, B = 20, Z = 4, Ot = 2, Ve = 0, Me = 1, N = [64, 64], Ne = (s) => Array.from(s).map((e) => e.toString(16).padStart(2, "0")).join("");
232
+ function et(s) {
233
+ return _e(Tt(s));
296
234
  }
297
- function Kt(n) {
298
- return (1 << n) - 1;
235
+ function $t(s) {
236
+ return (1 << s) - 1;
299
237
  }
300
- function en(n) {
301
- let t = 1;
302
- for (; t * t < n + 1; ) t++;
303
- return Math.max(t, 2);
238
+ function We(s) {
239
+ let e = 1;
240
+ for (; e * e < s + 1; ) e++;
241
+ return Math.max(e, 2);
304
242
  }
305
- function nn(n) {
306
- const t = ot, e = n * Kt(t);
307
- return { d: t, n, checksum_radix: en(e) };
243
+ function Fe(s) {
244
+ const e = Z, t = s * $t(e);
245
+ return { d: e, n: s, checksum_radix: We(t) };
308
246
  }
309
- function Y(n, t) {
310
- const e = [];
311
- let s = t;
312
- for (; s > 0; )
313
- e.push(s & 255), s >>>= 8;
314
- const o = new Uint8Array(n.length + e.length);
315
- o.set(n);
316
- for (let r = 0; r < e.length; r++)
317
- o[n.length + r] = e[r];
318
- return ct(o);
247
+ function D(s, e) {
248
+ const t = [];
249
+ let n = e;
250
+ for (; n > 0; )
251
+ t.push(n & 255), n >>>= 8;
252
+ const o = new Uint8Array(s.length + t.length);
253
+ o.set(s);
254
+ for (let r = 0; r < t.length; r++)
255
+ o[s.length + r] = t[r];
256
+ return et(o);
319
257
  }
320
- function j(n, t) {
321
- let e = n;
322
- for (let s = 0; s < t; s++)
323
- e = ct(e);
324
- return e;
258
+ function G(s, e) {
259
+ let t = s;
260
+ for (let n = 0; n < e; n++)
261
+ t = et(t);
262
+ return t;
325
263
  }
326
- function sn(n, t) {
327
- const e = Kt(t.d), s = t.checksum_radix - 1, o = Math.floor(t.n * e / t.checksum_radix), r = [];
328
- for (let l = 0; l < t.n; l++) {
329
- const m = Y(n, l + Xt), b = j(m, e);
330
- r.push(Array.from(b));
264
+ function Le(s, e) {
265
+ const t = $t(e.d), n = e.checksum_radix - 1, o = Math.floor(e.n * t / e.checksum_radix), r = [];
266
+ for (let l = 0; l < e.n; l++) {
267
+ const m = D(s, l + Ot), P = G(m, t);
268
+ r.push(Array.from(P));
331
269
  }
332
- const i = Y(
333
- n,
334
- Qe
335
- ), a = j(
270
+ const i = D(
271
+ s,
272
+ Ve
273
+ ), a = G(
336
274
  i,
337
- s
338
- ), c = Y(
339
- n,
340
- Je
341
- ), h = j(
275
+ n
276
+ ), c = D(
277
+ s,
278
+ Me
279
+ ), h = G(
342
280
  c,
343
281
  o
344
282
  );
345
283
  return {
346
- config: t,
284
+ config: e,
347
285
  message_terminals: r,
348
286
  checksum_major_terminal: Array.from(h),
349
287
  checksum_minor_terminal: Array.from(a)
350
288
  };
351
289
  }
352
- async function on(n) {
290
+ async function Xe(s) {
353
291
  try {
354
- if (n.length !== St)
292
+ if (s.length !== yt)
355
293
  throw new Error(
356
- `WOTS seed must be exactly ${St} bytes, got ${n.length}`
294
+ `WOTS seed must be exactly ${yt} bytes, got ${s.length}`
357
295
  );
358
- const t = [];
359
- for (let e = 0; e < F.length; e++) {
360
- const s = F[e], o = nn(s), r = new Uint8Array(n.length + 1);
361
- r.set(n), r[n.length] = e;
362
- const i = ct(r);
296
+ const e = [];
297
+ for (let t = 0; t < N.length; t++) {
298
+ const n = N[t], o = Fe(n), r = new Uint8Array(s.length + 1);
299
+ r.set(s), r[s.length] = t;
300
+ const i = et(r);
363
301
  try {
364
- const a = sn(i, o);
365
- if (a.config.d !== ot)
302
+ const a = Le(i, o);
303
+ if (a.config.d !== Z)
366
304
  throw new Error(
367
- `Block ${e}: expected d=${ot}, got d=${a.config.d}`
305
+ `Block ${t}: expected d=${Z}, got d=${a.config.d}`
368
306
  );
369
- if (a.config.n !== s)
307
+ if (a.config.n !== n)
370
308
  throw new Error(
371
- `Block ${e}: expected n=${s}, got n=${a.config.n}`
309
+ `Block ${t}: expected n=${n}, got n=${a.config.n}`
372
310
  );
373
- if (a.message_terminals.length !== s)
311
+ if (a.message_terminals.length !== n)
374
312
  throw new Error(
375
- `Block ${e}: expected ${s} message terminals, got ${a.message_terminals.length}`
313
+ `Block ${t}: expected ${n} message terminals, got ${a.message_terminals.length}`
376
314
  );
377
315
  for (let c = 0; c < a.message_terminals.length; c++)
378
- if (a.message_terminals[c].length !== _)
316
+ if (a.message_terminals[c].length !== B)
379
317
  throw new Error(
380
- `Block ${e} terminal ${c}: expected ${_} bytes, got ${a.message_terminals[c].length}`
318
+ `Block ${t} terminal ${c}: expected ${B} bytes, got ${a.message_terminals[c].length}`
381
319
  );
382
- if (a.checksum_minor_terminal.length !== _)
320
+ if (a.checksum_minor_terminal.length !== B)
383
321
  throw new Error(
384
- `Block ${e} checksum_minor: expected ${_} bytes`
322
+ `Block ${t} checksum_minor: expected ${B} bytes`
385
323
  );
386
- if (a.checksum_major_terminal.length !== _)
324
+ if (a.checksum_major_terminal.length !== B)
387
325
  throw new Error(
388
- `Block ${e} checksum_major: expected ${_} bytes`
326
+ `Block ${t} checksum_major: expected ${B} bytes`
389
327
  );
390
- t.push(a);
328
+ e.push(a);
391
329
  } finally {
392
330
  r.fill(0), i.fill(0);
393
331
  }
394
332
  }
395
- if (t.length !== F.length)
333
+ if (e.length !== N.length)
396
334
  throw new Error(
397
- `Expected ${F.length} blocks, got ${t.length}`
335
+ `Expected ${N.length} blocks, got ${e.length}`
398
336
  );
399
- return t;
337
+ return e;
400
338
  } finally {
401
- n.fill(0);
339
+ s.fill(0);
402
340
  }
403
341
  }
404
- function Z(n, t, e) {
405
- if (n.length !== _)
342
+ function q(s, e, t) {
343
+ if (s.length !== B)
406
344
  throw new Error(
407
- `Block ${t} ${e}: expected ${_} bytes, got ${n.length}`
345
+ `Block ${e} ${t}: expected ${B} bytes, got ${s.length}`
408
346
  );
409
- for (let s = 0; s < n.length; s++) {
410
- const o = n[s];
347
+ for (let n = 0; n < s.length; n++) {
348
+ const o = s[n];
411
349
  if (!Number.isInteger(o) || o < 0 || o > 255)
412
350
  throw new Error(
413
- `Block ${t} ${e}[${s}]: invalid byte value ${o}`
351
+ `Block ${e} ${t}[${n}]: invalid byte value ${o}`
414
352
  );
415
353
  }
416
354
  }
417
- function rn(n) {
418
- if (n.length === 0)
355
+ function Ke(s) {
356
+ if (s.length === 0)
419
357
  throw new Error("Public keys array must not be empty");
420
- for (let r = 0; r < n.length; r++) {
421
- const i = n[r];
422
- Z(i.checksum_minor_terminal, r, "checksum_minor_terminal"), Z(i.checksum_major_terminal, r, "checksum_major_terminal");
358
+ for (let r = 0; r < s.length; r++) {
359
+ const i = s[r];
360
+ q(i.checksum_minor_terminal, r, "checksum_minor_terminal"), q(i.checksum_major_terminal, r, "checksum_major_terminal");
423
361
  for (let a = 0; a < i.message_terminals.length; a++)
424
- Z(i.message_terminals[a], r, `message_terminal[${a}]`);
362
+ q(i.message_terminals[a], r, `message_terminal[${a}]`);
425
363
  }
426
- let t = 0;
427
- for (const r of n)
428
- t += Xt + r.message_terminals.length;
429
- const e = new Uint8Array(t * _);
430
- let s = 0;
431
- for (const r of n) {
432
- e.set(r.checksum_minor_terminal, s), s += _, e.set(r.checksum_major_terminal, s), s += _;
364
+ let e = 0;
365
+ for (const r of s)
366
+ e += Ot + r.message_terminals.length;
367
+ const t = new Uint8Array(e * B);
368
+ let n = 0;
369
+ for (const r of s) {
370
+ t.set(r.checksum_minor_terminal, n), n += B, t.set(r.checksum_major_terminal, n), n += B;
433
371
  for (const i of r.message_terminals)
434
- e.set(i, s), s += _;
372
+ t.set(i, n), n += B;
435
373
  }
436
- const o = Ze(e);
437
- return `0x${tn(o)}`;
374
+ const o = Ue(t);
375
+ return `0x${Ne(o)}`;
438
376
  }
439
- async function an(n, t) {
440
- const e = [], s = [], o = [], r = [];
377
+ async function De(s, e) {
378
+ const t = [], n = [], o = [], r = [];
441
379
  try {
442
- for (let i = 0; i < t; i++) {
443
- const a = await te(n, i);
380
+ for (let i = 0; i < e; i++) {
381
+ const a = await Dt(s, i);
444
382
  try {
445
- const h = await on(a);
446
- e.push(h), s.push(rn(h));
383
+ const h = await Xe(a);
384
+ t.push(h), n.push(Ke(h));
447
385
  } finally {
448
386
  a.fill(0);
449
387
  }
450
- const c = await ee(n, i);
388
+ const c = await Gt(s, i);
451
389
  try {
452
- const h = X(c);
453
- o.push(h), r.push(he(v(h)).slice(2));
390
+ const h = Q(c);
391
+ o.push(h), r.push(ne(v(h)).slice(2));
454
392
  } finally {
455
393
  c.fill(0);
456
394
  }
457
395
  }
458
396
  } finally {
459
- n.fill(0);
397
+ s.fill(0);
460
398
  }
461
- return { perVaultWotsKeys: e, wotsPkHashes: s, htlcSecretHexes: o, hashlocks: r };
399
+ return { perVaultWotsKeys: t, wotsPkHashes: n, htlcSecretHexes: o, hashlocks: r };
462
400
  }
463
- const cn = /^0x[0-9a-f]+$/i, ln = /^[0-9a-f]+$/i, un = /^[A-Za-z0-9+/]+={0,2}$/;
464
- function $(n) {
465
- if (typeof n != "string" || n.length === 0)
401
+ const Ge = /^0x[0-9a-f]+$/i, qe = /^[0-9a-f]+$/i, ze = /^[A-Za-z0-9+/]+={0,2}$/;
402
+ function $(s) {
403
+ if (typeof s != "string" || s.length === 0)
466
404
  throw new Error("BTC wallet returned empty public key");
467
- return ce(n).toLowerCase();
405
+ return Jt(s).toLowerCase();
468
406
  }
469
- function hn(n) {
470
- if (typeof n != "string" || n.length === 0)
407
+ function Ye(s) {
408
+ if (typeof s != "string" || s.length === 0)
471
409
  throw new Error("BTC wallet returned empty BIP-322 signature");
472
- if (n.startsWith("0x") || n.startsWith("0X")) {
473
- if (!cn.test(n) || n.length < 4 || n.length % 2 !== 0)
410
+ if (s.startsWith("0x") || s.startsWith("0X")) {
411
+ if (!Ge.test(s) || s.length < 4 || s.length % 2 !== 0)
474
412
  throw new Error("BTC wallet returned malformed hex BIP-322 signature");
475
- return n.toLowerCase();
413
+ return s.toLowerCase();
476
414
  }
477
- if (ln.test(n)) {
478
- if (n.length % 2 !== 0)
415
+ if (qe.test(s)) {
416
+ if (s.length % 2 !== 0)
479
417
  throw new Error("BTC wallet returned malformed hex BIP-322 signature");
480
- return `0x${n.toLowerCase()}`;
418
+ return `0x${s.toLowerCase()}`;
481
419
  }
482
- if (!un.test(n) || n.length % 4 !== 0)
420
+ if (!ze.test(s) || s.length % 4 !== 0)
483
421
  throw new Error("BTC wallet returned malformed base64 BIP-322 signature");
484
- const t = J.from(n, "base64");
485
- if (t.length === 0 || t.toString("base64") !== n)
422
+ const e = Y.from(s, "base64");
423
+ if (e.length === 0 || e.toString("base64") !== s)
486
424
  throw new Error("BTC wallet returned malformed base64 BIP-322 signature");
487
- return `0x${t.toString("hex")}`;
425
+ return `0x${e.toString("hex")}`;
488
426
  }
489
- const Dt = 0, L = 25, rt = 9999, Q = "00".repeat(32);
490
- function dn(n, t) {
491
- const e = {
427
+ const Ut = 0, W = 25, J = 9999, z = "00".repeat(32);
428
+ function je(s, e) {
429
+ const t = {
492
430
  bitcoin: "bc",
493
431
  testnet: "tb",
494
432
  signet: "tb",
495
433
  regtest: "bcrt"
496
434
  };
497
435
  try {
498
- const s = Ct.address.fromBech32(n);
499
- return s.prefix === e[t] && s.version === 0 && s.data.length === 20;
436
+ const n = Et.address.fromBech32(s);
437
+ return n.prefix === t[e] && n.version === 0 && n.data.length === 20;
500
438
  } catch {
501
439
  return !1;
502
440
  }
503
441
  }
504
- function gn(n, t, e, s) {
505
- const o = e == null ? void 0 : e[`${n}:${t}`];
442
+ function Qe(s, e, t, n) {
443
+ const o = t == null ? void 0 : t[`${s}:${e}`];
506
444
  return o ? Promise.resolve({
507
- txid: n,
508
- vout: t,
445
+ txid: s,
446
+ vout: e,
509
447
  value: o.value,
510
448
  scriptPubKey: o.scriptPubKey
511
- }) : ye(n, t, s);
449
+ }) : de(s, e, n);
512
450
  }
513
- const It = 12e4;
514
- class Vn {
451
+ const xt = 12e4;
452
+ class ks {
515
453
  /**
516
454
  * Creates a new PeginManager instance.
517
455
  *
518
456
  * @param config - Manager configuration including wallets and contract addresses
519
457
  */
520
- constructor(t) {
458
+ constructor(e) {
521
459
  x(this, "config");
522
- this.config = t;
460
+ this.config = e;
523
461
  }
524
462
  /**
525
463
  * Prepare a peg-in: sizing pass → vault-root derivation (one wallet
@@ -531,67 +469,67 @@ class Vn {
531
469
  * @throws If the wallet rejects, insufficient funds, or an internal
532
470
  * invariant violation.
533
471
  */
534
- async preparePegin(t) {
535
- if (t.amounts.length === 0)
472
+ async preparePegin(e) {
473
+ if (e.amounts.length === 0)
536
474
  throw new Error("amounts must contain at least one entry");
537
- const e = await this.config.btcWallet.getPublicKeyHex(), s = $(e);
538
- if (!Pt(
539
- t.changeAddress,
540
- e,
475
+ const t = await this.config.btcWallet.getPublicKeyHex(), n = $(t);
476
+ if (!ht(
477
+ e.changeAddress,
478
+ t,
541
479
  this.config.btcNetwork
542
480
  ))
543
481
  throw new Error(
544
- `Pre-PegIn changeAddress "${t.changeAddress}" is not derived from the connected wallet's public key. Refusing to build a tx that would send change to an address the signing key doesn't control.`
482
+ `Pre-PegIn changeAddress "${e.changeAddress}" is not derived from the connected wallet's public key. Refusing to build a tx that would send change to an address the signing key doesn't control.`
545
483
  );
546
- const o = await this.prepareSizing(s, t), r = o.selectedUTXOs.map(
547
- (f) => ({
548
- txid: et(f.txid),
549
- vout: f.vout
484
+ const o = await this.prepareSizing(n, e), r = o.selectedUTXOs.map(
485
+ (g) => ({
486
+ txid: dt(g.txid),
487
+ vout: g.vout
550
488
  })
551
- ), i = await Oe(this.config.btcWallet, {
552
- depositorBtcPubkey: et(s),
489
+ ), i = await se(this.config.btcWallet, {
490
+ depositorBtcPubkey: dt(n),
553
491
  fundingOutpoints: r
554
492
  });
555
493
  let a, c;
556
494
  try {
557
- const f = await ne(i);
495
+ const g = await qt(i);
558
496
  try {
559
- a = X(f), c = X(it(f));
497
+ a = Q(g), c = Q(Tt(g));
560
498
  } finally {
561
- f.fill(0);
499
+ g.fill(0);
562
500
  }
563
- } catch (f) {
564
- throw i.fill(0), f;
501
+ } catch (g) {
502
+ throw i.fill(0), g;
565
503
  }
566
- const h = await an(i, t.amounts.length), { perVaultWotsKeys: l, wotsPkHashes: m, htlcSecretHexes: b, hashlocks: P } = h, g = await this.preparePeginCommit({
567
- depositorBtcPubkeyRaw: e,
568
- depositorBtcPubkey: s,
569
- hashlocks: P,
504
+ const h = await De(i, e.amounts.length), { perVaultWotsKeys: l, wotsPkHashes: m, htlcSecretHexes: P, hashlocks: b } = h, f = await this.preparePeginCommit({
505
+ depositorBtcPubkeyRaw: t,
506
+ depositorBtcPubkey: n,
507
+ hashlocks: b,
570
508
  authAnchorHash: c,
571
509
  sizing: o,
572
- params: t
510
+ params: e
573
511
  });
574
- for (let f = 0; f < g.perVault.length; f++)
575
- if (g.perVault[f].htlcVout !== f)
512
+ for (let g = 0; g < f.perVault.length; g++)
513
+ if (f.perVault[g].htlcVout !== g)
576
514
  throw new Error(
577
- `Internal invariant violation: htlcVout/index mismatch at vault ${f} (expected ${f}, got ${g.perVault[f].htlcVout})`
515
+ `Internal invariant violation: htlcVout/index mismatch at vault ${g} (expected ${g}, got ${f.perVault[g].htlcVout})`
578
516
  );
579
- return de(
580
- g.fundedPrePeginTxHex,
581
- t.amounts.length,
517
+ return oe(
518
+ f.fundedPrePeginTxHex,
519
+ e.amounts.length,
582
520
  c
583
521
  ), {
584
522
  transaction: {
585
- ...g,
523
+ ...f,
586
524
  selectedUTXOs: o.selectedUTXOs,
587
525
  fee: o.fee,
588
526
  changeAmount: o.changeAmount
589
527
  },
590
- depositorBtcPubkey: s,
528
+ depositorBtcPubkey: n,
591
529
  derivedSecrets: {
592
530
  perVaultWotsKeys: l,
593
531
  wotsPkHashes: m,
594
- htlcSecretHexes: b,
532
+ htlcSecretHexes: P,
595
533
  authAnchorHex: a
596
534
  }
597
535
  };
@@ -612,30 +550,30 @@ class Vn {
612
550
  * real values. Output budget is identical (32-byte push regardless of
613
551
  * content), so UTXO selection is invariant under substitution.
614
552
  */
615
- async prepareSizing(t, e) {
616
- const s = e.amounts.map(
617
- () => Q
618
- ), o = e.vaultKeeperBtcPubkeys.length, r = await mt({
619
- vaultCoreVersion: e.vaultCoreVersion,
620
- depositorPubkey: t,
621
- vaultProviderPubkey: T(e.vaultProviderBtcPubkey),
622
- vaultKeeperPubkeys: e.vaultKeeperBtcPubkeys.map(T),
623
- universalChallengerPubkeys: e.universalChallengerBtcPubkeys.map(T),
624
- hashlocks: s,
625
- timelockRefund: e.timelockRefund,
626
- pegInAmounts: e.amounts,
627
- feeRate: e.protocolFeeRate,
628
- minPeginFeeRate: e.minPeginFeeRate,
553
+ async prepareSizing(e, t) {
554
+ const n = t.amounts.map(
555
+ () => z
556
+ ), o = t.vaultKeeperBtcPubkeys.length, r = await lt({
557
+ vaultCoreVersion: t.vaultCoreVersion,
558
+ depositorPubkey: e,
559
+ vaultProviderPubkey: E(t.vaultProviderBtcPubkey),
560
+ vaultKeeperPubkeys: t.vaultKeeperBtcPubkeys.map(E),
561
+ universalChallengerPubkeys: t.universalChallengerBtcPubkeys.map(E),
562
+ hashlocks: n,
563
+ timelockRefund: t.timelockRefund,
564
+ pegInAmounts: t.amounts,
565
+ feeRate: t.protocolFeeRate,
566
+ minPeginFeeRate: t.minPeginFeeRate,
629
567
  numLocalChallengers: o,
630
- councilQuorum: e.councilQuorum,
631
- councilSize: e.councilSize,
568
+ councilQuorum: t.councilQuorum,
569
+ councilSize: t.councilSize,
632
570
  network: this.config.btcNetwork,
633
- authAnchorHash: Q
634
- }), i = fe(
635
- [...e.availableUTXOs],
571
+ authAnchorHash: z
572
+ }), i = ie(
573
+ [...t.availableUTXOs],
636
574
  r.totalOutputValue,
637
- e.mempoolFeeRate,
638
- me(r.htlcValues.length, !0)
575
+ t.mempoolFeeRate,
576
+ ce(r.htlcValues.length, !0)
639
577
  );
640
578
  return {
641
579
  selectedUTXOs: i.selectedUTXOs,
@@ -644,15 +582,15 @@ class Vn {
644
582
  };
645
583
  }
646
584
  /** Build PegIn txs and batch-sign their inputs with real hashlocks. */
647
- async preparePeginCommit(t) {
585
+ async preparePeginCommit(e) {
648
586
  const {
649
- depositorBtcPubkeyRaw: e,
650
- depositorBtcPubkey: s,
587
+ depositorBtcPubkeyRaw: t,
588
+ depositorBtcPubkey: n,
651
589
  hashlocks: o,
652
590
  authAnchorHash: r,
653
591
  sizing: i,
654
592
  params: a
655
- } = t, c = Q.toLowerCase();
593
+ } = e, c = z.toLowerCase();
656
594
  for (let u = 0; u < o.length; u++)
657
595
  if (o[u].toLowerCase() === c)
658
596
  throw new Error(
@@ -662,11 +600,11 @@ class Vn {
662
600
  throw new Error(
663
601
  "preparePeginCommit refusing to build with sizing-pass placeholder auth-anchor hash — internal substitution bug"
664
602
  );
665
- const h = T(
603
+ const h = E(
666
604
  a.vaultProviderBtcPubkey
667
- ), l = a.vaultKeeperBtcPubkeys.map(T), m = a.universalChallengerBtcPubkeys.map(T), b = l.length, P = {
605
+ ), l = a.vaultKeeperBtcPubkeys.map(E), m = a.universalChallengerBtcPubkeys.map(E), P = l.length, b = {
668
606
  vaultCoreVersion: a.vaultCoreVersion,
669
- depositorPubkey: s,
607
+ depositorPubkey: n,
670
608
  vaultProviderPubkey: h,
671
609
  vaultKeeperPubkeys: l,
672
610
  universalChallengerPubkeys: m,
@@ -675,31 +613,31 @@ class Vn {
675
613
  pegInAmounts: a.amounts,
676
614
  feeRate: a.protocolFeeRate,
677
615
  minPeginFeeRate: a.minPeginFeeRate,
678
- numLocalChallengers: b,
616
+ numLocalChallengers: P,
679
617
  councilQuorum: a.councilQuorum,
680
618
  councilSize: a.councilSize,
681
619
  network: this.config.btcNetwork,
682
620
  authAnchorHash: r
683
- }, g = await mt(P), f = wt(this.config.btcNetwork), k = be({
684
- unfundedTxHex: g.psbtHex,
621
+ }, f = await lt(b), g = ft(this.config.btcNetwork), k = le({
622
+ unfundedTxHex: f.psbtHex,
685
623
  selectedUTXOs: i.selectedUTXOs,
686
624
  changeAddress: a.changeAddress,
687
625
  changeAmount: i.changeAmount,
688
- network: f
689
- }), S = T(
690
- q(k)
691
- ), E = [], p = [], w = [];
626
+ network: g
627
+ }), S = E(
628
+ K(k)
629
+ ), T = [], p = [], w = [];
692
630
  for (let u = 0; u < o.length; u++) {
693
- const B = await se({
694
- prePeginParams: P,
631
+ const _ = await zt({
632
+ prePeginParams: b,
695
633
  timelockPegin: a.timelockPegin,
696
634
  fundedPrePeginTxHex: k,
697
635
  htlcVout: u
698
- }), I = await re({
636
+ }), A = await jt({
699
637
  vaultCoreVersion: a.vaultCoreVersion,
700
- peginTxHex: B.txHex,
638
+ peginTxHex: _.txHex,
701
639
  fundedPrePeginTxHex: k,
702
- depositorPubkey: s,
640
+ depositorPubkey: n,
703
641
  vaultProviderPubkey: h,
704
642
  vaultKeeperPubkeys: l,
705
643
  universalChallengerPubkeys: m,
@@ -707,38 +645,38 @@ class Vn {
707
645
  timelockRefund: a.timelockRefund,
708
646
  network: this.config.btcNetwork
709
647
  });
710
- E.push(B), p.push(I.psbtHex), w.push(
711
- ue(e, 1)
648
+ T.push(_), p.push(A.psbtHex), w.push(
649
+ ee(t, 1)
712
650
  );
713
651
  }
714
- const y = await ge(
652
+ const y = await re(
715
653
  this.config.btcWallet,
716
654
  p,
717
655
  w
718
656
  ), d = [];
719
657
  for (let u = 0; u < y.length; u++) {
720
- bt({
658
+ ut({
721
659
  requestedPsbtHex: p[u],
722
660
  returnedPsbtHex: y[u]
723
661
  });
724
- const B = ie(
662
+ const _ = Qt(
725
663
  y[u],
726
- s
664
+ n
727
665
  );
728
- oe({
666
+ Yt({
729
667
  requestedPsbtHex: p[u],
730
- signatureHex: B,
731
- signerXOnlyPubkeyHex: s,
668
+ signatureHex: _,
669
+ signerXOnlyPubkeyHex: n,
732
670
  inputIndex: 0
733
671
  });
734
- const I = ae(y[u]);
672
+ const A = Zt(y[u]);
735
673
  d.push({
736
674
  htlcVout: u,
737
- htlcValue: g.htlcValues[u],
738
- peginTxHex: I,
739
- peginTxid: E[u].txid,
740
- peginInputSignature: B,
741
- vaultScriptPubKey: E[u].vaultScriptPubKey
675
+ htlcValue: f.htlcValues[u],
676
+ peginTxHex: A,
677
+ peginTxid: T[u].txid,
678
+ peginInputSignature: _,
679
+ vaultScriptPubKey: T[u].vaultScriptPubKey
742
680
  });
743
681
  }
744
682
  return {
@@ -762,38 +700,38 @@ class Vn {
762
700
  * @returns The broadcasted Bitcoin transaction ID
763
701
  * @throws Error if signing or broadcasting fails
764
702
  */
765
- async signAndBroadcast(t) {
766
- const { fundedPrePeginTxHex: e, depositorBtcPubkey: s } = t, o = e.startsWith("0x") ? e.slice(2) : e, r = Qt.fromHex(o);
703
+ async signAndBroadcast(e) {
704
+ const { fundedPrePeginTxHex: t, depositorBtcPubkey: n } = e, o = t.startsWith("0x") ? t.slice(2) : t, r = Xt.fromHex(o);
767
705
  if (r.ins.length === 0)
768
706
  throw new Error("Transaction has no inputs");
769
- const i = new gt();
707
+ const i = new it();
770
708
  i.setVersion(r.version), i.setLocktime(r.locktime);
771
- const a = J.from(
772
- $(s),
709
+ const a = Y.from(
710
+ $(n),
773
711
  "hex"
774
712
  ), c = this.config.mempoolApiUrl, h = r.ins.map((p) => {
775
- const w = J.from(p.hash).reverse().toString("hex"), y = p.index;
776
- return gn(w, y, t.localPrevouts, c).then(
713
+ const w = Y.from(p.hash).reverse().toString("hex"), y = p.index;
714
+ return Qe(w, y, e.localPrevouts, c).then(
777
715
  (d) => ({ input: p, utxoData: d, txid: w, vout: y })
778
716
  );
779
717
  }), l = await Promise.all(h), m = l.reduce(
780
718
  (p, w) => p + BigInt(w.utxoData.value),
781
719
  0n
782
- ), b = r.outs.reduce(
720
+ ), P = r.outs.reduce(
783
721
  (p, w) => p + BigInt(w.value),
784
722
  0n
785
723
  );
786
- if (m < b)
724
+ if (m < P)
787
725
  throw new Error(
788
- `UTXO value mismatch: total input value (${m} sat) is less than total output value (${b} sat). This may indicate the mempool API returned manipulated UTXO data.`
726
+ `UTXO value mismatch: total input value (${m} sat) is less than total output value (${P} sat). This may indicate the mempool API returned manipulated UTXO data.`
789
727
  );
790
- const P = m - b;
791
- if (P > yt)
728
+ const b = m - P;
729
+ if (b > gt)
792
730
  throw new Error(
793
- `Implied transaction fee (${P} sat) exceeds maximum reasonable fee (${yt} sat). This may indicate manipulated UTXO data.`
731
+ `Implied transaction fee (${b} sat) exceeds maximum reasonable fee (${gt} sat). This may indicate manipulated UTXO data.`
794
732
  );
795
733
  for (const { input: p, utxoData: w, txid: y, vout: d } of l) {
796
- const u = pe(
734
+ const u = ae(
797
735
  {
798
736
  value: w.value,
799
737
  scriptPubKey: w.scriptPubKey
@@ -812,12 +750,12 @@ class Vn {
812
750
  script: p.script,
813
751
  value: p.value
814
752
  });
815
- const g = i.toHex(), f = await this.config.btcWallet.signPsbt(g);
816
- bt({
817
- requestedPsbtHex: g,
818
- returnedPsbtHex: f
753
+ const f = i.toHex(), g = await this.config.btcWallet.signPsbt(f);
754
+ ut({
755
+ requestedPsbtHex: f,
756
+ returnedPsbtHex: g
819
757
  });
820
- const k = gt.fromHex(f);
758
+ const k = it.fromHex(g);
821
759
  try {
822
760
  k.finalizeAllInputs();
823
761
  } catch (p) {
@@ -829,7 +767,7 @@ class Vn {
829
767
  );
830
768
  }
831
769
  const S = k.extractTransaction().toHex();
832
- return await Pe(S, c);
770
+ return await ue(S, c);
833
771
  }
834
772
  /**
835
773
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -855,66 +793,66 @@ class Vn {
855
793
  * @throws Error if contract simulation fails (e.g., invalid signature,
856
794
  * unauthorized)
857
795
  */
858
- async registerPeginOnChain(t) {
796
+ async registerPeginOnChain(e) {
859
797
  const {
860
- unsignedPrePeginTx: e,
861
- depositorSignedPeginTx: s,
798
+ unsignedPrePeginTx: t,
799
+ depositorSignedPeginTx: n,
862
800
  vaultProvider: o,
863
801
  hashlock: r,
864
802
  htlcVout: i,
865
803
  depositorPayoutBtcAddress: a,
866
804
  depositorWotsPkHash: c,
867
805
  popSignature: h
868
- } = t;
806
+ } = e;
869
807
  if (!this.config.ethWallet.account)
870
808
  throw new Error("Ethereum wallet account not found");
871
809
  const l = this.config.ethWallet.account.address;
872
- if (!ft(h.depositorEthAddress, l))
810
+ if (!at(h.depositorEthAddress, l))
873
811
  throw new Error(
874
812
  `Proof of possession was signed for ${h.depositorEthAddress} but the Ethereum wallet is currently connected to ${l}. Reconnect the original account or call signProofOfPossession() again.`
875
813
  );
876
- const m = await this.assertPopMatchesBtcWallet(h), b = h.btcPopSignature, P = v(
814
+ const m = await this.assertPopMatchesBtcWallet(h), P = h.btcPopSignature, b = v(
877
815
  h.depositorBtcPubkey
878
- ), g = v(e), f = v(s), k = a ?? await this.config.btcWallet.getAddress(), S = this.resolvePayoutScriptPubKey(
816
+ ), f = v(t), g = v(n), k = a ?? await this.config.btcWallet.getAddress(), S = this.resolvePayoutScriptPubKey(
879
817
  m,
880
818
  k
881
- ), E = q(f), p = await pt(
882
- T(E),
883
- T(l)
819
+ ), T = K(g), p = await ct(
820
+ E(T),
821
+ E(l)
884
822
  ), w = v(p);
885
823
  if (await this.checkVaultExists(w))
886
824
  throw new Error(
887
- `Vault already exists (ID: ${w}, peginTxHash: ${E}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
825
+ `Vault already exists (ID: ${w}, peginTxHash: ${T}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
888
826
  );
889
827
  const d = this.config.publicClient;
890
828
  let u;
891
829
  try {
892
830
  u = await d.readContract({
893
831
  address: this.config.vaultContracts.btcVaultRegistry,
894
- abi: A,
832
+ abi: I,
895
833
  functionName: "getPegInFee",
896
834
  args: [o]
897
835
  });
898
- } catch (O) {
836
+ } catch (R) {
899
837
  throw new Error(
900
838
  "Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct.",
901
- { cause: O }
839
+ { cause: R }
902
840
  );
903
841
  }
904
- const B = await this.resolveMaxAcceptableCommissionBps(
842
+ const _ = await this.resolveMaxAcceptableCommissionBps(
905
843
  o,
906
- t.quotedCommissionBps
907
- ), I = tt({
908
- abi: A,
844
+ e.quotedCommissionBps
845
+ ), A = j({
846
+ abi: I,
909
847
  functionName: "submitPeginRequest",
910
848
  args: [
911
849
  l,
912
- P,
913
850
  b,
914
- g,
851
+ P,
915
852
  f,
853
+ g,
916
854
  o,
917
- B,
855
+ _,
918
856
  r,
919
857
  i,
920
858
  S,
@@ -925,40 +863,40 @@ class Vn {
925
863
  try {
926
864
  C = await d.estimateGas({
927
865
  to: this.config.vaultContracts.btcVaultRegistry,
928
- data: I,
866
+ data: A,
929
867
  value: u,
930
868
  account: this.config.ethWallet.account.address
931
869
  });
932
- } catch (O) {
933
- H(O);
870
+ } catch (R) {
871
+ H(R);
934
872
  }
935
- let D;
873
+ let L;
936
874
  try {
937
- D = await this.config.ethWallet.sendTransaction({
875
+ L = await this.config.ethWallet.sendTransaction({
938
876
  to: this.config.vaultContracts.btcVaultRegistry,
939
- data: I,
877
+ data: A,
940
878
  value: u,
941
879
  account: this.config.ethWallet.account,
942
880
  chain: this.config.ethChain,
943
881
  gas: C
944
882
  });
945
- } catch (O) {
946
- H(O);
883
+ } catch (R) {
884
+ H(R);
947
885
  }
948
- const G = await xt({
886
+ const X = await pt({
949
887
  publicClient: d,
950
888
  walletAddress: this.config.ethWallet.account.address,
951
- hash: D,
952
- timeout: It
889
+ hash: L,
890
+ timeout: xt
953
891
  });
954
- return G.status === "reverted" && H(
892
+ return X.status === "reverted" && H(
955
893
  new Error(
956
- `Transaction reverted. Hash: ${G.transactionHash}. Check the transaction on block explorer for details.`
894
+ `Transaction reverted. Hash: ${X.transactionHash}. Check the transaction on block explorer for details.`
957
895
  )
958
896
  ), {
959
- ethTxHash: G.transactionHash,
897
+ ethTxHash: X.transactionHash,
960
898
  vaultId: w,
961
- peginTxHash: E
899
+ peginTxHash: T
962
900
  };
963
901
  }
964
902
  /**
@@ -971,14 +909,14 @@ class Vn {
971
909
  * @param params - Batch registration parameters
972
910
  * @returns Batch result with per-vault IDs and single ETH tx hash
973
911
  */
974
- async registerPeginBatchOnChain(t) {
975
- const { vaultProvider: e, unsignedPrePeginTx: s, requests: o, popSignature: r } = t;
912
+ async registerPeginBatchOnChain(e) {
913
+ const { vaultProvider: t, unsignedPrePeginTx: n, requests: o, popSignature: r } = e;
976
914
  if (o.length === 0)
977
915
  throw new Error("Batch pegin requires at least one request");
978
916
  if (!this.config.ethWallet.account)
979
917
  throw new Error("Ethereum wallet account not found");
980
918
  const i = this.config.ethWallet.account.address;
981
- if (!ft(r.depositorEthAddress, i))
919
+ if (!at(r.depositorEthAddress, i))
982
920
  throw new Error(
983
921
  `Proof of possession was signed for ${r.depositorEthAddress} but the Ethereum wallet is currently connected to ${i}. Reconnect the original account or call signProofOfPossession() again.`
984
922
  );
@@ -991,24 +929,24 @@ class Vn {
991
929
  for (const d of o) {
992
930
  const u = v(
993
931
  d.depositorSignedPeginTx
994
- ), B = q(u), I = await pt(
995
- T(B),
996
- T(i)
997
- ), C = v(I);
932
+ ), _ = K(u), A = await ct(
933
+ E(_),
934
+ E(i)
935
+ ), C = v(A);
998
936
  if (await this.checkVaultExists(C))
999
937
  throw new Error(
1000
- `Vault already exists (ID: ${C}, peginTxHash: ${B}). To create a new vault, use different UTXOs or a different amount.`
938
+ `Vault already exists (ID: ${C}, peginTxHash: ${_}). To create a new vault, use different UTXOs or a different amount.`
1001
939
  );
1002
- l.push({ vaultId: C, peginTxHash: B });
940
+ l.push({ vaultId: C, peginTxHash: _ });
1003
941
  }
1004
942
  const m = this.config.publicClient;
1005
- let b;
943
+ let P;
1006
944
  try {
1007
- b = await m.readContract({
945
+ P = await m.readContract({
1008
946
  address: this.config.vaultContracts.btcVaultRegistry,
1009
- abi: A,
947
+ abi: I,
1010
948
  functionName: "getPegInFee",
1011
- args: [e]
949
+ args: [t]
1012
950
  });
1013
951
  } catch (d) {
1014
952
  throw new Error(
@@ -1016,13 +954,13 @@ class Vn {
1016
954
  { cause: d }
1017
955
  );
1018
956
  }
1019
- const P = b * BigInt(o.length), g = await this.resolveMaxAcceptableCommissionBps(
1020
- e,
1021
- t.quotedCommissionBps
1022
- ), f = v(
957
+ const b = P * BigInt(o.length), f = await this.resolveMaxAcceptableCommissionBps(
958
+ t,
959
+ e.quotedCommissionBps
960
+ ), g = v(
1023
961
  r.depositorBtcPubkey
1024
- ), k = v(s), S = o.map((d, u) => ({
1025
- depositorBtcPubKey: f,
962
+ ), k = v(n), S = o.map((d, u) => ({
963
+ depositorBtcPubKey: g,
1026
964
  btcPopSignature: c,
1027
965
  unsignedPrePeginTx: k,
1028
966
  depositorSignedPeginTx: v(
@@ -1030,16 +968,16 @@ class Vn {
1030
968
  ),
1031
969
  hashlock: d.hashlock,
1032
970
  htlcVout: d.htlcVout,
1033
- referralCode: Dt,
971
+ referralCode: Ut,
1034
972
  depositorPayoutBtcAddress: h[u],
1035
973
  depositorWotsPkHash: d.depositorWotsPkHash
1036
- })), E = tt({
1037
- abi: A,
974
+ })), T = j({
975
+ abi: I,
1038
976
  functionName: "submitPeginRequestBatch",
1039
977
  args: [
1040
978
  i,
1041
- e,
1042
- g,
979
+ t,
980
+ f,
1043
981
  S
1044
982
  ]
1045
983
  });
@@ -1047,8 +985,8 @@ class Vn {
1047
985
  try {
1048
986
  p = await m.estimateGas({
1049
987
  to: this.config.vaultContracts.btcVaultRegistry,
1050
- data: E,
1051
- value: P,
988
+ data: T,
989
+ value: b,
1052
990
  account: this.config.ethWallet.account.address
1053
991
  });
1054
992
  } catch (d) {
@@ -1058,8 +996,8 @@ class Vn {
1058
996
  try {
1059
997
  w = await this.config.ethWallet.sendTransaction({
1060
998
  to: this.config.vaultContracts.btcVaultRegistry,
1061
- data: E,
1062
- value: P,
999
+ data: T,
1000
+ value: b,
1063
1001
  account: this.config.ethWallet.account,
1064
1002
  chain: this.config.ethChain,
1065
1003
  gas: p
@@ -1067,11 +1005,11 @@ class Vn {
1067
1005
  } catch (d) {
1068
1006
  H(d);
1069
1007
  }
1070
- const y = await xt({
1008
+ const y = await pt({
1071
1009
  publicClient: m,
1072
1010
  walletAddress: this.config.ethWallet.account.address,
1073
1011
  hash: w,
1074
- timeout: It
1012
+ timeout: xt
1075
1013
  });
1076
1014
  return y.status === "reverted" && H(
1077
1015
  new Error(
@@ -1084,32 +1022,32 @@ class Vn {
1084
1022
  }
1085
1023
  // Anchor to quoted+headroom when supplied (refuse if chain drifted past it);
1086
1024
  // otherwise fall back to chain-current+headroom — see #1691.
1087
- async resolveMaxAcceptableCommissionBps(t, e) {
1088
- let s;
1025
+ async resolveMaxAcceptableCommissionBps(e, t) {
1026
+ let n;
1089
1027
  try {
1090
- s = await new we(
1028
+ n = await new he(
1091
1029
  this.config.publicClient,
1092
1030
  this.config.vaultContracts.btcVaultRegistry
1093
- ).getVaultProviderCommission(t);
1031
+ ).getVaultProviderCommission(e);
1094
1032
  } catch (o) {
1095
1033
  throw new Error(
1096
1034
  "Failed to query vault provider commission from the contract. Please check your network connection and that the contract address is correct.",
1097
1035
  { cause: o }
1098
1036
  );
1099
1037
  }
1100
- if (e !== void 0) {
1101
- if (s > e + L)
1038
+ if (t !== void 0) {
1039
+ if (n > t + W)
1102
1040
  throw new Error(
1103
- `Vault provider commission changed since quote: quoted ${e} bps, chain currently reports ${s} bps (allowed drift ${L} bps). Please refresh to see the new commission and try again.`
1041
+ `Vault provider commission changed since quote: quoted ${t} bps, chain currently reports ${n} bps (allowed drift ${W} bps). Please refresh to see the new commission and try again.`
1104
1042
  );
1105
1043
  return Math.min(
1106
- e + L,
1107
- rt
1044
+ t + W,
1045
+ J
1108
1046
  );
1109
1047
  }
1110
1048
  return Math.min(
1111
- s + L,
1112
- rt
1049
+ n + W,
1050
+ J
1113
1051
  );
1114
1052
  }
1115
1053
  /**
@@ -1125,13 +1063,13 @@ class Vn {
1125
1063
  * @returns True if vault exists, false otherwise
1126
1064
  * @throws If the underlying RPC read fails
1127
1065
  */
1128
- async checkVaultExists(t) {
1066
+ async checkVaultExists(e) {
1129
1067
  return (await this.config.publicClient.readContract({
1130
1068
  address: this.config.vaultContracts.btcVaultRegistry,
1131
- abi: A,
1069
+ abi: I,
1132
1070
  functionName: "getBtcVaultBasicInfo",
1133
- args: [t]
1134
- })).depositor !== Jt;
1071
+ args: [e]
1072
+ })).depositor !== Kt;
1135
1073
  }
1136
1074
  /**
1137
1075
  * Resolve the BTC scriptPubKey to register as the depositor's payout sink.
@@ -1149,23 +1087,23 @@ class Vn {
1149
1087
  * state-race or stale FE state that lets a non-wallet address reach the
1150
1088
  * on-chain payout-script registration.
1151
1089
  */
1152
- resolvePayoutScriptPubKey(t, e) {
1153
- if (!Pt(
1154
- e,
1090
+ resolvePayoutScriptPubKey(e, t) {
1091
+ if (!ht(
1155
1092
  t,
1093
+ e,
1156
1094
  this.config.btcNetwork
1157
1095
  ))
1158
- throw T(t).length === le && dn(e, this.config.btcNetwork) ? new Error(
1159
- `BTC payout address "${e}" is a P2WPKH (Native SegWit) address, but the connected wallet only exposes an x-only public key. P2WPKH validation requires a compressed key with known y-parity. Use a P2TR (Taproot) payout address instead.`
1096
+ throw E(e).length === te && je(t, this.config.btcNetwork) ? new Error(
1097
+ `BTC payout address "${t}" is a P2WPKH (Native SegWit) address, but the connected wallet only exposes an x-only public key. P2WPKH validation requires a compressed key with known y-parity. Use a P2TR (Taproot) payout address instead.`
1160
1098
  ) : new Error(
1161
- `BTC payout address "${e}" is not derived from the connected wallet's public key. The payout sink must be controlled by the same key that signs the pegin; refusing to register a mismatched address.`
1099
+ `BTC payout address "${t}" is not derived from the connected wallet's public key. The payout sink must be controlled by the same key that signs the pegin; refusing to register a mismatched address.`
1162
1100
  );
1163
- const s = wt(this.config.btcNetwork);
1101
+ const n = ft(this.config.btcNetwork);
1164
1102
  try {
1165
- return `0x${Ct.address.toOutputScript(e, s).toString("hex")}`;
1103
+ return `0x${Et.address.toOutputScript(t, n).toString("hex")}`;
1166
1104
  } catch {
1167
1105
  throw new Error(
1168
- `Invalid BTC payout address: "${e}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
1106
+ `Invalid BTC payout address: "${t}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
1169
1107
  );
1170
1108
  }
1171
1109
  }
@@ -1178,16 +1116,16 @@ class Vn {
1178
1116
  async signProofOfPossession() {
1179
1117
  if (!this.config.ethWallet.account)
1180
1118
  throw new Error("Ethereum wallet account not found");
1181
- const t = this.config.ethWallet.account.address, e = $(
1119
+ const e = this.config.ethWallet.account.address, t = $(
1182
1120
  await this.config.btcWallet.getPublicKeyHex()
1183
- ), s = this.config.vaultContracts.btcVaultRegistry, o = `${t.toLowerCase()}:${this.config.ethChain.id}:pegin:${s.toLowerCase()}`, r = await this.config.btcWallet.signMessage(
1121
+ ), n = this.config.vaultContracts.btcVaultRegistry, o = `${e.toLowerCase()}:${this.config.ethChain.id}:pegin:${n.toLowerCase()}`, r = await this.config.btcWallet.signMessage(
1184
1122
  o,
1185
1123
  "bip322-simple"
1186
1124
  );
1187
1125
  return {
1188
- btcPopSignature: hn(r),
1189
- depositorEthAddress: t,
1190
- depositorBtcPubkey: e
1126
+ btcPopSignature: Ye(r),
1127
+ depositorEthAddress: e,
1128
+ depositorBtcPubkey: t
1191
1129
  };
1192
1130
  }
1193
1131
  /**
@@ -1198,13 +1136,13 @@ class Vn {
1198
1136
  * a parity-bearing compressed key — an x-only form would let an attacker
1199
1137
  * substitute the opposite-parity P2WPKH address.
1200
1138
  */
1201
- async assertPopMatchesBtcWallet(t) {
1202
- const e = await this.config.btcWallet.getPublicKeyHex(), s = $(e), o = $(t.depositorBtcPubkey);
1203
- if (s !== o)
1139
+ async assertPopMatchesBtcWallet(e) {
1140
+ const t = await this.config.btcWallet.getPublicKeyHex(), n = $(t), o = $(e.depositorBtcPubkey);
1141
+ if (n !== o)
1204
1142
  throw new Error(
1205
- `Proof of possession was signed with BTC pubkey ${o} but the BTC wallet is currently connected to ${s}. Reconnect the original wallet or call signProofOfPossession() again.`
1143
+ `Proof of possession was signed with BTC pubkey ${o} but the BTC wallet is currently connected to ${n}. Reconnect the original wallet or call signProofOfPossession() again.`
1206
1144
  );
1207
- return e;
1145
+ return t;
1208
1146
  }
1209
1147
  /**
1210
1148
  * Gets the configured Bitcoin network.
@@ -1223,73 +1161,69 @@ class Vn {
1223
1161
  return this.config.vaultContracts.btcVaultRegistry;
1224
1162
  }
1225
1163
  }
1226
- const fn = 80, pn = 250, mn = 300, bn = 22, Gt = "ab";
1227
- function Pn(n, t) {
1228
- const e = Gt.repeat(mn), s = T(n).toLowerCase(), o = t.toString(16).padStart(8, "0"), r = `${s}${o}`, i = e.slice(r.length);
1164
+ const Ze = 80, Je = 250, ts = 300, es = 22, Vt = "ab";
1165
+ function ss(s, e) {
1166
+ const t = Vt.repeat(ts), n = E(s).toLowerCase(), o = e.toString(16).padStart(8, "0"), r = `${n}${o}`, i = t.slice(r.length);
1229
1167
  return `0x${r}${i}`;
1230
1168
  }
1231
- function wn(n, t) {
1232
- const e = (s) => `0x${Gt.repeat(s)}`;
1169
+ function ns(s, e) {
1170
+ const t = (n) => `0x${Vt.repeat(n)}`;
1233
1171
  return {
1234
- depositorBtcPubKey: e(32),
1235
- btcPopSignature: e(fn),
1236
- unsignedPrePeginTx: e(pn),
1237
- depositorSignedPeginTx: Pn(
1238
- n,
1239
- t
1172
+ depositorBtcPubKey: t(32),
1173
+ btcPopSignature: t(Ze),
1174
+ unsignedPrePeginTx: t(Je),
1175
+ depositorSignedPeginTx: ss(
1176
+ s,
1177
+ e
1240
1178
  ),
1241
- hashlock: e(32),
1242
- htlcVout: t,
1243
- referralCode: Dt,
1244
- depositorPayoutBtcAddress: e(bn),
1245
- depositorWotsPkHash: e(32)
1179
+ hashlock: t(32),
1180
+ htlcVout: e,
1181
+ referralCode: Ut,
1182
+ depositorPayoutBtcAddress: t(es),
1183
+ depositorWotsPkHash: t(32)
1246
1184
  };
1247
1185
  }
1248
- async function Mn(n) {
1186
+ async function Ts(s) {
1249
1187
  const {
1250
- publicClient: t,
1251
- btcVaultRegistry: e,
1252
- depositorEthAddress: s,
1188
+ publicClient: e,
1189
+ btcVaultRegistry: t,
1190
+ depositorEthAddress: n,
1253
1191
  vaultProvider: o,
1254
1192
  batchSize: r
1255
- } = n;
1193
+ } = s;
1256
1194
  if (r <= 0)
1257
1195
  throw new Error(
1258
1196
  `estimateSubmitPeginRequestBatchGas requires batchSize >= 1 (received ${r})`
1259
1197
  );
1260
- const a = await t.readContract({
1261
- address: e,
1262
- abi: A,
1198
+ const a = await e.readContract({
1199
+ address: t,
1200
+ abi: I,
1263
1201
  functionName: "getPegInFee",
1264
1202
  args: [o]
1265
1203
  }) * BigInt(r), c = Array.from(
1266
1204
  { length: r },
1267
- (l, m) => wn(s, m)
1268
- ), h = tt({
1269
- abi: A,
1205
+ (l, m) => ns(n, m)
1206
+ ), h = j({
1207
+ abi: I,
1270
1208
  functionName: "submitPeginRequestBatch",
1271
1209
  args: [
1272
- s,
1210
+ n,
1273
1211
  o,
1274
- rt,
1212
+ J,
1275
1213
  c
1276
1214
  ]
1277
1215
  });
1278
- return t.estimateGas({
1279
- to: e,
1216
+ return e.estimateGas({
1217
+ to: t,
1280
1218
  data: h,
1281
1219
  value: a,
1282
- account: s
1220
+ account: n
1283
1221
  });
1284
1222
  }
1285
1223
  export {
1286
- Vn as P,
1287
- Ce as V,
1288
- Ae as a,
1289
- Ie as b,
1290
- rn as c,
1291
- on as d,
1292
- Mn as e,
1293
- Oe as f
1224
+ ks as P,
1225
+ Ke as c,
1226
+ Xe as d,
1227
+ Ts as e
1294
1228
  };
1295
- //# sourceMappingURL=PeginManager-D22MLWfM.js.map
1229
+ //# sourceMappingURL=PeginManager-CW03-M3T.js.map