@babylonlabs-io/ts-sdk 0.38.0 → 0.39.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 (85) 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-DXrfY4d6.js} +376 -344
  6. package/dist/PeginManager-DXrfY4d6.js.map +1 -0
  7. package/dist/PeginManager-zkTJOy_U.cjs +2 -0
  8. package/dist/PeginManager-zkTJOy_U.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 +140 -139
  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/clients/eth/types.d.ts +2 -0
  32. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  33. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +5 -0
  34. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  35. package/dist/tbv/core/clients/index.cjs +1 -1
  36. package/dist/tbv/core/clients/index.js +1 -1
  37. package/dist/tbv/core/index.cjs +1 -1
  38. package/dist/tbv/core/index.js +139 -138
  39. package/dist/tbv/core/managers/PeginManager.d.ts +25 -0
  40. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  41. package/dist/tbv/core/managers/index.cjs +1 -1
  42. package/dist/tbv/core/managers/index.d.ts +2 -2
  43. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  44. package/dist/tbv/core/managers/index.js +5 -4
  45. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts +37 -0
  46. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts.map +1 -1
  47. package/dist/tbv/core/managers/pegin/index.d.ts +1 -1
  48. package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -1
  49. package/dist/tbv/core/primitives/index.cjs +1 -1
  50. package/dist/tbv/core/primitives/index.js +17 -17
  51. package/dist/tbv/core/primitives/psbt/__tests__/refund.test.d.ts +12 -0
  52. package/dist/tbv/core/primitives/psbt/__tests__/refund.test.d.ts.map +1 -0
  53. package/dist/tbv/core/primitives/psbt/pegin.d.ts +5 -0
  54. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  55. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  56. package/dist/tbv/core/services/index.cjs +1 -1
  57. package/dist/tbv/core/services/index.js +2 -2
  58. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  59. package/dist/tbv/index.cjs +1 -1
  60. package/dist/tbv/index.js +139 -138
  61. package/dist/{vault-registry-reader-CbJHSxVe.cjs → vault-registry-reader-BM_993Lb.cjs} +2 -2
  62. package/dist/{vault-registry-reader-CbJHSxVe.cjs.map → vault-registry-reader-BM_993Lb.cjs.map} +1 -1
  63. package/dist/{vault-registry-reader-BrARgFre.js → vault-registry-reader-DXvw-1f6.js} +28 -16
  64. package/dist/{vault-registry-reader-BrARgFre.js.map → vault-registry-reader-DXvw-1f6.js.map} +1 -1
  65. package/package.json +3 -3
  66. package/dist/PayoutManager-BfT0V-tm.cjs +0 -2
  67. package/dist/PayoutManager-BfT0V-tm.cjs.map +0 -1
  68. package/dist/PayoutManager-Cf51DBcu.js +0 -208
  69. package/dist/PayoutManager-Cf51DBcu.js.map +0 -1
  70. package/dist/PeginManager-BRHJZYmE.cjs +0 -2
  71. package/dist/PeginManager-BRHJZYmE.cjs.map +0 -1
  72. package/dist/PeginManager-C1en2vwr.js.map +0 -1
  73. package/dist/assertPsbtUnsignedTxMatches-CagW7XqW.cjs +0 -2
  74. package/dist/assertPsbtUnsignedTxMatches-CagW7XqW.cjs.map +0 -1
  75. package/dist/assertPsbtUnsignedTxMatches-Dry5dTfl.js +0 -266
  76. package/dist/assertPsbtUnsignedTxMatches-Dry5dTfl.js.map +0 -1
  77. package/dist/buildAndBroadcastRefund-CEKwFY8l.cjs +0 -2
  78. package/dist/noPayout-B6s8vrW6.cjs +0 -2
  79. package/dist/noPayout-B6s8vrW6.cjs.map +0 -1
  80. package/dist/noPayout-BhgknZBx.js +0 -141
  81. package/dist/noPayout-BhgknZBx.js.map +0 -1
  82. package/dist/peginInput-57FK2O99.cjs +0 -2
  83. package/dist/peginInput-57FK2O99.cjs.map +0 -1
  84. package/dist/peginInput-CYJzbuwA.js +0 -177
  85. package/dist/peginInput-CYJzbuwA.js.map +0 -1
@@ -1,73 +1,51 @@
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 qt = Object.defineProperty;
2
+ var zt = (n, t, e) => t in n ? qt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var x = (n, t, e) => zt(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { s as it, c as It, H as Yt, r as M, a as X, b as lt, u as jt, d as ut, e as ht, f as dt, g as Zt } from "./sha2-BYVxyZzX.js";
5
+ import * as Ct from "bitcoinjs-lib";
6
+ import { Transaction as Qt, Psbt as gt } from "bitcoinjs-lib";
7
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";
8
+ import { isAddressEqual as ft, encodeFunctionData as tt, zeroAddress as Jt } from "viem";
9
+ import { B as I } from "./BTCVaultRegistry.abi-Cq9-JlqT.js";
10
+ import { h as H } from "./errors-CznAK5NB.js";
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, f as bt } from "./assertPsbtUnsignedTxMatches-mTAnLhCz.js";
13
+ import { b as oe, e as re, f as ie } from "./peginInput-BPRB9tUi.js";
14
+ import { u as K, h as et, e as v, p as ae, i as wt, s as T, j as Pt, X as ce } from "./bitcoin-B5aNKtsk.js";
15
+ import { c as le } from "./signing-DaLvGwQe.js";
16
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);
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 };
24
- }
17
+ import { c as ue, a as he } from "./PayoutManager-D29D-K-V.js";
18
+ import { s as de, f as z, i as ge, w as xt } from "./waitForTransactionReceiptSmartAware-CmgFXFza.js";
19
+ import { p as fe, f as pe } from "./fundPeginTransaction-t-6TsHAY.js";
20
+ import { p as me, f as be } from "./mempoolApi-CAIge7Nj.js";
21
+ const N = /* @__PURE__ */ BigInt(2 ** 32 - 1), kt = /* @__PURE__ */ BigInt(32);
25
22
  function we(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
+ }
25
+ function Pe(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 } = me(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 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;
57
- function nt(n, t, e) {
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, Y = 32, nt = 36, Ht = 32, D = 4, Te = D + U + D + Ht;
35
+ function st(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) {
61
- if (n.txid.length !== j)
38
+ function _e(n) {
39
+ if (n.txid.length !== Y)
62
40
  throw new Error(
63
- `outpoint.txid must be exactly ${j} bytes, got ${n.txid.length}`
41
+ `outpoint.txid must be exactly ${Y} bytes, got ${n.txid.length}`
64
42
  );
65
43
  if (!Number.isInteger(n.vout) || n.vout < 0 || n.vout > 4294967295)
66
44
  throw new Error(`outpoint.vout must be a u32, got ${n.vout}`);
67
- const t = new Uint8Array(et);
68
- return t.set(n.txid, 0), nt(t, j, n.vout), t;
45
+ const t = new Uint8Array(nt);
46
+ return t.set(n.txid, 0), st(t, Y, n.vout), t;
69
47
  }
70
- function Tt(n, t) {
48
+ function Et(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];
@@ -78,43 +56,43 @@ function Be(n) {
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(_e);
60
+ t.sort(Et);
83
61
  for (let s = 1; s < t.length; s++)
84
- if (Tt(t[s - 1], t[s]) === 0)
62
+ if (Et(t[s - 1], t[s]) === 0)
85
63
  throw new Error(
86
64
  "buildFundingOutpointsCommitment: duplicate outpoint detected"
87
65
  );
88
- const e = new Uint8Array(t.length * et);
66
+ const e = new Uint8Array(t.length * nt);
89
67
  for (let s = 0; s < t.length; s++)
90
- e.set(t[s], s * et);
91
- return ot(e);
68
+ e.set(t[s], s * nt);
69
+ return it(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 = Be(n.fundingOutpoints), e = new Uint8Array(Te);
99
77
  let s = 0;
100
- 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;
78
+ return st(e, s, U), s += D, e.set(n.depositorBtcPubkey, s), s += U, st(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 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 = K(e), o = await n.deriveContextHash(Se, 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 !== Tt)
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 ${Tt}-character hex string (${Ot} bytes), got length ${o.length}`
112
90
  );
113
91
  if (!Ae.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
- return tt(o);
95
+ return et(o);
118
96
  }
119
97
  const Ce = /* @__PURE__ */ Uint8Array.from([
120
98
  7,
@@ -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__ */ (() => {
114
+ ]), $t = Uint8Array.from(new Array(16).fill(0).map((n, t) => t)), He = $t.map((n) => (9 * n + 5) % 16), Rt = /* @__PURE__ */ (() => {
137
115
  const e = [[$t], [He]];
138
116
  for (let s = 0; s < 4; s++)
139
117
  for (let o of e)
140
118
  o.push(o[s].map((r) => Ce[r]));
141
119
  return e;
142
- })(), Nt = Ut[0], Vt = Ut[1], Lt = /* @__PURE__ */ [
120
+ })(), Ut = Rt[0], Mt = 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)), Oe = /* @__PURE__ */ Ut.map((n, t) => n.map((e) => Nt[t][e])), $e = /* @__PURE__ */ Mt.map((n, t) => n.map((e) => Nt[t][e])), Re = /* @__PURE__ */ Uint32Array.from([
149
127
  0,
150
128
  1518500249,
151
129
  1859775393,
152
130
  2400959708,
153
131
  2840853838
154
- ]), Ne = /* @__PURE__ */ Uint32Array.from([
132
+ ]), Ue = /* @__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 _t(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 V = /* @__PURE__ */ new Uint32Array(16);
143
+ class Me extends Yt {
166
144
  constructor() {
167
145
  super(64, 20, 8, !0);
168
146
  x(this, "h0", 1732584193);
@@ -180,51 +158,51 @@ class Ve extends Gt {
180
158
  }
181
159
  process(e, s) {
182
160
  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;
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, w = b;
185
163
  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];
187
- 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;
164
+ const f = 4 - g, k = Re[g], S = Ue[g], E = Ut[g], p = Mt[g], P = Oe[g], y = $e[g];
165
+ for (let h = 0; h < 16; h++) {
166
+ const d = M(o + _t(g, i, c, l) + V[E[h]] + k, P[h]) + b | 0;
167
+ o = b, b = l, l = M(c, 10) | 0, c = i, i = d;
190
168
  }
191
- 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;
169
+ for (let h = 0; h < 16; h++) {
170
+ const d = M(r + _t(f, a, u, m) + V[p[h]] + S, y[h]) + w | 0;
171
+ r = w, w = m, m = M(u, 10) | 0, u = a, a = d;
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 + w | 0, this.h3 + b + r | 0, this.h4 + o + a | 0, this.h0 + i + u | 0);
197
175
  }
198
176
  roundClean() {
199
- F(L);
177
+ X(V);
200
178
  }
201
179
  destroy() {
202
- this.destroyed = !0, F(this.buffer), this.set(0, 0, 0, 0, 0);
180
+ this.destroyed = !0, X(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++) {
207
- [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;
183
+ const Ne = /* @__PURE__ */ It(() => new Me()), Ve = BigInt(0), $ = BigInt(1), Le = BigInt(2), We = BigInt(7), Fe = BigInt(256), Xe = BigInt(113), Vt = [], Lt = [], Wt = [];
184
+ for (let n = 0, t = $, e = 1, s = 0; n < 24; n++) {
185
+ [e, s] = [s, (2 * e + 3 * s) % 5], Vt.push(2 * (5 * s + e)), Lt.push((n + 1) * (n + 2) / 2 % 64);
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 >> We) * Xe) % Fe, t & Le && (o ^= $ << ($ << BigInt(r)) - $);
189
+ Wt.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 Ft = Pe(Wt, !0), Ke = Ft[0], De = Ft[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) {
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, 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 w = 0; w < 50; w += 10)
200
+ n[i + w] ^= m, n[i + w + 1] ^= b;
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];
227
- o = n[l], r = n[l + 1], n[l] = c, n[l + 1] = d;
204
+ const a = Lt[i], c = Bt(o, r, a), u = vt(o, r, a), l = Vt[i];
205
+ o = n[l], r = n[l + 1], n[l] = c, n[l + 1] = u;
228
206
  }
229
207
  for (let i = 0; i < 50; i += 10) {
230
208
  for (let a = 0; a < 10; a++)
@@ -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] ^= Ke[s], n[1] ^= De[s];
236
214
  }
237
- F(e);
215
+ X(e);
238
216
  }
239
- class it {
217
+ class at {
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,7 +228,7 @@ 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, lt(s, "outputLen"), !(0 < t && t < 200))
254
232
  throw new Error("only keccak-f1600 function is supported");
255
233
  this.state = new Uint8Array(200), this.state32 = jt(this.state);
256
234
  }
@@ -258,10 +236,10 @@ class it {
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
+ ut(this.state32), Ge(this.state32, this.rounds), ut(this.state32), this.posOut = 0, this.pos = 0;
262
240
  }
263
241
  update(t) {
264
- ut(this), ht(t);
242
+ ht(this), dt(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
+ ht(this, !1), dt(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,7 +272,7 @@ 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 lt(t), this.xofInto(new Uint8Array(t));
298
276
  }
299
277
  digestInto(t) {
300
278
  if (Zt(t, this), this.finished)
@@ -305,30 +283,30 @@ class it {
305
283
  return this.digestInto(new Uint8Array(this.outputLen));
306
284
  }
307
285
  destroy() {
308
- this.destroyed = !0, F(this.state);
286
+ this.destroyed = !0, X(this.state);
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 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;
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 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, L = [64, 64], Ze = (n) => Array.from(n).map((t) => t.toString(16).padStart(2, "0")).join("");
294
+ function ct(n) {
295
+ return Ne(it(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 Qe(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 Je(n) {
306
+ const t = ot, e = n * Kt(t);
307
+ return { d: t, n, checksum_radix: Qe(e) };
330
308
  }
331
- function Z(n, t) {
309
+ function j(n, t) {
332
310
  const e = [];
333
311
  let s = t;
334
312
  for (; s > 0; )
@@ -337,56 +315,56 @@ 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 ct(o);
341
319
  }
342
- function Y(n, t) {
320
+ function Z(n, t) {
343
321
  let e = n;
344
322
  for (let s = 0; s < t; s++)
345
- e = at(e);
323
+ e = ct(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 tn(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);
352
- r.push(Array.from(w));
329
+ const m = j(n, l + Xt), b = Z(m, e);
330
+ r.push(Array.from(b));
353
331
  }
354
- const i = Z(
332
+ const i = j(
355
333
  n,
356
- Ze
357
- ), a = Y(
334
+ Ye
335
+ ), a = Z(
358
336
  i,
359
337
  s
360
- ), c = Z(
338
+ ), c = j(
361
339
  n,
362
- Ye
363
- ), d = Y(
340
+ je
341
+ ), u = Z(
364
342
  c,
365
343
  o
366
344
  );
367
345
  return {
368
346
  config: t,
369
347
  message_terminals: r,
370
- checksum_major_terminal: Array.from(d),
348
+ checksum_major_terminal: Array.from(u),
371
349
  checksum_minor_terminal: Array.from(a)
372
350
  };
373
351
  }
374
- async function nn(n) {
352
+ async function en(n) {
375
353
  try {
376
- if (n.length !== It)
354
+ if (n.length !== St)
377
355
  throw new Error(
378
- `WOTS seed must be exactly ${It} bytes, got ${n.length}`
356
+ `WOTS seed must be exactly ${St} 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 < L.length; e++) {
360
+ const s = L[e], o = Je(s), r = new Uint8Array(n.length + 1);
383
361
  r.set(n), r[n.length] = e;
384
- const i = at(r);
362
+ const i = ct(r);
385
363
  try {
386
- const a = en(i, o);
387
- if (a.config.d !== st)
364
+ const a = tn(i, o);
365
+ if (a.config.d !== ot)
388
366
  throw new Error(
389
- `Block ${e}: expected d=${st}, got d=${a.config.d}`
367
+ `Block ${e}: expected d=${ot}, got d=${a.config.d}`
390
368
  );
391
369
  if (a.config.n !== s)
392
370
  throw new Error(
@@ -414,9 +392,9 @@ async function nn(n) {
414
392
  r.fill(0), i.fill(0);
415
393
  }
416
394
  }
417
- if (t.length !== M.length)
395
+ if (t.length !== L.length)
418
396
  throw new Error(
419
- `Expected ${M.length} blocks, got ${t.length}`
397
+ `Expected ${L.length} blocks, got ${t.length}`
420
398
  );
421
399
  return t;
422
400
  } finally {
@@ -436,7 +414,7 @@ function Q(n, t, e) {
436
414
  );
437
415
  }
438
416
  }
439
- function sn(n) {
417
+ function nn(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,7 +425,7 @@ function sn(n) {
447
425
  }
448
426
  let t = 0;
449
427
  for (const r of n)
450
- t += Kt + r.message_terminals.length;
428
+ t += Xt + r.message_terminals.length;
451
429
  const e = new Uint8Array(t * _);
452
430
  let s = 0;
453
431
  for (const r of n) {
@@ -455,24 +433,24 @@ function sn(n) {
455
433
  for (const i of r.message_terminals)
456
434
  e.set(i, s), s += _;
457
435
  }
458
- const o = je(e);
459
- return `0x${Qe(o)}`;
436
+ const o = ze(e);
437
+ return `0x${Ze(o)}`;
460
438
  }
461
- async function on(n, t) {
439
+ async function sn(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 te(n, i);
466
444
  try {
467
- const d = await nn(a);
468
- e.push(d), s.push(sn(d));
445
+ const u = await en(a);
446
+ e.push(u), s.push(nn(u));
469
447
  } finally {
470
448
  a.fill(0);
471
449
  }
472
- const c = await te(n, i);
450
+ const c = await ee(n, i);
473
451
  try {
474
- const d = K(c);
475
- o.push(d), r.push(le(B(d)).slice(2));
452
+ const u = K(c);
453
+ o.push(u), r.push(ue(v(u)).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 on = /^0x[0-9a-f]+$/i, rn = /^[0-9a-f]+$/i, an = /^[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 ae(n).toLowerCase();
490
468
  }
491
- function ln(n) {
469
+ function cn(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 (!on.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 (rn.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 (!an.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 ln(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 Dt = 0, W = 25, rt = 9999, F = "00".repeat(32);
506
+ function un(n, t) {
529
507
  const e = {
530
508
  bitcoin: "bc",
531
509
  testnet: "tb",
@@ -533,23 +511,23 @@ 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 hn(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,
546
524
  vout: t,
547
525
  value: o.value,
548
526
  scriptPubKey: o.scriptPubKey
549
- }) : pe(n, t, s);
527
+ }) : be(n, t, s);
550
528
  }
551
- const Ot = 12e4;
552
- class On {
529
+ const At = 12e4;
530
+ class Rn {
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
@@ -582,28 +560,28 @@ class On {
582
560
  );
583
561
  const o = await this.prepareSizing(s, t), r = o.selectedUTXOs.map(
584
562
  (f) => ({
585
- txid: tt(f.txid),
563
+ txid: et(f.txid),
586
564
  vout: f.vout
587
565
  })
588
- ), i = await Oe(this.config.btcWallet, {
589
- depositorBtcPubkey: tt(s),
566
+ ), i = await Ie(this.config.btcWallet, {
567
+ depositorBtcPubkey: et(s),
590
568
  fundingOutpoints: r
591
569
  });
592
570
  let a, c;
593
571
  try {
594
- const f = await ee(i);
572
+ const f = await ne(i);
595
573
  try {
596
- a = K(f), c = K(ot(f));
574
+ a = K(f), c = K(it(f));
597
575
  } finally {
598
576
  f.fill(0);
599
577
  }
600
578
  } catch (f) {
601
579
  throw i.fill(0), f;
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 u = await sn(i, t.amounts.length), { perVaultWotsKeys: l, wotsPkHashes: m, htlcSecretHexes: b, hashlocks: w } = u, g = await this.preparePeginCommit({
604
582
  depositorBtcPubkeyRaw: e,
605
583
  depositorBtcPubkey: s,
606
- hashlocks: P,
584
+ hashlocks: w,
607
585
  authAnchorHash: c,
608
586
  sizing: o,
609
587
  params: t
@@ -613,7 +591,7 @@ class On {
613
591
  throw new Error(
614
592
  `Internal invariant violation: htlcVout/index mismatch at vault ${f} (expected ${f}, got ${g.perVault[f].htlcVout})`
615
593
  );
616
- return Te(
594
+ return he(
617
595
  g.fundedPrePeginTxHex,
618
596
  t.amounts.length,
619
597
  c
@@ -628,7 +606,7 @@ class On {
628
606
  derivedSecrets: {
629
607
  perVaultWotsKeys: l,
630
608
  wotsPkHashes: m,
631
- htlcSecretHexes: w,
609
+ htlcSecretHexes: b,
632
610
  authAnchorHex: a
633
611
  }
634
612
  };
@@ -651,7 +629,7 @@ class On {
651
629
  */
652
630
  async prepareSizing(t, e) {
653
631
  const s = e.amounts.map(
654
- () => X
632
+ () => F
655
633
  ), o = e.vaultKeeperBtcPubkeys.length, r = await mt({
656
634
  depositorPubkey: t,
657
635
  vaultProviderPubkey: T(e.vaultProviderBtcPubkey),
@@ -665,14 +643,14 @@ class On {
665
643
  councilQuorum: e.councilQuorum,
666
644
  councilSize: e.councilSize,
667
645
  network: this.config.btcNetwork,
668
- authAnchorHash: X
669
- }), i = ue(
646
+ authAnchorHash: F
647
+ }), i = de(
670
648
  [...e.availableUTXOs],
671
649
  r.totalOutputValue,
672
650
  e.mempoolFeeRate,
673
- de(
651
+ fe(
674
652
  r.htlcValues.length,
675
- X
653
+ F
676
654
  )
677
655
  );
678
656
  return {
@@ -690,85 +668,85 @@ class On {
690
668
  authAnchorHash: r,
691
669
  sizing: i,
692
670
  params: a
693
- } = t, c = X.toLowerCase();
694
- for (let h = 0; h < o.length; h++)
695
- if (o[h].toLowerCase() === c)
671
+ } = t, c = F.toLowerCase();
672
+ for (let d = 0; d < o.length; d++)
673
+ if (o[d].toLowerCase() === c)
696
674
  throw new Error(
697
- `preparePeginCommit refusing to build with sizing-pass placeholder hashlock at vault ${h} — internal substitution bug`
675
+ `preparePeginCommit refusing to build with sizing-pass placeholder hashlock at vault ${d} — internal substitution bug`
698
676
  );
699
677
  if (r.toLowerCase() === c)
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 u = T(a.vaultProviderBtcPubkey), l = a.vaultKeeperBtcPubkeys.map(T), m = a.universalChallengerBtcPubkeys.map(T), b = l.length, w = {
704
682
  depositorPubkey: s,
705
- vaultProviderPubkey: d,
683
+ vaultProviderPubkey: u,
706
684
  vaultKeeperPubkeys: l,
707
685
  universalChallengerPubkeys: m,
708
686
  hashlocks: o,
709
687
  timelockRefund: a.timelockRefund,
710
688
  pegInAmounts: a.amounts,
711
689
  feeRate: a.protocolFeeRate,
712
- numLocalChallengers: w,
690
+ numLocalChallengers: b,
713
691
  councilQuorum: a.councilQuorum,
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({
695
+ }, g = await mt(w), f = Pt(this.config.btcNetwork), k = pe({
718
696
  unfundedTxHex: g.psbtHex,
719
697
  selectedUTXOs: i.selectedUTXOs,
720
698
  changeAddress: a.changeAddress,
721
699
  changeAmount: i.changeAmount,
722
700
  network: f
723
- }), S = T(G(k)), E = [], p = [], b = [];
724
- for (let h = 0; h < o.length; h++) {
725
- const v = await ne({
726
- prePeginParams: P,
701
+ }), S = T(z(k)), E = [], p = [], P = [];
702
+ for (let d = 0; d < o.length; d++) {
703
+ const B = await se({
704
+ prePeginParams: w,
727
705
  timelockPegin: a.timelockPegin,
728
706
  fundedPrePeginTxHex: k,
729
- htlcVout: h
730
- }), I = await se({
731
- peginTxHex: v.txHex,
707
+ htlcVout: d
708
+ }), A = await oe({
709
+ peginTxHex: B.txHex,
732
710
  fundedPrePeginTxHex: k,
733
711
  depositorPubkey: s,
734
- vaultProviderPubkey: d,
712
+ vaultProviderPubkey: u,
735
713
  vaultKeeperPubkeys: l,
736
714
  universalChallengerPubkeys: m,
737
- hashlock: o[h],
715
+ hashlock: o[d],
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(B), p.push(A.psbtHex), P.push(
720
+ le(e, 1)
743
721
  );
744
722
  }
745
- const y = await un(
723
+ const y = await ln(
746
724
  this.config.btcWallet,
747
725
  p,
748
- b
749
- ), u = [];
750
- for (let h = 0; h < y.length; h++) {
751
- wt({
752
- requestedPsbtHex: p[h],
753
- returnedPsbtHex: y[h]
726
+ P
727
+ ), h = [];
728
+ for (let d = 0; d < y.length; d++) {
729
+ bt({
730
+ requestedPsbtHex: p[d],
731
+ returnedPsbtHex: y[d]
754
732
  });
755
- const v = oe(
756
- y[h],
733
+ const B = re(
734
+ y[d],
757
735
  s
758
- ), I = re(y[h]);
759
- u.push({
760
- htlcVout: h,
761
- htlcValue: g.htlcValues[h],
762
- peginTxHex: I,
763
- peginTxid: E[h].txid,
764
- peginInputSignature: v,
765
- vaultScriptPubKey: E[h].vaultScriptPubKey
736
+ ), A = ie(y[d]);
737
+ h.push({
738
+ htlcVout: d,
739
+ htlcValue: g.htlcValues[d],
740
+ peginTxHex: A,
741
+ peginTxid: E[d].txid,
742
+ peginInputSignature: B,
743
+ vaultScriptPubKey: E[d].vaultScriptPubKey
766
744
  });
767
745
  }
768
746
  return {
769
747
  fundedPrePeginTxHex: k,
770
748
  prePeginTxid: S,
771
- perVault: u
749
+ perVault: h
772
750
  };
773
751
  }
774
752
  /**
@@ -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 = Qt.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 gt();
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
- ), 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 })
776
+ ), c = this.config.mempoolApiUrl, u = r.ins.map((p) => {
777
+ const P = J.from(p.hash).reverse().toString("hex"), y = p.index;
778
+ return hn(P, y, t.localPrevouts, c).then(
779
+ (h) => ({ input: p, utxoData: h, txid: P, vout: y })
802
780
  );
803
- }), l = await Promise.all(d), m = l.reduce(
804
- (p, b) => p + BigInt(b.utxoData.value),
781
+ }), l = await Promise.all(u), m = l.reduce(
782
+ (p, P) => p + BigInt(P.utxoData.value),
805
783
  0n
806
- ), w = r.outs.reduce(
807
- (p, b) => p + BigInt(b.value),
784
+ ), b = r.outs.reduce(
785
+ (p, P) => p + BigInt(P.value),
808
786
  0n
809
787
  );
810
- if (m < w)
788
+ if (m < b)
811
789
  throw new Error(
812
- `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.`
790
+ `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.`
813
791
  );
814
- const P = m - w;
815
- if (P > yt)
792
+ const w = m - b;
793
+ if (w > yt)
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 (${w} sat) exceeds maximum reasonable fee (${yt} sat). This may indicate manipulated UTXO data.`
818
796
  );
819
- for (const { input: p, utxoData: b, txid: y, vout: u } of l) {
820
- const h = he(
797
+ for (const { input: p, utxoData: P, txid: y, vout: h } of l) {
798
+ const d = ge(
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
  );
@@ -828,7 +806,7 @@ class On {
828
806
  hash: p.hash,
829
807
  index: p.index,
830
808
  sequence: p.sequence,
831
- ...h
809
+ ...d
832
810
  });
833
811
  }
834
812
  for (const p of r.outs)
@@ -837,11 +815,11 @@ class On {
837
815
  value: p.value
838
816
  });
839
817
  const g = i.toHex(), f = await this.config.btcWallet.signPsbt(g);
840
- wt({
818
+ bt({
841
819
  requestedPsbtHex: g,
842
820
  returnedPsbtHex: f
843
821
  });
844
- const k = dt.fromHex(f);
822
+ const k = gt.fromHex(f);
845
823
  try {
846
824
  k.finalizeAllInputs();
847
825
  } catch (p) {
@@ -853,7 +831,7 @@ class On {
853
831
  );
854
832
  }
855
833
  const S = k.extractTransaction().toHex();
856
- return await fe(S, c);
834
+ return await me(S, c);
857
835
  }
858
836
  /**
859
837
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -888,98 +866,98 @@ class On {
888
866
  htlcVout: i,
889
867
  depositorPayoutBtcAddress: a,
890
868
  depositorWotsPkHash: c,
891
- popSignature: d
869
+ popSignature: u
892
870
  } = t;
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 (!ft(u.depositorEthAddress, l))
897
875
  throw new Error(
898
- `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.`
876
+ `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.`
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(u), b = u.btcPopSignature, w = v(u.depositorBtcPubkey), g = v(e), f = v(s), k = a ?? await this.config.btcWallet.getAddress(), S = this.resolvePayoutScriptPubKey(
901
879
  m,
902
880
  k
903
- ), E = G(f), p = await pt(
881
+ ), E = z(f), p = await pt(
904
882
  T(E),
905
883
  T(l)
906
- ), b = B(p);
907
- if (await this.checkVaultExists(b))
884
+ ), P = v(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
- const u = this.config.publicClient;
912
- let h;
889
+ const h = this.config.publicClient;
890
+ let d;
913
891
  try {
914
- h = await u.readContract({
892
+ d = await h.readContract({
915
893
  address: this.config.vaultContracts.btcVaultRegistry,
916
- abi: O,
894
+ abi: I,
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 B = await this.resolveMaxAcceptableCommissionBps(
927
905
  o,
928
906
  t.quotedCommissionBps
929
- ), I = ft({
930
- abi: O,
907
+ ), A = tt({
908
+ abi: I,
931
909
  functionName: "submitPeginRequest",
932
910
  args: [
933
911
  l,
934
- P,
935
912
  w,
913
+ b,
936
914
  g,
937
915
  f,
938
916
  o,
939
- v,
917
+ B,
940
918
  r,
941
919
  i,
942
920
  S,
943
921
  c
944
922
  ]
945
923
  });
946
- let A;
924
+ let C;
947
925
  try {
948
- A = await u.estimateGas({
926
+ C = await h.estimateGas({
949
927
  to: this.config.vaultContracts.btcVaultRegistry,
950
- data: I,
951
- value: h,
928
+ data: A,
929
+ value: d,
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
- let z;
935
+ let G;
958
936
  try {
959
- z = await this.config.ethWallet.sendTransaction({
937
+ G = await this.config.ethWallet.sendTransaction({
960
938
  to: this.config.vaultContracts.btcVaultRegistry,
961
- data: I,
962
- value: h,
939
+ data: A,
940
+ value: d,
963
941
  account: this.config.ethWallet.account,
964
942
  chain: this.config.ethChain,
965
- gas: A
943
+ gas: C
966
944
  });
967
- } catch (H) {
968
- C(H);
945
+ } catch (O) {
946
+ H(O);
969
947
  }
970
948
  const q = await xt({
971
- publicClient: u,
949
+ publicClient: h,
972
950
  walletAddress: this.config.ethWallet.account.address,
973
- hash: z,
974
- timeout: Ot
951
+ hash: G,
952
+ timeout: At
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,63 +978,63 @@ 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 (!ft(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
  );
1007
- const a = await this.assertPopMatchesBtcWallet(r), c = r.btcPopSignature, d = o.map(
1008
- (u) => this.resolvePayoutScriptPubKey(
985
+ const a = await this.assertPopMatchesBtcWallet(r), c = r.btcPopSignature, u = o.map(
986
+ (h) => this.resolvePayoutScriptPubKey(
1009
987
  a,
1010
- u.depositorPayoutBtcAddress
988
+ h.depositorPayoutBtcAddress
1011
989
  )
1012
990
  ), l = [];
1013
- for (const u of o) {
1014
- const h = B(
1015
- u.depositorSignedPeginTx
1016
- ), v = G(h), I = await pt(
1017
- T(v),
991
+ for (const h of o) {
992
+ const d = v(
993
+ h.depositorSignedPeginTx
994
+ ), B = z(d), A = await pt(
995
+ T(B),
1018
996
  T(i)
1019
- ), A = B(I);
1020
- if (await this.checkVaultExists(A))
997
+ ), C = v(A);
998
+ if (await this.checkVaultExists(C))
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: ${C}, peginTxHash: ${B}). 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: C, peginTxHash: B });
1025
1003
  }
1026
1004
  const m = this.config.publicClient;
1027
- let w;
1005
+ let b;
1028
1006
  try {
1029
- w = await m.readContract({
1007
+ b = await m.readContract({
1030
1008
  address: this.config.vaultContracts.btcVaultRegistry,
1031
- abi: O,
1009
+ abi: I,
1032
1010
  functionName: "getPegInFee",
1033
1011
  args: [e]
1034
1012
  });
1035
- } catch (u) {
1013
+ } catch (h) {
1036
1014
  throw new Error(
1037
1015
  "Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct.",
1038
- { cause: u }
1016
+ { cause: h }
1039
1017
  );
1040
1018
  }
1041
- const P = w * BigInt(o.length), g = await this.resolveMaxAcceptableCommissionBps(
1019
+ const w = b * BigInt(o.length), g = await this.resolveMaxAcceptableCommissionBps(
1042
1020
  e,
1043
1021
  t.quotedCommissionBps
1044
- ), f = B(
1022
+ ), f = v(
1045
1023
  r.depositorBtcPubkey
1046
- ), k = B(s), S = o.map((u, h) => ({
1024
+ ), k = v(s), S = o.map((h, d) => ({
1047
1025
  depositorBtcPubKey: f,
1048
1026
  btcPopSignature: c,
1049
1027
  unsignedPrePeginTx: k,
1050
- depositorSignedPeginTx: B(
1051
- u.depositorSignedPeginTx
1028
+ depositorSignedPeginTx: v(
1029
+ h.depositorSignedPeginTx
1052
1030
  ),
1053
- hashlock: u.hashlock,
1054
- htlcVout: u.htlcVout,
1055
- referralCode: hn,
1056
- depositorPayoutBtcAddress: d[h],
1057
- depositorWotsPkHash: u.depositorWotsPkHash
1058
- })), E = ft({
1059
- abi: O,
1031
+ hashlock: h.hashlock,
1032
+ htlcVout: h.htlcVout,
1033
+ referralCode: Dt,
1034
+ depositorPayoutBtcAddress: u[d],
1035
+ depositorWotsPkHash: h.depositorWotsPkHash
1036
+ })), E = tt({
1037
+ abi: I,
1060
1038
  functionName: "submitPeginRequestBatch",
1061
1039
  args: [
1062
1040
  i,
@@ -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: w,
1074
1052
  account: this.config.ethWallet.account.address
1075
1053
  });
1076
- } catch (u) {
1077
- C(u);
1054
+ } catch (h) {
1055
+ H(h);
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: w,
1085
1063
  account: this.config.ethWallet.account,
1086
1064
  chain: this.config.ethChain,
1087
1065
  gas: p
1088
1066
  });
1089
- } catch (u) {
1090
- C(u);
1067
+ } catch (h) {
1068
+ H(h);
1091
1069
  }
1092
1070
  const y = await xt({
1093
1071
  publicClient: m,
1094
1072
  walletAddress: this.config.ethWallet.account.address,
1095
- hash: b,
1096
- timeout: Ot
1073
+ hash: P,
1074
+ timeout: At
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: I,
1115
1093
  functionName: "getVaultProviderCommission",
1116
1094
  args: [t]
1117
1095
  });
@@ -1128,12 +1106,12 @@ class On {
1128
1106
  );
1129
1107
  return Math.min(
1130
1108
  e + W,
1131
- At
1109
+ rt
1132
1110
  );
1133
1111
  }
1134
1112
  return Math.min(
1135
1113
  s + W,
1136
- At
1114
+ rt
1137
1115
  );
1138
1116
  }
1139
1117
  /**
@@ -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: I,
1156
1134
  functionName: "getBtcVaultBasicInfo",
1157
1135
  args: [t]
1158
- })).depositor !== Qt;
1136
+ })).depositor !== Jt;
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 === ce && un(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
- const s = bt(this.config.btcNetwork);
1165
+ const s = Pt(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: cn(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.`
@@ -1247,13 +1225,67 @@ class On {
1247
1225
  return this.config.vaultContracts.btcVaultRegistry;
1248
1226
  }
1249
1227
  }
1228
+ const dn = 80, gn = 250, fn = 300, pn = 22, Gt = "ab";
1229
+ function mn(n, t) {
1230
+ const e = Gt.repeat(fn), s = T(n).toLowerCase(), o = t.toString(16).padStart(8, "0"), r = `${s}${o}`, i = e.slice(r.length);
1231
+ return `0x${r}${i}`;
1232
+ }
1233
+ function bn(n, t) {
1234
+ const e = (s) => `0x${Gt.repeat(s)}`;
1235
+ return {
1236
+ depositorBtcPubKey: e(32),
1237
+ btcPopSignature: e(dn),
1238
+ unsignedPrePeginTx: e(gn),
1239
+ depositorSignedPeginTx: mn(
1240
+ n,
1241
+ t
1242
+ ),
1243
+ hashlock: e(32),
1244
+ htlcVout: t,
1245
+ referralCode: Dt,
1246
+ depositorPayoutBtcAddress: e(pn),
1247
+ depositorWotsPkHash: e(32)
1248
+ };
1249
+ }
1250
+ async function Un(n) {
1251
+ const { publicClient: t, btcVaultRegistry: e, depositorEthAddress: s, vaultProvider: o, batchSize: r } = n;
1252
+ if (r <= 0)
1253
+ throw new Error(
1254
+ `estimateSubmitPeginRequestBatchGas requires batchSize >= 1 (received ${r})`
1255
+ );
1256
+ const a = await t.readContract({
1257
+ address: e,
1258
+ abi: I,
1259
+ functionName: "getPegInFee",
1260
+ args: [o]
1261
+ }) * BigInt(r), c = Array.from(
1262
+ { length: r },
1263
+ (l, m) => bn(s, m)
1264
+ ), u = tt({
1265
+ abi: I,
1266
+ functionName: "submitPeginRequestBatch",
1267
+ args: [
1268
+ s,
1269
+ o,
1270
+ rt,
1271
+ c
1272
+ ]
1273
+ });
1274
+ return t.estimateGas({
1275
+ to: e,
1276
+ data: u,
1277
+ value: a,
1278
+ account: s
1279
+ });
1280
+ }
1250
1281
  export {
1251
- On as P,
1252
- Ie as V,
1253
- Se as a,
1282
+ Rn as P,
1283
+ Se as V,
1284
+ ve as a,
1254
1285
  Be as b,
1255
- sn as c,
1256
- nn as d,
1257
- Oe as e
1286
+ nn as c,
1287
+ en as d,
1288
+ Un as e,
1289
+ Ie as f
1258
1290
  };
1259
- //# sourceMappingURL=PeginManager-C1en2vwr.js.map
1291
+ //# sourceMappingURL=PeginManager-DXrfY4d6.js.map