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