@babylonlabs-io/ts-sdk 0.10.0 → 0.12.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 (35) hide show
  1. package/dist/challengeAssert-DW0sEUgn.cjs +2 -0
  2. package/dist/challengeAssert-DW0sEUgn.cjs.map +1 -0
  3. package/dist/{challengeAssert-D50t_Qyo.js → challengeAssert-DnnliaRt.js} +66 -60
  4. package/dist/challengeAssert-DnnliaRt.js.map +1 -0
  5. package/dist/{errors-fLxe1eml.js → errors-DOJdtNTD.js} +367 -316
  6. package/dist/errors-DOJdtNTD.js.map +1 -0
  7. package/dist/errors-DbATYfYA.cjs +2 -0
  8. package/dist/errors-DbATYfYA.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +66 -64
  11. package/dist/tbv/core/index.cjs +1 -1
  12. package/dist/tbv/core/index.js +68 -66
  13. package/dist/tbv/core/managers/PeginManager.d.ts +41 -44
  14. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  15. package/dist/tbv/core/primitives/__tests__/deriveVaultId.test.d.ts +6 -0
  16. package/dist/tbv/core/primitives/__tests__/deriveVaultId.test.d.ts.map +1 -0
  17. package/dist/tbv/core/primitives/index.cjs +1 -1
  18. package/dist/tbv/core/primitives/index.d.ts +2 -2
  19. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  20. package/dist/tbv/core/primitives/index.js +12 -12
  21. package/dist/tbv/core/primitives/psbt/pegin.d.ts +10 -11
  22. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  23. package/dist/tbv/core/utils/fee/constants.d.ts +16 -0
  24. package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -1
  25. package/dist/tbv/core/utils/utxo/selectUtxos.d.ts +2 -1
  26. package/dist/tbv/core/utils/utxo/selectUtxos.d.ts.map +1 -1
  27. package/dist/tbv/index.cjs +1 -1
  28. package/dist/tbv/index.js +68 -66
  29. package/package.json +3 -3
  30. package/dist/challengeAssert-D50t_Qyo.js.map +0 -1
  31. package/dist/challengeAssert-DDceAi0r.cjs +0 -2
  32. package/dist/challengeAssert-DDceAi0r.cjs.map +0 -1
  33. package/dist/errors-CIDTtluC.cjs +0 -2
  34. package/dist/errors-CIDTtluC.cjs.map +0 -1
  35. package/dist/errors-fLxe1eml.js.map +0 -1
@@ -1,55 +1,59 @@
1
- var ue = Object.defineProperty;
2
- var le = (e, t, n) => t in e ? ue(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var f = (e, t, n) => le(e, typeof t != "symbol" ? t + "" : t, n);
4
- import * as he from "bitcoinjs-lib";
5
- import { script as fe, Transaction as st, address as de, Psbt as dt } from "bitcoinjs-lib";
1
+ var ce = Object.defineProperty;
2
+ var ue = (e, t, n) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var f = (e, t, n) => ue(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import * as le from "bitcoinjs-lib";
5
+ import { script as he, Transaction as st, address as fe, Psbt as dt } from "bitcoinjs-lib";
6
6
  import { Buffer as S } from "buffer";
7
- import { P as pe, x as be, D as Dt, M as Tt, B as xe, T as ge, A as pt, t as W, b as ye, z as me, a as we, d as Pe, e as Te, f as ve, r as at, p as ke, w as vt, g as kt, h as Ht } from "./challengeAssert-D50t_Qyo.js";
7
+ import { P as de, x as pe, D as Wt, M as Tt, B as be, T as ge, E as pt, t as D, b as xe, z as ye, C as me, a as we, d as Pe, e as Te, f as ve, r as at, p as ke, w as vt, g as kt, h as Ht } from "./challengeAssert-DnnliaRt.js";
8
8
  import { createPublicClient as It, http as Et, encodeFunctionData as He, zeroAddress as Ie } from "viem";
9
- import { SINGLE_DEPOSIT_HTLC_VOUT as St } from "@babylonlabs-io/babylon-tbv-rust-wasm";
10
- function Ee(e, t, n) {
9
+ import "@babylonlabs-io/babylon-tbv-rust-wasm";
10
+ function Ee(e, t, n, s) {
11
+ if (!Number.isInteger(s) || s < 1)
12
+ throw new Error(
13
+ `Invalid numOutputs: expected a positive integer, got ${s}`
14
+ );
11
15
  if (e.length === 0)
12
16
  throw new Error("Insufficient funds: no UTXOs available");
13
- const s = e.filter((c) => {
14
- const l = S.from(c.scriptPubKey, "hex");
15
- return !!fe.decompile(l);
17
+ const r = e.filter((u) => {
18
+ const h = S.from(u.scriptPubKey, "hex");
19
+ return !!he.decompile(h);
16
20
  });
17
- if (s.length === 0)
21
+ if (r.length === 0)
18
22
  throw new Error(
19
23
  "Insufficient funds: no valid UTXOs available (all have invalid scripts)"
20
24
  );
21
- const r = [...s].sort((c, l) => l.value - c.value), o = [];
22
- let i = 0n, a = 0n;
23
- for (const c of r) {
24
- o.push(c), i += BigInt(c.value);
25
- const l = o.length * pe, h = 2 * Tt, u = l + h + ge;
26
- if (a = BigInt(Math.ceil(u * n)) + BigInt(be(n)), i - t - a > Dt) {
25
+ const o = [...r].sort((u, h) => h.value - u.value), i = [];
26
+ let a = 0n, c = 0n;
27
+ for (const u of o) {
28
+ i.push(u), a += BigInt(u.value);
29
+ const h = i.length * de, l = s * Tt, d = h + l + ge;
30
+ if (c = BigInt(Math.ceil(d * n)) + BigInt(pe(n)), a - t - c > Wt) {
27
31
  const p = BigInt(
28
32
  Math.ceil(Tt * n)
29
33
  );
30
- a += p;
34
+ c += p;
31
35
  }
32
- if (i >= t + a) {
33
- const p = i - t - a;
36
+ if (a >= t + c) {
37
+ const p = a - t - c;
34
38
  return {
35
- selectedUTXOs: o,
36
- totalValue: i,
37
- fee: a,
39
+ selectedUTXOs: i,
40
+ totalValue: a,
41
+ fee: c,
38
42
  changeAmount: p
39
43
  };
40
44
  }
41
45
  }
42
46
  throw new Error(
43
- `Insufficient funds: need ${t + a} sats (${t} pegin + ${a} fee), have ${i} sats`
47
+ `Insufficient funds: need ${t + c} sats (${t} pegin + ${c} fee), have ${a} sats`
44
48
  );
45
49
  }
46
50
  function zn(e) {
47
- return e > Dt;
51
+ return e > Wt;
48
52
  }
49
53
  function qn() {
50
- return xe;
54
+ return be;
51
55
  }
52
- function At(e) {
56
+ function St(e) {
53
57
  const t = e.startsWith("0x") ? e.slice(2) : e;
54
58
  return `0x${st.fromHex(t).getId()}`;
55
59
  }
@@ -66,25 +70,25 @@ function Zn(e, t, n) {
66
70
  const s = pt(n), r = new st();
67
71
  r.version = 2;
68
72
  for (const c of e) {
69
- const l = S.from(c.txid, "hex").reverse();
70
- r.addInput(l, c.vout);
73
+ const u = S.from(c.txid, "hex").reverse();
74
+ r.addInput(u, c.vout);
71
75
  }
72
76
  const o = [];
73
77
  for (let c = 0; c < t.length; c++) {
74
- const l = t[c];
78
+ const u = t[c];
75
79
  let h;
76
80
  try {
77
- h = de.toOutputScript(l.address, s);
78
- } catch (u) {
81
+ h = fe.toOutputScript(u.address, s);
82
+ } catch (l) {
79
83
  throw new Error(
80
- `Failed to decode address "${l.address}": ${u instanceof Error ? u.message : String(u)}`
84
+ `Failed to decode address "${u.address}": ${l instanceof Error ? l.message : String(l)}`
81
85
  );
82
86
  }
83
- r.addOutput(h, Number(l.amount)), o.push({
87
+ r.addOutput(h, Number(u.amount)), o.push({
84
88
  txid: "",
85
89
  // Will be set after txid calculation
86
90
  vout: c,
87
- value: Number(l.amount),
91
+ value: Number(u.amount),
88
92
  scriptPubKey: h.toString("hex")
89
93
  });
90
94
  }
@@ -111,10 +115,10 @@ function Jn(e, t, n) {
111
115
  const i = s.ins[o], a = t[o];
112
116
  if (!a)
113
117
  throw new Error(`Missing UTXO data for input ${o}`);
114
- const c = S.from(i.hash).reverse().toString("hex"), l = i.index;
115
- if (a.txid !== c || a.vout !== l)
118
+ const c = S.from(i.hash).reverse().toString("hex"), u = i.index;
119
+ if (a.txid !== c || a.vout !== u)
116
120
  throw new Error(
117
- `Input ${o} outpoint mismatch: transaction expects ${c}:${l}, but UTXO ${a.txid}:${a.vout} was provided. Ensure inputs array matches the order used in createSplitTransaction().`
121
+ `Input ${o} outpoint mismatch: transaction expects ${c}:${u}, but UTXO ${a.txid}:${a.vout} was provided. Ensure inputs array matches the order used in createSplitTransaction().`
118
122
  );
119
123
  const h = S.from(a.scriptPubKey, "hex");
120
124
  if (!(h.length === 34 && h[0] === 81 && // OP_1 (witness version 1)
@@ -206,17 +210,17 @@ function bt(e, t) {
206
210
  }))
207
211
  };
208
212
  }
209
- const Be = 21e6 * 1e8, Kt = 1e4;
210
- function Mt(e) {
213
+ const Be = 21e6 * 1e8, Dt = 1e4;
214
+ function Kt(e) {
211
215
  return Number.isInteger(e) && e > 0 && e <= Be;
212
216
  }
213
- function Ue(e) {
214
- return Number.isInteger(e) && e > 0 && e <= Kt;
217
+ function $e(e) {
218
+ return Number.isInteger(e) && e > 0 && e <= Dt;
215
219
  }
216
- function Nt(e, t) {
220
+ function Mt(e, t) {
217
221
  return !Number.isInteger(e) || e < 0 ? !1 : t === void 0 || e < t;
218
222
  }
219
- const $e = {
223
+ const Ue = {
220
224
  mainnet: "https://mempool.space/api",
221
225
  testnet: "https://mempool.space/testnet/api",
222
226
  signet: "https://mempool.space/signet/api"
@@ -279,14 +283,14 @@ async function Yn(e, t) {
279
283
  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`);
280
284
  }
281
285
  }
282
- async function Oe(e, t, n) {
286
+ async function Ce(e, t, n) {
283
287
  const s = await Fe(e, n);
284
- if (!Nt(t, s.vout.length))
288
+ if (!Mt(t, s.vout.length))
285
289
  throw new Error(
286
290
  `Invalid vout ${t} for transaction ${e} (has ${s.vout.length} outputs)`
287
291
  );
288
292
  const r = s.vout[t];
289
- if (!Mt(r.value))
293
+ if (!Kt(r.value))
290
294
  throw new Error(`Invalid UTXO value ${r.value} for ${e}:${t}`);
291
295
  return {
292
296
  txid: e,
@@ -303,9 +307,9 @@ async function Qn(e, t) {
303
307
  `Invalid Bitcoin address: ${e}. Mempool API validation failed.`
304
308
  );
305
309
  for (const o of n) {
306
- if (!Nt(o.vout))
310
+ if (!Mt(o.vout))
307
311
  throw new Error(`Invalid vout ${o.vout} for ${o.txid}`);
308
- if (!Mt(o.value))
312
+ if (!Kt(o.value))
309
313
  throw new Error(
310
314
  `Invalid UTXO value ${o.value} for ${o.txid}:${o.vout}`
311
315
  );
@@ -326,7 +330,7 @@ async function Qn(e, t) {
326
330
  }
327
331
  }
328
332
  function ts(e) {
329
- return $e[e];
333
+ return Ue[e];
330
334
  }
331
335
  async function es(e, t) {
332
336
  return nt(`${t}/address/${e}/txs`);
@@ -345,9 +349,9 @@ async function ns(e) {
345
349
  "minimumFee"
346
350
  ];
347
351
  for (const r of s)
348
- if (!Ue(n[r]))
352
+ if (!$e(n[r]))
349
353
  throw new Error(
350
- `Invalid fee rate ${r}=${n[r]} from mempool API: expected a positive number ≤ ${Kt}`
354
+ `Invalid fee rate ${r}=${n[r]} from mempool API: expected a positive number ≤ ${Dt}`
351
355
  );
352
356
  if (n.minimumFee > n.economyFee || n.economyFee > n.hourFee || n.hourFee > n.halfHourFee || n.halfHourFee > n.fastestFee)
353
357
  throw new Error(
@@ -614,7 +618,7 @@ const ct = [
614
618
  name: "PeginSignaturesIncomplete",
615
619
  inputs: []
616
620
  }
617
- ], D = {
621
+ ], K = {
618
622
  // VaultAlreadyExists()
619
623
  "0x04aabf33": "Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.",
620
624
  // ScriptPubKeyMismatch() - taproot output doesn't match expected script
@@ -644,7 +648,7 @@ const ct = [
644
648
  // InvalidPeginFee(uint256,uint256)
645
649
  "0x979f4518": "Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction."
646
650
  };
647
- function gt(e) {
651
+ function xt(e) {
648
652
  if (!e || typeof e != "object") return;
649
653
  const t = e;
650
654
  if (typeof t.data == "string" && t.data.startsWith("0x"))
@@ -664,23 +668,23 @@ function gt(e) {
664
668
  return i[1];
665
669
  }
666
670
  function ss(e) {
667
- const t = gt(e);
671
+ const t = xt(e);
668
672
  if (t) {
669
673
  const n = t.substring(0, 10);
670
- return D[t] ?? D[n];
674
+ return K[t] ?? K[n];
671
675
  }
672
676
  }
673
677
  function rs(e) {
674
- const t = gt(e);
678
+ const t = xt(e);
675
679
  if (t === void 0) return !1;
676
680
  const n = t.substring(0, 10);
677
- return t in D || n in D;
681
+ return t in K || n in K;
678
682
  }
679
683
  function ut(e) {
680
684
  console.error("[Contract Error] Raw error:", e);
681
- const t = gt(e);
685
+ const t = xt(e);
682
686
  if (console.error("[Contract Error] Extracted error data:", t), t) {
683
- const s = t.substring(0, 10), r = D[t] ?? D[s];
687
+ const s = t.substring(0, 10), r = K[t] ?? K[s];
684
688
  if (r)
685
689
  throw console.error("[Contract Error] Known error:", r), new Error(r);
686
690
  }
@@ -698,14 +702,14 @@ function ut(e) {
698
702
  }
699
703
  throw e instanceof Error ? (console.error("[Contract Error] Unhandled error:", e.message), e) : new Error(`Contract call failed: ${String(e)}`);
700
704
  }
701
- function Ce(e, t, n, s) {
705
+ function Oe(e, t, n, s) {
702
706
  const r = n == null ? void 0 : n[`${e}:${t}`];
703
707
  return r ? Promise.resolve({
704
708
  txid: e,
705
709
  vout: t,
706
710
  value: r.value,
707
711
  scriptPubKey: r.scriptPubKey
708
- }) : Oe(e, t, s);
712
+ }) : Ce(e, t, s);
709
713
  }
710
714
  const _e = 12e4;
711
715
  class os {
@@ -739,11 +743,13 @@ class os {
739
743
  * @throws Error if wallet operations fail or insufficient funds
740
744
  */
741
745
  async preparePegin(t) {
742
- const n = await this.config.btcWallet.getPublicKeyHex(), s = n.length === 66 ? n.slice(2) : n, r = W(t.vaultProviderBtcPubkey), o = t.vaultKeeperBtcPubkeys.map(W), i = t.universalChallengerBtcPubkeys.map(W);
743
- if (t.hashlocks.length !== 1)
746
+ const n = await this.config.btcWallet.getPublicKeyHex(), s = n.length === 66 ? n.slice(2) : n, r = D(t.vaultProviderBtcPubkey), o = t.vaultKeeperBtcPubkeys.map(D), i = t.universalChallengerBtcPubkeys.map(D);
747
+ if (t.hashlocks.length !== t.amounts.length)
744
748
  throw new Error(
745
- "hashlocks must contain exactly one entry (batched deposits not yet supported)"
749
+ `hashlocks.length (${t.hashlocks.length}) must equal amounts.length (${t.amounts.length})`
746
750
  );
751
+ if (t.hashlocks.length === 0)
752
+ throw new Error("hashlocks must contain at least one entry");
747
753
  const a = o.length, c = {
748
754
  depositorPubkey: s,
749
755
  vaultProviderPubkey: r,
@@ -751,58 +757,102 @@ class os {
751
757
  universalChallengerPubkeys: i,
752
758
  hashlocks: t.hashlocks,
753
759
  timelockRefund: t.timelockRefund,
754
- pegInAmount: t.amount,
760
+ pegInAmounts: t.amounts,
755
761
  feeRate: t.protocolFeeRate,
756
762
  numLocalChallengers: a,
757
763
  councilQuorum: t.councilQuorum,
758
764
  councilSize: t.councilSize,
759
765
  network: this.config.btcNetwork
760
- }, l = await ye(c), h = Ee(
766
+ }, u = await xe(c), h = Ee(
761
767
  [...t.availableUTXOs],
762
- l.totalOutputValue,
763
- t.mempoolFeeRate
764
- ), u = pt(this.config.btcNetwork), d = me({
765
- unfundedTxHex: l.psbtHex,
768
+ u.totalOutputValue,
769
+ t.mempoolFeeRate,
770
+ ye(u.htlcValues.length)
771
+ ), l = pt(this.config.btcNetwork), d = me({
772
+ unfundedTxHex: u.psbtHex,
766
773
  selectedUTXOs: h.selectedUTXOs,
767
774
  changeAddress: t.changeAddress,
768
775
  changeAmount: h.changeAmount,
769
- network: u
770
- }), p = W(At(d)), b = await we({
771
- prePeginParams: c,
772
- timelockPegin: t.timelockPegin,
773
- fundedPrePeginTxHex: d,
774
- htlcVout: St
775
- }), m = await Pe({
776
- peginTxHex: b.txHex,
777
- fundedPrePeginTxHex: d,
778
- depositorPubkey: s,
779
- vaultProviderPubkey: r,
780
- vaultKeeperPubkeys: o,
781
- universalChallengerPubkeys: i,
782
- hashlock: t.hashlocks[0],
783
- timelockRefund: t.timelockRefund,
784
- network: this.config.btcNetwork
785
- }), x = await this.config.btcWallet.signPsbt(
786
- m.psbtHex,
787
- bt(n, 1)
788
- ), y = Te(
789
- x,
790
- s
791
- ), w = ve(x);
776
+ network: l
777
+ }), g = D(St(d)), p = [], m = [], x = [];
778
+ for (let b = 0; b < t.hashlocks.length; b++) {
779
+ const P = await we({
780
+ prePeginParams: c,
781
+ timelockPegin: t.timelockPegin,
782
+ fundedPrePeginTxHex: d,
783
+ htlcVout: b
784
+ }), T = await Pe({
785
+ peginTxHex: P.txHex,
786
+ fundedPrePeginTxHex: d,
787
+ depositorPubkey: s,
788
+ vaultProviderPubkey: r,
789
+ vaultKeeperPubkeys: o,
790
+ universalChallengerPubkeys: i,
791
+ hashlock: t.hashlocks[b],
792
+ timelockRefund: t.timelockRefund,
793
+ network: this.config.btcNetwork
794
+ });
795
+ p.push(P), m.push(T.psbtHex), x.push(
796
+ bt(n, 1)
797
+ );
798
+ }
799
+ const y = await this.signPsbtsWithFallback(
800
+ m,
801
+ x
802
+ ), w = [];
803
+ for (let b = 0; b < y.length; b++) {
804
+ const P = Te(
805
+ y[b],
806
+ s
807
+ ), T = ve(y[b]);
808
+ w.push({
809
+ htlcVout: b,
810
+ htlcValue: u.htlcValues[b],
811
+ peginTxHex: T,
812
+ peginTxid: p[b].txid,
813
+ peginInputSignature: P,
814
+ vaultScriptPubKey: p[b].vaultScriptPubKey
815
+ });
816
+ }
792
817
  return {
793
818
  fundedPrePeginTxHex: d,
794
- htlcValue: l.htlcValue,
795
- signedPeginInputPsbtHex: x,
796
- peginInputSignature: y,
797
- vaultScriptPubKey: b.vaultScriptPubKey,
798
- peginTxHex: w,
799
- prePeginTxid: p,
800
- peginTxid: b.txid,
819
+ prePeginTxid: g,
820
+ unsignedPrePeginTxHex: u.psbtHex,
821
+ perVault: w,
801
822
  selectedUTXOs: h.selectedUTXOs,
802
823
  fee: h.fee,
803
824
  changeAmount: h.changeAmount
804
825
  };
805
826
  }
827
+ /**
828
+ * Signs multiple PSBTs using batch signing if available, falling back to sequential signing.
829
+ *
830
+ * Wallets that support native batch signing (e.g. UniSat) will sign all PSBTs
831
+ * in a single interaction. Others (e.g. Ledger, AppKit) implement signPsbts
832
+ * by looping signPsbt internally, so the UX depends on the wallet adapter.
833
+ */
834
+ async signPsbtsWithFallback(t, n) {
835
+ if (typeof this.config.btcWallet.signPsbts == "function") {
836
+ const r = await this.config.btcWallet.signPsbts(
837
+ t,
838
+ n
839
+ );
840
+ if (r.length !== t.length)
841
+ throw new Error(
842
+ `Expected ${t.length} signed PSBTs but received ${r.length}`
843
+ );
844
+ return r;
845
+ }
846
+ const s = [];
847
+ for (let r = 0; r < t.length; r++) {
848
+ const o = await this.config.btcWallet.signPsbt(
849
+ t[r],
850
+ n[r]
851
+ );
852
+ s.push(o);
853
+ }
854
+ return s;
855
+ }
806
856
  /**
807
857
  * Signs and broadcasts a funded peg-in transaction to the Bitcoin network.
808
858
  *
@@ -834,13 +884,13 @@ class os {
834
884
  throw new Error(
835
885
  `Invalid depositorBtcPubkey length: expected 32 bytes, got ${c.length}`
836
886
  );
837
- const l = this.config.mempoolApiUrl, h = o.ins.map((x) => {
887
+ const u = this.config.mempoolApiUrl, h = o.ins.map((x) => {
838
888
  const y = S.from(x.hash).reverse().toString("hex"), w = x.index;
839
- return Ce(y, w, t.localPrevouts, l).then(
840
- (g) => ({ input: x, utxoData: g, txid: y, vout: w })
889
+ return Oe(y, w, t.localPrevouts, u).then(
890
+ (b) => ({ input: x, utxoData: b, txid: y, vout: w })
841
891
  );
842
- }), u = await Promise.all(h);
843
- for (const { input: x, utxoData: y, txid: w, vout: g } of u) {
892
+ }), l = await Promise.all(h);
893
+ for (const { input: x, utxoData: y, txid: w, vout: b } of l) {
844
894
  const P = Ae(
845
895
  {
846
896
  value: y.value,
@@ -860,19 +910,19 @@ class os {
860
910
  script: x.script,
861
911
  value: x.value
862
912
  });
863
- const d = await this.config.btcWallet.signPsbt(i.toHex()), p = dt.fromHex(d);
913
+ const d = await this.config.btcWallet.signPsbt(i.toHex()), g = dt.fromHex(d);
864
914
  try {
865
- p.finalizeAllInputs();
915
+ g.finalizeAllInputs();
866
916
  } catch (x) {
867
- if (!p.data.inputs.every(
917
+ if (!g.data.inputs.every(
868
918
  (w) => w.finalScriptWitness || w.finalScriptSig
869
919
  ))
870
920
  throw new Error(
871
921
  `PSBT finalization failed and wallet did not auto-finalize: ${x}`
872
922
  );
873
923
  }
874
- const b = p.extractTransaction().toHex();
875
- return await Le(b, l);
924
+ const p = g.extractTransaction().toHex();
925
+ return await Le(p, u);
876
926
  }
877
927
  /**
878
928
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -898,32 +948,33 @@ class os {
898
948
  depositorSignedPeginTx: r,
899
949
  vaultProvider: o,
900
950
  hashlock: i,
901
- onPopSigned: a,
902
- depositorPayoutBtcAddress: c,
903
- depositorLamportPkHash: l,
904
- preSignedBtcPopSignature: h
951
+ htlcVout: a,
952
+ onPopSigned: c,
953
+ depositorPayoutBtcAddress: u,
954
+ depositorLamportPkHash: h,
955
+ preSignedBtcPopSignature: l
905
956
  } = t;
906
957
  if (!this.config.ethWallet.account)
907
958
  throw new Error("Ethereum wallet account not found");
908
- const u = this.config.ethWallet.account.address, d = await this.resolvePopSignature(
909
- u,
910
- h
959
+ const d = this.config.ethWallet.account.address, g = await this.resolvePopSignature(
960
+ d,
961
+ l
911
962
  );
912
- a && await a();
913
- const p = at(n), b = at(s), m = at(r), x = await this.resolvePayoutScriptPubKey(
914
- c
915
- ), y = At(m);
916
- if (await this.checkVaultExists(y))
963
+ c && await c();
964
+ const p = at(n), m = at(s), x = at(r), y = await this.resolvePayoutScriptPubKey(
965
+ u
966
+ ), w = St(x);
967
+ if (await this.checkVaultExists(w))
917
968
  throw new Error(
918
- `Vault already exists for this transaction (ID: ${y}). Vault IDs are deterministically derived from the unsigned Bitcoin transaction, so using the same UTXOs and amount will always produce the same vault. To create a new vault, please use different UTXOs or a different amount to generate a unique transaction.`
969
+ `Vault already exists for this transaction (ID: ${w}). Vault IDs are deterministically derived from the unsigned Bitcoin transaction, so using the same UTXOs and amount will always produce the same vault. To create a new vault, please use different UTXOs or a different amount to generate a unique transaction.`
919
970
  );
920
- const g = It({
971
+ const P = It({
921
972
  chain: this.config.ethChain,
922
973
  transport: Et()
923
974
  });
924
- let P;
975
+ let T;
925
976
  try {
926
- P = await g.readContract({
977
+ T = await P.readContract({
927
978
  address: this.config.vaultContracts.btcVaultRegistry,
928
979
  abi: ct,
929
980
  functionName: "getPegInFee",
@@ -938,54 +989,54 @@ class os {
938
989
  abi: ct,
939
990
  functionName: "submitPeginRequest",
940
991
  args: [
941
- u,
942
- p,
943
992
  d,
944
- b,
993
+ p,
994
+ g,
945
995
  m,
996
+ x,
946
997
  o,
947
998
  i,
948
- St,
949
- x,
950
- l
999
+ a,
1000
+ y,
1001
+ h
951
1002
  ]
952
1003
  });
953
- let T;
1004
+ let E;
954
1005
  try {
955
- T = await g.estimateGas({
1006
+ E = await P.estimateGas({
956
1007
  to: this.config.vaultContracts.btcVaultRegistry,
957
1008
  data: v,
958
- value: P,
1009
+ value: T,
959
1010
  account: this.config.ethWallet.account.address
960
1011
  });
961
- } catch (k) {
962
- ut(k);
1012
+ } catch (U) {
1013
+ ut(U);
963
1014
  }
964
- let E;
1015
+ let k;
965
1016
  try {
966
- E = await this.config.ethWallet.sendTransaction({
1017
+ k = await this.config.ethWallet.sendTransaction({
967
1018
  to: this.config.vaultContracts.btcVaultRegistry,
968
1019
  data: v,
969
- value: P,
1020
+ value: T,
970
1021
  account: this.config.ethWallet.account,
971
1022
  chain: this.config.ethChain,
972
- gas: T
1023
+ gas: E
973
1024
  });
974
- } catch (k) {
975
- ut(k);
1025
+ } catch (U) {
1026
+ ut(U);
976
1027
  }
977
- const I = await g.waitForTransactionReceipt({
978
- hash: E,
1028
+ const I = await P.waitForTransactionReceipt({
1029
+ hash: k,
979
1030
  timeout: _e
980
1031
  });
981
1032
  return I.status === "reverted" && ut(
982
1033
  new Error(
983
- `Transaction reverted. Hash: ${E}. Check the transaction on block explorer for details.`
1034
+ `Transaction reverted. Hash: ${k}. Check the transaction on block explorer for details.`
984
1035
  )
985
1036
  ), {
986
1037
  ethTxHash: I.transactionHash,
987
- vaultId: y,
988
- btcPopSignature: d
1038
+ vaultId: w,
1039
+ btcPopSignature: g
989
1040
  };
990
1041
  }
991
1042
  /**
@@ -1034,7 +1085,7 @@ class os {
1034
1085
  }
1035
1086
  const s = pt(this.config.btcNetwork);
1036
1087
  try {
1037
- return `0x${he.address.toOutputScript(n, s).toString("hex")}`;
1088
+ return `0x${le.address.toOutputScript(n, s).toString("hex")}`;
1038
1089
  } catch {
1039
1090
  throw new Error(
1040
1091
  `Invalid BTC payout address: "${n}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
@@ -1160,16 +1211,16 @@ class is {
1160
1211
  );
1161
1212
  const n = await this.config.btcWallet.getPublicKeyHex(), s = [], r = [], o = [];
1162
1213
  for (const c of t) {
1163
- const { depositorPubkey: l } = vt(
1214
+ const { depositorPubkey: u } = vt(
1164
1215
  n,
1165
1216
  c.depositorBtcPubkey
1166
1217
  );
1167
- o.push(l);
1218
+ o.push(u);
1168
1219
  const h = await kt({
1169
1220
  payoutTxHex: c.payoutTxHex,
1170
1221
  peginTxHex: c.peginTxHex,
1171
1222
  assertTxHex: c.assertTxHex,
1172
- depositorBtcPubkey: l,
1223
+ depositorBtcPubkey: u,
1173
1224
  vaultProviderBtcPubkey: c.vaultProviderBtcPubkey,
1174
1225
  vaultKeeperBtcPubkeys: c.vaultKeeperBtcPubkeys,
1175
1226
  universalChallengerBtcPubkeys: c.universalChallengerBtcPubkeys,
@@ -1188,13 +1239,13 @@ class is {
1188
1239
  );
1189
1240
  const a = [];
1190
1241
  for (let c = 0; c < t.length; c++) {
1191
- const l = o[c], h = Ht(
1242
+ const u = o[c], h = Ht(
1192
1243
  i[c],
1193
- l
1244
+ u
1194
1245
  );
1195
1246
  a.push({
1196
1247
  payoutSignature: h,
1197
- depositorBtcPubkey: l
1248
+ depositorBtcPubkey: u
1198
1249
  });
1199
1250
  }
1200
1251
  return a;
@@ -1203,13 +1254,13 @@ class is {
1203
1254
  function Re(e) {
1204
1255
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
1205
1256
  }
1206
- function C(e, t = "") {
1257
+ function _(e, t = "") {
1207
1258
  if (!Number.isSafeInteger(e) || e < 0) {
1208
1259
  const n = t && `"${t}" `;
1209
1260
  throw new Error(`${n}expected integer >= 0, got ${e}`);
1210
1261
  }
1211
1262
  }
1212
- function _(e, t, n = "") {
1263
+ function R(e, t, n = "") {
1213
1264
  const s = Re(e), r = e == null ? void 0 : e.length, o = t !== void 0;
1214
1265
  if (!s || o && r !== t) {
1215
1266
  const i = n && `"${n}" `, a = o ? ` of length ${t}` : "", c = s ? `length=${r}` : `type=${typeof e}`;
@@ -1217,19 +1268,19 @@ function _(e, t, n = "") {
1217
1268
  }
1218
1269
  return e;
1219
1270
  }
1220
- function Xt(e) {
1271
+ function Nt(e) {
1221
1272
  if (typeof e != "function" || typeof e.create != "function")
1222
1273
  throw new Error("Hash must wrapped by utils.createHasher");
1223
- C(e.outputLen), C(e.blockLen);
1274
+ _(e.outputLen), _(e.blockLen);
1224
1275
  }
1225
- function K(e, t = !0) {
1276
+ function M(e, t = !0) {
1226
1277
  if (e.destroyed)
1227
1278
  throw new Error("Hash instance has been destroyed");
1228
1279
  if (t && e.finished)
1229
1280
  throw new Error("Hash#digest() has already been called");
1230
1281
  }
1231
- function Gt(e, t) {
1232
- _(e, void 0, "digestInto() output");
1282
+ function Xt(e, t) {
1283
+ R(e, void 0, "digestInto() output");
1233
1284
  const n = t.outputLen;
1234
1285
  if (e.length < n)
1235
1286
  throw new Error('"digestInto() output" expected to be of length >=' + n);
@@ -1247,7 +1298,7 @@ function et(e) {
1247
1298
  function B(e, t) {
1248
1299
  return e << 32 - t | e >>> t;
1249
1300
  }
1250
- function j(e, t) {
1301
+ function G(e, t) {
1251
1302
  return e << t | e >>> 32 - t >>> 0;
1252
1303
  }
1253
1304
  const We = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
@@ -1259,14 +1310,14 @@ function Ke(e) {
1259
1310
  e[t] = De(e[t]);
1260
1311
  return e;
1261
1312
  }
1262
- const Bt = We ? (e) => e : Ke;
1313
+ const At = We ? (e) => e : Ke;
1263
1314
  function Me(e) {
1264
1315
  if (typeof e != "string")
1265
1316
  throw new Error("string expected");
1266
1317
  return new Uint8Array(new TextEncoder().encode(e));
1267
1318
  }
1268
- function Ut(e, t = "") {
1269
- return typeof e == "string" ? Me(e) : _(e, void 0, t);
1319
+ function Bt(e, t = "") {
1320
+ return typeof e == "string" ? Me(e) : R(e, void 0, t);
1270
1321
  }
1271
1322
  function Ne(e, t) {
1272
1323
  if (t !== void 0 && {}.toString.call(t) !== "[object Object]")
@@ -1280,7 +1331,7 @@ function rt(e, t = {}) {
1280
1331
  const jt = (e) => ({
1281
1332
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, e])
1282
1333
  });
1283
- class zt {
1334
+ class Gt {
1284
1335
  constructor(t, n) {
1285
1336
  f(this, "oHash");
1286
1337
  f(this, "iHash");
@@ -1288,7 +1339,7 @@ class zt {
1288
1339
  f(this, "outputLen");
1289
1340
  f(this, "finished", !1);
1290
1341
  f(this, "destroyed", !1);
1291
- if (Xt(t), _(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
1342
+ if (Nt(t), R(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
1292
1343
  throw new Error("Expected instance of class which extends utils.Hash");
1293
1344
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
1294
1345
  const s = this.blockLen, r = new Uint8Array(s);
@@ -1301,10 +1352,10 @@ class zt {
1301
1352
  this.oHash.update(r), A(r);
1302
1353
  }
1303
1354
  update(t) {
1304
- return K(this), this.iHash.update(t), this;
1355
+ return M(this), this.iHash.update(t), this;
1305
1356
  }
1306
1357
  digestInto(t) {
1307
- K(this), _(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1358
+ M(this), R(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1308
1359
  }
1309
1360
  digest() {
1310
1361
  const t = new Uint8Array(this.oHash.outputLen);
@@ -1322,12 +1373,12 @@ class zt {
1322
1373
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
1323
1374
  }
1324
1375
  }
1325
- const yt = (e, t, n) => new zt(e, t).update(n).digest();
1326
- yt.create = (e, t) => new zt(e, t);
1376
+ const yt = (e, t, n) => new Gt(e, t).update(n).digest();
1377
+ yt.create = (e, t) => new Gt(e, t);
1327
1378
  function Xe(e, t, n) {
1328
1379
  return e & t ^ ~e & n;
1329
1380
  }
1330
- function Ge(e, t, n) {
1381
+ function je(e, t, n) {
1331
1382
  return e & t ^ e & n ^ t & n;
1332
1383
  }
1333
1384
  class mt {
@@ -1346,7 +1397,7 @@ class mt {
1346
1397
  this.blockLen = t, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(t), this.view = et(this.buffer);
1347
1398
  }
1348
1399
  update(t) {
1349
- K(this), _(t);
1400
+ M(this), R(t);
1350
1401
  const { view: n, buffer: s, blockLen: r } = this, o = t.length;
1351
1402
  for (let i = 0; i < o; ) {
1352
1403
  const a = Math.min(r - this.pos, o - i);
@@ -1361,21 +1412,21 @@ class mt {
1361
1412
  return this.length += t.length, this.roundClean(), this;
1362
1413
  }
1363
1414
  digestInto(t) {
1364
- K(this), Gt(t, this), this.finished = !0;
1415
+ M(this), Xt(t, this), this.finished = !0;
1365
1416
  const { buffer: n, view: s, blockLen: r, isLE: o } = this;
1366
1417
  let { pos: i } = this;
1367
1418
  n[i++] = 128, A(this.buffer.subarray(i)), this.padOffset > r - i && (this.process(s, 0), i = 0);
1368
- for (let u = i; u < r; u++)
1369
- n[u] = 0;
1419
+ for (let l = i; l < r; l++)
1420
+ n[l] = 0;
1370
1421
  s.setBigUint64(r - 8, BigInt(this.length * 8), o), this.process(s, 0);
1371
1422
  const a = et(t), c = this.outputLen;
1372
1423
  if (c % 4)
1373
1424
  throw new Error("_sha2: outputLen must be aligned to 32bit");
1374
- const l = c / 4, h = this.get();
1375
- if (l > h.length)
1425
+ const u = c / 4, h = this.get();
1426
+ if (u > h.length)
1376
1427
  throw new Error("_sha2: outputLen bigger than state");
1377
- for (let u = 0; u < l; u++)
1378
- a.setUint32(4 * u, h[u], o);
1428
+ for (let l = 0; l < u; l++)
1429
+ a.setUint32(4 * l, h[l], o);
1379
1430
  }
1380
1431
  digest() {
1381
1432
  const { buffer: t, outputLen: n } = this;
@@ -1392,7 +1443,7 @@ class mt {
1392
1443
  return this._cloneInto();
1393
1444
  }
1394
1445
  }
1395
- const $ = /* @__PURE__ */ Uint32Array.from([
1446
+ const L = /* @__PURE__ */ Uint32Array.from([
1396
1447
  1779033703,
1397
1448
  3144134277,
1398
1449
  1013904242,
@@ -1418,7 +1469,7 @@ const $ = /* @__PURE__ */ Uint32Array.from([
1418
1469
  4215389547,
1419
1470
  1541459225,
1420
1471
  327033209
1421
- ]), je = /* @__PURE__ */ Uint8Array.from([
1472
+ ]), Ge = /* @__PURE__ */ Uint8Array.from([
1422
1473
  7,
1423
1474
  4,
1424
1475
  13,
@@ -1435,19 +1486,19 @@ const $ = /* @__PURE__ */ Uint32Array.from([
1435
1486
  14,
1436
1487
  11,
1437
1488
  8
1438
- ]), qt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), ze = qt.map((e) => (9 * e + 5) % 16), Zt = /* @__PURE__ */ (() => {
1439
- const n = [[qt], [ze]];
1489
+ ]), zt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), ze = zt.map((e) => (9 * e + 5) % 16), qt = /* @__PURE__ */ (() => {
1490
+ const n = [[zt], [ze]];
1440
1491
  for (let s = 0; s < 4; s++)
1441
1492
  for (let r of n)
1442
- r.push(r[s].map((o) => je[o]));
1493
+ r.push(r[s].map((o) => Ge[o]));
1443
1494
  return n;
1444
- })(), Jt = Zt[0], Yt = Zt[1], Qt = /* @__PURE__ */ [
1495
+ })(), Zt = qt[0], Jt = qt[1], Yt = /* @__PURE__ */ [
1445
1496
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
1446
1497
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
1447
1498
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
1448
1499
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
1449
1500
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
1450
- ].map((e) => Uint8Array.from(e)), qe = /* @__PURE__ */ Jt.map((e, t) => e.map((n) => Qt[t][n])), Ze = /* @__PURE__ */ Yt.map((e, t) => e.map((n) => Qt[t][n])), Je = /* @__PURE__ */ Uint32Array.from([
1501
+ ].map((e) => Uint8Array.from(e)), qe = /* @__PURE__ */ Zt.map((e, t) => e.map((n) => Yt[t][n])), Ze = /* @__PURE__ */ Jt.map((e, t) => e.map((n) => Yt[t][n])), Je = /* @__PURE__ */ Uint32Array.from([
1451
1502
  0,
1452
1503
  1518500249,
1453
1504
  1859775393,
@@ -1481,21 +1532,21 @@ class Qe extends mt {
1481
1532
  this.h0 = n | 0, this.h1 = s | 0, this.h2 = r | 0, this.h3 = o | 0, this.h4 = i | 0;
1482
1533
  }
1483
1534
  process(n, s) {
1484
- for (let b = 0; b < 16; b++, s += 4)
1485
- z[b] = n.getUint32(s, !0);
1486
- let r = this.h0 | 0, o = r, i = this.h1 | 0, a = i, c = this.h2 | 0, l = c, h = this.h3 | 0, u = h, d = this.h4 | 0, p = d;
1487
- for (let b = 0; b < 5; b++) {
1488
- const m = 4 - b, x = Je[b], y = Ye[b], w = Jt[b], g = Yt[b], P = qe[b], v = Ze[b];
1489
- for (let T = 0; T < 16; T++) {
1490
- const E = j(r + $t(b, i, c, h) + z[w[T]] + x, P[T]) + d | 0;
1491
- r = d, d = h, h = j(c, 10) | 0, c = i, i = E;
1535
+ for (let p = 0; p < 16; p++, s += 4)
1536
+ z[p] = n.getUint32(s, !0);
1537
+ let r = this.h0 | 0, o = r, i = this.h1 | 0, a = i, c = this.h2 | 0, u = c, h = this.h3 | 0, l = h, d = this.h4 | 0, g = d;
1538
+ for (let p = 0; p < 5; p++) {
1539
+ const m = 4 - p, x = Je[p], y = Ye[p], w = Zt[p], b = Jt[p], P = qe[p], T = Ze[p];
1540
+ for (let v = 0; v < 16; v++) {
1541
+ const E = G(r + $t(p, i, c, h) + z[w[v]] + x, P[v]) + d | 0;
1542
+ r = d, d = h, h = G(c, 10) | 0, c = i, i = E;
1492
1543
  }
1493
- for (let T = 0; T < 16; T++) {
1494
- const E = j(o + $t(m, a, l, u) + z[g[T]] + y, v[T]) + p | 0;
1495
- o = p, p = u, u = j(l, 10) | 0, l = a, a = E;
1544
+ for (let v = 0; v < 16; v++) {
1545
+ const E = G(o + $t(m, a, u, l) + z[b[v]] + y, T[v]) + g | 0;
1546
+ o = g, g = l, l = G(u, 10) | 0, u = a, a = E;
1496
1547
  }
1497
1548
  }
1498
- this.set(this.h1 + c + u | 0, this.h2 + h + p | 0, this.h3 + d + o | 0, this.h4 + r + a | 0, this.h0 + i + l | 0);
1549
+ this.set(this.h1 + c + l | 0, this.h2 + h + g | 0, this.h3 + d + o | 0, this.h4 + r + a | 0, this.h0 + i + u | 0);
1499
1550
  }
1500
1551
  roundClean() {
1501
1552
  A(z);
@@ -1504,11 +1555,11 @@ class Qe extends mt {
1504
1555
  this.destroyed = !0, A(this.buffer), this.set(0, 0, 0, 0, 0);
1505
1556
  }
1506
1557
  }
1507
- const tn = /* @__PURE__ */ rt(() => new Qe()), q = /* @__PURE__ */ BigInt(2 ** 32 - 1), Lt = /* @__PURE__ */ BigInt(32);
1558
+ const tn = /* @__PURE__ */ rt(() => new Qe()), q = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ut = /* @__PURE__ */ BigInt(32);
1508
1559
  function en(e, t = !1) {
1509
- return t ? { h: Number(e & q), l: Number(e >> Lt & q) } : { h: Number(e >> Lt & q) | 0, l: Number(e & q) | 0 };
1560
+ return t ? { h: Number(e & q), l: Number(e >> Ut & q) } : { h: Number(e >> Ut & q) | 0, l: Number(e & q) | 0 };
1510
1561
  }
1511
- function te(e, t = !1) {
1562
+ function Qt(e, t = !1) {
1512
1563
  const n = e.length;
1513
1564
  let s = new Uint32Array(n), r = new Uint32Array(n);
1514
1565
  for (let o = 0; o < n; o++) {
@@ -1517,8 +1568,8 @@ function te(e, t = !1) {
1517
1568
  }
1518
1569
  return [s, r];
1519
1570
  }
1520
- const Ft = (e, t, n) => e >>> n, Ot = (e, t, n) => e << 32 - n | t >>> n, R = (e, t, n) => e >>> n | t << 32 - n, V = (e, t, n) => e << 32 - n | t >>> n, Z = (e, t, n) => e << 64 - n | t >>> n - 32, J = (e, t, n) => e >>> n - 32 | t << 64 - n, nn = (e, t, n) => e << n | t >>> 32 - n, sn = (e, t, n) => t << n | e >>> 32 - n, rn = (e, t, n) => t << n - 32 | e >>> 64 - n, on = (e, t, n) => e << n - 32 | t >>> 64 - n;
1521
- function U(e, t, n, s) {
1571
+ const Lt = (e, t, n) => e >>> n, Ft = (e, t, n) => e << 32 - n | t >>> n, V = (e, t, n) => e >>> n | t << 32 - n, W = (e, t, n) => e << 32 - n | t >>> n, Z = (e, t, n) => e << 64 - n | t >>> n - 32, J = (e, t, n) => e >>> n - 32 | t << 64 - n, nn = (e, t, n) => e << n | t >>> 32 - n, sn = (e, t, n) => t << n | e >>> 32 - n, rn = (e, t, n) => t << n - 32 | e >>> 64 - n, on = (e, t, n) => e << n - 32 | t >>> 64 - n;
1572
+ function $(e, t, n, s) {
1522
1573
  const r = (t >>> 0) + (s >>> 0);
1523
1574
  return { h: e + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
1524
1575
  }
@@ -1587,7 +1638,7 @@ const an = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), cn = (e, t, n, s) =>
1587
1638
  2756734187,
1588
1639
  3204031479,
1589
1640
  3329325298
1590
- ]), L = /* @__PURE__ */ new Uint32Array(64);
1641
+ ]), F = /* @__PURE__ */ new Uint32Array(64);
1591
1642
  class pn extends mt {
1592
1643
  constructor(t) {
1593
1644
  super(64, t, 8, !1);
@@ -1601,21 +1652,21 @@ class pn extends mt {
1601
1652
  this.A = t | 0, this.B = n | 0, this.C = s | 0, this.D = r | 0, this.E = o | 0, this.F = i | 0, this.G = a | 0, this.H = c | 0;
1602
1653
  }
1603
1654
  process(t, n) {
1604
- for (let u = 0; u < 16; u++, n += 4)
1605
- L[u] = t.getUint32(n, !1);
1606
- for (let u = 16; u < 64; u++) {
1607
- const d = L[u - 15], p = L[u - 2], b = B(d, 7) ^ B(d, 18) ^ d >>> 3, m = B(p, 17) ^ B(p, 19) ^ p >>> 10;
1608
- L[u] = m + L[u - 7] + b + L[u - 16] | 0;
1655
+ for (let l = 0; l < 16; l++, n += 4)
1656
+ F[l] = t.getUint32(n, !1);
1657
+ for (let l = 16; l < 64; l++) {
1658
+ const d = F[l - 15], g = F[l - 2], p = B(d, 7) ^ B(d, 18) ^ d >>> 3, m = B(g, 17) ^ B(g, 19) ^ g >>> 10;
1659
+ F[l] = m + F[l - 7] + p + F[l - 16] | 0;
1609
1660
  }
1610
- let { A: s, B: r, C: o, D: i, E: a, F: c, G: l, H: h } = this;
1611
- for (let u = 0; u < 64; u++) {
1612
- const d = B(a, 6) ^ B(a, 11) ^ B(a, 25), p = h + d + Xe(a, c, l) + dn[u] + L[u] | 0, m = (B(s, 2) ^ B(s, 13) ^ B(s, 22)) + Ge(s, r, o) | 0;
1613
- h = l, l = c, c = a, a = i + p | 0, i = o, o = r, r = s, s = p + m | 0;
1661
+ let { A: s, B: r, C: o, D: i, E: a, F: c, G: u, H: h } = this;
1662
+ for (let l = 0; l < 64; l++) {
1663
+ const d = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + d + Xe(a, c, u) + dn[l] + F[l] | 0, m = (B(s, 2) ^ B(s, 13) ^ B(s, 22)) + je(s, r, o) | 0;
1664
+ h = u, u = c, c = a, a = i + g | 0, i = o, o = r, r = s, s = g + m | 0;
1614
1665
  }
1615
- s = s + this.A | 0, r = r + this.B | 0, o = o + 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, r, o, i, a, c, l, h);
1666
+ s = s + this.A | 0, r = r + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, u = u + this.G | 0, h = h + this.H | 0, this.set(s, r, o, i, a, c, u, h);
1616
1667
  }
1617
1668
  roundClean() {
1618
- A(L);
1669
+ A(F);
1619
1670
  }
1620
1671
  destroy() {
1621
1672
  this.set(0, 0, 0, 0, 0, 0, 0, 0), A(this.buffer);
@@ -1626,17 +1677,17 @@ class bn extends pn {
1626
1677
  super(32);
1627
1678
  // We cannot use array here since array allows indexing by variable
1628
1679
  // which means optimizer/compiler cannot use registers.
1629
- f(this, "A", $[0] | 0);
1630
- f(this, "B", $[1] | 0);
1631
- f(this, "C", $[2] | 0);
1632
- f(this, "D", $[3] | 0);
1633
- f(this, "E", $[4] | 0);
1634
- f(this, "F", $[5] | 0);
1635
- f(this, "G", $[6] | 0);
1636
- f(this, "H", $[7] | 0);
1680
+ f(this, "A", L[0] | 0);
1681
+ f(this, "B", L[1] | 0);
1682
+ f(this, "C", L[2] | 0);
1683
+ f(this, "D", L[3] | 0);
1684
+ f(this, "E", L[4] | 0);
1685
+ f(this, "F", L[5] | 0);
1686
+ f(this, "G", L[6] | 0);
1687
+ f(this, "H", L[7] | 0);
1637
1688
  }
1638
1689
  }
1639
- const ee = te([
1690
+ const te = Qt([
1640
1691
  "0x428a2f98d728ae22",
1641
1692
  "0x7137449123ef65cd",
1642
1693
  "0xb5c0fbcfec4d3b2f",
@@ -1717,38 +1768,38 @@ const ee = te([
1717
1768
  "0x597f299cfc657e2a",
1718
1769
  "0x5fcb6fab3ad6faec",
1719
1770
  "0x6c44198c4a475817"
1720
- ].map((e) => BigInt(e))), xn = ee[0], gn = ee[1], F = /* @__PURE__ */ new Uint32Array(80), O = /* @__PURE__ */ new Uint32Array(80);
1771
+ ].map((e) => BigInt(e))), gn = te[0], xn = te[1], C = /* @__PURE__ */ new Uint32Array(80), O = /* @__PURE__ */ new Uint32Array(80);
1721
1772
  class yn extends mt {
1722
1773
  constructor(t) {
1723
1774
  super(128, t, 16, !1);
1724
1775
  }
1725
1776
  // prettier-ignore
1726
1777
  get() {
1727
- const { Ah: t, Al: n, Bh: s, Bl: r, Ch: o, Cl: i, Dh: a, Dl: c, Eh: l, El: h, Fh: u, Fl: d, Gh: p, Gl: b, Hh: m, Hl: x } = this;
1728
- return [t, n, s, r, o, i, a, c, l, h, u, d, p, b, m, x];
1778
+ const { Ah: t, Al: n, Bh: s, Bl: r, Ch: o, Cl: i, Dh: a, Dl: c, Eh: u, El: h, Fh: l, Fl: d, Gh: g, Gl: p, Hh: m, Hl: x } = this;
1779
+ return [t, n, s, r, o, i, a, c, u, h, l, d, g, p, m, x];
1729
1780
  }
1730
1781
  // prettier-ignore
1731
- set(t, n, s, r, o, i, a, c, l, h, u, d, p, b, m, x) {
1732
- this.Ah = t | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = o | 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 = p | 0, this.Gl = b | 0, this.Hh = m | 0, this.Hl = x | 0;
1782
+ set(t, n, s, r, o, i, a, c, u, h, l, d, g, p, m, x) {
1783
+ this.Ah = t | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = o | 0, this.Cl = i | 0, this.Dh = a | 0, this.Dl = c | 0, this.Eh = u | 0, this.El = h | 0, this.Fh = l | 0, this.Fl = d | 0, this.Gh = g | 0, this.Gl = p | 0, this.Hh = m | 0, this.Hl = x | 0;
1733
1784
  }
1734
1785
  process(t, n) {
1735
- for (let g = 0; g < 16; g++, n += 4)
1736
- F[g] = t.getUint32(n), O[g] = t.getUint32(n += 4);
1737
- for (let g = 16; g < 80; g++) {
1738
- const P = F[g - 15] | 0, v = O[g - 15] | 0, T = R(P, v, 1) ^ R(P, v, 8) ^ Ft(P, v, 7), E = V(P, v, 1) ^ V(P, v, 8) ^ Ot(P, v, 7), I = F[g - 2] | 0, k = O[g - 2] | 0, X = R(I, k, 19) ^ Z(I, k, 61) ^ Ft(I, k, 6), ot = V(I, k, 19) ^ J(I, k, 61) ^ Ot(I, k, 6), G = un(E, ot, O[g - 7], O[g - 16]), it = ln(G, T, X, F[g - 7], F[g - 16]);
1739
- F[g] = it | 0, O[g] = G | 0;
1786
+ for (let b = 0; b < 16; b++, n += 4)
1787
+ C[b] = t.getUint32(n), O[b] = t.getUint32(n += 4);
1788
+ for (let b = 16; b < 80; b++) {
1789
+ const P = C[b - 15] | 0, T = O[b - 15] | 0, v = V(P, T, 1) ^ V(P, T, 8) ^ Lt(P, T, 7), E = W(P, T, 1) ^ W(P, T, 8) ^ Ft(P, T, 7), k = C[b - 2] | 0, I = O[b - 2] | 0, U = V(k, I, 19) ^ Z(k, I, 61) ^ Lt(k, I, 6), ot = W(k, I, 19) ^ J(k, I, 61) ^ Ft(k, I, 6), j = un(E, ot, O[b - 7], O[b - 16]), it = ln(j, v, U, C[b - 7], C[b - 16]);
1790
+ C[b] = it | 0, O[b] = j | 0;
1740
1791
  }
1741
- let { Ah: s, Al: r, Bh: o, Bl: i, Ch: a, Cl: c, Dh: l, Dl: h, Eh: u, El: d, Fh: p, Fl: b, Gh: m, Gl: x, Hh: y, Hl: w } = this;
1742
- for (let g = 0; g < 80; g++) {
1743
- const P = R(u, d, 14) ^ R(u, d, 18) ^ Z(u, d, 41), v = V(u, d, 14) ^ V(u, d, 18) ^ J(u, d, 41), T = u & p ^ ~u & m, E = d & b ^ ~d & x, I = hn(w, v, E, gn[g], O[g]), k = fn(I, y, P, T, xn[g], F[g]), X = I | 0, ot = R(s, r, 28) ^ Z(s, r, 34) ^ Z(s, r, 39), G = V(s, r, 28) ^ J(s, r, 34) ^ J(s, r, 39), it = s & o ^ s & a ^ o & a, ce = r & i ^ r & c ^ i & c;
1744
- y = m | 0, w = x | 0, m = p | 0, x = b | 0, p = u | 0, b = d | 0, { h: u, l: d } = U(l | 0, h | 0, k | 0, X | 0), l = a | 0, h = c | 0, a = o | 0, c = i | 0, o = s | 0, i = r | 0;
1745
- const Pt = an(X, G, ce);
1746
- s = cn(Pt, k, ot, it), r = Pt | 0;
1792
+ let { Ah: s, Al: r, Bh: o, Bl: i, Ch: a, Cl: c, Dh: u, Dl: h, Eh: l, El: d, Fh: g, Fl: p, Gh: m, Gl: x, Hh: y, Hl: w } = this;
1793
+ for (let b = 0; b < 80; b++) {
1794
+ const P = V(l, d, 14) ^ V(l, d, 18) ^ Z(l, d, 41), T = W(l, d, 14) ^ W(l, d, 18) ^ J(l, d, 41), v = l & g ^ ~l & m, E = d & p ^ ~d & x, k = hn(w, T, E, xn[b], O[b]), I = fn(k, y, P, v, gn[b], C[b]), U = k | 0, ot = V(s, r, 28) ^ Z(s, r, 34) ^ Z(s, r, 39), j = W(s, r, 28) ^ J(s, r, 34) ^ J(s, r, 39), it = s & o ^ s & a ^ o & a, ae = r & i ^ r & c ^ i & c;
1795
+ y = m | 0, w = x | 0, m = g | 0, x = p | 0, g = l | 0, p = d | 0, { h: l, l: d } = $(u | 0, h | 0, I | 0, U | 0), u = a | 0, h = c | 0, a = o | 0, c = i | 0, o = s | 0, i = r | 0;
1796
+ const Pt = an(U, j, ae);
1797
+ s = cn(Pt, I, ot, it), r = Pt | 0;
1747
1798
  }
1748
- ({ h: s, l: r } = U(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: o, l: i } = U(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: a, l: c } = U(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: l, l: h } = U(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: u, l: d } = U(this.Eh | 0, this.El | 0, u | 0, d | 0), { h: p, l: b } = U(this.Fh | 0, this.Fl | 0, p | 0, b | 0), { h: m, l: x } = U(this.Gh | 0, this.Gl | 0, m | 0, x | 0), { h: y, l: w } = U(this.Hh | 0, this.Hl | 0, y | 0, w | 0), this.set(s, r, o, i, a, c, l, h, u, d, p, b, m, x, y, w);
1799
+ ({ h: s, l: r } = $(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: o, l: i } = $(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: a, l: c } = $(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: u, l: h } = $(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: l, l: d } = $(this.Eh | 0, this.El | 0, l | 0, d | 0), { h: g, l: p } = $(this.Fh | 0, this.Fl | 0, g | 0, p | 0), { h: m, l: x } = $(this.Gh | 0, this.Gl | 0, m | 0, x | 0), { h: y, l: w } = $(this.Hh | 0, this.Hl | 0, y | 0, w | 0), this.set(s, r, o, i, a, c, u, h, l, d, g, p, m, x, y, w);
1749
1800
  }
1750
1801
  roundClean() {
1751
- A(F, O);
1802
+ A(C, O);
1752
1803
  }
1753
1804
  destroy() {
1754
1805
  A(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -1778,32 +1829,32 @@ class mn extends yn {
1778
1829
  const wn = /* @__PURE__ */ rt(
1779
1830
  () => new bn(),
1780
1831
  /* @__PURE__ */ jt(1)
1781
- ), ne = /* @__PURE__ */ rt(
1832
+ ), ee = /* @__PURE__ */ rt(
1782
1833
  () => new mn(),
1783
1834
  /* @__PURE__ */ jt(3)
1784
- ), Pn = BigInt(0), M = BigInt(1), Tn = BigInt(2), vn = BigInt(7), kn = BigInt(256), Hn = BigInt(113), se = [], re = [], oe = [];
1785
- for (let e = 0, t = M, n = 1, s = 0; e < 24; e++) {
1786
- [n, s] = [s, (2 * n + 3 * s) % 5], se.push(2 * (5 * s + n)), re.push((e + 1) * (e + 2) / 2 % 64);
1835
+ ), Pn = BigInt(0), N = BigInt(1), Tn = BigInt(2), vn = BigInt(7), kn = BigInt(256), Hn = BigInt(113), ne = [], se = [], re = [];
1836
+ for (let e = 0, t = N, n = 1, s = 0; e < 24; e++) {
1837
+ [n, s] = [s, (2 * n + 3 * s) % 5], ne.push(2 * (5 * s + n)), se.push((e + 1) * (e + 2) / 2 % 64);
1787
1838
  let r = Pn;
1788
1839
  for (let o = 0; o < 7; o++)
1789
- t = (t << M ^ (t >> vn) * Hn) % kn, t & Tn && (r ^= M << (M << BigInt(o)) - M);
1790
- oe.push(r);
1840
+ t = (t << N ^ (t >> vn) * Hn) % kn, t & Tn && (r ^= N << (N << BigInt(o)) - N);
1841
+ re.push(r);
1791
1842
  }
1792
- const ie = te(oe, !0), In = ie[0], En = ie[1], Ct = (e, t, n) => n > 32 ? rn(e, t, n) : nn(e, t, n), _t = (e, t, n) => n > 32 ? on(e, t, n) : sn(e, t, n);
1843
+ const oe = Qt(re, !0), In = oe[0], En = oe[1], Ct = (e, t, n) => n > 32 ? rn(e, t, n) : nn(e, t, n), Ot = (e, t, n) => n > 32 ? on(e, t, n) : sn(e, t, n);
1793
1844
  function Sn(e, t = 24) {
1794
1845
  const n = new Uint32Array(10);
1795
1846
  for (let s = 24 - t; s < 24; s++) {
1796
1847
  for (let i = 0; i < 10; i++)
1797
1848
  n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
1798
1849
  for (let i = 0; i < 10; i += 2) {
1799
- const a = (i + 8) % 10, c = (i + 2) % 10, l = n[c], h = n[c + 1], u = Ct(l, h, 1) ^ n[a], d = _t(l, h, 1) ^ n[a + 1];
1800
- for (let p = 0; p < 50; p += 10)
1801
- e[i + p] ^= u, e[i + p + 1] ^= d;
1850
+ const a = (i + 8) % 10, c = (i + 2) % 10, u = n[c], h = n[c + 1], l = Ct(u, h, 1) ^ n[a], d = Ot(u, h, 1) ^ n[a + 1];
1851
+ for (let g = 0; g < 50; g += 10)
1852
+ e[i + g] ^= l, e[i + g + 1] ^= d;
1802
1853
  }
1803
1854
  let r = e[2], o = e[3];
1804
1855
  for (let i = 0; i < 24; i++) {
1805
- const a = re[i], c = Ct(r, o, a), l = _t(r, o, a), h = se[i];
1806
- r = e[h], o = e[h + 1], e[h] = c, e[h + 1] = l;
1856
+ const a = se[i], c = Ct(r, o, a), u = Ot(r, o, a), h = ne[i];
1857
+ r = e[h], o = e[h + 1], e[h] = c, e[h + 1] = u;
1807
1858
  }
1808
1859
  for (let i = 0; i < 50; i += 10) {
1809
1860
  for (let a = 0; a < 10; a++)
@@ -1829,7 +1880,7 @@ class wt {
1829
1880
  f(this, "outputLen");
1830
1881
  f(this, "enableXOF", !1);
1831
1882
  f(this, "rounds");
1832
- if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = r, this.rounds = o, C(s, "outputLen"), !(0 < t && t < 200))
1883
+ if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = r, this.rounds = o, _(s, "outputLen"), !(0 < t && t < 200))
1833
1884
  throw new Error("only keccak-f1600 function is supported");
1834
1885
  this.state = new Uint8Array(200), this.state32 = Ve(this.state);
1835
1886
  }
@@ -1837,10 +1888,10 @@ class wt {
1837
1888
  return this._cloneInto();
1838
1889
  }
1839
1890
  keccak() {
1840
- Bt(this.state32), Sn(this.state32, this.rounds), Bt(this.state32), this.posOut = 0, this.pos = 0;
1891
+ At(this.state32), Sn(this.state32, this.rounds), At(this.state32), this.posOut = 0, this.pos = 0;
1841
1892
  }
1842
1893
  update(t) {
1843
- K(this), _(t);
1894
+ M(this), R(t);
1844
1895
  const { blockLen: n, state: s } = this, r = t.length;
1845
1896
  for (let o = 0; o < r; ) {
1846
1897
  const i = Math.min(n - this.pos, r - o);
@@ -1858,7 +1909,7 @@ class wt {
1858
1909
  t[s] ^= n, (n & 128) !== 0 && s === r - 1 && this.keccak(), t[r - 1] ^= 128, this.keccak();
1859
1910
  }
1860
1911
  writeInto(t) {
1861
- K(this, !1), _(t), this.finish();
1912
+ M(this, !1), R(t), this.finish();
1862
1913
  const n = this.state, { blockLen: s } = this;
1863
1914
  for (let r = 0, o = t.length; r < o; ) {
1864
1915
  this.posOut >= s && this.keccak();
@@ -1873,10 +1924,10 @@ class wt {
1873
1924
  return this.writeInto(t);
1874
1925
  }
1875
1926
  xof(t) {
1876
- return C(t), this.xofInto(new Uint8Array(t));
1927
+ return _(t), this.xofInto(new Uint8Array(t));
1877
1928
  }
1878
1929
  digestInto(t) {
1879
- if (Gt(t, this), this.finished)
1930
+ if (Xt(t, this), this.finished)
1880
1931
  throw new Error("digest() was already called");
1881
1932
  return this.writeInto(t), this.destroy(), t;
1882
1933
  }
@@ -1892,49 +1943,49 @@ class wt {
1892
1943
  }
1893
1944
  }
1894
1945
  const An = (e, t, n, s = {}) => rt(() => new wt(t, e, n), s), Bn = /* @__PURE__ */ An(1, 136, 32);
1895
- function Un(e, t, n, s) {
1896
- Xt(e);
1946
+ function $n(e, t, n, s) {
1947
+ Nt(e);
1897
1948
  const r = Ne({ dkLen: 32, asyncTick: 10 }, s), { c: o, dkLen: i, asyncTick: a } = r;
1898
- if (C(o, "c"), C(i, "dkLen"), C(a, "asyncTick"), o < 1)
1949
+ if (_(o, "c"), _(i, "dkLen"), _(a, "asyncTick"), o < 1)
1899
1950
  throw new Error("iterations (c) must be >= 1");
1900
- const c = Ut(t, "password"), l = Ut(n, "salt"), h = new Uint8Array(i), u = yt.create(e, c), d = u._cloneInto().update(l);
1901
- return { c: o, dkLen: i, asyncTick: a, DK: h, PRF: u, PRFSalt: d };
1951
+ const c = Bt(t, "password"), u = Bt(n, "salt"), h = new Uint8Array(i), l = yt.create(e, c), d = l._cloneInto().update(u);
1952
+ return { c: o, dkLen: i, asyncTick: a, DK: h, PRF: l, PRFSalt: d };
1902
1953
  }
1903
- function $n(e, t, n, s, r) {
1954
+ function Un(e, t, n, s, r) {
1904
1955
  return e.destroy(), t.destroy(), s && s.destroy(), A(r), n;
1905
1956
  }
1906
1957
  function Ln(e, t, n, s) {
1907
- const { c: r, dkLen: o, DK: i, PRF: a, PRFSalt: c } = Un(e, t, n, s);
1908
- let l;
1909
- const h = new Uint8Array(4), u = et(h), d = new Uint8Array(a.outputLen);
1910
- for (let p = 1, b = 0; b < o; p++, b += a.outputLen) {
1911
- const m = i.subarray(b, b + a.outputLen);
1912
- u.setInt32(0, p, !1), (l = c._cloneInto(l)).update(h).digestInto(d), m.set(d.subarray(0, m.length));
1958
+ const { c: r, dkLen: o, DK: i, PRF: a, PRFSalt: c } = $n(e, t, n, s);
1959
+ let u;
1960
+ const h = new Uint8Array(4), l = et(h), d = new Uint8Array(a.outputLen);
1961
+ for (let g = 1, p = 0; p < o; g++, p += a.outputLen) {
1962
+ const m = i.subarray(p, p + a.outputLen);
1963
+ l.setInt32(0, g, !1), (u = c._cloneInto(u)).update(h).digestInto(d), m.set(d.subarray(0, m.length));
1913
1964
  for (let x = 1; x < r; x++) {
1914
- a._cloneInto(l).update(d).digestInto(d);
1965
+ a._cloneInto(u).update(d).digestInto(d);
1915
1966
  for (let y = 0; y < m.length; y++)
1916
1967
  m[y] ^= d[y];
1917
1968
  }
1918
1969
  }
1919
- return $n(a, c, i, l, d);
1970
+ return Un(a, c, i, u, d);
1920
1971
  }
1921
- function ae(e) {
1972
+ function ie(e) {
1922
1973
  if (typeof e != "string")
1923
1974
  throw new TypeError("invalid mnemonic type: " + typeof e);
1924
1975
  return e.normalize("NFKD");
1925
1976
  }
1926
1977
  function Fn(e) {
1927
- const t = ae(e), n = t.split(" ");
1978
+ const t = ie(e), n = t.split(" ");
1928
1979
  if (![12, 15, 18, 21, 24].includes(n.length))
1929
1980
  throw new Error("Invalid mnemonic");
1930
1981
  return { nfkd: t, words: n };
1931
1982
  }
1932
- const On = (e) => ae("mnemonic" + e);
1933
- function Cn(e, t = "") {
1934
- return Ln(ne, Fn(e).nfkd, On(t), { c: 2048, dkLen: 64 });
1983
+ const Cn = (e) => ie("mnemonic" + e);
1984
+ function On(e, t = "") {
1985
+ return Ln(ee, Fn(e).nfkd, Cn(t), { c: 2048, dkLen: 64 });
1935
1986
  }
1936
- const _n = 508, Rt = 16, Y = 32, Q = 64, Vt = 5, Rn = 4;
1937
- function N(...e) {
1987
+ const _n = 508, _t = 16, Y = 32, Q = 64, Rt = 5, Rn = 4;
1988
+ function X(...e) {
1938
1989
  const t = e.reduce((r, o) => r + o.length, 0), n = new Uint8Array(t);
1939
1990
  let s = 0;
1940
1991
  for (const r of e)
@@ -1946,17 +1997,17 @@ function lt(e) {
1946
1997
  }
1947
1998
  function ht(e) {
1948
1999
  const t = new Uint8Array(Rn);
1949
- return new DataView(t.buffer).setUint32(0, e.length, !1), N(t, e);
2000
+ return new DataView(t.buffer).setUint32(0, e.length, !1), X(t, e);
1950
2001
  }
1951
2002
  function ft(e, t) {
1952
- return yt(ne, e, t);
2003
+ return yt(ee, e, t);
1953
2004
  }
1954
- function Wt(e) {
2005
+ function Vt(e) {
1955
2006
  return tn(wn(e));
1956
2007
  }
1957
- const xt = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
2008
+ const gt = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
1958
2009
  function Vn(e) {
1959
- const t = Cn(e);
2010
+ const t = On(e);
1960
2011
  return new Uint8Array(t);
1961
2012
  }
1962
2013
  async function Wn(e, t, n, s) {
@@ -1964,40 +2015,40 @@ async function Wn(e, t, n, s) {
1964
2015
  throw new Error(
1965
2016
  `Lamport seed must be ${Q} bytes, got ${e.length}`
1966
2017
  );
1967
- t = W(t), n = W(n);
2018
+ t = D(t), n = D(n);
1968
2019
  const r = e.slice(Y, Q), o = e.slice(0, Y), i = [r, o];
1969
2020
  try {
1970
- const a = N(
2021
+ const a = X(
1971
2022
  ht(lt(t)),
1972
2023
  ht(lt(n)),
1973
2024
  ht(lt(s))
1974
- ), c = N(o, a);
2025
+ ), c = X(o, a);
1975
2026
  i.push(c);
1976
- const l = ft(r, c);
1977
- i.push(l);
1978
- const h = l.slice(0, Y), u = l.slice(Y, Q);
1979
- i.push(h, u);
1980
- const d = [], p = [], b = [], m = [];
2027
+ const u = ft(r, c);
2028
+ i.push(u);
2029
+ const h = u.slice(0, Y), l = u.slice(Y, Q);
2030
+ i.push(h, l);
2031
+ const d = [], g = [], p = [], m = [];
1981
2032
  let x = !1;
1982
2033
  try {
1983
2034
  for (let y = 0; y < _n; y++) {
1984
- const w = new Uint8Array(Vt);
2035
+ const w = new Uint8Array(Rt);
1985
2036
  w[0] = 0, new DataView(w.buffer).setUint32(1, y, !1);
1986
- const g = new Uint8Array(Vt);
1987
- g[0] = 1, new DataView(g.buffer).setUint32(1, y, !1);
1988
- const P = N(h, w), v = N(h, g), T = ft(u, P), E = ft(u, v);
2037
+ const b = new Uint8Array(Rt);
2038
+ b[0] = 1, new DataView(b.buffer).setUint32(1, y, !1);
2039
+ const P = X(h, w), T = X(h, b), v = ft(l, P), E = ft(l, T);
1989
2040
  try {
1990
- const I = T.slice(0, Rt), k = E.slice(0, Rt);
1991
- d.push(I), p.push(k), b.push(Wt(I)), m.push(Wt(k));
2041
+ const k = v.slice(0, _t), I = E.slice(0, _t);
2042
+ d.push(k), g.push(I), p.push(Vt(k)), m.push(Vt(I));
1992
2043
  } finally {
1993
- P.fill(0), v.fill(0), T.fill(0), E.fill(0);
2044
+ P.fill(0), T.fill(0), v.fill(0), E.fill(0);
1994
2045
  }
1995
2046
  }
1996
- return x = !0, { falsePreimages: d, truePreimages: p, falseHashes: b, trueHashes: m };
2047
+ return x = !0, { falsePreimages: d, truePreimages: g, falseHashes: p, trueHashes: m };
1997
2048
  } finally {
1998
2049
  if (!x) {
1999
2050
  for (const y of d) y.fill(0);
2000
- for (const y of p) y.fill(0);
2051
+ for (const y of g) y.fill(0);
2001
2052
  }
2002
2053
  }
2003
2054
  } finally {
@@ -2007,8 +2058,8 @@ async function Wn(e, t, n, s) {
2007
2058
  }
2008
2059
  function as(e) {
2009
2060
  return {
2010
- false_list: e.falseHashes.map(xt),
2011
- true_list: e.trueHashes.map(xt)
2061
+ false_list: e.falseHashes.map(gt),
2062
+ true_list: e.trueHashes.map(gt)
2012
2063
  };
2013
2064
  }
2014
2065
  function Dn(e) {
@@ -2023,7 +2074,7 @@ function Dn(e) {
2023
2074
  for (const i of e.trueHashes)
2024
2075
  s.set(i, r), r += t;
2025
2076
  const o = Bn(s);
2026
- return `0x${xt(o)}`;
2077
+ return `0x${gt(o)}`;
2027
2078
  }
2028
2079
  async function cs(e, t, n, s) {
2029
2080
  const r = Vn(e);
@@ -2051,14 +2102,14 @@ function us(e) {
2051
2102
  export {
2052
2103
  Dn as A,
2053
2104
  tt as B,
2054
- D as C,
2105
+ K as C,
2055
2106
  cs as D,
2056
2107
  us as E,
2057
- $e as M,
2108
+ Ue as M,
2058
2109
  os as P,
2059
2110
  zn as a,
2060
2111
  Zn as b,
2061
- At as c,
2112
+ St as c,
2062
2113
  Jn as d,
2063
2114
  Se as e,
2064
2115
  Ae as f,
@@ -2071,11 +2122,11 @@ export {
2071
2122
  ns as m,
2072
2123
  Yn as n,
2073
2124
  Fe as o,
2074
- Oe as p,
2125
+ Ce as p,
2075
2126
  Le as q,
2076
2127
  ct as r,
2077
2128
  Ee as s,
2078
- gt as t,
2129
+ xt as t,
2079
2130
  ss as u,
2080
2131
  rs as v,
2081
2132
  ut as w,
@@ -2083,4 +2134,4 @@ export {
2083
2134
  Wn as y,
2084
2135
  as as z
2085
2136
  };
2086
- //# sourceMappingURL=errors-fLxe1eml.js.map
2137
+ //# sourceMappingURL=errors-DOJdtNTD.js.map