@btc-vision/transaction 1.8.7-beta.0 → 1.8.8

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 (36) hide show
  1. package/browser/btc-vision-bitcoin.js +832 -828
  2. package/browser/index.js +1074 -947
  3. package/browser/noble-curves.js +1183 -2156
  4. package/browser/noble-hashes.js +88 -88
  5. package/browser/rolldown-runtime.js +26 -19
  6. package/browser/src/epoch/validator/EpochValidator.d.ts +28 -6
  7. package/browser/src/transaction/builders/TransactionBuilder.d.ts +1 -0
  8. package/browser/src/transaction/offline/OfflineTransactionManager.d.ts +50 -0
  9. package/browser/src/transaction/offline/interfaces/ISerializableState.d.ts +10 -2
  10. package/browser/vendors.js +3267 -3229
  11. package/build/epoch/validator/EpochValidator.d.ts +28 -6
  12. package/build/epoch/validator/EpochValidator.js +44 -10
  13. package/build/transaction/TransactionFactory.js +1 -1
  14. package/build/transaction/builders/FundingTransaction.js +17 -13
  15. package/build/transaction/builders/TransactionBuilder.d.ts +1 -0
  16. package/build/transaction/builders/TransactionBuilder.js +32 -7
  17. package/build/transaction/offline/OfflineTransactionManager.d.ts +50 -0
  18. package/build/transaction/offline/OfflineTransactionManager.js +142 -1
  19. package/build/transaction/offline/TransactionSerializer.js +9 -0
  20. package/build/transaction/offline/interfaces/ISerializableState.d.ts +10 -2
  21. package/build/transaction/offline/interfaces/ISerializableState.js +3 -2
  22. package/build/transaction/shared/TweakedTransaction.js +27 -5
  23. package/package.json +1 -1
  24. package/src/epoch/validator/EpochValidator.ts +67 -6
  25. package/src/transaction/TransactionFactory.ts +1 -1
  26. package/src/transaction/builders/FundingTransaction.ts +21 -16
  27. package/src/transaction/builders/TransactionBuilder.ts +46 -10
  28. package/src/transaction/offline/OfflineTransactionManager.ts +191 -1
  29. package/src/transaction/offline/TransactionSerializer.ts +11 -0
  30. package/src/transaction/offline/interfaces/ISerializableState.ts +10 -2
  31. package/src/transaction/shared/TweakedTransaction.ts +33 -5
  32. package/test/add-refund-output.test.ts +96 -11
  33. package/test/csv-multisig-offline-edges.test.ts +293 -0
  34. package/test/csv-multisig-offline.test.ts +202 -0
  35. package/test/transaction-builders.test.ts +69 -3
  36. package/tsconfig.build.tsbuildinfo +1 -1
@@ -156,10 +156,10 @@ var kt = {
156
156
  scriptHash: 196,
157
157
  wif: 239
158
158
  }
159
- }, Symbol.toStringTag, { value: "Module" })), ye = {}, vi;
159
+ }, Symbol.toStringTag, { value: "Module" })), ye = {}, mi;
160
160
  function Ia() {
161
- if (vi) return ye;
162
- vi = 1, Object.defineProperty(ye, "__esModule", { value: !0 }), ye.bech32m = ye.bech32 = void 0;
161
+ if (mi) return ye;
162
+ mi = 1, Object.defineProperty(ye, "__esModule", { value: !0 }), ye.bech32m = ye.bech32 = void 0;
163
163
  const e = "qpzry9x8gf2tvdw0s3jn54khce6mua7l", t = {};
164
164
  for (let p = 0; p < 32; p++) {
165
165
  const u = e.charAt(p);
@@ -184,13 +184,13 @@ function Ia() {
184
184
  return u;
185
185
  }
186
186
  function i(p, u, d, w) {
187
- let b = 0, m = 0;
187
+ let y = 0, m = 0;
188
188
  const v = (1 << d) - 1, I = [];
189
- for (let P = 0; P < p.length; ++P) for (b = b << u | p[P], m += u; m >= d; ) m -= d, I.push(b >> m & v);
190
- if (w) m > 0 && I.push(b << d - m & v);
189
+ for (let P = 0; P < p.length; ++P) for (y = y << u | p[P], m += u; m >= d; ) m -= d, I.push(y >> m & v);
190
+ if (w) m > 0 && I.push(y << d - m & v);
191
191
  else {
192
192
  if (m >= u) return "Excess padding";
193
- if (b << d - m & v) return "Non-zero padding";
193
+ if (y << d - m & v) return "Non-zero padding";
194
194
  }
195
195
  return I;
196
196
  }
@@ -239,20 +239,20 @@ function Ia() {
239
239
  if (_ === 0) return "Missing prefix for " + v;
240
240
  const O = v.slice(0, _), z = v.slice(_ + 1);
241
241
  if (z.length < 6) return "Data too short";
242
- let D = n(O);
243
- if (typeof D == "string") return D;
244
- const X = [];
245
- for (let at = 0; at < z.length; ++at) {
246
- const q = z.charAt(at), Vt = t[q];
242
+ let M = n(O);
243
+ if (typeof M == "string") return M;
244
+ const Z = [];
245
+ for (let Q = 0; Q < z.length; ++Q) {
246
+ const q = z.charAt(Q), Vt = t[q];
247
247
  if (Vt === void 0) return "Unknown character " + q;
248
- D = r(D) ^ Vt, !(at + 6 >= z.length) && X.push(Vt);
248
+ M = r(M) ^ Vt, !(Q + 6 >= z.length) && Z.push(Vt);
249
249
  }
250
- return D !== u ? "Invalid checksum for " + v : {
250
+ return M !== u ? "Invalid checksum for " + v : {
251
251
  prefix: O,
252
- words: X
252
+ words: Z
253
253
  };
254
254
  }
255
- function b(v, I) {
255
+ function y(v, I) {
256
256
  const P = w(v, I);
257
257
  if (typeof P == "object") return P;
258
258
  }
@@ -262,7 +262,7 @@ function Ia() {
262
262
  throw new Error(P);
263
263
  }
264
264
  return {
265
- decodeUnsafe: b,
265
+ decodeUnsafe: y,
266
266
  decode: m,
267
267
  encode: d,
268
268
  toWords: o,
@@ -272,27 +272,27 @@ function Ia() {
272
272
  }
273
273
  return ye.bech32 = l("bech32"), ye.bech32m = l("bech32m"), ye;
274
274
  }
275
- var tt = Ia();
275
+ var et = Ia();
276
276
  function cr(e) {
277
277
  let t, r;
278
278
  try {
279
- t = tt.bech32.decode(e);
279
+ t = et.bech32.decode(e);
280
280
  } catch {
281
281
  }
282
282
  if (t) {
283
283
  if (r = t.words[0], r !== 0) throw new TypeError(e + " uses wrong encoding");
284
- } else if (t = tt.bech32m.decode(e), r = t.words[0], r === 0) throw new TypeError(e + " uses wrong encoding");
285
- const n = tt.bech32.fromWords(t.words.slice(1));
284
+ } else if (t = et.bech32m.decode(e), r = t.words[0], r === 0) throw new TypeError(e + " uses wrong encoding");
285
+ const n = et.bech32.fromWords(t.words.slice(1));
286
286
  return {
287
287
  version: r,
288
288
  prefix: t.prefix,
289
289
  data: new Uint8Array(n)
290
290
  };
291
291
  }
292
- var Ts = "0123456789abcdefABCDEF";
293
- Ts.split("").map((e) => e.codePointAt(0));
292
+ var Ss = "0123456789abcdefABCDEF";
293
+ Ss.split("").map((e) => e.codePointAt(0));
294
294
  Array(256).fill(!0).map((e, t) => {
295
- const r = String.fromCodePoint(t), n = Ts.indexOf(r);
295
+ const r = String.fromCodePoint(t), n = Ss.indexOf(r);
296
296
  return n < 0 ? void 0 : n < 16 ? n : n - 6;
297
297
  });
298
298
  new TextEncoder();
@@ -348,11 +348,11 @@ var Pa = (e) => {
348
348
  function xa(e) {
349
349
  if (e < 0 || e > Number.MAX_SAFE_INTEGER || e % 1 !== 0) throw new RangeError("value out of range");
350
350
  }
351
- function ks(e) {
351
+ function Ts(e) {
352
352
  typeof e == "number" ? xa(e) : Pa(e);
353
353
  }
354
354
  function ge(e, t, r) {
355
- ks(e), r === void 0 && (r = 0), t === void 0 && (t = new Uint8Array(Ct(e)));
355
+ Ts(e), r === void 0 && (r = 0), t === void 0 && (t = new Uint8Array(Ct(e)));
356
356
  let n = 0;
357
357
  return e < 253 ? (t.set([Number(e)], r), n = 1) : e <= 65535 ? (t.set([253], r), Aa(t, r + 1, Number(e), "LE"), n = 3) : e <= 4294967295 ? (t.set([254], r), Sa(t, r + 1, Number(e), "LE"), n = 5) : (t.set([255], r), Ta(t, r + 1, BigInt(e), "LE"), n = 9), {
358
358
  buffer: t,
@@ -392,14 +392,14 @@ function We(e, t) {
392
392
  }
393
393
  }
394
394
  function Ct(e) {
395
- return ks(e), e < 253 ? 1 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
395
+ return Ts(e), e < 253 ? 1 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
396
396
  }
397
397
  var Kl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
398
398
  __proto__: null,
399
399
  decode: We,
400
400
  encode: ge,
401
401
  encodingLength: Ct
402
- }, Symbol.toStringTag, { value: "Module" })), Ba = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), Ii = (() => {
402
+ }, Symbol.toStringTag, { value: "Module" })), Ba = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), Ei = (() => {
403
403
  const e = new Array(128).fill(-1);
404
404
  for (let t = 0; t < 10; t++) e[48 + t] = t;
405
405
  for (let t = 0; t < 6; t++) e[65 + t] = 10 + t, e[97 + t] = 10 + t;
@@ -421,14 +421,14 @@ function Mt(e) {
421
421
  for (let i = 0; i < r; i++) {
422
422
  const o = i * 2, a = e.charCodeAt(o), f = e.charCodeAt(o + 1);
423
423
  if (a >= 128 || f >= 128) throw new TypeError(`Invalid hex character at position ${o}`);
424
- const l = Ii[a], p = Ii[f];
424
+ const l = Ei[a], p = Ei[f];
425
425
  if (l === -1) throw new TypeError(`Invalid hex character at position ${o}`);
426
426
  if (p === -1) throw new TypeError(`Invalid hex character at position ${o + 1}`);
427
427
  n[i] = l << 4 | p;
428
428
  }
429
429
  return n;
430
430
  }
431
- var _a = class Us {
431
+ var _a = class ks {
432
432
  #t;
433
433
  #a;
434
434
  #e;
@@ -452,7 +452,7 @@ var _a = class Us {
452
452
  return this.#t;
453
453
  }
454
454
  static fromHex(t) {
455
- return new Us(Mt(t));
455
+ return new ks(Mt(t));
456
456
  }
457
457
  readUInt8() {
458
458
  if (this.#e >= this.#t.length) throw new RangeError("Read past end of buffer");
@@ -697,7 +697,7 @@ var _a = class Us {
697
697
  function Na(e) {
698
698
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
699
699
  }
700
- function Os(e, t, r = "") {
700
+ function Us(e, t, r = "") {
701
701
  const n = Na(e), i = e?.length;
702
702
  if (!n || t !== void 0) {
703
703
  const o = r && `"${r}" `, a = n ? `length=${i}` : `type=${typeof e}`;
@@ -705,12 +705,12 @@ function Os(e, t, r = "") {
705
705
  }
706
706
  return e;
707
707
  }
708
- function Ai(e, t = !0) {
708
+ function vi(e, t = !0) {
709
709
  if (e.destroyed) throw new Error("Hash instance has been destroyed");
710
710
  if (t && e.finished) throw new Error("Hash#digest() has already been called");
711
711
  }
712
712
  function Ha(e, t) {
713
- Os(e, void 0, "digestInto() output");
713
+ Us(e, void 0, "digestInto() output");
714
714
  const r = t.outputLen;
715
715
  if (e.length < r) throw new Error('"digestInto() output" expected to be of length >=' + r);
716
716
  }
@@ -726,7 +726,7 @@ function Wt(e, t) {
726
726
  function Ee(e, t) {
727
727
  return e << t | e >>> 32 - t >>> 0;
728
728
  }
729
- function Wn(e, t = {}) {
729
+ function Fn(e, t = {}) {
730
730
  const r = (i, o) => e(o).update(i).digest(), n = e(void 0);
731
731
  return r.outputLen = n.outputLen, r.blockLen = n.blockLen, r.create = (i) => e(i), Object.assign(r, t), Object.freeze(r);
732
732
  }
@@ -743,13 +743,13 @@ var La = (e) => ({ oid: Uint8Array.from([
743
743
  2,
744
744
  e
745
745
  ]) });
746
- function Ps(e, t, r) {
746
+ function Os(e, t, r) {
747
747
  return e & t ^ ~e & r;
748
748
  }
749
- function xs(e, t, r) {
749
+ function Ps(e, t, r) {
750
750
  return e & t ^ e & r ^ t & r;
751
751
  }
752
- var Gn = class {
752
+ var Wn = class {
753
753
  blockLen;
754
754
  outputLen;
755
755
  padOffset;
@@ -764,7 +764,7 @@ var Gn = class {
764
764
  this.blockLen = e, this.outputLen = t, this.padOffset = r, this.isLE = n, this.buffer = new Uint8Array(e), this.view = fn(this.buffer);
765
765
  }
766
766
  update(e) {
767
- Ai(this), Os(e);
767
+ vi(this), Us(e);
768
768
  const { view: t, buffer: r, blockLen: n } = this, i = e.length;
769
769
  for (let o = 0; o < i; ) {
770
770
  const a = Math.min(n - this.pos, i - o);
@@ -778,7 +778,7 @@ var Gn = class {
778
778
  return this.length += e.length, this.roundClean(), this;
779
779
  }
780
780
  digestInto(e) {
781
- Ai(this), Ha(e, this), this.finished = !0;
781
+ vi(this), Ha(e, this), this.finished = !0;
782
782
  const { buffer: t, view: r, blockLen: n, isLE: i } = this;
783
783
  let { pos: o } = this;
784
784
  t[o++] = 128, Te(this.buffer.subarray(o)), this.padOffset > n - o && (this.process(r, 0), o = 0);
@@ -878,7 +878,7 @@ var Gn = class {
878
878
  2756734187,
879
879
  3204031479,
880
880
  3329325298
881
- ]), oe = /* @__PURE__ */ new Uint32Array(64), Va = class extends Gn {
881
+ ]), oe = /* @__PURE__ */ new Uint32Array(64), Va = class extends Wn {
882
882
  constructor(e) {
883
883
  super(64, e, 8, !1);
884
884
  }
@@ -901,13 +901,13 @@ var Gn = class {
901
901
  process(e, t) {
902
902
  for (let u = 0; u < 16; u++, t += 4) oe[u] = e.getUint32(t, !1);
903
903
  for (let u = 16; u < 64; u++) {
904
- const d = oe[u - 15], w = oe[u - 2], b = Wt(d, 7) ^ Wt(d, 18) ^ d >>> 3;
905
- oe[u] = (Wt(w, 17) ^ Wt(w, 19) ^ w >>> 10) + oe[u - 7] + b + oe[u - 16] | 0;
904
+ const d = oe[u - 15], w = oe[u - 2], y = Wt(d, 7) ^ Wt(d, 18) ^ d >>> 3, m = Wt(w, 17) ^ Wt(w, 19) ^ w >>> 10;
905
+ oe[u] = m + oe[u - 7] + y + oe[u - 16] | 0;
906
906
  }
907
907
  let { A: r, B: n, C: i, D: o, E: a, F: f, G: l, H: p } = this;
908
908
  for (let u = 0; u < 64; u++) {
909
- const d = Wt(a, 6) ^ Wt(a, 11) ^ Wt(a, 25), w = p + d + Ps(a, f, l) + Ca[u] + oe[u] | 0, b = (Wt(r, 2) ^ Wt(r, 13) ^ Wt(r, 22)) + xs(r, n, i) | 0;
910
- p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w + b | 0;
909
+ const d = Wt(a, 6) ^ Wt(a, 11) ^ Wt(a, 25), w = p + d + Os(a, f, l) + Ca[u] + oe[u] | 0, y = (Wt(r, 2) ^ Wt(r, 13) ^ Wt(r, 22)) + Ps(r, n, i) | 0;
910
+ p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w + y | 0;
911
911
  }
912
912
  r = r + this.A | 0, n = n + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, p = p + this.H | 0, this.set(r, n, i, o, a, f, l, p);
913
913
  }
@@ -929,10 +929,10 @@ var Gn = class {
929
929
  constructor() {
930
930
  super(32);
931
931
  }
932
- }, Ke = /* @__PURE__ */ Wn(() => new $a(), /* @__PURE__ */ La(1));
932
+ }, Ke = /* @__PURE__ */ Fn(() => new $a(), /* @__PURE__ */ La(1));
933
933
  function Ka(e) {
934
934
  if (e.length >= 255) throw new TypeError("Alphabet too long");
935
- const t = new Uint8Array(256);
935
+ const t = /* @__PURE__ */ new Uint8Array(256);
936
936
  for (let p = 0; p < t.length; p++) t[p] = 255;
937
937
  for (let p = 0; p < e.length; p++) {
938
938
  const u = e.charAt(p), d = u.charCodeAt(0);
@@ -944,10 +944,10 @@ function Ka(e) {
944
944
  if (p instanceof Uint8Array || (ArrayBuffer.isView(p) ? p = new Uint8Array(p.buffer, p.byteOffset, p.byteLength) : Array.isArray(p) && (p = Uint8Array.from(p))), !(p instanceof Uint8Array)) throw new TypeError("Expected Uint8Array");
945
945
  if (p.length === 0) return "";
946
946
  let u = 0, d = 0, w = 0;
947
- const b = p.length;
948
- for (; w !== b && p[w] === 0; ) w++, u++;
949
- const m = (b - w) * o + 1 >>> 0, v = new Uint8Array(m);
950
- for (; w !== b; ) {
947
+ const y = p.length;
948
+ for (; w !== y && p[w] === 0; ) w++, u++;
949
+ const m = (y - w) * o + 1 >>> 0, v = new Uint8Array(m);
950
+ for (; w !== y; ) {
951
951
  let S = p[w], _ = 0;
952
952
  for (let O = m - 1; (S !== 0 || _ < d) && O !== -1; O--, _++) S += 256 * v[O] >>> 0, v[O] = S % r >>> 0, S = S / r >>> 0;
953
953
  if (S !== 0) throw new Error("Non-zero carry");
@@ -961,25 +961,25 @@ function Ka(e) {
961
961
  }
962
962
  function f(p) {
963
963
  if (typeof p != "string") throw new TypeError("Expected String");
964
- if (p.length === 0) return new Uint8Array();
964
+ if (p.length === 0) return /* @__PURE__ */ new Uint8Array();
965
965
  let u = 0, d = 0, w = 0;
966
966
  for (; p[u] === n; ) d++, u++;
967
- const b = (p.length - u) * i + 1 >>> 0, m = new Uint8Array(b);
967
+ const y = (p.length - u) * i + 1 >>> 0, m = new Uint8Array(y);
968
968
  for (; u < p.length; ) {
969
969
  const S = p.charCodeAt(u);
970
970
  if (S > 255) return;
971
971
  let _ = t[S];
972
972
  if (_ === 255) return;
973
973
  let O = 0;
974
- for (let z = b - 1; (_ !== 0 || O < w) && z !== -1; z--, O++) _ += r * m[z] >>> 0, m[z] = _ % 256 >>> 0, _ = _ / 256 >>> 0;
974
+ for (let z = y - 1; (_ !== 0 || O < w) && z !== -1; z--, O++) _ += r * m[z] >>> 0, m[z] = _ % 256 >>> 0, _ = _ / 256 >>> 0;
975
975
  if (_ !== 0) throw new Error("Non-zero carry");
976
976
  w = O, u++;
977
977
  }
978
- let v = b - w;
979
- for (; v !== b && m[v] === 0; ) v++;
980
- const I = new Uint8Array(d + (b - v));
978
+ let v = y - w;
979
+ for (; v !== y && m[v] === 0; ) v++;
980
+ const I = new Uint8Array(d + (y - v));
981
981
  let P = d;
982
- for (; v !== b; ) I[P++] = m[v++];
982
+ for (; v !== y; ) I[P++] = m[v++];
983
983
  return I;
984
984
  }
985
985
  function l(p) {
@@ -1021,7 +1021,7 @@ function Da(e) {
1021
1021
  function Ma(e) {
1022
1022
  return Ke(Ke(e));
1023
1023
  }
1024
- var { encode: jn, decode: zn } = Da(Ma);
1024
+ var { encode: Gn, decode: jn } = Da(Ma);
1025
1025
  function Bt(e) {
1026
1026
  let t = 0;
1027
1027
  for (const i of e) t += i.length;
@@ -1047,11 +1047,11 @@ function Un(e) {
1047
1047
  for (let t = 0; t < e.length; t++) if (e[t] !== 0) return !1;
1048
1048
  return !0;
1049
1049
  }
1050
- function Si(e) {
1050
+ function Ii(e) {
1051
1051
  const t = new Uint8Array(e.length);
1052
1052
  return t.set(e), t;
1053
1053
  }
1054
- function qn(e) {
1054
+ function zn(e) {
1055
1055
  return e.reverse(), e;
1056
1056
  }
1057
1057
  function Et(e, t = 0) {
@@ -1224,7 +1224,7 @@ var j = {
1224
1224
  OP_PUBKEY: 254,
1225
1225
  OP_INVALIDOPCODE: 255
1226
1226
  }, mr;
1227
- function Bs() {
1227
+ function xs() {
1228
1228
  if (!mr) {
1229
1229
  mr = {};
1230
1230
  for (const e of Object.keys(j)) {
@@ -1234,12 +1234,12 @@ function Bs() {
1234
1234
  }
1235
1235
  return mr;
1236
1236
  }
1237
- Bs();
1238
- function _s(e) {
1237
+ xs();
1238
+ function Bs(e) {
1239
1239
  return e < j.OP_PUSHDATA1 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : 5;
1240
1240
  }
1241
1241
  function ja(e, t, r) {
1242
- const n = _s(t), i = new DataView(e.buffer, e.byteOffset, e.byteLength);
1242
+ const n = Bs(t), i = new DataView(e.buffer, e.byteOffset, e.byteLength);
1243
1243
  return n === 1 ? e[r] = t : n === 2 ? (e[r] = j.OP_PUSHDATA1, e[r + 1] = t) : n === 3 ? (e[r] = j.OP_PUSHDATA2, i.setUint16(r + 1, t, !0)) : (e[r] = j.OP_PUSHDATA4, i.setUint32(r + 1, t, !0)), n;
1244
1244
  }
1245
1245
  function za(e, t) {
@@ -1263,7 +1263,7 @@ function za(e, t) {
1263
1263
  size: o
1264
1264
  };
1265
1265
  }
1266
- var Rs = {}, Zr = {};
1266
+ var _s = {}, Zr = {};
1267
1267
  Zr.byteLength = Xa;
1268
1268
  Zr.toByteArray = Qa;
1269
1269
  Zr.fromByteArray = eh;
@@ -1271,7 +1271,7 @@ var zt = [], Ht = [], qa = typeof Uint8Array < "u" ? Uint8Array : Array, ln = "A
1271
1271
  for (var Re = 0, Ya = ln.length; Re < Ya; ++Re) zt[Re] = ln[Re], Ht[ln.charCodeAt(Re)] = Re;
1272
1272
  Ht[45] = 62;
1273
1273
  Ht[95] = 63;
1274
- function Ns(e) {
1274
+ function Rs(e) {
1275
1275
  var t = e.length;
1276
1276
  if (t % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
1277
1277
  var r = e.indexOf("=");
@@ -1280,14 +1280,14 @@ function Ns(e) {
1280
1280
  return [r, n];
1281
1281
  }
1282
1282
  function Xa(e) {
1283
- var t = Ns(e), r = t[0], n = t[1];
1283
+ var t = Rs(e), r = t[0], n = t[1];
1284
1284
  return (r + n) * 3 / 4 - n;
1285
1285
  }
1286
1286
  function Za(e, t, r) {
1287
1287
  return (t + r) * 3 / 4 - r;
1288
1288
  }
1289
1289
  function Qa(e) {
1290
- var t, r = Ns(e), n = r[0], i = r[1], o = new qa(Za(e, n, i)), a = 0, f = i > 0 ? n - 4 : n, l;
1290
+ var t, r = Rs(e), n = r[0], i = r[1], o = new qa(Za(e, n, i)), a = 0, f = i > 0 ? n - 4 : n, l;
1291
1291
  for (l = 0; l < f; l += 4) t = Ht[e.charCodeAt(l)] << 18 | Ht[e.charCodeAt(l + 1)] << 12 | Ht[e.charCodeAt(l + 2)] << 6 | Ht[e.charCodeAt(l + 3)], o[a++] = t >> 16 & 255, o[a++] = t >> 8 & 255, o[a++] = t & 255;
1292
1292
  return i === 2 && (t = Ht[e.charCodeAt(l)] << 2 | Ht[e.charCodeAt(l + 1)] >> 4, o[a++] = t & 255), i === 1 && (t = Ht[e.charCodeAt(l)] << 10 | Ht[e.charCodeAt(l + 1)] << 4 | Ht[e.charCodeAt(l + 2)] >> 2, o[a++] = t >> 8 & 255, o[a++] = t & 255), o;
1293
1293
  }
@@ -1302,26 +1302,26 @@ function eh(e) {
1302
1302
  for (var t, r = e.length, n = r % 3, i = [], o = 16383, a = 0, f = r - n; a < f; a += o) i.push(th(e, a, a + o > f ? f : a + o));
1303
1303
  return n === 1 ? (t = e[r - 1], i.push(zt[t >> 2] + zt[t << 4 & 63] + "==")) : n === 2 && (t = (e[r - 2] << 8) + e[r - 1], i.push(zt[t >> 10] + zt[t >> 4 & 63] + zt[t << 2 & 63] + "=")), i.join("");
1304
1304
  }
1305
- var Yn = {};
1306
- Yn.read = function(e, t, r, n, i) {
1307
- var o, a, f = i * 8 - n - 1, l = (1 << f) - 1, p = l >> 1, u = -7, d = r ? i - 1 : 0, w = r ? -1 : 1, b = e[t + d];
1308
- for (d += w, o = b & (1 << -u) - 1, b >>= -u, u += f; u > 0; o = o * 256 + e[t + d], d += w, u -= 8) ;
1305
+ var qn = {};
1306
+ qn.read = function(e, t, r, n, i) {
1307
+ var o, a, f = i * 8 - n - 1, l = (1 << f) - 1, p = l >> 1, u = -7, d = r ? i - 1 : 0, w = r ? -1 : 1, y = e[t + d];
1308
+ for (d += w, o = y & (1 << -u) - 1, y >>= -u, u += f; u > 0; o = o * 256 + e[t + d], d += w, u -= 8) ;
1309
1309
  for (a = o & (1 << -u) - 1, o >>= -u, u += n; u > 0; a = a * 256 + e[t + d], d += w, u -= 8) ;
1310
1310
  if (o === 0) o = 1 - p;
1311
1311
  else {
1312
- if (o === l) return a ? NaN : (b ? -1 : 1) * (1 / 0);
1312
+ if (o === l) return a ? NaN : (y ? -1 : 1) * (1 / 0);
1313
1313
  a = a + Math.pow(2, n), o = o - p;
1314
1314
  }
1315
- return (b ? -1 : 1) * a * Math.pow(2, o - n);
1315
+ return (y ? -1 : 1) * a * Math.pow(2, o - n);
1316
1316
  };
1317
- Yn.write = function(e, t, r, n, i, o) {
1318
- var a, f, l, p = o * 8 - i - 1, u = (1 << p) - 1, d = u >> 1, w = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, b = n ? 0 : o - 1, m = n ? 1 : -1, v = t < 0 || t === 0 && 1 / t < 0 ? 1 : 0;
1319
- for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (f = isNaN(t) ? 1 : 0, a = u) : (a = Math.floor(Math.log(t) / Math.LN2), t * (l = Math.pow(2, -a)) < 1 && (a--, l *= 2), a + d >= 1 ? t += w / l : t += w * Math.pow(2, 1 - d), t * l >= 2 && (a++, l /= 2), a + d >= u ? (f = 0, a = u) : a + d >= 1 ? (f = (t * l - 1) * Math.pow(2, i), a = a + d) : (f = t * Math.pow(2, d - 1) * Math.pow(2, i), a = 0)); i >= 8; e[r + b] = f & 255, b += m, f /= 256, i -= 8) ;
1320
- for (a = a << i | f, p += i; p > 0; e[r + b] = a & 255, b += m, a /= 256, p -= 8) ;
1321
- e[r + b - m] |= v * 128;
1317
+ qn.write = function(e, t, r, n, i, o) {
1318
+ var a, f, l, p = o * 8 - i - 1, u = (1 << p) - 1, d = u >> 1, w = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, y = n ? 0 : o - 1, m = n ? 1 : -1, v = t < 0 || t === 0 && 1 / t < 0 ? 1 : 0;
1319
+ for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (f = isNaN(t) ? 1 : 0, a = u) : (a = Math.floor(Math.log(t) / Math.LN2), t * (l = Math.pow(2, -a)) < 1 && (a--, l *= 2), a + d >= 1 ? t += w / l : t += w * Math.pow(2, 1 - d), t * l >= 2 && (a++, l /= 2), a + d >= u ? (f = 0, a = u) : a + d >= 1 ? (f = (t * l - 1) * Math.pow(2, i), a = a + d) : (f = t * Math.pow(2, d - 1) * Math.pow(2, i), a = 0)); i >= 8; e[r + y] = f & 255, y += m, f /= 256, i -= 8) ;
1320
+ for (a = a << i | f, p += i; p > 0; e[r + y] = a & 255, y += m, a /= 256, p -= 8) ;
1321
+ e[r + y - m] |= v * 128;
1322
1322
  };
1323
1323
  (function(e) {
1324
- const t = Zr, r = Yn, n = typeof Symbol == "function" && typeof Symbol.for == "function" ? /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom") : null;
1324
+ const t = Zr, r = qn, n = typeof Symbol == "function" && typeof Symbol.for == "function" ? /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom") : null;
1325
1325
  e.Buffer = u, e.SlowBuffer = z, e.INSPECT_MAX_BYTES = 50;
1326
1326
  const i = 2147483647;
1327
1327
  e.kMaxLength = i;
@@ -1369,8 +1369,8 @@ Yn.write = function(e, t, r, n, i, o) {
1369
1369
  if (typeof s == "number") throw new TypeError('The "value" argument must not be of type number. Received type number');
1370
1370
  const g = s.valueOf && s.valueOf();
1371
1371
  if (g != null && g !== s) return u.from(g, h, c);
1372
- const y = _(s);
1373
- if (y) return y;
1372
+ const b = _(s);
1373
+ if (b) return b;
1374
1374
  if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof s[Symbol.toPrimitive] == "function") return u.from(s[Symbol.toPrimitive]("string"), h, c);
1375
1375
  throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof s);
1376
1376
  }
@@ -1381,11 +1381,11 @@ Yn.write = function(e, t, r, n, i, o) {
1381
1381
  if (typeof s != "number") throw new TypeError('"size" argument must be of type number');
1382
1382
  if (s < 0) throw new RangeError('The value "' + s + '" is invalid for option "size"');
1383
1383
  }
1384
- function b(s, h, c) {
1384
+ function y(s, h, c) {
1385
1385
  return w(s), s <= 0 ? p(s) : h !== void 0 ? typeof c == "string" ? p(s).fill(h, c) : p(s).fill(h) : p(s);
1386
1386
  }
1387
1387
  u.alloc = function(s, h, c) {
1388
- return b(s, h, c);
1388
+ return y(s, h, c);
1389
1389
  };
1390
1390
  function m(s) {
1391
1391
  return w(s), p(s < 0 ? 0 : O(s) | 0);
@@ -1397,10 +1397,10 @@ Yn.write = function(e, t, r, n, i, o) {
1397
1397
  };
1398
1398
  function v(s, h) {
1399
1399
  if ((typeof h != "string" || h === "") && (h = "utf8"), !u.isEncoding(h)) throw new TypeError("Unknown encoding: " + h);
1400
- const c = D(s, h) | 0;
1400
+ const c = M(s, h) | 0;
1401
1401
  let g = p(c);
1402
- const y = g.write(s, h);
1403
- return y !== c && (g = g.slice(0, y)), g;
1402
+ const b = g.write(s, h);
1403
+ return b !== c && (g = g.slice(0, b)), g;
1404
1404
  }
1405
1405
  function I(s) {
1406
1406
  const h = s.length < 0 ? 0 : O(s.length) | 0, c = p(h);
@@ -1441,8 +1441,8 @@ Yn.write = function(e, t, r, n, i, o) {
1441
1441
  if (Ft(s, o) && (s = u.from(s, s.offset, s.byteLength)), Ft(h, o) && (h = u.from(h, h.offset, h.byteLength)), !u.isBuffer(s) || !u.isBuffer(h)) throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
1442
1442
  if (s === h) return 0;
1443
1443
  let c = s.length, g = h.length;
1444
- for (let y = 0, E = Math.min(c, g); y < E; ++y) if (s[y] !== h[y]) {
1445
- c = s[y], g = h[y];
1444
+ for (let b = 0, E = Math.min(c, g); b < E; ++b) if (s[b] !== h[b]) {
1445
+ c = s[b], g = h[b];
1446
1446
  break;
1447
1447
  }
1448
1448
  return c < g ? -1 : g < c ? 1 : 0;
@@ -1469,23 +1469,23 @@ Yn.write = function(e, t, r, n, i, o) {
1469
1469
  let c;
1470
1470
  if (h === void 0) for (h = 0, c = 0; c < s.length; ++c) h += s[c].length;
1471
1471
  const g = u.allocUnsafe(h);
1472
- let y = 0;
1472
+ let b = 0;
1473
1473
  for (c = 0; c < s.length; ++c) {
1474
1474
  let E = s[c];
1475
- if (Ft(E, o)) y + E.length > g.length ? (u.isBuffer(E) || (E = u.from(E)), E.copy(g, y)) : o.prototype.set.call(g, E, y);
1476
- else if (u.isBuffer(E)) E.copy(g, y);
1475
+ if (Ft(E, o)) b + E.length > g.length ? (u.isBuffer(E) || (E = u.from(E)), E.copy(g, b)) : o.prototype.set.call(g, E, b);
1476
+ else if (u.isBuffer(E)) E.copy(g, b);
1477
1477
  else throw new TypeError('"list" argument must be an Array of Buffers');
1478
- y += E.length;
1478
+ b += E.length;
1479
1479
  }
1480
1480
  return g;
1481
1481
  };
1482
- function D(s, h) {
1482
+ function M(s, h) {
1483
1483
  if (u.isBuffer(s)) return s.length;
1484
1484
  if (a.isView(s) || Ft(s, a)) return s.byteLength;
1485
1485
  if (typeof s != "string") throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof s);
1486
1486
  const c = s.length, g = arguments.length > 2 && arguments[2] === !0;
1487
1487
  if (!g && c === 0) return 0;
1488
- let y = !1;
1488
+ let b = !1;
1489
1489
  for (; ; ) switch (h) {
1490
1490
  case "ascii":
1491
1491
  case "latin1":
@@ -1502,14 +1502,14 @@ Yn.write = function(e, t, r, n, i, o) {
1502
1502
  case "hex":
1503
1503
  return c >>> 1;
1504
1504
  case "base64":
1505
- return Ei(s).length;
1505
+ return bi(s).length;
1506
1506
  default:
1507
- if (y) return g ? -1 : hn(s).length;
1508
- h = ("" + h).toLowerCase(), y = !0;
1507
+ if (b) return g ? -1 : hn(s).length;
1508
+ h = ("" + h).toLowerCase(), b = !0;
1509
1509
  }
1510
1510
  }
1511
- u.byteLength = D;
1512
- function X(s, h, c) {
1511
+ u.byteLength = M;
1512
+ function Z(s, h, c) {
1513
1513
  let g = !1;
1514
1514
  if ((h === void 0 || h < 0) && (h = 0), h > this.length || ((c === void 0 || c > this.length) && (c = this.length), c <= 0) || (c >>>= 0, h >>>= 0, c <= h)) return "";
1515
1515
  for (s || (s = "utf8"); ; ) switch (s) {
@@ -1522,7 +1522,7 @@ Yn.write = function(e, t, r, n, i, o) {
1522
1522
  return L(this, h, c);
1523
1523
  case "latin1":
1524
1524
  case "binary":
1525
- return M(this, h, c);
1525
+ return D(this, h, c);
1526
1526
  case "base64":
1527
1527
  return B(this, h, c);
1528
1528
  case "ucs2":
@@ -1536,28 +1536,28 @@ Yn.write = function(e, t, r, n, i, o) {
1536
1536
  }
1537
1537
  }
1538
1538
  u.prototype._isBuffer = !0;
1539
- function at(s, h, c) {
1539
+ function Q(s, h, c) {
1540
1540
  const g = s[h];
1541
1541
  s[h] = s[c], s[c] = g;
1542
1542
  }
1543
1543
  u.prototype.swap16 = function() {
1544
1544
  const s = this.length;
1545
1545
  if (s % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
1546
- for (let h = 0; h < s; h += 2) at(this, h, h + 1);
1546
+ for (let h = 0; h < s; h += 2) Q(this, h, h + 1);
1547
1547
  return this;
1548
1548
  }, u.prototype.swap32 = function() {
1549
1549
  const s = this.length;
1550
1550
  if (s % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
1551
- for (let h = 0; h < s; h += 4) at(this, h, h + 3), at(this, h + 1, h + 2);
1551
+ for (let h = 0; h < s; h += 4) Q(this, h, h + 3), Q(this, h + 1, h + 2);
1552
1552
  return this;
1553
1553
  }, u.prototype.swap64 = function() {
1554
1554
  const s = this.length;
1555
1555
  if (s % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
1556
- for (let h = 0; h < s; h += 8) at(this, h, h + 7), at(this, h + 1, h + 6), at(this, h + 2, h + 5), at(this, h + 3, h + 4);
1556
+ for (let h = 0; h < s; h += 8) Q(this, h, h + 7), Q(this, h + 1, h + 6), Q(this, h + 2, h + 5), Q(this, h + 3, h + 4);
1557
1557
  return this;
1558
1558
  }, u.prototype.toString = function() {
1559
1559
  const s = this.length;
1560
- return s === 0 ? "" : arguments.length === 0 ? V(this, 0, s) : X.apply(this, arguments);
1560
+ return s === 0 ? "" : arguments.length === 0 ? V(this, 0, s) : Z.apply(this, arguments);
1561
1561
  }, u.prototype.toLocaleString = u.prototype.toString, u.prototype.equals = function(s) {
1562
1562
  if (!u.isBuffer(s)) throw new TypeError("Argument must be a Buffer");
1563
1563
  return this === s ? !0 : u.compare(this, s) === 0;
@@ -1565,54 +1565,54 @@ Yn.write = function(e, t, r, n, i, o) {
1565
1565
  let s = "";
1566
1566
  const h = e.INSPECT_MAX_BYTES;
1567
1567
  return s = this.toString("hex", 0, h).replace(/(.{2})/g, "$1 ").trim(), this.length > h && (s += " ... "), "<Buffer " + s + ">";
1568
- }, n && (u.prototype[n] = u.prototype.inspect), u.prototype.compare = function(s, h, c, g, y) {
1568
+ }, n && (u.prototype[n] = u.prototype.inspect), u.prototype.compare = function(s, h, c, g, b) {
1569
1569
  if (Ft(s, o) && (s = u.from(s, s.offset, s.byteLength)), !u.isBuffer(s)) throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof s);
1570
- if (h === void 0 && (h = 0), c === void 0 && (c = s ? s.length : 0), g === void 0 && (g = 0), y === void 0 && (y = this.length), h < 0 || c > s.length || g < 0 || y > this.length) throw new RangeError("out of range index");
1571
- if (g >= y && h >= c) return 0;
1572
- if (g >= y) return -1;
1570
+ if (h === void 0 && (h = 0), c === void 0 && (c = s ? s.length : 0), g === void 0 && (g = 0), b === void 0 && (b = this.length), h < 0 || c > s.length || g < 0 || b > this.length) throw new RangeError("out of range index");
1571
+ if (g >= b && h >= c) return 0;
1572
+ if (g >= b) return -1;
1573
1573
  if (h >= c) return 1;
1574
- if (h >>>= 0, c >>>= 0, g >>>= 0, y >>>= 0, this === s) return 0;
1575
- let E = y - g, k = c - h;
1576
- const st = Math.min(E, k), bt = this.slice(g, y), ot = s.slice(h, c);
1577
- for (let rt = 0; rt < st; ++rt) if (bt[rt] !== ot[rt]) {
1578
- E = bt[rt], k = ot[rt];
1574
+ if (h >>>= 0, c >>>= 0, g >>>= 0, b >>>= 0, this === s) return 0;
1575
+ let E = b - g, k = c - h;
1576
+ const ot = Math.min(E, k), bt = this.slice(g, b), at = s.slice(h, c);
1577
+ for (let nt = 0; nt < ot; ++nt) if (bt[nt] !== at[nt]) {
1578
+ E = bt[nt], k = at[nt];
1579
1579
  break;
1580
1580
  }
1581
1581
  return E < k ? -1 : k < E ? 1 : 0;
1582
1582
  };
1583
- function q(s, h, c, g, y) {
1583
+ function q(s, h, c, g, b) {
1584
1584
  if (s.length === 0) return -1;
1585
- if (typeof c == "string" ? (g = c, c = 0) : c > 2147483647 ? c = 2147483647 : c < -2147483648 && (c = -2147483648), c = +c, un(c) && (c = y ? 0 : s.length - 1), c < 0 && (c = s.length + c), c >= s.length) {
1586
- if (y) return -1;
1585
+ if (typeof c == "string" ? (g = c, c = 0) : c > 2147483647 ? c = 2147483647 : c < -2147483648 && (c = -2147483648), c = +c, un(c) && (c = b ? 0 : s.length - 1), c < 0 && (c = s.length + c), c >= s.length) {
1586
+ if (b) return -1;
1587
1587
  c = s.length - 1;
1588
- } else if (c < 0) if (y) c = 0;
1588
+ } else if (c < 0) if (b) c = 0;
1589
1589
  else return -1;
1590
- if (typeof h == "string" && (h = u.from(h, g)), u.isBuffer(h)) return h.length === 0 ? -1 : Vt(s, h, c, g, y);
1591
- if (typeof h == "number") return h = h & 255, typeof o.prototype.indexOf == "function" ? y ? o.prototype.indexOf.call(s, h, c) : o.prototype.lastIndexOf.call(s, h, c) : Vt(s, [h], c, g, y);
1590
+ if (typeof h == "string" && (h = u.from(h, g)), u.isBuffer(h)) return h.length === 0 ? -1 : Vt(s, h, c, g, b);
1591
+ if (typeof h == "number") return h = h & 255, typeof o.prototype.indexOf == "function" ? b ? o.prototype.indexOf.call(s, h, c) : o.prototype.lastIndexOf.call(s, h, c) : Vt(s, [h], c, g, b);
1592
1592
  throw new TypeError("val must be string, number or Buffer");
1593
1593
  }
1594
- function Vt(s, h, c, g, y) {
1595
- let E = 1, k = s.length, st = h.length;
1594
+ function Vt(s, h, c, g, b) {
1595
+ let E = 1, k = s.length, ot = h.length;
1596
1596
  if (g !== void 0 && (g = String(g).toLowerCase(), g === "ucs2" || g === "ucs-2" || g === "utf16le" || g === "utf-16le")) {
1597
1597
  if (s.length < 2 || h.length < 2) return -1;
1598
- E = 2, k /= 2, st /= 2, c /= 2;
1599
- }
1600
- function bt(rt, pt) {
1601
- return E === 1 ? rt[pt] : rt.readUInt16BE(pt * E);
1602
- }
1603
- let ot;
1604
- if (y) {
1605
- let rt = -1;
1606
- for (ot = c; ot < k; ot++) if (bt(s, ot) === bt(h, rt === -1 ? 0 : ot - rt)) {
1607
- if (rt === -1 && (rt = ot), ot - rt + 1 === st) return rt * E;
1608
- } else rt !== -1 && (ot -= ot - rt), rt = -1;
1609
- } else for (c + st > k && (c = k - st), ot = c; ot >= 0; ot--) {
1610
- let rt = !0;
1611
- for (let pt = 0; pt < st; pt++) if (bt(s, ot + pt) !== bt(h, pt)) {
1612
- rt = !1;
1598
+ E = 2, k /= 2, ot /= 2, c /= 2;
1599
+ }
1600
+ function bt(nt, pt) {
1601
+ return E === 1 ? nt[pt] : nt.readUInt16BE(pt * E);
1602
+ }
1603
+ let at;
1604
+ if (b) {
1605
+ let nt = -1;
1606
+ for (at = c; at < k; at++) if (bt(s, at) === bt(h, nt === -1 ? 0 : at - nt)) {
1607
+ if (nt === -1 && (nt = at), at - nt + 1 === ot) return nt * E;
1608
+ } else nt !== -1 && (at -= at - nt), nt = -1;
1609
+ } else for (c + ot > k && (c = k - ot), at = c; at >= 0; at--) {
1610
+ let nt = !0;
1611
+ for (let pt = 0; pt < ot; pt++) if (bt(s, at + pt) !== bt(h, pt)) {
1612
+ nt = !1;
1613
1613
  break;
1614
1614
  }
1615
- if (rt) return ot;
1615
+ if (nt) return at;
1616
1616
  }
1617
1617
  return -1;
1618
1618
  }
@@ -1625,15 +1625,15 @@ Yn.write = function(e, t, r, n, i, o) {
1625
1625
  };
1626
1626
  function Qt(s, h, c, g) {
1627
1627
  c = Number(c) || 0;
1628
- const y = s.length - c;
1629
- g ? (g = Number(g), g > y && (g = y)) : g = y;
1628
+ const b = s.length - c;
1629
+ g ? (g = Number(g), g > b && (g = b)) : g = b;
1630
1630
  const E = h.length;
1631
1631
  g > E / 2 && (g = E / 2);
1632
1632
  let k;
1633
1633
  for (k = 0; k < g; ++k) {
1634
- const st = parseInt(h.substr(k * 2, 2), 16);
1635
- if (un(st)) return k;
1636
- s[c + k] = st;
1634
+ const ot = parseInt(h.substr(k * 2, 2), 16);
1635
+ if (un(ot)) return k;
1636
+ s[c + k] = ot;
1637
1637
  }
1638
1638
  return k;
1639
1639
  }
@@ -1644,7 +1644,7 @@ Yn.write = function(e, t, r, n, i, o) {
1644
1644
  return br(ya(h), s, c, g);
1645
1645
  }
1646
1646
  function T(s, h, c, g) {
1647
- return br(Ei(h), s, c, g);
1647
+ return br(bi(h), s, c, g);
1648
1648
  }
1649
1649
  function A(s, h, c, g) {
1650
1650
  return br(ba(h, s.length - c), s, c, g);
@@ -1654,8 +1654,8 @@ Yn.write = function(e, t, r, n, i, o) {
1654
1654
  else if (c === void 0 && typeof h == "string") g = h, c = this.length, h = 0;
1655
1655
  else if (isFinite(h)) h = h >>> 0, isFinite(c) ? (c = c >>> 0, g === void 0 && (g = "utf8")) : (g = c, c = void 0);
1656
1656
  else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
1657
- const y = this.length - h;
1658
- if ((c === void 0 || c > y) && (c = y), s.length > 0 && (c < 0 || h < 0) || h > this.length) throw new RangeError("Attempt to write outside buffer bounds");
1657
+ const b = this.length - h;
1658
+ if ((c === void 0 || c > b) && (c = b), s.length > 0 && (c < 0 || h < 0) || h > this.length) throw new RangeError("Attempt to write outside buffer bounds");
1659
1659
  g || (g = "utf8");
1660
1660
  let E = !1;
1661
1661
  for (; ; ) switch (g) {
@@ -1691,27 +1691,27 @@ Yn.write = function(e, t, r, n, i, o) {
1691
1691
  function V(s, h, c) {
1692
1692
  c = Math.min(s.length, c);
1693
1693
  const g = [];
1694
- let y = h;
1695
- for (; y < c; ) {
1696
- const E = s[y];
1697
- let k = null, st = E > 239 ? 4 : E > 223 ? 3 : E > 191 ? 2 : 1;
1698
- if (y + st <= c) {
1699
- let bt, ot, rt, pt;
1700
- switch (st) {
1694
+ let b = h;
1695
+ for (; b < c; ) {
1696
+ const E = s[b];
1697
+ let k = null, ot = E > 239 ? 4 : E > 223 ? 3 : E > 191 ? 2 : 1;
1698
+ if (b + ot <= c) {
1699
+ let bt, at, nt, pt;
1700
+ switch (ot) {
1701
1701
  case 1:
1702
1702
  E < 128 && (k = E);
1703
1703
  break;
1704
1704
  case 2:
1705
- bt = s[y + 1], (bt & 192) === 128 && (pt = (E & 31) << 6 | bt & 63, pt > 127 && (k = pt));
1705
+ bt = s[b + 1], (bt & 192) === 128 && (pt = (E & 31) << 6 | bt & 63, pt > 127 && (k = pt));
1706
1706
  break;
1707
1707
  case 3:
1708
- bt = s[y + 1], ot = s[y + 2], (bt & 192) === 128 && (ot & 192) === 128 && (pt = (E & 15) << 12 | (bt & 63) << 6 | ot & 63, pt > 2047 && (pt < 55296 || pt > 57343) && (k = pt));
1708
+ bt = s[b + 1], at = s[b + 2], (bt & 192) === 128 && (at & 192) === 128 && (pt = (E & 15) << 12 | (bt & 63) << 6 | at & 63, pt > 2047 && (pt < 55296 || pt > 57343) && (k = pt));
1709
1709
  break;
1710
1710
  case 4:
1711
- bt = s[y + 1], ot = s[y + 2], rt = s[y + 3], (bt & 192) === 128 && (ot & 192) === 128 && (rt & 192) === 128 && (pt = (E & 15) << 18 | (bt & 63) << 12 | (ot & 63) << 6 | rt & 63, pt > 65535 && pt < 1114112 && (k = pt));
1711
+ bt = s[b + 1], at = s[b + 2], nt = s[b + 3], (bt & 192) === 128 && (at & 192) === 128 && (nt & 192) === 128 && (pt = (E & 15) << 18 | (bt & 63) << 12 | (at & 63) << 6 | nt & 63, pt > 65535 && pt < 1114112 && (k = pt));
1712
1712
  }
1713
1713
  }
1714
- k === null ? (k = 65533, st = 1) : k > 65535 && (k -= 65536, g.push(k >>> 10 & 1023 | 55296), k = 56320 | k & 1023), g.push(k), y += st;
1714
+ k === null ? (k = 65533, ot = 1) : k > 65535 && (k -= 65536, g.push(k >>> 10 & 1023 | 55296), k = 56320 | k & 1023), g.push(k), b += ot;
1715
1715
  }
1716
1716
  return C(g);
1717
1717
  }
@@ -1726,27 +1726,27 @@ Yn.write = function(e, t, r, n, i, o) {
1726
1726
  function L(s, h, c) {
1727
1727
  let g = "";
1728
1728
  c = Math.min(s.length, c);
1729
- for (let y = h; y < c; ++y) g += String.fromCharCode(s[y] & 127);
1729
+ for (let b = h; b < c; ++b) g += String.fromCharCode(s[b] & 127);
1730
1730
  return g;
1731
1731
  }
1732
- function M(s, h, c) {
1732
+ function D(s, h, c) {
1733
1733
  let g = "";
1734
1734
  c = Math.min(s.length, c);
1735
- for (let y = h; y < c; ++y) g += String.fromCharCode(s[y]);
1735
+ for (let b = h; b < c; ++b) g += String.fromCharCode(s[b]);
1736
1736
  return g;
1737
1737
  }
1738
1738
  function F(s, h, c) {
1739
1739
  const g = s.length;
1740
1740
  (!h || h < 0) && (h = 0), (!c || c < 0 || c > g) && (c = g);
1741
- let y = "";
1742
- for (let E = h; E < c; ++E) y += ma[s[E]];
1743
- return y;
1741
+ let b = "";
1742
+ for (let E = h; E < c; ++E) b += ma[s[E]];
1743
+ return b;
1744
1744
  }
1745
1745
  function ct(s, h, c) {
1746
1746
  const g = s.slice(h, c);
1747
- let y = "";
1748
- for (let E = 0; E < g.length - 1; E += 2) y += String.fromCharCode(g[E] + g[E + 1] * 256);
1749
- return y;
1747
+ let b = "";
1748
+ for (let E = 0; E < g.length - 1; E += 2) b += String.fromCharCode(g[E] + g[E + 1] * 256);
1749
+ return b;
1750
1750
  }
1751
1751
  u.prototype.slice = function(s, h) {
1752
1752
  const c = this.length;
@@ -1760,13 +1760,13 @@ Yn.write = function(e, t, r, n, i, o) {
1760
1760
  }
1761
1761
  u.prototype.readUintLE = u.prototype.readUIntLE = function(s, h, c) {
1762
1762
  s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
1763
- let g = this[s], y = 1, E = 0;
1764
- for (; ++E < h && (y *= 256); ) g += this[s + E] * y;
1763
+ let g = this[s], b = 1, E = 0;
1764
+ for (; ++E < h && (b *= 256); ) g += this[s + E] * b;
1765
1765
  return g;
1766
1766
  }, u.prototype.readUintBE = u.prototype.readUIntBE = function(s, h, c) {
1767
1767
  s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
1768
- let g = this[s + --h], y = 1;
1769
- for (; h > 0 && (y *= 256); ) g += this[s + --h] * y;
1768
+ let g = this[s + --h], b = 1;
1769
+ for (; h > 0 && (b *= 256); ) g += this[s + --h] * b;
1770
1770
  return g;
1771
1771
  }, u.prototype.readUint8 = u.prototype.readUInt8 = function(s, h) {
1772
1772
  return s = s >>> 0, h || W(s, 1, this.length), this[s];
@@ -1782,24 +1782,24 @@ Yn.write = function(e, t, r, n, i, o) {
1782
1782
  s = s >>> 0, _e(s, "offset");
1783
1783
  const h = this[s], c = this[s + 7];
1784
1784
  (h === void 0 || c === void 0) && ze(s, this.length - 8);
1785
- const g = h + this[++s] * 2 ** 8 + this[++s] * 2 ** 16 + this[++s] * 2 ** 24, y = this[++s] + this[++s] * 2 ** 8 + this[++s] * 2 ** 16 + c * 2 ** 24;
1786
- return BigInt(g) + (BigInt(y) << BigInt(32));
1785
+ const g = h + this[++s] * 2 ** 8 + this[++s] * 2 ** 16 + this[++s] * 2 ** 24, b = this[++s] + this[++s] * 2 ** 8 + this[++s] * 2 ** 16 + c * 2 ** 24;
1786
+ return BigInt(g) + (BigInt(b) << BigInt(32));
1787
1787
  }), u.prototype.readBigUInt64BE = ie(function(s) {
1788
1788
  s = s >>> 0, _e(s, "offset");
1789
1789
  const h = this[s], c = this[s + 7];
1790
1790
  (h === void 0 || c === void 0) && ze(s, this.length - 8);
1791
- const g = h * 2 ** 24 + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + this[++s], y = this[++s] * 2 ** 24 + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + c;
1792
- return (BigInt(g) << BigInt(32)) + BigInt(y);
1791
+ const g = h * 2 ** 24 + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + this[++s], b = this[++s] * 2 ** 24 + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + c;
1792
+ return (BigInt(g) << BigInt(32)) + BigInt(b);
1793
1793
  }), u.prototype.readIntLE = function(s, h, c) {
1794
1794
  s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
1795
- let g = this[s], y = 1, E = 0;
1796
- for (; ++E < h && (y *= 256); ) g += this[s + E] * y;
1797
- return y *= 128, g >= y && (g -= Math.pow(2, 8 * h)), g;
1795
+ let g = this[s], b = 1, E = 0;
1796
+ for (; ++E < h && (b *= 256); ) g += this[s + E] * b;
1797
+ return b *= 128, g >= b && (g -= Math.pow(2, 8 * h)), g;
1798
1798
  }, u.prototype.readIntBE = function(s, h, c) {
1799
1799
  s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
1800
- let g = h, y = 1, E = this[s + --g];
1801
- for (; g > 0 && (y *= 256); ) E += this[s + --g] * y;
1802
- return y *= 128, E >= y && (E -= Math.pow(2, 8 * h)), E;
1800
+ let g = h, b = 1, E = this[s + --g];
1801
+ for (; g > 0 && (b *= 256); ) E += this[s + --g] * b;
1802
+ return b *= 128, E >= b && (E -= Math.pow(2, 8 * h)), E;
1803
1803
  }, u.prototype.readInt8 = function(s, h) {
1804
1804
  return s = s >>> 0, h || W(s, 1, this.length), this[s] & 128 ? (255 - this[s] + 1) * -1 : this[s];
1805
1805
  }, u.prototype.readInt16LE = function(s, h) {
@@ -1835,9 +1835,9 @@ Yn.write = function(e, t, r, n, i, o) {
1835
1835
  }, u.prototype.readDoubleBE = function(s, h) {
1836
1836
  return s = s >>> 0, h || W(s, 8, this.length), r.read(this, s, !1, 52, 8);
1837
1837
  };
1838
- function K(s, h, c, g, y, E) {
1838
+ function K(s, h, c, g, b, E) {
1839
1839
  if (!u.isBuffer(s)) throw new TypeError('"buffer" argument must be a Buffer instance');
1840
- if (h > y || h < E) throw new RangeError('"value" argument is out of bounds');
1840
+ if (h > b || h < E) throw new RangeError('"value" argument is out of bounds');
1841
1841
  if (c + g > s.length) throw new RangeError("Index out of range");
1842
1842
  }
1843
1843
  u.prototype.writeUintLE = u.prototype.writeUIntLE = function(s, h, c, g) {
@@ -1845,16 +1845,16 @@ Yn.write = function(e, t, r, n, i, o) {
1845
1845
  const k = Math.pow(2, 8 * c) - 1;
1846
1846
  K(this, s, h, c, k, 0);
1847
1847
  }
1848
- let y = 1, E = 0;
1849
- for (this[h] = s & 255; ++E < c && (y *= 256); ) this[h + E] = s / y & 255;
1848
+ let b = 1, E = 0;
1849
+ for (this[h] = s & 255; ++E < c && (b *= 256); ) this[h + E] = s / b & 255;
1850
1850
  return h + c;
1851
1851
  }, u.prototype.writeUintBE = u.prototype.writeUIntBE = function(s, h, c, g) {
1852
1852
  if (s = +s, h = h >>> 0, c = c >>> 0, !g) {
1853
1853
  const k = Math.pow(2, 8 * c) - 1;
1854
1854
  K(this, s, h, c, k, 0);
1855
1855
  }
1856
- let y = c - 1, E = 1;
1857
- for (this[h + y] = s & 255; --y >= 0 && (E *= 256); ) this[h + y] = s / E & 255;
1856
+ let b = c - 1, E = 1;
1857
+ for (this[h + b] = s & 255; --b >= 0 && (E *= 256); ) this[h + b] = s / E & 255;
1858
1858
  return h + c;
1859
1859
  }, u.prototype.writeUint8 = u.prototype.writeUInt8 = function(s, h, c) {
1860
1860
  return s = +s, h = h >>> 0, c || K(this, s, h, 1, 255, 0), this[h] = s & 255, h + 1;
@@ -1867,39 +1867,39 @@ Yn.write = function(e, t, r, n, i, o) {
1867
1867
  }, u.prototype.writeUint32BE = u.prototype.writeUInt32BE = function(s, h, c) {
1868
1868
  return s = +s, h = h >>> 0, c || K(this, s, h, 4, 4294967295, 0), this[h] = s >>> 24, this[h + 1] = s >>> 16, this[h + 2] = s >>> 8, this[h + 3] = s & 255, h + 4;
1869
1869
  };
1870
- function nt(s, h, c, g, y) {
1871
- mi(h, g, y, s, c, 7);
1870
+ function it(s, h, c, g, b) {
1871
+ yi(h, g, b, s, c, 7);
1872
1872
  let E = Number(h & BigInt(4294967295));
1873
1873
  s[c++] = E, E = E >> 8, s[c++] = E, E = E >> 8, s[c++] = E, E = E >> 8, s[c++] = E;
1874
1874
  let k = Number(h >> BigInt(32) & BigInt(4294967295));
1875
1875
  return s[c++] = k, k = k >> 8, s[c++] = k, k = k >> 8, s[c++] = k, k = k >> 8, s[c++] = k, c;
1876
1876
  }
1877
- function lt(s, h, c, g, y) {
1878
- mi(h, g, y, s, c, 7);
1877
+ function lt(s, h, c, g, b) {
1878
+ yi(h, g, b, s, c, 7);
1879
1879
  let E = Number(h & BigInt(4294967295));
1880
1880
  s[c + 7] = E, E = E >> 8, s[c + 6] = E, E = E >> 8, s[c + 5] = E, E = E >> 8, s[c + 4] = E;
1881
1881
  let k = Number(h >> BigInt(32) & BigInt(4294967295));
1882
1882
  return s[c + 3] = k, k = k >> 8, s[c + 2] = k, k = k >> 8, s[c + 1] = k, k = k >> 8, s[c] = k, c + 8;
1883
1883
  }
1884
1884
  u.prototype.writeBigUInt64LE = ie(function(s, h = 0) {
1885
- return nt(this, s, h, BigInt(0), BigInt("0xffffffffffffffff"));
1885
+ return it(this, s, h, BigInt(0), BigInt("0xffffffffffffffff"));
1886
1886
  }), u.prototype.writeBigUInt64BE = ie(function(s, h = 0) {
1887
1887
  return lt(this, s, h, BigInt(0), BigInt("0xffffffffffffffff"));
1888
1888
  }), u.prototype.writeIntLE = function(s, h, c, g) {
1889
1889
  if (s = +s, h = h >>> 0, !g) {
1890
- const st = Math.pow(2, 8 * c - 1);
1891
- K(this, s, h, c, st - 1, -st);
1890
+ const ot = Math.pow(2, 8 * c - 1);
1891
+ K(this, s, h, c, ot - 1, -ot);
1892
1892
  }
1893
- let y = 0, E = 1, k = 0;
1894
- for (this[h] = s & 255; ++y < c && (E *= 256); ) s < 0 && k === 0 && this[h + y - 1] !== 0 && (k = 1), this[h + y] = (s / E >> 0) - k & 255;
1893
+ let b = 0, E = 1, k = 0;
1894
+ for (this[h] = s & 255; ++b < c && (E *= 256); ) s < 0 && k === 0 && this[h + b - 1] !== 0 && (k = 1), this[h + b] = (s / E >> 0) - k & 255;
1895
1895
  return h + c;
1896
1896
  }, u.prototype.writeIntBE = function(s, h, c, g) {
1897
1897
  if (s = +s, h = h >>> 0, !g) {
1898
- const st = Math.pow(2, 8 * c - 1);
1899
- K(this, s, h, c, st - 1, -st);
1898
+ const ot = Math.pow(2, 8 * c - 1);
1899
+ K(this, s, h, c, ot - 1, -ot);
1900
1900
  }
1901
- let y = c - 1, E = 1, k = 0;
1902
- for (this[h + y] = s & 255; --y >= 0 && (E *= 256); ) s < 0 && k === 0 && this[h + y + 1] !== 0 && (k = 1), this[h + y] = (s / E >> 0) - k & 255;
1901
+ let b = c - 1, E = 1, k = 0;
1902
+ for (this[h + b] = s & 255; --b >= 0 && (E *= 256); ) s < 0 && k === 0 && this[h + b + 1] !== 0 && (k = 1), this[h + b] = (s / E >> 0) - k & 255;
1903
1903
  return h + c;
1904
1904
  }, u.prototype.writeInt8 = function(s, h, c) {
1905
1905
  return s = +s, h = h >>> 0, c || K(this, s, h, 1, 127, -128), s < 0 && (s = 255 + s + 1), this[h] = s & 255, h + 1;
@@ -1912,24 +1912,24 @@ Yn.write = function(e, t, r, n, i, o) {
1912
1912
  }, u.prototype.writeInt32BE = function(s, h, c) {
1913
1913
  return s = +s, h = h >>> 0, c || K(this, s, h, 4, 2147483647, -2147483648), s < 0 && (s = 4294967295 + s + 1), this[h] = s >>> 24, this[h + 1] = s >>> 16, this[h + 2] = s >>> 8, this[h + 3] = s & 255, h + 4;
1914
1914
  }, u.prototype.writeBigInt64LE = ie(function(s, h = 0) {
1915
- return nt(this, s, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1915
+ return it(this, s, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1916
1916
  }), u.prototype.writeBigInt64BE = ie(function(s, h = 0) {
1917
1917
  return lt(this, s, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1918
1918
  });
1919
- function _t(s, h, c, g, y, E) {
1919
+ function _t(s, h, c, g, b, E) {
1920
1920
  if (c + g > s.length) throw new RangeError("Index out of range");
1921
1921
  if (c < 0) throw new RangeError("Index out of range");
1922
1922
  }
1923
- function it(s, h, c, g, y) {
1924
- return h = +h, c = c >>> 0, y || _t(s, h, c, 4), r.write(s, h, c, g, 23, 4), c + 4;
1923
+ function st(s, h, c, g, b) {
1924
+ return h = +h, c = c >>> 0, b || _t(s, h, c, 4), r.write(s, h, c, g, 23, 4), c + 4;
1925
1925
  }
1926
1926
  u.prototype.writeFloatLE = function(s, h, c) {
1927
- return it(this, s, h, !0, c);
1927
+ return st(this, s, h, !0, c);
1928
1928
  }, u.prototype.writeFloatBE = function(s, h, c) {
1929
- return it(this, s, h, !1, c);
1929
+ return st(this, s, h, !1, c);
1930
1930
  };
1931
- function yt(s, h, c, g, y) {
1932
- return h = +h, c = c >>> 0, y || _t(s, h, c, 8), r.write(s, h, c, g, 52, 8), c + 8;
1931
+ function yt(s, h, c, g, b) {
1932
+ return h = +h, c = c >>> 0, b || _t(s, h, c, 8), r.write(s, h, c, g, 52, 8), c + 8;
1933
1933
  }
1934
1934
  u.prototype.writeDoubleLE = function(s, h, c) {
1935
1935
  return yt(this, s, h, !0, c);
@@ -1942,8 +1942,8 @@ Yn.write = function(e, t, r, n, i, o) {
1942
1942
  if (c < 0 || c >= this.length) throw new RangeError("Index out of range");
1943
1943
  if (g < 0) throw new RangeError("sourceEnd out of bounds");
1944
1944
  g > this.length && (g = this.length), s.length - h < g - c && (g = s.length - h + c);
1945
- const y = g - c;
1946
- return this === s && typeof o.prototype.copyWithin == "function" ? this.copyWithin(h, c, g) : o.prototype.set.call(s, this.subarray(c, g), h), y;
1945
+ const b = g - c;
1946
+ return this === s && typeof o.prototype.copyWithin == "function" ? this.copyWithin(h, c, g) : o.prototype.set.call(s, this.subarray(c, g), h), b;
1947
1947
  }, u.prototype.fill = function(s, h, c, g) {
1948
1948
  if (typeof s == "string") {
1949
1949
  if (typeof h == "string" ? (g = h, h = 0, c = this.length) : typeof c == "string" && (g = c, c = this.length), g !== void 0 && typeof g != "string") throw new TypeError("encoding must be a string");
@@ -1956,12 +1956,12 @@ Yn.write = function(e, t, r, n, i, o) {
1956
1956
  if (h < 0 || this.length < h || this.length < c) throw new RangeError("Out of range index");
1957
1957
  if (c <= h) return this;
1958
1958
  h = h >>> 0, c = c === void 0 ? this.length : c >>> 0, s || (s = 0);
1959
- let y;
1960
- if (typeof s == "number") for (y = h; y < c; ++y) this[y] = s;
1959
+ let b;
1960
+ if (typeof s == "number") for (b = h; b < c; ++b) this[b] = s;
1961
1961
  else {
1962
1962
  const E = u.isBuffer(s) ? s : u.from(s, g), k = E.length;
1963
1963
  if (k === 0) throw new TypeError('The value "' + s + '" is invalid for argument "value"');
1964
- for (y = 0; y < c - h; ++y) this[y + h] = E[y % k];
1964
+ for (b = 0; b < c - h; ++b) this[b + h] = E[b % k];
1965
1965
  }
1966
1966
  return this;
1967
1967
  };
@@ -1996,8 +1996,8 @@ Yn.write = function(e, t, r, n, i, o) {
1996
1996
  }, RangeError), Be("ERR_INVALID_ARG_TYPE", function(s, h) {
1997
1997
  return `The "${s}" argument must be of type number. Received type ${typeof h}`;
1998
1998
  }, TypeError), Be("ERR_OUT_OF_RANGE", function(s, h, c) {
1999
- let g = `The value of "${s}" is out of range.`, y = c;
2000
- return Number.isInteger(c) && Math.abs(c) > 2 ** 32 ? y = je(String(c)) : typeof c == "bigint" && (y = String(c), (c > BigInt(2) ** BigInt(32) || c < -(BigInt(2) ** BigInt(32))) && (y = je(y)), y += "n"), g += ` It must be ${h}. Received ${y}`, g;
1999
+ let g = `The value of "${s}" is out of range.`, b = c;
2000
+ return Number.isInteger(c) && Math.abs(c) > 2 ** 32 ? b = je(String(c)) : typeof c == "bigint" && (b = String(c), (c > BigInt(2) ** BigInt(32) || c < -(BigInt(2) ** BigInt(32))) && (b = je(b)), b += "n"), g += ` It must be ${h}. Received ${b}`, g;
2001
2001
  }, RangeError);
2002
2002
  function je(s) {
2003
2003
  let h = "", c = s.length;
@@ -2008,13 +2008,13 @@ Yn.write = function(e, t, r, n, i, o) {
2008
2008
  function da(s, h, c) {
2009
2009
  _e(h, "offset"), (s[h] === void 0 || s[h + c] === void 0) && ze(h, s.length - (c + 1));
2010
2010
  }
2011
- function mi(s, h, c, g, y, E) {
2011
+ function yi(s, h, c, g, b, E) {
2012
2012
  if (s > c || s < h) {
2013
2013
  const k = typeof h == "bigint" ? "n" : "";
2014
- let st;
2015
- throw h === 0 || h === BigInt(0) ? st = `>= 0${k} and < 2${k} ** ${(E + 1) * 8}${k}` : st = `>= -(2${k} ** ${(E + 1) * 8 - 1}${k}) and < 2 ** ${(E + 1) * 8 - 1}${k}`, new $t.ERR_OUT_OF_RANGE("value", st, s);
2014
+ let ot;
2015
+ throw h === 0 || h === BigInt(0) ? ot = `>= 0${k} and < 2${k} ** ${(E + 1) * 8}${k}` : ot = `>= -(2${k} ** ${(E + 1) * 8 - 1}${k}) and < 2 ** ${(E + 1) * 8 - 1}${k}`, new $t.ERR_OUT_OF_RANGE("value", ot, s);
2016
2016
  }
2017
- da(g, y, E);
2017
+ da(g, b, E);
2018
2018
  }
2019
2019
  function _e(s, h) {
2020
2020
  if (typeof s != "number") throw new $t.ERR_INVALID_ARG_TYPE(h, "number", s);
@@ -2032,11 +2032,11 @@ Yn.write = function(e, t, r, n, i, o) {
2032
2032
  h = h || 1 / 0;
2033
2033
  let c;
2034
2034
  const g = s.length;
2035
- let y = null;
2035
+ let b = null;
2036
2036
  const E = [];
2037
2037
  for (let k = 0; k < g; ++k) {
2038
2038
  if (c = s.charCodeAt(k), c > 55295 && c < 57344) {
2039
- if (!y) {
2039
+ if (!b) {
2040
2040
  if (c > 56319) {
2041
2041
  (h -= 3) > -1 && E.push(239, 191, 189);
2042
2042
  continue;
@@ -2044,16 +2044,16 @@ Yn.write = function(e, t, r, n, i, o) {
2044
2044
  (h -= 3) > -1 && E.push(239, 191, 189);
2045
2045
  continue;
2046
2046
  }
2047
- y = c;
2047
+ b = c;
2048
2048
  continue;
2049
2049
  }
2050
2050
  if (c < 56320) {
2051
- (h -= 3) > -1 && E.push(239, 191, 189), y = c;
2051
+ (h -= 3) > -1 && E.push(239, 191, 189), b = c;
2052
2052
  continue;
2053
2053
  }
2054
- c = (y - 55296 << 10 | c - 56320) + 65536;
2055
- } else y && (h -= 3) > -1 && E.push(239, 191, 189);
2056
- if (y = null, c < 128) {
2054
+ c = (b - 55296 << 10 | c - 56320) + 65536;
2055
+ } else b && (h -= 3) > -1 && E.push(239, 191, 189);
2056
+ if (b = null, c < 128) {
2057
2057
  if ((h -= 1) < 0) break;
2058
2058
  E.push(c);
2059
2059
  } else if (c < 2048) {
@@ -2075,18 +2075,18 @@ Yn.write = function(e, t, r, n, i, o) {
2075
2075
  return h;
2076
2076
  }
2077
2077
  function ba(s, h) {
2078
- let c, g, y;
2078
+ let c, g, b;
2079
2079
  const E = [];
2080
- for (let k = 0; k < s.length && !((h -= 2) < 0); ++k) c = s.charCodeAt(k), g = c >> 8, y = c % 256, E.push(y), E.push(g);
2080
+ for (let k = 0; k < s.length && !((h -= 2) < 0); ++k) c = s.charCodeAt(k), g = c >> 8, b = c % 256, E.push(b), E.push(g);
2081
2081
  return E;
2082
2082
  }
2083
- function Ei(s) {
2083
+ function bi(s) {
2084
2084
  return t.toByteArray(ga(s));
2085
2085
  }
2086
2086
  function br(s, h, c, g) {
2087
- let y;
2088
- for (y = 0; y < g && !(y + c >= h.length || y >= s.length); ++y) h[y + c] = s[y];
2089
- return y;
2087
+ let b;
2088
+ for (b = 0; b < g && !(b + c >= h.length || b >= s.length); ++b) h[b + c] = s[b];
2089
+ return b;
2090
2090
  }
2091
2091
  function Ft(s, h) {
2092
2092
  return s instanceof h || s != null && s.constructor != null && s.constructor.name != null && s.constructor.name === h.name;
@@ -2098,7 +2098,7 @@ Yn.write = function(e, t, r, n, i, o) {
2098
2098
  const s = "0123456789abcdef", h = new Array(256);
2099
2099
  for (let c = 0; c < 16; ++c) {
2100
2100
  const g = c * 16;
2101
- for (let y = 0; y < 16; ++y) h[g + y] = s[c] + s[y];
2101
+ for (let b = 0; b < 16; ++b) h[g + b] = s[c] + s[b];
2102
2102
  }
2103
2103
  return h;
2104
2104
  })();
@@ -2108,8 +2108,8 @@ Yn.write = function(e, t, r, n, i, o) {
2108
2108
  function Ea() {
2109
2109
  throw new Error("BigInt not supported");
2110
2110
  }
2111
- })(Rs);
2112
- var rh = Rs.Buffer;
2111
+ })(_s);
2112
+ var rh = _s.Buffer;
2113
2113
  function nh(e, t, r) {
2114
2114
  t = t || 4, r = r === void 0 ? !0 : r;
2115
2115
  const n = e.length;
@@ -2127,7 +2127,7 @@ function nh(e, t, r) {
2127
2127
  function ih(e) {
2128
2128
  return e > 2147483647 ? 5 : e > 8388607 ? 4 : e > 32767 ? 3 : e > 127 ? 2 : e > 0 ? 1 : 0;
2129
2129
  }
2130
- function Hs(e) {
2130
+ function Ns(e) {
2131
2131
  let t = Math.abs(e);
2132
2132
  const r = ih(t), n = rh.allocUnsafe(r), i = e < 0;
2133
2133
  for (let o = 0; o < r; ++o) n.writeUInt8(t & 255, o), t >>= 8;
@@ -2136,9 +2136,9 @@ function Hs(e) {
2136
2136
  var sh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2137
2137
  __proto__: null,
2138
2138
  decode: nh,
2139
- encode: Hs
2140
- }, Symbol.toStringTag, { value: "Module" })), On = Mt("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), Ml = Mt("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Ti = 21n * 10n ** 14n;
2141
- function Ls(e) {
2139
+ encode: Ns
2140
+ }, Symbol.toStringTag, { value: "Module" })), On = Mt("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), Ml = Mt("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Ai = 21n * 10n ** 14n;
2141
+ function Hs(e) {
2142
2142
  return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= 255;
2143
2143
  }
2144
2144
  function oh(e) {
@@ -2147,7 +2147,7 @@ function oh(e) {
2147
2147
  function ah(e, t) {
2148
2148
  return e instanceof Uint8Array && e.length === t;
2149
2149
  }
2150
- function Xn(e) {
2150
+ function Yn(e) {
2151
2151
  return Array.isArray(e);
2152
2152
  }
2153
2153
  function hh(e) {
@@ -2156,7 +2156,7 @@ function hh(e) {
2156
2156
  function uh(e) {
2157
2157
  return e instanceof Uint8Array && e.length === 32;
2158
2158
  }
2159
- function Cs(e) {
2159
+ function Ls(e) {
2160
2160
  return e instanceof Uint8Array && e.length === 20;
2161
2161
  }
2162
2162
  function fh(e) {
@@ -2171,7 +2171,7 @@ function ke(e) {
2171
2171
  const n = e.subarray(33);
2172
2172
  return Un(n) || De(n, On) >= 0 ? !1 : t === 4 || t === 6 || t === 7;
2173
2173
  }
2174
- function Vs(e) {
2174
+ function Cs(e) {
2175
2175
  if (!e || typeof e != "object") return !1;
2176
2176
  const t = e;
2177
2177
  return !(!("output" in t) || !(t.output instanceof Uint8Array) || t.version !== void 0 && (typeof t.version != "number" || (t.version & 254) !== t.version));
@@ -2179,7 +2179,7 @@ function Vs(e) {
2179
2179
  function Ue(e, t) {
2180
2180
  return e.length !== t.length ? !1 : e.every((r, n) => x(r, t[n]));
2181
2181
  }
2182
- function ki(e) {
2182
+ function Si(e) {
2183
2183
  if (!uh(e)) throw new TypeError(`Expected 32-byte Uint8Array, got ${e.length} bytes`);
2184
2184
  return e;
2185
2185
  }
@@ -2191,25 +2191,25 @@ function Or(e) {
2191
2191
  return e;
2192
2192
  }
2193
2193
  function lh(e) {
2194
- if (!Cs(e)) throw new TypeError(`Expected 20-byte Uint8Array, got ${e.length} bytes`);
2194
+ if (!Ls(e)) throw new TypeError(`Expected 20-byte Uint8Array, got ${e.length} bytes`);
2195
2195
  return e;
2196
2196
  }
2197
2197
  function Fl(e) {
2198
2198
  if (e < 0n) throw new RangeError(`Satoshi cannot be negative, got ${e}`);
2199
- if (e > Ti) throw new RangeError(`Satoshi exceeds maximum supply (${Ti}), got ${e}`);
2199
+ if (e > Ai) throw new RangeError(`Satoshi exceeds maximum supply (${Ai}), got ${e}`);
2200
2200
  return e;
2201
2201
  }
2202
- var Ui = new Uint8Array([0]);
2202
+ var Ti = new Uint8Array([0]);
2203
2203
  function Qr(e) {
2204
2204
  const t = e & -129;
2205
2205
  return t > 0 && t < 4;
2206
2206
  }
2207
- function Oi(e) {
2207
+ function ki(e) {
2208
2208
  let t = 0;
2209
2209
  for (; e[t] === 0; ) ++t;
2210
- return t === e.length ? Ui : (e = e.subarray(t), e[0] & 128 ? Bt([Ui, e]) : e);
2210
+ return t === e.length ? Ti : (e = e.subarray(t), e[0] & 128 ? Bt([Ti, e]) : e);
2211
2211
  }
2212
- function Pi(e) {
2212
+ function Ui(e) {
2213
2213
  e[0] === 0 && (e = e.subarray(1));
2214
2214
  const t = Et(32), r = Math.max(0, 32 - e.length);
2215
2215
  return t.set(e, r), t;
@@ -2219,55 +2219,55 @@ function ph(e) {
2219
2219
  if (!Qr(t)) throw new Error(`Invalid hashType ${t}`);
2220
2220
  const r = Wa(e.subarray(0, -1));
2221
2221
  return {
2222
- signature: Bt([Pi(r.r), Pi(r.s)]),
2222
+ signature: Bt([Ui(r.r), Ui(r.s)]),
2223
2223
  hashType: t
2224
2224
  };
2225
2225
  }
2226
2226
  function dh(e, t) {
2227
2227
  if (!ah(e, 64)) throw new TypeError("Expected signature to be a 64-byte Uint8Array");
2228
- if (!Ls(t)) throw new TypeError("Expected hashType to be a UInt8");
2228
+ if (!Hs(t)) throw new TypeError("Expected hashType to be a UInt8");
2229
2229
  if (!Qr(t)) throw new Error(`Invalid hashType ${t}`);
2230
2230
  const r = new Uint8Array([t]);
2231
- return Bt([Ga(Oi(e.subarray(0, 32)), Oi(e.subarray(32, 64))), r]);
2231
+ return Bt([Ga(ki(e.subarray(0, 32)), ki(e.subarray(32, 64))), r]);
2232
2232
  }
2233
2233
  var wh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2234
2234
  __proto__: null,
2235
2235
  decode: ph,
2236
2236
  encode: dh,
2237
2237
  isDefinedHashType: Qr
2238
- }, Symbol.toStringTag, { value: "Module" })), $s = j.OP_RESERVED;
2238
+ }, Symbol.toStringTag, { value: "Module" })), Vs = j.OP_RESERVED;
2239
2239
  function gh(e) {
2240
2240
  return oh(e) && (e === j.OP_0 || e >= j.OP_1 && e <= j.OP_16 || e === j.OP_1NEGATE);
2241
2241
  }
2242
- function Ks(e) {
2242
+ function $s(e) {
2243
2243
  return e instanceof Uint8Array ? !0 : gh(e);
2244
2244
  }
2245
2245
  function Jr(e) {
2246
- return Xn(e) && e.every(Ks);
2246
+ return Yn(e) && e.every($s);
2247
2247
  }
2248
- function Zn(e) {
2249
- return e.length - e.filter(Ks).length;
2248
+ function Xn(e) {
2249
+ return e.length - e.filter($s).length;
2250
2250
  }
2251
2251
  function Rr(e) {
2252
2252
  if (e.length === 0) return j.OP_0;
2253
2253
  if (e.length !== 1) return;
2254
2254
  const t = e[0];
2255
- if (t >= 1 && t <= 16) return $s + t;
2255
+ if (t >= 1 && t <= 16) return Vs + t;
2256
2256
  if (t === 129) return j.OP_1NEGATE;
2257
2257
  }
2258
- function Qn(e) {
2258
+ function Zn(e) {
2259
2259
  return e instanceof Uint8Array;
2260
2260
  }
2261
2261
  function yh(e) {
2262
- return Xn(e);
2262
+ return Yn(e);
2263
2263
  }
2264
2264
  function Nr(e) {
2265
2265
  return e instanceof Uint8Array;
2266
2266
  }
2267
2267
  function gt(e) {
2268
- if (Qn(e)) return e;
2269
- if (!Xn(e)) throw new TypeError("Expected an array");
2270
- const t = e.reduce((i, o) => Nr(o) ? o.length === 1 && Rr(o) !== void 0 ? i + 1 : i + _s(o.length) + o.length : i + 1, 0), r = new Uint8Array(t);
2268
+ if (Zn(e)) return e;
2269
+ if (!Yn(e)) throw new TypeError("Expected an array");
2270
+ const t = e.reduce((i, o) => Nr(o) ? o.length === 1 && Rr(o) !== void 0 ? i + 1 : i + Bs(o.length) + o.length : i + 1, 0), r = new Uint8Array(t);
2271
2271
  let n = 0;
2272
2272
  if (e.forEach((i) => {
2273
2273
  if (Nr(i)) {
@@ -2281,7 +2281,7 @@ function gt(e) {
2281
2281
  }), n !== r.length) throw new Error("Could not decode chunks");
2282
2282
  return r;
2283
2283
  }
2284
- function et(e) {
2284
+ function rt(e) {
2285
2285
  if (yh(e)) return e;
2286
2286
  if (!(e instanceof Uint8Array)) throw new TypeError("Expected a Uint8Array");
2287
2287
  const t = [];
@@ -2299,10 +2299,10 @@ function et(e) {
2299
2299
  }
2300
2300
  return t;
2301
2301
  }
2302
- function Ds(e) {
2302
+ function Ks(e) {
2303
2303
  let t;
2304
- if (Qn(e)) {
2305
- const r = et(e);
2304
+ if (Zn(e)) {
2305
+ const r = rt(e);
2306
2306
  if (!r) throw new Error("Could not convert invalid chunks to ASM");
2307
2307
  t = r;
2308
2308
  } else t = e;
@@ -2312,7 +2312,7 @@ function Ds(e) {
2312
2312
  if (n === void 0) return Yt(r);
2313
2313
  r = n;
2314
2314
  }
2315
- return Bs()[r];
2315
+ return xs()[r];
2316
2316
  }).join(" ");
2317
2317
  }
2318
2318
  function bh(e) {
@@ -2323,12 +2323,12 @@ function bh(e) {
2323
2323
  return Mt(t);
2324
2324
  }));
2325
2325
  }
2326
- function Ms(e) {
2327
- const t = Qn(e) ? et(e) : e;
2326
+ function Ds(e) {
2327
+ const t = Zn(e) ? rt(e) : e;
2328
2328
  if (!t || !Jr(t)) throw new TypeError("Expected push-only script");
2329
- return t.map((r) => Nr(r) ? r : r === j.OP_0 ? Et(0) : Hs(r - $s));
2329
+ return t.map((r) => Nr(r) ? r : r === j.OP_0 ? Et(0) : Ns(r - Vs));
2330
2330
  }
2331
- function Fs(e) {
2331
+ function Ms(e) {
2332
2332
  return ke(e);
2333
2333
  }
2334
2334
  function xe(e) {
@@ -2337,17 +2337,17 @@ function xe(e) {
2337
2337
  var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2338
2338
  __proto__: null,
2339
2339
  compile: gt,
2340
- countNonPushOnlyOPs: Zn,
2341
- decompile: et,
2340
+ countNonPushOnlyOPs: Xn,
2341
+ decompile: rt,
2342
2342
  fromASM: bh,
2343
- isCanonicalPubKey: Fs,
2343
+ isCanonicalPubKey: Ms,
2344
2344
  isCanonicalScriptSignature: xe,
2345
2345
  isPushOnly: Jr,
2346
2346
  number: mh,
2347
2347
  opcodes: j,
2348
2348
  signature: Ae,
2349
- toASM: Ds,
2350
- toStack: Ms
2349
+ toASM: Ks,
2350
+ toStack: Ds
2351
2351
  }, Symbol.toStringTag, { value: "Module" })), ft = {
2352
2352
  P2PK: "p2pk",
2353
2353
  P2PKH: "p2pkh",
@@ -2360,7 +2360,7 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
2360
2360
  P2OP: "p2op",
2361
2361
  Embed: "embed",
2362
2362
  ScriptRedeem: "scriptRedeem"
2363
- }, xi = j, Bi = 16, _i = 2, Ri = 40, Ws = class Qe {
2363
+ }, Oi = j, Pi = 16, xi = 2, Bi = 40, Fs = class Qe {
2364
2364
  static NAME = ft.P2OP;
2365
2365
  #t;
2366
2366
  #a;
@@ -2470,15 +2470,15 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
2470
2470
  const t = this.program;
2471
2471
  if (!t) return;
2472
2472
  if (!this.#t.bech32Opnet) throw new TypeError("Network does not support opnet");
2473
- const r = tt.bech32m.toWords(t);
2474
- return r.unshift(Bi), tt.bech32m.encode(this.#t.bech32Opnet, r);
2473
+ const r = et.bech32m.toWords(t);
2474
+ return r.unshift(Pi), et.bech32m.encode(this.#t.bech32Opnet, r);
2475
2475
  }
2476
2476
  #b() {
2477
2477
  if (this.#s) return this.#s;
2478
2478
  const t = this.#v();
2479
2479
  if (t) return t;
2480
2480
  if (this.#i) {
2481
- if (this.#i[0] !== xi.OP_16) throw new TypeError("Invalid P2OP script");
2481
+ if (this.#i[0] !== Oi.OP_16) throw new TypeError("Invalid P2OP script");
2482
2482
  let r = 1, n;
2483
2483
  const i = this.#i[1], o = this.#i[2];
2484
2484
  if (i !== void 0 && i < 76) n = i, r = 2;
@@ -2501,7 +2501,7 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
2501
2501
  #T() {
2502
2502
  if (this.#i) return this.#i;
2503
2503
  const t = this.program;
2504
- if (t) return gt([xi.OP_16, t]);
2504
+ if (t) return gt([Oi.OP_16, t]);
2505
2505
  }
2506
2506
  #k() {
2507
2507
  let t = Et(0);
@@ -2509,8 +2509,8 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
2509
2509
  const r = this.#E();
2510
2510
  if (!r) throw new TypeError("Invalid address");
2511
2511
  if (this.#t.bech32Opnet !== r.prefix) throw new TypeError("Invalid prefix or network mismatch");
2512
- if (r.version !== Bi) throw new TypeError("Invalid witness version for p2op");
2513
- if (r.data.length < _i || r.data.length > Ri) throw new TypeError("Invalid witness program length");
2512
+ if (r.version !== Pi) throw new TypeError("Invalid witness version for p2op");
2513
+ if (r.data.length < xi || r.data.length > Bi) throw new TypeError("Invalid witness program length");
2514
2514
  t = r.data;
2515
2515
  }
2516
2516
  if (this.#s) {
@@ -2527,14 +2527,14 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
2527
2527
  if (t.length > 0 && !x(t, r)) throw new TypeError("Program mismatch (output vs other source)");
2528
2528
  t = r;
2529
2529
  }
2530
- if (t.length < _i || t.length > Ri) throw new TypeError(`Witness program must be 2–40 bytes. Was ${t.length} bytes`);
2530
+ if (t.length < xi || t.length > Bi) throw new TypeError(`Witness program must be 2–40 bytes. Was ${t.length} bytes`);
2531
2531
  if (this.#r !== void 0 && this.#r !== t[0]) throw new TypeError("deploymentVersion mismatch");
2532
2532
  if (this.#n && !x(this.#n, t.subarray(1))) throw new TypeError("hash160 mismatch");
2533
2533
  }
2534
2534
  };
2535
- function Jn(e, t) {
2535
+ function Qn(e, t) {
2536
2536
  if (!e.address && !e.output && !e.program && (typeof e.deploymentVersion > "u" || !e.hash160)) throw new TypeError("At least one of address, output or program must be provided");
2537
- const r = new Ws({
2537
+ const r = new Fs({
2538
2538
  address: e.address,
2539
2539
  program: e.program,
2540
2540
  deploymentVersion: e.deploymentVersion,
@@ -2550,7 +2550,7 @@ var qe = /* @__PURE__ */ Uint32Array.from([
2550
2550
  2562383102,
2551
2551
  271733878,
2552
2552
  3285377520
2553
- ]), ae = /* @__PURE__ */ new Uint32Array(80), vh = class extends Gn {
2553
+ ]), ae = /* @__PURE__ */ new Uint32Array(80), vh = class extends Wn {
2554
2554
  A = qe[0] | 0;
2555
2555
  B = qe[1] | 0;
2556
2556
  C = qe[2] | 0;
@@ -2578,7 +2578,7 @@ var qe = /* @__PURE__ */ Uint32Array.from([
2578
2578
  let { A: r, B: n, C: i, D: o, E: a } = this;
2579
2579
  for (let f = 0; f < 80; f++) {
2580
2580
  let l, p;
2581
- f < 20 ? (l = Ps(n, i, o), p = 1518500249) : f < 40 ? (l = n ^ i ^ o, p = 1859775393) : f < 60 ? (l = xs(n, i, o), p = 2400959708) : (l = n ^ i ^ o, p = 3395469782);
2581
+ f < 20 ? (l = Os(n, i, o), p = 1518500249) : f < 40 ? (l = n ^ i ^ o, p = 1859775393) : f < 60 ? (l = Ps(n, i, o), p = 2400959708) : (l = n ^ i ^ o, p = 3395469782);
2582
2582
  const u = Ee(r, 5) + l + a + p + ae[f] | 0;
2583
2583
  a = o, o = i, i = Ee(n, 30), n = r, r = u;
2584
2584
  }
@@ -2590,7 +2590,7 @@ var qe = /* @__PURE__ */ Uint32Array.from([
2590
2590
  destroy() {
2591
2591
  this.set(0, 0, 0, 0, 0), Te(this.buffer);
2592
2592
  }
2593
- }, Ih = /* @__PURE__ */ Wn(() => new vh()), Ah = /* @__PURE__ */ Uint8Array.from([
2593
+ }, Ih = /* @__PURE__ */ Fn(() => new vh()), Ah = /* @__PURE__ */ Uint8Array.from([
2594
2594
  7,
2595
2595
  4,
2596
2596
  13,
@@ -2607,11 +2607,11 @@ var qe = /* @__PURE__ */ Uint32Array.from([
2607
2607
  14,
2608
2608
  11,
2609
2609
  8
2610
- ]), Gs = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), Sh = Gs.map((e) => (9 * e + 5) % 16), js = /* @__PURE__ */ (() => {
2611
- const e = [[Gs], [Sh]];
2610
+ ]), Ws = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), Sh = Ws.map((e) => (9 * e + 5) % 16), Gs = /* @__PURE__ */ (() => {
2611
+ const e = [[Ws], [Sh]];
2612
2612
  for (let t = 0; t < 4; t++) for (let r of e) r.push(r[t].map((n) => Ah[n]));
2613
2613
  return e;
2614
- })(), zs = js[0], qs = js[1], Ys = /* @__PURE__ */ [
2614
+ })(), js = Gs[0], zs = Gs[1], qs = /* @__PURE__ */ [
2615
2615
  [
2616
2616
  11,
2617
2617
  14,
@@ -2702,7 +2702,7 @@ var qe = /* @__PURE__ */ Uint32Array.from([
2702
2702
  5,
2703
2703
  5
2704
2704
  ]
2705
- ].map((e) => Uint8Array.from(e)), Th = /* @__PURE__ */ zs.map((e, t) => e.map((r) => Ys[t][r])), kh = /* @__PURE__ */ qs.map((e, t) => e.map((r) => Ys[t][r])), Uh = /* @__PURE__ */ Uint32Array.from([
2705
+ ].map((e) => Uint8Array.from(e)), Th = /* @__PURE__ */ js.map((e, t) => e.map((r) => qs[t][r])), kh = /* @__PURE__ */ zs.map((e, t) => e.map((r) => qs[t][r])), Uh = /* @__PURE__ */ Uint32Array.from([
2706
2706
  0,
2707
2707
  1518500249,
2708
2708
  1859775393,
@@ -2715,10 +2715,10 @@ var qe = /* @__PURE__ */ Uint32Array.from([
2715
2715
  2053994217,
2716
2716
  0
2717
2717
  ]);
2718
- function Ni(e, t, r, n) {
2718
+ function _i(e, t, r, n) {
2719
2719
  return e === 0 ? t ^ r ^ n : e === 1 ? t & r | ~t & n : e === 2 ? (t | ~r) ^ n : e === 3 ? t & n | r & ~n : t ^ (r | ~n);
2720
2720
  }
2721
- var Er = /* @__PURE__ */ new Uint32Array(16), Ph = class extends Gn {
2721
+ var Er = /* @__PURE__ */ new Uint32Array(16), Ph = class extends Wn {
2722
2722
  h0 = 1732584193;
2723
2723
  h1 = -271733879;
2724
2724
  h2 = -1732584194;
@@ -2744,13 +2744,13 @@ var Er = /* @__PURE__ */ new Uint32Array(16), Ph = class extends Gn {
2744
2744
  for (let w = 0; w < 16; w++, t += 4) Er[w] = e.getUint32(t, !0);
2745
2745
  let r = this.h0 | 0, n = r, i = this.h1 | 0, o = i, a = this.h2 | 0, f = a, l = this.h3 | 0, p = l, u = this.h4 | 0, d = u;
2746
2746
  for (let w = 0; w < 5; w++) {
2747
- const b = 4 - w, m = Uh[w], v = Oh[w], I = zs[w], P = qs[w], S = Th[w], _ = kh[w];
2747
+ const y = 4 - w, m = Uh[w], v = Oh[w], I = js[w], P = zs[w], S = Th[w], _ = kh[w];
2748
2748
  for (let O = 0; O < 16; O++) {
2749
- const z = Ee(r + Ni(w, i, a, l) + Er[I[O]] + m, S[O]) + u | 0;
2749
+ const z = Ee(r + _i(w, i, a, l) + Er[I[O]] + m, S[O]) + u | 0;
2750
2750
  r = u, u = l, l = Ee(a, 10) | 0, a = i, i = z;
2751
2751
  }
2752
2752
  for (let O = 0; O < 16; O++) {
2753
- const z = Ee(n + Ni(b, o, f, p) + Er[P[O]] + v, _[O]) + d | 0;
2753
+ const z = Ee(n + _i(y, o, f, p) + Er[P[O]] + v, _[O]) + d | 0;
2754
2754
  n = d, d = p, p = Ee(f, 10) | 0, f = o, o = z;
2755
2755
  }
2756
2756
  }
@@ -2762,9 +2762,9 @@ var Er = /* @__PURE__ */ new Uint32Array(16), Ph = class extends Gn {
2762
2762
  destroy() {
2763
2763
  this.destroyed = !0, Te(this.buffer), this.set(0, 0, 0, 0, 0);
2764
2764
  }
2765
- }, Xs = /* @__PURE__ */ Wn(() => new Ph());
2765
+ }, Ys = /* @__PURE__ */ Fn(() => new Ph());
2766
2766
  function xh(e) {
2767
- return Xs(e);
2767
+ return Ys(e);
2768
2768
  }
2769
2769
  function Bh(e) {
2770
2770
  return Ih(e);
@@ -2773,7 +2773,7 @@ function It(e) {
2773
2773
  return Ke(e);
2774
2774
  }
2775
2775
  function St(e) {
2776
- return Xs(Ke(e));
2776
+ return Ys(Ke(e));
2777
2777
  }
2778
2778
  function le(e) {
2779
2779
  return Ke(Ke(e));
@@ -2788,7 +2788,7 @@ var _h = [
2788
2788
  "TapTweak",
2789
2789
  "KeyAgg list",
2790
2790
  "KeyAgg coefficient"
2791
- ], Zs = {
2791
+ ], Xs = {
2792
2792
  "BIP0340/challenge": new Uint8Array([
2793
2793
  123,
2794
2794
  181,
@@ -3385,11 +3385,11 @@ var _h = [
3385
3385
  ])
3386
3386
  };
3387
3387
  function lr(e, t) {
3388
- return It(Bt([Zs[e], t]));
3388
+ return It(Bt([Xs[e], t]));
3389
3389
  }
3390
3390
  var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3391
3391
  __proto__: null,
3392
- TAGGED_HASH_PREFIXES: Zs,
3392
+ TAGGED_HASH_PREFIXES: Xs,
3393
3393
  TAGS: _h,
3394
3394
  hash160: St,
3395
3395
  hash256: le,
@@ -3397,7 +3397,7 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3397
3397
  sha1: Bh,
3398
3398
  sha256: It,
3399
3399
  taggedHash: lr
3400
- }, Symbol.toStringTag, { value: "Module" })), Qs = {
3400
+ }, Symbol.toStringTag, { value: "Module" })), Zs = {
3401
3401
  p: 115792089237316195423570985008687907853269984665640564039457584007908834671663n,
3402
3402
  n: 115792089237316195423570985008687907852837564279074904382605163141518161494337n,
3403
3403
  h: 1n,
@@ -3405,29 +3405,29 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3405
3405
  b: 7n,
3406
3406
  Gx: 55066263022277343669578718895168534326250603453777594175500187360389116729240n,
3407
3407
  Gy: 32670510020758816978083085130507043184471273380659243275938904335757337482424n
3408
- }, { p: Se, n: Nh, Gx: Hh, Gy: Lh, b: Js } = Qs, Pn = 32, ti = 64, Ch = {
3409
- publicKey: Pn + 1,
3410
- publicKeyUncompressed: ti + 1
3408
+ }, { p: Se, n: Nh, Gx: Hh, Gy: Lh, b: Qs } = Zs, Ri = 32, Js = 64, Ch = {
3409
+ publicKey: 33,
3410
+ publicKeyUncompressed: 65
3411
3411
  }, Vh = (...e) => {
3412
3412
  "captureStackTrace" in Error && typeof Error.captureStackTrace == "function" && Error.captureStackTrace(...e);
3413
3413
  }, xt = (e = "") => {
3414
3414
  const t = new Error(e);
3415
3415
  throw Vh(t, xt), t;
3416
- }, $h = (e) => typeof e == "bigint", Kh = (e) => typeof e == "string", Dh = (e) => e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array", ei = (e, t, r = "") => {
3416
+ }, $h = (e) => typeof e == "bigint", Kh = (e) => typeof e == "string", Dh = (e) => e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array", Jn = (e, t, r = "") => {
3417
3417
  const n = Dh(e), i = e?.length, o = t !== void 0;
3418
3418
  if (!n || o && i !== t) {
3419
3419
  const a = r && `"${r}" `, f = o ? ` of length ${t}` : "", l = n ? `length=${i}` : `type=${typeof e}`;
3420
3420
  xt(a + "expected Uint8Array" + f + ", got " + l);
3421
3421
  }
3422
3422
  return e;
3423
- }, to = (e) => new Uint8Array(e), eo = (e, t) => e.toString(16).padStart(t, "0"), ro = (e) => Array.from(ei(e)).map((t) => eo(t, 2)).join(""), Jt = {
3423
+ }, to = (e) => new Uint8Array(e), eo = (e, t) => e.toString(16).padStart(t, "0"), ro = (e) => Array.from(Jn(e)).map((t) => eo(t, 2)).join(""), Jt = {
3424
3424
  _0: 48,
3425
3425
  _9: 57,
3426
3426
  A: 65,
3427
3427
  F: 70,
3428
3428
  a: 97,
3429
3429
  f: 102
3430
- }, Hi = (e) => {
3430
+ }, Ni = (e) => {
3431
3431
  if (e >= Jt._0 && e <= Jt._9) return e - Jt._0;
3432
3432
  if (e >= Jt.A && e <= Jt.F) return e - (Jt.A - 10);
3433
3433
  if (e >= Jt.a && e <= Jt.f) return e - (Jt.a - 10);
@@ -3438,13 +3438,13 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3438
3438
  if (r % 2) return xt(t);
3439
3439
  const i = to(n);
3440
3440
  for (let o = 0, a = 0; o < n; o++, a += 2) {
3441
- const f = Hi(e.charCodeAt(a)), l = Hi(e.charCodeAt(a + 1));
3441
+ const f = Ni(e.charCodeAt(a)), l = Ni(e.charCodeAt(a + 1));
3442
3442
  if (f === void 0 || l === void 0) return xt(t);
3443
3443
  i[o] = f * 16 + l;
3444
3444
  }
3445
3445
  return i;
3446
- }, Li = (...e) => {
3447
- const t = to(e.reduce((n, i) => n + ei(i).length, 0));
3446
+ }, Hi = (...e) => {
3447
+ const t = to(e.reduce((n, i) => n + Jn(i).length, 0));
3448
3448
  let r = 0;
3449
3449
  return e.forEach((n) => {
3450
3450
  t.set(n, r), r += n.length;
@@ -3460,7 +3460,7 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3460
3460
  n = r, r = f, i = o, o = l;
3461
3461
  }
3462
3462
  return n === 1n ? N(i, t) : xt("no inverse");
3463
- }, pn = (e) => e instanceof Ge ? e : xt("Point expected"), io = (e) => N(N(e * e) * e + Js), Ci = (e) => tn(e, 0n, Se), Pr = (e) => tn(e, 1n, Se), Fh = (e) => tn(e, 1n, Nh), xn = (e) => (e & 1n) === 0n, so = (e) => Uint8Array.of(e), Wh = (e) => so(xn(e) ? 2 : 3), Gh = (e) => {
3463
+ }, pn = (e) => e instanceof Ge ? e : xt("Point expected"), io = (e) => N(N(e * e) * e + Qs), Li = (e) => tn(e, 0n, Se), Pr = (e) => tn(e, 1n, Se), Fh = (e) => tn(e, 1n, Nh), Pn = (e) => (e & 1n) === 0n, so = (e) => Uint8Array.of(e), Wh = (e) => so(Pn(e) ? 2 : 3), Gh = (e) => {
3464
3464
  const t = io(Pr(e));
3465
3465
  let r = 1n;
3466
3466
  for (let n = t, i = (Se + 1n) / 4n; i > 0n; i >>= 1n) i & 1n && (r = r * n % Se), n = n * n % Se;
@@ -3472,26 +3472,26 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3472
3472
  Y;
3473
3473
  Z;
3474
3474
  constructor(t, r, n) {
3475
- this.X = Ci(t), this.Y = Pr(r), this.Z = Ci(n), Object.freeze(this);
3475
+ this.X = Li(t), this.Y = Pr(r), this.Z = Li(n), Object.freeze(this);
3476
3476
  }
3477
3477
  static CURVE() {
3478
- return Qs;
3478
+ return Zs;
3479
3479
  }
3480
3480
  static fromAffine(t) {
3481
3481
  const { x: r, y: n } = t;
3482
3482
  return r === 0n && n === 0n ? me : new be(r, n, 1n);
3483
3483
  }
3484
3484
  static fromBytes(t) {
3485
- ei(t);
3485
+ Jn(t);
3486
3486
  const { publicKey: r, publicKeyUncompressed: n } = Ch;
3487
3487
  let i;
3488
- const o = t.length, a = t[0], f = t.subarray(1), l = Vi(f, 0, Pn);
3488
+ const o = t.length, a = t[0], f = t.subarray(1), l = Ci(f, 0, Ri);
3489
3489
  if (o === r && (a === 2 || a === 3)) {
3490
3490
  let p = Gh(l);
3491
- const u = xn(p);
3492
- xn(Hr(a)) !== u && (p = N(-p)), i = new be(l, p, 1n);
3491
+ const u = Pn(p);
3492
+ Pn(Hr(a)) !== u && (p = N(-p)), i = new be(l, p, 1n);
3493
3493
  }
3494
- return o === n && a === 4 && (i = new be(l, Vi(f, Pn, ti), 1n)), i ? i.assertValidity() : xt("bad point: not on curve");
3494
+ return o === n && a === 4 && (i = new be(l, Ci(f, Ri, Js), 1n)), i ? i.assertValidity() : xt("bad point: not on curve");
3495
3495
  }
3496
3496
  static fromHex(t) {
3497
3497
  return be.fromBytes(no(t));
@@ -3516,13 +3516,13 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3516
3516
  return this.add(this);
3517
3517
  }
3518
3518
  add(t) {
3519
- const { X: r, Y: n, Z: i } = this, { X: o, Y: a, Z: f } = pn(t), l = 0n, p = Js;
3519
+ const { X: r, Y: n, Z: i } = this, { X: o, Y: a, Z: f } = pn(t), l = 0n, p = Qs;
3520
3520
  let u = 0n, d = 0n, w = 0n;
3521
- const b = N(p * 3n);
3521
+ const y = N(p * 3n);
3522
3522
  let m = N(r * o), v = N(n * a), I = N(i * f), P = N(r + n), S = N(o + a);
3523
3523
  P = N(P * S), S = N(m + v), P = N(P - S), S = N(r + i);
3524
3524
  let _ = N(o + f);
3525
- return S = N(S * _), _ = N(m + I), S = N(S - _), _ = N(n + i), u = N(a + f), _ = N(_ * u), u = N(v + I), _ = N(_ - u), w = N(l * S), u = N(b * I), w = N(u + w), u = N(v - w), w = N(v + w), d = N(u * w), v = N(m + m), v = N(v + m), I = N(l * I), S = N(b * S), v = N(v + I), I = N(m - I), I = N(l * I), S = N(S + I), m = N(v * S), d = N(d + m), m = N(_ * S), u = N(P * u), u = N(u - m), m = N(P * v), w = N(_ * w), w = N(w + m), new be(u, d, w);
3525
+ return S = N(S * _), _ = N(m + I), S = N(S - _), _ = N(n + i), u = N(a + f), _ = N(_ * u), u = N(v + I), _ = N(_ - u), w = N(l * S), u = N(y * I), w = N(u + w), u = N(v - w), w = N(v + w), d = N(u * w), v = N(m + m), v = N(v + m), I = N(l * I), S = N(y * S), v = N(v + I), I = N(m - I), I = N(l * I), S = N(S + I), m = N(v * S), d = N(d + m), m = N(_ * S), u = N(P * u), u = N(u - m), m = N(P * v), w = N(_ * w), w = N(w + m), new be(u, d, w);
3526
3526
  }
3527
3527
  subtract(t) {
3528
3528
  return this.add(pn(t).negate());
@@ -3559,8 +3559,8 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3559
3559
  return Pr(t), Pr(r), N(r * r) === io(t) ? this : xt("bad point: not on curve");
3560
3560
  }
3561
3561
  toBytes(t = !0) {
3562
- const { x: r, y: n } = this.assertValidity().toAffine(), i = $i(r);
3563
- return t ? Li(Wh(n), i) : Li(so(4), i, $i(n));
3562
+ const { x: r, y: n } = this.assertValidity().toAffine(), i = Vi(r);
3563
+ return t ? Hi(Wh(n), i) : Hi(so(4), i, Vi(n));
3564
3564
  }
3565
3565
  toHex(t) {
3566
3566
  return ro(this.toBytes(t));
@@ -3568,38 +3568,38 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3568
3568
  }, ar = new Ge(Hh, Lh, 1n), me = new Ge(0n, 1n, 0n);
3569
3569
  Ge.BASE = ar;
3570
3570
  Ge.ZERO = me;
3571
- var jh = (e) => Hr("0x" + (ro(e) || "0")), Vi = (e, t, r) => jh(e.subarray(t, r)), zh = 2n ** 256n, $i = (e) => no(eo(tn(e, 0n, zh), ti)), Lr = 8, oo = Math.ceil(256 / Lr) + 1, Bn = 2 ** (Lr - 1), qh = () => {
3571
+ var jh = (e) => Hr("0x" + (ro(e) || "0")), Ci = (e, t, r) => jh(e.subarray(t, r)), zh = 2n ** 256n, Vi = (e) => no(eo(tn(e, 0n, zh), Js)), Lr = 8, oo = Math.ceil(256 / Lr) + 1, xn = 2 ** (Lr - 1), qh = () => {
3572
3572
  const e = [];
3573
3573
  let t = ar, r = t;
3574
3574
  for (let n = 0; n < oo; n++) {
3575
3575
  r = t, e.push(r);
3576
- for (let i = 1; i < Bn; i++) r = r.add(t), e.push(r);
3576
+ for (let i = 1; i < xn; i++) r = r.add(t), e.push(r);
3577
3577
  t = r.double();
3578
3578
  }
3579
3579
  return e;
3580
- }, Ki, Di = (e, t) => {
3580
+ }, $i, Ki = (e, t) => {
3581
3581
  const r = t.negate();
3582
3582
  return e ? r : t;
3583
3583
  }, Yh = (e) => {
3584
- const t = Ki || (Ki = qh());
3584
+ const t = $i || ($i = qh());
3585
3585
  let r = me, n = ar;
3586
3586
  const i = 2 ** Lr, o = i, a = Hr(i - 1), f = Hr(Lr);
3587
3587
  for (let l = 0; l < oo; l++) {
3588
3588
  let p = Number(e & a);
3589
- e >>= f, p > Bn && (p -= o, e += 1n);
3590
- const u = l * Bn, d = u, w = u + Math.abs(p) - 1, b = l % 2 !== 0, m = p < 0;
3591
- p === 0 ? n = n.add(Di(b, t[d])) : r = r.add(Di(m, t[w]));
3589
+ e >>= f, p > xn && (p -= o, e += 1n);
3590
+ const u = l * xn, d = u, w = u + Math.abs(p) - 1, y = l % 2 !== 0, m = p < 0;
3591
+ p === 0 ? n = n.add(Ki(y, t[d])) : r = r.add(Ki(m, t[w]));
3592
3592
  }
3593
3593
  return e !== 0n && xt("invalid wnaf"), {
3594
3594
  p: r,
3595
3595
  f: n
3596
3596
  };
3597
3597
  }, Ce = (e) => e.length === 32 ? e : e.subarray(1, 33);
3598
- function Mi(e) {
3598
+ function Di(e) {
3599
3599
  let t = e.toString(16);
3600
3600
  return t = t.padStart(64, "0"), t.length > 64 && (t = t.slice(-64)), Mt(t);
3601
3601
  }
3602
- function _n(e) {
3602
+ function Bn(e) {
3603
3603
  if (e.length === 32) return;
3604
3604
  if (![33, 65].includes(e.length)) {
3605
3605
  console.warn(`Unsupported key length=${e.length}. Must be 33 (compressed) or 65 (uncompressed).`);
@@ -3611,7 +3611,7 @@ function _n(e) {
3611
3611
  } catch (a) {
3612
3612
  throw new Error("Invalid secp256k1 public key bytes. Cannot parse.", { cause: a });
3613
3613
  }
3614
- const r = Mi(t.x), n = Mi(t.y), i = t.y % 2n === 0n ? 6 : 7, o = Et(65);
3614
+ const r = Di(t.x), n = Di(t.y), i = t.y % 2n === 0n ? 6 : 7, o = Et(65);
3615
3615
  return o[0] = i, o.set(r, 1), o.set(n, 33), {
3616
3616
  hybrid: o,
3617
3617
  uncompressed: Bt([
@@ -3732,7 +3732,7 @@ var he = j, ao = class Je {
3732
3732
  #U() {
3733
3733
  if (!this.#T) {
3734
3734
  if (this.#e) {
3735
- const t = new Uint8Array(zn(this.#e));
3735
+ const t = new Uint8Array(jn(this.#e));
3736
3736
  this.#A = {
3737
3737
  version: t[0],
3738
3738
  hash: t.subarray(1)
@@ -3743,14 +3743,14 @@ var he = j, ao = class Je {
3743
3743
  return this.#A;
3744
3744
  }
3745
3745
  #O() {
3746
- return this.#P || (this.#o && (this.#k = et(this.#o) ?? void 0), this.#P = !0), this.#k;
3746
+ return this.#P || (this.#o && (this.#k = rt(this.#o) ?? void 0), this.#P = !0), this.#k;
3747
3747
  }
3748
3748
  #x() {
3749
3749
  if (this.#e) return this.#e;
3750
3750
  const t = this.hash;
3751
3751
  if (!t) return;
3752
3752
  const r = Et(21);
3753
- return r[0] = this.#t.pubKeyHash, r.set(t, 1), jn(r);
3753
+ return r[0] = this.#t.pubKeyHash, r.set(t, 1), Gn(r);
3754
3754
  }
3755
3755
  #B() {
3756
3756
  if (this.#s) return this.#s;
@@ -3789,7 +3789,7 @@ var he = j, ao = class Je {
3789
3789
  if (!this.#r || !this.#n) return;
3790
3790
  let t = this.#r;
3791
3791
  if (this.#h || this.#f) {
3792
- const r = _n(this.#r);
3792
+ const r = Bn(this.#r);
3793
3793
  r && (this.#f ? t = r.uncompressed : t = r.hybrid);
3794
3794
  }
3795
3795
  return gt([this.#n, t]);
@@ -3798,7 +3798,7 @@ var he = j, ao = class Je {
3798
3798
  if (this.input) return [];
3799
3799
  }
3800
3800
  #C() {
3801
- let t = new Uint8Array(0);
3801
+ let t = /* @__PURE__ */ new Uint8Array(0);
3802
3802
  if (this.#e) {
3803
3803
  const r = this.#U();
3804
3804
  if (!r) throw new TypeError("Invalid address");
@@ -3820,7 +3820,7 @@ var he = j, ao = class Je {
3820
3820
  const r = St(this.#r);
3821
3821
  let n = t.length > 0 && !x(t, r);
3822
3822
  if (n && (this.#r.length === 33 && (this.#r[0] === 2 || this.#r[0] === 3) || this.#r.length === 65 && this.#r[0] === 4)) {
3823
- const i = _n(this.#r);
3823
+ const i = Bn(this.#r);
3824
3824
  if (i) {
3825
3825
  const o = St(i.uncompressed);
3826
3826
  if (x(t, o)) n = !1, this.#f = !0;
@@ -3959,7 +3959,7 @@ var Ye = j, ho = class tr {
3959
3959
  #k() {
3960
3960
  if (!this.#I) {
3961
3961
  if (this.#e) {
3962
- const t = new Uint8Array(zn(this.#e));
3962
+ const t = new Uint8Array(jn(this.#e));
3963
3963
  this.#v = {
3964
3964
  version: t[0],
3965
3965
  hash: t.subarray(1)
@@ -3970,7 +3970,7 @@ var Ye = j, ho = class tr {
3970
3970
  return this.#v;
3971
3971
  }
3972
3972
  #P() {
3973
- return this.#S || (this.#n && (this.#b = et(this.#n) ?? void 0), this.#S = !0), this.#b;
3973
+ return this.#S || (this.#n && (this.#b = rt(this.#n) ?? void 0), this.#S = !0), this.#b;
3974
3974
  }
3975
3975
  #U() {
3976
3976
  if (!this.#T) {
@@ -3979,7 +3979,7 @@ var Ye = j, ho = class tr {
3979
3979
  const r = t[t.length - 1];
3980
3980
  this.#A = {
3981
3981
  network: this.#t,
3982
- output: r === Ye.OP_FALSE ? new Uint8Array(0) : r,
3982
+ output: r === Ye.OP_FALSE ? /* @__PURE__ */ new Uint8Array(0) : r,
3983
3983
  input: gt(t.slice(0, -1)),
3984
3984
  witness: this.#o || []
3985
3985
  };
@@ -3993,7 +3993,7 @@ var Ye = j, ho = class tr {
3993
3993
  const t = this.hash;
3994
3994
  if (!t) return;
3995
3995
  const r = Et(21);
3996
- return r[0] = this.#t.scriptHash, r.set(t, 1), jn(r);
3996
+ return r[0] = this.#t.scriptHash, r.set(t, 1), Gn(r);
3997
3997
  }
3998
3998
  #x() {
3999
3999
  if (this.#s) return this.#s;
@@ -4014,7 +4014,7 @@ var Ye = j, ho = class tr {
4014
4014
  #_() {
4015
4015
  if (this.#n) return this.#n;
4016
4016
  const t = this.#i;
4017
- if (!(!t || !t.input || !t.output)) return gt([].concat(et(t.input), t.output));
4017
+ if (!(!t || !t.input || !t.output)) return gt([].concat(rt(t.input), t.output));
4018
4018
  }
4019
4019
  #R() {
4020
4020
  if (this.#i) return this.#i;
@@ -4028,21 +4028,21 @@ var Ye = j, ho = class tr {
4028
4028
  }
4029
4029
  #H(t) {
4030
4030
  if (t.output) {
4031
- const r = et(t.output);
4031
+ const r = rt(t.output);
4032
4032
  if (!r || r.length < 1) throw new TypeError("Redeem.output too short");
4033
4033
  if (t.output.byteLength > 520) throw new TypeError("Redeem.output unspendable if larger than 520 bytes");
4034
- if (Zn(r) > 201) throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
4034
+ if (Xn(r) > 201) throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
4035
4035
  }
4036
4036
  if (t.input) {
4037
4037
  const r = t.input.length > 0, n = t.witness && t.witness.length > 0;
4038
4038
  if (!r && !n) throw new TypeError("Empty input");
4039
4039
  if (r && n) throw new TypeError("Input and witness provided");
4040
- if (r && !Jr(et(t.input)))
4040
+ if (r && !Jr(rt(t.input)))
4041
4041
  throw new TypeError("Non push-only scriptSig");
4042
4042
  }
4043
4043
  }
4044
4044
  #L() {
4045
- let t = new Uint8Array(0);
4045
+ let t = /* @__PURE__ */ new Uint8Array(0);
4046
4046
  if (this.#e) {
4047
4047
  const r = this.#k();
4048
4048
  if (!r) throw new TypeError("Invalid address");
@@ -4106,13 +4106,13 @@ function Xh(e) {
4106
4106
  if (t % 2 !== 0) throw new TypeError("fromHexInternal: odd-length hex string");
4107
4107
  const r = new Uint8Array(t / 2);
4108
4108
  for (let n = 0; n < t; n += 2) {
4109
- const i = Fi(e.charCodeAt(n)), o = Fi(e.charCodeAt(n + 1));
4109
+ const i = Mi(e.charCodeAt(n)), o = Mi(e.charCodeAt(n + 1));
4110
4110
  if (i === -1 || o === -1) throw new TypeError("fromHexInternal: invalid hex character");
4111
4111
  r[n >> 1] = i << 4 | o;
4112
4112
  }
4113
4113
  return r;
4114
4114
  }
4115
- function Fi(e) {
4115
+ function Mi(e) {
4116
4116
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
4117
4117
  }
4118
4118
  function Ut(e, t) {
@@ -4120,7 +4120,7 @@ function Ut(e, t) {
4120
4120
  for (let r = 0; r < e.length; r++) if (e[r] !== t[r]) return !1;
4121
4121
  return !0;
4122
4122
  }
4123
- function ri(e) {
4123
+ function ti(e) {
4124
4124
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
4125
4125
  }
4126
4126
  function Oe(e, t = "") {
@@ -4130,7 +4130,7 @@ function Oe(e, t = "") {
4130
4130
  }
4131
4131
  }
4132
4132
  function ut(e, t, r = "") {
4133
- const n = ri(e), i = e?.length, o = t !== void 0;
4133
+ const n = ti(e), i = e?.length, o = t !== void 0;
4134
4134
  if (!n || o && i !== t) {
4135
4135
  const a = r && `"${r}" `, f = o ? ` of length ${t}` : "", l = n ? `length=${i}` : `type=${typeof e}`;
4136
4136
  throw new Error(a + "expected Uint8Array" + f + ", got " + l);
@@ -4174,7 +4174,7 @@ var te = {
4174
4174
  a: 97,
4175
4175
  f: 102
4176
4176
  };
4177
- function Wi(e) {
4177
+ function Fi(e) {
4178
4178
  if (e >= te._0 && e <= te._9) return e - te._0;
4179
4179
  if (e >= te.A && e <= te.F) return e - (te.A - 10);
4180
4180
  if (e >= te.a && e <= te.f) return e - (te.a - 10);
@@ -4186,7 +4186,7 @@ function $r(e) {
4186
4186
  if (t % 2) throw new Error("hex string expected, got unpadded hex of length " + t);
4187
4187
  const n = new Uint8Array(r);
4188
4188
  for (let i = 0, o = 0; i < r; i++, o += 2) {
4189
- const a = Wi(e.charCodeAt(o)), f = Wi(e.charCodeAt(o + 1));
4189
+ const a = Fi(e.charCodeAt(o)), f = Fi(e.charCodeAt(o + 1));
4190
4190
  if (a === void 0 || f === void 0) {
4191
4191
  const l = e[o] + e[o + 1];
4192
4192
  throw new Error('hex string expected, got non-hex character "' + l + '" at index ' + o);
@@ -4388,13 +4388,13 @@ var nu = class {
4388
4388
  process(e, t) {
4389
4389
  for (let u = 0; u < 16; u++, t += 4) fe[u] = e.getUint32(t, !1);
4390
4390
  for (let u = 16; u < 64; u++) {
4391
- const d = fe[u - 15], w = fe[u - 2], b = Gt(d, 7) ^ Gt(d, 18) ^ d >>> 3;
4392
- fe[u] = (Gt(w, 17) ^ Gt(w, 19) ^ w >>> 10) + fe[u - 7] + b + fe[u - 16] | 0;
4391
+ const d = fe[u - 15], w = fe[u - 2], y = Gt(d, 7) ^ Gt(d, 18) ^ d >>> 3, m = Gt(w, 17) ^ Gt(w, 19) ^ w >>> 10;
4392
+ fe[u] = m + fe[u - 7] + y + fe[u - 16] | 0;
4393
4393
  }
4394
4394
  let { A: r, B: n, C: i, D: o, E: a, F: f, G: l, H: p } = this;
4395
4395
  for (let u = 0; u < 64; u++) {
4396
- const d = Gt(a, 6) ^ Gt(a, 11) ^ Gt(a, 25), w = p + d + eu(a, f, l) + iu[u] + fe[u] | 0, b = (Gt(r, 2) ^ Gt(r, 13) ^ Gt(r, 22)) + ru(r, n, i) | 0;
4397
- p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w + b | 0;
4396
+ const d = Gt(a, 6) ^ Gt(a, 11) ^ Gt(a, 25), w = p + d + eu(a, f, l) + iu[u] + fe[u] | 0, y = (Gt(r, 2) ^ Gt(r, 13) ^ Gt(r, 22)) + ru(r, n, i) | 0;
4397
+ p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w + y | 0;
4398
4398
  }
4399
4399
  r = r + this.A | 0, n = n + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, p = p + this.H | 0, this.set(r, n, i, o, a, f, l, p);
4400
4400
  }
@@ -4419,7 +4419,7 @@ var nu = class {
4419
4419
  }, au = /* @__PURE__ */ Jh(() => new ou(), /* @__PURE__ */ tu(1));
4420
4420
  function hu(e) {
4421
4421
  if (e.length >= 255) throw new TypeError("Alphabet too long");
4422
- const t = new Uint8Array(256);
4422
+ const t = /* @__PURE__ */ new Uint8Array(256);
4423
4423
  for (let p = 0; p < t.length; p++) t[p] = 255;
4424
4424
  for (let p = 0; p < e.length; p++) {
4425
4425
  const u = e.charAt(p), d = u.charCodeAt(0);
@@ -4431,10 +4431,10 @@ function hu(e) {
4431
4431
  if (p instanceof Uint8Array || (ArrayBuffer.isView(p) ? p = new Uint8Array(p.buffer, p.byteOffset, p.byteLength) : Array.isArray(p) && (p = Uint8Array.from(p))), !(p instanceof Uint8Array)) throw new TypeError("Expected Uint8Array");
4432
4432
  if (p.length === 0) return "";
4433
4433
  let u = 0, d = 0, w = 0;
4434
- const b = p.length;
4435
- for (; w !== b && p[w] === 0; ) w++, u++;
4436
- const m = (b - w) * o + 1 >>> 0, v = new Uint8Array(m);
4437
- for (; w !== b; ) {
4434
+ const y = p.length;
4435
+ for (; w !== y && p[w] === 0; ) w++, u++;
4436
+ const m = (y - w) * o + 1 >>> 0, v = new Uint8Array(m);
4437
+ for (; w !== y; ) {
4438
4438
  let S = p[w], _ = 0;
4439
4439
  for (let O = m - 1; (S !== 0 || _ < d) && O !== -1; O--, _++) S += 256 * v[O] >>> 0, v[O] = S % r >>> 0, S = S / r >>> 0;
4440
4440
  if (S !== 0) throw new Error("Non-zero carry");
@@ -4448,25 +4448,25 @@ function hu(e) {
4448
4448
  }
4449
4449
  function f(p) {
4450
4450
  if (typeof p != "string") throw new TypeError("Expected String");
4451
- if (p.length === 0) return new Uint8Array();
4451
+ if (p.length === 0) return /* @__PURE__ */ new Uint8Array();
4452
4452
  let u = 0, d = 0, w = 0;
4453
4453
  for (; p[u] === n; ) d++, u++;
4454
- const b = (p.length - u) * i + 1 >>> 0, m = new Uint8Array(b);
4454
+ const y = (p.length - u) * i + 1 >>> 0, m = new Uint8Array(y);
4455
4455
  for (; u < p.length; ) {
4456
4456
  const S = p.charCodeAt(u);
4457
4457
  if (S > 255) return;
4458
4458
  let _ = t[S];
4459
4459
  if (_ === 255) return;
4460
4460
  let O = 0;
4461
- for (let z = b - 1; (_ !== 0 || O < w) && z !== -1; z--, O++) _ += r * m[z] >>> 0, m[z] = _ % 256 >>> 0, _ = _ / 256 >>> 0;
4461
+ for (let z = y - 1; (_ !== 0 || O < w) && z !== -1; z--, O++) _ += r * m[z] >>> 0, m[z] = _ % 256 >>> 0, _ = _ / 256 >>> 0;
4462
4462
  if (_ !== 0) throw new Error("Non-zero carry");
4463
4463
  w = O, u++;
4464
4464
  }
4465
- let v = b - w;
4466
- for (; v !== b && m[v] === 0; ) v++;
4467
- const I = new Uint8Array(d + (b - v));
4465
+ let v = y - w;
4466
+ for (; v !== y && m[v] === 0; ) v++;
4467
+ const I = new Uint8Array(d + (y - v));
4468
4468
  let P = d;
4469
- for (; v !== b; ) I[P++] = m[v++];
4469
+ for (; v !== y; ) I[P++] = m[v++];
4470
4470
  return I;
4471
4471
  }
4472
4472
  function l(p) {
@@ -4481,7 +4481,7 @@ function hu(e) {
4481
4481
  };
4482
4482
  }
4483
4483
  hu("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
4484
- var ni = /* @__PURE__ */ BigInt(0), Rn = /* @__PURE__ */ BigInt(1);
4484
+ var ei = /* @__PURE__ */ BigInt(0), _n = /* @__PURE__ */ BigInt(1);
4485
4485
  function Kr(e, t = "") {
4486
4486
  if (typeof e != "boolean") {
4487
4487
  const r = t && `"${t}" `;
@@ -4501,7 +4501,7 @@ function Ir(e) {
4501
4501
  }
4502
4502
  function po(e) {
4503
4503
  if (typeof e != "string") throw new Error("hex string expected, got " + typeof e);
4504
- return e === "" ? ni : BigInt("0x" + e);
4504
+ return e === "" ? ei : BigInt("0x" + e);
4505
4505
  }
4506
4506
  function rn(e) {
4507
4507
  return po(en(e));
@@ -4509,19 +4509,19 @@ function rn(e) {
4509
4509
  function wo(e) {
4510
4510
  return po(en(uu(ut(e)).reverse()));
4511
4511
  }
4512
- function ii(e, t) {
4512
+ function ri(e, t) {
4513
4513
  Oe(t), e = lo(e);
4514
4514
  const r = $r(e.toString(16).padStart(t * 2, "0"));
4515
4515
  if (r.length !== t) throw new Error("number too large");
4516
4516
  return r;
4517
4517
  }
4518
4518
  function go(e, t) {
4519
- return ii(e, t).reverse();
4519
+ return ri(e, t).reverse();
4520
4520
  }
4521
4521
  function uu(e) {
4522
4522
  return Uint8Array.from(e);
4523
4523
  }
4524
- var xr = (e) => typeof e == "bigint" && ni <= e;
4524
+ var xr = (e) => typeof e == "bigint" && ei <= e;
4525
4525
  function fu(e, t, r) {
4526
4526
  return xr(e) && xr(t) && xr(r) && t <= e && e < r;
4527
4527
  }
@@ -4530,17 +4530,17 @@ function cu(e, t, r, n) {
4530
4530
  }
4531
4531
  function lu(e) {
4532
4532
  let t;
4533
- for (t = 0; e > ni; e >>= Rn, t += 1) ;
4533
+ for (t = 0; e > ei; e >>= _n, t += 1) ;
4534
4534
  return t;
4535
4535
  }
4536
- var si = (e) => (Rn << BigInt(e)) - Rn;
4536
+ var ni = (e) => (_n << BigInt(e)) - _n;
4537
4537
  function pu(e, t, r) {
4538
4538
  if (Oe(e, "hashLen"), Oe(t, "qByteLen"), typeof r != "function") throw new Error("hmacFn must be a function");
4539
4539
  const n = (v) => new Uint8Array(v), i = Uint8Array.of(), o = Uint8Array.of(0), a = Uint8Array.of(1), f = 1e3;
4540
4540
  let l = n(e), p = n(e), u = 0;
4541
4541
  const d = () => {
4542
4542
  l.fill(1), p.fill(0), u = 0;
4543
- }, w = (...v) => r(p, we(l, ...v)), b = (v = i) => {
4543
+ }, w = (...v) => r(p, we(l, ...v)), y = (v = i) => {
4544
4544
  p = w(o, v), l = w(), v.length !== 0 && (p = w(a, v), l = w());
4545
4545
  }, m = () => {
4546
4546
  if (u++ >= f) throw new Error("drbg: tried max amount of iterations");
@@ -4554,13 +4554,13 @@ function pu(e, t, r) {
4554
4554
  return we(...I);
4555
4555
  };
4556
4556
  return (v, I) => {
4557
- d(), b(v);
4557
+ d(), y(v);
4558
4558
  let P;
4559
- for (; !(P = I(m())); ) b();
4559
+ for (; !(P = I(m())); ) y();
4560
4560
  return d(), P;
4561
4561
  };
4562
4562
  }
4563
- function oi(e, t = {}, r = {}) {
4563
+ function ii(e, t = {}, r = {}) {
4564
4564
  if (!e || typeof e != "object") throw new Error("expected valid options object");
4565
4565
  function n(o, a, f) {
4566
4566
  const l = e[o];
@@ -4571,7 +4571,7 @@ function oi(e, t = {}, r = {}) {
4571
4571
  const i = (o, a) => Object.entries(o).forEach(([f, l]) => n(f, l, a));
4572
4572
  i(t, !1), i(r, !0);
4573
4573
  }
4574
- function Gi(e) {
4574
+ function Wi(e) {
4575
4575
  const t = /* @__PURE__ */ new WeakMap();
4576
4576
  return (r, ...n) => {
4577
4577
  const i = t.get(r);
@@ -4590,7 +4590,7 @@ function Rt(e, t, r) {
4590
4590
  for (; t-- > Ot; ) n *= n, n %= r;
4591
4591
  return n;
4592
4592
  }
4593
- function ji(e, t) {
4593
+ function Gi(e, t) {
4594
4594
  if (e === Ot) throw new Error("invert: expected non-zero number");
4595
4595
  if (t <= Ot) throw new Error("invert: expected positive modulus, got " + t);
4596
4596
  let r = Dt(e, t), n = t, i = Ot, o = Tt;
@@ -4601,25 +4601,25 @@ function ji(e, t) {
4601
4601
  if (n !== Tt) throw new Error("invert: does not exist");
4602
4602
  return Dt(i, t);
4603
4603
  }
4604
- function ai(e, t, r) {
4604
+ function si(e, t, r) {
4605
4605
  if (!e.eql(e.sqr(t), r)) throw new Error("Cannot find square root");
4606
4606
  }
4607
4607
  function Io(e, t) {
4608
4608
  const r = (e.ORDER + Tt) / bo, n = e.pow(t, r);
4609
- return ai(e, n, t), n;
4609
+ return si(e, n, t), n;
4610
4610
  }
4611
4611
  function gu(e, t) {
4612
4612
  const r = (e.ORDER - mo) / Eo, n = e.mul(t, ve), i = e.pow(n, r), o = e.mul(t, i), a = e.mul(e.mul(o, ve), i), f = e.mul(o, e.sub(a, e.ONE));
4613
- return ai(e, f, t), f;
4613
+ return si(e, f, t), f;
4614
4614
  }
4615
4615
  function yu(e) {
4616
4616
  const t = nn(e), r = Ao(e), n = r(t, t.neg(t.ONE)), i = r(t, n), o = r(t, t.neg(n)), a = (e + du) / vo;
4617
4617
  return (f, l) => {
4618
4618
  let p = f.pow(l, a), u = f.mul(p, n);
4619
- const d = f.mul(p, i), w = f.mul(p, o), b = f.eql(f.sqr(u), l), m = f.eql(f.sqr(d), l);
4620
- p = f.cmov(p, u, b), u = f.cmov(w, d, m);
4619
+ const d = f.mul(p, i), w = f.mul(p, o), y = f.eql(f.sqr(u), l), m = f.eql(f.sqr(d), l);
4620
+ p = f.cmov(p, u, y), u = f.cmov(w, d, m);
4621
4621
  const v = f.eql(f.sqr(u), l), I = f.cmov(p, u, v);
4622
- return ai(f, I, l), I;
4622
+ return si(f, I, l), I;
4623
4623
  };
4624
4624
  }
4625
4625
  function Ao(e) {
@@ -4628,20 +4628,20 @@ function Ao(e) {
4628
4628
  for (; t % ve === Ot; ) t /= ve, r++;
4629
4629
  let n = ve;
4630
4630
  const i = nn(e);
4631
- for (; zi(i, n) === 1; ) if (n++ > 1e3) throw new Error("Cannot find square root: probably non-prime P");
4631
+ for (; ji(i, n) === 1; ) if (n++ > 1e3) throw new Error("Cannot find square root: probably non-prime P");
4632
4632
  if (r === 1) return Io;
4633
4633
  let o = i.pow(n, t);
4634
4634
  const a = (t + Tt) / ve;
4635
4635
  return function(f, l) {
4636
4636
  if (f.is0(l)) return l;
4637
- if (zi(f, l) !== 1) throw new Error("Cannot find square root");
4637
+ if (ji(f, l) !== 1) throw new Error("Cannot find square root");
4638
4638
  let p = r, u = f.mul(f.ONE, o), d = f.pow(l, t), w = f.pow(l, a);
4639
4639
  for (; !f.eql(d, f.ONE); ) {
4640
4640
  if (f.is0(d)) return f.ZERO;
4641
- let b = 1, m = f.sqr(d);
4642
- for (; !f.eql(m, f.ONE); ) if (b++, m = f.sqr(m), b === p) throw new Error("Cannot find square root");
4643
- const v = Tt << BigInt(p - b - 1), I = f.pow(u, v);
4644
- p = b, u = f.sqr(I), d = f.mul(d, u), w = f.mul(w, I);
4641
+ let y = 1, m = f.sqr(d);
4642
+ for (; !f.eql(m, f.ONE); ) if (y++, m = f.sqr(m), y === p) throw new Error("Cannot find square root");
4643
+ const v = Tt << BigInt(p - y - 1), I = f.pow(u, v);
4644
+ p = y, u = f.sqr(I), d = f.mul(d, u), w = f.mul(w, I);
4645
4645
  }
4646
4646
  return w;
4647
4647
  };
@@ -4669,7 +4669,7 @@ var mu = [
4669
4669
  "sqrN"
4670
4670
  ];
4671
4671
  function Eu(e) {
4672
- return oi(e, mu.reduce((t, r) => (t[r] = "function", t), {
4672
+ return ii(e, mu.reduce((t, r) => (t[r] = "function", t), {
4673
4673
  ORDER: "bigint",
4674
4674
  BYTES: "number",
4675
4675
  BITS: "number"
@@ -4687,7 +4687,7 @@ function So(e, t, r = !1) {
4687
4687
  const n = new Array(t.length).fill(r ? e.ZERO : void 0), i = t.reduce((a, f, l) => e.is0(f) ? a : (n[l] = a, e.mul(a, f)), e.ONE), o = e.inv(i);
4688
4688
  return t.reduceRight((a, f, l) => e.is0(f) ? a : (n[l] = e.mul(a, n[l]), e.mul(a, f)), o), n;
4689
4689
  }
4690
- function zi(e, t) {
4690
+ function ji(e, t) {
4691
4691
  const r = (e.ORDER - Tt) / ve, n = e.pow(t, r), i = e.eql(n, e.ONE), o = e.eql(n, e.ZERO), a = e.eql(n, e.neg(e.ONE));
4692
4692
  if (!i && !o && !a) throw new Error("invalid Legendre symbol result");
4693
4693
  return i ? 1 : o ? 0 : -1;
@@ -4756,7 +4756,7 @@ var Au = class {
4756
4756
  return vu(this, e, t);
4757
4757
  }
4758
4758
  div(e, t) {
4759
- return Dt(e * ji(t, this.ORDER), this.ORDER);
4759
+ return Dt(e * Gi(t, this.ORDER), this.ORDER);
4760
4760
  }
4761
4761
  sqrN(e) {
4762
4762
  return e * e;
@@ -4771,13 +4771,13 @@ var Au = class {
4771
4771
  return e * t;
4772
4772
  }
4773
4773
  inv(e) {
4774
- return ji(e, this.ORDER);
4774
+ return Gi(e, this.ORDER);
4775
4775
  }
4776
4776
  sqrt(e) {
4777
4777
  return this._sqrt || (this._sqrt = bu(this.ORDER)), this._sqrt(this, e);
4778
4778
  }
4779
4779
  toBytes(e) {
4780
- return this.isLE ? go(e, this.BYTES) : ii(e, this.BYTES);
4780
+ return this.isLE ? go(e, this.BYTES) : ri(e, this.BYTES);
4781
4781
  }
4782
4782
  fromBytes(e, t = !1) {
4783
4783
  ut(e);
@@ -4816,14 +4816,14 @@ function Su(e, t, r = !1) {
4816
4816
  const n = e.length, i = To(t), o = ko(t);
4817
4817
  if (n < 16 || n < o || n > 1024) throw new Error("expected " + o + "-1024 bytes of input, got " + n);
4818
4818
  const a = Dt(r ? wo(e) : rn(e), t - Tt) + Tt;
4819
- return r ? go(a, i) : ii(a, i);
4819
+ return r ? go(a, i) : ri(a, i);
4820
4820
  }
4821
4821
  var Me = /* @__PURE__ */ BigInt(0), Ie = /* @__PURE__ */ BigInt(1);
4822
4822
  function Dr(e, t) {
4823
4823
  const r = t.negate();
4824
4824
  return e ? r : t;
4825
4825
  }
4826
- function qi(e, t) {
4826
+ function zi(e, t) {
4827
4827
  const r = So(e.Fp, t.map((n) => n.Z));
4828
4828
  return t.map((n, i) => e.fromAffine(n.toAffine(r[i])));
4829
4829
  }
@@ -4836,22 +4836,22 @@ function wn(e, t) {
4836
4836
  return {
4837
4837
  windows: r,
4838
4838
  windowSize: n,
4839
- mask: si(e),
4839
+ mask: ni(e),
4840
4840
  maxNumber: i,
4841
4841
  shiftBy: BigInt(e)
4842
4842
  };
4843
4843
  }
4844
- function Yi(e, t, r) {
4844
+ function qi(e, t, r) {
4845
4845
  const { windowSize: n, mask: i, maxNumber: o, shiftBy: a } = r;
4846
4846
  let f = Number(e & i), l = e >> a;
4847
4847
  f > n && (f -= o, l += Ie);
4848
- const p = t * n, u = p + Math.abs(f) - 1, d = f === 0, w = f < 0, b = t % 2 !== 0;
4848
+ const p = t * n, u = p + Math.abs(f) - 1, d = f === 0, w = f < 0, y = t % 2 !== 0;
4849
4849
  return {
4850
4850
  nextN: l,
4851
4851
  offset: u,
4852
4852
  isZero: d,
4853
4853
  isNeg: w,
4854
- isNegF: b,
4854
+ isNegF: y,
4855
4855
  offsetF: p
4856
4856
  };
4857
4857
  }
@@ -4859,7 +4859,7 @@ var gn = /* @__PURE__ */ new WeakMap(), Oo = /* @__PURE__ */ new WeakMap();
4859
4859
  function yn(e) {
4860
4860
  return Oo.get(e) || 1;
4861
4861
  }
4862
- function Xi(e) {
4862
+ function Yi(e) {
4863
4863
  if (e !== Me) throw new Error("invalid wNAF");
4864
4864
  }
4865
4865
  var Tu = class {
@@ -4890,10 +4890,10 @@ var Tu = class {
4890
4890
  let n = this.ZERO, i = this.BASE;
4891
4891
  const o = wn(e, this.bits);
4892
4892
  for (let a = 0; a < o.windows; a++) {
4893
- const { nextN: f, offset: l, isZero: p, isNeg: u, isNegF: d, offsetF: w } = Yi(r, a, o);
4893
+ const { nextN: f, offset: l, isZero: p, isNeg: u, isNegF: d, offsetF: w } = qi(r, a, o);
4894
4894
  r = f, p ? i = i.add(Dr(d, t[w])) : n = n.add(Dr(u, t[l]));
4895
4895
  }
4896
- return Xi(r), {
4896
+ return Yi(r), {
4897
4897
  p: n,
4898
4898
  f: i
4899
4899
  };
@@ -4901,13 +4901,13 @@ var Tu = class {
4901
4901
  wNAFUnsafe(e, t, r, n = this.ZERO) {
4902
4902
  const i = wn(e, this.bits);
4903
4903
  for (let o = 0; o < i.windows && r !== Me; o++) {
4904
- const { nextN: a, offset: f, isZero: l, isNeg: p } = Yi(r, o, i);
4904
+ const { nextN: a, offset: f, isZero: l, isNeg: p } = qi(r, o, i);
4905
4905
  if (r = a, !l) {
4906
4906
  const u = t[f];
4907
4907
  n = n.add(p ? u.negate() : u);
4908
4908
  }
4909
4909
  }
4910
- return Xi(r), n;
4910
+ return Yi(r), n;
4911
4911
  }
4912
4912
  getPrecomputes(e, t, r) {
4913
4913
  let n = gn.get(t);
@@ -4936,7 +4936,7 @@ function ku(e, t, r, n) {
4936
4936
  p2: a
4937
4937
  };
4938
4938
  }
4939
- function Zi(e, t, r) {
4939
+ function Xi(e, t, r) {
4940
4940
  if (t) {
4941
4941
  if (t.ORDER !== e) throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
4942
4942
  return Eu(t), t;
@@ -4952,7 +4952,7 @@ function Uu(e, t, r = {}, n) {
4952
4952
  const f = t[a];
4953
4953
  if (!(typeof f == "bigint" && f > Me)) throw new Error(`CURVE.${a} must be positive bigint`);
4954
4954
  }
4955
- const i = Zi(t.p, r.Fp, n), o = Zi(t.n, r.Fn, n);
4955
+ const i = Xi(t.p, r.Fp, n), o = Xi(t.n, r.Fn, n);
4956
4956
  for (const a of [
4957
4957
  "Gx",
4958
4958
  "Gy",
@@ -5014,14 +5014,14 @@ var Po = class {
5014
5014
  }
5015
5015
  }, xo = (e, t, r) => new Po(e, t).update(r).digest();
5016
5016
  xo.create = (e, t) => new Po(e, t);
5017
- var Qi = (e, t) => (e + (e >= 0 ? t : -t) / Bo) / t;
5017
+ var Zi = (e, t) => (e + (e >= 0 ? t : -t) / Bo) / t;
5018
5018
  function Pu(e, t, r) {
5019
- const [[n, i], [o, a]] = t, f = Qi(a * e, r), l = Qi(-i * e, r);
5019
+ const [[n, i], [o, a]] = t, f = Zi(a * e, r), l = Zi(-i * e, r);
5020
5020
  let p = e - f * n - l * o, u = -f * i - l * a;
5021
5021
  const d = p < re, w = u < re;
5022
5022
  d && (p = -p), w && (u = -u);
5023
- const b = si(Math.ceil(lu(r) / 2)) + Ve;
5024
- if (p < re || p >= b || u < re || u >= b) throw new Error("splitScalar (endomorphism): failed, k=" + e);
5023
+ const y = ni(Math.ceil(lu(r) / 2)) + Ve;
5024
+ if (p < re || p >= y || u < re || u >= y) throw new Error("splitScalar (endomorphism): failed, k=" + e);
5025
5025
  return {
5026
5026
  k1neg: d,
5027
5027
  k1: p,
@@ -5029,7 +5029,7 @@ function Pu(e, t, r) {
5029
5029
  k2: u
5030
5030
  };
5031
5031
  }
5032
- function Nn(e) {
5032
+ function Rn(e) {
5033
5033
  if (![
5034
5034
  "compact",
5035
5035
  "recovered",
@@ -5040,7 +5040,7 @@ function Nn(e) {
5040
5040
  function bn(e, t) {
5041
5041
  const r = {};
5042
5042
  for (let n of Object.keys(t)) r[n] = e[n] === void 0 ? t[n] : e[n];
5043
- return Kr(r.lowS, "lowS"), Kr(r.prehash, "prehash"), r.format !== void 0 && Nn(r.format), r;
5043
+ return Kr(r.lowS, "lowS"), Kr(r.prehash, "prehash"), r.format !== void 0 && Rn(r.format), r;
5044
5044
  }
5045
5045
  var xu = class extends Error {
5046
5046
  constructor(e = "") {
@@ -5118,7 +5118,7 @@ function _u(e, t = {}) {
5118
5118
  const r = Uu("weierstrass", e, t), { Fp: n, Fn: i } = r;
5119
5119
  let o = r.CURVE;
5120
5120
  const { h: a, n: f } = o;
5121
- oi(t, {}, {
5121
+ ii(t, {}, {
5122
5122
  allowInfinityPoint: "boolean",
5123
5123
  clearCofactor: "function",
5124
5124
  isTorsionFree: "function",
@@ -5151,8 +5151,8 @@ function _u(e, t = {}) {
5151
5151
  throw new Error("bad point: is not on curve, sqrt error" + ct);
5152
5152
  }
5153
5153
  u();
5154
- const M = n.isOdd(L);
5155
- return (B & 1) === 1 !== M && (L = n.neg(L)), {
5154
+ const D = n.isOdd(L);
5155
+ return (B & 1) === 1 !== D && (L = n.neg(L)), {
5156
5156
  x: $,
5157
5157
  y: L
5158
5158
  };
@@ -5165,7 +5165,7 @@ function _u(e, t = {}) {
5165
5165
  };
5166
5166
  } else throw new Error(`bad point: got length ${A}, expected compressed=${U} or uncompressed=${T}`);
5167
5167
  }
5168
- const b = t.toBytes || d, m = t.fromBytes || w;
5168
+ const y = t.toBytes || d, m = t.fromBytes || w;
5169
5169
  function v(Y) {
5170
5170
  const U = n.sqr(Y), T = n.mul(U, Y);
5171
5171
  return n.add(n.add(T, n.mul(Y, o.a)), o.b);
@@ -5188,7 +5188,7 @@ function _u(e, t = {}) {
5188
5188
  if (!l || !l.basises) throw new Error("no endo");
5189
5189
  return Pu(Y, l.basises, i.ORDER);
5190
5190
  }
5191
- const D = Gi((Y, U) => {
5191
+ const M = Wi((Y, U) => {
5192
5192
  const { X: T, Y: A, Z: B } = Y;
5193
5193
  if (n.eql(B, n.ONE)) return {
5194
5194
  x: T,
@@ -5206,7 +5206,7 @@ function _u(e, t = {}) {
5206
5206
  x: $,
5207
5207
  y: C
5208
5208
  };
5209
- }), X = Gi((Y) => {
5209
+ }), Z = Wi((Y) => {
5210
5210
  if (Y.is0()) {
5211
5211
  if (t.allowInfinityPoint && !n.is0(Y.Y)) return;
5212
5212
  throw new Error("bad point: ZERO");
@@ -5217,7 +5217,7 @@ function _u(e, t = {}) {
5217
5217
  if (!Y.isTorsionFree()) throw new Error("bad point: not in prime-order subgroup");
5218
5218
  return !0;
5219
5219
  });
5220
- function at(Y, U, T, A, B) {
5220
+ function Q(Y, U, T, A, B) {
5221
5221
  return T = new q(n.mul(T.X, Y), T.Y, T.Z), U = Dr(A, U), T = Dr(B, T), U.add(T);
5222
5222
  }
5223
5223
  class q {
@@ -5257,7 +5257,7 @@ function _u(e, t = {}) {
5257
5257
  return Qt.createCache(this, U), T || this.multiply(Ar), this;
5258
5258
  }
5259
5259
  assertValidity() {
5260
- X(this);
5260
+ Z(this);
5261
5261
  }
5262
5262
  hasEvenY() {
5263
5263
  const { y: U } = this.toAffine();
@@ -5266,26 +5266,26 @@ function _u(e, t = {}) {
5266
5266
  }
5267
5267
  equals(U) {
5268
5268
  O(U);
5269
- const { X: T, Y: A, Z: B } = this, { X: V, Y: $, Z: C } = U, L = n.eql(n.mul(T, C), n.mul(V, B)), M = n.eql(n.mul(A, C), n.mul($, B));
5270
- return L && M;
5269
+ const { X: T, Y: A, Z: B } = this, { X: V, Y: $, Z: C } = U, L = n.eql(n.mul(T, C), n.mul(V, B)), D = n.eql(n.mul(A, C), n.mul($, B));
5270
+ return L && D;
5271
5271
  }
5272
5272
  negate() {
5273
5273
  return new q(this.X, n.neg(this.Y), this.Z);
5274
5274
  }
5275
5275
  double() {
5276
5276
  const { a: U, b: T } = o, A = n.mul(T, Ar), { X: B, Y: V, Z: $ } = this;
5277
- let C = n.ZERO, L = n.ZERO, M = n.ZERO, F = n.mul(B, B), ct = n.mul(V, V), W = n.mul($, $), K = n.mul(B, V);
5278
- return K = n.add(K, K), M = n.mul(B, $), M = n.add(M, M), C = n.mul(U, M), L = n.mul(A, W), L = n.add(C, L), C = n.sub(ct, L), L = n.add(ct, L), L = n.mul(C, L), C = n.mul(K, C), M = n.mul(A, M), W = n.mul(U, W), K = n.sub(F, W), K = n.mul(U, K), K = n.add(K, M), M = n.add(F, F), F = n.add(M, F), F = n.add(F, W), F = n.mul(F, K), L = n.add(L, F), W = n.mul(V, $), W = n.add(W, W), F = n.mul(W, K), C = n.sub(C, F), M = n.mul(W, ct), M = n.add(M, M), M = n.add(M, M), new q(C, L, M);
5277
+ let C = n.ZERO, L = n.ZERO, D = n.ZERO, F = n.mul(B, B), ct = n.mul(V, V), W = n.mul($, $), K = n.mul(B, V);
5278
+ return K = n.add(K, K), D = n.mul(B, $), D = n.add(D, D), C = n.mul(U, D), L = n.mul(A, W), L = n.add(C, L), C = n.sub(ct, L), L = n.add(ct, L), L = n.mul(C, L), C = n.mul(K, C), D = n.mul(A, D), W = n.mul(U, W), K = n.sub(F, W), K = n.mul(U, K), K = n.add(K, D), D = n.add(F, F), F = n.add(D, F), F = n.add(F, W), F = n.mul(F, K), L = n.add(L, F), W = n.mul(V, $), W = n.add(W, W), F = n.mul(W, K), C = n.sub(C, F), D = n.mul(W, ct), D = n.add(D, D), D = n.add(D, D), new q(C, L, D);
5279
5279
  }
5280
5280
  add(U) {
5281
5281
  O(U);
5282
5282
  const { X: T, Y: A, Z: B } = this, { X: V, Y: $, Z: C } = U;
5283
- let L = n.ZERO, M = n.ZERO, F = n.ZERO;
5283
+ let L = n.ZERO, D = n.ZERO, F = n.ZERO;
5284
5284
  const ct = o.a, W = n.mul(o.b, Ar);
5285
- let K = n.mul(T, V), nt = n.mul(A, $), lt = n.mul(B, C), _t = n.add(T, A), it = n.add(V, $);
5286
- _t = n.mul(_t, it), it = n.add(K, nt), _t = n.sub(_t, it), it = n.add(T, B);
5285
+ let K = n.mul(T, V), it = n.mul(A, $), lt = n.mul(B, C), _t = n.add(T, A), st = n.add(V, $);
5286
+ _t = n.mul(_t, st), st = n.add(K, it), _t = n.sub(_t, st), st = n.add(T, B);
5287
5287
  let yt = n.add(V, C);
5288
- return it = n.mul(it, yt), yt = n.add(K, lt), it = n.sub(it, yt), yt = n.add(A, B), L = n.add($, C), yt = n.mul(yt, L), L = n.add(nt, lt), yt = n.sub(yt, L), F = n.mul(ct, it), L = n.mul(W, lt), F = n.add(L, F), L = n.sub(nt, F), F = n.add(nt, F), M = n.mul(L, F), nt = n.add(K, K), nt = n.add(nt, K), lt = n.mul(ct, lt), it = n.mul(W, it), nt = n.add(nt, lt), lt = n.sub(K, lt), lt = n.mul(ct, lt), it = n.add(it, lt), K = n.mul(nt, it), M = n.add(M, K), K = n.mul(yt, it), L = n.mul(_t, L), L = n.sub(L, K), K = n.mul(_t, nt), F = n.mul(yt, F), F = n.add(F, K), new q(L, M, F);
5288
+ return st = n.mul(st, yt), yt = n.add(K, lt), st = n.sub(st, yt), yt = n.add(A, B), L = n.add($, C), yt = n.mul(yt, L), L = n.add(it, lt), yt = n.sub(yt, L), F = n.mul(ct, st), L = n.mul(W, lt), F = n.add(L, F), L = n.sub(it, F), F = n.add(it, F), D = n.mul(L, F), it = n.add(K, K), it = n.add(it, K), lt = n.mul(ct, lt), st = n.mul(W, st), it = n.add(it, lt), lt = n.sub(K, lt), lt = n.mul(ct, lt), st = n.add(st, lt), K = n.mul(it, st), D = n.add(D, K), K = n.mul(yt, st), L = n.mul(_t, L), L = n.sub(L, K), K = n.mul(_t, it), F = n.mul(yt, F), F = n.add(F, K), new q(L, D, F);
5289
5289
  }
5290
5290
  subtract(U) {
5291
5291
  return this.add(U.negate());
@@ -5297,15 +5297,15 @@ function _u(e, t = {}) {
5297
5297
  const { endo: T } = t;
5298
5298
  if (!i.isValidNot0(U)) throw new Error("invalid scalar: out of range");
5299
5299
  let A, B;
5300
- const V = ($) => Qt.cached(this, $, (C) => qi(q, C));
5300
+ const V = ($) => Qt.cached(this, $, (C) => zi(q, C));
5301
5301
  if (T) {
5302
- const { k1neg: $, k1: C, k2neg: L, k2: M } = z(U), { p: F, f: ct } = V(C), { p: W, f: K } = V(M);
5303
- B = ct.add(K), A = at(T.beta, F, W, $, L);
5302
+ const { k1neg: $, k1: C, k2neg: L, k2: D } = z(U), { p: F, f: ct } = V(C), { p: W, f: K } = V(D);
5303
+ B = ct.add(K), A = Q(T.beta, F, W, $, L);
5304
5304
  } else {
5305
5305
  const { p: $, f: C } = V(U);
5306
5306
  A = $, B = C;
5307
5307
  }
5308
- return qi(q, [A, B])[0];
5308
+ return zi(q, [A, B])[0];
5309
5309
  }
5310
5310
  multiplyUnsafe(U) {
5311
5311
  const { endo: T } = t, A = this;
@@ -5314,12 +5314,12 @@ function _u(e, t = {}) {
5314
5314
  if (U === Ve) return A;
5315
5315
  if (Qt.hasCache(this)) return this.multiply(U);
5316
5316
  if (T) {
5317
- const { k1neg: B, k1: V, k2neg: $, k2: C } = z(U), { p1: L, p2: M } = ku(q, A, V, C);
5318
- return at(T.beta, L, M, B, $);
5317
+ const { k1neg: B, k1: V, k2neg: $, k2: C } = z(U), { p1: L, p2: D } = ku(q, A, V, C);
5318
+ return Q(T.beta, L, D, B, $);
5319
5319
  } else return Qt.unsafe(A, U);
5320
5320
  }
5321
5321
  toAffine(U) {
5322
- return D(this, U);
5322
+ return M(this, U);
5323
5323
  }
5324
5324
  isTorsionFree() {
5325
5325
  const { isTorsionFree: U } = t;
@@ -5333,7 +5333,7 @@ function _u(e, t = {}) {
5333
5333
  return this.multiplyUnsafe(a).is0();
5334
5334
  }
5335
5335
  toBytes(U = !0) {
5336
- return Kr(U, "isCompressed"), this.assertValidity(), b(q, this, U);
5336
+ return Kr(U, "isCompressed"), this.assertValidity(), y(q, this, U);
5337
5337
  }
5338
5338
  toHex(U = !0) {
5339
5339
  return en(this.toBytes(U));
@@ -5359,39 +5359,39 @@ function Ro(e, t) {
5359
5359
  }
5360
5360
  function Ru(e, t = {}) {
5361
5361
  const { Fn: r } = e, n = t.randomBytes || co, i = Object.assign(Ro(e.Fp, r), { seed: ko(r.ORDER) });
5362
- function o(b) {
5362
+ function o(y) {
5363
5363
  try {
5364
- const m = r.fromBytes(b);
5364
+ const m = r.fromBytes(y);
5365
5365
  return r.isValidNot0(m);
5366
5366
  } catch {
5367
5367
  return !1;
5368
5368
  }
5369
5369
  }
5370
- function a(b, m) {
5370
+ function a(y, m) {
5371
5371
  const { publicKey: v, publicKeyUncompressed: I } = i;
5372
5372
  try {
5373
- const P = b.length;
5374
- return m === !0 && P !== v || m === !1 && P !== I ? !1 : !!e.fromBytes(b);
5373
+ const P = y.length;
5374
+ return m === !0 && P !== v || m === !1 && P !== I ? !1 : !!e.fromBytes(y);
5375
5375
  } catch {
5376
5376
  return !1;
5377
5377
  }
5378
5378
  }
5379
- function f(b = n(i.seed)) {
5380
- return Su(ut(b, i.seed, "seed"), r.ORDER);
5379
+ function f(y = n(i.seed)) {
5380
+ return Su(ut(y, i.seed, "seed"), r.ORDER);
5381
5381
  }
5382
- function l(b, m = !0) {
5383
- return e.BASE.multiply(r.fromBytes(b)).toBytes(m);
5382
+ function l(y, m = !0) {
5383
+ return e.BASE.multiply(r.fromBytes(y)).toBytes(m);
5384
5384
  }
5385
- function p(b) {
5385
+ function p(y) {
5386
5386
  const { secretKey: m, publicKey: v, publicKeyUncompressed: I } = i;
5387
- if (!ri(b) || "_lengths" in r && r._lengths || m === v) return;
5388
- const P = ut(b, void 0, "key").length;
5387
+ if (!ti(y) || "_lengths" in r && r._lengths || m === v) return;
5388
+ const P = ut(y, void 0, "key").length;
5389
5389
  return P === v || P === I;
5390
5390
  }
5391
- function u(b, m, v = !0) {
5392
- if (p(b) === !0) throw new Error("first arg must be private key");
5391
+ function u(y, m, v = !0) {
5392
+ if (p(y) === !0) throw new Error("first arg must be private key");
5393
5393
  if (p(m) === !1) throw new Error("second arg must be public key");
5394
- const I = r.fromBytes(b);
5394
+ const I = r.fromBytes(y);
5395
5395
  return e.fromBytes(m).multiply(I).toBytes(v);
5396
5396
  }
5397
5397
  const d = {
@@ -5409,14 +5409,14 @@ function Ru(e, t = {}) {
5409
5409
  });
5410
5410
  }
5411
5411
  function Nu(e, t, r = {}) {
5412
- uo(t), oi(r, {}, {
5412
+ uo(t), ii(r, {}, {
5413
5413
  hmac: "function",
5414
5414
  lowS: "boolean",
5415
5415
  randomBytes: "function",
5416
5416
  bits2int: "function",
5417
5417
  bits2int_modN: "function"
5418
5418
  }), r = Object.assign({}, r);
5419
- const n = r.randomBytes || co, i = r.hmac || ((T, A) => xo(t, T, A)), { Fp: o, Fn: a } = e, { ORDER: f, BITS: l } = a, { keygen: p, getPublicKey: u, getSharedSecret: d, utils: w, lengths: b } = Ru(e, r), m = {
5419
+ const n = r.randomBytes || co, i = r.hmac || ((T, A) => xo(t, T, A)), { Fp: o, Fn: a } = e, { ORDER: f, BITS: l } = a, { keygen: p, getPublicKey: u, getSharedSecret: d, utils: w, lengths: y } = Ru(e, r), m = {
5420
5420
  prehash: !0,
5421
5421
  lowS: typeof r.lowS == "boolean" ? r.lowS : !0,
5422
5422
  format: "compact",
@@ -5433,8 +5433,8 @@ function Nu(e, t, r = {}) {
5433
5433
  if (v) throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
5434
5434
  }
5435
5435
  function _(T, A) {
5436
- Nn(A);
5437
- const B = b.signature;
5436
+ Rn(A);
5437
+ const B = y.signature;
5438
5438
  return ut(T, A === "compact" ? B : A === "recovered" ? B + 1 : void 0);
5439
5439
  }
5440
5440
  class O {
@@ -5457,11 +5457,11 @@ function Nu(e, t, r = {}) {
5457
5457
  _(A, B);
5458
5458
  let V;
5459
5459
  if (B === "der") {
5460
- const { r: M, s: F } = de.toSig(ut(A));
5461
- return new O(M, F);
5460
+ const { r: D, s: F } = de.toSig(ut(A));
5461
+ return new O(D, F);
5462
5462
  }
5463
5463
  B === "recovered" && (V = A[0], B = "compact", A = A.subarray(1));
5464
- const $ = b.signature / 2, C = A.subarray(0, $), L = A.subarray($, $ * 2);
5464
+ const $ = y.signature / 2, C = A.subarray(0, $), L = A.subarray($, $ * 2);
5465
5465
  return new O(a.fromBytes(C), a.fromBytes(L), V);
5466
5466
  }
5467
5467
  static fromHex(A, B) {
@@ -5478,15 +5478,15 @@ function Nu(e, t, r = {}) {
5478
5478
  recoverPublicKey(A) {
5479
5479
  const { r: B, s: V } = this, $ = this.assertRecovery(), C = $ === 2 || $ === 3 ? B + f : B;
5480
5480
  if (!o.isValid(C)) throw new Error("invalid recovery id: sig.r+curve.n != R.x");
5481
- const L = o.toBytes(C), M = e.fromBytes(we(_o(($ & 1) === 0), L)), F = a.inv(C), ct = D(ut(A, void 0, "msgHash")), W = a.create(-ct * F), K = a.create(V * F), nt = e.BASE.multiplyUnsafe(W).add(M.multiplyUnsafe(K));
5482
- if (nt.is0()) throw new Error("invalid recovery: point at infinify");
5483
- return nt.assertValidity(), nt;
5481
+ const L = o.toBytes(C), D = e.fromBytes(we(_o(($ & 1) === 0), L)), F = a.inv(C), ct = M(ut(A, void 0, "msgHash")), W = a.create(-ct * F), K = a.create(V * F), it = e.BASE.multiplyUnsafe(W).add(D.multiplyUnsafe(K));
5482
+ if (it.is0()) throw new Error("invalid recovery: point at infinify");
5483
+ return it.assertValidity(), it;
5484
5484
  }
5485
5485
  hasHighS() {
5486
5486
  return I(this.s);
5487
5487
  }
5488
5488
  toBytes(A = m.format) {
5489
- if (Nn(A), A === "der") return $r(de.hexFromSig(this));
5489
+ if (Rn(A), A === "der") return $r(de.hexFromSig(this));
5490
5490
  const { r: B, s: V } = this, $ = a.toBytes(B), C = a.toBytes(V);
5491
5491
  return A === "recovered" ? (S(), we(Uint8Array.of(this.assertRecovery()), $, C)) : we($, C);
5492
5492
  }
@@ -5498,11 +5498,11 @@ function Nu(e, t, r = {}) {
5498
5498
  if (T.length > 8192) throw new Error("input is too large");
5499
5499
  const A = rn(T), B = T.length * 8 - l;
5500
5500
  return B > 0 ? A >> BigInt(B) : A;
5501
- }, D = r.bits2int_modN || function(T) {
5501
+ }, M = r.bits2int_modN || function(T) {
5502
5502
  return a.create(z(T));
5503
- }, X = si(l);
5504
- function at(T) {
5505
- return cu("num < 2^" + l, T, re, X), a.toBytes(T);
5503
+ }, Z = ni(l);
5504
+ function Q(T) {
5505
+ return cu("num < 2^" + l, T, re, Z), a.toBytes(T);
5506
5506
  }
5507
5507
  function q(T, A) {
5508
5508
  return ut(T, void 0, "message"), A ? ut(t(T), void 0, "prehashed message") : T;
@@ -5510,22 +5510,22 @@ function Nu(e, t, r = {}) {
5510
5510
  function Vt(T, A, B) {
5511
5511
  const { lowS: V, prehash: $, extraEntropy: C } = bn(B, m);
5512
5512
  T = q(T, $);
5513
- const L = D(T), M = a.fromBytes(A);
5514
- if (!a.isValidNot0(M)) throw new Error("invalid private key");
5515
- const F = [at(M), at(L)];
5513
+ const L = M(T), D = a.fromBytes(A);
5514
+ if (!a.isValidNot0(D)) throw new Error("invalid private key");
5515
+ const F = [Q(D), Q(L)];
5516
5516
  if (C != null && C !== !1) {
5517
- const nt = C === !0 ? n(b.secretKey) : C;
5518
- F.push(ut(nt, void 0, "extraEntropy"));
5517
+ const it = C === !0 ? n(y.secretKey) : C;
5518
+ F.push(ut(it, void 0, "extraEntropy"));
5519
5519
  }
5520
5520
  const ct = we(...F), W = L;
5521
- function K(nt) {
5522
- const lt = z(nt);
5521
+ function K(it) {
5522
+ const lt = z(it);
5523
5523
  if (!a.isValidNot0(lt)) return;
5524
- const _t = a.inv(lt), it = e.BASE.multiply(lt).toAffine(), yt = a.create(it.x);
5524
+ const _t = a.inv(lt), st = e.BASE.multiply(lt).toAffine(), yt = a.create(st.x);
5525
5525
  if (yt === re) return;
5526
- const $t = a.create(_t * a.create(W + yt * M));
5526
+ const $t = a.create(_t * a.create(W + yt * D));
5527
5527
  if ($t === re) return;
5528
- let Be = (it.x === yt ? 0 : 2) | Number(it.y & Ve), je = $t;
5528
+ let Be = (st.x === yt ? 0 : 2) | Number(st.y & Ve), je = $t;
5529
5529
  return V && I($t) && (je = a.neg($t), Be ^= 1), new O(yt, je, v ? void 0 : Be);
5530
5530
  }
5531
5531
  return {
@@ -5539,16 +5539,16 @@ function Nu(e, t, r = {}) {
5539
5539
  }
5540
5540
  function Y(T, A, B, V = {}) {
5541
5541
  const { lowS: $, prehash: C, format: L } = bn(V, m);
5542
- if (B = ut(B, void 0, "publicKey"), A = q(A, C), !ri(T)) {
5543
- const M = T instanceof O ? ", use sig.toBytes()" : "";
5544
- throw new Error("verify expects Uint8Array signature" + M);
5542
+ if (B = ut(B, void 0, "publicKey"), A = q(A, C), !ti(T)) {
5543
+ const D = T instanceof O ? ", use sig.toBytes()" : "";
5544
+ throw new Error("verify expects Uint8Array signature" + D);
5545
5545
  }
5546
5546
  _(T, L);
5547
5547
  try {
5548
- const M = O.fromBytes(T, L), F = e.fromBytes(B);
5549
- if ($ && M.hasHighS()) return !1;
5550
- const { r: ct, s: W } = M, K = D(A), nt = a.inv(W), lt = a.create(K * nt), _t = a.create(ct * nt), it = e.BASE.multiplyUnsafe(lt).add(F.multiplyUnsafe(_t));
5551
- return it.is0() ? !1 : a.create(it.x) === ct;
5548
+ const D = O.fromBytes(T, L), F = e.fromBytes(B);
5549
+ if ($ && D.hasHighS()) return !1;
5550
+ const { r: ct, s: W } = D, K = M(A), it = a.inv(W), lt = a.create(K * it), _t = a.create(ct * it), st = e.BASE.multiplyUnsafe(lt).add(F.multiplyUnsafe(_t));
5551
+ return st.is0() ? !1 : a.create(st.x) === ct;
5552
5552
  } catch {
5553
5553
  return !1;
5554
5554
  }
@@ -5562,7 +5562,7 @@ function Nu(e, t, r = {}) {
5562
5562
  getPublicKey: u,
5563
5563
  getSharedSecret: d,
5564
5564
  utils: w,
5565
- lengths: b,
5565
+ lengths: y,
5566
5566
  Point: e,
5567
5567
  sign: Qt,
5568
5568
  verify: Y,
@@ -5571,7 +5571,7 @@ function Nu(e, t, r = {}) {
5571
5571
  hash: t
5572
5572
  });
5573
5573
  }
5574
- var hi = {
5574
+ var oi = {
5575
5575
  p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
5576
5576
  n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
5577
5577
  h: BigInt(1),
@@ -5582,37 +5582,37 @@ var hi = {
5582
5582
  }, Hu = {
5583
5583
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
5584
5584
  basises: [[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")], [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]
5585
- }, Ji = /* @__PURE__ */ BigInt(2);
5585
+ }, Qi = /* @__PURE__ */ BigInt(2);
5586
5586
  function Lu(e) {
5587
- const t = hi.p, r = BigInt(3), n = BigInt(6), i = BigInt(11), o = BigInt(22), a = BigInt(23), f = BigInt(44), l = BigInt(88), p = e * e * e % t, u = p * p * e % t, d = Rt(Rt(Rt(u, r, t) * u % t, r, t) * u % t, Ji, t) * p % t, w = Rt(d, i, t) * d % t, b = Rt(w, o, t) * w % t, m = Rt(b, f, t) * b % t, v = Rt(Rt(Rt(Rt(Rt(Rt(m, l, t) * m % t, f, t) * b % t, r, t) * u % t, a, t) * w % t, n, t) * p % t, Ji, t);
5588
- if (!Hn.eql(Hn.sqr(v), e)) throw new Error("Cannot find square root");
5587
+ const t = oi.p, r = BigInt(3), n = BigInt(6), i = BigInt(11), o = BigInt(22), a = BigInt(23), f = BigInt(44), l = BigInt(88), p = e * e * e % t, u = p * p * e % t, d = Rt(Rt(Rt(u, r, t) * u % t, r, t) * u % t, Qi, t) * p % t, w = Rt(d, i, t) * d % t, y = Rt(w, o, t) * w % t, m = Rt(y, f, t) * y % t, v = Rt(Rt(Rt(Rt(Rt(Rt(m, l, t) * m % t, f, t) * y % t, r, t) * u % t, a, t) * w % t, n, t) * p % t, Qi, t);
5588
+ if (!Nn.eql(Nn.sqr(v), e)) throw new Error("Cannot find square root");
5589
5589
  return v;
5590
5590
  }
5591
- var Hn = nn(hi.p, { sqrt: Lu });
5592
- (/* @__PURE__ */ Nu(/* @__PURE__ */ _u(hi, {
5593
- Fp: Hn,
5591
+ var Nn = nn(oi.p, { sqrt: Lu });
5592
+ (/* @__PURE__ */ Nu(/* @__PURE__ */ _u(oi, {
5593
+ Fp: Nn,
5594
5594
  endo: Hu
5595
5595
  }), au)).Point.Fn.ORDER;
5596
5596
  function H(e) {
5597
5597
  return Xh(e);
5598
5598
  }
5599
- function Z(e, t) {
5599
+ function X(e, t) {
5600
5600
  if (!e) throw new Error(`verifyCryptoBackend: ${t}`);
5601
5601
  }
5602
5602
  function Cu(e) {
5603
- Z(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isPoint should accept generator point"), Z(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005")), "isPoint should reject invalid point"), Z(e.isXOnlyPoint(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isXOnlyPoint should accept generator x-coordinate"), Z(!e.isXOnlyPoint(H("0000000000000000000000000000000000000000000000000000000000000005")), "isXOnlyPoint should reject x-coordinate not on curve"), Z(!e.isXOnlyPoint(H("0000000000000000000000000000000000000000000000000000000000000000")), "isXOnlyPoint should reject zero"), Z(!e.isXOnlyPoint(H("79be667ef9dcbbac55a06295ce870b07")), "isXOnlyPoint should reject wrong length"), Z(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isPrivate should accept valid scalar"), Z(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")), "isPrivate should accept n-1"), Z(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000")), "isPrivate should reject zero"), Z(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141")), "isPrivate should reject n"), Z(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142")), "isPrivate should reject n+1");
5603
+ X(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isPoint should accept generator point"), X(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005")), "isPoint should reject invalid point"), X(e.isXOnlyPoint(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isXOnlyPoint should accept generator x-coordinate"), X(!e.isXOnlyPoint(H("0000000000000000000000000000000000000000000000000000000000000005")), "isXOnlyPoint should reject x-coordinate not on curve"), X(!e.isXOnlyPoint(H("0000000000000000000000000000000000000000000000000000000000000000")), "isXOnlyPoint should reject zero"), X(!e.isXOnlyPoint(H("79be667ef9dcbbac55a06295ce870b07")), "isXOnlyPoint should reject wrong length"), X(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isPrivate should accept valid scalar"), X(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")), "isPrivate should accept n-1"), X(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000")), "isPrivate should reject zero"), X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141")), "isPrivate should reject n"), X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142")), "isPrivate should reject n+1");
5604
5604
  const t = e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"), H("0000000000000000000000000000000000000000000000000000000000000000"));
5605
- Z(t !== null && Ut(t, H("0000000000000000000000000000000000000000000000000000000000000001")), "privateAdd: 1 + 0 should equal 1"), Z(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"), H("0000000000000000000000000000000000000000000000000000000000000003")) === null, "privateAdd: (n-3) + 3 should return null (result is zero mod n)");
5605
+ X(t !== null && Ut(t, H("0000000000000000000000000000000000000000000000000000000000000001")), "privateAdd: 1 + 0 should equal 1"), X(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"), H("0000000000000000000000000000000000000000000000000000000000000003")) === null, "privateAdd: (n-3) + 3 should return null (result is zero mod n)");
5606
5606
  const r = e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"), H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"));
5607
- Z(r !== null && Ut(r, H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24")), "privateAdd: known vector failed"), Z(Ut(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001")), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")), "privateNegate(1) should equal n-1"), Z(Ut(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")), H("0000000000000000000000000000000000000000000000000000000000000003")), "privateNegate(n-3) should equal 3"), Z(Ut(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")), H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")), "privateNegate known vector failed"), Z(Ut(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"), !0), H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "pointCompress uncompressed->compressed failed"), Z(Ut(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"), !1), H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")), "pointCompress uncompressed->uncompressed failed"), Z(Ut(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), !0), H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "pointCompress compressed->compressed failed"), Z(Ut(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), !1), H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")), "pointCompress compressed->uncompressed failed");
5607
+ X(r !== null && Ut(r, H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24")), "privateAdd: known vector failed"), X(Ut(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001")), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")), "privateNegate(1) should equal n-1"), X(Ut(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")), H("0000000000000000000000000000000000000000000000000000000000000003")), "privateNegate(n-3) should equal 3"), X(Ut(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")), H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")), "privateNegate known vector failed"), X(Ut(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"), !0), H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "pointCompress uncompressed->compressed failed"), X(Ut(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"), !1), H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")), "pointCompress uncompressed->uncompressed failed"), X(Ut(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), !0), H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "pointCompress compressed->compressed failed"), X(Ut(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), !1), H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")), "pointCompress compressed->uncompressed failed");
5608
5608
  const n = e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"));
5609
- Z(n !== null && Ut(n, H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99")), "pointFromScalar known vector failed"), Z(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")) === null, "xOnlyPointAddTweak should return null for infinity result");
5609
+ X(n !== null && Ut(n, H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99")), "pointFromScalar known vector failed"), X(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")) === null, "xOnlyPointAddTweak should return null for infinity result");
5610
5610
  let i = e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"), H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));
5611
- Z(i !== null && Ut(i.xOnlyPubkey, H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf")) && i.parity === 1, "xOnlyPointAddTweak parity=1 case failed"), i = e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"), H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")), Z(i !== null && Ut(i.xOnlyPubkey, H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c")) && i.parity === 0, "xOnlyPointAddTweak parity=0 case failed");
5611
+ X(i !== null && Ut(i.xOnlyPubkey, H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf")) && i.parity === 1, "xOnlyPointAddTweak parity=1 case failed"), i = e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"), H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")), X(i !== null && Ut(i.xOnlyPubkey, H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c")) && i.parity === 0, "xOnlyPointAddTweak parity=0 case failed");
5612
5612
  const o = e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"));
5613
- Z(Ut(o, H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5")), "sign known vector failed"), Z(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"), H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), o), "verify known vector failed"), e.signSchnorr && Z(Ut(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"), H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"), H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")), H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")), "signSchnorr known vector failed"), e.verifySchnorr && Z(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"), H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"), H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")), "verifySchnorr known vector failed");
5613
+ X(Ut(o, H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5")), "sign known vector failed"), X(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"), H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), o), "verify known vector failed"), e.signSchnorr && X(Ut(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"), H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"), H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")), H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")), "signSchnorr known vector failed"), e.verifySchnorr && X(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"), H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"), H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")), "verifySchnorr known vector failed");
5614
5614
  }
5615
- var Ln = class Kt {
5615
+ var Hn = class Kt {
5616
5616
  static #t;
5617
5617
  #a;
5618
5618
  constructor(t) {
@@ -5637,13 +5637,13 @@ var Ln = class Kt {
5637
5637
  };
5638
5638
  function Wl(e) {
5639
5639
  if (e === void 0) {
5640
- Ln.clear();
5640
+ Hn.clear();
5641
5641
  return;
5642
5642
  }
5643
- Ln.init(e);
5643
+ Hn.init(e);
5644
5644
  }
5645
5645
  function Vu() {
5646
- return Ln.get().lib;
5646
+ return Hn.get().lib;
5647
5647
  }
5648
5648
  var $u = (e) => "left" in e && "right" in e;
5649
5649
  function Mr(e, t) {
@@ -5667,7 +5667,7 @@ function hr(e, t) {
5667
5667
  return n;
5668
5668
  }
5669
5669
  function ur(e) {
5670
- if (Vs(e)) return { hash: Pt(e) };
5670
+ if (Cs(e)) return { hash: Pt(e) };
5671
5671
  const t = [ur(e[0]), ur(e[1])];
5672
5672
  t.sort((i, o) => De(i.hash, o.hash));
5673
5673
  const r = t[0], n = t[1];
@@ -5707,7 +5707,7 @@ function Du(e) {
5707
5707
  const t = Et(Ct(e.length));
5708
5708
  return ge(e.length, t), Bt([t, e]);
5709
5709
  }
5710
- var ts = j, es = 2, Mu = 80, No = class rr {
5710
+ var Ji = j, ts = 2, Mu = 80, No = class rr {
5711
5711
  static NAME = ft.P2MR;
5712
5712
  #t;
5713
5713
  #a;
@@ -5834,8 +5834,8 @@ var ts = j, es = 2, Mu = 80, No = class rr {
5834
5834
  if (this.#e) return this.#e;
5835
5835
  const t = this.hash;
5836
5836
  if (!t) return;
5837
- const r = tt.bech32m.toWords(t);
5838
- return r.unshift(es), tt.bech32m.encode(this.#t.bech32, r);
5837
+ const r = et.bech32m.toWords(t);
5838
+ return r.unshift(ts), et.bech32m.encode(this.#t.bech32, r);
5839
5839
  }
5840
5840
  #B() {
5841
5841
  if (this.#s) return this.#s;
@@ -5855,7 +5855,7 @@ var ts = j, es = 2, Mu = 80, No = class rr {
5855
5855
  #_() {
5856
5856
  if (this.#n) return this.#n;
5857
5857
  const t = this.hash;
5858
- if (t) return gt([ts.OP_2, t]);
5858
+ if (t) return gt([Ji.OP_2, t]);
5859
5859
  }
5860
5860
  #R() {
5861
5861
  if (this.#o) return this.#o;
@@ -5885,17 +5885,17 @@ var ts = j, es = 2, Mu = 80, No = class rr {
5885
5885
  }
5886
5886
  }
5887
5887
  #L() {
5888
- let t = new Uint8Array(0);
5888
+ let t = /* @__PURE__ */ new Uint8Array(0);
5889
5889
  if (this.#e) {
5890
5890
  const i = this.#P();
5891
5891
  if (!i) throw new TypeError("Invalid address");
5892
5892
  if (this.#t && this.#t.bech32 !== i.prefix) throw new TypeError("Invalid prefix or Network mismatch");
5893
- if (i.version !== es) throw new TypeError("Invalid address version");
5893
+ if (i.version !== ts) throw new TypeError("Invalid address version");
5894
5894
  if (i.data.length !== 32) throw new TypeError("Invalid address data");
5895
5895
  t = i.data;
5896
5896
  }
5897
5897
  if (this.#n) {
5898
- if (this.#n.length !== 34 || this.#n[0] !== ts.OP_2 || this.#n[1] !== 32) throw new TypeError("Output is invalid");
5898
+ if (this.#n.length !== 34 || this.#n[0] !== Ji.OP_2 || this.#n[1] !== 32) throw new TypeError("Output is invalid");
5899
5899
  if (t.length > 0 && !x(t, this.#n.subarray(2))) throw new TypeError("Hash mismatch");
5900
5900
  t = this.#n.subarray(2);
5901
5901
  }
@@ -5914,7 +5914,7 @@ var ts = j, es = 2, Mu = 80, No = class rr {
5914
5914
  if (this.#o && this.redeem) {
5915
5915
  if (this.#o.redeemVersion && this.#o.redeemVersion !== this.redeem.redeemVersion) throw new TypeError("Redeem.redeemVersion and witness mismatch");
5916
5916
  if (this.#o.output) {
5917
- const i = et(this.#o.output);
5917
+ const i = rt(this.#o.output);
5918
5918
  if (!i || i.length === 0) throw new TypeError("Redeem.output is invalid");
5919
5919
  if (this.redeem.output && !x(this.#o.output, this.redeem.output)) throw new TypeError("Redeem.output and witness mismatch");
5920
5920
  }
@@ -5937,7 +5937,7 @@ var ts = j, es = 2, Mu = 80, No = class rr {
5937
5937
  }
5938
5938
  }
5939
5939
  };
5940
- function ui(e, t) {
5940
+ function ai(e, t) {
5941
5941
  if (!e.address && !e.output && !e.hash && !e.scriptTree && !(e.witness && e.witness.length > 1)) throw new TypeError("Not enough data");
5942
5942
  const r = new No({
5943
5943
  address: e.address,
@@ -5951,7 +5951,7 @@ function ui(e, t) {
5951
5951
  }, t);
5952
5952
  return Object.assign(r.toPayment(), e);
5953
5953
  }
5954
- var rs = j, ns = 1, Fu = 80, Ho = class nr {
5954
+ var es = j, rs = 1, Fu = 80, Ho = class nr {
5955
5955
  static NAME = ft.P2TR;
5956
5956
  #t;
5957
5957
  #a;
@@ -6101,8 +6101,8 @@ var rs = j, ns = 1, Fu = 80, Ho = class nr {
6101
6101
  if (this.#e) return this.#e;
6102
6102
  const t = this.pubkey;
6103
6103
  if (!t) return;
6104
- const r = tt.bech32m.toWords(t);
6105
- return r.unshift(ns), tt.bech32m.encode(this.#t.bech32, r);
6104
+ const r = et.bech32m.toWords(t);
6105
+ return r.unshift(rs), et.bech32m.encode(this.#t.bech32, r);
6106
6106
  }
6107
6107
  #K() {
6108
6108
  if (this.#s) return this.#s;
@@ -6142,7 +6142,7 @@ var rs = j, ns = 1, Fu = 80, Ho = class nr {
6142
6142
  #W() {
6143
6143
  if (this.#h) return this.#h;
6144
6144
  const t = this.pubkey;
6145
- if (t) return gt([rs.OP_1, t]);
6145
+ if (t) return gt([es.OP_1, t]);
6146
6146
  }
6147
6147
  #G() {
6148
6148
  if (this.#u) return this.#u;
@@ -6179,12 +6179,12 @@ var rs = j, ns = 1, Fu = 80, Ho = class nr {
6179
6179
  if (this.#o) return [this.#o];
6180
6180
  }
6181
6181
  #q() {
6182
- let t = new Uint8Array(0);
6182
+ let t = /* @__PURE__ */ new Uint8Array(0);
6183
6183
  if (this.#e) {
6184
6184
  const i = this.#L();
6185
6185
  if (!i) throw new TypeError("Invalid address");
6186
6186
  if (this.#t && this.#t.bech32 !== i.prefix) throw new TypeError("Invalid prefix or Network mismatch");
6187
- if (i.version !== ns) throw new TypeError("Invalid address version");
6187
+ if (i.version !== rs) throw new TypeError("Invalid address version");
6188
6188
  if (i.data.length !== 32) throw new TypeError("Invalid address data");
6189
6189
  t = i.data;
6190
6190
  }
@@ -6193,7 +6193,7 @@ var rs = j, ns = 1, Fu = 80, Ho = class nr {
6193
6193
  t = this.#s;
6194
6194
  }
6195
6195
  if (this.#h) {
6196
- if (this.#h.length !== 34 || this.#h[0] !== rs.OP_1 || this.#h[1] !== 32) throw new TypeError("Output is invalid");
6196
+ if (this.#h.length !== 34 || this.#h[0] !== es.OP_1 || this.#h[1] !== 32) throw new TypeError("Output is invalid");
6197
6197
  if (t.length > 0 && !x(t, this.#h.subarray(2))) throw new TypeError("Pubkey mismatch");
6198
6198
  t = this.#h.subarray(2);
6199
6199
  }
@@ -6214,7 +6214,7 @@ var rs = j, ns = 1, Fu = 80, Ho = class nr {
6214
6214
  if (this.#u && this.redeem) {
6215
6215
  if (this.#u.redeemVersion && this.#u.redeemVersion !== this.redeem.redeemVersion) throw new TypeError("Redeem.redeemVersion and witness mismatch");
6216
6216
  if (this.#u.output) {
6217
- const i = et(this.#u.output);
6217
+ const i = rt(this.#u.output);
6218
6218
  if (!i || i.length === 0) throw new TypeError("Redeem.output is invalid");
6219
6219
  if (this.redeem.output && !x(this.#u.output, this.redeem.output)) throw new TypeError("Redeem.output and witness mismatch");
6220
6220
  }
@@ -6259,7 +6259,7 @@ function wr(e, t) {
6259
6259
  }, t);
6260
6260
  return Object.assign(r.toPayment(), e);
6261
6261
  }
6262
- var is = j, Wu = new Uint8Array(0), Lo = class ir {
6262
+ var ns = j, Wu = /* @__PURE__ */ new Uint8Array(0), Lo = class ir {
6263
6263
  static NAME = ft.P2WPKH;
6264
6264
  #t;
6265
6265
  #a;
@@ -6358,7 +6358,7 @@ var is = j, Wu = new Uint8Array(0), Lo = class ir {
6358
6358
  #A() {
6359
6359
  if (!this.#S) {
6360
6360
  if (this.#e) {
6361
- const t = tt.bech32.decode(this.#e), r = t.words.shift(), n = tt.bech32.fromWords(t.words);
6361
+ const t = et.bech32.decode(this.#e), r = t.words.shift(), n = et.bech32.fromWords(t.words);
6362
6362
  this.#b = {
6363
6363
  version: r ?? 0,
6364
6364
  prefix: t.prefix,
@@ -6373,8 +6373,8 @@ var is = j, Wu = new Uint8Array(0), Lo = class ir {
6373
6373
  if (this.#e) return this.#e;
6374
6374
  const t = this.hash;
6375
6375
  if (!t) return;
6376
- const r = tt.bech32.toWords(t);
6377
- return r.unshift(0), tt.bech32.encode(this.#t.bech32, r);
6376
+ const r = et.bech32.toWords(t);
6377
+ return r.unshift(0), et.bech32.encode(this.#t.bech32, r);
6378
6378
  }
6379
6379
  #k() {
6380
6380
  if (this.#s) return this.#s;
@@ -6394,7 +6394,7 @@ var is = j, Wu = new Uint8Array(0), Lo = class ir {
6394
6394
  #O() {
6395
6395
  if (this.#i) return this.#i;
6396
6396
  const t = this.hash;
6397
- if (t) return gt([is.OP_0, t]);
6397
+ if (t) return gt([ns.OP_0, t]);
6398
6398
  }
6399
6399
  #x() {
6400
6400
  if (this.witness) return Wu;
@@ -6404,7 +6404,7 @@ var is = j, Wu = new Uint8Array(0), Lo = class ir {
6404
6404
  if (!(!this.#r || !this.#n)) return [this.#n, this.#r];
6405
6405
  }
6406
6406
  #_() {
6407
- let t = new Uint8Array(0);
6407
+ let t = /* @__PURE__ */ new Uint8Array(0);
6408
6408
  if (this.#e) {
6409
6409
  const r = this.#A();
6410
6410
  if (!r) throw new TypeError("Invalid address");
@@ -6418,7 +6418,7 @@ var is = j, Wu = new Uint8Array(0), Lo = class ir {
6418
6418
  t = this.#s;
6419
6419
  }
6420
6420
  if (this.#i) {
6421
- if (this.#i.length !== 22 || this.#i[0] !== is.OP_0 || this.#i[1] !== 20) throw new TypeError("Output is invalid");
6421
+ if (this.#i.length !== 22 || this.#i[0] !== ns.OP_0 || this.#i[1] !== 20) throw new TypeError("Output is invalid");
6422
6422
  if (t.length > 0 && !x(t, this.#i.subarray(2))) throw new TypeError("Hash mismatch");
6423
6423
  t = this.#i.subarray(2);
6424
6424
  }
@@ -6452,7 +6452,7 @@ function sn(e, t) {
6452
6452
  }, t);
6453
6453
  return Object.assign(r.toPayment(), e);
6454
6454
  }
6455
- var ss = j, mn = new Uint8Array(0);
6455
+ var is = j, mn = /* @__PURE__ */ new Uint8Array(0);
6456
6456
  function Sr(e) {
6457
6457
  return !!(e instanceof Uint8Array && e.length === 65 && e[0] === 4 && ke(e));
6458
6458
  }
@@ -6553,7 +6553,7 @@ var Co = class sr {
6553
6553
  #S() {
6554
6554
  if (!this.#v) {
6555
6555
  if (this.#e) {
6556
- const t = tt.bech32.decode(this.#e), r = t.words.shift(), n = tt.bech32.fromWords(t.words);
6556
+ const t = et.bech32.decode(this.#e), r = t.words.shift(), n = et.bech32.fromWords(t.words);
6557
6557
  this.#E = {
6558
6558
  version: r ?? 0,
6559
6559
  prefix: t.prefix,
@@ -6565,14 +6565,14 @@ var Co = class sr {
6565
6565
  return this.#E;
6566
6566
  }
6567
6567
  #A() {
6568
- return this.#b || (this.#n?.input && (this.#I = et(this.#n.input) ?? void 0), this.#b = !0), this.#I;
6568
+ return this.#b || (this.#n?.input && (this.#I = rt(this.#n.input) ?? void 0), this.#b = !0), this.#I;
6569
6569
  }
6570
6570
  #T() {
6571
6571
  if (this.#e) return this.#e;
6572
6572
  const t = this.hash;
6573
6573
  if (!t) return;
6574
- const r = tt.bech32.toWords(t);
6575
- return r.unshift(0), tt.bech32.encode(this.#t.bech32, r);
6574
+ const r = et.bech32.toWords(t);
6575
+ return r.unshift(0), et.bech32.encode(this.#t.bech32, r);
6576
6576
  }
6577
6577
  #k() {
6578
6578
  if (this.#s) return this.#s;
@@ -6584,7 +6584,7 @@ var Co = class sr {
6584
6584
  #P() {
6585
6585
  if (this.#r) return this.#r;
6586
6586
  const t = this.hash;
6587
- if (t) return gt([ss.OP_0, t]);
6587
+ if (t) return gt([is.OP_0, t]);
6588
6588
  }
6589
6589
  #U() {
6590
6590
  if (this.witness) return mn;
@@ -6604,7 +6604,7 @@ var Co = class sr {
6604
6604
  if (t.input && t.input.length > 0 && t.output && t.output.length > 0) {
6605
6605
  const r = this.#A();
6606
6606
  if (r) {
6607
- const n = Ms(r);
6607
+ const n = Ds(r);
6608
6608
  return this.#c = Object.assign({ witness: n }, t, { input: mn }), this.#y = !0, [].concat(n, t.output);
6609
6609
  }
6610
6610
  }
@@ -6612,7 +6612,7 @@ var Co = class sr {
6612
6612
  }
6613
6613
  }
6614
6614
  #B() {
6615
- let t = new Uint8Array(0);
6615
+ let t = /* @__PURE__ */ new Uint8Array(0);
6616
6616
  if (this.#e) {
6617
6617
  const r = this.#S();
6618
6618
  if (!r) throw new TypeError("Invalid address");
@@ -6626,7 +6626,7 @@ var Co = class sr {
6626
6626
  t = this.#s;
6627
6627
  }
6628
6628
  if (this.#r) {
6629
- if (this.#r.length !== 34 || this.#r[0] !== ss.OP_0 || this.#r[1] !== 32) throw new TypeError("Output is invalid");
6629
+ if (this.#r.length !== 34 || this.#r[0] !== is.OP_0 || this.#r[1] !== 32) throw new TypeError("Output is invalid");
6630
6630
  const r = this.#r.subarray(2);
6631
6631
  if (t.length > 0 && !x(t, r)) throw new TypeError("Hash mismatch");
6632
6632
  t = r;
@@ -6635,10 +6635,10 @@ var Co = class sr {
6635
6635
  if (this.#n.network && this.#n.network !== this.#t) throw new TypeError("Network mismatch");
6636
6636
  if (this.#n.input && this.#n.input.length > 0 && this.#n.witness && this.#n.witness.length > 0) throw new TypeError("Ambiguous witness source");
6637
6637
  if (this.#n.output) {
6638
- const n = et(this.#n.output);
6638
+ const n = rt(this.#n.output);
6639
6639
  if (!n || n.length < 1) throw new TypeError("Redeem.output is invalid");
6640
6640
  if (this.#n.output.byteLength > 3600) throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");
6641
- if (Zn(n) > 201) throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
6641
+ if (Xn(n) > 201) throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
6642
6642
  const i = It(this.#n.output);
6643
6643
  if (t.length > 0 && !x(t, i)) throw new TypeError("Hash mismatch");
6644
6644
  t = i;
@@ -6646,12 +6646,12 @@ var Co = class sr {
6646
6646
  const r = this.#A();
6647
6647
  if (this.#n.input && r && !Jr(r)) throw new TypeError("Non push-only scriptSig");
6648
6648
  if (this.#i && this.#n.witness && !Ue(this.#i, this.#n.witness)) throw new TypeError("Witness and redeem.witness mismatch");
6649
- if (this.#n.input && r?.some(Sr) || this.#n.output && (et(this.#n.output) || []).some(Sr)) throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey");
6649
+ if (this.#n.input && r?.some(Sr) || this.#n.output && (rt(this.#n.output) || []).some(Sr)) throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey");
6650
6650
  }
6651
6651
  if (this.#i && this.#i.length > 0) {
6652
6652
  const r = this.#i[this.#i.length - 1];
6653
6653
  if (this.#n && this.#n.output && !x(this.#n.output, r)) throw new TypeError("Witness and redeem.output mismatch");
6654
- if (this.#i.some(Sr) || (et(r) || []).some(Sr)) throw new TypeError("Witness contains uncompressed pubkey");
6654
+ if (this.#i.some(Sr) || (rt(r) || []).some(Sr)) throw new TypeError("Witness contains uncompressed pubkey");
6655
6655
  }
6656
6656
  }
6657
6657
  };
@@ -6666,7 +6666,7 @@ function gr(e, t) {
6666
6666
  network: e.network
6667
6667
  }, t).toPayment();
6668
6668
  }
6669
- var os = j, Vo = class Br {
6669
+ var ss = j, Vo = class Br {
6670
6670
  static NAME = ft.P2PK;
6671
6671
  #t;
6672
6672
  #a;
@@ -6748,14 +6748,14 @@ var os = j, Vo = class Br {
6748
6748
  #y() {
6749
6749
  if (this.#s) return this.#s;
6750
6750
  if (this.#n) {
6751
- const t = et(this.#n);
6751
+ const t = rt(this.#n);
6752
6752
  if (t && t.length > 0) return t[0];
6753
6753
  }
6754
6754
  }
6755
6755
  #m() {
6756
6756
  if (this.#r) return this.#r;
6757
6757
  const t = this.#e;
6758
- if (t) return gt([t, os.OP_CHECKSIG]);
6758
+ if (t) return gt([t, ss.OP_CHECKSIG]);
6759
6759
  }
6760
6760
  #E() {
6761
6761
  if (this.#n) return this.#n;
@@ -6767,7 +6767,7 @@ var os = j, Vo = class Br {
6767
6767
  }
6768
6768
  #I() {
6769
6769
  if (this.#r) {
6770
- if (this.#r[this.#r.length - 1] !== os.OP_CHECKSIG) throw new TypeError("Output is invalid");
6770
+ if (this.#r[this.#r.length - 1] !== ss.OP_CHECKSIG) throw new TypeError("Output is invalid");
6771
6771
  const t = this.pubkey;
6772
6772
  if (!ke(t)) throw new TypeError("Output pubkey is invalid");
6773
6773
  if (this.#e && t && !x(this.#e, t)) throw new TypeError("Pubkey mismatch");
@@ -6777,14 +6777,14 @@ var os = j, Vo = class Br {
6777
6777
  if (this.#n && t && !x(this.#n, t)) throw new TypeError("Signature mismatch");
6778
6778
  }
6779
6779
  if (this.#n) {
6780
- const t = et(this.#n);
6780
+ const t = rt(this.#n);
6781
6781
  if (!t || t.length !== 1) throw new TypeError("Input is invalid");
6782
6782
  const r = this.signature;
6783
6783
  if (!r || !xe(r)) throw new TypeError("Input has invalid signature");
6784
6784
  }
6785
6785
  }
6786
6786
  };
6787
- function fi(e, t) {
6787
+ function hi(e, t) {
6788
6788
  if (!e.input && !e.output && !e.pubkey && !e.signature) throw new TypeError("Not enough data");
6789
6789
  const r = new Vo({
6790
6790
  pubkey: e.pubkey,
@@ -6890,7 +6890,7 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
6890
6890
  };
6891
6891
  }
6892
6892
  #A(t) {
6893
- this.#S || (this.#S = !0, this.#b = et(t) ?? [], this.#h = this.#b[0] - Tr, this.#f = this.#b[this.#b.length - 2] - Tr, this.#u = this.#b.slice(1, -2), this.#w = !0, this.#g = !0, this.#y = !0);
6893
+ this.#S || (this.#S = !0, this.#b = rt(t) ?? [], this.#h = this.#b[0] - Tr, this.#f = this.#b[this.#b.length - 2] - Tr, this.#u = this.#b.slice(1, -2), this.#w = !0, this.#g = !0, this.#y = !0);
6894
6894
  }
6895
6895
  #T() {
6896
6896
  if (this.#e !== void 0) return this.#e;
@@ -6908,7 +6908,7 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
6908
6908
  }
6909
6909
  #U() {
6910
6910
  if (this.#n) return this.#n;
6911
- if (this.#o) return et(this.#o)?.slice(1);
6911
+ if (this.#o) return rt(this.#o)?.slice(1);
6912
6912
  }
6913
6913
  #O() {
6914
6914
  if (this.#i) return this.#i;
@@ -6979,7 +6979,7 @@ function Gu(e) {
6979
6979
  const t = e.length;
6980
6980
  return Ct(t) + e.reduce((r, n) => r + Nt(n), 0);
6981
6981
  }
6982
- var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000000000000000000000000000000000"), hs = Or(Mt("0000000000000000000000000000000000000000000000000000000000000001")), ju = 18446744073709551615n, J = class Q {
6982
+ var ce = /* @__PURE__ */ new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000000000000000000000000000000000"), as = Or(Mt("0000000000000000000000000000000000000000000000000000000000000001")), ju = 18446744073709551615n, tt = class J {
6983
6983
  static DEFAULT_SEQUENCE = 4294967295;
6984
6984
  static SIGHASH_DEFAULT = 0;
6985
6985
  static SIGHASH_ALL = 1;
@@ -6998,20 +6998,20 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
6998
6998
  ins = [];
6999
6999
  outs = [];
7000
7000
  static fromBuffer(t, r) {
7001
- const n = new _a(t), i = new Q();
7001
+ const n = new _a(t), i = new J();
7002
7002
  i.version = n.readInt32LE();
7003
7003
  const o = n.readUInt8(), a = n.readUInt8();
7004
7004
  let f = !1;
7005
- o === Q.ADVANCED_TRANSACTION_MARKER && a === Q.ADVANCED_TRANSACTION_FLAG ? f = !0 : n.offset -= 2;
7005
+ o === J.ADVANCED_TRANSACTION_MARKER && a === J.ADVANCED_TRANSACTION_FLAG ? f = !0 : n.offset -= 2;
7006
7006
  const l = n.readVarInt();
7007
7007
  for (let u = 0; u < l; ++u) {
7008
- const d = n.readBytes(32), w = n.readUInt32LE(), b = n.readVarBytes(), m = n.readUInt32LE();
7008
+ const d = n.readBytes(32), w = n.readUInt32LE(), y = n.readVarBytes(), m = n.readUInt32LE();
7009
7009
  i.ins.push({
7010
7010
  hash: d,
7011
7011
  index: w,
7012
- script: b,
7012
+ script: y,
7013
7013
  sequence: m,
7014
- witness: as
7014
+ witness: os
7015
7015
  });
7016
7016
  }
7017
7017
  const p = n.readVarInt();
@@ -7028,7 +7028,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7028
7028
  return i;
7029
7029
  }
7030
7030
  static fromHex(t) {
7031
- return Q.fromBuffer(Mt(t), !1);
7031
+ return J.fromBuffer(Mt(t), !1);
7032
7032
  }
7033
7033
  static isCoinbaseHash(t) {
7034
7034
  if (t.length !== 32) throw new TypeError("Expected 32-byte hash");
@@ -7037,18 +7037,18 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7037
7037
  }
7038
7038
  isCoinbase() {
7039
7039
  const t = this.ins[0];
7040
- return this.ins.length === 1 && t !== void 0 && Q.isCoinbaseHash(t.hash);
7040
+ return this.ins.length === 1 && t !== void 0 && J.isCoinbaseHash(t.hash);
7041
7041
  }
7042
7042
  addInput(t, r, n, i) {
7043
7043
  if (t.length !== 32) throw new TypeError("Expected 32-byte hash");
7044
7044
  if (!Number.isInteger(r) || r < 0 || r > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for index");
7045
7045
  if (n != null && (!Number.isInteger(n) || n < 0 || n > 4294967295)) throw new TypeError("Expected unsigned 32-bit integer for sequence");
7046
- return n ??= Q.DEFAULT_SEQUENCE, this.ins.push({
7046
+ return n ??= J.DEFAULT_SEQUENCE, this.ins.push({
7047
7047
  hash: t,
7048
7048
  index: r,
7049
7049
  script: i || ce,
7050
7050
  sequence: n,
7051
- witness: as
7051
+ witness: os
7052
7052
  }) - 1;
7053
7053
  }
7054
7054
  addOutput(t, r) {
@@ -7074,7 +7074,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7074
7074
  return (r ? 10 : 8) + Ct(this.ins.length) + Ct(this.outs.length) + this.ins.reduce((n, i) => n + 40 + Nt(i.script), 0) + this.outs.reduce((n, i) => n + 8 + Nt(i.script), 0) + (r ? this.ins.reduce((n, i) => n + Gu(i.witness), 0) : 0);
7075
7075
  }
7076
7076
  clone() {
7077
- const t = new Q();
7077
+ const t = new J();
7078
7078
  return t.version = this.version, t.locktime = this.locktime, t.ins = this.ins.map((r) => ({
7079
7079
  hash: r.hash,
7080
7080
  index: r.index,
@@ -7090,15 +7090,15 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7090
7090
  if (!Number.isInteger(t) || t < 0) throw new TypeError("Expected non-negative integer for inIndex");
7091
7091
  if (!(r instanceof Uint8Array)) throw new TypeError("Expected Uint8Array for prevOutScript");
7092
7092
  if (!Number.isInteger(n)) throw new TypeError("Expected integer for hashType");
7093
- if (t >= this.ins.length) return hs;
7094
- const i = et(r);
7093
+ if (t >= this.ins.length) return as;
7094
+ const i = rt(r);
7095
7095
  if (!i) throw new Error("Could not decompile prevOutScript");
7096
7096
  const o = gt(i.filter((l) => l !== j.OP_CODESEPARATOR)), a = this.clone();
7097
- if ((n & 31) === Q.SIGHASH_NONE) a.outs = [], a.ins.forEach((l, p) => {
7097
+ if ((n & 31) === J.SIGHASH_NONE) a.outs = [], a.ins.forEach((l, p) => {
7098
7098
  p !== t && (l.sequence = 0);
7099
7099
  });
7100
- else if ((n & 31) === Q.SIGHASH_SINGLE) {
7101
- if (t >= this.outs.length) return hs;
7100
+ else if ((n & 31) === J.SIGHASH_SINGLE) {
7101
+ if (t >= this.outs.length) return as;
7102
7102
  a.outs.length = t + 1;
7103
7103
  for (let l = 0; l < t; l++) a.outs[l] = {
7104
7104
  script: ce,
@@ -7108,7 +7108,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7108
7108
  p !== t && (l.sequence = 0);
7109
7109
  });
7110
7110
  }
7111
- n & Q.SIGHASH_ANYONECANPAY ? (a.ins = [a.ins[t]], a.ins[0].script = o) : (a.ins.forEach((l) => {
7111
+ n & J.SIGHASH_ANYONECANPAY ? (a.ins = [a.ins[t]], a.ins[0].script = o) : (a.ins.forEach((l) => {
7112
7112
  l.script = ce;
7113
7113
  }), a.ins[t].script = o);
7114
7114
  const f = Et(a.byteLength(!1) + 4);
@@ -7116,40 +7116,40 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7116
7116
  }
7117
7117
  hashForWitnessV1(t, r, n, i, o, a, f) {
7118
7118
  if (!Number.isInteger(t) || t < 0 || t > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for inIndex");
7119
- if (!Array.isArray(r) || !r.every((D) => D instanceof Uint8Array)) throw new TypeError("Expected array of Uint8Array for prevOutScripts");
7120
- if (!Array.isArray(n) || !n.every((D) => typeof D == "bigint")) throw new TypeError("Expected array of bigint for values");
7119
+ if (!Array.isArray(r) || !r.every((M) => M instanceof Uint8Array)) throw new TypeError("Expected array of Uint8Array for prevOutScripts");
7120
+ if (!Array.isArray(n) || !n.every((M) => typeof M == "bigint")) throw new TypeError("Expected array of bigint for values");
7121
7121
  if (!Number.isInteger(i) || i < 0 || i > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for hashType");
7122
7122
  if (n.length !== this.ins.length || r.length !== this.ins.length) throw new Error("Must supply prevout script and value for all inputs");
7123
- const l = i === Q.SIGHASH_DEFAULT ? Q.SIGHASH_ALL : i & Q.SIGHASH_OUTPUT_MASK, p = (i & Q.SIGHASH_INPUT_MASK) === Q.SIGHASH_ANYONECANPAY, u = l === Q.SIGHASH_NONE, d = l === Q.SIGHASH_SINGLE;
7124
- let w = ce, b = ce, m = ce, v = ce, I = ce;
7125
- if (!p) if (f) w = f.hashPrevouts, b = f.hashAmounts, m = f.hashScriptPubKeys, v = f.hashSequences;
7123
+ const l = i === J.SIGHASH_DEFAULT ? J.SIGHASH_ALL : i & J.SIGHASH_OUTPUT_MASK, p = (i & J.SIGHASH_INPUT_MASK) === J.SIGHASH_ANYONECANPAY, u = l === J.SIGHASH_NONE, d = l === J.SIGHASH_SINGLE;
7124
+ let w = ce, y = ce, m = ce, v = ce, I = ce;
7125
+ if (!p) if (f) w = f.hashPrevouts, y = f.hashAmounts, m = f.hashScriptPubKeys, v = f.hashSequences;
7126
7126
  else {
7127
- let D = new dt(36 * this.ins.length);
7128
- this.ins.forEach((X) => {
7129
- D.writeBytes(X.hash), D.writeUInt32LE(X.index);
7130
- }), w = It(D.finish()), D = new dt(8 * this.ins.length), n.forEach((X) => D.writeUInt64LE(X)), b = It(D.finish()), D = new dt(r.map(Nt).reduce((X, at) => X + at)), r.forEach((X) => D.writeVarBytes(X)), m = It(D.finish()), D = new dt(4 * this.ins.length), this.ins.forEach((X) => D.writeUInt32LE(X.sequence)), v = It(D.finish());
7127
+ let M = new dt(36 * this.ins.length);
7128
+ this.ins.forEach((Z) => {
7129
+ M.writeBytes(Z.hash), M.writeUInt32LE(Z.index);
7130
+ }), w = It(M.finish()), M = new dt(8 * this.ins.length), n.forEach((Z) => M.writeUInt64LE(Z)), y = It(M.finish()), M = new dt(r.map(Nt).reduce((Z, Q) => Z + Q)), r.forEach((Z) => M.writeVarBytes(Z)), m = It(M.finish()), M = new dt(4 * this.ins.length), this.ins.forEach((Z) => M.writeUInt32LE(Z.sequence)), v = It(M.finish());
7131
7131
  }
7132
7132
  if (u || d) {
7133
7133
  if (d && t < this.outs.length) {
7134
- const D = this.outs[t], X = new dt(8 + Nt(D.script));
7135
- X.writeUInt64LE(D.value), X.writeVarBytes(D.script), I = It(X.finish());
7134
+ const M = this.outs[t], Z = new dt(8 + Nt(M.script));
7135
+ Z.writeUInt64LE(M.value), Z.writeVarBytes(M.script), I = It(Z.finish());
7136
7136
  }
7137
7137
  } else if (f) I = f.hashOutputs;
7138
7138
  else {
7139
7139
  if (!this.outs.length) throw new Error("Add outputs to the transaction before signing.");
7140
- const D = new dt(this.outs.map((X) => 8 + Nt(X.script)).reduce((X, at) => X + at));
7141
- this.outs.forEach((X) => {
7142
- D.writeUInt64LE(X.value), D.writeVarBytes(X.script);
7143
- }), I = It(D.finish());
7140
+ const M = this.outs.map((Q) => 8 + Nt(Q.script)).reduce((Q, q) => Q + q), Z = new dt(M);
7141
+ this.outs.forEach((Q) => {
7142
+ Z.writeUInt64LE(Q.value), Z.writeVarBytes(Q.script);
7143
+ }), I = It(Z.finish());
7144
7144
  }
7145
7145
  const P = (o ? 2 : 0) + (a ? 1 : 0), S = new dt(174 - (p ? 49 : 0) - (u ? 32 : 0) + (a ? 32 : 0) + (o ? 37 : 0));
7146
- if (S.writeUInt8(i), S.writeInt32LE(this.version), S.writeUInt32LE(this.locktime), S.writeBytes(w), S.writeBytes(b), S.writeBytes(m), S.writeBytes(v), u || d || S.writeBytes(I), S.writeUInt8(P), p) {
7147
- const D = this.ins[t];
7148
- S.writeBytes(D.hash), S.writeUInt32LE(D.index), S.writeUInt64LE(n[t]), S.writeVarBytes(r[t]), S.writeUInt32LE(D.sequence);
7146
+ if (S.writeUInt8(i), S.writeInt32LE(this.version), S.writeUInt32LE(this.locktime), S.writeBytes(w), S.writeBytes(y), S.writeBytes(m), S.writeBytes(v), u || d || S.writeBytes(I), S.writeUInt8(P), p) {
7147
+ const M = this.ins[t];
7148
+ S.writeBytes(M.hash), S.writeUInt32LE(M.index), S.writeUInt64LE(n[t]), S.writeVarBytes(r[t]), S.writeUInt32LE(M.sequence);
7149
7149
  } else S.writeUInt32LE(t);
7150
7150
  if (a) {
7151
- const D = new dt(Nt(a));
7152
- D.writeVarBytes(a), S.writeBytes(It(D.finish()));
7151
+ const M = new dt(Nt(a));
7152
+ M.writeVarBytes(a), S.writeBytes(It(M.finish()));
7153
7153
  }
7154
7154
  d && S.writeBytes(I), o && (S.writeBytes(o), S.writeUInt8(0), S.writeUInt32LE(4294967295));
7155
7155
  const _ = new Uint8Array([0]), O = S.finish(), z = new Uint8Array(1 + O.length);
@@ -7188,14 +7188,14 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7188
7188
  if (typeof n != "bigint") throw new TypeError("Expected bigint for value");
7189
7189
  if (!Number.isInteger(i) || i < 0 || i > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for hashType");
7190
7190
  let o, a, f = kr, l = kr, p = kr;
7191
- if (i & Q.SIGHASH_ANYONECANPAY || (o = Et(36 * this.ins.length), a = new dt(o, 0), this.ins.forEach((d) => {
7191
+ if (i & J.SIGHASH_ANYONECANPAY || (o = Et(36 * this.ins.length), a = new dt(o, 0), this.ins.forEach((d) => {
7192
7192
  a.writeBytes(d.hash), a.writeUInt32LE(d.index);
7193
- }), l = le(o)), !(i & Q.SIGHASH_ANYONECANPAY) && (i & 31) !== Q.SIGHASH_SINGLE && (i & 31) !== Q.SIGHASH_NONE && (o = Et(4 * this.ins.length), a = new dt(o, 0), this.ins.forEach((d) => {
7193
+ }), l = le(o)), !(i & J.SIGHASH_ANYONECANPAY) && (i & 31) !== J.SIGHASH_SINGLE && (i & 31) !== J.SIGHASH_NONE && (o = Et(4 * this.ins.length), a = new dt(o, 0), this.ins.forEach((d) => {
7194
7194
  a.writeUInt32LE(d.sequence);
7195
- }), p = le(o)), (i & 31) !== Q.SIGHASH_SINGLE && (i & 31) !== Q.SIGHASH_NONE) o = Et(this.outs.reduce((d, w) => d + 8 + Nt(w.script), 0)), a = new dt(o, 0), this.outs.forEach((d) => {
7195
+ }), p = le(o)), (i & 31) !== J.SIGHASH_SINGLE && (i & 31) !== J.SIGHASH_NONE) o = Et(this.outs.reduce((d, w) => d + 8 + Nt(w.script), 0)), a = new dt(o, 0), this.outs.forEach((d) => {
7196
7196
  a.writeUInt64LE(d.value), a.writeVarBytes(d.script);
7197
7197
  }), f = le(o);
7198
- else if ((i & 31) === Q.SIGHASH_SINGLE && t < this.outs.length) {
7198
+ else if ((i & 31) === J.SIGHASH_SINGLE && t < this.outs.length) {
7199
7199
  const d = this.outs[t];
7200
7200
  o = Et(8 + Nt(d.script)), a = new dt(o, 0), a.writeUInt64LE(d.value), a.writeVarBytes(d.script), f = le(o);
7201
7201
  }
@@ -7204,10 +7204,10 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7204
7204
  return a.writeInt32LE(this.version), a.writeBytes(l), a.writeBytes(p), a.writeBytes(u.hash), a.writeUInt32LE(u.index), a.writeVarBytes(r), a.writeUInt64LE(n), a.writeUInt32LE(u.sequence), a.writeBytes(f), a.writeUInt32LE(this.locktime), a.writeUInt32LE(i), Or(le(o));
7205
7205
  }
7206
7206
  getHash(t) {
7207
- return t && this.isCoinbase() ? new Uint8Array(32) : le(this.#t(void 0, void 0, t));
7207
+ return t && this.isCoinbase() ? /* @__PURE__ */ new Uint8Array(32) : le(this.#t(void 0, void 0, t));
7208
7208
  }
7209
7209
  getId() {
7210
- return Yt(qn(this.getHash(!1)));
7210
+ return Yt(zn(this.getHash(!1)));
7211
7211
  }
7212
7212
  toBuffer(t, r) {
7213
7213
  return this.#t(t, r, !0);
@@ -7230,7 +7230,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7230
7230
  const i = new dt(t, r || 0);
7231
7231
  i.writeInt32LE(this.version);
7232
7232
  const o = n && this.hasWitnesses();
7233
- return o && (i.writeUInt8(Q.ADVANCED_TRANSACTION_MARKER), i.writeUInt8(Q.ADVANCED_TRANSACTION_FLAG)), i.writeVarInt(this.ins.length), this.ins.forEach((a) => {
7233
+ return o && (i.writeUInt8(J.ADVANCED_TRANSACTION_MARKER), i.writeUInt8(J.ADVANCED_TRANSACTION_FLAG)), i.writeVarInt(this.ins.length), this.ins.forEach((a) => {
7234
7234
  i.writeBytes(a.hash), i.writeUInt32LE(a.index), i.writeVarBytes(a.script), i.writeUInt32LE(a.sequence);
7235
7235
  }), i.writeVarInt(this.outs.length), this.outs.forEach((a) => {
7236
7236
  i.writeUInt64LE(a.value), i.writeVarBytes(a.script);
@@ -7240,7 +7240,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7240
7240
  }
7241
7241
  }, zu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7242
7242
  __proto__: null,
7243
- Transaction: J
7243
+ Transaction: tt
7244
7244
  }, Symbol.toStringTag, { value: "Module" }));
7245
7245
  function ne(e) {
7246
7246
  return (t) => {
@@ -7251,7 +7251,7 @@ function ne(e) {
7251
7251
  }
7252
7252
  };
7253
7253
  }
7254
- var qu = ne(yr), Yu = ne(fi), Xu = ne(pr), on = ne(sn), us = ne(gr), Ko = ne(dr), ci = ne(wr), li = ne(ui), Gl = ne(Jn), jl = (e) => e.length === 4 && e[0] === 81 && e[1] === 2 && e[2] === 78 && e[3] === 115;
7254
+ var qu = ne(yr), Yu = ne(hi), Xu = ne(pr), on = ne(sn), hs = ne(gr), Ko = ne(dr), ui = ne(wr), fi = ne(ai), Gl = ne(Qn), jl = (e) => e.length === 4 && e[0] === 81 && e[1] === 2 && e[2] === 78 && e[3] === 115;
7255
7255
  function or(e) {
7256
7256
  const t = [];
7257
7257
  function r(a) {
@@ -7270,9 +7270,9 @@ function or(e) {
7270
7270
  return o(e), Bt(t);
7271
7271
  }
7272
7272
  function Do(e, t) {
7273
- const r = et(t);
7273
+ const r = rt(t);
7274
7274
  if (r === null) throw new Error("Unknown script error");
7275
- const n = St(e), i = Ce(e), o = _n(e), a = o?.hybrid ? St(o.hybrid) : void 0, f = o?.uncompressed ? St(o.uncompressed) : void 0;
7275
+ const n = St(e), i = Ce(e), o = Bn(e), a = o?.hybrid ? St(o.hybrid) : void 0, f = o?.uncompressed ? St(o.uncompressed) : void 0;
7276
7276
  return r.findIndex((l) => typeof l == "number" ? !1 : !!(vr(l, e) || vr(l, i) || x(l, n) || o && (vr(l, o.uncompressed) || vr(l, o.hybrid) || a && x(l, a) || f && x(l, f))));
7277
7277
  }
7278
7278
  function Fr(e, t) {
@@ -7283,11 +7283,11 @@ function Zu(e, t) {
7283
7283
  }
7284
7284
  function Mo(e, t, r) {
7285
7285
  const { hashType: n } = t(e), i = [];
7286
- switch (n & J.SIGHASH_ANYONECANPAY && i.push("addInput"), n & 31) {
7287
- case J.SIGHASH_ALL:
7286
+ switch (n & tt.SIGHASH_ANYONECANPAY && i.push("addInput"), n & 31) {
7287
+ case tt.SIGHASH_ALL:
7288
7288
  break;
7289
- case J.SIGHASH_SINGLE:
7290
- case J.SIGHASH_NONE:
7289
+ case tt.SIGHASH_SINGLE:
7290
+ case tt.SIGHASH_NONE:
7291
7291
  i.push("addOutput"), i.push("setInputSequence");
7292
7292
  break;
7293
7293
  }
@@ -7303,10 +7303,10 @@ function Qu(e) {
7303
7303
  return r.map((n) => new Uint8Array(n.signature));
7304
7304
  }
7305
7305
  function Ju(e) {
7306
- const t = e.finalScriptSig ? et(new Uint8Array(e.finalScriptSig)) || [] : [], r = e.finalScriptWitness ? et(new Uint8Array(e.finalScriptWitness)) || [] : [];
7306
+ const t = e.finalScriptSig ? rt(new Uint8Array(e.finalScriptSig)) || [] : [], r = e.finalScriptWitness ? rt(new Uint8Array(e.finalScriptWitness)) || [] : [];
7307
7307
  return t.concat(r).filter((n) => n instanceof Uint8Array && xe(n)).map((n) => ({ signature: n }));
7308
7308
  }
7309
- function fs(e, t, r) {
7309
+ function us(e, t, r) {
7310
7310
  const n = df(t, e, r);
7311
7311
  try {
7312
7312
  return { finalScriptWitness: or(lf(t, n).concat(new Uint8Array(n.script)).concat(new Uint8Array(n.controlBlock))) };
@@ -7315,21 +7315,21 @@ function fs(e, t, r) {
7315
7315
  }
7316
7316
  }
7317
7317
  function Le(e, t) {
7318
- return Bt([e, t ? new Uint8Array([t]) : new Uint8Array(0)]);
7318
+ return Bt([e, t ? new Uint8Array([t]) : /* @__PURE__ */ new Uint8Array(0)]);
7319
7319
  }
7320
7320
  function Lt(e) {
7321
- return e && !!(e.tapInternalKey || e.tapMerkleRoot || e.tapLeafScript && e.tapLeafScript.length || e.tapBip32Derivation && e.tapBip32Derivation.length || e.witnessUtxo && (ci(new Uint8Array(e.witnessUtxo.script)) || li(new Uint8Array(e.witnessUtxo.script))));
7321
+ return e && !!(e.tapInternalKey || e.tapMerkleRoot || e.tapLeafScript && e.tapLeafScript.length || e.tapBip32Derivation && e.tapBip32Derivation.length || e.witnessUtxo && (ui(new Uint8Array(e.witnessUtxo.script)) || fi(new Uint8Array(e.witnessUtxo.script))));
7322
7322
  }
7323
- function Cn(e) {
7324
- return !!(e.witnessUtxo && li(new Uint8Array(e.witnessUtxo.script)));
7323
+ function Ln(e) {
7324
+ return !!(e.witnessUtxo && fi(new Uint8Array(e.witnessUtxo.script)));
7325
7325
  }
7326
7326
  function En(e, t) {
7327
- return e && !!(e.tapInternalKey || e.tapTree || e.tapBip32Derivation && e.tapBip32Derivation.length || t && (ci(t) || li(t)));
7327
+ return e && !!(e.tapInternalKey || e.tapTree || e.tapBip32Derivation && e.tapBip32Derivation.length || t && (ui(t) || fi(t)));
7328
7328
  }
7329
- function cs(e, t, r) {
7329
+ function fs(e, t, r) {
7330
7330
  uf(e, t, r), cf(e, t, r);
7331
7331
  }
7332
- function ls(e, t, r) {
7332
+ function cs(e, t, r) {
7333
7333
  ff(e, t, r), tf(e, t);
7334
7334
  }
7335
7335
  function tf(e, t) {
@@ -7361,7 +7361,7 @@ function nf(e, t) {
7361
7361
  function sf(e) {
7362
7362
  return {
7363
7363
  signature: e.subarray(0, 64),
7364
- hashType: e.subarray(64)[0] || J.SIGHASH_DEFAULT
7364
+ hashType: e.subarray(64)[0] || tt.SIGHASH_DEFAULT
7365
7365
  };
7366
7366
  }
7367
7367
  function of(e) {
@@ -7379,19 +7379,19 @@ function af(e) {
7379
7379
  }
7380
7380
  function hf(e) {
7381
7381
  let t;
7382
- for (const r of e) if (t = Vn(r, t), !t) throw new Error("No room left to insert tapleaf in tree");
7382
+ for (const r of e) if (t = Cn(r, t), !t) throw new Error("No room left to insert tapleaf in tree");
7383
7383
  return t;
7384
7384
  }
7385
- function Vn(e, t, r = 0) {
7385
+ function Cn(e, t, r = 0) {
7386
7386
  if (r > 128) throw new Error("Max taptree depth exceeded.");
7387
7387
  if (e.depth === r) return t ? void 0 : {
7388
7388
  output: new Uint8Array(e.script),
7389
7389
  version: e.leafVersion
7390
7390
  };
7391
- if (Vs(t)) return;
7392
- const n = Vn(e, t && t[0], r + 1);
7391
+ if (Cs(t)) return;
7392
+ const n = Cn(e, t && t[0], r + 1);
7393
7393
  if (n) return [n, t && t[1]];
7394
- const i = Vn(e, t && t[1], r + 1);
7394
+ const i = Cn(e, t && t[1], r + 1);
7395
7395
  if (i) return [t && t[0], i];
7396
7396
  }
7397
7397
  function uf(e, t, r) {
@@ -7403,7 +7403,7 @@ function ff(e, t, r) {
7403
7403
  if (n || i || o) throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`);
7404
7404
  }
7405
7405
  function cf(e, t, r) {
7406
- const n = Cn(e) || Cn(t);
7406
+ const n = Ln(e) || Ln(t);
7407
7407
  if (t.tapMerkleRoot) {
7408
7408
  const i = new Uint8Array(t.tapMerkleRoot), o = (t.tapLeafScript || []).every((f) => vn(f, i, n)), a = (e.tapLeafScript || []).every((f) => vn(f, i, n));
7409
7409
  if (!o || !a) throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`);
@@ -7852,19 +7852,19 @@ var If = {
7852
7852
  const d = f[u];
7853
7853
  if (d.status === "fulfilled") {
7854
7854
  const w = d.value;
7855
- for (const b of w.results) l.set(b.inputIndex, {
7855
+ for (const y of w.results) l.set(y.inputIndex, {
7856
7856
  type: "result",
7857
- taskId: b.taskId,
7858
- signature: b.signature,
7859
- inputIndex: b.inputIndex,
7860
- publicKey: b.publicKey,
7861
- signatureType: b.signatureType,
7862
- leafHash: b.leafHash
7857
+ taskId: y.taskId,
7858
+ signature: y.signature,
7859
+ inputIndex: y.inputIndex,
7860
+ publicKey: y.publicKey,
7861
+ signatureType: y.signatureType,
7862
+ leafHash: y.leafHash
7863
7863
  });
7864
- for (const b of w.errors) p.set(b.inputIndex, b.error);
7864
+ for (const y of w.errors) p.set(y.inputIndex, y.error);
7865
7865
  } else {
7866
- const w = d.reason?.message ?? "Batch signing failed", b = o[u];
7867
- for (const m of b) p.set(m.inputIndex, w);
7866
+ const w = d.reason?.message ?? "Batch signing failed", y = o[u];
7867
+ for (const m of y) p.set(m.inputIndex, w);
7868
7868
  }
7869
7869
  }
7870
7870
  return this.#n || await this.#w(), {
@@ -7920,33 +7920,33 @@ var If = {
7920
7920
  };
7921
7921
  const o = this.#e[i] ?? await this.#p(), a = `batch-${this.#o++}`;
7922
7922
  return new Promise((f, l) => {
7923
- const p = {
7923
+ const p = setTimeout(() => {
7924
+ this.#s.delete(a), o.state = At.Idle, o.currentTaskId = null, o.taskStartTime = null, this.#d(o).catch(() => {
7925
+ }), this.#u().catch(() => {
7926
+ }), l(/* @__PURE__ */ new Error(`Batch signing timeout for ${t.length} tasks`));
7927
+ }, this.#a.maxKeyHoldTimeMs), u = {
7924
7928
  batchId: a,
7925
7929
  resolve: f,
7926
7930
  reject: l,
7927
- timeoutId: setTimeout(() => {
7928
- this.#s.delete(a), o.state = At.Idle, o.currentTaskId = null, o.taskStartTime = null, this.#d(o).catch(() => {
7929
- }), this.#u().catch(() => {
7930
- }), l(/* @__PURE__ */ new Error(`Batch signing timeout for ${t.length} tasks`));
7931
- }, this.#a.maxKeyHoldTimeMs)
7931
+ timeoutId: p
7932
7932
  };
7933
- this.#s.set(a, p), o.state = At.Busy, o.currentTaskId = a, o.taskStartTime = Date.now();
7934
- const u = {
7933
+ this.#s.set(a, u), o.state = At.Busy, o.currentTaskId = a, o.taskStartTime = Date.now();
7934
+ const d = t.map((y) => ({
7935
+ taskId: y.taskId,
7936
+ hash: y.hash,
7937
+ publicKey: n,
7938
+ signatureType: y.signatureType,
7939
+ lowR: y.lowR,
7940
+ inputIndex: y.inputIndex,
7941
+ sighashType: y.sighashType,
7942
+ leafHash: y.leafHash
7943
+ })), w = {
7935
7944
  type: "signBatch",
7936
7945
  batchId: a,
7937
- tasks: t.map((d) => ({
7938
- taskId: d.taskId,
7939
- hash: d.hash,
7940
- publicKey: n,
7941
- signatureType: d.signatureType,
7942
- lowR: d.lowR,
7943
- inputIndex: d.inputIndex,
7944
- sighashType: d.sighashType,
7945
- leafHash: d.leafHash
7946
- })),
7946
+ tasks: d,
7947
7947
  privateKey: r
7948
7948
  };
7949
- o.worker.postMessage(u);
7949
+ o.worker.postMessage(w);
7950
7950
  });
7951
7951
  }
7952
7952
  async #p() {
@@ -8005,7 +8005,7 @@ function Af(e, t, r, n, i) {
8005
8005
  inputIndex: t,
8006
8006
  hash: f,
8007
8007
  signatureType: Fo.Schnorr,
8008
- sighashType: r.sighashType ?? J.SIGHASH_DEFAULT,
8008
+ sighashType: r.sighashType ?? tt.SIGHASH_DEFAULT,
8009
8009
  leafHash: l
8010
8010
  });
8011
8011
  } catch {
@@ -8014,8 +8014,8 @@ function Af(e, t, r, n, i) {
8014
8014
  }
8015
8015
  function Sf(e, t, r, n, i) {
8016
8016
  try {
8017
- const o = r.sighashType ?? J.SIGHASH_ALL;
8018
- return (i.sighashTypes ?? [J.SIGHASH_ALL]).includes(o), null;
8017
+ const o = r.sighashType ?? tt.SIGHASH_ALL;
8018
+ return (i.sighashTypes ?? [tt.SIGHASH_ALL]).includes(o), null;
8019
8019
  } catch {
8020
8020
  return null;
8021
8021
  }
@@ -8036,7 +8036,7 @@ function Yl(e, t, r) {
8036
8036
  e.data.updateInput(i, { tapKeySig: f });
8037
8037
  }
8038
8038
  else {
8039
- const f = Ae.encode(o.signature, a.sighashType ?? J.SIGHASH_ALL), l = [{
8039
+ const f = Ae.encode(o.signature, a.sighashType ?? tt.SIGHASH_ALL), l = [{
8040
8040
  pubkey: Uint8Array.from(n),
8041
8041
  signature: f
8042
8042
  }];
@@ -8076,8 +8076,8 @@ function Go(e, t) {
8076
8076
  if (f.length < 2 || f.length > 40) throw new TypeError("Invalid program length for segwit address");
8077
8077
  const l = r === j.OP_0 ? 0 : r !== void 0 && r >= j.OP_1 && r <= j.OP_16 ? r - (j.OP_1 - 1) : -1;
8078
8078
  if (l < 15 || l > 16) throw new TypeError(`Invalid segwit version ${l}`);
8079
- const p = [l, ...tt.bech32m.toWords(f)];
8080
- return tt.bech32m.encode(t.bech32Opnet, p);
8079
+ const p = [l, ...et.bech32m.toWords(f)];
8080
+ return et.bech32m.encode(t.bech32Opnet, p);
8081
8081
  }
8082
8082
  function jo(e, t) {
8083
8083
  const r = e.subarray(2);
@@ -8090,7 +8090,7 @@ function jo(e, t) {
8090
8090
  return Wr(r, i, t.bech32, t.bech32Opnet);
8091
8091
  }
8092
8092
  function zo(e) {
8093
- const t = new Uint8Array(zn(e));
8093
+ const t = new Uint8Array(jn(e));
8094
8094
  if (t.length < 21) throw new TypeError(e + " is too short");
8095
8095
  if (t.length > 21) throw new TypeError(e + " is too long");
8096
8096
  return {
@@ -8098,30 +8098,30 @@ function zo(e) {
8098
8098
  hash: t.subarray(1)
8099
8099
  };
8100
8100
  }
8101
- function $n(e, t) {
8102
- if (!Cs(e)) throw new TypeError("Expected 20 bytes hash");
8103
- if (!Ls(t)) throw new TypeError("Expected UInt8 version");
8101
+ function Vn(e, t) {
8102
+ if (!Ls(e)) throw new TypeError("Expected 20 bytes hash");
8103
+ if (!Hs(t)) throw new TypeError("Expected UInt8 version");
8104
8104
  const r = Et(21);
8105
- return r[0] = t, r.set(e, 1), jn(r);
8105
+ return r[0] = t, r.set(e, 1), Gn(r);
8106
8106
  }
8107
8107
  function Wr(e, t, r, n) {
8108
- const i = tt.bech32.toWords(e);
8109
- return i.unshift(t), t === 16 && n ? tt.bech32m.encode(n, i) : t === 0 ? tt.bech32.encode(r, i) : tt.bech32m.encode(r, i);
8108
+ const i = et.bech32.toWords(e);
8109
+ return i.unshift(t), t === 16 && n ? et.bech32m.encode(n, i) : t === 0 ? et.bech32.encode(r, i) : et.bech32m.encode(r, i);
8110
8110
  }
8111
8111
  function qo(e, t) {
8112
8112
  t = t || kt;
8113
8113
  const r = e.length;
8114
- if (r === 25 && e[0] === 118 && e[1] === 169 && e[2] === 20 && e[23] === 136 && e[24] === 172) return $n(e.subarray(3, 23), t.pubKeyHash);
8115
- if (r === 23 && e[0] === 169 && e[1] === 20 && e[22] === 135) return $n(e.subarray(2, 22), t.scriptHash);
8114
+ if (r === 25 && e[0] === 118 && e[1] === 169 && e[2] === 20 && e[23] === 136 && e[24] === 172) return Vn(e.subarray(3, 23), t.pubKeyHash);
8115
+ if (r === 23 && e[0] === 169 && e[1] === 20 && e[22] === 135) return Vn(e.subarray(2, 22), t.scriptHash);
8116
8116
  if (r === 22 && e[0] === 0 && e[1] === 20) return Wr(e.subarray(2, 22), 0, t.bech32);
8117
8117
  if (r === 34 && e[0] === 0 && e[1] === 32) return Wr(e.subarray(2, 34), 0, t.bech32);
8118
8118
  if (r === 34 && e[0] === 81 && e[1] === 32) {
8119
- const n = tt.bech32m.toWords(e.subarray(2, 34));
8120
- return n.unshift(1), tt.bech32m.encode(t.bech32, n);
8119
+ const n = et.bech32m.toWords(e.subarray(2, 34));
8120
+ return n.unshift(1), et.bech32m.encode(t.bech32, n);
8121
8121
  }
8122
8122
  if (r === 34 && e[0] === 82 && e[1] === 32) {
8123
- const n = tt.bech32m.toWords(e.subarray(2, 34));
8124
- return n.unshift(2), tt.bech32m.encode(t.bech32, n);
8123
+ const n = et.bech32m.toWords(e.subarray(2, 34));
8124
+ return n.unshift(2), et.bech32m.encode(t.bech32, n);
8125
8125
  }
8126
8126
  try {
8127
8127
  return Go(e, t);
@@ -8131,7 +8131,7 @@ function qo(e, t) {
8131
8131
  return jo(e, t);
8132
8132
  } catch {
8133
8133
  }
8134
- throw new Error(Ds(e) + " has no matching Address");
8134
+ throw new Error(Ks(e) + " has no matching Address");
8135
8135
  }
8136
8136
  function Yo(e, t) {
8137
8137
  let r, n;
@@ -8153,14 +8153,14 @@ function Yo(e, t) {
8153
8153
  if (o.prefix !== r.bech32 && r.bech32Opnet && o.prefix !== r.bech32Opnet) throw new Error(e + " has an invalid prefix");
8154
8154
  if (o.version === 0) {
8155
8155
  if (o.data.length === 20) return sn({ hash: lh(o.data) }).output;
8156
- if (o.data.length === 32) return gr({ hash: ki(o.data) }).output;
8156
+ if (o.data.length === 32) return gr({ hash: Si(o.data) }).output;
8157
8157
  } else if (o.version === 1) {
8158
8158
  if (o.data.length === 32) return wr({ pubkey: o.data }).output;
8159
8159
  } else {
8160
- if (o.version === 2 && o.data.length === 32) return ui({ hash: ki(o.data) }).output;
8160
+ if (o.version === 2 && o.data.length === 32) return ai({ hash: Si(o.data) }).output;
8161
8161
  if (o.version === 16) {
8162
8162
  if (!r.bech32Opnet) throw new Error(e + " has an invalid prefix");
8163
- return Jn({
8163
+ return Qn({
8164
8164
  program: o.data,
8165
8165
  network: r
8166
8166
  }).output;
@@ -8184,11 +8184,11 @@ var Uf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8184
8184
  fromBech32: cr,
8185
8185
  fromOutputScript: qo,
8186
8186
  isUnknownSegwitVersion: Wo,
8187
- toBase58Check: $n,
8187
+ toBase58Check: Vn,
8188
8188
  toBech32: Wr,
8189
8189
  toFutureOPNetAddress: Go,
8190
8190
  toOutputScript: Yo
8191
- }, Symbol.toStringTag, { value: "Module" })), ps = j, Xo = class Kn {
8191
+ }, Symbol.toStringTag, { value: "Module" })), ls = j, Xo = class $n {
8192
8192
  static NAME = ft.Embed;
8193
8193
  #t;
8194
8194
  #a;
@@ -8217,13 +8217,13 @@ var Uf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8217
8217
  return this.#o || (this.#n = this.#f(), this.#o = !0), this.#n;
8218
8218
  }
8219
8219
  static fromData(t, r) {
8220
- return new Kn({
8220
+ return new $n({
8221
8221
  data: t,
8222
8222
  network: r
8223
8223
  });
8224
8224
  }
8225
8225
  static fromOutput(t, r) {
8226
- return new Kn({
8226
+ return new $n({
8227
8227
  output: t,
8228
8228
  network: r
8229
8229
  });
@@ -8238,17 +8238,17 @@ var Uf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8238
8238
  }
8239
8239
  #h() {
8240
8240
  if (this.#e) return this.#e;
8241
- if (this.#s) return et(this.#s)?.slice(1);
8241
+ if (this.#s) return rt(this.#s)?.slice(1);
8242
8242
  }
8243
8243
  #f() {
8244
8244
  if (this.#s) return this.#s;
8245
- if (this.#e) return gt([ps.OP_RETURN].concat(this.#e));
8245
+ if (this.#e) return gt([ls.OP_RETURN].concat(this.#e));
8246
8246
  }
8247
8247
  #u() {
8248
8248
  if (this.#s) {
8249
- const t = et(this.#s);
8249
+ const t = rt(this.#s);
8250
8250
  if (!t) throw new TypeError("Output is invalid");
8251
- if (t[0] !== ps.OP_RETURN) throw new TypeError("Output is invalid");
8251
+ if (t[0] !== ls.OP_RETURN) throw new TypeError("Output is invalid");
8252
8252
  if (!t.slice(1).every((r) => r instanceof Uint8Array)) throw new TypeError("Output is invalid");
8253
8253
  if (this.#e && !Ue(this.#e, this.data)) throw new TypeError("Data mismatch");
8254
8254
  }
@@ -8270,7 +8270,7 @@ var Pf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8270
8270
  MAX_TAPTREE_DEPTH: 128,
8271
8271
  P2MR: No,
8272
8272
  P2MS: $o,
8273
- P2OP: Ws,
8273
+ P2OP: Fs,
8274
8274
  P2PK: Vo,
8275
8275
  P2PKH: ao,
8276
8276
  P2SH: ho,
@@ -8280,10 +8280,10 @@ var Pf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8280
8280
  PaymentType: ft,
8281
8281
  findScriptPath: Pe,
8282
8282
  p2data: Of,
8283
- p2mr: ui,
8283
+ p2mr: ai,
8284
8284
  p2ms: yr,
8285
- p2op: Jn,
8286
- p2pk: fi,
8285
+ p2op: Qn,
8286
+ p2pk: hi,
8287
8287
  p2pkh: pr,
8288
8288
  p2sh: dr,
8289
8289
  p2tr: wr,
@@ -8325,7 +8325,7 @@ function Xt(e) {
8325
8325
  return r;
8326
8326
  }
8327
8327
  function G(e) {
8328
- const t = e || new Uint8Array();
8328
+ const t = e || /* @__PURE__ */ new Uint8Array();
8329
8329
  return t.length > 512 ? Rf(t) : _f(t);
8330
8330
  }
8331
8331
  function _f(e) {
@@ -8361,12 +8361,12 @@ function Zt(e, t) {
8361
8361
  for (let n = 0; n < r; ++n) if (e[n] !== t[n]) return e[n] < t[n] ? -1 : 1;
8362
8362
  return e.length === t.length ? 0 : e.length > t.length ? 1 : -1;
8363
8363
  }
8364
- function pi(e, t, r, n) {
8364
+ function ci(e, t, r, n) {
8365
8365
  if (t + 4 > e.length) throw new Error("Offset is outside the bounds of Uint8Array");
8366
8366
  if (n = n.toUpperCase(), r > 4294967295) throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);
8367
8367
  return n === "LE" ? (e[t] = r & 255, e[t + 1] = r >> 8 & 255, e[t + 2] = r >> 16 & 255, e[t + 3] = r >> 24 & 255) : (e[t] = r >> 24 & 255, e[t + 1] = r >> 16 & 255, e[t + 2] = r >> 8 & 255, e[t + 3] = r & 255), t + 4;
8368
8368
  }
8369
- function ds(e, t) {
8369
+ function ps(e, t) {
8370
8370
  if (t + 1 > e.length) throw new Error("Offset is outside the bounds of Uint8Array");
8371
8371
  return e[t];
8372
8372
  }
@@ -8418,7 +8418,7 @@ function Df(e) {
8418
8418
  return r.slice(1).forEach((o) => {
8419
8419
  const a = o.slice(-1) === "'";
8420
8420
  let f = 2147483647 & parseInt(a ? o.slice(0, -1) : o, 10);
8421
- a && (f += 2147483648), pi(n, i, f, "LE"), i += 4;
8421
+ a && (f += 2147483648), ci(n, i, f, "LE"), i += 4;
8422
8422
  }), {
8423
8423
  key: t,
8424
8424
  value: n
@@ -8601,8 +8601,8 @@ function Tc(e) {
8601
8601
  return Number(an(e.value, 0, "LE"));
8602
8602
  }
8603
8603
  function kc(e) {
8604
- const t = Uint8Array.from([R.SIGHASH_TYPE]), r = new Uint8Array(4);
8605
- return pi(r, 0, e, "LE"), {
8604
+ const t = Uint8Array.from([R.SIGHASH_TYPE]), r = /* @__PURE__ */ new Uint8Array(4);
8605
+ return ci(r, 0, e, "LE"), {
8606
8606
  key: t,
8607
8607
  value: r
8608
8608
  };
@@ -8819,7 +8819,7 @@ var fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8819
8819
  encode: ol,
8820
8820
  expected: al
8821
8821
  }, Symbol.toStringTag, { value: "Module" })), cl = (e) => [...Array(e).keys()], ll = (e) => e.length === 33 && [2, 3].includes(e[0]) || e.length === 65 && e[0] === 4;
8822
- function di(e, t = ll) {
8822
+ function li(e, t = ll) {
8823
8823
  function r(f) {
8824
8824
  if (f.key[0] !== e) throw new Error("Decode Error: could not decode bip32Derivation with key 0x" + G(f.key));
8825
8825
  const l = f.key.slice(1);
@@ -8831,8 +8831,8 @@ function di(e, t = ll) {
8831
8831
  path: "m"
8832
8832
  };
8833
8833
  for (const u of cl(f.value.length / 4 - 1)) {
8834
- const d = an(f.value, u * 4 + 4, "LE"), w = !!(d & 2147483648), b = d & 2147483647;
8835
- p.path += "/" + b.toString(10) + (w ? "'" : "");
8834
+ const d = an(f.value, u * 4 + 4, "LE"), w = !!(d & 2147483648), y = d & 2147483647;
8835
+ p.path += "/" + y.toString(10) + (w ? "'" : "");
8836
8836
  }
8837
8837
  return p;
8838
8838
  }
@@ -8841,9 +8841,9 @@ function di(e, t = ll) {
8841
8841
  u.set(f.masterFingerprint, 0);
8842
8842
  let d = 4;
8843
8843
  return p.slice(1).forEach((w) => {
8844
- const b = w.slice(-1) === "'";
8845
- let m = 2147483647 & parseInt(b ? w.slice(0, -1) : w, 10);
8846
- b && (m += 2147483648), pi(u, d, m, "LE"), d += 4;
8844
+ const y = w.slice(-1) === "'";
8845
+ let m = 2147483647 & parseInt(y ? w.slice(0, -1) : w, 10);
8846
+ y && (m += 2147483648), ci(u, d, m, "LE"), d += 4;
8847
8847
  }), {
8848
8848
  key: l,
8849
8849
  value: u
@@ -8865,7 +8865,7 @@ function di(e, t = ll) {
8865
8865
  canAddToArray: a
8866
8866
  };
8867
8867
  }
8868
- function wi(e) {
8868
+ function pi(e) {
8869
8869
  return t;
8870
8870
  function t(r) {
8871
8871
  let n;
@@ -8905,7 +8905,7 @@ function ea(e) {
8905
8905
  }
8906
8906
  var pl = (e) => e.length === 32;
8907
8907
  function ra(e) {
8908
- const t = di(e, pl);
8908
+ const t = li(e, pl);
8909
8909
  function r(a) {
8910
8910
  const { numberValue: f, bytes: l } = We(a.value), p = t.decode({
8911
8911
  key: a.key,
@@ -8995,10 +8995,10 @@ function ia(e) {
8995
8995
  canAdd: o
8996
8996
  };
8997
8997
  }
8998
- var gi = {
8998
+ var di = {
8999
8999
  unsignedTx: zf,
9000
9000
  globalXpub: Gf,
9001
- checkPubkey: wi([])
9001
+ checkPubkey: pi([])
9002
9002
  }, wt = {
9003
9003
  nonWitnessUtxo: cc,
9004
9004
  partialSig: bc,
@@ -9007,10 +9007,10 @@ var gi = {
9007
9007
  finalScriptWitness: sc,
9008
9008
  porCommitment: Sc,
9009
9009
  witnessUtxo: il,
9010
- bip32Derivation: di(R.BIP32_DERIVATION),
9010
+ bip32Derivation: li(R.BIP32_DERIVATION),
9011
9011
  redeemScript: ea(R.REDEEM_SCRIPT),
9012
9012
  witnessScript: ia(R.WITNESS_SCRIPT),
9013
- checkPubkey: wi([R.PARTIAL_SIG, R.BIP32_DERIVATION]),
9013
+ checkPubkey: pi([R.PARTIAL_SIG, R.BIP32_DERIVATION]),
9014
9014
  tapKeySig: Hc,
9015
9015
  tapScriptSig: Qc,
9016
9016
  tapLeafScript: Dc,
@@ -9018,20 +9018,20 @@ var gi = {
9018
9018
  tapInternalKey: na(R.TAP_INTERNAL_KEY),
9019
9019
  tapMerkleRoot: jc
9020
9020
  }, ee = {
9021
- bip32Derivation: di(ht.BIP32_DERIVATION),
9021
+ bip32Derivation: li(ht.BIP32_DERIVATION),
9022
9022
  redeemScript: ea(ht.REDEEM_SCRIPT),
9023
9023
  witnessScript: ia(ht.WITNESS_SCRIPT),
9024
- checkPubkey: wi([ht.BIP32_DERIVATION]),
9024
+ checkPubkey: pi([ht.BIP32_DERIVATION]),
9025
9025
  tapBip32Derivation: ra(ht.TAP_BIP32_DERIVATION),
9026
9026
  tapTree: fl,
9027
9027
  tapInternalKey: na(ht.TAP_INTERNAL_KEY)
9028
9028
  }, dl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9029
9029
  __proto__: null,
9030
- globals: gi,
9030
+ globals: di,
9031
9031
  inputs: wt,
9032
9032
  outputs: ee
9033
9033
  }, Symbol.toStringTag, { value: "Module" })), qr = (e) => [...Array(e).keys()];
9034
- function ws(e) {
9034
+ function ds(e) {
9035
9035
  const t = e.map(wl);
9036
9036
  return t.push(Uint8Array.from([0])), Xt(t);
9037
9037
  }
@@ -9052,7 +9052,7 @@ function gl(e, t) {
9052
9052
  return r += 4, I;
9053
9053
  }
9054
9054
  function o() {
9055
- const I = ds(e, r);
9055
+ const I = ps(e, r);
9056
9056
  return r += 1, I;
9057
9057
  }
9058
9058
  function a() {
@@ -9063,7 +9063,7 @@ function gl(e, t) {
9063
9063
  }
9064
9064
  function f() {
9065
9065
  if (r >= e.length) throw new Error("Format Error: Unexpected End of PSBT");
9066
- const I = ds(e, r) === 0;
9066
+ const I = ps(e, r) === 0;
9067
9067
  return I && r++, I;
9068
9068
  }
9069
9069
  if (i() !== 1886610036) throw new Error("Format Error: Invalid Magic Number");
@@ -9076,7 +9076,7 @@ function gl(e, t) {
9076
9076
  }
9077
9077
  const u = l.filter((I) => I.key[0] === qt.UNSIGNED_TX);
9078
9078
  if (u.length !== 1) throw new Error("Format Error: Only one UNSIGNED_TX allowed");
9079
- const d = t(u[0].value), { inputCount: w, outputCount: b } = d.getInputOutputCounts(), m = [], v = [];
9079
+ const d = t(u[0].value), { inputCount: w, outputCount: y } = d.getInputOutputCounts(), m = [], v = [];
9080
9080
  for (const I of qr(w)) {
9081
9081
  const P = {}, S = [];
9082
9082
  for (; !f(); ) {
@@ -9086,7 +9086,7 @@ function gl(e, t) {
9086
9086
  }
9087
9087
  m.push(S);
9088
9088
  }
9089
- for (const I of qr(b)) {
9089
+ for (const I of qr(y)) {
9090
9090
  const P = {}, S = [];
9091
9091
  for (; !f(); ) {
9092
9092
  const _ = a(), O = G(_.key);
@@ -9113,7 +9113,7 @@ function sa(e, { globalMapKeyVals: t, inputKeyVals: r, outputKeyVals: n }) {
9113
9113
  o++;
9114
9114
  break;
9115
9115
  case qt.GLOBAL_XPUB:
9116
- i.globalXpub === void 0 && (i.globalXpub = []), i.globalXpub.push(gi.globalXpub.decode(u));
9116
+ i.globalXpub === void 0 && (i.globalXpub = []), i.globalXpub.push(di.globalXpub.decode(u));
9117
9117
  break;
9118
9118
  default:
9119
9119
  i.unknownKeyVals || (i.unknownKeyVals = []), i.unknownKeyVals.push(u);
@@ -9215,11 +9215,11 @@ function sa(e, { globalMapKeyVals: t, inputKeyVals: r, outputKeyVals: n }) {
9215
9215
  };
9216
9216
  }
9217
9217
  function yl({ globalMap: e, inputs: t, outputs: r }) {
9218
- const { globalKeyVals: n, inputKeyVals: i, outputKeyVals: o } = Dn({
9218
+ const { globalKeyVals: n, inputKeyVals: i, outputKeyVals: o } = Kn({
9219
9219
  globalMap: e,
9220
9220
  inputs: t,
9221
9221
  outputs: r
9222
- }), a = ws(n), f = (d) => d.length === 0 ? [Uint8Array.from([0])] : d.map(ws), l = f(i), p = f(o), u = new Uint8Array(5);
9222
+ }), a = ds(n), f = (d) => d.length === 0 ? [Uint8Array.from([0])] : d.map(ds), l = f(i), p = f(o), u = /* @__PURE__ */ new Uint8Array(5);
9223
9223
  return u.set([
9224
9224
  112,
9225
9225
  115,
@@ -9242,23 +9242,23 @@ function In(e, t) {
9242
9242
  }, []), i = e.unknownKeyVals ? e.unknownKeyVals.filter((o) => !r.has(G(o.key))) : [];
9243
9243
  return n.concat(i).sort(bl);
9244
9244
  }
9245
- function Dn({ globalMap: e, inputs: t, outputs: r }) {
9245
+ function Kn({ globalMap: e, inputs: t, outputs: r }) {
9246
9246
  return {
9247
- globalKeyVals: In(e, gi),
9247
+ globalKeyVals: In(e, di),
9248
9248
  inputKeyVals: t.map((n) => In(n, wt)),
9249
9249
  outputKeyVals: r.map((n) => In(n, ee))
9250
9250
  };
9251
9251
  }
9252
9252
  function ml(e) {
9253
- const t = e[0], r = Dn(t), n = e.slice(1);
9253
+ const t = e[0], r = Kn(t), n = e.slice(1);
9254
9254
  if (n.length === 0) throw new Error("Combine: Nothing to combine");
9255
- const i = gs(t);
9255
+ const i = ws(t);
9256
9256
  if (i === void 0) throw new Error("Combine: Self missing transaction");
9257
9257
  const o = Ne(r.globalKeyVals), a = r.inputKeyVals.map(Ne), f = r.outputKeyVals.map(Ne);
9258
9258
  for (const l of n) {
9259
- const p = gs(l);
9259
+ const p = ws(l);
9260
9260
  if (p === void 0 || Zt(p.toBuffer(), i.toBuffer()) !== 0) throw new Error("Combine: One of the Psbts does not have the same transaction.");
9261
- const u = Dn(l);
9261
+ const u = Kn(l);
9262
9262
  Ne(u.globalKeyVals).forEach(An(o, r.globalKeyVals, u.globalKeyVals)), u.inputKeyVals.map(Ne).forEach((d, w) => d.forEach(An(a[w], r.inputKeyVals[w], u.inputKeyVals[w]))), u.outputKeyVals.map(Ne).forEach((d, w) => d.forEach(An(f[w], r.outputKeyVals[w], u.outputKeyVals[w])));
9263
9263
  }
9264
9264
  return sa(i, {
@@ -9274,7 +9274,7 @@ function An(e, t, r) {
9274
9274
  t.push(i), e.add(n);
9275
9275
  };
9276
9276
  }
9277
- function gs(e) {
9277
+ function ws(e) {
9278
9278
  return e.globalMap.unsignedTx;
9279
9279
  }
9280
9280
  function Ne(e) {
@@ -9313,34 +9313,36 @@ function El(e, t) {
9313
9313
  }
9314
9314
  if (r === !1) throw new Error(`Input #${e} has too much or too little data to clean`);
9315
9315
  }
9316
- function ys(e, t, r, n) {
9316
+ function gs(e, t, r, n) {
9317
9317
  throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`);
9318
9318
  }
9319
- function yi(e) {
9319
+ function wi(e) {
9320
9320
  return (t, r) => {
9321
9321
  for (const n of Object.keys(t)) {
9322
9322
  const i = t[n], { canAdd: o, canAddToArray: a, check: f, expected: l } = dl[e + "s"][n] || {}, p = !!a;
9323
9323
  if (f) if (p) {
9324
9324
  if (!Array.isArray(i) || r[n] && !Array.isArray(r[n])) throw new Error(`Key type ${n} must be an array`);
9325
- i.every(f) || ys(e, n, l, i);
9325
+ i.every(f) || gs(e, n, l, i);
9326
9326
  const u = r[n] || [], d = /* @__PURE__ */ new Set();
9327
9327
  if (!i.every((w) => a(u, w, d))) throw new Error("Can not add duplicate data to array");
9328
9328
  r[n] = u.concat(i);
9329
9329
  } else {
9330
- if (f(i) || ys(e, n, l, i), !o(r, i)) throw new Error(`Can not add duplicate data to ${e}`);
9330
+ if (f(i) || gs(e, n, l, i), !o(r, i)) throw new Error(`Can not add duplicate data to ${e}`);
9331
9331
  r[n] = i;
9332
9332
  }
9333
9333
  }
9334
9334
  };
9335
9335
  }
9336
- var vl = yi("global"), oa = yi("input"), aa = yi("output");
9336
+ var vl = wi("global"), oa = wi("input"), aa = wi("output");
9337
9337
  function Il(e, t) {
9338
- oa(t, mt(e, e.length - 1));
9338
+ const r = mt(e, e.length - 1);
9339
+ oa(t, r);
9339
9340
  }
9340
9341
  function Al(e, t) {
9341
- aa(t, fr(e, e.length - 1));
9342
+ const r = fr(e, e.length - 1);
9343
+ aa(t, r);
9342
9344
  }
9343
- var bs = class {
9345
+ var ys = class {
9344
9346
  constructor(e) {
9345
9347
  this.inputs = [], this.outputs = [], this.globalMap = { unsignedTx: e };
9346
9348
  }
@@ -9369,10 +9371,12 @@ var bs = class {
9369
9371
  return vl(e, this.globalMap), this;
9370
9372
  }
9371
9373
  updateInput(e, t) {
9372
- return oa(t, mt(this.inputs, e)), this;
9374
+ const r = mt(this.inputs, e);
9375
+ return oa(t, r), this;
9373
9376
  }
9374
9377
  updateOutput(e, t) {
9375
- return aa(t, fr(this.outputs, e)), this;
9378
+ const r = fr(this.outputs, e);
9379
+ return aa(t, r), this;
9376
9380
  }
9377
9381
  addUnknownKeyValToGlobal(e) {
9378
9382
  return Sn(e, this.globalMap.unknownKeyVals, Tn(qt)), this.globalMap.unknownKeyVals || (this.globalMap.unknownKeyVals = []), this.globalMap.unknownKeyVals.push(e), this;
@@ -9423,14 +9427,14 @@ function Ur(e) {
9423
9427
  function kn(e) {
9424
9428
  if (e.unsafeSignNonSegwit) throw new Error("Not BIP174 compliant, can not export");
9425
9429
  }
9426
- function Mn(e) {
9430
+ function Dn(e) {
9427
9431
  return !!e.finalScriptSig || !!e.finalScriptWitness;
9428
9432
  }
9429
9433
  function Sl(e) {
9430
9434
  if (!e.ins.every((t) => t.script && t.script.length === 0 && t.witness && t.witness.length === 0)) throw new Error("Format Error: Transaction ScriptSigs are not empty");
9431
9435
  }
9432
9436
  function ha(e, t) {
9433
- const r = `${Yt(qn(new Uint8Array(t.hash)))}:${t.index}`;
9437
+ const r = `${Yt(zn(new Uint8Array(t.hash)))}:${t.index}`;
9434
9438
  if (e.txInCache[r]) throw new Error("Duplicate input detected.");
9435
9439
  e.txInCache[r] = 1;
9436
9440
  }
@@ -9461,8 +9465,8 @@ function fa(e, t) {
9461
9465
  if (!x(n, a)) throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`);
9462
9466
  };
9463
9467
  }
9464
- var ms = fa(dr, "Redeem script"), Es = fa(gr, "Witness script");
9465
- function vs(e) {
9468
+ var bs = fa(dr, "Redeem script"), ms = fa(gr, "Witness script");
9469
+ function Es(e) {
9466
9470
  let t = 0;
9467
9471
  function r(a) {
9468
9472
  return t += a, e.subarray(t - a, t);
@@ -9482,15 +9486,15 @@ function vs(e) {
9482
9486
  return o();
9483
9487
  }
9484
9488
  function Ul(e) {
9485
- let t = e & J.SIGHASH_ANYONECANPAY ? "SIGHASH_ANYONECANPAY | " : "";
9489
+ let t = e & tt.SIGHASH_ANYONECANPAY ? "SIGHASH_ANYONECANPAY | " : "";
9486
9490
  switch (e & 31) {
9487
- case J.SIGHASH_ALL:
9491
+ case tt.SIGHASH_ALL:
9488
9492
  t += "SIGHASH_ALL";
9489
9493
  break;
9490
- case J.SIGHASH_SINGLE:
9494
+ case tt.SIGHASH_SINGLE:
9491
9495
  t += "SIGHASH_SINGLE";
9492
9496
  break;
9493
- case J.SIGHASH_NONE:
9497
+ case tt.SIGHASH_NONE:
9494
9498
  t += "SIGHASH_NONE";
9495
9499
  break;
9496
9500
  }
@@ -9503,13 +9507,13 @@ function Ol(e) {
9503
9507
  }
9504
9508
  return new Uint8Array(e);
9505
9509
  }
9506
- function Is(e) {
9507
- return e.length === 33 && Fs(e);
9510
+ function vs(e) {
9511
+ return e.length === 33 && Ms(e);
9508
9512
  }
9509
9513
  function Pl(e) {
9510
9514
  return xe(e);
9511
9515
  }
9512
- function bi(e) {
9516
+ function gi(e) {
9513
9517
  return on(e) ? "witnesspubkeyhash" : Xu(e) ? "pubkeyhash" : qu(e) ? "multisig" : Yu(e) ? "pubkey" : "nonstandard";
9514
9518
  }
9515
9519
  function Ze(e) {
@@ -9519,19 +9523,19 @@ function Yr(e) {
9519
9523
  if (on(e) || Ko(e)) throw new Error("P2WPKH or P2SH can not be contained within P2WSH");
9520
9524
  }
9521
9525
  function Xr(e, t, r, n, i) {
9522
- const o = Ko(e), a = o && n && us(n), f = us(e);
9526
+ const o = Ko(e), a = o && n && hs(n), f = hs(e);
9523
9527
  if (o && n === void 0) throw new Error("scriptPubkey is P2SH but redeemScript missing");
9524
9528
  let l;
9525
9529
  if (a) {
9526
9530
  if (!i) throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
9527
9531
  if (!n) throw new Error("P2SH-P2WSH requires redeemScript");
9528
- l = i, ms(t, e, n, r), Es(t, n, i, r), Yr(l);
9532
+ l = i, bs(t, e, n, r), ms(t, n, i, r), Yr(l);
9529
9533
  } else if (f) {
9530
9534
  if (!i) throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
9531
- l = i, Es(t, e, i, r), Yr(l);
9535
+ l = i, ms(t, e, i, r), Yr(l);
9532
9536
  } else if (o) {
9533
9537
  if (!n) throw new Error("P2SH requires redeemScript");
9534
- l = n, ms(t, e, n, r);
9538
+ l = n, bs(t, e, n, r);
9535
9539
  } else l = e;
9536
9540
  return {
9537
9541
  meaningfulScript: l,
@@ -9585,7 +9589,7 @@ var xl = class {
9585
9589
  } else throw new Error("Can't find pubkey in input without Utxo data");
9586
9590
  }
9587
9591
  computeFee(e, t = !1, r) {
9588
- if (!e.every(Mn)) throw new Error("PSBT must be finalized to calculate fee");
9592
+ if (!e.every(Dn)) throw new Error("PSBT must be finalized to calculate fee");
9589
9593
  if (this.fee !== void 0) return this.fee;
9590
9594
  let n, i = !0;
9591
9595
  this.extractedTx ? (n = this.extractedTx, i = !1) : n = this.tx.clone();
@@ -9593,7 +9597,7 @@ var xl = class {
9593
9597
  return o;
9594
9598
  }
9595
9599
  computeFeeRate(e, t = !1, r) {
9596
- if (!e.every(Mn)) throw new Error("PSBT must be finalized to calculate fee rate");
9600
+ if (!e.every(Dn)) throw new Error("PSBT must be finalized to calculate fee rate");
9597
9601
  if (this.feeRate !== void 0) return this.feeRate;
9598
9602
  let n, i = !0;
9599
9603
  this.extractedTx ? (n = this.extractedTx, i = !1) : n = this.tx.clone();
@@ -9617,24 +9621,24 @@ var xl = class {
9617
9621
  }
9618
9622
  redeemFromFinalScriptSig(e) {
9619
9623
  if (!e) return;
9620
- const t = et(e);
9624
+ const t = rt(e);
9621
9625
  if (!t) return;
9622
9626
  const r = t[t.length - 1];
9623
- if (!(!(r instanceof Uint8Array) || Is(r) || Pl(r) || !et(r))) return r;
9627
+ if (!(!(r instanceof Uint8Array) || vs(r) || Pl(r) || !rt(r))) return r;
9624
9628
  }
9625
9629
  redeemFromFinalWitnessScript(e) {
9626
9630
  if (!e) return;
9627
- const t = vs(e), r = t[t.length - 1];
9628
- if (!(!r || Is(r) || !et(r))) return r;
9631
+ const t = Es(e), r = t[t.length - 1];
9632
+ if (!(!r || vs(r) || !rt(r))) return r;
9629
9633
  }
9630
9634
  finalizeAndComputeAmounts(e, t, r, n, i) {
9631
9635
  let o = 0n;
9632
9636
  e.forEach((d, w) => {
9633
- const b = t.ins[w];
9634
- if (r && d.finalScriptSig && (b.script = d.finalScriptSig), r && d.finalScriptWitness && (b.witness = vs(d.finalScriptWitness)), d.witnessUtxo) o += d.witnessUtxo.value;
9637
+ const y = t.ins[w];
9638
+ if (r && d.finalScriptSig && (y.script = d.finalScriptSig), r && d.finalScriptWitness && (y.witness = Es(d.finalScriptWitness)), d.witnessUtxo) o += d.witnessUtxo.value;
9635
9639
  else if (d.nonWitnessUtxo) {
9636
9640
  if (!i) throw new Error("txFromBuffer is required for nonWitnessUtxo inputs");
9637
- const m = this.getNonWitnessUtxoTx(d, w, i), v = b.index, I = m.outs[v];
9641
+ const m = this.getNonWitnessUtxoTx(d, w, i), v = y.index, I = m.outs[v];
9638
9642
  o += I.value;
9639
9643
  }
9640
9644
  });
@@ -9663,7 +9667,7 @@ var xl = class {
9663
9667
  }
9664
9668
  getPrevoutTaprootKey(e, t, r) {
9665
9669
  const { script: n } = this.getScriptAndAmountFromUtxo(e, t, r);
9666
- return ci(n) ? n.subarray(2, 34) : null;
9670
+ return ui(n) ? n.subarray(2, 34) : null;
9667
9671
  }
9668
9672
  }, Bl = class {
9669
9673
  #t;
@@ -9679,12 +9683,12 @@ var xl = class {
9679
9683
  };
9680
9684
  }
9681
9685
  getHashForSig(e, t, r, n) {
9682
- const i = this.#t.tx, o = t.sighashType || J.SIGHASH_ALL;
9683
- As(o, n);
9686
+ const i = this.#t.tx, o = t.sighashType || tt.SIGHASH_ALL;
9687
+ Is(o, n);
9684
9688
  let a, f;
9685
9689
  if (t.nonWitnessUtxo) {
9686
- const d = this.#t.getNonWitnessUtxoTx(t, e, this.#a), w = i.ins[e], b = w.hash;
9687
- if (!x(b, d.getHash())) throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);
9690
+ const d = this.#t.getNonWitnessUtxoTx(t, e, this.#a), w = i.ins[e], y = w.hash;
9691
+ if (!x(y, d.getHash())) throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);
9688
9692
  const m = w.index;
9689
9693
  f = d.outs[m];
9690
9694
  } else if (t.witnessUtxo) f = {
@@ -9712,17 +9716,17 @@ PROCEED WITH CAUTION!
9712
9716
  };
9713
9717
  }
9714
9718
  getTaprootHashesForSig(e, t, r, n, i, o) {
9715
- const a = this.#t.tx, f = t.sighashType || J.SIGHASH_DEFAULT;
9716
- if (As(f, o), !this.#t.prevOuts) {
9717
- const b = r.map((m, v) => this.#t.getScriptAndAmountFromUtxo(v, m, this.#a));
9718
- this.#t.prevOuts = b, this.#t.signingScripts = b.map((m) => m.script), this.#t.values = b.map((m) => m.value);
9719
+ const a = this.#t.tx, f = t.sighashType || tt.SIGHASH_DEFAULT;
9720
+ if (Is(f, o), !this.#t.prevOuts) {
9721
+ const y = r.map((m, v) => this.#t.getScriptAndAmountFromUtxo(v, m, this.#a));
9722
+ this.#t.prevOuts = y, this.#t.signingScripts = y.map((m) => m.script), this.#t.values = y.map((m) => m.value);
9719
9723
  }
9720
9724
  const l = this.#t.signingScripts, p = this.#t.values;
9721
9725
  this.#t.taprootHashCache || (this.#t.taprootHashCache = a.getTaprootHashCache(l, p));
9722
9726
  const u = this.#t.taprootHashCache, d = [];
9723
9727
  if (t.tapInternalKey && !i) {
9724
- const b = this.#t.getPrevoutTaprootKey(e, t, this.#a) || new Uint8Array(0);
9725
- if (x(Ce(n), b)) {
9728
+ const y = this.#t.getPrevoutTaprootKey(e, t, this.#a) || /* @__PURE__ */ new Uint8Array(0);
9729
+ if (x(Ce(n), y)) {
9726
9730
  const m = a.hashForWitnessV1(e, l, p, f, void 0, void 0, u);
9727
9731
  d.push({
9728
9732
  pubkey: n,
@@ -9730,16 +9734,16 @@ PROCEED WITH CAUTION!
9730
9734
  });
9731
9735
  }
9732
9736
  }
9733
- const w = (t.tapLeafScript || []).filter((b) => Fr(n, b.script)).map((b) => {
9737
+ const w = (t.tapLeafScript || []).filter((y) => Fr(n, y.script)).map((y) => {
9734
9738
  const m = Pt({
9735
- output: b.script,
9736
- version: b.leafVersion
9739
+ output: y.script,
9740
+ version: y.leafVersion
9737
9741
  });
9738
- return Object.assign({ hash: m }, b);
9739
- }).filter((b) => !i || x(i, b.hash)).map((b) => ({
9742
+ return Object.assign({ hash: m }, y);
9743
+ }).filter((y) => !i || x(i, y.hash)).map((y) => ({
9740
9744
  pubkey: n,
9741
- hash: a.hashForWitnessV1(e, l, p, f, b.hash, void 0, u),
9742
- leafHash: b.hash
9745
+ hash: a.hashForWitnessV1(e, l, p, f, y.hash, void 0, u),
9746
+ leafHash: y.hash
9743
9747
  }));
9744
9748
  return d.concat(w);
9745
9749
  }
@@ -9780,7 +9784,7 @@ PROCEED WITH CAUTION!
9780
9784
  };
9781
9785
  }
9782
9786
  };
9783
- function As(e, t) {
9787
+ function Is(e, t) {
9784
9788
  if (t && !t.includes(e)) {
9785
9789
  const r = Ul(e);
9786
9790
  throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`);
@@ -9793,7 +9797,7 @@ var _l = class {
9793
9797
  this.#t = e, this.#a = t;
9794
9798
  }
9795
9799
  getFinalScripts(e, t, r, n, i, o, a = !0, f) {
9796
- const l = bi(r);
9800
+ const l = gi(r);
9797
9801
  if (!la(t, r, l) && a) throw new Error(`Can not finalize input #${e}`);
9798
9802
  if (!t.partialSig) throw new Error("Input missing partial signatures");
9799
9803
  return ca(r, l, t.partialSig, n, i, o, f);
@@ -9803,7 +9807,7 @@ var _l = class {
9803
9807
  }
9804
9808
  };
9805
9809
  function Rl(e, t, r, n, i, o, a = !0, f) {
9806
- const l = bi(r);
9810
+ const l = gi(r);
9807
9811
  if (!la(t, r, l) && a) throw new Error(`Can not finalize input #${e}`);
9808
9812
  if (!t.partialSig) throw new Error("Input missing partial signatures");
9809
9813
  return ca(r, l, t.partialSig, n, i, o, f);
@@ -9821,11 +9825,11 @@ function la(e, t, r) {
9821
9825
  case "pubkey":
9822
9826
  case "pubkeyhash":
9823
9827
  case "witnesspubkeyhash":
9824
- return Ss(1, e.partialSig);
9828
+ return As(1, e.partialSig);
9825
9829
  case "multisig": {
9826
9830
  const n = yr({ output: t });
9827
9831
  if (n.m === void 0) throw new Error("Cannot determine m for multisig");
9828
- return Ss(n.m, e.partialSig, n.pubkeys);
9832
+ return As(n.m, e.partialSig, n.pubkeys);
9829
9833
  }
9830
9834
  case "nonstandard":
9831
9835
  return !0;
@@ -9833,7 +9837,7 @@ function la(e, t, r) {
9833
9837
  return !1;
9834
9838
  }
9835
9839
  }
9836
- function Ss(e, t, r) {
9840
+ function As(e, t, r) {
9837
9841
  if (!t) return !1;
9838
9842
  let n;
9839
9843
  if (r ? n = r.map((i) => {
@@ -9852,7 +9856,7 @@ function Nl(e, t, r) {
9852
9856
  });
9853
9857
  case "pubkey": {
9854
9858
  const i = r[0];
9855
- return fi({
9859
+ return hi({
9856
9860
  output: n,
9857
9861
  signature: i.signature
9858
9862
  });
@@ -9901,7 +9905,7 @@ var Ll = new Uint8Array([
9901
9905
  ]), pa = class {
9902
9906
  tx;
9903
9907
  constructor(e = Ll) {
9904
- this.tx = J.fromBuffer(e), Sl(this.tx), Object.defineProperty(this, "tx", {
9908
+ this.tx = tt.fromBuffer(e), Sl(this.tx), Object.defineProperty(this, "tx", {
9905
9909
  enumerable: !1,
9906
9910
  writable: !0
9907
9911
  });
@@ -9914,7 +9918,7 @@ var Ll = new Uint8Array([
9914
9918
  }
9915
9919
  addInput(e) {
9916
9920
  if (e.hash === void 0 || e.index === void 0 || !(e.hash instanceof Uint8Array) && typeof e.hash != "string" || typeof e.index != "number") throw new Error("Error adding input.");
9917
- const t = typeof e.hash == "string" ? qn(Mt(e.hash)) : e.hash;
9921
+ const t = typeof e.hash == "string" ? zn(Mt(e.hash)) : e.hash;
9918
9922
  this.tx.addInput(t, e.index, e.sequence);
9919
9923
  }
9920
9924
  addOutput(e) {
@@ -9929,13 +9933,13 @@ var Ll = new Uint8Array([
9929
9933
  maximumFeeRate: 5e3
9930
9934
  };
9931
9935
  function jt(e) {
9932
- return J.fromBuffer(e);
9936
+ return tt.fromBuffer(e);
9933
9937
  }
9934
9938
  function $l(e, t, r, n, i, o, a = !0, f) {
9935
9939
  return Rl(e, t, r, n, i, o, a, f);
9936
9940
  }
9937
- var Zl = class Fn {
9938
- constructor(t = {}, r = new bs(new pa())) {
9941
+ var Zl = class Mn {
9942
+ constructor(t = {}, r = new ys(new pa())) {
9939
9943
  this.data = r, this.#s = Object.assign({}, Vl, t);
9940
9944
  const n = this.data.globalMap.unsignedTx.tx;
9941
9945
  this.#t = new xl(n), t.version === 3 ? this.setVersionTRUC() : this.data.inputs.length === 0 && this.setVersion(2);
@@ -9961,7 +9965,7 @@ var Zl = class Fn {
9961
9965
  }
9962
9966
  get txInputs() {
9963
9967
  return this.#t.tx.ins.map((t) => ({
9964
- hash: Si(t.hash),
9968
+ hash: Ii(t.hash),
9965
9969
  index: t.index,
9966
9970
  sequence: t.sequence
9967
9971
  }));
@@ -9974,7 +9978,7 @@ var Zl = class Fn {
9974
9978
  } catch {
9975
9979
  }
9976
9980
  return {
9977
- script: Si(t.script),
9981
+ script: Ii(t.script),
9978
9982
  value: t.value,
9979
9983
  address: r
9980
9984
  };
@@ -9995,15 +9999,15 @@ var Zl = class Fn {
9995
9999
  return this.fromBuffer(n, r);
9996
10000
  }
9997
10001
  static fromBuffer(t, r = {}) {
9998
- const n = new Fn(r, bs.fromBuffer(t, Cl));
9999
- return Tl(n.#t.tx, n.#t), n.#t.hasSignatures = n.data.inputs.some((i) => i.partialSig?.length || i.tapKeySig || i.tapScriptSig?.length || i.finalScriptSig || i.finalScriptWitness), n;
10002
+ const n = ys.fromBuffer(t, Cl), i = new Mn(r, n);
10003
+ return Tl(i.#t.tx, i.#t), i.#t.hasSignatures = i.data.inputs.some((o) => o.partialSig?.length || o.tapKeySig || o.tapScriptSig?.length || o.finalScriptSig || o.finalScriptWitness), i;
10000
10004
  }
10001
10005
  combine(...t) {
10002
10006
  return this.data.combine(...t.map((r) => r.data)), this;
10003
10007
  }
10004
10008
  clone() {
10005
10009
  const t = structuredClone(this.#s);
10006
- return Fn.fromBuffer(new Uint8Array(this.data.toBuffer()), t);
10010
+ return Mn.fromBuffer(new Uint8Array(this.data.toBuffer()), t);
10007
10011
  }
10008
10012
  get maximumFeeRate() {
10009
10013
  return this.#s.maximumFeeRate;
@@ -10015,7 +10019,7 @@ var Zl = class Fn {
10015
10019
  return Ur(t), Xe(this.data.inputs, "setVersion", this.#t.hasSignatures), this.#t.tx.version = t, this.#t.invalidate("outputs"), this;
10016
10020
  }
10017
10021
  setVersionTRUC() {
10018
- return this.setVersion(J.TRUC_VERSION);
10022
+ return this.setVersion(tt.TRUC_VERSION);
10019
10023
  }
10020
10024
  setLocktime(t) {
10021
10025
  return Ur(t), Xe(this.data.inputs, "setLocktime", this.#t.hasSignatures), this.#t.tx.locktime = t, this.#t.invalidate("outputs"), this;
@@ -10029,7 +10033,7 @@ var Zl = class Fn {
10029
10033
  }
10030
10034
  addInput(t, r = !0) {
10031
10035
  if (!t || t.hash === void 0 || t.index === void 0) throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");
10032
- cs(t, t, "addInput"), r && Xe(this.data.inputs, "addInput", this.#t.hasSignatures), t.witnessScript && Yr(t.witnessScript);
10036
+ fs(t, t, "addInput"), r && Xe(this.data.inputs, "addInput", this.#t.hasSignatures), t.witnessScript && Yr(t.witnessScript);
10033
10037
  const n = t.witnessUtxo ? {
10034
10038
  ...t,
10035
10039
  witnessUtxo: {
@@ -10053,10 +10057,10 @@ var Zl = class Fn {
10053
10057
  const { address: o } = t, { network: a } = this.#s, f = Yo(o, a);
10054
10058
  t = Object.assign({}, t, { script: f });
10055
10059
  }
10056
- return ls(t, t, "addOutput"), this.data.addOutput(t), this.#t.invalidate("outputs"), this;
10060
+ return cs(t, t, "addOutput"), this.data.addOutput(t), this.#t.invalidate("outputs"), this;
10057
10061
  }
10058
10062
  extractTransaction(t, r) {
10059
- if (r && (this.data.inputs = this.data.inputs.filter((i) => !i.partialSig)), !this.data.inputs.every(Mn)) throw new Error("Not finalized");
10063
+ if (r && (this.data.inputs = this.data.inputs.filter((i) => !i.partialSig)), !this.data.inputs.every(Dn)) throw new Error("Not finalized");
10060
10064
  if (t || (this.#t.computeFeeRate(this.data.inputs, r, jt), this.#t.checkFees(this.#s)), this.#t.extractedTx) return this.#t.extractedTx;
10061
10065
  const n = this.#t.tx.clone();
10062
10066
  return this.#t.finalizeAndComputeAmounts(this.data.inputs, n, !0, r, jt), n;
@@ -10074,14 +10078,14 @@ var Zl = class Fn {
10074
10078
  const i = mt(this.data.inputs, t);
10075
10079
  return Lt(i) ? this.#o(t, i, void 0, r) : this.#i(t, i, r, n ?? !0);
10076
10080
  }
10077
- finalizeTaprootInput(t, r, n = fs) {
10081
+ finalizeTaprootInput(t, r, n = us) {
10078
10082
  const i = mt(this.data.inputs, t);
10079
10083
  if (Lt(i)) return this.#o(t, i, r, n);
10080
10084
  throw new Error(`Cannot finalize input #${t}. Not Taproot.`);
10081
10085
  }
10082
10086
  getInputType(t) {
10083
10087
  const r = mt(this.data.inputs, t), n = Xr(this.#t.getScriptFromUtxo(t, r, jt), t, "input", r.redeemScript || this.#t.redeemFromFinalScriptSig(r.finalScriptSig), r.witnessScript || this.#t.redeemFromFinalWitnessScript(r.finalScriptWitness));
10084
- return (n.type === "raw" ? "" : n.type + "-") + bi(n.meaningfulScript);
10088
+ return (n.type === "raw" ? "" : n.type + "-") + gi(n.meaningfulScript);
10085
10089
  }
10086
10090
  inputHasPubkey(t, r) {
10087
10091
  const n = mt(this.data.inputs, t);
@@ -10106,7 +10110,7 @@ var Zl = class Fn {
10106
10110
  const i = this.data.inputs[t];
10107
10111
  return Lt(i) ? this.#f(t, r, n) : this.#h(t, r, n);
10108
10112
  }
10109
- signAllInputsHD(t, r = [J.SIGHASH_ALL]) {
10113
+ signAllInputsHD(t, r = [tt.SIGHASH_ALL]) {
10110
10114
  if (!t || !t.publicKey || !t.fingerprint) throw new Error("Need HDSigner to sign input");
10111
10115
  const n = [];
10112
10116
  for (const i of Ze(this.data.inputs.length)) try {
@@ -10117,7 +10121,7 @@ var Zl = class Fn {
10117
10121
  if (n.every((i) => !i)) throw new Error("No inputs were signed");
10118
10122
  return this;
10119
10123
  }
10120
- async signAllInputsHDAsync(t, r = [J.SIGHASH_ALL]) {
10124
+ async signAllInputsHDAsync(t, r = [tt.SIGHASH_ALL]) {
10121
10125
  if (!t || !t.publicKey || !t.fingerprint) throw new Error("Need HDSigner to sign input");
10122
10126
  const n = [], i = [];
10123
10127
  for (const o of Ze(this.data.inputs.length)) i.push(this.signInputHDAsync(o, t, r).then(() => {
@@ -10127,11 +10131,11 @@ var Zl = class Fn {
10127
10131
  }));
10128
10132
  if (await Promise.all(i), n.every((o) => !o)) throw new Error("No inputs were signed");
10129
10133
  }
10130
- signInputHD(t, r, n = [J.SIGHASH_ALL]) {
10134
+ signInputHD(t, r, n = [tt.SIGHASH_ALL]) {
10131
10135
  if (!r || !r.publicKey || !r.fingerprint) throw new Error("Need HDSigner to sign input");
10132
10136
  return this.#r.getSignersFromHD(t, this.data.inputs, r).forEach((i) => this.signInput(t, i, n)), this;
10133
10137
  }
10134
- async signInputHDAsync(t, r, n = [J.SIGHASH_ALL]) {
10138
+ async signInputHDAsync(t, r, n = [tt.SIGHASH_ALL]) {
10135
10139
  if (!r || !r.publicKey || !r.fingerprint) throw new Error("Need HDSigner to sign input");
10136
10140
  const i = this.#r.getSignersFromHD(t, this.data.inputs, r).map((o) => this.signInputAsync(t, o, n));
10137
10141
  await Promise.all(i);
@@ -10192,7 +10196,7 @@ var Zl = class Fn {
10192
10196
  return this.data.updateGlobal(t), this;
10193
10197
  }
10194
10198
  updateInput(t, r) {
10195
- r.witnessScript && Yr(r.witnessScript), cs(this.data.inputs[t], r, "updateInput");
10199
+ r.witnessScript && Yr(r.witnessScript), fs(this.data.inputs[t], r, "updateInput");
10196
10200
  const n = r.witnessUtxo ? {
10197
10201
  ...r,
10198
10202
  witnessUtxo: {
@@ -10204,7 +10208,7 @@ var Zl = class Fn {
10204
10208
  }
10205
10209
  updateOutput(t, r) {
10206
10210
  const n = this.data.outputs[t];
10207
- return ls(n, r, "updateOutput"), this.data.updateOutput(t, r), this;
10211
+ return cs(n, r, "updateOutput"), this.data.updateOutput(t, r), this;
10208
10212
  }
10209
10213
  addUnknownKeyValToGlobal(t) {
10210
10214
  return this.data.addUnknownKeyValToGlobal(t), this;
@@ -10232,9 +10236,9 @@ var Zl = class Fn {
10232
10236
  if (p && this.data.updateInput(t, { finalScriptSig: p }), u && this.data.updateInput(t, { finalScriptWitness: u }), !p && !u) throw new Error(`Unknown error finalizing input #${t}`);
10233
10237
  return this.data.clearFinalizedInput(t), this;
10234
10238
  }
10235
- #o(t, r, n, i = fs) {
10239
+ #o(t, r, n, i = us) {
10236
10240
  if (!r.witnessUtxo) throw new Error(`Cannot finalize input #${t}. Missing witness utxo.`);
10237
- if (r.tapKeySig && !Cn(r)) {
10241
+ if (r.tapKeySig && !Ln(r)) {
10238
10242
  const o = wr({
10239
10243
  output: r.witnessUtxo.script,
10240
10244
  signature: r.tapKeySig
@@ -10257,11 +10261,11 @@ var Zl = class Fn {
10257
10261
  const f = [];
10258
10262
  let l, p, u;
10259
10263
  for (const d of a) {
10260
- const w = d.signature, b = d.pubkey, m = Ae.decode(w), { hash: v, script: I } = u !== m.hashType || !l || !p ? this.#r.getHashForSig(t, Object.assign({}, i, { sighashType: m.hashType }), !0) : {
10264
+ const w = d.signature, y = d.pubkey, m = Ae.decode(w), { hash: v, script: I } = u !== m.hashType || !l || !p ? this.#r.getHashForSig(t, Object.assign({}, i, { sighashType: m.hashType }), !0) : {
10261
10265
  hash: l,
10262
10266
  script: p
10263
10267
  };
10264
- u = m.hashType, l = v, p = I, ua(b, I, "verify"), f.push(r(b, v, m.signature));
10268
+ u = m.hashType, l = v, p = I, ua(y, I, "verify"), f.push(r(y, v, m.signature));
10265
10269
  }
10266
10270
  return f.every((d) => d);
10267
10271
  }
@@ -10278,22 +10282,22 @@ var Zl = class Fn {
10278
10282
  u++;
10279
10283
  }
10280
10284
  if (a) for (const d of a) {
10281
- const w = d.pubkey, b = l.find((m) => x(w, m.pubkey));
10282
- if (b) {
10283
- if (!r(w, b.hash, this.#r.trimTaprootSig(d.signature))) return !1;
10285
+ const w = d.pubkey, y = l.find((m) => x(w, m.pubkey));
10286
+ if (y) {
10287
+ if (!r(w, y.hash, this.#r.trimTaprootSig(d.signature))) return !1;
10284
10288
  u++;
10285
10289
  }
10286
10290
  }
10287
10291
  return u > 0;
10288
10292
  }
10289
- #u(t, r, n = [J.SIGHASH_ALL]) {
10293
+ #u(t, r, n = [tt.SIGHASH_ALL]) {
10290
10294
  const i = r.publicKey instanceof Uint8Array ? r.publicKey : new Uint8Array(r.publicKey), { hash: o, sighashType: a } = this.#r.getHashAndSighashType(this.data.inputs, t, i, n), f = r.sign(o), l = [{
10291
10295
  pubkey: i,
10292
10296
  signature: Ae.encode(f instanceof Uint8Array ? f : new Uint8Array(f), a)
10293
10297
  }];
10294
10298
  return this.data.updateInput(t, { partialSig: l }), this.#t.hasSignatures = !0, this;
10295
10299
  }
10296
- #c(t, r, n, i, o = [J.SIGHASH_DEFAULT]) {
10300
+ #c(t, r, n, i, o = [tt.SIGHASH_DEFAULT]) {
10297
10301
  const a = n.publicKey instanceof Uint8Array ? n.publicKey : new Uint8Array(n.publicKey);
10298
10302
  if (!("signSchnorr" in n) || typeof n.signSchnorr != "function") throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);
10299
10303
  const f = this.checkTaprootHashesForSig(t, r, n, i, o), l = n.signSchnorr.bind(n), p = f.filter((d) => !d.leafHash).map((d) => Le(l(d.hash), r.sighashType))[0], u = f.filter((d) => !!d.leafHash).map((d) => ({
@@ -10303,14 +10307,14 @@ var Zl = class Fn {
10303
10307
  }));
10304
10308
  return p && (this.data.updateInput(t, { tapKeySig: p }), this.#t.hasSignatures = !0), u.length && (this.data.updateInput(t, { tapScriptSig: u }), this.#t.hasSignatures = !0), this;
10305
10309
  }
10306
- async #p(t, r, n = [J.SIGHASH_ALL]) {
10310
+ async #p(t, r, n = [tt.SIGHASH_ALL]) {
10307
10311
  const i = r.publicKey instanceof Uint8Array ? r.publicKey : new Uint8Array(r.publicKey), { hash: o, sighashType: a } = this.#r.getHashAndSighashType(this.data.inputs, t, i, n), f = await r.sign(o), l = f instanceof Uint8Array ? f : new Uint8Array(f), p = [{
10308
10312
  pubkey: i,
10309
10313
  signature: Ae.encode(l, a)
10310
10314
  }];
10311
10315
  this.data.updateInput(t, { partialSig: p }), this.#t.hasSignatures = !0;
10312
10316
  }
10313
- async #l(t, r, n, i, o = [J.SIGHASH_DEFAULT]) {
10317
+ async #l(t, r, n, i, o = [tt.SIGHASH_DEFAULT]) {
10314
10318
  const a = n.publicKey instanceof Uint8Array ? n.publicKey : new Uint8Array(n.publicKey);
10315
10319
  if (!("signSchnorr" in n) || typeof n.signSchnorr != "function") throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);
10316
10320
  const f = this.checkTaprootHashesForSig(t, r, n, i, o), l = n.signSchnorr.bind(n), p = f.find((d) => !d.leafHash);
@@ -10321,10 +10325,10 @@ var Zl = class Fn {
10321
10325
  const u = f.filter((d) => !!d.leafHash);
10322
10326
  if (u.length) {
10323
10327
  const d = await Promise.all(u.map(async (w) => {
10324
- const b = await l(w.hash);
10328
+ const y = await l(w.hash);
10325
10329
  return {
10326
10330
  pubkey: Ce(a),
10327
- signature: Le(b, r.sighashType),
10331
+ signature: Le(y, r.sighashType),
10328
10332
  leafHash: w.leafHash
10329
10333
  };
10330
10334
  }));
@@ -10354,10 +10358,10 @@ export {
10354
10358
  Wl as O,
10355
10359
  Ku as P,
10356
10360
  Yt as R,
10357
- ci as S,
10358
- li as T,
10361
+ ui as S,
10362
+ fi as T,
10359
10363
  j as V,
10360
- us as _,
10364
+ hs as _,
10361
10365
  $l as a,
10362
10366
  va as b,
10363
10367
  Wo as c,
@@ -10366,13 +10370,13 @@ export {
10366
10370
  Kl as g,
10367
10371
  zl as h,
10368
10372
  Uf as i,
10369
- J as j,
10373
+ tt as j,
10370
10374
  Mt as k,
10371
10375
  Yu as l,
10372
10376
  De as m,
10373
10377
  Pf as n,
10374
10378
  Tf as o,
10375
- _n as p,
10379
+ Bn as p,
10376
10380
  qo as r,
10377
10381
  Ql as s,
10378
10382
  Zl as t,