@babylonlabs-io/ts-sdk 0.53.0 → 0.55.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 (98) hide show
  1. package/dist/{PayoutManager-Ddo9_Ozc.js → PayoutManager-BJmPnyRP.js} +120 -103
  2. package/dist/PayoutManager-BJmPnyRP.js.map +1 -0
  3. package/dist/PayoutManager-aqtsj60t.cjs +2 -0
  4. package/dist/PayoutManager-aqtsj60t.cjs.map +1 -0
  5. package/dist/{PeginManager-CTU0wgkJ.js → PeginManager-D22MLWfM.js} +113 -128
  6. package/dist/PeginManager-D22MLWfM.js.map +1 -0
  7. package/dist/PeginManager-vUUfZCzj.cjs +2 -0
  8. package/dist/PeginManager-vUUfZCzj.cjs.map +1 -0
  9. package/dist/{buildAndBroadcastRefund-DjS9nf87.js → buildAndBroadcastRefund-BiSO4zg2.js} +222 -235
  10. package/dist/buildAndBroadcastRefund-BiSO4zg2.js.map +1 -0
  11. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs +2 -0
  12. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs.map +1 -0
  13. package/dist/{fundPeginTransaction-96FxwYYJ.js → fundPeginTransaction-B2wyjqp0.js} +21 -22
  14. package/dist/fundPeginTransaction-B2wyjqp0.js.map +1 -0
  15. package/dist/fundPeginTransaction-BLD8FRL9.cjs +2 -0
  16. package/dist/fundPeginTransaction-BLD8FRL9.cjs.map +1 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +176 -175
  19. package/dist/{noPayout-8dDKwi6n.cjs → noPayout-CNMqNNpc.cjs} +2 -2
  20. package/dist/{noPayout-8dDKwi6n.cjs.map → noPayout-CNMqNNpc.cjs.map} +1 -1
  21. package/dist/{noPayout-tZFoNun3.js → noPayout-CfBg3HzC.js} +2 -2
  22. package/dist/{noPayout-tZFoNun3.js.map → noPayout-CfBg3HzC.js.map} +1 -1
  23. package/dist/tbv/core/index.cjs +1 -1
  24. package/dist/tbv/core/index.js +176 -175
  25. package/dist/tbv/core/managers/PeginManager.d.ts +3 -2
  26. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  27. package/dist/tbv/core/managers/index.cjs +1 -1
  28. package/dist/tbv/core/managers/index.js +2 -2
  29. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts +10 -6
  30. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts.map +1 -1
  31. package/dist/tbv/core/primitives/index.cjs +1 -1
  32. package/dist/tbv/core/primitives/index.d.ts +2 -2
  33. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  34. package/dist/tbv/core/primitives/index.js +38 -36
  35. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +11 -0
  36. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -0
  37. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +11 -10
  38. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  39. package/dist/tbv/core/primitives/psbt/pegin.d.ts +10 -2
  40. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  41. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  42. package/dist/tbv/core/services/index.cjs +1 -1
  43. package/dist/tbv/core/services/index.js +2 -2
  44. package/dist/tbv/core/utils/fee/constants.d.ts +6 -14
  45. package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -1
  46. package/dist/tbv/core/utils/index.cjs +1 -1
  47. package/dist/tbv/core/utils/index.js +35 -36
  48. package/dist/tbv/index.cjs +1 -1
  49. package/dist/tbv/index.js +176 -175
  50. package/dist/tbv/integrations/aave/clients/abis/AaveAdapterPositionProxy.abi.json.d.ts +16 -0
  51. package/dist/tbv/integrations/aave/clients/abis/AaveIntegrationAdapter.abi.json.d.ts +2 -2
  52. package/dist/tbv/integrations/aave/clients/index.d.ts +1 -0
  53. package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
  54. package/dist/tbv/integrations/aave/clients/positionProxy.d.ts +8 -0
  55. package/dist/tbv/integrations/aave/clients/positionProxy.d.ts.map +1 -0
  56. package/dist/tbv/integrations/aave/clients/spoke.d.ts +11 -10
  57. package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
  58. package/dist/tbv/integrations/aave/clients/transaction.d.ts +6 -1
  59. package/dist/tbv/integrations/aave/clients/transaction.d.ts.map +1 -1
  60. package/dist/tbv/integrations/aave/constants.d.ts +6 -14
  61. package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
  62. package/dist/tbv/integrations/aave/index.cjs +1 -1
  63. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  64. package/dist/tbv/integrations/aave/index.d.ts +2 -2
  65. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  66. package/dist/tbv/integrations/aave/index.js +119 -85
  67. package/dist/tbv/integrations/aave/index.js.map +1 -1
  68. package/dist/testing/MockBitcoinWallet.d.ts +1 -1
  69. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  70. package/dist/testing/index.cjs +1 -1
  71. package/dist/testing/index.cjs.map +1 -1
  72. package/dist/testing/index.js +3 -3
  73. package/dist/testing/index.js.map +1 -1
  74. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs +2 -0
  75. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs.map +1 -0
  76. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js +658 -0
  77. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js.map +1 -0
  78. package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs} +2 -2
  79. package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs.map → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs.map} +1 -1
  80. package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js → waitForTransactionReceiptSmartAware-lobLm0q0.js} +2 -2
  81. package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js.map → waitForTransactionReceiptSmartAware-lobLm0q0.js.map} +1 -1
  82. package/package.json +1 -1
  83. package/dist/PayoutManager-1GWmbvI9.cjs +0 -2
  84. package/dist/PayoutManager-1GWmbvI9.cjs.map +0 -1
  85. package/dist/PayoutManager-Ddo9_Ozc.js.map +0 -1
  86. package/dist/PeginManager-CTU0wgkJ.js.map +0 -1
  87. package/dist/PeginManager-De-eHl3v.cjs +0 -2
  88. package/dist/PeginManager-De-eHl3v.cjs.map +0 -1
  89. package/dist/buildAndBroadcastRefund-BnD2qUDW.cjs +0 -2
  90. package/dist/buildAndBroadcastRefund-BnD2qUDW.cjs.map +0 -1
  91. package/dist/buildAndBroadcastRefund-DjS9nf87.js.map +0 -1
  92. package/dist/fundPeginTransaction-96FxwYYJ.js.map +0 -1
  93. package/dist/fundPeginTransaction-DuMwnytD.cjs +0 -2
  94. package/dist/fundPeginTransaction-DuMwnytD.cjs.map +0 -1
  95. package/dist/verifyScriptPathSchnorrSignature-DpWZx5J0.js +0 -567
  96. package/dist/verifyScriptPathSchnorrSignature-DpWZx5J0.js.map +0 -1
  97. package/dist/verifyScriptPathSchnorrSignature-a4Us7D3e.cjs +0 -2
  98. package/dist/verifyScriptPathSchnorrSignature-a4Us7D3e.cjs.map +0 -1
@@ -9,33 +9,33 @@ import { isAddressEqual as ft, encodeFunctionData as tt, zeroAddress as Jt } fro
9
9
  import { B as A } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
10
10
  import { h as H } from "./errors-Blc-JWnI.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 { a as mt, b as se, d as Pt, f as oe } from "./verifyScriptPathSchnorrSignature-DpWZx5J0.js";
12
+ import { a as mt, b as se, d as bt, f as oe } from "./verifyScriptPathSchnorrSignature-DA4Z4yZ3.js";
13
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 bt, s as T, j as wt, X as le } from "./bitcoin-B5aNKtsk.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
15
  import { c as ue } from "./signing-DaLvGwQe.js";
16
16
  import { M as yt } from "./validation-CxqROCno.js";
17
- import { c as he, a as de } from "./PayoutManager-Ddo9_Ozc.js";
18
- import { s as ge, f as q, i as fe, w as xt } from "./waitForTransactionReceiptSmartAware-Ckg_oZAo.js";
19
- import { p as pe, f as me } from "./fundPeginTransaction-96FxwYYJ.js";
20
- import { p as Pe, V as be, i as we } from "./mempoolApi-CB7bHuwi.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
21
  const M = /* @__PURE__ */ BigInt(2 ** 32 - 1), kt = /* @__PURE__ */ BigInt(32);
22
- function ye(n, t = !1) {
22
+ function xe(n, t = !1) {
23
23
  return t ? { h: Number(n & M), l: Number(n >> kt & M) } : { h: Number(n >> kt & M) | 0, l: Number(n & M) | 0 };
24
24
  }
25
- function xe(n, t = !1) {
25
+ function ke(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 } = ye(n[r], t);
29
+ const { h: i, l: a } = xe(n[r], t);
30
30
  [s[r], o[r]] = [i, a];
31
31
  }
32
32
  return [s, o];
33
33
  }
34
- const ke = (n, t, e) => n << e | t >>> 32 - e, Ee = (n, t, e) => t << e | n >>> 32 - e, Te = (n, t, e) => t << e - 32 | n >>> 64 - e, _e = (n, t, e) => n << e - 32 | t >>> 64 - e, U = 32, z = 32, nt = 36, Ht = 32, K = 4, Be = K + U + K + Ht;
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
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 ve(n) {
38
+ function Se(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 Se(n) {
54
+ function Ie(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(ve);
59
+ const t = n.map(Se);
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 Se(n) {
68
68
  e.set(t[s], s * nt);
69
69
  return it(e);
70
70
  }
71
- function Ie(n) {
71
+ function Ae(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 = Se(n.fundingOutpoints), e = new Uint8Array(Be);
76
+ const t = Ie(n.fundingOutpoints), e = new Uint8Array(ve);
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 Ae = "babylon-btc-vault", Ot = 32, Tt = Ot * 2, Ce = /^[0-9a-f]+$/;
81
- async function He(n, t) {
82
- const e = Ie(t), s = X(e), o = await n.deriveContextHash(Ae, s);
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
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 He(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 (!Ce.test(o))
91
+ if (!He.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 Oe = /* @__PURE__ */ Uint8Array.from([
97
+ const Re = /* @__PURE__ */ Uint8Array.from([
98
98
  7,
99
99
  4,
100
100
  13,
@@ -111,11 +111,11 @@ const Oe = /* @__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)), Re = Rt.map((n) => (9 * n + 5) % 16), $t = /* @__PURE__ */ (() => {
115
- const e = [[Rt], [Re]];
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
116
  for (let s = 0; s < 4; s++)
117
117
  for (let o of e)
118
- o.push(o[s].map((r) => Oe[r]));
118
+ o.push(o[s].map((r) => Re[r]));
119
119
  return e;
120
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],
@@ -123,13 +123,13 @@ const Oe = /* @__PURE__ */ Uint8Array.from([
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)), $e = /* @__PURE__ */ Ut.map((n, t) => n.map((e) => Mt[t][e])), Ue = /* @__PURE__ */ Vt.map((n, t) => n.map((e) => Mt[t][e])), Ve = /* @__PURE__ */ Uint32Array.from([
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([
127
127
  0,
128
128
  1518500249,
129
129
  1859775393,
130
130
  2400959708,
131
131
  2840853838
132
- ]), Me = /* @__PURE__ */ Uint32Array.from([
132
+ ]), Ne = /* @__PURE__ */ Uint32Array.from([
133
133
  1352829926,
134
134
  1548603684,
135
135
  1836072691,
@@ -140,7 +140,7 @@ 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
142
  const N = /* @__PURE__ */ new Uint32Array(16);
143
- class Ne extends Yt {
143
+ class Fe extends Yt {
144
144
  constructor() {
145
145
  super(64, 20, 8, !0);
146
146
  x(this, "h0", 1732584193);
@@ -159,19 +159,19 @@ class Ne extends Yt {
159
159
  process(e, s) {
160
160
  for (let g = 0; g < 16; g++, s += 4)
161
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, P = this.h4 | 0, b = P;
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
163
  for (let g = 0; g < 5; g++) {
164
- const f = 4 - g, k = Ve[g], S = Me[g], E = Ut[g], p = Vt[g], w = $e[g], y = Ue[g];
164
+ const f = 4 - g, k = Me[g], S = Ne[g], E = Ut[g], p = Vt[g], w = Ue[g], y = Ve[g];
165
165
  for (let d = 0; d < 16; d++) {
166
- const u = V(o + _t(g, i, c, l) + N[E[d]] + k, w[d]) + P | 0;
167
- o = P, P = l, l = V(c, 10) | 0, c = i, i = u;
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;
168
168
  }
169
169
  for (let d = 0; d < 16; d++) {
170
- const u = V(r + _t(f, a, h, m) + N[p[d]] + S, y[d]) + b | 0;
171
- r = b, b = m, m = V(h, 10) | 0, h = a, a = u;
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;
172
172
  }
173
173
  }
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 + h | 0);
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);
175
175
  }
176
176
  roundClean() {
177
177
  W(N);
@@ -180,24 +180,24 @@ class Ne extends Yt {
180
180
  this.destroyed = !0, W(this.buffer), this.set(0, 0, 0, 0, 0);
181
181
  }
182
182
  }
183
- const Fe = /* @__PURE__ */ At(() => new Ne()), Le = BigInt(0), R = BigInt(1), We = BigInt(2), Xe = BigInt(7), Ke = BigInt(256), De = BigInt(113), Nt = [], Ft = [], Lt = [];
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
184
  for (let n = 0, t = R, e = 1, s = 0; n < 24; n++) {
185
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 = Le;
186
+ let o = We;
187
187
  for (let r = 0; r < 7; r++)
188
- t = (t << R ^ (t >> Xe) * De) % Ke, t & We && (o ^= R << (R << BigInt(r)) - R);
188
+ t = (t << R ^ (t >> Ke) * Ge) % De, t & Xe && (o ^= R << (R << BigInt(r)) - R);
189
189
  Lt.push(o);
190
190
  }
191
- const Wt = xe(Lt, !0), Ge = Wt[0], qe = Wt[1], Bt = (n, t, e) => e > 32 ? Te(n, t, e) : ke(n, t, e), vt = (n, t, e) => e > 32 ? _e(n, t, e) : Ee(n, t, e);
192
- function ze(n, t = 24) {
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
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, h = e[c], l = e[c + 1], m = Bt(h, l, 1) ^ e[a], P = vt(h, l, 1) ^ e[a + 1];
199
- for (let b = 0; b < 50; b += 10)
200
- n[i + b] ^= m, n[i + b + 1] ^= P;
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;
201
201
  }
202
202
  let o = n[2], r = n[3];
203
203
  for (let i = 0; i < 24; i++) {
@@ -210,7 +210,7 @@ function ze(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] ^= Ge[s], n[1] ^= qe[s];
213
+ n[0] ^= qe[s], n[1] ^= ze[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), ze(this.state32, this.rounds), ut(this.state32), this.posOut = 0, this.pos = 0;
239
+ ut(this.state32), Ye(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 Ye = (n, t, e, s = {}) => At(() => new at(t, n, e), s), je = /* @__PURE__ */ Ye(1, 136, 32), St = 64, _ = 20, ot = 4, Xt = 2, Ze = 0, Qe = 1, F = [64, 64], Je = (n) => Array.from(n).map((t) => t.toString(16).padStart(2, "0")).join("");
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
294
  function ct(n) {
295
- return Fe(it(n));
295
+ return Le(it(n));
296
296
  }
297
297
  function Kt(n) {
298
298
  return (1 << n) - 1;
299
299
  }
300
- function tn(n) {
300
+ function en(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 en(n) {
305
+ function nn(n) {
306
306
  const t = ot, e = n * Kt(t);
307
- return { d: t, n, checksum_radix: tn(e) };
307
+ return { d: t, n, checksum_radix: en(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 nn(n, t) {
326
+ function sn(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), P = j(m, e);
330
- r.push(Array.from(P));
329
+ const m = Y(n, l + Xt), b = j(m, e);
330
+ r.push(Array.from(b));
331
331
  }
332
332
  const i = Y(
333
333
  n,
334
- Ze
334
+ Qe
335
335
  ), a = j(
336
336
  i,
337
337
  s
338
338
  ), c = Y(
339
339
  n,
340
- Qe
340
+ Je
341
341
  ), h = j(
342
342
  c,
343
343
  o
@@ -349,7 +349,7 @@ function nn(n, t) {
349
349
  checksum_minor_terminal: Array.from(a)
350
350
  };
351
351
  }
352
- async function sn(n) {
352
+ async function on(n) {
353
353
  try {
354
354
  if (n.length !== St)
355
355
  throw new Error(
@@ -357,11 +357,11 @@ async function sn(n) {
357
357
  );
358
358
  const t = [];
359
359
  for (let e = 0; e < F.length; e++) {
360
- const s = F[e], o = en(s), r = new Uint8Array(n.length + 1);
360
+ const s = F[e], o = nn(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 = nn(i, o);
364
+ const a = sn(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 on(n) {
417
+ function rn(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 on(n) {
433
433
  for (const i of r.message_terminals)
434
434
  e.set(i, s), s += _;
435
435
  }
436
- const o = je(e);
437
- return `0x${Je(o)}`;
436
+ const o = Ze(e);
437
+ return `0x${tn(o)}`;
438
438
  }
439
- async function rn(n, t) {
439
+ async function an(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 h = await sn(a);
446
- e.push(h), s.push(on(h));
445
+ const h = await on(a);
446
+ e.push(h), s.push(rn(h));
447
447
  } finally {
448
448
  a.fill(0);
449
449
  }
@@ -460,48 +460,32 @@ async function rn(n, t) {
460
460
  }
461
461
  return { perVaultWotsKeys: e, wotsPkHashes: s, htlcSecretHexes: o, hashlocks: r };
462
462
  }
463
- const an = /^0x[0-9a-f]+$/i, cn = /^[0-9a-f]+$/i, ln = /^[A-Za-z0-9+/]+={0,2}$/;
463
+ const cn = /^0x[0-9a-f]+$/i, ln = /^[0-9a-f]+$/i, un = /^[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 ce(n).toLowerCase();
468
468
  }
469
- function un(n) {
469
+ function hn(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 (!an.test(n) || n.length < 4 || n.length % 2 !== 0)
473
+ if (!cn.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 (cn.test(n)) {
477
+ if (ln.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 (!ln.test(n) || n.length % 4 !== 0)
482
+ if (!un.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 hn(n, t, e) {
490
- if (typeof n.signPsbts == "function") {
491
- const o = await n.signPsbts(t, e);
492
- if (o.length !== t.length)
493
- throw new Error(
494
- `Expected ${t.length} signed PSBTs but received ${o.length}`
495
- );
496
- return o;
497
- }
498
- const s = [];
499
- for (let o = 0; o < t.length; o++) {
500
- const r = await n.signPsbt(t[o], e[o]);
501
- s.push(r);
502
- }
503
- return s;
504
- }
505
489
  const Dt = 0, L = 25, rt = 9999, Q = "00".repeat(32);
506
490
  function dn(n, t) {
507
491
  const e = {
@@ -524,7 +508,7 @@ function gn(n, t, e, s) {
524
508
  vout: t,
525
509
  value: o.value,
526
510
  scriptPubKey: o.scriptPubKey
527
- }) : we(n, t, s);
511
+ }) : ye(n, t, s);
528
512
  }
529
513
  const It = 12e4;
530
514
  class Vn {
@@ -540,8 +524,9 @@ class Vn {
540
524
  /**
541
525
  * Prepare a peg-in: sizing pass → vault-root derivation (one wallet
542
526
  * popup) → per-vault WOTS / hashlock derivation → commit pass with
543
- * batch PSBT signing (one popup). Returns broadcast-ready txs, the
544
- * pubkey snapshot, and the sensitive derived material.
527
+ * PSBT signing (signPsbt for a single vault, one batch popup for a
528
+ * split). Returns broadcast-ready txs, the pubkey snapshot, and the
529
+ * sensitive derived material.
545
530
  *
546
531
  * @throws If the wallet rejects, insufficient funds, or an internal
547
532
  * invariant violation.
@@ -550,7 +535,7 @@ class Vn {
550
535
  if (t.amounts.length === 0)
551
536
  throw new Error("amounts must contain at least one entry");
552
537
  const e = await this.config.btcWallet.getPublicKeyHex(), s = $(e);
553
- if (!bt(
538
+ if (!Pt(
554
539
  t.changeAddress,
555
540
  e,
556
541
  this.config.btcNetwork
@@ -563,7 +548,7 @@ class Vn {
563
548
  txid: et(f.txid),
564
549
  vout: f.vout
565
550
  })
566
- ), i = await He(this.config.btcWallet, {
551
+ ), i = await Oe(this.config.btcWallet, {
567
552
  depositorBtcPubkey: et(s),
568
553
  fundingOutpoints: r
569
554
  });
@@ -578,10 +563,10 @@ class Vn {
578
563
  } catch (f) {
579
564
  throw i.fill(0), f;
580
565
  }
581
- const h = await rn(i, t.amounts.length), { perVaultWotsKeys: l, wotsPkHashes: m, htlcSecretHexes: P, hashlocks: b } = h, g = await this.preparePeginCommit({
566
+ const h = await an(i, t.amounts.length), { perVaultWotsKeys: l, wotsPkHashes: m, htlcSecretHexes: b, hashlocks: P } = h, g = await this.preparePeginCommit({
582
567
  depositorBtcPubkeyRaw: e,
583
568
  depositorBtcPubkey: s,
584
- hashlocks: b,
569
+ hashlocks: P,
585
570
  authAnchorHash: c,
586
571
  sizing: o,
587
572
  params: t
@@ -606,7 +591,7 @@ class Vn {
606
591
  derivedSecrets: {
607
592
  perVaultWotsKeys: l,
608
593
  wotsPkHashes: m,
609
- htlcSecretHexes: P,
594
+ htlcSecretHexes: b,
610
595
  authAnchorHex: a
611
596
  }
612
597
  };
@@ -646,11 +631,11 @@ class Vn {
646
631
  councilSize: e.councilSize,
647
632
  network: this.config.btcNetwork,
648
633
  authAnchorHash: Q
649
- }), i = ge(
634
+ }), i = fe(
650
635
  [...e.availableUTXOs],
651
636
  r.totalOutputValue,
652
637
  e.mempoolFeeRate,
653
- pe(r.htlcValues.length, !0)
638
+ me(r.htlcValues.length, !0)
654
639
  );
655
640
  return {
656
641
  selectedUTXOs: i.selectedUTXOs,
@@ -679,7 +664,7 @@ class Vn {
679
664
  );
680
665
  const h = T(
681
666
  a.vaultProviderBtcPubkey
682
- ), l = a.vaultKeeperBtcPubkeys.map(T), m = a.universalChallengerBtcPubkeys.map(T), P = l.length, b = {
667
+ ), l = a.vaultKeeperBtcPubkeys.map(T), m = a.universalChallengerBtcPubkeys.map(T), b = l.length, P = {
683
668
  vaultCoreVersion: a.vaultCoreVersion,
684
669
  depositorPubkey: s,
685
670
  vaultProviderPubkey: h,
@@ -690,12 +675,12 @@ class Vn {
690
675
  pegInAmounts: a.amounts,
691
676
  feeRate: a.protocolFeeRate,
692
677
  minPeginFeeRate: a.minPeginFeeRate,
693
- numLocalChallengers: P,
678
+ numLocalChallengers: b,
694
679
  councilQuorum: a.councilQuorum,
695
680
  councilSize: a.councilSize,
696
681
  network: this.config.btcNetwork,
697
682
  authAnchorHash: r
698
- }, g = await mt(b), f = wt(this.config.btcNetwork), k = me({
683
+ }, g = await mt(P), f = wt(this.config.btcNetwork), k = be({
699
684
  unfundedTxHex: g.psbtHex,
700
685
  selectedUTXOs: i.selectedUTXOs,
701
686
  changeAddress: a.changeAddress,
@@ -706,7 +691,7 @@ class Vn {
706
691
  ), E = [], p = [], w = [];
707
692
  for (let u = 0; u < o.length; u++) {
708
693
  const B = await se({
709
- prePeginParams: b,
694
+ prePeginParams: P,
710
695
  timelockPegin: a.timelockPegin,
711
696
  fundedPrePeginTxHex: k,
712
697
  htlcVout: u
@@ -726,13 +711,13 @@ class Vn {
726
711
  ue(e, 1)
727
712
  );
728
713
  }
729
- const y = await hn(
714
+ const y = await ge(
730
715
  this.config.btcWallet,
731
716
  p,
732
717
  w
733
718
  ), d = [];
734
719
  for (let u = 0; u < y.length; u++) {
735
- Pt({
720
+ bt({
736
721
  requestedPsbtHex: p[u],
737
722
  returnedPsbtHex: y[u]
738
723
  });
@@ -794,21 +779,21 @@ class Vn {
794
779
  }), l = await Promise.all(h), m = l.reduce(
795
780
  (p, w) => p + BigInt(w.utxoData.value),
796
781
  0n
797
- ), P = r.outs.reduce(
782
+ ), b = r.outs.reduce(
798
783
  (p, w) => p + BigInt(w.value),
799
784
  0n
800
785
  );
801
- if (m < P)
786
+ if (m < b)
802
787
  throw new Error(
803
- `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.`
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.`
804
789
  );
805
- const b = m - P;
806
- if (b > yt)
790
+ const P = m - b;
791
+ if (P > yt)
807
792
  throw new Error(
808
- `Implied transaction fee (${b} sat) exceeds maximum reasonable fee (${yt} sat). This may indicate manipulated UTXO data.`
793
+ `Implied transaction fee (${P} sat) exceeds maximum reasonable fee (${yt} sat). This may indicate manipulated UTXO data.`
809
794
  );
810
795
  for (const { input: p, utxoData: w, txid: y, vout: d } of l) {
811
- const u = fe(
796
+ const u = pe(
812
797
  {
813
798
  value: w.value,
814
799
  scriptPubKey: w.scriptPubKey
@@ -828,7 +813,7 @@ class Vn {
828
813
  value: p.value
829
814
  });
830
815
  const g = i.toHex(), f = await this.config.btcWallet.signPsbt(g);
831
- Pt({
816
+ bt({
832
817
  requestedPsbtHex: g,
833
818
  returnedPsbtHex: f
834
819
  });
@@ -888,7 +873,7 @@ class Vn {
888
873
  throw new Error(
889
874
  `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.`
890
875
  );
891
- const m = await this.assertPopMatchesBtcWallet(h), P = h.btcPopSignature, b = v(
876
+ const m = await this.assertPopMatchesBtcWallet(h), b = h.btcPopSignature, P = v(
892
877
  h.depositorBtcPubkey
893
878
  ), g = v(e), f = v(s), k = a ?? await this.config.btcWallet.getAddress(), S = this.resolvePayoutScriptPubKey(
894
879
  m,
@@ -924,8 +909,8 @@ class Vn {
924
909
  functionName: "submitPeginRequest",
925
910
  args: [
926
911
  l,
927
- b,
928
912
  P,
913
+ b,
929
914
  g,
930
915
  f,
931
916
  o,
@@ -1017,9 +1002,9 @@ class Vn {
1017
1002
  l.push({ vaultId: C, peginTxHash: B });
1018
1003
  }
1019
1004
  const m = this.config.publicClient;
1020
- let P;
1005
+ let b;
1021
1006
  try {
1022
- P = await m.readContract({
1007
+ b = await m.readContract({
1023
1008
  address: this.config.vaultContracts.btcVaultRegistry,
1024
1009
  abi: A,
1025
1010
  functionName: "getPegInFee",
@@ -1031,7 +1016,7 @@ class Vn {
1031
1016
  { cause: d }
1032
1017
  );
1033
1018
  }
1034
- const b = P * BigInt(o.length), g = await this.resolveMaxAcceptableCommissionBps(
1019
+ const P = b * BigInt(o.length), g = await this.resolveMaxAcceptableCommissionBps(
1035
1020
  e,
1036
1021
  t.quotedCommissionBps
1037
1022
  ), f = v(
@@ -1063,7 +1048,7 @@ class Vn {
1063
1048
  p = await m.estimateGas({
1064
1049
  to: this.config.vaultContracts.btcVaultRegistry,
1065
1050
  data: E,
1066
- value: b,
1051
+ value: P,
1067
1052
  account: this.config.ethWallet.account.address
1068
1053
  });
1069
1054
  } catch (d) {
@@ -1074,7 +1059,7 @@ class Vn {
1074
1059
  w = await this.config.ethWallet.sendTransaction({
1075
1060
  to: this.config.vaultContracts.btcVaultRegistry,
1076
1061
  data: E,
1077
- value: b,
1062
+ value: P,
1078
1063
  account: this.config.ethWallet.account,
1079
1064
  chain: this.config.ethChain,
1080
1065
  gas: p
@@ -1102,7 +1087,7 @@ class Vn {
1102
1087
  async resolveMaxAcceptableCommissionBps(t, e) {
1103
1088
  let s;
1104
1089
  try {
1105
- s = await new be(
1090
+ s = await new we(
1106
1091
  this.config.publicClient,
1107
1092
  this.config.vaultContracts.btcVaultRegistry
1108
1093
  ).getVaultProviderCommission(t);
@@ -1165,7 +1150,7 @@ class Vn {
1165
1150
  * on-chain payout-script registration.
1166
1151
  */
1167
1152
  resolvePayoutScriptPubKey(t, e) {
1168
- if (!bt(
1153
+ if (!Pt(
1169
1154
  e,
1170
1155
  t,
1171
1156
  this.config.btcNetwork
@@ -1200,7 +1185,7 @@ class Vn {
1200
1185
  "bip322-simple"
1201
1186
  );
1202
1187
  return {
1203
- btcPopSignature: un(r),
1188
+ btcPopSignature: hn(r),
1204
1189
  depositorEthAddress: t,
1205
1190
  depositorBtcPubkey: e
1206
1191
  };
@@ -1238,8 +1223,8 @@ class Vn {
1238
1223
  return this.config.vaultContracts.btcVaultRegistry;
1239
1224
  }
1240
1225
  }
1241
- const fn = 80, pn = 250, mn = 300, Pn = 22, Gt = "ab";
1242
- function bn(n, t) {
1226
+ const fn = 80, pn = 250, mn = 300, bn = 22, Gt = "ab";
1227
+ function Pn(n, t) {
1243
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);
1244
1229
  return `0x${r}${i}`;
1245
1230
  }
@@ -1249,14 +1234,14 @@ function wn(n, t) {
1249
1234
  depositorBtcPubKey: e(32),
1250
1235
  btcPopSignature: e(fn),
1251
1236
  unsignedPrePeginTx: e(pn),
1252
- depositorSignedPeginTx: bn(
1237
+ depositorSignedPeginTx: Pn(
1253
1238
  n,
1254
1239
  t
1255
1240
  ),
1256
1241
  hashlock: e(32),
1257
1242
  htlcVout: t,
1258
1243
  referralCode: Dt,
1259
- depositorPayoutBtcAddress: e(Pn),
1244
+ depositorPayoutBtcAddress: e(bn),
1260
1245
  depositorWotsPkHash: e(32)
1261
1246
  };
1262
1247
  }
@@ -1299,12 +1284,12 @@ async function Mn(n) {
1299
1284
  }
1300
1285
  export {
1301
1286
  Vn as P,
1302
- Ae as V,
1303
- Ie as a,
1304
- Se as b,
1305
- on as c,
1306
- sn as d,
1287
+ Ce as V,
1288
+ Ae as a,
1289
+ Ie as b,
1290
+ rn as c,
1291
+ on as d,
1307
1292
  Mn as e,
1308
- He as f
1293
+ Oe as f
1309
1294
  };
1310
- //# sourceMappingURL=PeginManager-CTU0wgkJ.js.map
1295
+ //# sourceMappingURL=PeginManager-D22MLWfM.js.map