@babylonlabs-io/ts-sdk 0.15.3 → 0.16.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 (33) hide show
  1. package/dist/{errors-UqmtfBtv.js → errors-BEUjAw2k.js} +363 -453
  2. package/dist/errors-BEUjAw2k.js.map +1 -0
  3. package/dist/errors-DnMc1lLU.cjs +2 -0
  4. package/dist/errors-DnMc1lLU.cjs.map +1 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +31 -33
  7. package/dist/tbv/core/index.cjs +1 -1
  8. package/dist/tbv/core/index.js +33 -35
  9. package/dist/tbv/core/utils/transaction/index.d.ts +0 -1
  10. package/dist/tbv/core/utils/transaction/index.d.ts.map +1 -1
  11. package/dist/tbv/index.cjs +1 -1
  12. package/dist/tbv/index.js +33 -35
  13. package/dist/tbv/integrations/aave/clients/abis/AaveSpoke.abi.json.d.ts +15 -25
  14. package/dist/tbv/integrations/aave/clients/index.d.ts +1 -1
  15. package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
  16. package/dist/tbv/integrations/aave/clients/spoke.d.ts +59 -26
  17. package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
  18. package/dist/tbv/integrations/aave/constants.d.ts +0 -35
  19. package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
  20. package/dist/tbv/integrations/aave/index.cjs +1 -1
  21. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  22. package/dist/tbv/integrations/aave/index.d.ts +2 -2
  23. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  24. package/dist/tbv/integrations/aave/index.js +201 -190
  25. package/dist/tbv/integrations/aave/index.js.map +1 -1
  26. package/package.json +3 -3
  27. package/dist/errors-BZc3Urez.cjs +0 -2
  28. package/dist/errors-BZc3Urez.cjs.map +0 -1
  29. package/dist/errors-UqmtfBtv.js.map +0 -1
  30. package/dist/tbv/core/utils/transaction/__tests__/createSplitTransaction.test.d.ts +0 -5
  31. package/dist/tbv/core/utils/transaction/__tests__/createSplitTransaction.test.d.ts.map +0 -1
  32. package/dist/tbv/core/utils/transaction/createSplitTransaction.d.ts +0 -106
  33. package/dist/tbv/core/utils/transaction/createSplitTransaction.d.ts.map +0 -1
@@ -1,13 +1,13 @@
1
- var de = Object.defineProperty;
2
- var fe = (e, t, n) => t in e ? de(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var p = (e, t, n) => fe(e, typeof t != "symbol" ? t + "" : t, n);
4
- import * as pe from "bitcoinjs-lib";
5
- import { script as ge, Transaction as J, address as be, Psbt as bt } from "bitcoinjs-lib";
6
- import { Buffer as S } from "buffer";
7
- import { P as ye, y as xe, D as Mt, M as Ht, B as we, T as me, H as Nt, G as yt, u as B, b as Pe, A as Te, E as ve, a as ke, d as He, e as Ee, f as Ie, s as U, q as Se, x as Et, h as It, i as St, r as Be } from "./challengeAssert-C5DQSUnp.js";
8
- import { createPublicClient as lt, http as ht, encodeFunctionData as Bt, zeroAddress as Ae } from "viem";
1
+ var he = Object.defineProperty;
2
+ var de = (e, t, n) => t in e ? he(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var p = (e, t, n) => de(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import * as fe from "bitcoinjs-lib";
5
+ import { script as pe, Transaction as gt, Psbt as vt } from "bitcoinjs-lib";
6
+ import { Buffer as W } from "buffer";
7
+ import { createPublicClient as ut, http as lt, encodeFunctionData as kt, zeroAddress as ye } from "viem";
8
+ import { P as be, y as ge, D as Mt, M as Ht, B as xe, T as we, u as B, b as me, A as Pe, G as It, E as Te, a as ve, d as ke, e as He, f as Ie, s as C, H as Ee, q as Be, x as Et, h as Bt, i as St, r as Se } from "./challengeAssert-C5DQSUnp.js";
9
9
  import { deriveVaultId as At } from "@babylonlabs-io/babylon-tbv-rust-wasm";
10
- function $e(e, t, n, s) {
10
+ function Ae(e, t, n, s) {
11
11
  if (!Number.isInteger(s) || s < 1)
12
12
  throw new Error(
13
13
  `Invalid numOutputs: expected a positive integer, got ${s}`
@@ -15,8 +15,8 @@ function $e(e, t, n, s) {
15
15
  if (e.length === 0)
16
16
  throw new Error("Insufficient funds: no UTXOs available");
17
17
  const o = e.filter((l) => {
18
- const h = S.from(l.scriptPubKey, "hex");
19
- return !!ge.decompile(h);
18
+ const h = W.from(l.scriptPubKey, "hex");
19
+ return !!pe.decompile(h);
20
20
  });
21
21
  if (o.length === 0)
22
22
  throw new Error(
@@ -26,20 +26,20 @@ function $e(e, t, n, s) {
26
26
  let a = 0n, c = 0n;
27
27
  for (const l of r) {
28
28
  i.push(l), a += BigInt(l.value);
29
- const h = i.length * ye, u = s * Ht, d = h + u + me;
30
- if (c = BigInt(Math.ceil(d * n)) + BigInt(xe(n)), a - t - c > Mt) {
31
- const g = BigInt(
29
+ const h = i.length * be, u = s * Ht, d = h + u + we;
30
+ if (c = BigInt(Math.ceil(d * n)) + BigInt(ge(n)), a - t - c > Mt) {
31
+ const y = BigInt(
32
32
  Math.ceil(Ht * n)
33
33
  );
34
- c += g;
34
+ c += y;
35
35
  }
36
36
  if (a >= t + c) {
37
- const g = a - t - c;
37
+ const y = a - t - c;
38
38
  return {
39
39
  selectedUTXOs: i,
40
40
  totalValue: a,
41
41
  fee: c,
42
- changeAmount: g
42
+ changeAmount: y
43
43
  };
44
44
  }
45
45
  }
@@ -47,106 +47,18 @@ function $e(e, t, n, s) {
47
47
  `Insufficient funds: need ${t + c} sats (${t} pegin + ${c} fee), have ${a} sats`
48
48
  );
49
49
  }
50
- function Yn(e) {
50
+ function Jn(e) {
51
51
  return e > Mt;
52
52
  }
53
- function Qn() {
54
- return we;
53
+ function Yn() {
54
+ return xe;
55
55
  }
56
- function dt(e) {
56
+ function ht(e) {
57
57
  const t = e.startsWith("0x") ? e.slice(2) : e;
58
- return `0x${J.fromHex(t).getId()}`;
59
- }
60
- function ts(e, t, n) {
61
- if (Nt(), e.length === 0)
62
- throw new Error("No input UTXOs provided for split transaction");
63
- if (t.length === 0)
64
- throw new Error("No outputs specified for split transaction");
65
- for (const c of t)
66
- if (c.amount <= 0n)
67
- throw new Error(
68
- `Invalid output amount for ${c.address}: ${c.amount} satoshis. Amount must be greater than zero.`
69
- );
70
- const s = yt(n), o = new J();
71
- o.version = 2;
72
- for (const c of e) {
73
- const l = S.from(c.txid, "hex").reverse();
74
- o.addInput(l, c.vout);
75
- }
76
- const r = [];
77
- for (let c = 0; c < t.length; c++) {
78
- const l = t[c];
79
- let h;
80
- try {
81
- h = be.toOutputScript(l.address, s);
82
- } catch (u) {
83
- throw new Error(
84
- `Failed to decode address "${l.address}": ${u instanceof Error ? u.message : String(u)}`
85
- );
86
- }
87
- o.addOutput(h, Number(l.amount)), r.push({
88
- txid: "",
89
- // Will be set after txid calculation
90
- vout: c,
91
- value: Number(l.amount),
92
- scriptPubKey: h.toString("hex")
93
- });
94
- }
95
- const i = o.toHex(), a = o.getId();
96
- for (const c of r)
97
- c.txid = a;
98
- return {
99
- txHex: i,
100
- txid: a,
101
- outputs: r
102
- };
58
+ return `0x${gt.fromHex(t).getId()}`;
103
59
  }
104
- function es(e, t, n) {
105
- const s = J.fromHex(e), o = new bt();
106
- if (o.setVersion(s.version), o.setLocktime(s.locktime), !S.isBuffer(n) || n.length !== 32)
107
- throw new Error(
108
- `Invalid publicKeyNoCoord: expected 32-byte Buffer (x-only pubkey), got ${S.isBuffer(n) ? `${n.length}-byte Buffer` : typeof n}`
109
- );
110
- if (t.length !== s.ins.length)
111
- throw new Error(
112
- `UTXO count mismatch: transaction has ${s.ins.length} input${s.ins.length !== 1 ? "s" : ""}, but ${t.length} UTXO${t.length !== 1 ? "s were" : " was"} provided`
113
- );
114
- for (let r = 0; r < s.ins.length; r++) {
115
- const i = s.ins[r], a = t[r];
116
- if (!a)
117
- throw new Error(`Missing UTXO data for input ${r}`);
118
- const c = S.from(i.hash).reverse().toString("hex"), l = i.index;
119
- if (a.txid !== c || a.vout !== l)
120
- throw new Error(
121
- `Input ${r} outpoint mismatch: transaction expects ${c}:${l}, but UTXO ${a.txid}:${a.vout} was provided. Ensure inputs array matches the order used in createSplitTransaction().`
122
- );
123
- const h = S.from(a.scriptPubKey, "hex");
124
- if (!(h.length === 34 && h[0] === 81 && // OP_1 (witness version 1)
125
- h[1] === 32))
126
- throw new Error(
127
- `Input ${r} must be P2TR (Taproot). createSplitTransactionPsbt() requires P2TR inputs because it uses tapInternalKey for Taproot signing. ScriptPubKey: ${a.scriptPubKey.substring(0, 20)}...`
128
- );
129
- const d = {
130
- script: S.from(a.scriptPubKey, "hex"),
131
- value: a.value
132
- };
133
- o.addInput({
134
- hash: i.hash,
135
- index: i.index,
136
- sequence: i.sequence,
137
- witnessUtxo: d,
138
- tapInternalKey: n
139
- });
140
- }
141
- for (const r of s.outs)
142
- o.addOutput({
143
- script: r.script,
144
- value: r.value
145
- });
146
- return o.toHex();
147
- }
148
- var rt = /* @__PURE__ */ ((e) => (e.P2PKH = "P2PKH", e.P2SH = "P2SH", e.P2WPKH = "P2WPKH", e.P2WSH = "P2WSH", e.P2TR = "P2TR", e.UNKNOWN = "UNKNOWN", e))(rt || {});
149
- function Ue(e) {
60
+ var ot = /* @__PURE__ */ ((e) => (e.P2PKH = "P2PKH", e.P2SH = "P2SH", e.P2WPKH = "P2WPKH", e.P2WSH = "P2WSH", e.P2TR = "P2TR", e.UNKNOWN = "UNKNOWN", e))(ot || {});
61
+ function Ce(e) {
150
62
  const t = e.length;
151
63
  return t === 25 && e[0] === 118 && // OP_DUP
152
64
  e[1] === 169 && // OP_HASH160
@@ -160,16 +72,16 @@ function Ue(e) {
160
72
  e[1] === 32 ? "P2TR" : "UNKNOWN";
161
73
  }
162
74
  function Fe(e, t) {
163
- const n = S.from(e.scriptPubKey, "hex"), s = Ue(n);
75
+ const n = W.from(e.scriptPubKey, "hex"), s = Ce(n);
164
76
  switch (s) {
165
- case rt.P2WPKH:
77
+ case ot.P2WPKH:
166
78
  return {
167
79
  witnessUtxo: {
168
80
  script: n,
169
81
  value: e.value
170
82
  }
171
83
  };
172
- case rt.P2WSH: {
84
+ case ot.P2WSH: {
173
85
  if (!e.witnessScript)
174
86
  throw new Error("Missing witnessScript for P2WSH input");
175
87
  return {
@@ -177,10 +89,10 @@ function Fe(e, t) {
177
89
  script: n,
178
90
  value: e.value
179
91
  },
180
- witnessScript: S.from(e.witnessScript, "hex")
92
+ witnessScript: W.from(e.witnessScript, "hex")
181
93
  };
182
94
  }
183
- case rt.P2TR: {
95
+ case ot.P2TR: {
184
96
  if (t && t.length !== 32)
185
97
  throw new Error(
186
98
  `Invalid tapInternalKey length: expected 32 bytes, got ${t.length}`
@@ -198,7 +110,7 @@ function Fe(e, t) {
198
110
  throw new Error(`Unsupported script type: ${s}`);
199
111
  }
200
112
  }
201
- function xt(e, t) {
113
+ function yt(e, t) {
202
114
  if (!Number.isInteger(t) || t < 1)
203
115
  throw new Error(`inputCount must be a positive integer, got ${t}`);
204
116
  return {
@@ -210,22 +122,22 @@ function xt(e, t) {
210
122
  }))
211
123
  };
212
124
  }
213
- const Ce = 21e6 * 1e8, Xt = 1e4;
214
- function qt(e) {
215
- return Number.isInteger(e) && e > 0 && e <= Ce;
125
+ const Ue = 21e6 * 1e8, Nt = 1e4;
126
+ function Xt(e) {
127
+ return Number.isInteger(e) && e > 0 && e <= Ue;
216
128
  }
217
- function Oe(e) {
218
- return Number.isInteger(e) && e > 0 && e <= Xt;
129
+ function $e(e) {
130
+ return Number.isInteger(e) && e > 0 && e <= Nt;
219
131
  }
220
- function Gt(e, t) {
132
+ function qt(e, t) {
221
133
  return !Number.isInteger(e) || e < 0 ? !1 : t === void 0 || e < t;
222
134
  }
223
- const Le = {
135
+ const Oe = {
224
136
  mainnet: "https://mempool.space/api",
225
137
  testnet: "https://mempool.space/testnet/api",
226
138
  signet: "https://mempool.space/signet/api"
227
139
  };
228
- async function at(e, t) {
140
+ async function it(e, t) {
229
141
  try {
230
142
  const n = await fetch(e, t);
231
143
  if (!n.ok) {
@@ -240,7 +152,7 @@ async function at(e, t) {
240
152
  throw n instanceof Error ? new Error(`Failed to fetch from mempool API: ${n.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
241
153
  }
242
154
  }
243
- async function _e(e, t) {
155
+ async function Le(e, t) {
244
156
  try {
245
157
  const n = await fetch(`${t}/tx`, {
246
158
  method: "POST",
@@ -266,10 +178,10 @@ async function _e(e, t) {
266
178
  throw n instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${n.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
267
179
  }
268
180
  }
269
- async function Re(e, t) {
270
- return at(`${t}/tx/${e}`);
181
+ async function _e(e, t) {
182
+ return it(`${t}/tx/${e}`);
271
183
  }
272
- async function ns(e, t) {
184
+ async function Qn(e, t) {
273
185
  try {
274
186
  const n = await fetch(`${t}/tx/${e}/hex`);
275
187
  if (!n.ok) {
@@ -283,14 +195,14 @@ async function ns(e, t) {
283
195
  throw n instanceof Error ? new Error(`Failed to get transaction hex for ${e}: ${n.message}`) : new Error(`Failed to get transaction hex for ${e}: Unknown error`);
284
196
  }
285
197
  }
286
- async function We(e, t, n) {
287
- const s = await Re(e, n);
288
- if (!Gt(t, s.vout.length))
198
+ async function Re(e, t, n) {
199
+ const s = await _e(e, n);
200
+ if (!qt(t, s.vout.length))
289
201
  throw new Error(
290
202
  `Invalid vout ${t} for transaction ${e} (has ${s.vout.length} outputs)`
291
203
  );
292
204
  const o = s.vout[t];
293
- if (!qt(o.value))
205
+ if (!Xt(o.value))
294
206
  throw new Error(`Invalid UTXO value ${o.value} for ${e}:${t}`);
295
207
  return {
296
208
  txid: e,
@@ -299,17 +211,17 @@ async function We(e, t, n) {
299
211
  scriptPubKey: o.scriptpubkey
300
212
  };
301
213
  }
302
- async function ss(e, t) {
214
+ async function ts(e, t) {
303
215
  try {
304
- const n = await at(`${t}/address/${e}/utxo`), s = await at(`${t}/v1/validate-address/${e}`);
216
+ const n = await it(`${t}/address/${e}/utxo`), s = await it(`${t}/v1/validate-address/${e}`);
305
217
  if (!s.isvalid)
306
218
  throw new Error(
307
219
  `Invalid Bitcoin address: ${e}. Mempool API validation failed.`
308
220
  );
309
221
  for (const r of n) {
310
- if (!Gt(r.vout))
222
+ if (!qt(r.vout))
311
223
  throw new Error(`Invalid vout ${r.vout} for ${r.txid}`);
312
- if (!qt(r.value))
224
+ if (!Xt(r.value))
313
225
  throw new Error(
314
226
  `Invalid UTXO value ${r.value} for ${r.txid}:${r.vout}`
315
227
  );
@@ -329,13 +241,13 @@ async function ss(e, t) {
329
241
  );
330
242
  }
331
243
  }
332
- function os(e) {
333
- return Le[e];
244
+ function es(e) {
245
+ return Oe[e];
334
246
  }
335
- async function rs(e, t) {
336
- return at(`${t}/address/${e}/txs`);
247
+ async function ns(e, t) {
248
+ return it(`${t}/address/${e}/txs`);
337
249
  }
338
- async function is(e) {
250
+ async function ss(e) {
339
251
  const t = await fetch(`${e}/v1/fees/recommended`);
340
252
  if (!t.ok)
341
253
  throw new Error(
@@ -349,9 +261,9 @@ async function is(e) {
349
261
  "minimumFee"
350
262
  ];
351
263
  for (const o of s)
352
- if (!Oe(n[o]))
264
+ if (!$e(n[o]))
353
265
  throw new Error(
354
- `Invalid fee rate ${o}=${n[o]} from mempool API: expected a positive number ≤ ${Xt}`
266
+ `Invalid fee rate ${o}=${n[o]} from mempool API: expected a positive number ≤ ${Nt}`
355
267
  );
356
268
  if (n.minimumFee > n.economyFee || n.economyFee > n.hourFee || n.hourFee > n.halfHourFee || n.halfHourFee > n.fastestFee)
357
269
  throw new Error(
@@ -682,7 +594,7 @@ const j = [
682
594
  // InvalidPeginFee(uint256,uint256)
683
595
  "0x979f4518": "Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction."
684
596
  };
685
- function mt(e) {
597
+ function xt(e) {
686
598
  if (!e || typeof e != "object") return;
687
599
  const t = e;
688
600
  if (typeof t.data == "string" && t.data.startsWith("0x"))
@@ -701,22 +613,22 @@ function mt(e) {
701
613
  if (i)
702
614
  return i[1];
703
615
  }
704
- function as(e) {
705
- const t = mt(e);
616
+ function os(e) {
617
+ const t = xt(e);
706
618
  if (t) {
707
619
  const n = t.substring(0, 10);
708
620
  return q[t] ?? q[n];
709
621
  }
710
622
  }
711
- function cs(e) {
712
- const t = mt(e);
623
+ function rs(e) {
624
+ const t = xt(e);
713
625
  if (t === void 0) return !1;
714
626
  const n = t.substring(0, 10);
715
627
  return t in q || n in q;
716
628
  }
717
629
  function M(e) {
718
630
  console.error("[Contract Error] Raw error:", e);
719
- const t = mt(e);
631
+ const t = xt(e);
720
632
  if (console.error("[Contract Error] Extracted error data:", t), t) {
721
633
  const s = t.substring(0, 10), o = q[t] ?? q[s];
722
634
  if (o)
@@ -736,18 +648,18 @@ function M(e) {
736
648
  }
737
649
  throw e instanceof Error ? (console.error("[Contract Error] Unhandled error:", e.message), e) : new Error(`Contract call failed: ${String(e)}`);
738
650
  }
739
- const Ve = 0;
740
- function Ke(e, t, n, s) {
651
+ const We = 0;
652
+ function Ve(e, t, n, s) {
741
653
  const o = n == null ? void 0 : n[`${e}:${t}`];
742
654
  return o ? Promise.resolve({
743
655
  txid: e,
744
656
  vout: t,
745
657
  value: o.value,
746
658
  scriptPubKey: o.scriptPubKey
747
- }) : We(e, t, s);
659
+ }) : Re(e, t, s);
748
660
  }
749
- const $t = 12e4;
750
- class us {
661
+ const Ct = 12e4;
662
+ class is {
751
663
  /**
752
664
  * Creates a new PeginManager instance.
753
665
  *
@@ -798,25 +710,25 @@ class us {
798
710
  councilQuorum: t.councilQuorum,
799
711
  councilSize: t.councilSize,
800
712
  network: this.config.btcNetwork
801
- }, l = await Pe(c), h = $e(
713
+ }, l = await me(c), h = Ae(
802
714
  [...t.availableUTXOs],
803
715
  l.totalOutputValue,
804
716
  t.mempoolFeeRate,
805
- Te(l.htlcValues.length)
806
- ), u = yt(this.config.btcNetwork), d = ve({
717
+ Pe(l.htlcValues.length)
718
+ ), u = It(this.config.btcNetwork), d = Te({
807
719
  unfundedTxHex: l.psbtHex,
808
720
  selectedUTXOs: h.selectedUTXOs,
809
721
  changeAddress: t.changeAddress,
810
722
  changeAmount: h.changeAmount,
811
723
  network: u
812
- }), y = B(dt(d)), g = [], x = [], P = [];
724
+ }), g = B(ht(d)), y = [], x = [], P = [];
813
725
  for (let f = 0; f < t.hashlocks.length; f++) {
814
- const w = await ke({
726
+ const w = await ve({
815
727
  prePeginParams: c,
816
728
  timelockPegin: t.timelockPegin,
817
729
  fundedPrePeginTxHex: d,
818
730
  htlcVout: f
819
- }), v = await He({
731
+ }), v = await ke({
820
732
  peginTxHex: w.txHex,
821
733
  fundedPrePeginTxHex: d,
822
734
  depositorPubkey: s,
@@ -827,8 +739,8 @@ class us {
827
739
  timelockRefund: t.timelockRefund,
828
740
  network: this.config.btcNetwork
829
741
  });
830
- g.push(w), x.push(v.psbtHex), P.push(
831
- xt(n, 1)
742
+ y.push(w), x.push(v.psbtHex), P.push(
743
+ yt(n, 1)
832
744
  );
833
745
  }
834
746
  const m = await this.signPsbtsWithFallback(
@@ -836,7 +748,7 @@ class us {
836
748
  P
837
749
  ), b = [];
838
750
  for (let f = 0; f < m.length; f++) {
839
- const w = Ee(
751
+ const w = He(
840
752
  m[f],
841
753
  s
842
754
  ), v = Ie(m[f]);
@@ -844,14 +756,14 @@ class us {
844
756
  htlcVout: f,
845
757
  htlcValue: l.htlcValues[f],
846
758
  peginTxHex: v,
847
- peginTxid: g[f].txid,
759
+ peginTxid: y[f].txid,
848
760
  peginInputSignature: w,
849
- vaultScriptPubKey: g[f].vaultScriptPubKey
761
+ vaultScriptPubKey: y[f].vaultScriptPubKey
850
762
  });
851
763
  }
852
764
  return {
853
765
  fundedPrePeginTxHex: d,
854
- prePeginTxid: y,
766
+ prePeginTxid: g,
855
767
  unsignedPrePeginTxHex: l.psbtHex,
856
768
  perVault: b,
857
769
  selectedUTXOs: h.selectedUTXOs,
@@ -904,36 +816,36 @@ class us {
904
816
  * @throws Error if signing or broadcasting fails
905
817
  */
906
818
  async signAndBroadcast(t) {
907
- const { fundedPrePeginTxHex: n, depositorBtcPubkey: s } = t, o = n.startsWith("0x") ? n.slice(2) : n, r = J.fromHex(o);
819
+ const { fundedPrePeginTxHex: n, depositorBtcPubkey: s } = t, o = n.startsWith("0x") ? n.slice(2) : n, r = gt.fromHex(o);
908
820
  if (r.ins.length === 0)
909
821
  throw new Error("Transaction has no inputs");
910
- const i = new bt();
822
+ const i = new vt();
911
823
  i.setVersion(r.version), i.setLocktime(r.locktime);
912
824
  const a = s.startsWith("0x") ? s.slice(2) : s;
913
825
  if (a.length !== 64 || !/^[0-9a-fA-F]+$/.test(a))
914
826
  throw new Error(
915
827
  "Invalid depositorBtcPubkey: expected 64 hex characters (x-only pubkey)"
916
828
  );
917
- const c = S.from(a, "hex");
829
+ const c = W.from(a, "hex");
918
830
  if (c.length !== 32)
919
831
  throw new Error(
920
832
  `Invalid depositorBtcPubkey length: expected 32 bytes, got ${c.length}`
921
833
  );
922
834
  const l = this.config.mempoolApiUrl, h = r.ins.map((b) => {
923
- const f = S.from(b.hash).reverse().toString("hex"), w = b.index;
924
- return Ke(f, w, t.localPrevouts, l).then(
835
+ const f = W.from(b.hash).reverse().toString("hex"), w = b.index;
836
+ return Ve(f, w, t.localPrevouts, l).then(
925
837
  (v) => ({ input: b, utxoData: v, txid: f, vout: w })
926
838
  );
927
839
  }), u = await Promise.all(h), d = u.reduce(
928
840
  (b, f) => b + BigInt(f.utxoData.value),
929
841
  0n
930
- ), y = r.outs.reduce(
842
+ ), g = r.outs.reduce(
931
843
  (b, f) => b + BigInt(f.value),
932
844
  0n
933
845
  );
934
- if (d < y)
846
+ if (d < g)
935
847
  throw new Error(
936
- `UTXO value mismatch: total input value (${d} sat) is less than total output value (${y} sat). This may indicate the mempool API returned manipulated UTXO data.`
848
+ `UTXO value mismatch: total input value (${d} sat) is less than total output value (${g} sat). This may indicate the mempool API returned manipulated UTXO data.`
937
849
  );
938
850
  for (const { input: b, utxoData: f, txid: w, vout: v } of u) {
939
851
  const T = Fe(
@@ -955,7 +867,7 @@ class us {
955
867
  script: b.script,
956
868
  value: b.value
957
869
  });
958
- const g = await this.config.btcWallet.signPsbt(i.toHex()), x = bt.fromHex(g);
870
+ const y = await this.config.btcWallet.signPsbt(i.toHex()), x = vt.fromHex(y);
959
871
  try {
960
872
  x.finalizeAllInputs();
961
873
  } catch (b) {
@@ -967,7 +879,7 @@ class us {
967
879
  );
968
880
  }
969
881
  const P = x.extractTransaction().toHex();
970
- return await _e(P, l);
882
+ return await Le(P, l);
971
883
  }
972
884
  /**
973
885
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -1001,24 +913,24 @@ class us {
1001
913
  } = t;
1002
914
  if (!this.config.ethWallet.account)
1003
915
  throw new Error("Ethereum wallet account not found");
1004
- const d = this.config.ethWallet.account.address, y = await this.resolvePopSignature(
916
+ const d = this.config.ethWallet.account.address, g = await this.resolvePopSignature(
1005
917
  d,
1006
918
  u
1007
919
  );
1008
920
  c && await c();
1009
- const g = U(n), x = U(s), P = U(o), m = await this.resolvePayoutScriptPubKey(
921
+ const y = C(n), x = C(s), P = C(o), m = await this.resolvePayoutScriptPubKey(
1010
922
  l
1011
- ), b = dt(P), f = await At(
923
+ ), b = ht(P), f = await At(
1012
924
  B(b),
1013
925
  B(d)
1014
- ), w = U(f);
926
+ ), w = C(f);
1015
927
  if (await this.checkVaultExists(w))
1016
928
  throw new Error(
1017
929
  `Vault already exists (ID: ${w}, peginTxHash: ${b}). 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.`
1018
930
  );
1019
- const T = lt({
931
+ const T = ut({
1020
932
  chain: this.config.ethChain,
1021
- transport: ht()
933
+ transport: lt()
1022
934
  });
1023
935
  let H;
1024
936
  try {
@@ -1033,13 +945,13 @@ class us {
1033
945
  "Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct."
1034
946
  );
1035
947
  }
1036
- const E = Bt({
948
+ const I = kt({
1037
949
  abi: j,
1038
950
  functionName: "submitPeginRequest",
1039
951
  args: [
1040
952
  d,
1041
- g,
1042
953
  y,
954
+ g,
1043
955
  x,
1044
956
  P,
1045
957
  r,
@@ -1049,43 +961,43 @@ class us {
1049
961
  h
1050
962
  ]
1051
963
  });
1052
- let I;
964
+ let E;
1053
965
  try {
1054
- I = await T.estimateGas({
966
+ E = await T.estimateGas({
1055
967
  to: this.config.vaultContracts.btcVaultRegistry,
1056
- data: E,
968
+ data: I,
1057
969
  value: H,
1058
970
  account: this.config.ethWallet.account.address
1059
971
  });
1060
- } catch (O) {
1061
- M(O);
972
+ } catch ($) {
973
+ M($);
1062
974
  }
1063
- let C;
975
+ let U;
1064
976
  try {
1065
- C = await this.config.ethWallet.sendTransaction({
977
+ U = await this.config.ethWallet.sendTransaction({
1066
978
  to: this.config.vaultContracts.btcVaultRegistry,
1067
- data: E,
979
+ data: I,
1068
980
  value: H,
1069
981
  account: this.config.ethWallet.account,
1070
982
  chain: this.config.ethChain,
1071
- gas: I
983
+ gas: E
1072
984
  });
1073
- } catch (O) {
1074
- M(O);
985
+ } catch ($) {
986
+ M($);
1075
987
  }
1076
- const D = await T.waitForTransactionReceipt({
1077
- hash: C,
1078
- timeout: $t
988
+ const K = await T.waitForTransactionReceipt({
989
+ hash: U,
990
+ timeout: Ct
1079
991
  });
1080
- return D.status === "reverted" && M(
992
+ return K.status === "reverted" && M(
1081
993
  new Error(
1082
- `Transaction reverted. Hash: ${C}. Check the transaction on block explorer for details.`
994
+ `Transaction reverted. Hash: ${U}. Check the transaction on block explorer for details.`
1083
995
  )
1084
996
  ), {
1085
- ethTxHash: D.transactionHash,
997
+ ethTxHash: K.transactionHash,
1086
998
  vaultId: w,
1087
999
  peginTxHash: b,
1088
- btcPopSignature: y
1000
+ btcPopSignature: g
1089
1001
  };
1090
1002
  }
1091
1003
  /**
@@ -1116,21 +1028,21 @@ class us {
1116
1028
  );
1117
1029
  const l = [];
1118
1030
  for (const b of s) {
1119
- const f = U(
1031
+ const f = C(
1120
1032
  b.depositorSignedPeginTx
1121
- ), w = dt(f), v = await At(
1033
+ ), w = ht(f), v = await At(
1122
1034
  B(w),
1123
1035
  B(i)
1124
- ), T = U(v);
1036
+ ), T = C(v);
1125
1037
  if (await this.checkVaultExists(T))
1126
1038
  throw new Error(
1127
1039
  `Vault already exists (ID: ${T}, peginTxHash: ${w}). To create a new vault, use different UTXOs or a different amount.`
1128
1040
  );
1129
1041
  l.push({ vaultId: T, peginTxHash: w });
1130
1042
  }
1131
- const h = lt({
1043
+ const h = ut({
1132
1044
  chain: this.config.ethChain,
1133
- transport: ht()
1045
+ transport: lt()
1134
1046
  });
1135
1047
  let u;
1136
1048
  try {
@@ -1145,28 +1057,28 @@ class us {
1145
1057
  "Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct."
1146
1058
  );
1147
1059
  }
1148
- const d = u * BigInt(s.length), y = s.map((b, f) => ({
1149
- depositorBtcPubKey: U(b.depositorBtcPubkey),
1060
+ const d = u * BigInt(s.length), g = s.map((b, f) => ({
1061
+ depositorBtcPubKey: C(b.depositorBtcPubkey),
1150
1062
  btcPopSignature: a,
1151
- unsignedPrePeginTx: U(b.unsignedPrePeginTx),
1152
- depositorSignedPeginTx: U(
1063
+ unsignedPrePeginTx: C(b.unsignedPrePeginTx),
1064
+ depositorSignedPeginTx: C(
1153
1065
  b.depositorSignedPeginTx
1154
1066
  ),
1155
1067
  hashlock: b.hashlock,
1156
1068
  htlcVout: b.htlcVout,
1157
- referralCode: Ve,
1069
+ referralCode: We,
1158
1070
  depositorPayoutBtcAddress: c[f],
1159
1071
  depositorWotsPkHash: b.depositorWotsPkHash
1160
- })), g = Bt({
1072
+ })), y = kt({
1161
1073
  abi: j,
1162
1074
  functionName: "submitPeginRequestBatch",
1163
- args: [i, n, y]
1075
+ args: [i, n, g]
1164
1076
  });
1165
1077
  let x;
1166
1078
  try {
1167
1079
  x = await h.estimateGas({
1168
1080
  to: this.config.vaultContracts.btcVaultRegistry,
1169
- data: g,
1081
+ data: y,
1170
1082
  value: d,
1171
1083
  account: this.config.ethWallet.account.address
1172
1084
  });
@@ -1177,7 +1089,7 @@ class us {
1177
1089
  try {
1178
1090
  P = await this.config.ethWallet.sendTransaction({
1179
1091
  to: this.config.vaultContracts.btcVaultRegistry,
1180
- data: g,
1092
+ data: y,
1181
1093
  value: d,
1182
1094
  account: this.config.ethWallet.account,
1183
1095
  chain: this.config.ethChain,
@@ -1188,7 +1100,7 @@ class us {
1188
1100
  }
1189
1101
  const m = await h.waitForTransactionReceipt({
1190
1102
  hash: P,
1191
- timeout: $t
1103
+ timeout: Ct
1192
1104
  });
1193
1105
  return m.status === "reverted" && M(
1194
1106
  new Error(
@@ -1208,15 +1120,15 @@ class us {
1208
1120
  */
1209
1121
  async checkVaultExists(t) {
1210
1122
  try {
1211
- return (await lt({
1123
+ return (await ut({
1212
1124
  chain: this.config.ethChain,
1213
- transport: ht()
1125
+ transport: lt()
1214
1126
  }).readContract({
1215
1127
  address: this.config.vaultContracts.btcVaultRegistry,
1216
1128
  abi: j,
1217
1129
  functionName: "getBTCVault",
1218
1130
  args: [t]
1219
- })).depositor !== Ae;
1131
+ })).depositor !== ye;
1220
1132
  } catch {
1221
1133
  return !1;
1222
1134
  }
@@ -1229,14 +1141,14 @@ class us {
1229
1141
  * wallet's public key to guard against a compromised wallet provider.
1230
1142
  */
1231
1143
  async resolvePayoutScriptPubKey(t) {
1232
- Nt();
1144
+ Ee();
1233
1145
  let n;
1234
1146
  if (t)
1235
1147
  n = t;
1236
1148
  else {
1237
1149
  n = await this.config.btcWallet.getAddress();
1238
1150
  const o = await this.config.btcWallet.getPublicKeyHex();
1239
- if (!Se(
1151
+ if (!Be(
1240
1152
  n,
1241
1153
  o,
1242
1154
  this.config.btcNetwork
@@ -1245,9 +1157,9 @@ class us {
1245
1157
  "The BTC address from your wallet does not match the wallet's public key. Please ensure your wallet is using a supported address type (Taproot or Native SegWit)."
1246
1158
  );
1247
1159
  }
1248
- const s = yt(this.config.btcNetwork);
1160
+ const s = It(this.config.btcNetwork);
1249
1161
  try {
1250
- return `0x${pe.address.toOutputScript(n, s).toString("hex")}`;
1162
+ return `0x${fe.address.toOutputScript(n, s).toString("hex")}`;
1251
1163
  } catch {
1252
1164
  throw new Error(
1253
1165
  `Invalid BTC payout address: "${n}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
@@ -1267,7 +1179,7 @@ class us {
1267
1179
  o,
1268
1180
  "bip322-simple"
1269
1181
  );
1270
- return r.startsWith("0x") ? r : `0x${S.from(r, "base64").toString("hex")}`;
1182
+ return r.startsWith("0x") ? r : `0x${W.from(r, "base64").toString("hex")}`;
1271
1183
  }
1272
1184
  /**
1273
1185
  * Gets the configured Bitcoin network.
@@ -1286,7 +1198,7 @@ class us {
1286
1198
  return this.config.vaultContracts.btcVaultRegistry;
1287
1199
  }
1288
1200
  }
1289
- class ls {
1201
+ class as {
1290
1202
  /**
1291
1203
  * Creates a new PayoutManager instance.
1292
1204
  *
@@ -1326,7 +1238,7 @@ class ls {
1326
1238
  const n = await this.config.btcWallet.getPublicKeyHex(), { depositorPubkey: s } = Et(
1327
1239
  n,
1328
1240
  t.depositorBtcPubkey
1329
- ), o = await It({
1241
+ ), o = await Bt({
1330
1242
  payoutTxHex: t.payoutTxHex,
1331
1243
  peginTxHex: t.peginTxHex,
1332
1244
  assertTxHex: t.assertTxHex,
@@ -1338,7 +1250,7 @@ class ls {
1338
1250
  network: this.config.network
1339
1251
  }), r = await this.config.btcWallet.signPsbt(
1340
1252
  o.psbtHex,
1341
- xt(n, 1)
1253
+ yt(n, 1)
1342
1254
  );
1343
1255
  return {
1344
1256
  signature: St(r, s),
@@ -1386,7 +1298,7 @@ class ls {
1386
1298
  c.depositorBtcPubkey
1387
1299
  );
1388
1300
  r.push(l);
1389
- const h = await It({
1301
+ const h = await Bt({
1390
1302
  payoutTxHex: c.payoutTxHex,
1391
1303
  peginTxHex: c.peginTxHex,
1392
1304
  assertTxHex: c.assertTxHex,
@@ -1397,7 +1309,7 @@ class ls {
1397
1309
  timelockPegin: c.timelockPegin,
1398
1310
  network: this.config.network
1399
1311
  });
1400
- s.push(h.psbtHex), o.push(xt(n, 1));
1312
+ s.push(h.psbtHex), o.push(yt(n, 1));
1401
1313
  }
1402
1314
  const i = await this.config.btcWallet.signPsbts(
1403
1315
  s,
@@ -1435,14 +1347,14 @@ class ls {
1435
1347
  * @throws Error if the largest output does not pay to the registered address
1436
1348
  */
1437
1349
  validatePayoutOutputs(t, n) {
1438
- if (!Be(n))
1350
+ if (!Se(n))
1439
1351
  throw new Error(
1440
1352
  "Invalid registeredPayoutScriptPubKey: not valid hex"
1441
1353
  );
1442
- const s = S.from(
1354
+ const s = W.from(
1443
1355
  B(n),
1444
1356
  "hex"
1445
- ), o = J.fromHex(B(t));
1357
+ ), o = gt.fromHex(B(t));
1446
1358
  if (o.outs.length === 0)
1447
1359
  throw new Error("Payout transaction has no outputs");
1448
1360
  if (!o.outs.reduce(
@@ -1462,7 +1374,7 @@ function V(e, t = "") {
1462
1374
  throw new Error(`${n}expected integer >= 0, got ${e}`);
1463
1375
  }
1464
1376
  }
1465
- function K(e, t, n = "") {
1377
+ function D(e, t, n = "") {
1466
1378
  const s = De(e), o = e == null ? void 0 : e.length, r = t !== void 0;
1467
1379
  if (!s || r && o !== t) {
1468
1380
  const i = n && `"${n}" `, a = r ? ` of length ${t}` : "", c = s ? `length=${o}` : `type=${typeof e}`;
@@ -1470,7 +1382,7 @@ function K(e, t, n = "") {
1470
1382
  }
1471
1383
  return e;
1472
1384
  }
1473
- function jt(e) {
1385
+ function Gt(e) {
1474
1386
  if (typeof e != "function" || typeof e.create != "function")
1475
1387
  throw new Error("Hash must wrapped by utils.createHasher");
1476
1388
  V(e.outputLen), V(e.blockLen);
@@ -1481,59 +1393,59 @@ function G(e, t = !0) {
1481
1393
  if (t && e.finished)
1482
1394
  throw new Error("Hash#digest() has already been called");
1483
1395
  }
1484
- function zt(e, t) {
1485
- K(e, void 0, "digestInto() output");
1396
+ function jt(e, t) {
1397
+ D(e, void 0, "digestInto() output");
1486
1398
  const n = t.outputLen;
1487
1399
  if (e.length < n)
1488
1400
  throw new Error('"digestInto() output" expected to be of length >=' + n);
1489
1401
  }
1490
- function Me(e) {
1402
+ function Ke(e) {
1491
1403
  return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
1492
1404
  }
1493
- function A(...e) {
1405
+ function S(...e) {
1494
1406
  for (let t = 0; t < e.length; t++)
1495
1407
  e[t].fill(0);
1496
1408
  }
1497
- function it(e) {
1409
+ function rt(e) {
1498
1410
  return new DataView(e.buffer, e.byteOffset, e.byteLength);
1499
1411
  }
1500
- function $(e, t) {
1412
+ function A(e, t) {
1501
1413
  return e << 32 - t | e >>> t;
1502
1414
  }
1503
- function Y(e, t) {
1415
+ function J(e, t) {
1504
1416
  return e << t | e >>> 32 - t >>> 0;
1505
1417
  }
1506
- const Ne = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1507
- function Xe(e) {
1418
+ const Me = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1419
+ function Ne(e) {
1508
1420
  return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
1509
1421
  }
1510
- function qe(e) {
1422
+ function Xe(e) {
1511
1423
  for (let t = 0; t < e.length; t++)
1512
- e[t] = Xe(e[t]);
1424
+ e[t] = Ne(e[t]);
1513
1425
  return e;
1514
1426
  }
1515
- const Ut = Ne ? (e) => e : qe;
1516
- function Ge(e) {
1427
+ const Ft = Me ? (e) => e : Xe;
1428
+ function qe(e) {
1517
1429
  if (typeof e != "string")
1518
1430
  throw new Error("string expected");
1519
1431
  return new Uint8Array(new TextEncoder().encode(e));
1520
1432
  }
1521
- function Ft(e, t = "") {
1522
- return typeof e == "string" ? Ge(e) : K(e, void 0, t);
1433
+ function Ut(e, t = "") {
1434
+ return typeof e == "string" ? qe(e) : D(e, void 0, t);
1523
1435
  }
1524
- function je(e, t) {
1436
+ function Ge(e, t) {
1525
1437
  if (t !== void 0 && {}.toString.call(t) !== "[object Object]")
1526
1438
  throw new Error("options must be object or undefined");
1527
1439
  return Object.assign(e, t);
1528
1440
  }
1529
- function ct(e, t = {}) {
1441
+ function at(e, t = {}) {
1530
1442
  const n = (o, r) => e(r).update(o).digest(), s = e(void 0);
1531
1443
  return n.outputLen = s.outputLen, n.blockLen = s.blockLen, n.create = (o) => e(o), Object.assign(n, t), Object.freeze(n);
1532
1444
  }
1533
- const Zt = (e) => ({
1445
+ const zt = (e) => ({
1534
1446
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, e])
1535
1447
  });
1536
- class Jt {
1448
+ class Zt {
1537
1449
  constructor(t, n) {
1538
1450
  p(this, "oHash");
1539
1451
  p(this, "iHash");
@@ -1541,7 +1453,7 @@ class Jt {
1541
1453
  p(this, "outputLen");
1542
1454
  p(this, "finished", !1);
1543
1455
  p(this, "destroyed", !1);
1544
- if (jt(t), K(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
1456
+ if (Gt(t), D(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
1545
1457
  throw new Error("Expected instance of class which extends utils.Hash");
1546
1458
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
1547
1459
  const s = this.blockLen, o = new Uint8Array(s);
@@ -1551,13 +1463,13 @@ class Jt {
1551
1463
  this.iHash.update(o), this.oHash = t.create();
1552
1464
  for (let r = 0; r < o.length; r++)
1553
1465
  o[r] ^= 106;
1554
- this.oHash.update(o), A(o);
1466
+ this.oHash.update(o), S(o);
1555
1467
  }
1556
1468
  update(t) {
1557
1469
  return G(this), this.iHash.update(t), this;
1558
1470
  }
1559
1471
  digestInto(t) {
1560
- G(this), K(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1472
+ G(this), D(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1561
1473
  }
1562
1474
  digest() {
1563
1475
  const t = new Uint8Array(this.oHash.outputLen);
@@ -1575,15 +1487,15 @@ class Jt {
1575
1487
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
1576
1488
  }
1577
1489
  }
1578
- const Pt = (e, t, n) => new Jt(e, t).update(n).digest();
1579
- Pt.create = (e, t) => new Jt(e, t);
1580
- function ze(e, t, n) {
1490
+ const wt = (e, t, n) => new Zt(e, t).update(n).digest();
1491
+ wt.create = (e, t) => new Zt(e, t);
1492
+ function je(e, t, n) {
1581
1493
  return e & t ^ ~e & n;
1582
1494
  }
1583
- function Ze(e, t, n) {
1495
+ function ze(e, t, n) {
1584
1496
  return e & t ^ e & n ^ t & n;
1585
1497
  }
1586
- class Tt {
1498
+ class mt {
1587
1499
  constructor(t, n, s, o) {
1588
1500
  p(this, "blockLen");
1589
1501
  p(this, "outputLen");
@@ -1596,15 +1508,15 @@ class Tt {
1596
1508
  p(this, "length", 0);
1597
1509
  p(this, "pos", 0);
1598
1510
  p(this, "destroyed", !1);
1599
- this.blockLen = t, this.outputLen = n, this.padOffset = s, this.isLE = o, this.buffer = new Uint8Array(t), this.view = it(this.buffer);
1511
+ this.blockLen = t, this.outputLen = n, this.padOffset = s, this.isLE = o, this.buffer = new Uint8Array(t), this.view = rt(this.buffer);
1600
1512
  }
1601
1513
  update(t) {
1602
- G(this), K(t);
1514
+ G(this), D(t);
1603
1515
  const { view: n, buffer: s, blockLen: o } = this, r = t.length;
1604
1516
  for (let i = 0; i < r; ) {
1605
1517
  const a = Math.min(o - this.pos, r - i);
1606
1518
  if (a === o) {
1607
- const c = it(t);
1519
+ const c = rt(t);
1608
1520
  for (; o <= r - i; i += o)
1609
1521
  this.process(c, i);
1610
1522
  continue;
@@ -1614,14 +1526,14 @@ class Tt {
1614
1526
  return this.length += t.length, this.roundClean(), this;
1615
1527
  }
1616
1528
  digestInto(t) {
1617
- G(this), zt(t, this), this.finished = !0;
1529
+ G(this), jt(t, this), this.finished = !0;
1618
1530
  const { buffer: n, view: s, blockLen: o, isLE: r } = this;
1619
1531
  let { pos: i } = this;
1620
- n[i++] = 128, A(this.buffer.subarray(i)), this.padOffset > o - i && (this.process(s, 0), i = 0);
1532
+ n[i++] = 128, S(this.buffer.subarray(i)), this.padOffset > o - i && (this.process(s, 0), i = 0);
1621
1533
  for (let u = i; u < o; u++)
1622
1534
  n[u] = 0;
1623
1535
  s.setBigUint64(o - 8, BigInt(this.length * 8), r), this.process(s, 0);
1624
- const a = it(t), c = this.outputLen;
1536
+ const a = rt(t), c = this.outputLen;
1625
1537
  if (c % 4)
1626
1538
  throw new Error("_sha2: outputLen must be aligned to 32bit");
1627
1539
  const l = c / 4, h = this.get();
@@ -1645,7 +1557,7 @@ class Tt {
1645
1557
  return this._cloneInto();
1646
1558
  }
1647
1559
  }
1648
- const L = /* @__PURE__ */ Uint32Array.from([
1560
+ const O = /* @__PURE__ */ Uint32Array.from([
1649
1561
  1779033703,
1650
1562
  3144134277,
1651
1563
  1013904242,
@@ -1671,7 +1583,7 @@ const L = /* @__PURE__ */ Uint32Array.from([
1671
1583
  4215389547,
1672
1584
  1541459225,
1673
1585
  327033209
1674
- ]), Je = /* @__PURE__ */ Uint8Array.from([
1586
+ ]), Ze = /* @__PURE__ */ Uint8Array.from([
1675
1587
  7,
1676
1588
  4,
1677
1589
  13,
@@ -1688,36 +1600,36 @@ const L = /* @__PURE__ */ Uint32Array.from([
1688
1600
  14,
1689
1601
  11,
1690
1602
  8
1691
- ]), Yt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), Ye = Yt.map((e) => (9 * e + 5) % 16), Qt = /* @__PURE__ */ (() => {
1692
- const n = [[Yt], [Ye]];
1603
+ ]), Jt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), Je = Jt.map((e) => (9 * e + 5) % 16), Yt = /* @__PURE__ */ (() => {
1604
+ const n = [[Jt], [Je]];
1693
1605
  for (let s = 0; s < 4; s++)
1694
1606
  for (let o of n)
1695
- o.push(o[s].map((r) => Je[r]));
1607
+ o.push(o[s].map((r) => Ze[r]));
1696
1608
  return n;
1697
- })(), te = Qt[0], ee = Qt[1], ne = /* @__PURE__ */ [
1609
+ })(), Qt = Yt[0], te = Yt[1], ee = /* @__PURE__ */ [
1698
1610
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
1699
1611
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
1700
1612
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
1701
1613
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
1702
1614
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
1703
- ].map((e) => Uint8Array.from(e)), Qe = /* @__PURE__ */ te.map((e, t) => e.map((n) => ne[t][n])), tn = /* @__PURE__ */ ee.map((e, t) => e.map((n) => ne[t][n])), en = /* @__PURE__ */ Uint32Array.from([
1615
+ ].map((e) => Uint8Array.from(e)), Ye = /* @__PURE__ */ Qt.map((e, t) => e.map((n) => ee[t][n])), Qe = /* @__PURE__ */ te.map((e, t) => e.map((n) => ee[t][n])), tn = /* @__PURE__ */ Uint32Array.from([
1704
1616
  0,
1705
1617
  1518500249,
1706
1618
  1859775393,
1707
1619
  2400959708,
1708
1620
  2840853838
1709
- ]), nn = /* @__PURE__ */ Uint32Array.from([
1621
+ ]), en = /* @__PURE__ */ Uint32Array.from([
1710
1622
  1352829926,
1711
1623
  1548603684,
1712
1624
  1836072691,
1713
1625
  2053994217,
1714
1626
  0
1715
1627
  ]);
1716
- function Ct(e, t, n, s) {
1628
+ function $t(e, t, n, s) {
1717
1629
  return e === 0 ? t ^ n ^ s : e === 1 ? t & n | ~t & s : e === 2 ? (t | ~n) ^ s : e === 3 ? t & s | n & ~s : t ^ (n | ~s);
1718
1630
  }
1719
- const Q = /* @__PURE__ */ new Uint32Array(16);
1720
- class sn extends Tt {
1631
+ const Y = /* @__PURE__ */ new Uint32Array(16);
1632
+ class nn extends mt {
1721
1633
  constructor() {
1722
1634
  super(64, 20, 8, !0);
1723
1635
  p(this, "h0", 1732584193);
@@ -1734,48 +1646,48 @@ class sn extends Tt {
1734
1646
  this.h0 = n | 0, this.h1 = s | 0, this.h2 = o | 0, this.h3 = r | 0, this.h4 = i | 0;
1735
1647
  }
1736
1648
  process(n, s) {
1737
- for (let g = 0; g < 16; g++, s += 4)
1738
- Q[g] = n.getUint32(s, !0);
1739
- let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, c = this.h2 | 0, l = c, h = this.h3 | 0, u = h, d = this.h4 | 0, y = d;
1740
- for (let g = 0; g < 5; g++) {
1741
- const x = 4 - g, P = en[g], m = nn[g], b = te[g], f = ee[g], w = Qe[g], v = tn[g];
1649
+ for (let y = 0; y < 16; y++, s += 4)
1650
+ Y[y] = n.getUint32(s, !0);
1651
+ let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, c = this.h2 | 0, l = c, h = this.h3 | 0, u = h, d = this.h4 | 0, g = d;
1652
+ for (let y = 0; y < 5; y++) {
1653
+ const x = 4 - y, P = tn[y], m = en[y], b = Qt[y], f = te[y], w = Ye[y], v = Qe[y];
1742
1654
  for (let T = 0; T < 16; T++) {
1743
- const H = Y(o + Ct(g, i, c, h) + Q[b[T]] + P, w[T]) + d | 0;
1744
- o = d, d = h, h = Y(c, 10) | 0, c = i, i = H;
1655
+ const H = J(o + $t(y, i, c, h) + Y[b[T]] + P, w[T]) + d | 0;
1656
+ o = d, d = h, h = J(c, 10) | 0, c = i, i = H;
1745
1657
  }
1746
1658
  for (let T = 0; T < 16; T++) {
1747
- const H = Y(r + Ct(x, a, l, u) + Q[f[T]] + m, v[T]) + y | 0;
1748
- r = y, y = u, u = Y(l, 10) | 0, l = a, a = H;
1659
+ const H = J(r + $t(x, a, l, u) + Y[f[T]] + m, v[T]) + g | 0;
1660
+ r = g, g = u, u = J(l, 10) | 0, l = a, a = H;
1749
1661
  }
1750
1662
  }
1751
- this.set(this.h1 + c + u | 0, this.h2 + h + y | 0, this.h3 + d + r | 0, this.h4 + o + a | 0, this.h0 + i + l | 0);
1663
+ this.set(this.h1 + c + u | 0, this.h2 + h + g | 0, this.h3 + d + r | 0, this.h4 + o + a | 0, this.h0 + i + l | 0);
1752
1664
  }
1753
1665
  roundClean() {
1754
- A(Q);
1666
+ S(Y);
1755
1667
  }
1756
1668
  destroy() {
1757
- this.destroyed = !0, A(this.buffer), this.set(0, 0, 0, 0, 0);
1669
+ this.destroyed = !0, S(this.buffer), this.set(0, 0, 0, 0, 0);
1758
1670
  }
1759
1671
  }
1760
- const on = /* @__PURE__ */ ct(() => new sn()), tt = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ot = /* @__PURE__ */ BigInt(32);
1761
- function rn(e, t = !1) {
1762
- return t ? { h: Number(e & tt), l: Number(e >> Ot & tt) } : { h: Number(e >> Ot & tt) | 0, l: Number(e & tt) | 0 };
1672
+ const sn = /* @__PURE__ */ at(() => new nn()), Q = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ot = /* @__PURE__ */ BigInt(32);
1673
+ function on(e, t = !1) {
1674
+ return t ? { h: Number(e & Q), l: Number(e >> Ot & Q) } : { h: Number(e >> Ot & Q) | 0, l: Number(e & Q) | 0 };
1763
1675
  }
1764
- function se(e, t = !1) {
1676
+ function ne(e, t = !1) {
1765
1677
  const n = e.length;
1766
1678
  let s = new Uint32Array(n), o = new Uint32Array(n);
1767
1679
  for (let r = 0; r < n; r++) {
1768
- const { h: i, l: a } = rn(e[r], t);
1680
+ const { h: i, l: a } = on(e[r], t);
1769
1681
  [s[r], o[r]] = [i, a];
1770
1682
  }
1771
1683
  return [s, o];
1772
1684
  }
1773
- const Lt = (e, t, n) => e >>> n, _t = (e, t, n) => e << 32 - n | t >>> n, N = (e, t, n) => e >>> n | t << 32 - n, X = (e, t, n) => e << 32 - n | t >>> n, et = (e, t, n) => e << 64 - n | t >>> n - 32, nt = (e, t, n) => e >>> n - 32 | t << 64 - n, an = (e, t, n) => e << n | t >>> 32 - n, cn = (e, t, n) => t << n | e >>> 32 - n, un = (e, t, n) => t << n - 32 | e >>> 64 - n, ln = (e, t, n) => e << n - 32 | t >>> 64 - n;
1685
+ const Lt = (e, t, n) => e >>> n, _t = (e, t, n) => e << 32 - n | t >>> n, N = (e, t, n) => e >>> n | t << 32 - n, X = (e, t, n) => e << 32 - n | t >>> n, tt = (e, t, n) => e << 64 - n | t >>> n - 32, et = (e, t, n) => e >>> n - 32 | t << 64 - n, rn = (e, t, n) => e << n | t >>> 32 - n, an = (e, t, n) => t << n | e >>> 32 - n, cn = (e, t, n) => t << n - 32 | e >>> 64 - n, un = (e, t, n) => e << n - 32 | t >>> 64 - n;
1774
1686
  function F(e, t, n, s) {
1775
1687
  const o = (t >>> 0) + (s >>> 0);
1776
1688
  return { h: e + n + (o / 2 ** 32 | 0) | 0, l: o | 0 };
1777
1689
  }
1778
- const hn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), dn = (e, t, n, s) => t + n + s + (e / 2 ** 32 | 0) | 0, fn = (e, t, n, s) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0), pn = (e, t, n, s, o) => t + n + s + o + (e / 2 ** 32 | 0) | 0, gn = (e, t, n, s, o) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0) + (o >>> 0), bn = (e, t, n, s, o, r) => t + n + s + o + r + (e / 2 ** 32 | 0) | 0, yn = /* @__PURE__ */ Uint32Array.from([
1690
+ const ln = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), hn = (e, t, n, s) => t + n + s + (e / 2 ** 32 | 0) | 0, dn = (e, t, n, s) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0), fn = (e, t, n, s, o) => t + n + s + o + (e / 2 ** 32 | 0) | 0, pn = (e, t, n, s, o) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0) + (o >>> 0), yn = (e, t, n, s, o, r) => t + n + s + o + r + (e / 2 ** 32 | 0) | 0, bn = /* @__PURE__ */ Uint32Array.from([
1779
1691
  1116352408,
1780
1692
  1899447441,
1781
1693
  3049323471,
@@ -1840,8 +1752,8 @@ const hn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), dn = (e, t, n, s) =>
1840
1752
  2756734187,
1841
1753
  3204031479,
1842
1754
  3329325298
1843
- ]), _ = /* @__PURE__ */ new Uint32Array(64);
1844
- class xn extends Tt {
1755
+ ]), L = /* @__PURE__ */ new Uint32Array(64);
1756
+ class gn extends mt {
1845
1757
  constructor(t) {
1846
1758
  super(64, t, 8, !1);
1847
1759
  }
@@ -1855,41 +1767,41 @@ class xn extends Tt {
1855
1767
  }
1856
1768
  process(t, n) {
1857
1769
  for (let u = 0; u < 16; u++, n += 4)
1858
- _[u] = t.getUint32(n, !1);
1770
+ L[u] = t.getUint32(n, !1);
1859
1771
  for (let u = 16; u < 64; u++) {
1860
- const d = _[u - 15], y = _[u - 2], g = $(d, 7) ^ $(d, 18) ^ d >>> 3, x = $(y, 17) ^ $(y, 19) ^ y >>> 10;
1861
- _[u] = x + _[u - 7] + g + _[u - 16] | 0;
1772
+ const d = L[u - 15], g = L[u - 2], y = A(d, 7) ^ A(d, 18) ^ d >>> 3, x = A(g, 17) ^ A(g, 19) ^ g >>> 10;
1773
+ L[u] = x + L[u - 7] + y + L[u - 16] | 0;
1862
1774
  }
1863
1775
  let { A: s, B: o, C: r, D: i, E: a, F: c, G: l, H: h } = this;
1864
1776
  for (let u = 0; u < 64; u++) {
1865
- const d = $(a, 6) ^ $(a, 11) ^ $(a, 25), y = h + d + ze(a, c, l) + yn[u] + _[u] | 0, x = ($(s, 2) ^ $(s, 13) ^ $(s, 22)) + Ze(s, o, r) | 0;
1866
- h = l, l = c, c = a, a = i + y | 0, i = r, r = o, o = s, s = y + x | 0;
1777
+ const d = A(a, 6) ^ A(a, 11) ^ A(a, 25), g = h + d + je(a, c, l) + bn[u] + L[u] | 0, x = (A(s, 2) ^ A(s, 13) ^ A(s, 22)) + ze(s, o, r) | 0;
1778
+ h = l, l = c, c = a, a = i + g | 0, i = r, r = o, o = s, s = g + x | 0;
1867
1779
  }
1868
1780
  s = s + this.A | 0, o = o + this.B | 0, r = r + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, h = h + this.H | 0, this.set(s, o, r, i, a, c, l, h);
1869
1781
  }
1870
1782
  roundClean() {
1871
- A(_);
1783
+ S(L);
1872
1784
  }
1873
1785
  destroy() {
1874
- this.set(0, 0, 0, 0, 0, 0, 0, 0), A(this.buffer);
1786
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), S(this.buffer);
1875
1787
  }
1876
1788
  }
1877
- class wn extends xn {
1789
+ class xn extends gn {
1878
1790
  constructor() {
1879
1791
  super(32);
1880
1792
  // We cannot use array here since array allows indexing by variable
1881
1793
  // which means optimizer/compiler cannot use registers.
1882
- p(this, "A", L[0] | 0);
1883
- p(this, "B", L[1] | 0);
1884
- p(this, "C", L[2] | 0);
1885
- p(this, "D", L[3] | 0);
1886
- p(this, "E", L[4] | 0);
1887
- p(this, "F", L[5] | 0);
1888
- p(this, "G", L[6] | 0);
1889
- p(this, "H", L[7] | 0);
1794
+ p(this, "A", O[0] | 0);
1795
+ p(this, "B", O[1] | 0);
1796
+ p(this, "C", O[2] | 0);
1797
+ p(this, "D", O[3] | 0);
1798
+ p(this, "E", O[4] | 0);
1799
+ p(this, "F", O[5] | 0);
1800
+ p(this, "G", O[6] | 0);
1801
+ p(this, "H", O[7] | 0);
1890
1802
  }
1891
1803
  }
1892
- const oe = se([
1804
+ const se = ne([
1893
1805
  "0x428a2f98d728ae22",
1894
1806
  "0x7137449123ef65cd",
1895
1807
  "0xb5c0fbcfec4d3b2f",
@@ -1970,44 +1882,44 @@ const oe = se([
1970
1882
  "0x597f299cfc657e2a",
1971
1883
  "0x5fcb6fab3ad6faec",
1972
1884
  "0x6c44198c4a475817"
1973
- ].map((e) => BigInt(e))), mn = oe[0], Pn = oe[1], R = /* @__PURE__ */ new Uint32Array(80), W = /* @__PURE__ */ new Uint32Array(80);
1974
- class Tn extends Tt {
1885
+ ].map((e) => BigInt(e))), wn = se[0], mn = se[1], _ = /* @__PURE__ */ new Uint32Array(80), R = /* @__PURE__ */ new Uint32Array(80);
1886
+ class Pn extends mt {
1975
1887
  constructor(t) {
1976
1888
  super(128, t, 16, !1);
1977
1889
  }
1978
1890
  // prettier-ignore
1979
1891
  get() {
1980
- const { Ah: t, Al: n, Bh: s, Bl: o, Ch: r, Cl: i, Dh: a, Dl: c, Eh: l, El: h, Fh: u, Fl: d, Gh: y, Gl: g, Hh: x, Hl: P } = this;
1981
- return [t, n, s, o, r, i, a, c, l, h, u, d, y, g, x, P];
1892
+ const { Ah: t, Al: n, Bh: s, Bl: o, Ch: r, Cl: i, Dh: a, Dl: c, Eh: l, El: h, Fh: u, Fl: d, Gh: g, Gl: y, Hh: x, Hl: P } = this;
1893
+ return [t, n, s, o, r, i, a, c, l, h, u, d, g, y, x, P];
1982
1894
  }
1983
1895
  // prettier-ignore
1984
- set(t, n, s, o, r, i, a, c, l, h, u, d, y, g, x, P) {
1985
- this.Ah = t | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = o | 0, this.Ch = r | 0, this.Cl = i | 0, this.Dh = a | 0, this.Dl = c | 0, this.Eh = l | 0, this.El = h | 0, this.Fh = u | 0, this.Fl = d | 0, this.Gh = y | 0, this.Gl = g | 0, this.Hh = x | 0, this.Hl = P | 0;
1896
+ set(t, n, s, o, r, i, a, c, l, h, u, d, g, y, x, P) {
1897
+ this.Ah = t | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = o | 0, this.Ch = r | 0, this.Cl = i | 0, this.Dh = a | 0, this.Dl = c | 0, this.Eh = l | 0, this.El = h | 0, this.Fh = u | 0, this.Fl = d | 0, this.Gh = g | 0, this.Gl = y | 0, this.Hh = x | 0, this.Hl = P | 0;
1986
1898
  }
1987
1899
  process(t, n) {
1988
1900
  for (let f = 0; f < 16; f++, n += 4)
1989
- R[f] = t.getUint32(n), W[f] = t.getUint32(n += 4);
1901
+ _[f] = t.getUint32(n), R[f] = t.getUint32(n += 4);
1990
1902
  for (let f = 16; f < 80; f++) {
1991
- const w = R[f - 15] | 0, v = W[f - 15] | 0, T = N(w, v, 1) ^ N(w, v, 8) ^ Lt(w, v, 7), H = X(w, v, 1) ^ X(w, v, 8) ^ _t(w, v, 7), E = R[f - 2] | 0, I = W[f - 2] | 0, C = N(E, I, 19) ^ et(E, I, 61) ^ Lt(E, I, 6), D = X(E, I, 19) ^ nt(E, I, 61) ^ _t(E, I, 6), O = fn(H, D, W[f - 7], W[f - 16]), ut = pn(O, T, C, R[f - 7], R[f - 16]);
1992
- R[f] = ut | 0, W[f] = O | 0;
1903
+ const w = _[f - 15] | 0, v = R[f - 15] | 0, T = N(w, v, 1) ^ N(w, v, 8) ^ Lt(w, v, 7), H = X(w, v, 1) ^ X(w, v, 8) ^ _t(w, v, 7), I = _[f - 2] | 0, E = R[f - 2] | 0, U = N(I, E, 19) ^ tt(I, E, 61) ^ Lt(I, E, 6), K = X(I, E, 19) ^ et(I, E, 61) ^ _t(I, E, 6), $ = dn(H, K, R[f - 7], R[f - 16]), ct = fn($, T, U, _[f - 7], _[f - 16]);
1904
+ _[f] = ct | 0, R[f] = $ | 0;
1993
1905
  }
1994
- let { Ah: s, Al: o, Bh: r, Bl: i, Ch: a, Cl: c, Dh: l, Dl: h, Eh: u, El: d, Fh: y, Fl: g, Gh: x, Gl: P, Hh: m, Hl: b } = this;
1906
+ let { Ah: s, Al: o, Bh: r, Bl: i, Ch: a, Cl: c, Dh: l, Dl: h, Eh: u, El: d, Fh: g, Fl: y, Gh: x, Gl: P, Hh: m, Hl: b } = this;
1995
1907
  for (let f = 0; f < 80; f++) {
1996
- const w = N(u, d, 14) ^ N(u, d, 18) ^ et(u, d, 41), v = X(u, d, 14) ^ X(u, d, 18) ^ nt(u, d, 41), T = u & y ^ ~u & x, H = d & g ^ ~d & P, E = gn(b, v, H, Pn[f], W[f]), I = bn(E, m, w, T, mn[f], R[f]), C = E | 0, D = N(s, o, 28) ^ et(s, o, 34) ^ et(s, o, 39), O = X(s, o, 28) ^ nt(s, o, 34) ^ nt(s, o, 39), ut = s & r ^ s & a ^ r & a, he = o & i ^ o & c ^ i & c;
1997
- m = x | 0, b = P | 0, x = y | 0, P = g | 0, y = u | 0, g = d | 0, { h: u, l: d } = F(l | 0, h | 0, I | 0, C | 0), l = a | 0, h = c | 0, a = r | 0, c = i | 0, r = s | 0, i = o | 0;
1998
- const kt = hn(C, O, he);
1999
- s = dn(kt, I, D, ut), o = kt | 0;
1908
+ const w = N(u, d, 14) ^ N(u, d, 18) ^ tt(u, d, 41), v = X(u, d, 14) ^ X(u, d, 18) ^ et(u, d, 41), T = u & g ^ ~u & x, H = d & y ^ ~d & P, I = pn(b, v, H, mn[f], R[f]), E = yn(I, m, w, T, wn[f], _[f]), U = I | 0, K = N(s, o, 28) ^ tt(s, o, 34) ^ tt(s, o, 39), $ = X(s, o, 28) ^ et(s, o, 34) ^ et(s, o, 39), ct = s & r ^ s & a ^ r & a, le = o & i ^ o & c ^ i & c;
1909
+ m = x | 0, b = P | 0, x = g | 0, P = y | 0, g = u | 0, y = d | 0, { h: u, l: d } = F(l | 0, h | 0, E | 0, U | 0), l = a | 0, h = c | 0, a = r | 0, c = i | 0, r = s | 0, i = o | 0;
1910
+ const Tt = ln(U, $, le);
1911
+ s = hn(Tt, E, K, ct), o = Tt | 0;
2000
1912
  }
2001
- ({ h: s, l: o } = F(this.Ah | 0, this.Al | 0, s | 0, o | 0)), { h: r, l: i } = F(this.Bh | 0, this.Bl | 0, r | 0, i | 0), { h: a, l: c } = F(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: l, l: h } = F(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: u, l: d } = F(this.Eh | 0, this.El | 0, u | 0, d | 0), { h: y, l: g } = F(this.Fh | 0, this.Fl | 0, y | 0, g | 0), { h: x, l: P } = F(this.Gh | 0, this.Gl | 0, x | 0, P | 0), { h: m, l: b } = F(this.Hh | 0, this.Hl | 0, m | 0, b | 0), this.set(s, o, r, i, a, c, l, h, u, d, y, g, x, P, m, b);
1913
+ ({ h: s, l: o } = F(this.Ah | 0, this.Al | 0, s | 0, o | 0)), { h: r, l: i } = F(this.Bh | 0, this.Bl | 0, r | 0, i | 0), { h: a, l: c } = F(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: l, l: h } = F(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: u, l: d } = F(this.Eh | 0, this.El | 0, u | 0, d | 0), { h: g, l: y } = F(this.Fh | 0, this.Fl | 0, g | 0, y | 0), { h: x, l: P } = F(this.Gh | 0, this.Gl | 0, x | 0, P | 0), { h: m, l: b } = F(this.Hh | 0, this.Hl | 0, m | 0, b | 0), this.set(s, o, r, i, a, c, l, h, u, d, g, y, x, P, m, b);
2002
1914
  }
2003
1915
  roundClean() {
2004
- A(R, W);
1916
+ S(_, R);
2005
1917
  }
2006
1918
  destroy() {
2007
- A(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1919
+ S(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2008
1920
  }
2009
1921
  }
2010
- class vn extends Tn {
1922
+ class Tn extends Pn {
2011
1923
  constructor() {
2012
1924
  super(64);
2013
1925
  p(this, "Ah", k[0] | 0);
@@ -2028,34 +1940,34 @@ class vn extends Tn {
2028
1940
  p(this, "Hl", k[15] | 0);
2029
1941
  }
2030
1942
  }
2031
- const kn = /* @__PURE__ */ ct(
2032
- () => new wn(),
2033
- /* @__PURE__ */ Zt(1)
2034
- ), re = /* @__PURE__ */ ct(
2035
- () => new vn(),
2036
- /* @__PURE__ */ Zt(3)
2037
- ), Hn = BigInt(0), z = BigInt(1), En = BigInt(2), In = BigInt(7), Sn = BigInt(256), Bn = BigInt(113), ie = [], ae = [], ce = [];
1943
+ const vn = /* @__PURE__ */ at(
1944
+ () => new xn(),
1945
+ /* @__PURE__ */ zt(1)
1946
+ ), oe = /* @__PURE__ */ at(
1947
+ () => new Tn(),
1948
+ /* @__PURE__ */ zt(3)
1949
+ ), kn = BigInt(0), z = BigInt(1), Hn = BigInt(2), In = BigInt(7), En = BigInt(256), Bn = BigInt(113), re = [], ie = [], ae = [];
2038
1950
  for (let e = 0, t = z, n = 1, s = 0; e < 24; e++) {
2039
- [n, s] = [s, (2 * n + 3 * s) % 5], ie.push(2 * (5 * s + n)), ae.push((e + 1) * (e + 2) / 2 % 64);
2040
- let o = Hn;
1951
+ [n, s] = [s, (2 * n + 3 * s) % 5], re.push(2 * (5 * s + n)), ie.push((e + 1) * (e + 2) / 2 % 64);
1952
+ let o = kn;
2041
1953
  for (let r = 0; r < 7; r++)
2042
- t = (t << z ^ (t >> In) * Bn) % Sn, t & En && (o ^= z << (z << BigInt(r)) - z);
2043
- ce.push(o);
1954
+ t = (t << z ^ (t >> In) * Bn) % En, t & Hn && (o ^= z << (z << BigInt(r)) - z);
1955
+ ae.push(o);
2044
1956
  }
2045
- const ue = se(ce, !0), An = ue[0], $n = ue[1], Rt = (e, t, n) => n > 32 ? un(e, t, n) : an(e, t, n), Wt = (e, t, n) => n > 32 ? ln(e, t, n) : cn(e, t, n);
2046
- function Un(e, t = 24) {
1957
+ const ce = ne(ae, !0), Sn = ce[0], An = ce[1], Rt = (e, t, n) => n > 32 ? cn(e, t, n) : rn(e, t, n), Wt = (e, t, n) => n > 32 ? un(e, t, n) : an(e, t, n);
1958
+ function Cn(e, t = 24) {
2047
1959
  const n = new Uint32Array(10);
2048
1960
  for (let s = 24 - t; s < 24; s++) {
2049
1961
  for (let i = 0; i < 10; i++)
2050
1962
  n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
2051
1963
  for (let i = 0; i < 10; i += 2) {
2052
1964
  const a = (i + 8) % 10, c = (i + 2) % 10, l = n[c], h = n[c + 1], u = Rt(l, h, 1) ^ n[a], d = Wt(l, h, 1) ^ n[a + 1];
2053
- for (let y = 0; y < 50; y += 10)
2054
- e[i + y] ^= u, e[i + y + 1] ^= d;
1965
+ for (let g = 0; g < 50; g += 10)
1966
+ e[i + g] ^= u, e[i + g + 1] ^= d;
2055
1967
  }
2056
1968
  let o = e[2], r = e[3];
2057
1969
  for (let i = 0; i < 24; i++) {
2058
- const a = ae[i], c = Rt(o, r, a), l = Wt(o, r, a), h = ie[i];
1970
+ const a = ie[i], c = Rt(o, r, a), l = Wt(o, r, a), h = re[i];
2059
1971
  o = e[h], r = e[h + 1], e[h] = c, e[h + 1] = l;
2060
1972
  }
2061
1973
  for (let i = 0; i < 50; i += 10) {
@@ -2064,11 +1976,11 @@ function Un(e, t = 24) {
2064
1976
  for (let a = 0; a < 10; a++)
2065
1977
  e[i + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
2066
1978
  }
2067
- e[0] ^= An[s], e[1] ^= $n[s];
1979
+ e[0] ^= Sn[s], e[1] ^= An[s];
2068
1980
  }
2069
- A(n);
1981
+ S(n);
2070
1982
  }
2071
- class vt {
1983
+ class Pt {
2072
1984
  // NOTE: we accept arguments in bytes instead of bits here.
2073
1985
  constructor(t, n, s, o = !1, r = 24) {
2074
1986
  p(this, "state");
@@ -2084,16 +1996,16 @@ class vt {
2084
1996
  p(this, "rounds");
2085
1997
  if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = o, this.rounds = r, V(s, "outputLen"), !(0 < t && t < 200))
2086
1998
  throw new Error("only keccak-f1600 function is supported");
2087
- this.state = new Uint8Array(200), this.state32 = Me(this.state);
1999
+ this.state = new Uint8Array(200), this.state32 = Ke(this.state);
2088
2000
  }
2089
2001
  clone() {
2090
2002
  return this._cloneInto();
2091
2003
  }
2092
2004
  keccak() {
2093
- Ut(this.state32), Un(this.state32, this.rounds), Ut(this.state32), this.posOut = 0, this.pos = 0;
2005
+ Ft(this.state32), Cn(this.state32, this.rounds), Ft(this.state32), this.posOut = 0, this.pos = 0;
2094
2006
  }
2095
2007
  update(t) {
2096
- G(this), K(t);
2008
+ G(this), D(t);
2097
2009
  const { blockLen: n, state: s } = this, o = t.length;
2098
2010
  for (let r = 0; r < o; ) {
2099
2011
  const i = Math.min(n - this.pos, o - r);
@@ -2111,7 +2023,7 @@ class vt {
2111
2023
  t[s] ^= n, (n & 128) !== 0 && s === o - 1 && this.keccak(), t[o - 1] ^= 128, this.keccak();
2112
2024
  }
2113
2025
  writeInto(t) {
2114
- G(this, !1), K(t), this.finish();
2026
+ G(this, !1), D(t), this.finish();
2115
2027
  const n = this.state, { blockLen: s } = this;
2116
2028
  for (let o = 0, r = t.length; o < r; ) {
2117
2029
  this.posOut >= s && this.keccak();
@@ -2129,7 +2041,7 @@ class vt {
2129
2041
  return V(t), this.xofInto(new Uint8Array(t));
2130
2042
  }
2131
2043
  digestInto(t) {
2132
- if (zt(t, this), this.finished)
2044
+ if (jt(t, this), this.finished)
2133
2045
  throw new Error("digest() was already called");
2134
2046
  return this.writeInto(t), this.destroy(), t;
2135
2047
  }
@@ -2137,56 +2049,56 @@ class vt {
2137
2049
  return this.digestInto(new Uint8Array(this.outputLen));
2138
2050
  }
2139
2051
  destroy() {
2140
- this.destroyed = !0, A(this.state);
2052
+ this.destroyed = !0, S(this.state);
2141
2053
  }
2142
2054
  _cloneInto(t) {
2143
2055
  const { blockLen: n, suffix: s, outputLen: o, rounds: r, enableXOF: i } = this;
2144
- return t || (t = new vt(n, 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;
2056
+ return t || (t = new Pt(n, 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;
2145
2057
  }
2146
2058
  }
2147
- const Fn = (e, t, n, s = {}) => ct(() => new vt(t, e, n), s), Cn = /* @__PURE__ */ Fn(1, 136, 32);
2148
- function On(e, t, n, s) {
2149
- jt(e);
2150
- const o = je({ dkLen: 32, asyncTick: 10 }, s), { c: r, dkLen: i, asyncTick: a } = o;
2059
+ const Fn = (e, t, n, s = {}) => at(() => new Pt(t, e, n), s), Un = /* @__PURE__ */ Fn(1, 136, 32);
2060
+ function $n(e, t, n, s) {
2061
+ Gt(e);
2062
+ const o = Ge({ dkLen: 32, asyncTick: 10 }, s), { c: r, dkLen: i, asyncTick: a } = o;
2151
2063
  if (V(r, "c"), V(i, "dkLen"), V(a, "asyncTick"), r < 1)
2152
2064
  throw new Error("iterations (c) must be >= 1");
2153
- const c = Ft(t, "password"), l = Ft(n, "salt"), h = new Uint8Array(i), u = Pt.create(e, c), d = u._cloneInto().update(l);
2065
+ const c = Ut(t, "password"), l = Ut(n, "salt"), h = new Uint8Array(i), u = wt.create(e, c), d = u._cloneInto().update(l);
2154
2066
  return { c: r, dkLen: i, asyncTick: a, DK: h, PRF: u, PRFSalt: d };
2155
2067
  }
2156
- function Ln(e, t, n, s, o) {
2157
- return e.destroy(), t.destroy(), s && s.destroy(), A(o), n;
2068
+ function On(e, t, n, s, o) {
2069
+ return e.destroy(), t.destroy(), s && s.destroy(), S(o), n;
2158
2070
  }
2159
- function _n(e, t, n, s) {
2160
- const { c: o, dkLen: r, DK: i, PRF: a, PRFSalt: c } = On(e, t, n, s);
2071
+ function Ln(e, t, n, s) {
2072
+ const { c: o, dkLen: r, DK: i, PRF: a, PRFSalt: c } = $n(e, t, n, s);
2161
2073
  let l;
2162
- const h = new Uint8Array(4), u = it(h), d = new Uint8Array(a.outputLen);
2163
- for (let y = 1, g = 0; g < r; y++, g += a.outputLen) {
2164
- const x = i.subarray(g, g + a.outputLen);
2165
- u.setInt32(0, y, !1), (l = c._cloneInto(l)).update(h).digestInto(d), x.set(d.subarray(0, x.length));
2074
+ const h = new Uint8Array(4), u = rt(h), d = new Uint8Array(a.outputLen);
2075
+ for (let g = 1, y = 0; y < r; g++, y += a.outputLen) {
2076
+ const x = i.subarray(y, y + a.outputLen);
2077
+ u.setInt32(0, g, !1), (l = c._cloneInto(l)).update(h).digestInto(d), x.set(d.subarray(0, x.length));
2166
2078
  for (let P = 1; P < o; P++) {
2167
2079
  a._cloneInto(l).update(d).digestInto(d);
2168
2080
  for (let m = 0; m < x.length; m++)
2169
2081
  x[m] ^= d[m];
2170
2082
  }
2171
2083
  }
2172
- return Ln(a, c, i, l, d);
2084
+ return On(a, c, i, l, d);
2173
2085
  }
2174
- function le(e) {
2086
+ function ue(e) {
2175
2087
  if (typeof e != "string")
2176
2088
  throw new TypeError("invalid mnemonic type: " + typeof e);
2177
2089
  return e.normalize("NFKD");
2178
2090
  }
2179
- function Rn(e) {
2180
- const t = le(e), n = t.split(" ");
2091
+ function _n(e) {
2092
+ const t = ue(e), n = t.split(" ");
2181
2093
  if (![12, 15, 18, 21, 24].includes(n.length))
2182
2094
  throw new Error("Invalid mnemonic");
2183
2095
  return { nfkd: t, words: n };
2184
2096
  }
2185
- const Wn = (e) => le("mnemonic" + e);
2186
- function Vn(e, t = "") {
2187
- return _n(re, Rn(e).nfkd, Wn(t), { c: 2048, dkLen: 64 });
2097
+ const Rn = (e) => ue("mnemonic" + e);
2098
+ function Wn(e, t = "") {
2099
+ return Ln(oe, _n(e).nfkd, Rn(t), { c: 2048, dkLen: 64 });
2188
2100
  }
2189
- const Kn = 508, Vt = 16, st = 32, ot = 64, Kt = 5, Dn = 4;
2101
+ const Vn = 508, Vt = 16, nt = 32, st = 64, Dt = 5, Dn = 4;
2190
2102
  function Z(...e) {
2191
2103
  const t = e.reduce((o, r) => o + r.length, 0), n = new Uint8Array(t);
2192
2104
  let s = 0;
@@ -2194,63 +2106,63 @@ function Z(...e) {
2194
2106
  n.set(o, s), s += o.length;
2195
2107
  return n;
2196
2108
  }
2197
- function ft(e) {
2109
+ function dt(e) {
2198
2110
  return new TextEncoder().encode(e);
2199
2111
  }
2200
- function pt(e) {
2112
+ function ft(e) {
2201
2113
  const t = new Uint8Array(Dn);
2202
2114
  return new DataView(t.buffer).setUint32(0, e.length, !1), Z(t, e);
2203
2115
  }
2204
- function gt(e, t) {
2205
- return Pt(re, e, t);
2116
+ function pt(e, t) {
2117
+ return wt(oe, e, t);
2206
2118
  }
2207
- function Dt(e) {
2208
- return on(kn(e));
2119
+ function Kt(e) {
2120
+ return sn(vn(e));
2209
2121
  }
2210
- const wt = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
2211
- function Mn(e) {
2212
- const t = Vn(e), n = new Uint8Array(t);
2122
+ const bt = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
2123
+ function Kn(e) {
2124
+ const t = Wn(e), n = new Uint8Array(t);
2213
2125
  return t.fill(0), n;
2214
2126
  }
2215
- async function Nn(e, t, n, s) {
2216
- if (e.length !== ot)
2127
+ async function Mn(e, t, n, s) {
2128
+ if (e.length !== st)
2217
2129
  throw new Error(
2218
- `WOTS seed must be ${ot} bytes, got ${e.length}`
2130
+ `WOTS seed must be ${st} bytes, got ${e.length}`
2219
2131
  );
2220
2132
  t = B(t), n = B(n);
2221
- const o = e.slice(st, ot), r = e.slice(0, st), i = [o, r];
2133
+ const o = e.slice(nt, st), r = e.slice(0, nt), i = [o, r];
2222
2134
  try {
2223
2135
  const a = Z(
2224
- pt(ft(t)),
2225
- pt(ft(n)),
2226
- pt(ft(s))
2136
+ ft(dt(t)),
2137
+ ft(dt(n)),
2138
+ ft(dt(s))
2227
2139
  ), c = Z(r, a);
2228
2140
  i.push(c);
2229
- const l = gt(o, c);
2141
+ const l = pt(o, c);
2230
2142
  i.push(l);
2231
- const h = l.slice(0, st), u = l.slice(st, ot);
2143
+ const h = l.slice(0, nt), u = l.slice(nt, st);
2232
2144
  i.push(h, u);
2233
- const d = [], y = [], g = [], x = [];
2145
+ const d = [], g = [], y = [], x = [];
2234
2146
  let P = !1;
2235
2147
  try {
2236
- for (let m = 0; m < Kn; m++) {
2237
- const b = new Uint8Array(Kt);
2148
+ for (let m = 0; m < Vn; m++) {
2149
+ const b = new Uint8Array(Dt);
2238
2150
  b[0] = 0, new DataView(b.buffer).setUint32(1, m, !1);
2239
- const f = new Uint8Array(Kt);
2151
+ const f = new Uint8Array(Dt);
2240
2152
  f[0] = 1, new DataView(f.buffer).setUint32(1, m, !1);
2241
- const w = Z(h, b), v = Z(h, f), T = gt(u, w), H = gt(u, v);
2153
+ const w = Z(h, b), v = Z(h, f), T = pt(u, w), H = pt(u, v);
2242
2154
  try {
2243
- const E = T.slice(0, Vt), I = H.slice(0, Vt);
2244
- d.push(E), y.push(I), g.push(Dt(E)), x.push(Dt(I));
2155
+ const I = T.slice(0, Vt), E = H.slice(0, Vt);
2156
+ d.push(I), g.push(E), y.push(Kt(I)), x.push(Kt(E));
2245
2157
  } finally {
2246
2158
  w.fill(0), v.fill(0), T.fill(0), H.fill(0);
2247
2159
  }
2248
2160
  }
2249
- return P = !0, { falsePreimages: d, truePreimages: y, falseHashes: g, trueHashes: x };
2161
+ return P = !0, { falsePreimages: d, truePreimages: g, falseHashes: y, trueHashes: x };
2250
2162
  } finally {
2251
2163
  if (!P) {
2252
2164
  for (const m of d) m.fill(0);
2253
- for (const m of y) m.fill(0);
2165
+ for (const m of g) m.fill(0);
2254
2166
  }
2255
2167
  }
2256
2168
  } finally {
@@ -2258,13 +2170,13 @@ async function Nn(e, t, n, s) {
2258
2170
  a.fill(0);
2259
2171
  }
2260
2172
  }
2261
- function hs(e) {
2173
+ function cs(e) {
2262
2174
  return {
2263
- false_list: e.falseHashes.map(wt),
2264
- true_list: e.trueHashes.map(wt)
2175
+ false_list: e.falseHashes.map(bt),
2176
+ true_list: e.trueHashes.map(bt)
2265
2177
  };
2266
2178
  }
2267
- function Xn(e) {
2179
+ function Nn(e) {
2268
2180
  if (e.falseHashes.length === 0 || e.trueHashes.length === 0)
2269
2181
  throw new Error(
2270
2182
  "computeWotsPkHash: keypair hash arrays must not be empty"
@@ -2275,20 +2187,20 @@ function Xn(e) {
2275
2187
  s.set(i, o), o += t;
2276
2188
  for (const i of e.trueHashes)
2277
2189
  s.set(i, o), o += t;
2278
- const r = Cn(s);
2279
- return `0x${wt(r)}`;
2190
+ const r = Un(s);
2191
+ return `0x${bt(r)}`;
2280
2192
  }
2281
- async function ds(e, t, n, s) {
2282
- const o = Mn(e);
2193
+ async function us(e, t, n, s) {
2194
+ const o = Kn(e);
2283
2195
  try {
2284
- const r = await Nn(
2196
+ const r = await Mn(
2285
2197
  o,
2286
2198
  t,
2287
2199
  n,
2288
2200
  s
2289
2201
  );
2290
2202
  try {
2291
- return Xn(r);
2203
+ return Nn(r);
2292
2204
  } finally {
2293
2205
  for (const i of r.falsePreimages) i.fill(0);
2294
2206
  for (const i of r.truePreimages) i.fill(0);
@@ -2297,43 +2209,41 @@ async function ds(e, t, n, s) {
2297
2209
  o.fill(0);
2298
2210
  }
2299
2211
  }
2300
- function fs(e) {
2212
+ function ls(e) {
2301
2213
  const t = (e instanceof Error ? e.message : typeof e == "string" ? e : "").toLowerCase();
2302
2214
  return t.includes("wots") && t.includes("hash") && t.includes("does not match");
2303
2215
  }
2304
2216
  export {
2305
- Xn as A,
2306
- rt as B,
2217
+ ls as A,
2218
+ ot as B,
2307
2219
  q as C,
2308
- ds as D,
2309
- fs as E,
2310
- Le as M,
2311
- us as P,
2312
- Yn as a,
2313
- ts as b,
2314
- dt as c,
2315
- es as d,
2316
- Ue as e,
2317
- Fe as f,
2318
- Qn as g,
2319
- xt as h,
2320
- ls as i,
2321
- rs as j,
2220
+ Oe as M,
2221
+ is as P,
2222
+ Jn as a,
2223
+ Ce as b,
2224
+ ht as c,
2225
+ Fe as d,
2226
+ yt as e,
2227
+ as as f,
2228
+ Yn as g,
2229
+ ns as h,
2230
+ ts as i,
2231
+ es as j,
2322
2232
  ss as k,
2323
- os as l,
2324
- is as m,
2325
- ns as n,
2326
- Re as o,
2327
- We as p,
2328
- _e as q,
2329
- j as r,
2330
- $e as s,
2331
- mt as t,
2332
- as as u,
2333
- cs as v,
2334
- M as w,
2335
- Mn as x,
2233
+ Qn as l,
2234
+ _e as m,
2235
+ Re as n,
2236
+ j as o,
2237
+ Le as p,
2238
+ xt as q,
2239
+ os as r,
2240
+ Ae as s,
2241
+ rs as t,
2242
+ M as u,
2243
+ Kn as v,
2244
+ Mn as w,
2245
+ cs as x,
2336
2246
  Nn as y,
2337
- hs as z
2247
+ us as z
2338
2248
  };
2339
- //# sourceMappingURL=errors-UqmtfBtv.js.map
2249
+ //# sourceMappingURL=errors-BEUjAw2k.js.map