@babylonlabs-io/ts-sdk 0.13.1 → 0.13.2

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.
@@ -1,13 +1,13 @@
1
1
  var ce = Object.defineProperty;
2
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);
3
+ var d = (e, t, n) => ue(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import * as le from "bitcoinjs-lib";
5
- import { script as he, Transaction as G, address as fe, Psbt as dt } from "bitcoinjs-lib";
5
+ import { script as he, Transaction as q, address as fe, Psbt as dt } from "bitcoinjs-lib";
6
6
  import { Buffer as S } from "buffer";
7
- import { P as de, y as pe, D as Vt, M as Tt, B as be, T as ge, G as pt, u as _, b as ye, A as xe, E as we, a as me, d as Pe, e as Te, f as ve, s as at, q as ke, x as vt, h as kt, i as Ht, r as He } from "./challengeAssert-CenzzhZU.js";
8
- import { createPublicClient as Et, http as It, encodeFunctionData as Ee, zeroAddress as Ie } from "viem";
9
- import "@babylonlabs-io/babylon-tbv-rust-wasm";
10
- function Se(e, t, n, s) {
7
+ import { P as de, y as pe, D as Vt, M as Tt, B as be, T as ge, G as pt, u as $, b as xe, A as ye, E as we, a as me, d as Pe, e as Te, f as ve, s as z, q as ke, x as vt, h as kt, i as Ht, r as He } from "./challengeAssert-CenzzhZU.js";
8
+ import { createPublicClient as It, http as Et, encodeFunctionData as Ie, zeroAddress as Ee } from "viem";
9
+ import { deriveVaultId as Se } from "@babylonlabs-io/babylon-tbv-rust-wasm";
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}`
@@ -26,20 +26,20 @@ function Se(e, t, n, s) {
26
26
  let a = 0n, c = 0n;
27
27
  for (const u of o) {
28
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 > Vt) {
31
- const p = BigInt(
29
+ const h = i.length * de, l = s * Tt, f = h + l + ge;
30
+ if (c = BigInt(Math.ceil(f * n)) + BigInt(pe(n)), a - t - c > Vt) {
31
+ const b = BigInt(
32
32
  Math.ceil(Tt * n)
33
33
  );
34
- c += p;
34
+ c += b;
35
35
  }
36
36
  if (a >= t + c) {
37
- const p = a - t - c;
37
+ const b = a - t - c;
38
38
  return {
39
39
  selectedUTXOs: i,
40
40
  totalValue: a,
41
41
  fee: c,
42
- changeAmount: p
42
+ changeAmount: b
43
43
  };
44
44
  }
45
45
  }
@@ -47,17 +47,17 @@ function Se(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 zn(e) {
50
+ function Zn(e) {
51
51
  return e > Vt;
52
52
  }
53
- function Zn() {
53
+ function Jn() {
54
54
  return be;
55
55
  }
56
56
  function St(e) {
57
57
  const t = e.startsWith("0x") ? e.slice(2) : e;
58
- return `0x${G.fromHex(t).getId()}`;
58
+ return `0x${q.fromHex(t).getId()}`;
59
59
  }
60
- function Jn(e, t, n) {
60
+ function Yn(e, t, n) {
61
61
  if (e.length === 0)
62
62
  throw new Error("No input UTXOs provided for split transaction");
63
63
  if (t.length === 0)
@@ -67,7 +67,7 @@ function Jn(e, t, n) {
67
67
  throw new Error(
68
68
  `Invalid output amount for ${c.address}: ${c.amount} satoshis. Amount must be greater than zero.`
69
69
  );
70
- const s = pt(n), r = new G();
70
+ const s = pt(n), r = new q();
71
71
  r.version = 2;
72
72
  for (const c of e) {
73
73
  const u = S.from(c.txid, "hex").reverse();
@@ -101,8 +101,8 @@ function Jn(e, t, n) {
101
101
  outputs: o
102
102
  };
103
103
  }
104
- function Yn(e, t, n) {
105
- const s = G.fromHex(e), r = new dt();
104
+ function Qn(e, t, n) {
105
+ const s = q.fromHex(e), r = new dt();
106
106
  if (r.setVersion(s.version), r.setLocktime(s.locktime), !S.isBuffer(n) || n.length !== 32)
107
107
  throw new Error(
108
108
  `Invalid publicKeyNoCoord: expected 32-byte Buffer (x-only pubkey), got ${S.isBuffer(n) ? `${n.length}-byte Buffer` : typeof n}`
@@ -126,7 +126,7 @@ function Yn(e, t, n) {
126
126
  throw new Error(
127
127
  `Input ${o} must be P2TR (Taproot). createSplitTransactionPsbt() requires P2TR inputs because it uses tapInternalKey for Taproot signing. ScriptPubKey: ${a.scriptPubKey.substring(0, 20)}...`
128
128
  );
129
- const d = {
129
+ const f = {
130
130
  script: S.from(a.scriptPubKey, "hex"),
131
131
  value: a.value
132
132
  };
@@ -134,7 +134,7 @@ function Yn(e, t, n) {
134
134
  hash: i.hash,
135
135
  index: i.index,
136
136
  sequence: i.sequence,
137
- witnessUtxo: d,
137
+ witnessUtxo: f,
138
138
  tapInternalKey: n
139
139
  });
140
140
  }
@@ -145,8 +145,8 @@ function Yn(e, t, n) {
145
145
  });
146
146
  return r.toHex();
147
147
  }
148
- var et = /* @__PURE__ */ ((e) => (e.P2PKH = "P2PKH", e.P2SH = "P2SH", e.P2WPKH = "P2WPKH", e.P2WSH = "P2WSH", e.P2TR = "P2TR", e.UNKNOWN = "UNKNOWN", e))(et || {});
149
- function Ae(e) {
148
+ var st = /* @__PURE__ */ ((e) => (e.P2PKH = "P2PKH", e.P2SH = "P2SH", e.P2WPKH = "P2WPKH", e.P2WSH = "P2WSH", e.P2TR = "P2TR", e.UNKNOWN = "UNKNOWN", e))(st || {});
149
+ function Be(e) {
150
150
  const t = e.length;
151
151
  return t === 25 && e[0] === 118 && // OP_DUP
152
152
  e[1] === 169 && // OP_HASH160
@@ -159,17 +159,17 @@ function Ae(e) {
159
159
  e[1] === 32 ? "P2WSH" : t === 34 && e[0] === 81 && // OP_1
160
160
  e[1] === 32 ? "P2TR" : "UNKNOWN";
161
161
  }
162
- function Be(e, t) {
163
- const n = S.from(e.scriptPubKey, "hex"), s = Ae(n);
162
+ function $e(e, t) {
163
+ const n = S.from(e.scriptPubKey, "hex"), s = Be(n);
164
164
  switch (s) {
165
- case et.P2WPKH:
165
+ case st.P2WPKH:
166
166
  return {
167
167
  witnessUtxo: {
168
168
  script: n,
169
169
  value: e.value
170
170
  }
171
171
  };
172
- case et.P2WSH: {
172
+ case st.P2WSH: {
173
173
  if (!e.witnessScript)
174
174
  throw new Error("Missing witnessScript for P2WSH input");
175
175
  return {
@@ -180,7 +180,7 @@ function Be(e, t) {
180
180
  witnessScript: S.from(e.witnessScript, "hex")
181
181
  };
182
182
  }
183
- case et.P2TR: {
183
+ case st.P2TR: {
184
184
  if (t && t.length !== 32)
185
185
  throw new Error(
186
186
  `Invalid tapInternalKey length: expected 32 bytes, got ${t.length}`
@@ -210,22 +210,22 @@ function bt(e, t) {
210
210
  }))
211
211
  };
212
212
  }
213
- const $e = 21e6 * 1e8, Kt = 1e4;
213
+ const Ue = 21e6 * 1e8, Kt = 1e4;
214
214
  function Dt(e) {
215
- return Number.isInteger(e) && e > 0 && e <= $e;
215
+ return Number.isInteger(e) && e > 0 && e <= Ue;
216
216
  }
217
- function Ue(e) {
217
+ function Fe(e) {
218
218
  return Number.isInteger(e) && e > 0 && e <= Kt;
219
219
  }
220
220
  function Mt(e, t) {
221
221
  return !Number.isInteger(e) || e < 0 ? !1 : t === void 0 || e < t;
222
222
  }
223
- const Fe = {
223
+ const Oe = {
224
224
  mainnet: "https://mempool.space/api",
225
225
  testnet: "https://mempool.space/testnet/api",
226
226
  signet: "https://mempool.space/signet/api"
227
227
  };
228
- async function st(e, t) {
228
+ async function ot(e, t) {
229
229
  try {
230
230
  const n = await fetch(e, t);
231
231
  if (!n.ok) {
@@ -240,7 +240,7 @@ async function st(e, t) {
240
240
  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
241
  }
242
242
  }
243
- async function Oe(e, t) {
243
+ async function Le(e, t) {
244
244
  try {
245
245
  const n = await fetch(`${t}/tx`, {
246
246
  method: "POST",
@@ -266,10 +266,10 @@ async function Oe(e, t) {
266
266
  throw n instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${n.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
267
267
  }
268
268
  }
269
- async function Le(e, t) {
270
- return st(`${t}/tx/${e}`);
269
+ async function Ce(e, t) {
270
+ return ot(`${t}/tx/${e}`);
271
271
  }
272
- async function Qn(e, t) {
272
+ async function ts(e, t) {
273
273
  try {
274
274
  const n = await fetch(`${t}/tx/${e}/hex`);
275
275
  if (!n.ok) {
@@ -283,8 +283,8 @@ async function Qn(e, t) {
283
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`);
284
284
  }
285
285
  }
286
- async function Ce(e, t, n) {
287
- const s = await Le(e, n);
286
+ async function _e(e, t, n) {
287
+ const s = await Ce(e, n);
288
288
  if (!Mt(t, s.vout.length))
289
289
  throw new Error(
290
290
  `Invalid vout ${t} for transaction ${e} (has ${s.vout.length} outputs)`
@@ -299,9 +299,9 @@ async function Ce(e, t, n) {
299
299
  scriptPubKey: r.scriptpubkey
300
300
  };
301
301
  }
302
- async function ts(e, t) {
302
+ async function es(e, t) {
303
303
  try {
304
- const n = await st(`${t}/address/${e}/utxo`), s = await st(`${t}/v1/validate-address/${e}`);
304
+ const n = await ot(`${t}/address/${e}/utxo`), s = await ot(`${t}/v1/validate-address/${e}`);
305
305
  if (!s.isvalid)
306
306
  throw new Error(
307
307
  `Invalid Bitcoin address: ${e}. Mempool API validation failed.`
@@ -329,13 +329,13 @@ async function ts(e, t) {
329
329
  );
330
330
  }
331
331
  }
332
- function es(e) {
333
- return Fe[e];
332
+ function ns(e) {
333
+ return Oe[e];
334
334
  }
335
- async function ns(e, t) {
336
- return st(`${t}/address/${e}/txs`);
335
+ async function ss(e, t) {
336
+ return ot(`${t}/address/${e}/txs`);
337
337
  }
338
- async function ss(e) {
338
+ async function rs(e) {
339
339
  const t = await fetch(`${e}/v1/fees/recommended`);
340
340
  if (!t.ok)
341
341
  throw new Error(
@@ -349,7 +349,7 @@ async function ss(e) {
349
349
  "minimumFee"
350
350
  ];
351
351
  for (const r of s)
352
- if (!Ue(n[r]))
352
+ if (!Fe(n[r]))
353
353
  throw new Error(
354
354
  `Invalid fee rate ${r}=${n[r]} from mempool API: expected a positive number ≤ ${Kt}`
355
355
  );
@@ -624,7 +624,7 @@ const ct = [
624
624
  name: "PeginSignaturesIncomplete",
625
625
  inputs: []
626
626
  }
627
- ], D = {
627
+ ], N = {
628
628
  // VaultAlreadyExists()
629
629
  "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.",
630
630
  // ScriptPubKeyMismatch() - taproot output doesn't match expected script
@@ -654,7 +654,7 @@ const ct = [
654
654
  // InvalidPeginFee(uint256,uint256)
655
655
  "0x979f4518": "Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction."
656
656
  };
657
- function yt(e) {
657
+ function xt(e) {
658
658
  if (!e || typeof e != "object") return;
659
659
  const t = e;
660
660
  if (typeof t.data == "string" && t.data.startsWith("0x"))
@@ -673,24 +673,24 @@ function yt(e) {
673
673
  if (i)
674
674
  return i[1];
675
675
  }
676
- function rs(e) {
677
- const t = yt(e);
676
+ function os(e) {
677
+ const t = xt(e);
678
678
  if (t) {
679
679
  const n = t.substring(0, 10);
680
- return D[t] ?? D[n];
680
+ return N[t] ?? N[n];
681
681
  }
682
682
  }
683
- function os(e) {
684
- const t = yt(e);
683
+ function is(e) {
684
+ const t = xt(e);
685
685
  if (t === void 0) return !1;
686
686
  const n = t.substring(0, 10);
687
- return t in D || n in D;
687
+ return t in N || n in N;
688
688
  }
689
689
  function ut(e) {
690
690
  console.error("[Contract Error] Raw error:", e);
691
- const t = yt(e);
691
+ const t = xt(e);
692
692
  if (console.error("[Contract Error] Extracted error data:", t), t) {
693
- const s = t.substring(0, 10), r = D[t] ?? D[s];
693
+ const s = t.substring(0, 10), r = N[t] ?? N[s];
694
694
  if (r)
695
695
  throw console.error("[Contract Error] Known error:", r), new Error(r);
696
696
  }
@@ -708,24 +708,24 @@ function ut(e) {
708
708
  }
709
709
  throw e instanceof Error ? (console.error("[Contract Error] Unhandled error:", e.message), e) : new Error(`Contract call failed: ${String(e)}`);
710
710
  }
711
- function _e(e, t, n, s) {
711
+ function We(e, t, n, s) {
712
712
  const r = n == null ? void 0 : n[`${e}:${t}`];
713
713
  return r ? Promise.resolve({
714
714
  txid: e,
715
715
  vout: t,
716
716
  value: r.value,
717
717
  scriptPubKey: r.scriptPubKey
718
- }) : Ce(e, t, s);
718
+ }) : _e(e, t, s);
719
719
  }
720
- const We = 12e4;
721
- class is {
720
+ const Re = 12e4;
721
+ class as {
722
722
  /**
723
723
  * Creates a new PeginManager instance.
724
724
  *
725
725
  * @param config - Manager configuration including wallets and contract addresses
726
726
  */
727
727
  constructor(t) {
728
- f(this, "config");
728
+ d(this, "config");
729
729
  this.config = t;
730
730
  }
731
731
  /**
@@ -749,7 +749,7 @@ class is {
749
749
  * @throws Error if wallet operations fail or insufficient funds
750
750
  */
751
751
  async preparePegin(t) {
752
- const n = await this.config.btcWallet.getPublicKeyHex(), s = n.length === 66 ? n.slice(2) : n, r = _(t.vaultProviderBtcPubkey), o = t.vaultKeeperBtcPubkeys.map(_), i = t.universalChallengerBtcPubkeys.map(_);
752
+ const n = await this.config.btcWallet.getPublicKeyHex(), s = n.length === 66 ? n.slice(2) : n, r = $(t.vaultProviderBtcPubkey), o = t.vaultKeeperBtcPubkeys.map($), i = t.universalChallengerBtcPubkeys.map($);
753
753
  if (t.hashlocks.length !== t.amounts.length)
754
754
  throw new Error(
755
755
  `hashlocks.length (${t.hashlocks.length}) must equal amounts.length (${t.amounts.length})`
@@ -769,59 +769,59 @@ class is {
769
769
  councilQuorum: t.councilQuorum,
770
770
  councilSize: t.councilSize,
771
771
  network: this.config.btcNetwork
772
- }, u = await ye(c), h = Se(
772
+ }, u = await xe(c), h = Ae(
773
773
  [...t.availableUTXOs],
774
774
  u.totalOutputValue,
775
775
  t.mempoolFeeRate,
776
- xe(u.htlcValues.length)
777
- ), l = pt(this.config.btcNetwork), d = we({
776
+ ye(u.htlcValues.length)
777
+ ), l = pt(this.config.btcNetwork), f = we({
778
778
  unfundedTxHex: u.psbtHex,
779
779
  selectedUTXOs: h.selectedUTXOs,
780
780
  changeAddress: t.changeAddress,
781
781
  changeAmount: h.changeAmount,
782
782
  network: l
783
- }), g = _(St(d)), p = [], w = [], y = [];
784
- for (let b = 0; b < t.hashlocks.length; b++) {
783
+ }), g = $(St(f)), b = [], w = [], x = [];
784
+ for (let p = 0; p < t.hashlocks.length; p++) {
785
785
  const P = await me({
786
786
  prePeginParams: c,
787
787
  timelockPegin: t.timelockPegin,
788
- fundedPrePeginTxHex: d,
789
- htlcVout: b
790
- }), T = await Pe({
788
+ fundedPrePeginTxHex: f,
789
+ htlcVout: p
790
+ }), v = await Pe({
791
791
  peginTxHex: P.txHex,
792
- fundedPrePeginTxHex: d,
792
+ fundedPrePeginTxHex: f,
793
793
  depositorPubkey: s,
794
794
  vaultProviderPubkey: r,
795
795
  vaultKeeperPubkeys: o,
796
796
  universalChallengerPubkeys: i,
797
- hashlock: t.hashlocks[b],
797
+ hashlock: t.hashlocks[p],
798
798
  timelockRefund: t.timelockRefund,
799
799
  network: this.config.btcNetwork
800
800
  });
801
- p.push(P), w.push(T.psbtHex), y.push(
801
+ b.push(P), w.push(v.psbtHex), x.push(
802
802
  bt(n, 1)
803
803
  );
804
804
  }
805
- const x = await this.signPsbtsWithFallback(
805
+ const y = await this.signPsbtsWithFallback(
806
806
  w,
807
- y
807
+ x
808
808
  ), m = [];
809
- for (let b = 0; b < x.length; b++) {
809
+ for (let p = 0; p < y.length; p++) {
810
810
  const P = Te(
811
- x[b],
811
+ y[p],
812
812
  s
813
- ), T = ve(x[b]);
813
+ ), v = ve(y[p]);
814
814
  m.push({
815
- htlcVout: b,
816
- htlcValue: u.htlcValues[b],
817
- peginTxHex: T,
818
- peginTxid: p[b].txid,
815
+ htlcVout: p,
816
+ htlcValue: u.htlcValues[p],
817
+ peginTxHex: v,
818
+ peginTxid: b[p].txid,
819
819
  peginInputSignature: P,
820
- vaultScriptPubKey: p[b].vaultScriptPubKey
820
+ vaultScriptPubKey: b[p].vaultScriptPubKey
821
821
  });
822
822
  }
823
823
  return {
824
- fundedPrePeginTxHex: d,
824
+ fundedPrePeginTxHex: f,
825
825
  prePeginTxid: g,
826
826
  unsignedPrePeginTxHex: u.psbtHex,
827
827
  perVault: m,
@@ -875,7 +875,7 @@ class is {
875
875
  * @throws Error if signing or broadcasting fails
876
876
  */
877
877
  async signAndBroadcast(t) {
878
- const { fundedPrePeginTxHex: n, depositorBtcPubkey: s } = t, r = n.startsWith("0x") ? n.slice(2) : n, o = G.fromHex(r);
878
+ const { fundedPrePeginTxHex: n, depositorBtcPubkey: s } = t, r = n.startsWith("0x") ? n.slice(2) : n, o = q.fromHex(r);
879
879
  if (o.ins.length === 0)
880
880
  throw new Error("Transaction has no inputs");
881
881
  const i = new dt();
@@ -890,45 +890,45 @@ class is {
890
890
  throw new Error(
891
891
  `Invalid depositorBtcPubkey length: expected 32 bytes, got ${c.length}`
892
892
  );
893
- const u = this.config.mempoolApiUrl, h = o.ins.map((y) => {
894
- const x = S.from(y.hash).reverse().toString("hex"), m = y.index;
895
- return _e(x, m, t.localPrevouts, u).then(
896
- (b) => ({ input: y, utxoData: b, txid: x, vout: m })
893
+ const u = this.config.mempoolApiUrl, h = o.ins.map((x) => {
894
+ const y = S.from(x.hash).reverse().toString("hex"), m = x.index;
895
+ return We(y, m, t.localPrevouts, u).then(
896
+ (p) => ({ input: x, utxoData: p, txid: y, vout: m })
897
897
  );
898
898
  }), l = await Promise.all(h);
899
- for (const { input: y, utxoData: x, txid: m, vout: b } of l) {
900
- const P = Be(
899
+ for (const { input: x, utxoData: y, txid: m, vout: p } of l) {
900
+ const P = $e(
901
901
  {
902
- value: x.value,
903
- scriptPubKey: x.scriptPubKey
902
+ value: y.value,
903
+ scriptPubKey: y.scriptPubKey
904
904
  },
905
905
  c
906
906
  );
907
907
  i.addInput({
908
- hash: y.hash,
909
- index: y.index,
910
- sequence: y.sequence,
908
+ hash: x.hash,
909
+ index: x.index,
910
+ sequence: x.sequence,
911
911
  ...P
912
912
  });
913
913
  }
914
- for (const y of o.outs)
914
+ for (const x of o.outs)
915
915
  i.addOutput({
916
- script: y.script,
917
- value: y.value
916
+ script: x.script,
917
+ value: x.value
918
918
  });
919
- const d = await this.config.btcWallet.signPsbt(i.toHex()), g = dt.fromHex(d);
919
+ const f = await this.config.btcWallet.signPsbt(i.toHex()), g = dt.fromHex(f);
920
920
  try {
921
921
  g.finalizeAllInputs();
922
- } catch (y) {
922
+ } catch (x) {
923
923
  if (!g.data.inputs.every(
924
924
  (m) => m.finalScriptWitness || m.finalScriptSig
925
925
  ))
926
926
  throw new Error(
927
- `PSBT finalization failed and wallet did not auto-finalize: ${y}`
927
+ `PSBT finalization failed and wallet did not auto-finalize: ${x}`
928
928
  );
929
929
  }
930
- const p = g.extractTransaction().toHex();
931
- return await Oe(p, u);
930
+ const b = g.extractTransaction().toHex();
931
+ return await Le(b, u);
932
932
  }
933
933
  /**
934
934
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -962,25 +962,28 @@ class is {
962
962
  } = t;
963
963
  if (!this.config.ethWallet.account)
964
964
  throw new Error("Ethereum wallet account not found");
965
- const d = this.config.ethWallet.account.address, g = await this.resolvePopSignature(
966
- d,
965
+ const f = this.config.ethWallet.account.address, g = await this.resolvePopSignature(
966
+ f,
967
967
  l
968
968
  );
969
969
  c && await c();
970
- const p = at(n), w = at(s), y = at(r), x = await this.resolvePayoutScriptPubKey(
970
+ const b = z(n), w = z(s), x = z(r), y = await this.resolvePayoutScriptPubKey(
971
971
  u
972
- ), m = St(y);
973
- if (await this.checkVaultExists(m))
972
+ ), m = St(x), p = await Se(
973
+ $(m),
974
+ $(f)
975
+ ), P = z(p);
976
+ if (await this.checkVaultExists(P))
974
977
  throw new Error(
975
- `Vault already exists for this transaction (ID: ${m}). 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.`
978
+ `Vault already exists (ID: ${P}, peginTxHash: ${m}). 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.`
976
979
  );
977
- const P = Et({
980
+ const T = It({
978
981
  chain: this.config.ethChain,
979
- transport: It()
982
+ transport: Et()
980
983
  });
981
- let T;
984
+ let E;
982
985
  try {
983
- T = await P.readContract({
986
+ E = await T.readContract({
984
987
  address: this.config.vaultContracts.btcVaultRegistry,
985
988
  abi: ct,
986
989
  functionName: "getPegInFee",
@@ -991,57 +994,58 @@ class is {
991
994
  "Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct."
992
995
  );
993
996
  }
994
- const v = Ee({
997
+ const H = Ie({
995
998
  abi: ct,
996
999
  functionName: "submitPeginRequest",
997
1000
  args: [
998
- d,
999
- p,
1001
+ f,
1002
+ b,
1000
1003
  g,
1001
1004
  w,
1002
- y,
1005
+ x,
1003
1006
  o,
1004
1007
  i,
1005
1008
  a,
1006
- x,
1009
+ y,
1007
1010
  h
1008
1011
  ]
1009
1012
  });
1010
1013
  let I;
1011
1014
  try {
1012
- I = await P.estimateGas({
1015
+ I = await T.estimateGas({
1013
1016
  to: this.config.vaultContracts.btcVaultRegistry,
1014
- data: v,
1015
- value: T,
1017
+ data: H,
1018
+ value: E,
1016
1019
  account: this.config.ethWallet.account.address
1017
1020
  });
1018
- } catch (U) {
1019
- ut(U);
1021
+ } catch (O) {
1022
+ ut(O);
1020
1023
  }
1021
- let k;
1024
+ let F;
1022
1025
  try {
1023
- k = await this.config.ethWallet.sendTransaction({
1026
+ F = await this.config.ethWallet.sendTransaction({
1024
1027
  to: this.config.vaultContracts.btcVaultRegistry,
1025
- data: v,
1026
- value: T,
1028
+ data: H,
1029
+ value: E,
1027
1030
  account: this.config.ethWallet.account,
1028
1031
  chain: this.config.ethChain,
1029
1032
  gas: I
1030
1033
  });
1031
- } catch (U) {
1032
- ut(U);
1034
+ } catch (O) {
1035
+ ut(O);
1033
1036
  }
1034
- const E = await P.waitForTransactionReceipt({
1035
- hash: k,
1036
- timeout: We
1037
+ const K = await T.waitForTransactionReceipt({
1038
+ hash: F,
1039
+ timeout: Re
1037
1040
  });
1038
- return E.status === "reverted" && ut(
1041
+ return K.status === "reverted" && ut(
1039
1042
  new Error(
1040
- `Transaction reverted. Hash: ${k}. Check the transaction on block explorer for details.`
1043
+ `Transaction reverted. Hash: ${F}. Check the transaction on block explorer for details.`
1041
1044
  )
1042
1045
  ), {
1043
- ethTxHash: E.transactionHash,
1044
- vaultId: m,
1046
+ ethTxHash: K.transactionHash,
1047
+ vaultId: P,
1048
+ peginTxHash: m,
1045
1049
  btcPopSignature: g
1046
1050
  };
1047
1051
  }
@@ -1053,15 +1057,15 @@ class is {
1053
1057
  */
1054
1058
  async checkVaultExists(t) {
1055
1059
  try {
1056
- return (await Et({
1060
+ return (await It({
1057
1061
  chain: this.config.ethChain,
1058
- transport: It()
1062
+ transport: Et()
1059
1063
  }).readContract({
1060
1064
  address: this.config.vaultContracts.btcVaultRegistry,
1061
1065
  abi: ct,
1062
1066
  functionName: "getBTCVault",
1063
1067
  args: [t]
1064
- })).depositor !== Ie;
1068
+ })).depositor !== Ee;
1065
1069
  } catch {
1066
1070
  return !1;
1067
1071
  }
@@ -1130,14 +1134,14 @@ class is {
1130
1134
  return this.config.vaultContracts.btcVaultRegistry;
1131
1135
  }
1132
1136
  }
1133
- class as {
1137
+ class cs {
1134
1138
  /**
1135
1139
  * Creates a new PayoutManager instance.
1136
1140
  *
1137
1141
  * @param config - Manager configuration including wallet
1138
1142
  */
1139
1143
  constructor(t) {
1140
- f(this, "config");
1144
+ d(this, "config");
1141
1145
  this.config = t;
1142
1146
  }
1143
1147
  /**
@@ -1284,9 +1288,9 @@ class as {
1284
1288
  "Invalid registeredPayoutScriptPubKey: not valid hex"
1285
1289
  );
1286
1290
  const s = S.from(
1287
- _(n),
1291
+ $(n),
1288
1292
  "hex"
1289
- ), r = G.fromHex(_(t));
1293
+ ), r = q.fromHex($(t));
1290
1294
  if (r.outs.length === 0)
1291
1295
  throw new Error("Payout transaction has no outputs");
1292
1296
  if (!r.outs.reduce(
@@ -1297,17 +1301,17 @@ class as {
1297
1301
  );
1298
1302
  }
1299
1303
  }
1300
- function Re(e) {
1304
+ function Ve(e) {
1301
1305
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
1302
1306
  }
1303
- function W(e, t = "") {
1307
+ function R(e, t = "") {
1304
1308
  if (!Number.isSafeInteger(e) || e < 0) {
1305
1309
  const n = t && `"${t}" `;
1306
1310
  throw new Error(`${n}expected integer >= 0, got ${e}`);
1307
1311
  }
1308
1312
  }
1309
- function R(e, t, n = "") {
1310
- const s = Re(e), r = e == null ? void 0 : e.length, o = t !== void 0;
1313
+ function V(e, t, n = "") {
1314
+ const s = Ve(e), r = e == null ? void 0 : e.length, o = t !== void 0;
1311
1315
  if (!s || o && r !== t) {
1312
1316
  const i = n && `"${n}" `, a = o ? ` of length ${t}` : "", c = s ? `length=${r}` : `type=${typeof e}`;
1313
1317
  throw new Error(i + "expected Uint8Array" + a + ", got " + c);
@@ -1317,60 +1321,60 @@ function R(e, t, n = "") {
1317
1321
  function Nt(e) {
1318
1322
  if (typeof e != "function" || typeof e.create != "function")
1319
1323
  throw new Error("Hash must wrapped by utils.createHasher");
1320
- W(e.outputLen), W(e.blockLen);
1324
+ R(e.outputLen), R(e.blockLen);
1321
1325
  }
1322
- function M(e, t = !0) {
1326
+ function X(e, t = !0) {
1323
1327
  if (e.destroyed)
1324
1328
  throw new Error("Hash instance has been destroyed");
1325
1329
  if (t && e.finished)
1326
1330
  throw new Error("Hash#digest() has already been called");
1327
1331
  }
1328
1332
  function Xt(e, t) {
1329
- R(e, void 0, "digestInto() output");
1333
+ V(e, void 0, "digestInto() output");
1330
1334
  const n = t.outputLen;
1331
1335
  if (e.length < n)
1332
1336
  throw new Error('"digestInto() output" expected to be of length >=' + n);
1333
1337
  }
1334
- function Ve(e) {
1338
+ function Ke(e) {
1335
1339
  return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
1336
1340
  }
1337
1341
  function A(...e) {
1338
1342
  for (let t = 0; t < e.length; t++)
1339
1343
  e[t].fill(0);
1340
1344
  }
1341
- function nt(e) {
1345
+ function rt(e) {
1342
1346
  return new DataView(e.buffer, e.byteOffset, e.byteLength);
1343
1347
  }
1344
1348
  function B(e, t) {
1345
1349
  return e << 32 - t | e >>> t;
1346
1350
  }
1347
- function q(e, t) {
1351
+ function Z(e, t) {
1348
1352
  return e << t | e >>> 32 - t >>> 0;
1349
1353
  }
1350
- const Ke = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1351
- function De(e) {
1354
+ const De = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1355
+ function Me(e) {
1352
1356
  return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
1353
1357
  }
1354
- function Me(e) {
1358
+ function Ne(e) {
1355
1359
  for (let t = 0; t < e.length; t++)
1356
- e[t] = De(e[t]);
1360
+ e[t] = Me(e[t]);
1357
1361
  return e;
1358
1362
  }
1359
- const At = Ke ? (e) => e : Me;
1360
- function Ne(e) {
1363
+ const At = De ? (e) => e : Ne;
1364
+ function Xe(e) {
1361
1365
  if (typeof e != "string")
1362
1366
  throw new Error("string expected");
1363
1367
  return new Uint8Array(new TextEncoder().encode(e));
1364
1368
  }
1365
1369
  function Bt(e, t = "") {
1366
- return typeof e == "string" ? Ne(e) : R(e, void 0, t);
1370
+ return typeof e == "string" ? Xe(e) : V(e, void 0, t);
1367
1371
  }
1368
- function Xe(e, t) {
1372
+ function Ge(e, t) {
1369
1373
  if (t !== void 0 && {}.toString.call(t) !== "[object Object]")
1370
1374
  throw new Error("options must be object or undefined");
1371
1375
  return Object.assign(e, t);
1372
1376
  }
1373
- function rt(e, t = {}) {
1377
+ function it(e, t = {}) {
1374
1378
  const n = (r, o) => e(o).update(r).digest(), s = e(void 0);
1375
1379
  return n.outputLen = s.outputLen, n.blockLen = s.blockLen, n.create = (r) => e(r), Object.assign(n, t), Object.freeze(n);
1376
1380
  }
@@ -1379,13 +1383,13 @@ const Gt = (e) => ({
1379
1383
  });
1380
1384
  class jt {
1381
1385
  constructor(t, n) {
1382
- f(this, "oHash");
1383
- f(this, "iHash");
1384
- f(this, "blockLen");
1385
- f(this, "outputLen");
1386
- f(this, "finished", !1);
1387
- f(this, "destroyed", !1);
1388
- if (Nt(t), R(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
1386
+ d(this, "oHash");
1387
+ d(this, "iHash");
1388
+ d(this, "blockLen");
1389
+ d(this, "outputLen");
1390
+ d(this, "finished", !1);
1391
+ d(this, "destroyed", !1);
1392
+ if (Nt(t), V(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
1389
1393
  throw new Error("Expected instance of class which extends utils.Hash");
1390
1394
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
1391
1395
  const s = this.blockLen, r = new Uint8Array(s);
@@ -1398,10 +1402,10 @@ class jt {
1398
1402
  this.oHash.update(r), A(r);
1399
1403
  }
1400
1404
  update(t) {
1401
- return M(this), this.iHash.update(t), this;
1405
+ return X(this), this.iHash.update(t), this;
1402
1406
  }
1403
1407
  digestInto(t) {
1404
- M(this), R(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1408
+ X(this), V(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1405
1409
  }
1406
1410
  digest() {
1407
1411
  const t = new Uint8Array(this.oHash.outputLen);
@@ -1419,36 +1423,36 @@ class jt {
1419
1423
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
1420
1424
  }
1421
1425
  }
1422
- const xt = (e, t, n) => new jt(e, t).update(n).digest();
1423
- xt.create = (e, t) => new jt(e, t);
1424
- function Ge(e, t, n) {
1426
+ const yt = (e, t, n) => new jt(e, t).update(n).digest();
1427
+ yt.create = (e, t) => new jt(e, t);
1428
+ function je(e, t, n) {
1425
1429
  return e & t ^ ~e & n;
1426
1430
  }
1427
- function je(e, t, n) {
1431
+ function qe(e, t, n) {
1428
1432
  return e & t ^ e & n ^ t & n;
1429
1433
  }
1430
1434
  class wt {
1431
1435
  constructor(t, n, s, r) {
1432
- f(this, "blockLen");
1433
- f(this, "outputLen");
1434
- f(this, "padOffset");
1435
- f(this, "isLE");
1436
+ d(this, "blockLen");
1437
+ d(this, "outputLen");
1438
+ d(this, "padOffset");
1439
+ d(this, "isLE");
1436
1440
  // For partial updates less than block size
1437
- f(this, "buffer");
1438
- f(this, "view");
1439
- f(this, "finished", !1);
1440
- f(this, "length", 0);
1441
- f(this, "pos", 0);
1442
- f(this, "destroyed", !1);
1443
- this.blockLen = t, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(t), this.view = nt(this.buffer);
1441
+ d(this, "buffer");
1442
+ d(this, "view");
1443
+ d(this, "finished", !1);
1444
+ d(this, "length", 0);
1445
+ d(this, "pos", 0);
1446
+ d(this, "destroyed", !1);
1447
+ this.blockLen = t, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(t), this.view = rt(this.buffer);
1444
1448
  }
1445
1449
  update(t) {
1446
- M(this), R(t);
1450
+ X(this), V(t);
1447
1451
  const { view: n, buffer: s, blockLen: r } = this, o = t.length;
1448
1452
  for (let i = 0; i < o; ) {
1449
1453
  const a = Math.min(r - this.pos, o - i);
1450
1454
  if (a === r) {
1451
- const c = nt(t);
1455
+ const c = rt(t);
1452
1456
  for (; r <= o - i; i += r)
1453
1457
  this.process(c, i);
1454
1458
  continue;
@@ -1458,14 +1462,14 @@ class wt {
1458
1462
  return this.length += t.length, this.roundClean(), this;
1459
1463
  }
1460
1464
  digestInto(t) {
1461
- M(this), Xt(t, this), this.finished = !0;
1465
+ X(this), Xt(t, this), this.finished = !0;
1462
1466
  const { buffer: n, view: s, blockLen: r, isLE: o } = this;
1463
1467
  let { pos: i } = this;
1464
1468
  n[i++] = 128, A(this.buffer.subarray(i)), this.padOffset > r - i && (this.process(s, 0), i = 0);
1465
1469
  for (let l = i; l < r; l++)
1466
1470
  n[l] = 0;
1467
1471
  s.setBigUint64(r - 8, BigInt(this.length * 8), o), this.process(s, 0);
1468
- const a = nt(t), c = this.outputLen;
1472
+ const a = rt(t), c = this.outputLen;
1469
1473
  if (c % 4)
1470
1474
  throw new Error("_sha2: outputLen must be aligned to 32bit");
1471
1475
  const u = c / 4, h = this.get();
@@ -1489,7 +1493,7 @@ class wt {
1489
1493
  return this._cloneInto();
1490
1494
  }
1491
1495
  }
1492
- const F = /* @__PURE__ */ Uint32Array.from([
1496
+ const L = /* @__PURE__ */ Uint32Array.from([
1493
1497
  1779033703,
1494
1498
  3144134277,
1495
1499
  1013904242,
@@ -1498,7 +1502,7 @@ const F = /* @__PURE__ */ Uint32Array.from([
1498
1502
  2600822924,
1499
1503
  528734635,
1500
1504
  1541459225
1501
- ]), H = /* @__PURE__ */ Uint32Array.from([
1505
+ ]), k = /* @__PURE__ */ Uint32Array.from([
1502
1506
  1779033703,
1503
1507
  4089235720,
1504
1508
  3144134277,
@@ -1515,7 +1519,7 @@ const F = /* @__PURE__ */ Uint32Array.from([
1515
1519
  4215389547,
1516
1520
  1541459225,
1517
1521
  327033209
1518
- ]), qe = /* @__PURE__ */ Uint8Array.from([
1522
+ ]), ze = /* @__PURE__ */ Uint8Array.from([
1519
1523
  7,
1520
1524
  4,
1521
1525
  13,
@@ -1532,11 +1536,11 @@ const F = /* @__PURE__ */ Uint32Array.from([
1532
1536
  14,
1533
1537
  11,
1534
1538
  8
1535
- ]), qt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), ze = qt.map((e) => (9 * e + 5) % 16), zt = /* @__PURE__ */ (() => {
1536
- const n = [[qt], [ze]];
1539
+ ]), qt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), Ze = qt.map((e) => (9 * e + 5) % 16), zt = /* @__PURE__ */ (() => {
1540
+ const n = [[qt], [Ze]];
1537
1541
  for (let s = 0; s < 4; s++)
1538
1542
  for (let r of n)
1539
- r.push(r[s].map((o) => qe[o]));
1543
+ r.push(r[s].map((o) => ze[o]));
1540
1544
  return n;
1541
1545
  })(), Zt = zt[0], Jt = zt[1], Yt = /* @__PURE__ */ [
1542
1546
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
@@ -1544,13 +1548,13 @@ const F = /* @__PURE__ */ Uint32Array.from([
1544
1548
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
1545
1549
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
1546
1550
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
1547
- ].map((e) => Uint8Array.from(e)), Ze = /* @__PURE__ */ Zt.map((e, t) => e.map((n) => Yt[t][n])), Je = /* @__PURE__ */ Jt.map((e, t) => e.map((n) => Yt[t][n])), Ye = /* @__PURE__ */ Uint32Array.from([
1551
+ ].map((e) => Uint8Array.from(e)), Je = /* @__PURE__ */ Zt.map((e, t) => e.map((n) => Yt[t][n])), Ye = /* @__PURE__ */ Jt.map((e, t) => e.map((n) => Yt[t][n])), Qe = /* @__PURE__ */ Uint32Array.from([
1548
1552
  0,
1549
1553
  1518500249,
1550
1554
  1859775393,
1551
1555
  2400959708,
1552
1556
  2840853838
1553
- ]), Qe = /* @__PURE__ */ Uint32Array.from([
1557
+ ]), tn = /* @__PURE__ */ Uint32Array.from([
1554
1558
  1352829926,
1555
1559
  1548603684,
1556
1560
  1836072691,
@@ -1560,15 +1564,15 @@ const F = /* @__PURE__ */ Uint32Array.from([
1560
1564
  function $t(e, t, n, s) {
1561
1565
  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);
1562
1566
  }
1563
- const z = /* @__PURE__ */ new Uint32Array(16);
1564
- class tn extends wt {
1567
+ const J = /* @__PURE__ */ new Uint32Array(16);
1568
+ class en extends wt {
1565
1569
  constructor() {
1566
1570
  super(64, 20, 8, !0);
1567
- f(this, "h0", 1732584193);
1568
- f(this, "h1", -271733879);
1569
- f(this, "h2", -1732584194);
1570
- f(this, "h3", 271733878);
1571
- f(this, "h4", -1009589776);
1571
+ d(this, "h0", 1732584193);
1572
+ d(this, "h1", -271733879);
1573
+ d(this, "h2", -1732584194);
1574
+ d(this, "h3", 271733878);
1575
+ d(this, "h4", -1009589776);
1572
1576
  }
1573
1577
  get() {
1574
1578
  const { h0: n, h1: s, h2: r, h3: o, h4: i } = this;
@@ -1578,48 +1582,48 @@ class tn extends wt {
1578
1582
  this.h0 = n | 0, this.h1 = s | 0, this.h2 = r | 0, this.h3 = o | 0, this.h4 = i | 0;
1579
1583
  }
1580
1584
  process(n, s) {
1581
- for (let p = 0; p < 16; p++, s += 4)
1582
- z[p] = n.getUint32(s, !0);
1583
- 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;
1584
- for (let p = 0; p < 5; p++) {
1585
- const w = 4 - p, y = Ye[p], x = Qe[p], m = Zt[p], b = Jt[p], P = Ze[p], T = Je[p];
1586
- for (let v = 0; v < 16; v++) {
1587
- const I = q(r + $t(p, i, c, h) + z[m[v]] + y, P[v]) + d | 0;
1588
- r = d, d = h, h = q(c, 10) | 0, c = i, i = I;
1585
+ for (let b = 0; b < 16; b++, s += 4)
1586
+ J[b] = n.getUint32(s, !0);
1587
+ 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, f = this.h4 | 0, g = f;
1588
+ for (let b = 0; b < 5; b++) {
1589
+ const w = 4 - b, x = Qe[b], y = tn[b], m = Zt[b], p = Jt[b], P = Je[b], v = Ye[b];
1590
+ for (let T = 0; T < 16; T++) {
1591
+ const E = Z(r + $t(b, i, c, h) + J[m[T]] + x, P[T]) + f | 0;
1592
+ r = f, f = h, h = Z(c, 10) | 0, c = i, i = E;
1589
1593
  }
1590
- for (let v = 0; v < 16; v++) {
1591
- const I = q(o + $t(w, a, u, l) + z[b[v]] + x, T[v]) + g | 0;
1592
- o = g, g = l, l = q(u, 10) | 0, u = a, a = I;
1594
+ for (let T = 0; T < 16; T++) {
1595
+ const E = Z(o + $t(w, a, u, l) + J[p[T]] + y, v[T]) + g | 0;
1596
+ o = g, g = l, l = Z(u, 10) | 0, u = a, a = E;
1593
1597
  }
1594
1598
  }
1595
- 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);
1599
+ this.set(this.h1 + c + l | 0, this.h2 + h + g | 0, this.h3 + f + o | 0, this.h4 + r + a | 0, this.h0 + i + u | 0);
1596
1600
  }
1597
1601
  roundClean() {
1598
- A(z);
1602
+ A(J);
1599
1603
  }
1600
1604
  destroy() {
1601
1605
  this.destroyed = !0, A(this.buffer), this.set(0, 0, 0, 0, 0);
1602
1606
  }
1603
1607
  }
1604
- const en = /* @__PURE__ */ rt(() => new tn()), Z = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ut = /* @__PURE__ */ BigInt(32);
1605
- function nn(e, t = !1) {
1606
- return t ? { h: Number(e & Z), l: Number(e >> Ut & Z) } : { h: Number(e >> Ut & Z) | 0, l: Number(e & Z) | 0 };
1608
+ const nn = /* @__PURE__ */ it(() => new en()), Y = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ut = /* @__PURE__ */ BigInt(32);
1609
+ function sn(e, t = !1) {
1610
+ return t ? { h: Number(e & Y), l: Number(e >> Ut & Y) } : { h: Number(e >> Ut & Y) | 0, l: Number(e & Y) | 0 };
1607
1611
  }
1608
1612
  function Qt(e, t = !1) {
1609
1613
  const n = e.length;
1610
1614
  let s = new Uint32Array(n), r = new Uint32Array(n);
1611
1615
  for (let o = 0; o < n; o++) {
1612
- const { h: i, l: a } = nn(e[o], t);
1616
+ const { h: i, l: a } = sn(e[o], t);
1613
1617
  [s[o], r[o]] = [i, a];
1614
1618
  }
1615
1619
  return [s, r];
1616
1620
  }
1617
- const Ft = (e, t, n) => e >>> n, Ot = (e, t, n) => e << 32 - n | t >>> n, V = (e, t, n) => e >>> n | t << 32 - n, K = (e, t, n) => e << 32 - n | t >>> n, J = (e, t, n) => e << 64 - n | t >>> n - 32, Y = (e, t, n) => e >>> n - 32 | t << 64 - n, sn = (e, t, n) => e << n | t >>> 32 - n, rn = (e, t, n) => t << n | e >>> 32 - n, on = (e, t, n) => t << n - 32 | e >>> 64 - n, an = (e, t, n) => e << n - 32 | t >>> 64 - n;
1618
- function $(e, t, n, s) {
1621
+ const Ft = (e, t, n) => e >>> n, Ot = (e, t, n) => e << 32 - n | t >>> n, D = (e, t, n) => e >>> n | t << 32 - n, M = (e, t, n) => e << 32 - n | t >>> n, Q = (e, t, n) => e << 64 - n | t >>> n - 32, tt = (e, t, n) => e >>> n - 32 | t << 64 - n, rn = (e, t, n) => e << n | t >>> 32 - n, on = (e, t, n) => t << n | e >>> 32 - n, an = (e, t, n) => t << n - 32 | e >>> 64 - n, cn = (e, t, n) => e << n - 32 | t >>> 64 - n;
1622
+ function U(e, t, n, s) {
1619
1623
  const r = (t >>> 0) + (s >>> 0);
1620
1624
  return { h: e + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
1621
1625
  }
1622
- const cn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), un = (e, t, n, s) => t + n + s + (e / 2 ** 32 | 0) | 0, ln = (e, t, n, s) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0), hn = (e, t, n, s, r) => t + n + s + r + (e / 2 ** 32 | 0) | 0, fn = (e, t, n, s, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0) + (r >>> 0), dn = (e, t, n, s, r, o) => t + n + s + r + o + (e / 2 ** 32 | 0) | 0, pn = /* @__PURE__ */ Uint32Array.from([
1626
+ const un = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), ln = (e, t, n, s) => t + n + s + (e / 2 ** 32 | 0) | 0, hn = (e, t, n, s) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0), fn = (e, t, n, s, r) => t + n + s + r + (e / 2 ** 32 | 0) | 0, dn = (e, t, n, s, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0) + (r >>> 0), pn = (e, t, n, s, r, o) => t + n + s + r + o + (e / 2 ** 32 | 0) | 0, bn = /* @__PURE__ */ Uint32Array.from([
1623
1627
  1116352408,
1624
1628
  1899447441,
1625
1629
  3049323471,
@@ -1684,8 +1688,8 @@ const cn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), un = (e, t, n, s) =>
1684
1688
  2756734187,
1685
1689
  3204031479,
1686
1690
  3329325298
1687
- ]), O = /* @__PURE__ */ new Uint32Array(64);
1688
- class bn extends wt {
1691
+ ]), C = /* @__PURE__ */ new Uint32Array(64);
1692
+ class gn extends wt {
1689
1693
  constructor(t) {
1690
1694
  super(64, t, 8, !1);
1691
1695
  }
@@ -1699,38 +1703,38 @@ class bn extends wt {
1699
1703
  }
1700
1704
  process(t, n) {
1701
1705
  for (let l = 0; l < 16; l++, n += 4)
1702
- O[l] = t.getUint32(n, !1);
1706
+ C[l] = t.getUint32(n, !1);
1703
1707
  for (let l = 16; l < 64; l++) {
1704
- const d = O[l - 15], g = O[l - 2], p = B(d, 7) ^ B(d, 18) ^ d >>> 3, w = B(g, 17) ^ B(g, 19) ^ g >>> 10;
1705
- O[l] = w + O[l - 7] + p + O[l - 16] | 0;
1708
+ const f = C[l - 15], g = C[l - 2], b = B(f, 7) ^ B(f, 18) ^ f >>> 3, w = B(g, 17) ^ B(g, 19) ^ g >>> 10;
1709
+ C[l] = w + C[l - 7] + b + C[l - 16] | 0;
1706
1710
  }
1707
1711
  let { A: s, B: r, C: o, D: i, E: a, F: c, G: u, H: h } = this;
1708
1712
  for (let l = 0; l < 64; l++) {
1709
- const d = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + d + Ge(a, c, u) + pn[l] + O[l] | 0, w = (B(s, 2) ^ B(s, 13) ^ B(s, 22)) + je(s, r, o) | 0;
1713
+ const f = B(a, 6) ^ B(a, 11) ^ B(a, 25), g = h + f + je(a, c, u) + bn[l] + C[l] | 0, w = (B(s, 2) ^ B(s, 13) ^ B(s, 22)) + qe(s, r, o) | 0;
1710
1714
  h = u, u = c, c = a, a = i + g | 0, i = o, o = r, r = s, s = g + w | 0;
1711
1715
  }
1712
1716
  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);
1713
1717
  }
1714
1718
  roundClean() {
1715
- A(O);
1719
+ A(C);
1716
1720
  }
1717
1721
  destroy() {
1718
1722
  this.set(0, 0, 0, 0, 0, 0, 0, 0), A(this.buffer);
1719
1723
  }
1720
1724
  }
1721
- class gn extends bn {
1725
+ class xn extends gn {
1722
1726
  constructor() {
1723
1727
  super(32);
1724
1728
  // We cannot use array here since array allows indexing by variable
1725
1729
  // which means optimizer/compiler cannot use registers.
1726
- f(this, "A", F[0] | 0);
1727
- f(this, "B", F[1] | 0);
1728
- f(this, "C", F[2] | 0);
1729
- f(this, "D", F[3] | 0);
1730
- f(this, "E", F[4] | 0);
1731
- f(this, "F", F[5] | 0);
1732
- f(this, "G", F[6] | 0);
1733
- f(this, "H", F[7] | 0);
1730
+ d(this, "A", L[0] | 0);
1731
+ d(this, "B", L[1] | 0);
1732
+ d(this, "C", L[2] | 0);
1733
+ d(this, "D", L[3] | 0);
1734
+ d(this, "E", L[4] | 0);
1735
+ d(this, "F", L[5] | 0);
1736
+ d(this, "G", L[6] | 0);
1737
+ d(this, "H", L[7] | 0);
1734
1738
  }
1735
1739
  }
1736
1740
  const te = Qt([
@@ -1814,88 +1818,88 @@ const te = Qt([
1814
1818
  "0x597f299cfc657e2a",
1815
1819
  "0x5fcb6fab3ad6faec",
1816
1820
  "0x6c44198c4a475817"
1817
- ].map((e) => BigInt(e))), yn = te[0], xn = te[1], L = /* @__PURE__ */ new Uint32Array(80), C = /* @__PURE__ */ new Uint32Array(80);
1818
- class wn extends wt {
1821
+ ].map((e) => BigInt(e))), yn = te[0], wn = te[1], _ = /* @__PURE__ */ new Uint32Array(80), W = /* @__PURE__ */ new Uint32Array(80);
1822
+ class mn extends wt {
1819
1823
  constructor(t) {
1820
1824
  super(128, t, 16, !1);
1821
1825
  }
1822
1826
  // prettier-ignore
1823
1827
  get() {
1824
- 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: w, Hl: y } = this;
1825
- return [t, n, s, r, o, i, a, c, u, h, l, d, g, p, w, y];
1828
+ const { Ah: t, Al: n, Bh: s, Bl: r, Ch: o, Cl: i, Dh: a, Dl: c, Eh: u, El: h, Fh: l, Fl: f, Gh: g, Gl: b, Hh: w, Hl: x } = this;
1829
+ return [t, n, s, r, o, i, a, c, u, h, l, f, g, b, w, x];
1826
1830
  }
1827
1831
  // prettier-ignore
1828
- set(t, n, s, r, o, i, a, c, u, h, l, d, g, p, w, y) {
1829
- 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 = w | 0, this.Hl = y | 0;
1832
+ set(t, n, s, r, o, i, a, c, u, h, l, f, g, b, w, x) {
1833
+ 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 = f | 0, this.Gh = g | 0, this.Gl = b | 0, this.Hh = w | 0, this.Hl = x | 0;
1830
1834
  }
1831
1835
  process(t, n) {
1832
- for (let b = 0; b < 16; b++, n += 4)
1833
- L[b] = t.getUint32(n), C[b] = t.getUint32(n += 4);
1834
- for (let b = 16; b < 80; b++) {
1835
- const P = L[b - 15] | 0, T = C[b - 15] | 0, v = V(P, T, 1) ^ V(P, T, 8) ^ Ft(P, T, 7), I = K(P, T, 1) ^ K(P, T, 8) ^ Ot(P, T, 7), k = L[b - 2] | 0, E = C[b - 2] | 0, U = V(k, E, 19) ^ J(k, E, 61) ^ Ft(k, E, 6), ot = K(k, E, 19) ^ Y(k, E, 61) ^ Ot(k, E, 6), j = ln(I, ot, C[b - 7], C[b - 16]), it = hn(j, v, U, L[b - 7], L[b - 16]);
1836
- L[b] = it | 0, C[b] = j | 0;
1836
+ for (let p = 0; p < 16; p++, n += 4)
1837
+ _[p] = t.getUint32(n), W[p] = t.getUint32(n += 4);
1838
+ for (let p = 16; p < 80; p++) {
1839
+ const P = _[p - 15] | 0, v = W[p - 15] | 0, T = D(P, v, 1) ^ D(P, v, 8) ^ Ft(P, v, 7), E = M(P, v, 1) ^ M(P, v, 8) ^ Ot(P, v, 7), H = _[p - 2] | 0, I = W[p - 2] | 0, F = D(H, I, 19) ^ Q(H, I, 61) ^ Ft(H, I, 6), K = M(H, I, 19) ^ tt(H, I, 61) ^ Ot(H, I, 6), O = hn(E, K, W[p - 7], W[p - 16]), at = fn(O, T, F, _[p - 7], _[p - 16]);
1840
+ _[p] = at | 0, W[p] = O | 0;
1837
1841
  }
1838
- 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: w, Gl: y, Hh: x, Hl: m } = this;
1839
- for (let b = 0; b < 80; b++) {
1840
- const P = V(l, d, 14) ^ V(l, d, 18) ^ J(l, d, 41), T = K(l, d, 14) ^ K(l, d, 18) ^ Y(l, d, 41), v = l & g ^ ~l & w, I = d & p ^ ~d & y, k = fn(m, T, I, xn[b], C[b]), E = dn(k, x, P, v, yn[b], L[b]), U = k | 0, ot = V(s, r, 28) ^ J(s, r, 34) ^ J(s, r, 39), j = K(s, r, 28) ^ Y(s, r, 34) ^ Y(s, r, 39), it = s & o ^ s & a ^ o & a, ae = r & i ^ r & c ^ i & c;
1841
- x = w | 0, m = y | 0, w = g | 0, y = p | 0, g = l | 0, p = d | 0, { h: l, l: d } = $(u | 0, h | 0, E | 0, U | 0), u = a | 0, h = c | 0, a = o | 0, c = i | 0, o = s | 0, i = r | 0;
1842
- const Pt = cn(U, j, ae);
1843
- s = un(Pt, E, ot, it), r = Pt | 0;
1842
+ let { Ah: s, Al: r, Bh: o, Bl: i, Ch: a, Cl: c, Dh: u, Dl: h, Eh: l, El: f, Fh: g, Fl: b, Gh: w, Gl: x, Hh: y, Hl: m } = this;
1843
+ for (let p = 0; p < 80; p++) {
1844
+ const P = D(l, f, 14) ^ D(l, f, 18) ^ Q(l, f, 41), v = M(l, f, 14) ^ M(l, f, 18) ^ tt(l, f, 41), T = l & g ^ ~l & w, E = f & b ^ ~f & x, H = dn(m, v, E, wn[p], W[p]), I = pn(H, y, P, T, yn[p], _[p]), F = H | 0, K = D(s, r, 28) ^ Q(s, r, 34) ^ Q(s, r, 39), O = M(s, r, 28) ^ tt(s, r, 34) ^ tt(s, r, 39), at = s & o ^ s & a ^ o & a, ae = r & i ^ r & c ^ i & c;
1845
+ y = w | 0, m = x | 0, w = g | 0, x = b | 0, g = l | 0, b = f | 0, { h: l, l: f } = U(u | 0, h | 0, I | 0, F | 0), u = a | 0, h = c | 0, a = o | 0, c = i | 0, o = s | 0, i = r | 0;
1846
+ const Pt = un(F, O, ae);
1847
+ s = ln(Pt, I, K, at), r = Pt | 0;
1844
1848
  }
1845
- ({ 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: w, l: y } = $(this.Gh | 0, this.Gl | 0, w | 0, y | 0), { h: x, l: m } = $(this.Hh | 0, this.Hl | 0, x | 0, m | 0), this.set(s, r, o, i, a, c, u, h, l, d, g, p, w, y, x, m);
1849
+ ({ 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: u, l: h } = U(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: l, l: f } = U(this.Eh | 0, this.El | 0, l | 0, f | 0), { h: g, l: b } = U(this.Fh | 0, this.Fl | 0, g | 0, b | 0), { h: w, l: x } = U(this.Gh | 0, this.Gl | 0, w | 0, x | 0), { h: y, l: m } = U(this.Hh | 0, this.Hl | 0, y | 0, m | 0), this.set(s, r, o, i, a, c, u, h, l, f, g, b, w, x, y, m);
1846
1850
  }
1847
1851
  roundClean() {
1848
- A(L, C);
1852
+ A(_, W);
1849
1853
  }
1850
1854
  destroy() {
1851
1855
  A(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1852
1856
  }
1853
1857
  }
1854
- class mn extends wn {
1858
+ class Pn extends mn {
1855
1859
  constructor() {
1856
1860
  super(64);
1857
- f(this, "Ah", H[0] | 0);
1858
- f(this, "Al", H[1] | 0);
1859
- f(this, "Bh", H[2] | 0);
1860
- f(this, "Bl", H[3] | 0);
1861
- f(this, "Ch", H[4] | 0);
1862
- f(this, "Cl", H[5] | 0);
1863
- f(this, "Dh", H[6] | 0);
1864
- f(this, "Dl", H[7] | 0);
1865
- f(this, "Eh", H[8] | 0);
1866
- f(this, "El", H[9] | 0);
1867
- f(this, "Fh", H[10] | 0);
1868
- f(this, "Fl", H[11] | 0);
1869
- f(this, "Gh", H[12] | 0);
1870
- f(this, "Gl", H[13] | 0);
1871
- f(this, "Hh", H[14] | 0);
1872
- f(this, "Hl", H[15] | 0);
1873
- }
1874
- }
1875
- const Pn = /* @__PURE__ */ rt(
1876
- () => new gn(),
1861
+ d(this, "Ah", k[0] | 0);
1862
+ d(this, "Al", k[1] | 0);
1863
+ d(this, "Bh", k[2] | 0);
1864
+ d(this, "Bl", k[3] | 0);
1865
+ d(this, "Ch", k[4] | 0);
1866
+ d(this, "Cl", k[5] | 0);
1867
+ d(this, "Dh", k[6] | 0);
1868
+ d(this, "Dl", k[7] | 0);
1869
+ d(this, "Eh", k[8] | 0);
1870
+ d(this, "El", k[9] | 0);
1871
+ d(this, "Fh", k[10] | 0);
1872
+ d(this, "Fl", k[11] | 0);
1873
+ d(this, "Gh", k[12] | 0);
1874
+ d(this, "Gl", k[13] | 0);
1875
+ d(this, "Hh", k[14] | 0);
1876
+ d(this, "Hl", k[15] | 0);
1877
+ }
1878
+ }
1879
+ const Tn = /* @__PURE__ */ it(
1880
+ () => new xn(),
1877
1881
  /* @__PURE__ */ Gt(1)
1878
- ), ee = /* @__PURE__ */ rt(
1879
- () => new mn(),
1882
+ ), ee = /* @__PURE__ */ it(
1883
+ () => new Pn(),
1880
1884
  /* @__PURE__ */ Gt(3)
1881
- ), Tn = BigInt(0), N = BigInt(1), vn = BigInt(2), kn = BigInt(7), Hn = BigInt(256), En = BigInt(113), ne = [], se = [], re = [];
1882
- for (let e = 0, t = N, n = 1, s = 0; e < 24; e++) {
1885
+ ), vn = BigInt(0), G = BigInt(1), kn = BigInt(2), Hn = BigInt(7), In = BigInt(256), En = BigInt(113), ne = [], se = [], re = [];
1886
+ for (let e = 0, t = G, n = 1, s = 0; e < 24; e++) {
1883
1887
  [n, s] = [s, (2 * n + 3 * s) % 5], ne.push(2 * (5 * s + n)), se.push((e + 1) * (e + 2) / 2 % 64);
1884
- let r = Tn;
1888
+ let r = vn;
1885
1889
  for (let o = 0; o < 7; o++)
1886
- t = (t << N ^ (t >> kn) * En) % Hn, t & vn && (r ^= N << (N << BigInt(o)) - N);
1890
+ t = (t << G ^ (t >> Hn) * En) % In, t & kn && (r ^= G << (G << BigInt(o)) - G);
1887
1891
  re.push(r);
1888
1892
  }
1889
- const oe = Qt(re, !0), In = oe[0], Sn = oe[1], Lt = (e, t, n) => n > 32 ? on(e, t, n) : sn(e, t, n), Ct = (e, t, n) => n > 32 ? an(e, t, n) : rn(e, t, n);
1890
- function An(e, t = 24) {
1893
+ const oe = Qt(re, !0), Sn = oe[0], An = oe[1], Lt = (e, t, n) => n > 32 ? an(e, t, n) : rn(e, t, n), Ct = (e, t, n) => n > 32 ? cn(e, t, n) : on(e, t, n);
1894
+ function Bn(e, t = 24) {
1891
1895
  const n = new Uint32Array(10);
1892
1896
  for (let s = 24 - t; s < 24; s++) {
1893
1897
  for (let i = 0; i < 10; i++)
1894
1898
  n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
1895
1899
  for (let i = 0; i < 10; i += 2) {
1896
- const a = (i + 8) % 10, c = (i + 2) % 10, u = n[c], h = n[c + 1], l = Lt(u, h, 1) ^ n[a], d = Ct(u, h, 1) ^ n[a + 1];
1900
+ const a = (i + 8) % 10, c = (i + 2) % 10, u = n[c], h = n[c + 1], l = Lt(u, h, 1) ^ n[a], f = Ct(u, h, 1) ^ n[a + 1];
1897
1901
  for (let g = 0; g < 50; g += 10)
1898
- e[i + g] ^= l, e[i + g + 1] ^= d;
1902
+ e[i + g] ^= l, e[i + g + 1] ^= f;
1899
1903
  }
1900
1904
  let r = e[2], o = e[3];
1901
1905
  for (let i = 0; i < 24; i++) {
@@ -1908,36 +1912,36 @@ function An(e, t = 24) {
1908
1912
  for (let a = 0; a < 10; a++)
1909
1913
  e[i + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
1910
1914
  }
1911
- e[0] ^= In[s], e[1] ^= Sn[s];
1915
+ e[0] ^= Sn[s], e[1] ^= An[s];
1912
1916
  }
1913
1917
  A(n);
1914
1918
  }
1915
1919
  class mt {
1916
1920
  // NOTE: we accept arguments in bytes instead of bits here.
1917
1921
  constructor(t, n, s, r = !1, o = 24) {
1918
- f(this, "state");
1919
- f(this, "pos", 0);
1920
- f(this, "posOut", 0);
1921
- f(this, "finished", !1);
1922
- f(this, "state32");
1923
- f(this, "destroyed", !1);
1924
- f(this, "blockLen");
1925
- f(this, "suffix");
1926
- f(this, "outputLen");
1927
- f(this, "enableXOF", !1);
1928
- f(this, "rounds");
1929
- if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = r, this.rounds = o, W(s, "outputLen"), !(0 < t && t < 200))
1922
+ d(this, "state");
1923
+ d(this, "pos", 0);
1924
+ d(this, "posOut", 0);
1925
+ d(this, "finished", !1);
1926
+ d(this, "state32");
1927
+ d(this, "destroyed", !1);
1928
+ d(this, "blockLen");
1929
+ d(this, "suffix");
1930
+ d(this, "outputLen");
1931
+ d(this, "enableXOF", !1);
1932
+ d(this, "rounds");
1933
+ if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = r, this.rounds = o, R(s, "outputLen"), !(0 < t && t < 200))
1930
1934
  throw new Error("only keccak-f1600 function is supported");
1931
- this.state = new Uint8Array(200), this.state32 = Ve(this.state);
1935
+ this.state = new Uint8Array(200), this.state32 = Ke(this.state);
1932
1936
  }
1933
1937
  clone() {
1934
1938
  return this._cloneInto();
1935
1939
  }
1936
1940
  keccak() {
1937
- At(this.state32), An(this.state32, this.rounds), At(this.state32), this.posOut = 0, this.pos = 0;
1941
+ At(this.state32), Bn(this.state32, this.rounds), At(this.state32), this.posOut = 0, this.pos = 0;
1938
1942
  }
1939
1943
  update(t) {
1940
- M(this), R(t);
1944
+ X(this), V(t);
1941
1945
  const { blockLen: n, state: s } = this, r = t.length;
1942
1946
  for (let o = 0; o < r; ) {
1943
1947
  const i = Math.min(n - this.pos, r - o);
@@ -1955,7 +1959,7 @@ class mt {
1955
1959
  t[s] ^= n, (n & 128) !== 0 && s === r - 1 && this.keccak(), t[r - 1] ^= 128, this.keccak();
1956
1960
  }
1957
1961
  writeInto(t) {
1958
- M(this, !1), R(t), this.finish();
1962
+ X(this, !1), V(t), this.finish();
1959
1963
  const n = this.state, { blockLen: s } = this;
1960
1964
  for (let r = 0, o = t.length; r < o; ) {
1961
1965
  this.posOut >= s && this.keccak();
@@ -1970,7 +1974,7 @@ class mt {
1970
1974
  return this.writeInto(t);
1971
1975
  }
1972
1976
  xof(t) {
1973
- return W(t), this.xofInto(new Uint8Array(t));
1977
+ return R(t), this.xofInto(new Uint8Array(t));
1974
1978
  }
1975
1979
  digestInto(t) {
1976
1980
  if (Xt(t, this), this.finished)
@@ -1988,50 +1992,50 @@ class mt {
1988
1992
  return t || (t = new mt(n, s, r, i, o)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = o, t.suffix = s, t.outputLen = r, t.enableXOF = i, t.destroyed = this.destroyed, t;
1989
1993
  }
1990
1994
  }
1991
- const Bn = (e, t, n, s = {}) => rt(() => new mt(t, e, n), s), $n = /* @__PURE__ */ Bn(1, 136, 32);
1992
- function Un(e, t, n, s) {
1995
+ const $n = (e, t, n, s = {}) => it(() => new mt(t, e, n), s), Un = /* @__PURE__ */ $n(1, 136, 32);
1996
+ function Fn(e, t, n, s) {
1993
1997
  Nt(e);
1994
- const r = Xe({ dkLen: 32, asyncTick: 10 }, s), { c: o, dkLen: i, asyncTick: a } = r;
1995
- if (W(o, "c"), W(i, "dkLen"), W(a, "asyncTick"), o < 1)
1998
+ const r = Ge({ dkLen: 32, asyncTick: 10 }, s), { c: o, dkLen: i, asyncTick: a } = r;
1999
+ if (R(o, "c"), R(i, "dkLen"), R(a, "asyncTick"), o < 1)
1996
2000
  throw new Error("iterations (c) must be >= 1");
1997
- const c = Bt(t, "password"), u = Bt(n, "salt"), h = new Uint8Array(i), l = xt.create(e, c), d = l._cloneInto().update(u);
1998
- return { c: o, dkLen: i, asyncTick: a, DK: h, PRF: l, PRFSalt: d };
2001
+ const c = Bt(t, "password"), u = Bt(n, "salt"), h = new Uint8Array(i), l = yt.create(e, c), f = l._cloneInto().update(u);
2002
+ return { c: o, dkLen: i, asyncTick: a, DK: h, PRF: l, PRFSalt: f };
1999
2003
  }
2000
- function Fn(e, t, n, s, r) {
2004
+ function On(e, t, n, s, r) {
2001
2005
  return e.destroy(), t.destroy(), s && s.destroy(), A(r), n;
2002
2006
  }
2003
- function On(e, t, n, s) {
2004
- const { c: r, dkLen: o, DK: i, PRF: a, PRFSalt: c } = Un(e, t, n, s);
2007
+ function Ln(e, t, n, s) {
2008
+ const { c: r, dkLen: o, DK: i, PRF: a, PRFSalt: c } = Fn(e, t, n, s);
2005
2009
  let u;
2006
- const h = new Uint8Array(4), l = nt(h), d = new Uint8Array(a.outputLen);
2007
- for (let g = 1, p = 0; p < o; g++, p += a.outputLen) {
2008
- const w = i.subarray(p, p + a.outputLen);
2009
- l.setInt32(0, g, !1), (u = c._cloneInto(u)).update(h).digestInto(d), w.set(d.subarray(0, w.length));
2010
- for (let y = 1; y < r; y++) {
2011
- a._cloneInto(u).update(d).digestInto(d);
2012
- for (let x = 0; x < w.length; x++)
2013
- w[x] ^= d[x];
2010
+ const h = new Uint8Array(4), l = rt(h), f = new Uint8Array(a.outputLen);
2011
+ for (let g = 1, b = 0; b < o; g++, b += a.outputLen) {
2012
+ const w = i.subarray(b, b + a.outputLen);
2013
+ l.setInt32(0, g, !1), (u = c._cloneInto(u)).update(h).digestInto(f), w.set(f.subarray(0, w.length));
2014
+ for (let x = 1; x < r; x++) {
2015
+ a._cloneInto(u).update(f).digestInto(f);
2016
+ for (let y = 0; y < w.length; y++)
2017
+ w[y] ^= f[y];
2014
2018
  }
2015
2019
  }
2016
- return Fn(a, c, i, u, d);
2020
+ return On(a, c, i, u, f);
2017
2021
  }
2018
2022
  function ie(e) {
2019
2023
  if (typeof e != "string")
2020
2024
  throw new TypeError("invalid mnemonic type: " + typeof e);
2021
2025
  return e.normalize("NFKD");
2022
2026
  }
2023
- function Ln(e) {
2027
+ function Cn(e) {
2024
2028
  const t = ie(e), n = t.split(" ");
2025
2029
  if (![12, 15, 18, 21, 24].includes(n.length))
2026
2030
  throw new Error("Invalid mnemonic");
2027
2031
  return { nfkd: t, words: n };
2028
2032
  }
2029
- const Cn = (e) => ie("mnemonic" + e);
2030
- function _n(e, t = "") {
2031
- return On(ee, Ln(e).nfkd, Cn(t), { c: 2048, dkLen: 64 });
2033
+ const _n = (e) => ie("mnemonic" + e);
2034
+ function Wn(e, t = "") {
2035
+ return Ln(ee, Cn(e).nfkd, _n(t), { c: 2048, dkLen: 64 });
2032
2036
  }
2033
- const Wn = 508, _t = 16, Q = 32, tt = 64, Wt = 5, Rn = 4;
2034
- function X(...e) {
2037
+ const Rn = 508, _t = 16, et = 32, nt = 64, Wt = 5, Vn = 4;
2038
+ function j(...e) {
2035
2039
  const t = e.reduce((r, o) => r + o.length, 0), n = new Uint8Array(t);
2036
2040
  let s = 0;
2037
2041
  for (const r of e)
@@ -2042,59 +2046,59 @@ function lt(e) {
2042
2046
  return new TextEncoder().encode(e);
2043
2047
  }
2044
2048
  function ht(e) {
2045
- const t = new Uint8Array(Rn);
2046
- return new DataView(t.buffer).setUint32(0, e.length, !1), X(t, e);
2049
+ const t = new Uint8Array(Vn);
2050
+ return new DataView(t.buffer).setUint32(0, e.length, !1), j(t, e);
2047
2051
  }
2048
2052
  function ft(e, t) {
2049
- return xt(ee, e, t);
2053
+ return yt(ee, e, t);
2050
2054
  }
2051
2055
  function Rt(e) {
2052
- return en(Pn(e));
2056
+ return nn(Tn(e));
2053
2057
  }
2054
2058
  const gt = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
2055
- function Vn(e) {
2056
- const t = _n(e), n = new Uint8Array(t);
2059
+ function Kn(e) {
2060
+ const t = Wn(e), n = new Uint8Array(t);
2057
2061
  return t.fill(0), n;
2058
2062
  }
2059
- async function Kn(e, t, n, s) {
2060
- if (e.length !== tt)
2063
+ async function Dn(e, t, n, s) {
2064
+ if (e.length !== nt)
2061
2065
  throw new Error(
2062
- `WOTS seed must be ${tt} bytes, got ${e.length}`
2066
+ `WOTS seed must be ${nt} bytes, got ${e.length}`
2063
2067
  );
2064
- t = _(t), n = _(n);
2065
- const r = e.slice(Q, tt), o = e.slice(0, Q), i = [r, o];
2068
+ t = $(t), n = $(n);
2069
+ const r = e.slice(et, nt), o = e.slice(0, et), i = [r, o];
2066
2070
  try {
2067
- const a = X(
2071
+ const a = j(
2068
2072
  ht(lt(t)),
2069
2073
  ht(lt(n)),
2070
2074
  ht(lt(s))
2071
- ), c = X(o, a);
2075
+ ), c = j(o, a);
2072
2076
  i.push(c);
2073
2077
  const u = ft(r, c);
2074
2078
  i.push(u);
2075
- const h = u.slice(0, Q), l = u.slice(Q, tt);
2079
+ const h = u.slice(0, et), l = u.slice(et, nt);
2076
2080
  i.push(h, l);
2077
- const d = [], g = [], p = [], w = [];
2078
- let y = !1;
2081
+ const f = [], g = [], b = [], w = [];
2082
+ let x = !1;
2079
2083
  try {
2080
- for (let x = 0; x < Wn; x++) {
2084
+ for (let y = 0; y < Rn; y++) {
2081
2085
  const m = new Uint8Array(Wt);
2082
- m[0] = 0, new DataView(m.buffer).setUint32(1, x, !1);
2083
- const b = new Uint8Array(Wt);
2084
- b[0] = 1, new DataView(b.buffer).setUint32(1, x, !1);
2085
- const P = X(h, m), T = X(h, b), v = ft(l, P), I = ft(l, T);
2086
+ m[0] = 0, new DataView(m.buffer).setUint32(1, y, !1);
2087
+ const p = new Uint8Array(Wt);
2088
+ p[0] = 1, new DataView(p.buffer).setUint32(1, y, !1);
2089
+ const P = j(h, m), v = j(h, p), T = ft(l, P), E = ft(l, v);
2086
2090
  try {
2087
- const k = v.slice(0, _t), E = I.slice(0, _t);
2088
- d.push(k), g.push(E), p.push(Rt(k)), w.push(Rt(E));
2091
+ const H = T.slice(0, _t), I = E.slice(0, _t);
2092
+ f.push(H), g.push(I), b.push(Rt(H)), w.push(Rt(I));
2089
2093
  } finally {
2090
- P.fill(0), T.fill(0), v.fill(0), I.fill(0);
2094
+ P.fill(0), v.fill(0), T.fill(0), E.fill(0);
2091
2095
  }
2092
2096
  }
2093
- return y = !0, { falsePreimages: d, truePreimages: g, falseHashes: p, trueHashes: w };
2097
+ return x = !0, { falsePreimages: f, truePreimages: g, falseHashes: b, trueHashes: w };
2094
2098
  } finally {
2095
- if (!y) {
2096
- for (const x of d) x.fill(0);
2097
- for (const x of g) x.fill(0);
2099
+ if (!x) {
2100
+ for (const y of f) y.fill(0);
2101
+ for (const y of g) y.fill(0);
2098
2102
  }
2099
2103
  }
2100
2104
  } finally {
@@ -2102,13 +2106,13 @@ async function Kn(e, t, n, s) {
2102
2106
  a.fill(0);
2103
2107
  }
2104
2108
  }
2105
- function cs(e) {
2109
+ function us(e) {
2106
2110
  return {
2107
2111
  false_list: e.falseHashes.map(gt),
2108
2112
  true_list: e.trueHashes.map(gt)
2109
2113
  };
2110
2114
  }
2111
- function Dn(e) {
2115
+ function Mn(e) {
2112
2116
  if (e.falseHashes.length === 0 || e.trueHashes.length === 0)
2113
2117
  throw new Error(
2114
2118
  "computeWotsPkHash: keypair hash arrays must not be empty"
@@ -2119,20 +2123,20 @@ function Dn(e) {
2119
2123
  s.set(i, r), r += t;
2120
2124
  for (const i of e.trueHashes)
2121
2125
  s.set(i, r), r += t;
2122
- const o = $n(s);
2126
+ const o = Un(s);
2123
2127
  return `0x${gt(o)}`;
2124
2128
  }
2125
- async function us(e, t, n, s) {
2126
- const r = Vn(e);
2129
+ async function ls(e, t, n, s) {
2130
+ const r = Kn(e);
2127
2131
  try {
2128
- const o = await Kn(
2132
+ const o = await Dn(
2129
2133
  r,
2130
2134
  t,
2131
2135
  n,
2132
2136
  s
2133
2137
  );
2134
2138
  try {
2135
- return Dn(o);
2139
+ return Mn(o);
2136
2140
  } finally {
2137
2141
  for (const i of o.falsePreimages) i.fill(0);
2138
2142
  for (const i of o.truePreimages) i.fill(0);
@@ -2141,43 +2145,43 @@ async function us(e, t, n, s) {
2141
2145
  r.fill(0);
2142
2146
  }
2143
2147
  }
2144
- function ls(e) {
2148
+ function hs(e) {
2145
2149
  const t = (e instanceof Error ? e.message : typeof e == "string" ? e : "").toLowerCase();
2146
2150
  return t.includes("wots") && t.includes("hash") && t.includes("does not match");
2147
2151
  }
2148
2152
  export {
2149
- Dn as A,
2150
- et as B,
2151
- D as C,
2152
- us as D,
2153
- ls as E,
2154
- Fe as M,
2155
- is as P,
2156
- zn as a,
2157
- Jn as b,
2153
+ Mn as A,
2154
+ st as B,
2155
+ N as C,
2156
+ ls as D,
2157
+ hs as E,
2158
+ Oe as M,
2159
+ as as P,
2160
+ Zn as a,
2161
+ Yn as b,
2158
2162
  St as c,
2159
- Yn as d,
2160
- Ae as e,
2161
- Be as f,
2162
- Zn as g,
2163
+ Qn as d,
2164
+ Be as e,
2165
+ $e as f,
2166
+ Jn as g,
2163
2167
  bt as h,
2164
- as as i,
2165
- ns as j,
2166
- ts as k,
2167
- es as l,
2168
- ss as m,
2169
- Qn as n,
2170
- Le as o,
2171
- Ce as p,
2172
- Oe as q,
2168
+ cs as i,
2169
+ ss as j,
2170
+ es as k,
2171
+ ns as l,
2172
+ rs as m,
2173
+ ts as n,
2174
+ Ce as o,
2175
+ _e as p,
2176
+ Le as q,
2173
2177
  ct as r,
2174
- Se as s,
2175
- yt as t,
2176
- rs as u,
2177
- os as v,
2178
+ Ae as s,
2179
+ xt as t,
2180
+ os as u,
2181
+ is as v,
2178
2182
  ut as w,
2179
- Vn as x,
2180
- Kn as y,
2181
- cs as z
2183
+ Kn as x,
2184
+ Dn as y,
2185
+ us as z
2182
2186
  };
2183
- //# sourceMappingURL=errors-Ci-2cgfS.js.map
2187
+ //# sourceMappingURL=errors-D19BQSaj.js.map