@babylonlabs-io/ts-sdk 0.41.1 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/ApplicationRegistry.abi-BAPhJch3.cjs +2 -0
  2. package/dist/ApplicationRegistry.abi-BAPhJch3.cjs.map +1 -0
  3. package/dist/{ProtocolParams.abi-C2brDWTI.js → ApplicationRegistry.abi-Dn2qk6JG.js} +90 -90
  4. package/dist/ApplicationRegistry.abi-Dn2qk6JG.js.map +1 -0
  5. package/dist/{PeginManager-Bsou6AQV.js → PeginManager-BezsAEDe.js} +125 -127
  6. package/dist/PeginManager-BezsAEDe.js.map +1 -0
  7. package/dist/{PeginManager-BOuzU8Zo.cjs → PeginManager-D-8vmqzq.cjs} +2 -2
  8. package/dist/PeginManager-D-8vmqzq.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +180 -179
  11. package/dist/mempoolApi-CknccHKg.cjs +2 -0
  12. package/dist/mempoolApi-CknccHKg.cjs.map +1 -0
  13. package/dist/mempoolApi-DI9HISqi.js +451 -0
  14. package/dist/mempoolApi-DI9HISqi.js.map +1 -0
  15. package/dist/primeVpAuth-Duds3vAO.cjs +2 -0
  16. package/dist/primeVpAuth-Duds3vAO.cjs.map +1 -0
  17. package/dist/primeVpAuth-qEC9TTO_.js +1136 -0
  18. package/dist/primeVpAuth-qEC9TTO_.js.map +1 -0
  19. package/dist/tbv/core/clients/eth/types.d.ts +7 -0
  20. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  21. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +8 -0
  22. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  23. package/dist/tbv/core/clients/index.cjs +1 -1
  24. package/dist/tbv/core/clients/index.js +31 -31
  25. package/dist/tbv/core/contracts/index.cjs +1 -1
  26. package/dist/tbv/core/contracts/index.js +1 -1
  27. package/dist/tbv/core/index.cjs +1 -1
  28. package/dist/tbv/core/index.js +182 -181
  29. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  30. package/dist/tbv/core/managers/index.cjs +1 -1
  31. package/dist/tbv/core/managers/index.js +1 -1
  32. package/dist/tbv/core/primitives/index.cjs +1 -1
  33. package/dist/tbv/core/primitives/index.d.ts +2 -1
  34. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  35. package/dist/tbv/core/primitives/index.js +23 -22
  36. package/dist/tbv/index.cjs +1 -1
  37. package/dist/tbv/index.js +182 -181
  38. package/dist/tbv/integrations/aave/clients/__tests__/oracle.test.d.ts +2 -0
  39. package/dist/tbv/integrations/aave/clients/__tests__/oracle.test.d.ts.map +1 -0
  40. package/dist/tbv/integrations/aave/clients/abis/AaveOracle.abi.json.d.ts +36 -0
  41. package/dist/tbv/integrations/aave/clients/index.d.ts +1 -0
  42. package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
  43. package/dist/tbv/integrations/aave/clients/oracle.d.ts +14 -0
  44. package/dist/tbv/integrations/aave/clients/oracle.d.ts.map +1 -0
  45. package/dist/tbv/integrations/aave/index.cjs +1 -1
  46. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  47. package/dist/tbv/integrations/aave/index.d.ts +1 -1
  48. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  49. package/dist/tbv/integrations/aave/index.js +249 -141
  50. package/dist/tbv/integrations/aave/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/PeginManager-BOuzU8Zo.cjs.map +0 -1
  53. package/dist/PeginManager-Bsou6AQV.js.map +0 -1
  54. package/dist/ProtocolParams.abi-C2brDWTI.js.map +0 -1
  55. package/dist/ProtocolParams.abi-DQhcqsNr.cjs +0 -2
  56. package/dist/ProtocolParams.abi-DQhcqsNr.cjs.map +0 -1
  57. package/dist/mempoolApi-C7hkVkym.js +0 -214
  58. package/dist/mempoolApi-C7hkVkym.js.map +0 -1
  59. package/dist/mempoolApi-DEAS9wVa.cjs +0 -2
  60. package/dist/mempoolApi-DEAS9wVa.cjs.map +0 -1
  61. package/dist/types-0bvDGR4x.js +0 -1347
  62. package/dist/types-0bvDGR4x.js.map +0 -1
  63. package/dist/types-Be3sAYzr.cjs +0 -2
  64. package/dist/types-Be3sAYzr.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  var qt = Object.defineProperty;
2
2
  var zt = (n, t, e) => t in n ? qt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
3
  var x = (n, t, e) => zt(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { s as it, c as It, H as Yt, r as M, 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";
4
+ import { s as it, c as It, 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
5
  import * as Ct from "bitcoinjs-lib";
6
6
  import { Transaction as Qt, Psbt as gt } from "bitcoinjs-lib";
7
7
  import { Buffer as J } from "buffer";
@@ -9,33 +9,33 @@ import { isAddressEqual as ft, encodeFunctionData as tt, zeroAddress as Jt } fro
9
9
  import { B as I } from "./BTCVaultRegistry.abi-Cq9-JlqT.js";
10
10
  import { h as H } from "./errors-CznAK5NB.js";
11
11
  import { expandWotsSeed as te, expandHashlockSecret as ee, expandAuthAnchor as ne, deriveVaultId as pt } from "@babylonlabs-io/babylon-tbv-rust-wasm";
12
- import { b as mt, a as se, d as bt } from "./assertPsbtUnsignedTxMatches-GHobJP-d.js";
12
+ import { b as mt, a as se, d as Pt } from "./assertPsbtUnsignedTxMatches-GHobJP-d.js";
13
13
  import { b as oe, e as re, f as ie } from "./peginInput-BPRB9tUi.js";
14
- import { u as X, h as et, e as v, p as ae, i as Pt, s as T, j as wt, X as ce } from "./bitcoin-B5aNKtsk.js";
14
+ import { u as X, h as et, e as v, p as ae, i as bt, s as T, j as wt, X as ce } from "./bitcoin-B5aNKtsk.js";
15
15
  import { c as le } from "./signing-DaLvGwQe.js";
16
16
  import { M as yt } from "./validation-CxqROCno.js";
17
17
  import { c as ue, a as he } from "./PayoutManager-CXDccwDN.js";
18
18
  import { s as de, f as q, i as ge, w as xt } from "./waitForTransactionReceiptSmartAware-Dt5VcMK0.js";
19
19
  import { p as fe, f as pe } from "./fundPeginTransaction-C11tYf6I.js";
20
- import { p as me, h as be } from "./mempoolApi-C7hkVkym.js";
21
- const N = /* @__PURE__ */ BigInt(2 ** 32 - 1), kt = /* @__PURE__ */ BigInt(32);
22
- function Pe(n, t = !1) {
23
- return t ? { h: Number(n & N), l: Number(n >> kt & N) } : { h: Number(n >> kt & N) | 0, l: Number(n & N) | 0 };
24
- }
20
+ import { p as me, V as Pe, h as be } from "./mempoolApi-DI9HISqi.js";
21
+ const M = /* @__PURE__ */ BigInt(2 ** 32 - 1), kt = /* @__PURE__ */ BigInt(32);
25
22
  function we(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 };
24
+ }
25
+ function ye(n, t = !1) {
26
26
  const e = n.length;
27
27
  let s = new Uint32Array(e), o = new Uint32Array(e);
28
28
  for (let r = 0; r < e; r++) {
29
- const { h: i, l: a } = Pe(n[r], t);
29
+ const { h: i, l: a } = we(n[r], t);
30
30
  [s[r], o[r]] = [i, a];
31
31
  }
32
32
  return [s, o];
33
33
  }
34
- const ye = (n, t, e) => n << e | t >>> 32 - e, xe = (n, t, e) => t << e | n >>> 32 - e, ke = (n, t, e) => t << e - 32 | n >>> 64 - e, Ee = (n, t, e) => n << e - 32 | t >>> 64 - e, U = 32, z = 32, nt = 36, Ht = 32, K = 4, Te = K + U + K + Ht;
34
+ const xe = (n, t, e) => n << e | t >>> 32 - e, ke = (n, t, e) => t << e | n >>> 32 - e, Ee = (n, t, e) => t << e - 32 | n >>> 64 - e, Te = (n, t, e) => n << e - 32 | t >>> 64 - e, U = 32, z = 32, nt = 36, Ht = 32, K = 4, _e = K + U + K + Ht;
35
35
  function st(n, t, e) {
36
36
  n[t] = e >>> 24 & 255, n[t + 1] = e >>> 16 & 255, n[t + 2] = e >>> 8 & 255, n[t + 3] = e & 255;
37
37
  }
38
- function _e(n) {
38
+ function Be(n) {
39
39
  if (n.txid.length !== z)
40
40
  throw new Error(
41
41
  `outpoint.txid must be exactly ${z} bytes, got ${n.txid.length}`
@@ -51,12 +51,12 @@ function Et(n, t) {
51
51
  if (n[s] !== t[s]) return n[s] - t[s];
52
52
  return n.length - t.length;
53
53
  }
54
- function Be(n) {
54
+ function ve(n) {
55
55
  if (n.length === 0)
56
56
  throw new Error(
57
57
  "buildFundingOutpointsCommitment: outpoints must be non-empty"
58
58
  );
59
- const t = n.map(_e);
59
+ const t = n.map(Be);
60
60
  t.sort(Et);
61
61
  for (let s = 1; s < t.length; s++)
62
62
  if (Et(t[s - 1], t[s]) === 0)
@@ -68,18 +68,18 @@ function Be(n) {
68
68
  e.set(t[s], s * nt);
69
69
  return it(e);
70
70
  }
71
- function ve(n) {
71
+ function Se(n) {
72
72
  if (n.depositorBtcPubkey.length !== U)
73
73
  throw new Error(
74
74
  `vaultContext: depositorBtcPubkey must be exactly ${U} bytes, got ${n.depositorBtcPubkey.length}`
75
75
  );
76
- const t = Be(n.fundingOutpoints), e = new Uint8Array(Te);
76
+ const t = ve(n.fundingOutpoints), e = new Uint8Array(_e);
77
77
  let s = 0;
78
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
79
  }
80
- const Se = "babylon-btc-vault", Ot = 32, Tt = Ot * 2, Ae = /^[0-9a-f]+$/;
81
- async function Ie(n, t) {
82
- const e = ve(t), s = X(e), o = await n.deriveContextHash(Se, s);
80
+ const Ae = "babylon-btc-vault", Ot = 32, Tt = Ot * 2, Ie = /^[0-9a-f]+$/;
81
+ async function Ce(n, t) {
82
+ const e = Se(t), s = X(e), o = await n.deriveContextHash(Ae, s);
83
83
  if (typeof o != "string")
84
84
  throw new Error(
85
85
  `deriveVaultRoot: wallet must return a string, got ${typeof o}`
@@ -88,13 +88,13 @@ async function Ie(n, t) {
88
88
  throw new Error(
89
89
  `deriveVaultRoot: wallet must return a ${Tt}-character hex string (${Ot} bytes), got length ${o.length}`
90
90
  );
91
- if (!Ae.test(o))
91
+ if (!Ie.test(o))
92
92
  throw new Error(
93
93
  "deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters"
94
94
  );
95
95
  return et(o);
96
96
  }
97
- const Ce = /* @__PURE__ */ Uint8Array.from([
97
+ const He = /* @__PURE__ */ Uint8Array.from([
98
98
  7,
99
99
  4,
100
100
  13,
@@ -111,25 +111,25 @@ const Ce = /* @__PURE__ */ Uint8Array.from([
111
111
  14,
112
112
  11,
113
113
  8
114
- ]), Rt = Uint8Array.from(new Array(16).fill(0).map((n, t) => t)), He = Rt.map((n) => (9 * n + 5) % 16), $t = /* @__PURE__ */ (() => {
115
- const e = [[Rt], [He]];
114
+ ]), Rt = Uint8Array.from(new Array(16).fill(0).map((n, t) => t)), Oe = Rt.map((n) => (9 * n + 5) % 16), $t = /* @__PURE__ */ (() => {
115
+ const e = [[Rt], [Oe]];
116
116
  for (let s = 0; s < 4; s++)
117
117
  for (let o of e)
118
- o.push(o[s].map((r) => Ce[r]));
118
+ o.push(o[s].map((r) => He[r]));
119
119
  return e;
120
- })(), Ut = $t[0], Mt = $t[1], Nt = /* @__PURE__ */ [
120
+ })(), Ut = $t[0], Vt = $t[1], Mt = /* @__PURE__ */ [
121
121
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
122
122
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
123
123
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
124
124
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
125
125
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
126
- ].map((n) => Uint8Array.from(n)), Oe = /* @__PURE__ */ Ut.map((n, t) => n.map((e) => Nt[t][e])), Re = /* @__PURE__ */ Mt.map((n, t) => n.map((e) => Nt[t][e])), $e = /* @__PURE__ */ Uint32Array.from([
126
+ ].map((n) => Uint8Array.from(n)), Re = /* @__PURE__ */ Ut.map((n, t) => n.map((e) => Mt[t][e])), $e = /* @__PURE__ */ Vt.map((n, t) => n.map((e) => Mt[t][e])), Ue = /* @__PURE__ */ Uint32Array.from([
127
127
  0,
128
128
  1518500249,
129
129
  1859775393,
130
130
  2400959708,
131
131
  2840853838
132
- ]), Ue = /* @__PURE__ */ Uint32Array.from([
132
+ ]), Ve = /* @__PURE__ */ Uint32Array.from([
133
133
  1352829926,
134
134
  1548603684,
135
135
  1836072691,
@@ -139,7 +139,7 @@ const Ce = /* @__PURE__ */ Uint8Array.from([
139
139
  function _t(n, t, e, s) {
140
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);
141
141
  }
142
- const V = /* @__PURE__ */ new Uint32Array(16);
142
+ const N = /* @__PURE__ */ new Uint32Array(16);
143
143
  class Me extends Yt {
144
144
  constructor() {
145
145
  super(64, 20, 8, !0);
@@ -158,50 +158,50 @@ class Me extends Yt {
158
158
  }
159
159
  process(e, s) {
160
160
  for (let g = 0; g < 16; g++, s += 4)
161
- V[g] = e.getUint32(s, !0);
162
- let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, c = this.h2 | 0, u = c, l = this.h3 | 0, m = l, b = this.h4 | 0, P = b;
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, u = c, l = this.h3 | 0, m = l, P = this.h4 | 0, b = P;
163
163
  for (let g = 0; g < 5; g++) {
164
- const f = 4 - g, k = $e[g], S = Ue[g], E = Ut[g], p = Mt[g], w = Oe[g], y = Re[g];
164
+ const f = 4 - g, k = Ue[g], S = Ve[g], E = Ut[g], p = Vt[g], w = Re[g], y = $e[g];
165
165
  for (let h = 0; h < 16; h++) {
166
- const d = M(o + _t(g, i, c, l) + V[E[h]] + k, w[h]) + b | 0;
167
- o = b, b = l, l = M(c, 10) | 0, c = i, i = d;
166
+ const d = V(o + _t(g, i, c, l) + N[E[h]] + k, w[h]) + P | 0;
167
+ o = P, P = l, l = V(c, 10) | 0, c = i, i = d;
168
168
  }
169
169
  for (let h = 0; h < 16; h++) {
170
- const d = M(r + _t(f, a, u, m) + V[p[h]] + S, y[h]) + P | 0;
171
- r = P, P = m, m = M(u, 10) | 0, u = a, a = d;
170
+ const d = V(r + _t(f, a, u, m) + N[p[h]] + S, y[h]) + b | 0;
171
+ r = b, b = m, m = V(u, 10) | 0, u = a, a = d;
172
172
  }
173
173
  }
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 + u | 0);
174
+ 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 + u | 0);
175
175
  }
176
176
  roundClean() {
177
- W(V);
177
+ W(N);
178
178
  }
179
179
  destroy() {
180
180
  this.destroyed = !0, W(this.buffer), this.set(0, 0, 0, 0, 0);
181
181
  }
182
182
  }
183
- const Ne = /* @__PURE__ */ It(() => new Me()), Ve = BigInt(0), R = BigInt(1), Fe = BigInt(2), Le = BigInt(7), We = BigInt(256), Xe = BigInt(113), Vt = [], Ft = [], Lt = [];
183
+ const Ne = /* @__PURE__ */ It(() => new Me()), Fe = BigInt(0), R = BigInt(1), Le = BigInt(2), We = BigInt(7), Xe = BigInt(256), Ke = BigInt(113), Nt = [], Ft = [], Lt = [];
184
184
  for (let n = 0, t = R, e = 1, s = 0; n < 24; n++) {
185
- [e, s] = [s, (2 * e + 3 * s) % 5], Vt.push(2 * (5 * s + e)), Ft.push((n + 1) * (n + 2) / 2 % 64);
186
- let o = Ve;
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 = Fe;
187
187
  for (let r = 0; r < 7; r++)
188
- t = (t << R ^ (t >> Le) * Xe) % We, t & Fe && (o ^= R << (R << BigInt(r)) - R);
188
+ t = (t << R ^ (t >> We) * Ke) % Xe, t & Le && (o ^= R << (R << BigInt(r)) - R);
189
189
  Lt.push(o);
190
190
  }
191
- const Wt = we(Lt, !0), Ke = Wt[0], De = Wt[1], Bt = (n, t, e) => e > 32 ? ke(n, t, e) : ye(n, t, e), vt = (n, t, e) => e > 32 ? Ee(n, t, e) : xe(n, t, e);
192
- function Ge(n, t = 24) {
191
+ const Wt = ye(Lt, !0), De = Wt[0], Ge = Wt[1], Bt = (n, t, e) => e > 32 ? Ee(n, t, e) : xe(n, t, e), vt = (n, t, e) => e > 32 ? Te(n, t, e) : ke(n, t, e);
192
+ function qe(n, t = 24) {
193
193
  const e = new Uint32Array(10);
194
194
  for (let s = 24 - t; s < 24; s++) {
195
195
  for (let i = 0; i < 10; i++)
196
196
  e[i] = n[i] ^ n[i + 10] ^ n[i + 20] ^ n[i + 30] ^ n[i + 40];
197
197
  for (let i = 0; i < 10; i += 2) {
198
- const a = (i + 8) % 10, c = (i + 2) % 10, u = e[c], l = e[c + 1], m = Bt(u, l, 1) ^ e[a], b = vt(u, l, 1) ^ e[a + 1];
199
- for (let P = 0; P < 50; P += 10)
200
- n[i + P] ^= m, n[i + P + 1] ^= b;
198
+ const a = (i + 8) % 10, c = (i + 2) % 10, u = e[c], l = e[c + 1], m = Bt(u, l, 1) ^ e[a], P = vt(u, l, 1) ^ e[a + 1];
199
+ for (let b = 0; b < 50; b += 10)
200
+ n[i + b] ^= m, n[i + b + 1] ^= P;
201
201
  }
202
202
  let o = n[2], r = n[3];
203
203
  for (let i = 0; i < 24; i++) {
204
- const a = Ft[i], c = Bt(o, r, a), u = vt(o, r, a), l = Vt[i];
204
+ const a = Ft[i], c = Bt(o, r, a), u = vt(o, r, a), l = Nt[i];
205
205
  o = n[l], r = n[l + 1], n[l] = c, n[l + 1] = u;
206
206
  }
207
207
  for (let i = 0; i < 50; i += 10) {
@@ -210,7 +210,7 @@ function Ge(n, t = 24) {
210
210
  for (let a = 0; a < 10; a++)
211
211
  n[i + a] ^= ~e[(a + 2) % 10] & e[(a + 4) % 10];
212
212
  }
213
- n[0] ^= Ke[s], n[1] ^= De[s];
213
+ n[0] ^= De[s], n[1] ^= Ge[s];
214
214
  }
215
215
  W(e);
216
216
  }
@@ -236,7 +236,7 @@ class at {
236
236
  return this._cloneInto();
237
237
  }
238
238
  keccak() {
239
- ut(this.state32), Ge(this.state32, this.rounds), ut(this.state32), this.posOut = 0, this.pos = 0;
239
+ ut(this.state32), qe(this.state32, this.rounds), ut(this.state32), this.posOut = 0, this.pos = 0;
240
240
  }
241
241
  update(t) {
242
242
  ht(this), dt(t);
@@ -290,21 +290,21 @@ class at {
290
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;
291
291
  }
292
292
  }
293
- const qe = (n, t, e, s = {}) => It(() => new at(t, n, e), s), ze = /* @__PURE__ */ qe(1, 136, 32), St = 64, _ = 20, ot = 4, Xt = 2, Ye = 0, je = 1, F = [64, 64], Ze = (n) => Array.from(n).map((t) => t.toString(16).padStart(2, "0")).join("");
293
+ const ze = (n, t, e, s = {}) => It(() => new at(t, n, e), s), Ye = /* @__PURE__ */ ze(1, 136, 32), St = 64, _ = 20, ot = 4, Xt = 2, je = 0, Ze = 1, F = [64, 64], Qe = (n) => Array.from(n).map((t) => t.toString(16).padStart(2, "0")).join("");
294
294
  function ct(n) {
295
295
  return Ne(it(n));
296
296
  }
297
297
  function Kt(n) {
298
298
  return (1 << n) - 1;
299
299
  }
300
- function Qe(n) {
300
+ function Je(n) {
301
301
  let t = 1;
302
302
  for (; t * t < n + 1; ) t++;
303
303
  return Math.max(t, 2);
304
304
  }
305
- function Je(n) {
305
+ function tn(n) {
306
306
  const t = ot, e = n * Kt(t);
307
- return { d: t, n, checksum_radix: Qe(e) };
307
+ return { d: t, n, checksum_radix: Je(e) };
308
308
  }
309
309
  function Y(n, t) {
310
310
  const e = [];
@@ -323,21 +323,21 @@ function j(n, t) {
323
323
  e = ct(e);
324
324
  return e;
325
325
  }
326
- function tn(n, t) {
326
+ function en(n, t) {
327
327
  const e = Kt(t.d), s = t.checksum_radix - 1, o = Math.floor(t.n * e / t.checksum_radix), r = [];
328
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));
329
+ const m = Y(n, l + Xt), P = j(m, e);
330
+ r.push(Array.from(P));
331
331
  }
332
332
  const i = Y(
333
333
  n,
334
- Ye
334
+ je
335
335
  ), a = j(
336
336
  i,
337
337
  s
338
338
  ), c = Y(
339
339
  n,
340
- je
340
+ Ze
341
341
  ), u = j(
342
342
  c,
343
343
  o
@@ -349,7 +349,7 @@ function tn(n, t) {
349
349
  checksum_minor_terminal: Array.from(a)
350
350
  };
351
351
  }
352
- async function en(n) {
352
+ async function nn(n) {
353
353
  try {
354
354
  if (n.length !== St)
355
355
  throw new Error(
@@ -357,11 +357,11 @@ async function en(n) {
357
357
  );
358
358
  const t = [];
359
359
  for (let e = 0; e < F.length; e++) {
360
- const s = F[e], o = Je(s), r = new Uint8Array(n.length + 1);
360
+ const s = F[e], o = tn(s), r = new Uint8Array(n.length + 1);
361
361
  r.set(n), r[n.length] = e;
362
362
  const i = ct(r);
363
363
  try {
364
- const a = tn(i, o);
364
+ const a = en(i, o);
365
365
  if (a.config.d !== ot)
366
366
  throw new Error(
367
367
  `Block ${e}: expected d=${ot}, got d=${a.config.d}`
@@ -414,7 +414,7 @@ function Z(n, t, e) {
414
414
  );
415
415
  }
416
416
  }
417
- function nn(n) {
417
+ function sn(n) {
418
418
  if (n.length === 0)
419
419
  throw new Error("Public keys array must not be empty");
420
420
  for (let r = 0; r < n.length; r++) {
@@ -433,17 +433,17 @@ function nn(n) {
433
433
  for (const i of r.message_terminals)
434
434
  e.set(i, s), s += _;
435
435
  }
436
- const o = ze(e);
437
- return `0x${Ze(o)}`;
436
+ const o = Ye(e);
437
+ return `0x${Qe(o)}`;
438
438
  }
439
- async function sn(n, t) {
439
+ async function on(n, t) {
440
440
  const e = [], s = [], o = [], r = [];
441
441
  try {
442
442
  for (let i = 0; i < t; i++) {
443
443
  const a = await te(n, i);
444
444
  try {
445
- const u = await en(a);
446
- e.push(u), s.push(nn(u));
445
+ const u = await nn(a);
446
+ e.push(u), s.push(sn(u));
447
447
  } finally {
448
448
  a.fill(0);
449
449
  }
@@ -460,33 +460,33 @@ async function sn(n, t) {
460
460
  }
461
461
  return { perVaultWotsKeys: e, wotsPkHashes: s, htlcSecretHexes: o, hashlocks: r };
462
462
  }
463
- const on = /^0x[0-9a-f]+$/i, rn = /^[0-9a-f]+$/i, an = /^[A-Za-z0-9+/]+={0,2}$/;
463
+ const rn = /^0x[0-9a-f]+$/i, an = /^[0-9a-f]+$/i, cn = /^[A-Za-z0-9+/]+={0,2}$/;
464
464
  function $(n) {
465
465
  if (typeof n != "string" || n.length === 0)
466
466
  throw new Error("BTC wallet returned empty public key");
467
467
  return ae(n).toLowerCase();
468
468
  }
469
- function cn(n) {
469
+ function ln(n) {
470
470
  if (typeof n != "string" || n.length === 0)
471
471
  throw new Error("BTC wallet returned empty BIP-322 signature");
472
472
  if (n.startsWith("0x") || n.startsWith("0X")) {
473
- if (!on.test(n) || n.length < 4 || n.length % 2 !== 0)
473
+ if (!rn.test(n) || n.length < 4 || n.length % 2 !== 0)
474
474
  throw new Error("BTC wallet returned malformed hex BIP-322 signature");
475
475
  return n.toLowerCase();
476
476
  }
477
- if (rn.test(n)) {
477
+ if (an.test(n)) {
478
478
  if (n.length % 2 !== 0)
479
479
  throw new Error("BTC wallet returned malformed hex BIP-322 signature");
480
480
  return `0x${n.toLowerCase()}`;
481
481
  }
482
- if (!an.test(n) || n.length % 4 !== 0)
482
+ if (!cn.test(n) || n.length % 4 !== 0)
483
483
  throw new Error("BTC wallet returned malformed base64 BIP-322 signature");
484
484
  const t = J.from(n, "base64");
485
485
  if (t.length === 0 || t.toString("base64") !== n)
486
486
  throw new Error("BTC wallet returned malformed base64 BIP-322 signature");
487
487
  return `0x${t.toString("hex")}`;
488
488
  }
489
- async function ln(n, t, e) {
489
+ async function un(n, t, e) {
490
490
  if (typeof n.signPsbts == "function") {
491
491
  const o = await n.signPsbts(t, e);
492
492
  if (o.length !== t.length)
@@ -503,7 +503,7 @@ async function ln(n, t, e) {
503
503
  return s;
504
504
  }
505
505
  const Dt = 0, L = 25, rt = 9999, Q = "00".repeat(32);
506
- function un(n, t) {
506
+ function hn(n, t) {
507
507
  const e = {
508
508
  bitcoin: "bc",
509
509
  testnet: "tb",
@@ -517,7 +517,7 @@ function un(n, t) {
517
517
  return !1;
518
518
  }
519
519
  }
520
- function hn(n, t, e, s) {
520
+ function dn(n, t, e, s) {
521
521
  const o = e == null ? void 0 : e[`${n}:${t}`];
522
522
  return o ? Promise.resolve({
523
523
  txid: n,
@@ -527,7 +527,7 @@ function hn(n, t, e, s) {
527
527
  }) : be(n, t, s);
528
528
  }
529
529
  const At = 12e4;
530
- class $n {
530
+ class Un {
531
531
  /**
532
532
  * Creates a new PeginManager instance.
533
533
  *
@@ -550,7 +550,7 @@ class $n {
550
550
  if (t.amounts.length === 0)
551
551
  throw new Error("amounts must contain at least one entry");
552
552
  const e = await this.config.btcWallet.getPublicKeyHex(), s = $(e);
553
- if (!Pt(
553
+ if (!bt(
554
554
  t.changeAddress,
555
555
  e,
556
556
  this.config.btcNetwork
@@ -563,7 +563,7 @@ class $n {
563
563
  txid: et(f.txid),
564
564
  vout: f.vout
565
565
  })
566
- ), i = await Ie(this.config.btcWallet, {
566
+ ), i = await Ce(this.config.btcWallet, {
567
567
  depositorBtcPubkey: et(s),
568
568
  fundingOutpoints: r
569
569
  });
@@ -578,10 +578,10 @@ class $n {
578
578
  } catch (f) {
579
579
  throw i.fill(0), f;
580
580
  }
581
- const u = await sn(i, t.amounts.length), { perVaultWotsKeys: l, wotsPkHashes: m, htlcSecretHexes: b, hashlocks: P } = u, g = await this.preparePeginCommit({
581
+ const u = await on(i, t.amounts.length), { perVaultWotsKeys: l, wotsPkHashes: m, htlcSecretHexes: P, hashlocks: b } = u, g = await this.preparePeginCommit({
582
582
  depositorBtcPubkeyRaw: e,
583
583
  depositorBtcPubkey: s,
584
- hashlocks: P,
584
+ hashlocks: b,
585
585
  authAnchorHash: c,
586
586
  sizing: o,
587
587
  params: t
@@ -606,7 +606,7 @@ class $n {
606
606
  derivedSecrets: {
607
607
  perVaultWotsKeys: l,
608
608
  wotsPkHashes: m,
609
- htlcSecretHexes: b,
609
+ htlcSecretHexes: P,
610
610
  authAnchorHex: a
611
611
  }
612
612
  };
@@ -676,7 +676,7 @@ class $n {
676
676
  throw new Error(
677
677
  "preparePeginCommit refusing to build with sizing-pass placeholder auth-anchor hash — internal substitution bug"
678
678
  );
679
- const u = T(a.vaultProviderBtcPubkey), l = a.vaultKeeperBtcPubkeys.map(T), m = a.universalChallengerBtcPubkeys.map(T), b = l.length, P = {
679
+ const u = T(a.vaultProviderBtcPubkey), l = a.vaultKeeperBtcPubkeys.map(T), m = a.universalChallengerBtcPubkeys.map(T), P = l.length, b = {
680
680
  depositorPubkey: s,
681
681
  vaultProviderPubkey: u,
682
682
  vaultKeeperPubkeys: l,
@@ -686,12 +686,12 @@ class $n {
686
686
  pegInAmounts: a.amounts,
687
687
  feeRate: a.protocolFeeRate,
688
688
  minPeginFeeRate: a.minPeginFeeRate,
689
- numLocalChallengers: b,
689
+ numLocalChallengers: P,
690
690
  councilQuorum: a.councilQuorum,
691
691
  councilSize: a.councilSize,
692
692
  network: this.config.btcNetwork,
693
693
  authAnchorHash: r
694
- }, g = await mt(P), f = wt(this.config.btcNetwork), k = pe({
694
+ }, g = await mt(b), f = wt(this.config.btcNetwork), k = pe({
695
695
  unfundedTxHex: g.psbtHex,
696
696
  selectedUTXOs: i.selectedUTXOs,
697
697
  changeAddress: a.changeAddress,
@@ -700,7 +700,7 @@ class $n {
700
700
  }), S = T(q(k)), E = [], p = [], w = [];
701
701
  for (let d = 0; d < o.length; d++) {
702
702
  const B = await se({
703
- prePeginParams: P,
703
+ prePeginParams: b,
704
704
  timelockPegin: a.timelockPegin,
705
705
  fundedPrePeginTxHex: k,
706
706
  htlcVout: d
@@ -719,13 +719,13 @@ class $n {
719
719
  le(e, 1)
720
720
  );
721
721
  }
722
- const y = await ln(
722
+ const y = await un(
723
723
  this.config.btcWallet,
724
724
  p,
725
725
  w
726
726
  ), h = [];
727
727
  for (let d = 0; d < y.length; d++) {
728
- bt({
728
+ Pt({
729
729
  requestedPsbtHex: p[d],
730
730
  returnedPsbtHex: y[d]
731
731
  });
@@ -774,24 +774,24 @@ class $n {
774
774
  "hex"
775
775
  ), c = this.config.mempoolApiUrl, u = r.ins.map((p) => {
776
776
  const w = J.from(p.hash).reverse().toString("hex"), y = p.index;
777
- return hn(w, y, t.localPrevouts, c).then(
777
+ return dn(w, y, t.localPrevouts, c).then(
778
778
  (h) => ({ input: p, utxoData: h, txid: w, vout: y })
779
779
  );
780
780
  }), l = await Promise.all(u), m = l.reduce(
781
781
  (p, w) => p + BigInt(w.utxoData.value),
782
782
  0n
783
- ), b = r.outs.reduce(
783
+ ), P = r.outs.reduce(
784
784
  (p, w) => p + BigInt(w.value),
785
785
  0n
786
786
  );
787
- if (m < b)
787
+ if (m < P)
788
788
  throw new Error(
789
- `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.`
789
+ `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.`
790
790
  );
791
- const P = m - b;
792
- if (P > yt)
791
+ const b = m - P;
792
+ if (b > yt)
793
793
  throw new Error(
794
- `Implied transaction fee (${P} sat) exceeds maximum reasonable fee (${yt} sat). This may indicate manipulated UTXO data.`
794
+ `Implied transaction fee (${b} sat) exceeds maximum reasonable fee (${yt} sat). This may indicate manipulated UTXO data.`
795
795
  );
796
796
  for (const { input: p, utxoData: w, txid: y, vout: h } of l) {
797
797
  const d = ge(
@@ -814,7 +814,7 @@ class $n {
814
814
  value: p.value
815
815
  });
816
816
  const g = i.toHex(), f = await this.config.btcWallet.signPsbt(g);
817
- bt({
817
+ Pt({
818
818
  requestedPsbtHex: g,
819
819
  returnedPsbtHex: f
820
820
  });
@@ -874,7 +874,7 @@ class $n {
874
874
  throw new Error(
875
875
  `Proof of possession was signed for ${u.depositorEthAddress} but the Ethereum wallet is currently connected to ${l}. Reconnect the original account or call signProofOfPossession() again.`
876
876
  );
877
- const m = await this.assertPopMatchesBtcWallet(u), b = u.btcPopSignature, P = v(u.depositorBtcPubkey), g = v(e), f = v(s), k = a ?? await this.config.btcWallet.getAddress(), S = this.resolvePayoutScriptPubKey(
877
+ const m = await this.assertPopMatchesBtcWallet(u), P = u.btcPopSignature, b = v(u.depositorBtcPubkey), g = v(e), f = v(s), k = a ?? await this.config.btcWallet.getAddress(), S = this.resolvePayoutScriptPubKey(
878
878
  m,
879
879
  k
880
880
  ), E = q(f), p = await pt(
@@ -908,8 +908,8 @@ class $n {
908
908
  functionName: "submitPeginRequest",
909
909
  args: [
910
910
  l,
911
- P,
912
911
  b,
912
+ P,
913
913
  g,
914
914
  f,
915
915
  o,
@@ -1001,9 +1001,9 @@ class $n {
1001
1001
  l.push({ vaultId: C, peginTxHash: B });
1002
1002
  }
1003
1003
  const m = this.config.publicClient;
1004
- let b;
1004
+ let P;
1005
1005
  try {
1006
- b = await m.readContract({
1006
+ P = await m.readContract({
1007
1007
  address: this.config.vaultContracts.btcVaultRegistry,
1008
1008
  abi: I,
1009
1009
  functionName: "getPegInFee",
@@ -1015,7 +1015,7 @@ class $n {
1015
1015
  { cause: h }
1016
1016
  );
1017
1017
  }
1018
- const P = b * BigInt(o.length), g = await this.resolveMaxAcceptableCommissionBps(
1018
+ const b = P * BigInt(o.length), g = await this.resolveMaxAcceptableCommissionBps(
1019
1019
  e,
1020
1020
  t.quotedCommissionBps
1021
1021
  ), f = v(
@@ -1047,7 +1047,7 @@ class $n {
1047
1047
  p = await m.estimateGas({
1048
1048
  to: this.config.vaultContracts.btcVaultRegistry,
1049
1049
  data: E,
1050
- value: P,
1050
+ value: b,
1051
1051
  account: this.config.ethWallet.account.address
1052
1052
  });
1053
1053
  } catch (h) {
@@ -1058,7 +1058,7 @@ class $n {
1058
1058
  w = await this.config.ethWallet.sendTransaction({
1059
1059
  to: this.config.vaultContracts.btcVaultRegistry,
1060
1060
  data: E,
1061
- value: P,
1061
+ value: b,
1062
1062
  account: this.config.ethWallet.account,
1063
1063
  chain: this.config.ethChain,
1064
1064
  gas: p
@@ -1086,12 +1086,10 @@ class $n {
1086
1086
  async resolveMaxAcceptableCommissionBps(t, e) {
1087
1087
  let s;
1088
1088
  try {
1089
- s = await this.config.publicClient.readContract({
1090
- address: this.config.vaultContracts.btcVaultRegistry,
1091
- abi: I,
1092
- functionName: "getVaultProviderCommission",
1093
- args: [t]
1094
- });
1089
+ s = await new Pe(
1090
+ this.config.publicClient,
1091
+ this.config.vaultContracts.btcVaultRegistry
1092
+ ).getVaultProviderCommission(t);
1095
1093
  } catch (o) {
1096
1094
  throw new Error(
1097
1095
  "Failed to query vault provider commission from the contract. Please check your network connection and that the contract address is correct.",
@@ -1151,12 +1149,12 @@ class $n {
1151
1149
  * on-chain payout-script registration.
1152
1150
  */
1153
1151
  resolvePayoutScriptPubKey(t, e) {
1154
- if (!Pt(
1152
+ if (!bt(
1155
1153
  e,
1156
1154
  t,
1157
1155
  this.config.btcNetwork
1158
1156
  ))
1159
- throw T(t).length === ce && un(e, this.config.btcNetwork) ? new Error(
1157
+ throw T(t).length === ce && hn(e, this.config.btcNetwork) ? new Error(
1160
1158
  `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.`
1161
1159
  ) : new Error(
1162
1160
  `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,7 +1184,7 @@ class $n {
1186
1184
  "bip322-simple"
1187
1185
  );
1188
1186
  return {
1189
- btcPopSignature: cn(r),
1187
+ btcPopSignature: ln(r),
1190
1188
  depositorEthAddress: t,
1191
1189
  depositorBtcPubkey: e
1192
1190
  };
@@ -1224,29 +1222,29 @@ class $n {
1224
1222
  return this.config.vaultContracts.btcVaultRegistry;
1225
1223
  }
1226
1224
  }
1227
- const dn = 80, gn = 250, fn = 300, pn = 22, Gt = "ab";
1228
- function mn(n, t) {
1229
- const e = Gt.repeat(fn), s = T(n).toLowerCase(), o = t.toString(16).padStart(8, "0"), r = `${s}${o}`, i = e.slice(r.length);
1225
+ const gn = 80, fn = 250, pn = 300, mn = 22, Gt = "ab";
1226
+ function Pn(n, t) {
1227
+ const e = Gt.repeat(pn), s = T(n).toLowerCase(), o = t.toString(16).padStart(8, "0"), r = `${s}${o}`, i = e.slice(r.length);
1230
1228
  return `0x${r}${i}`;
1231
1229
  }
1232
1230
  function bn(n, t) {
1233
1231
  const e = (s) => `0x${Gt.repeat(s)}`;
1234
1232
  return {
1235
1233
  depositorBtcPubKey: e(32),
1236
- btcPopSignature: e(dn),
1237
- unsignedPrePeginTx: e(gn),
1238
- depositorSignedPeginTx: mn(
1234
+ btcPopSignature: e(gn),
1235
+ unsignedPrePeginTx: e(fn),
1236
+ depositorSignedPeginTx: Pn(
1239
1237
  n,
1240
1238
  t
1241
1239
  ),
1242
1240
  hashlock: e(32),
1243
1241
  htlcVout: t,
1244
1242
  referralCode: Dt,
1245
- depositorPayoutBtcAddress: e(pn),
1243
+ depositorPayoutBtcAddress: e(mn),
1246
1244
  depositorWotsPkHash: e(32)
1247
1245
  };
1248
1246
  }
1249
- async function Un(n) {
1247
+ async function Vn(n) {
1250
1248
  const { publicClient: t, btcVaultRegistry: e, depositorEthAddress: s, vaultProvider: o, batchSize: r } = n;
1251
1249
  if (r <= 0)
1252
1250
  throw new Error(
@@ -1278,13 +1276,13 @@ async function Un(n) {
1278
1276
  });
1279
1277
  }
1280
1278
  export {
1281
- $n as P,
1282
- Se as V,
1283
- ve as a,
1284
- Be as b,
1285
- nn as c,
1286
- en as d,
1287
- Un as e,
1288
- Ie as f
1279
+ Un as P,
1280
+ Ae as V,
1281
+ Se as a,
1282
+ ve as b,
1283
+ sn as c,
1284
+ nn as d,
1285
+ Vn as e,
1286
+ Ce as f
1289
1287
  };
1290
- //# sourceMappingURL=PeginManager-Bsou6AQV.js.map
1288
+ //# sourceMappingURL=PeginManager-BezsAEDe.js.map