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

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 (30) hide show
  1. package/browser/btc-vision-bitcoin.js +364 -364
  2. package/browser/index.js +1022 -903
  3. package/browser/noble-curves.js +1183 -2156
  4. package/browser/src/transaction/builders/TransactionBuilder.d.ts +1 -0
  5. package/browser/src/transaction/offline/OfflineTransactionManager.d.ts +50 -0
  6. package/browser/src/transaction/offline/interfaces/ISerializableState.d.ts +10 -2
  7. package/browser/vendors.js +1395 -1395
  8. package/build/transaction/TransactionFactory.js +1 -1
  9. package/build/transaction/builders/FundingTransaction.js +17 -13
  10. package/build/transaction/builders/TransactionBuilder.d.ts +1 -0
  11. package/build/transaction/builders/TransactionBuilder.js +32 -7
  12. package/build/transaction/offline/OfflineTransactionManager.d.ts +50 -0
  13. package/build/transaction/offline/OfflineTransactionManager.js +142 -1
  14. package/build/transaction/offline/TransactionSerializer.js +9 -0
  15. package/build/transaction/offline/interfaces/ISerializableState.d.ts +10 -2
  16. package/build/transaction/offline/interfaces/ISerializableState.js +3 -2
  17. package/build/transaction/shared/TweakedTransaction.js +27 -5
  18. package/package.json +1 -1
  19. package/src/transaction/TransactionFactory.ts +1 -1
  20. package/src/transaction/builders/FundingTransaction.ts +21 -16
  21. package/src/transaction/builders/TransactionBuilder.ts +46 -10
  22. package/src/transaction/offline/OfflineTransactionManager.ts +191 -1
  23. package/src/transaction/offline/TransactionSerializer.ts +11 -0
  24. package/src/transaction/offline/interfaces/ISerializableState.ts +10 -2
  25. package/src/transaction/shared/TweakedTransaction.ts +33 -5
  26. package/test/add-refund-output.test.ts +96 -11
  27. package/test/csv-multisig-offline-edges.test.ts +293 -0
  28. package/test/csv-multisig-offline.test.ts +202 -0
  29. package/test/transaction-builders.test.ts +69 -3
  30. 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);
@@ -289,10 +289,10 @@ function cr(e) {
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
  }
@@ -906,7 +906,7 @@ var Gn = class {
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;
909
+ const d = Wt(a, 6) ^ Wt(a, 11) ^ Wt(a, 25), w = p + d + Os(a, f, l) + Ca[u] + oe[u] | 0, b = (Wt(r, 2) ^ Wt(r, 13) ^ Wt(r, 22)) + Ps(r, n, i) | 0;
910
910
  p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w + b | 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);
@@ -929,7 +929,7 @@ 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
935
  const t = new Uint8Array(256);
@@ -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,8 +1302,8 @@ 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) {
1305
+ var qn = {};
1306
+ qn.read = function(e, t, r, n, i) {
1307
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
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) ;
1309
1309
  for (a = o & (1 << -u) - 1, o >>= -u, u += n; u > 0; a = a * 256 + e[t + d], d += w, u -= 8) ;
@@ -1314,14 +1314,14 @@ Yn.read = function(e, t, r, n, i) {
1314
1314
  }
1315
1315
  return (b ? -1 : 1) * a * Math.pow(2, o - n);
1316
1316
  };
1317
- Yn.write = function(e, t, r, n, i, o) {
1317
+ qn.write = function(e, t, r, n, i, o) {
1318
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
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
1320
  for (a = a << i | f, p += i; p > 0; e[r + b] = a & 255, b += m, a /= 256, p -= 8) ;
1321
1321
  e[r + b - 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;
@@ -1502,7 +1502,7 @@ 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
1507
  if (y) return g ? -1 : hn(s).length;
1508
1508
  h = ("" + h).toLowerCase(), y = !0;
@@ -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);
@@ -1868,14 +1868,14 @@ Yn.write = function(e, t, r, n, i, o) {
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
1870
  function nt(s, h, c, g, y) {
1871
- mi(h, g, y, s, c, 7);
1871
+ yi(h, g, y, 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
1877
  function lt(s, h, c, g, y) {
1878
- mi(h, g, y, s, c, 7);
1878
+ yi(h, g, y, 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));
@@ -2008,7 +2008,7 @@ 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, y, E) {
2012
2012
  if (s > c || s < h) {
2013
2013
  const k = typeof h == "bigint" ? "n" : "";
2014
2014
  let st;
@@ -2080,7 +2080,7 @@ Yn.write = function(e, t, r, n, i, o) {
2080
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);
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) {
@@ -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)) {
@@ -2299,9 +2299,9 @@ 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)) {
2304
+ if (Zn(e)) {
2305
2305
  const r = et(e);
2306
2306
  if (!r) throw new Error("Could not convert invalid chunks to ASM");
2307
2307
  t = r;
@@ -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) ? et(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,
2340
+ countNonPushOnlyOPs: Xn,
2341
2341
  decompile: et,
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;
@@ -2471,14 +2471,14 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
2471
2471
  if (!t) return;
2472
2472
  if (!this.#t.bech32Opnet) throw new TypeError("Network does not support opnet");
2473
2473
  const r = tt.bech32m.toWords(t);
2474
- return r.unshift(Bi), tt.bech32m.encode(this.#t.bech32Opnet, r);
2474
+ return r.unshift(Pi), tt.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 b = 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(b, 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,7 +3516,7 @@ 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
3521
  const b = 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);
@@ -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, b = l % 2 !== 0, m = p < 0;
3591
+ p === 0 ? n = n.add(Ki(b, 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)
@@ -3750,7 +3750,7 @@ var he = j, ao = class Je {
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]);
@@ -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)
@@ -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;
@@ -4031,7 +4031,7 @@ var Ye = j, ho = class tr {
4031
4031
  const r = et(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;
@@ -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);
@@ -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,10 +4530,10 @@ 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;
@@ -4560,7 +4560,7 @@ function pu(e, t, r) {
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,16 +4601,16 @@ 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;
@@ -4619,7 +4619,7 @@ function yu(e) {
4619
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
4620
  p = f.cmov(p, u, b), 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,13 +4628,13 @@ 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;
@@ -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,12 +4836,12 @@ 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);
@@ -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,13 +5014,13 @@ 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;
5023
+ const b = ni(Math.ceil(lu(r) / 2)) + Ve;
5024
5024
  if (p < re || p >= b || u < re || u >= b) throw new Error("splitScalar (endomorphism): failed, k=" + e);
5025
5025
  return {
5026
5026
  k1neg: d,
@@ -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",
@@ -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 D = 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
+ }), X = 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");
@@ -5297,7 +5297,7 @@ 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
5302
  const { k1neg: $, k1: C, k2neg: L, k2: M } = z(U), { p: F, f: ct } = V(C), { p: W, f: K } = V(M);
5303
5303
  B = ct.add(K), A = at(T.beta, F, W, $, L);
@@ -5305,7 +5305,7 @@ function _u(e, t = {}) {
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;
@@ -5384,7 +5384,7 @@ function Ru(e, t = {}) {
5384
5384
  }
5385
5385
  function p(b) {
5386
5386
  const { secretKey: m, publicKey: v, publicKeyUncompressed: I } = i;
5387
- if (!ri(b) || "_lengths" in r && r._lengths || m === v) return;
5387
+ if (!ti(b) || "_lengths" in r && r._lengths || m === v) return;
5388
5388
  const P = ut(b, void 0, "key").length;
5389
5389
  return P === v || P === I;
5390
5390
  }
@@ -5409,7 +5409,7 @@ 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",
@@ -5433,7 +5433,7 @@ 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);
5436
+ Rn(A);
5437
5437
  const B = b.signature;
5438
5438
  return ut(T, A === "compact" ? B : A === "recovered" ? B + 1 : void 0);
5439
5439
  }
@@ -5486,7 +5486,7 @@ function Nu(e, t, r = {}) {
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
  }
@@ -5500,7 +5500,7 @@ function Nu(e, t, r = {}) {
5500
5500
  return B > 0 ? A >> BigInt(B) : A;
5501
5501
  }, D = r.bits2int_modN || function(T) {
5502
5502
  return a.create(z(T));
5503
- }, X = si(l);
5503
+ }, X = ni(l);
5504
5504
  function at(T) {
5505
5505
  return cu("num < 2^" + l, T, re, X), a.toBytes(T);
5506
5506
  }
@@ -5539,7 +5539,7 @@ 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)) {
5542
+ if (B = ut(B, void 0, "publicKey"), A = q(A, C), !ti(T)) {
5543
5543
  const M = T instanceof O ? ", use sig.toBytes()" : "";
5544
5544
  throw new Error("verify expects Uint8Array signature" + M);
5545
5545
  }
@@ -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,15 +5582,15 @@ 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, 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, 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) {
@@ -5612,7 +5612,7 @@ function Cu(e) {
5612
5612
  const o = e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"));
5613
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");
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;
@@ -5835,7 +5835,7 @@ var ts = j, es = 2, Mu = 80, No = class rr {
5835
5835
  const t = this.hash;
5836
5836
  if (!t) return;
5837
5837
  const r = tt.bech32m.toWords(t);
5838
- return r.unshift(es), tt.bech32m.encode(this.#t.bech32, r);
5838
+ return r.unshift(ts), tt.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;
@@ -5890,12 +5890,12 @@ var ts = j, es = 2, Mu = 80, No = class rr {
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
  }
@@ -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;
@@ -6102,7 +6102,7 @@ var rs = j, ns = 1, Fu = 80, Ho = class nr {
6102
6102
  const t = this.pubkey;
6103
6103
  if (!t) return;
6104
6104
  const r = tt.bech32m.toWords(t);
6105
- return r.unshift(ns), tt.bech32m.encode(this.#t.bech32, r);
6105
+ return r.unshift(rs), tt.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;
@@ -6184,7 +6184,7 @@ var rs = j, ns = 1, Fu = 80, Ho = class nr {
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
  }
@@ -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 = new Uint8Array(0), Lo = class ir {
6263
6263
  static NAME = ft.P2WPKH;
6264
6264
  #t;
6265
6265
  #a;
@@ -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;
@@ -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 = new Uint8Array(0);
6456
6456
  function Sr(e) {
6457
6457
  return !!(e instanceof Uint8Array && e.length === 65 && e[0] === 4 && ke(e));
6458
6458
  }
@@ -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
  }
@@ -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;
@@ -6638,7 +6638,7 @@ var Co = class sr {
6638
6638
  const n = et(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;
@@ -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;
@@ -6755,7 +6755,7 @@ var os = j, Vo = class Br {
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");
@@ -6784,7 +6784,7 @@ var os = j, Vo = class Br {
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,
@@ -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 = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000000000000000000000000000000000"), as = Or(Mt("0000000000000000000000000000000000000000000000000000000000000001")), ju = 18446744073709551615n, J = class Q {
6983
6983
  static DEFAULT_SEQUENCE = 4294967295;
6984
6984
  static SIGHASH_DEFAULT = 0;
6985
6985
  static SIGHASH_ALL = 1;
@@ -7011,7 +7011,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7011
7011
  index: w,
7012
7012
  script: b,
7013
7013
  sequence: m,
7014
- witness: as
7014
+ witness: os
7015
7015
  });
7016
7016
  }
7017
7017
  const p = n.readVarInt();
@@ -7048,7 +7048,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
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) {
@@ -7090,7 +7090,7 @@ 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;
7093
+ if (t >= this.ins.length) return as;
7094
7094
  const i = et(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();
@@ -7098,7 +7098,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7098
7098
  p !== t && (l.sequence = 0);
7099
7099
  });
7100
7100
  else if ((n & 31) === Q.SIGHASH_SINGLE) {
7101
- if (t >= this.outs.length) return hs;
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,
@@ -7207,7 +7207,7 @@ var ce = new Uint8Array(0), as = [], kr = Mt("0000000000000000000000000000000000
7207
7207
  return t && this.isCoinbase() ? 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);
@@ -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) {
@@ -7272,7 +7272,7 @@ function or(e) {
7272
7272
  function Do(e, t) {
7273
7273
  const r = et(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) {
@@ -7306,7 +7306,7 @@ function Ju(e) {
7306
7306
  const t = e.finalScriptSig ? et(new Uint8Array(e.finalScriptSig)) || [] : [], r = e.finalScriptWitness ? et(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))) };
@@ -7318,18 +7318,18 @@ function Le(e, t) {
7318
7318
  return Bt([e, t ? new Uint8Array([t]) : 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) {
@@ -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.`);
@@ -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,11 +8098,11 @@ 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
8108
  const i = tt.bech32.toWords(e);
@@ -8111,8 +8111,8 @@ function Wr(e, t, r, n) {
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) {
@@ -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
  });
@@ -8242,13 +8242,13 @@ var Uf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
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
8249
  const t = et(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,
@@ -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
@@ -8602,7 +8602,7 @@ function Tc(e) {
8602
8602
  }
8603
8603
  function kc(e) {
8604
8604
  const t = Uint8Array.from([R.SIGHASH_TYPE]), r = new Uint8Array(4);
8605
- return pi(r, 0, e, "LE"), {
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);
@@ -8843,7 +8843,7 @@ function di(e, t = ll) {
8843
8843
  return p.slice(1).forEach((w) => {
8844
8844
  const b = w.slice(-1) === "'";
8845
8845
  let m = 2147483647 & parseInt(b ? w.slice(0, -1) : w, 10);
8846
- b && (m += 2147483648), pi(u, d, m, "LE"), d += 4;
8846
+ b && (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");
@@ -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 = 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,34 @@ 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
9338
  oa(t, mt(e, e.length - 1));
9339
9339
  }
9340
9340
  function Al(e, t) {
9341
9341
  aa(t, fr(e, e.length - 1));
9342
9342
  }
9343
- var bs = class {
9343
+ var ys = class {
9344
9344
  constructor(e) {
9345
9345
  this.inputs = [], this.outputs = [], this.globalMap = { unsignedTx: e };
9346
9346
  }
@@ -9423,14 +9423,14 @@ function Ur(e) {
9423
9423
  function kn(e) {
9424
9424
  if (e.unsafeSignNonSegwit) throw new Error("Not BIP174 compliant, can not export");
9425
9425
  }
9426
- function Mn(e) {
9426
+ function Dn(e) {
9427
9427
  return !!e.finalScriptSig || !!e.finalScriptWitness;
9428
9428
  }
9429
9429
  function Sl(e) {
9430
9430
  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
9431
  }
9432
9432
  function ha(e, t) {
9433
- const r = `${Yt(qn(new Uint8Array(t.hash)))}:${t.index}`;
9433
+ const r = `${Yt(zn(new Uint8Array(t.hash)))}:${t.index}`;
9434
9434
  if (e.txInCache[r]) throw new Error("Duplicate input detected.");
9435
9435
  e.txInCache[r] = 1;
9436
9436
  }
@@ -9461,8 +9461,8 @@ function fa(e, t) {
9461
9461
  if (!x(n, a)) throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`);
9462
9462
  };
9463
9463
  }
9464
- var ms = fa(dr, "Redeem script"), Es = fa(gr, "Witness script");
9465
- function vs(e) {
9464
+ var bs = fa(dr, "Redeem script"), ms = fa(gr, "Witness script");
9465
+ function Es(e) {
9466
9466
  let t = 0;
9467
9467
  function r(a) {
9468
9468
  return t += a, e.subarray(t - a, t);
@@ -9503,13 +9503,13 @@ function Ol(e) {
9503
9503
  }
9504
9504
  return new Uint8Array(e);
9505
9505
  }
9506
- function Is(e) {
9507
- return e.length === 33 && Fs(e);
9506
+ function vs(e) {
9507
+ return e.length === 33 && Ms(e);
9508
9508
  }
9509
9509
  function Pl(e) {
9510
9510
  return xe(e);
9511
9511
  }
9512
- function bi(e) {
9512
+ function gi(e) {
9513
9513
  return on(e) ? "witnesspubkeyhash" : Xu(e) ? "pubkeyhash" : qu(e) ? "multisig" : Yu(e) ? "pubkey" : "nonstandard";
9514
9514
  }
9515
9515
  function Ze(e) {
@@ -9519,19 +9519,19 @@ function Yr(e) {
9519
9519
  if (on(e) || Ko(e)) throw new Error("P2WPKH or P2SH can not be contained within P2WSH");
9520
9520
  }
9521
9521
  function Xr(e, t, r, n, i) {
9522
- const o = Ko(e), a = o && n && us(n), f = us(e);
9522
+ const o = Ko(e), a = o && n && hs(n), f = hs(e);
9523
9523
  if (o && n === void 0) throw new Error("scriptPubkey is P2SH but redeemScript missing");
9524
9524
  let l;
9525
9525
  if (a) {
9526
9526
  if (!i) throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
9527
9527
  if (!n) throw new Error("P2SH-P2WSH requires redeemScript");
9528
- l = i, ms(t, e, n, r), Es(t, n, i, r), Yr(l);
9528
+ l = i, bs(t, e, n, r), ms(t, n, i, r), Yr(l);
9529
9529
  } else if (f) {
9530
9530
  if (!i) throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
9531
- l = i, Es(t, e, i, r), Yr(l);
9531
+ l = i, ms(t, e, i, r), Yr(l);
9532
9532
  } else if (o) {
9533
9533
  if (!n) throw new Error("P2SH requires redeemScript");
9534
- l = n, ms(t, e, n, r);
9534
+ l = n, bs(t, e, n, r);
9535
9535
  } else l = e;
9536
9536
  return {
9537
9537
  meaningfulScript: l,
@@ -9585,7 +9585,7 @@ var xl = class {
9585
9585
  } else throw new Error("Can't find pubkey in input without Utxo data");
9586
9586
  }
9587
9587
  computeFee(e, t = !1, r) {
9588
- if (!e.every(Mn)) throw new Error("PSBT must be finalized to calculate fee");
9588
+ if (!e.every(Dn)) throw new Error("PSBT must be finalized to calculate fee");
9589
9589
  if (this.fee !== void 0) return this.fee;
9590
9590
  let n, i = !0;
9591
9591
  this.extractedTx ? (n = this.extractedTx, i = !1) : n = this.tx.clone();
@@ -9593,7 +9593,7 @@ var xl = class {
9593
9593
  return o;
9594
9594
  }
9595
9595
  computeFeeRate(e, t = !1, r) {
9596
- if (!e.every(Mn)) throw new Error("PSBT must be finalized to calculate fee rate");
9596
+ if (!e.every(Dn)) throw new Error("PSBT must be finalized to calculate fee rate");
9597
9597
  if (this.feeRate !== void 0) return this.feeRate;
9598
9598
  let n, i = !0;
9599
9599
  this.extractedTx ? (n = this.extractedTx, i = !1) : n = this.tx.clone();
@@ -9620,18 +9620,18 @@ var xl = class {
9620
9620
  const t = et(e);
9621
9621
  if (!t) return;
9622
9622
  const r = t[t.length - 1];
9623
- if (!(!(r instanceof Uint8Array) || Is(r) || Pl(r) || !et(r))) return r;
9623
+ if (!(!(r instanceof Uint8Array) || vs(r) || Pl(r) || !et(r))) return r;
9624
9624
  }
9625
9625
  redeemFromFinalWitnessScript(e) {
9626
9626
  if (!e) return;
9627
- const t = vs(e), r = t[t.length - 1];
9628
- if (!(!r || Is(r) || !et(r))) return r;
9627
+ const t = Es(e), r = t[t.length - 1];
9628
+ if (!(!r || vs(r) || !et(r))) return r;
9629
9629
  }
9630
9630
  finalizeAndComputeAmounts(e, t, r, n, i) {
9631
9631
  let o = 0n;
9632
9632
  e.forEach((d, w) => {
9633
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;
9634
+ if (r && d.finalScriptSig && (b.script = d.finalScriptSig), r && d.finalScriptWitness && (b.witness = Es(d.finalScriptWitness)), d.witnessUtxo) o += d.witnessUtxo.value;
9635
9635
  else if (d.nonWitnessUtxo) {
9636
9636
  if (!i) throw new Error("txFromBuffer is required for nonWitnessUtxo inputs");
9637
9637
  const m = this.getNonWitnessUtxoTx(d, w, i), v = b.index, I = m.outs[v];
@@ -9663,7 +9663,7 @@ var xl = class {
9663
9663
  }
9664
9664
  getPrevoutTaprootKey(e, t, r) {
9665
9665
  const { script: n } = this.getScriptAndAmountFromUtxo(e, t, r);
9666
- return ci(n) ? n.subarray(2, 34) : null;
9666
+ return ui(n) ? n.subarray(2, 34) : null;
9667
9667
  }
9668
9668
  }, Bl = class {
9669
9669
  #t;
@@ -9680,7 +9680,7 @@ var xl = class {
9680
9680
  }
9681
9681
  getHashForSig(e, t, r, n) {
9682
9682
  const i = this.#t.tx, o = t.sighashType || J.SIGHASH_ALL;
9683
- As(o, n);
9683
+ Is(o, n);
9684
9684
  let a, f;
9685
9685
  if (t.nonWitnessUtxo) {
9686
9686
  const d = this.#t.getNonWitnessUtxoTx(t, e, this.#a), w = i.ins[e], b = w.hash;
@@ -9713,7 +9713,7 @@ PROCEED WITH CAUTION!
9713
9713
  }
9714
9714
  getTaprootHashesForSig(e, t, r, n, i, o) {
9715
9715
  const a = this.#t.tx, f = t.sighashType || J.SIGHASH_DEFAULT;
9716
- if (As(f, o), !this.#t.prevOuts) {
9716
+ if (Is(f, o), !this.#t.prevOuts) {
9717
9717
  const b = r.map((m, v) => this.#t.getScriptAndAmountFromUtxo(v, m, this.#a));
9718
9718
  this.#t.prevOuts = b, this.#t.signingScripts = b.map((m) => m.script), this.#t.values = b.map((m) => m.value);
9719
9719
  }
@@ -9780,7 +9780,7 @@ PROCEED WITH CAUTION!
9780
9780
  };
9781
9781
  }
9782
9782
  };
9783
- function As(e, t) {
9783
+ function Is(e, t) {
9784
9784
  if (t && !t.includes(e)) {
9785
9785
  const r = Ul(e);
9786
9786
  throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`);
@@ -9793,7 +9793,7 @@ var _l = class {
9793
9793
  this.#t = e, this.#a = t;
9794
9794
  }
9795
9795
  getFinalScripts(e, t, r, n, i, o, a = !0, f) {
9796
- const l = bi(r);
9796
+ const l = gi(r);
9797
9797
  if (!la(t, r, l) && a) throw new Error(`Can not finalize input #${e}`);
9798
9798
  if (!t.partialSig) throw new Error("Input missing partial signatures");
9799
9799
  return ca(r, l, t.partialSig, n, i, o, f);
@@ -9803,7 +9803,7 @@ var _l = class {
9803
9803
  }
9804
9804
  };
9805
9805
  function Rl(e, t, r, n, i, o, a = !0, f) {
9806
- const l = bi(r);
9806
+ const l = gi(r);
9807
9807
  if (!la(t, r, l) && a) throw new Error(`Can not finalize input #${e}`);
9808
9808
  if (!t.partialSig) throw new Error("Input missing partial signatures");
9809
9809
  return ca(r, l, t.partialSig, n, i, o, f);
@@ -9821,11 +9821,11 @@ function la(e, t, r) {
9821
9821
  case "pubkey":
9822
9822
  case "pubkeyhash":
9823
9823
  case "witnesspubkeyhash":
9824
- return Ss(1, e.partialSig);
9824
+ return As(1, e.partialSig);
9825
9825
  case "multisig": {
9826
9826
  const n = yr({ output: t });
9827
9827
  if (n.m === void 0) throw new Error("Cannot determine m for multisig");
9828
- return Ss(n.m, e.partialSig, n.pubkeys);
9828
+ return As(n.m, e.partialSig, n.pubkeys);
9829
9829
  }
9830
9830
  case "nonstandard":
9831
9831
  return !0;
@@ -9833,7 +9833,7 @@ function la(e, t, r) {
9833
9833
  return !1;
9834
9834
  }
9835
9835
  }
9836
- function Ss(e, t, r) {
9836
+ function As(e, t, r) {
9837
9837
  if (!t) return !1;
9838
9838
  let n;
9839
9839
  if (r ? n = r.map((i) => {
@@ -9852,7 +9852,7 @@ function Nl(e, t, r) {
9852
9852
  });
9853
9853
  case "pubkey": {
9854
9854
  const i = r[0];
9855
- return fi({
9855
+ return hi({
9856
9856
  output: n,
9857
9857
  signature: i.signature
9858
9858
  });
@@ -9914,7 +9914,7 @@ var Ll = new Uint8Array([
9914
9914
  }
9915
9915
  addInput(e) {
9916
9916
  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;
9917
+ const t = typeof e.hash == "string" ? zn(Mt(e.hash)) : e.hash;
9918
9918
  this.tx.addInput(t, e.index, e.sequence);
9919
9919
  }
9920
9920
  addOutput(e) {
@@ -9934,8 +9934,8 @@ function jt(e) {
9934
9934
  function $l(e, t, r, n, i, o, a = !0, f) {
9935
9935
  return Rl(e, t, r, n, i, o, a, f);
9936
9936
  }
9937
- var Zl = class Fn {
9938
- constructor(t = {}, r = new bs(new pa())) {
9937
+ var Zl = class Mn {
9938
+ constructor(t = {}, r = new ys(new pa())) {
9939
9939
  this.data = r, this.#s = Object.assign({}, Vl, t);
9940
9940
  const n = this.data.globalMap.unsignedTx.tx;
9941
9941
  this.#t = new xl(n), t.version === 3 ? this.setVersionTRUC() : this.data.inputs.length === 0 && this.setVersion(2);
@@ -9961,7 +9961,7 @@ var Zl = class Fn {
9961
9961
  }
9962
9962
  get txInputs() {
9963
9963
  return this.#t.tx.ins.map((t) => ({
9964
- hash: Si(t.hash),
9964
+ hash: Ii(t.hash),
9965
9965
  index: t.index,
9966
9966
  sequence: t.sequence
9967
9967
  }));
@@ -9974,7 +9974,7 @@ var Zl = class Fn {
9974
9974
  } catch {
9975
9975
  }
9976
9976
  return {
9977
- script: Si(t.script),
9977
+ script: Ii(t.script),
9978
9978
  value: t.value,
9979
9979
  address: r
9980
9980
  };
@@ -9995,7 +9995,7 @@ var Zl = class Fn {
9995
9995
  return this.fromBuffer(n, r);
9996
9996
  }
9997
9997
  static fromBuffer(t, r = {}) {
9998
- const n = new Fn(r, bs.fromBuffer(t, Cl));
9998
+ const n = new Mn(r, ys.fromBuffer(t, Cl));
9999
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;
10000
10000
  }
10001
10001
  combine(...t) {
@@ -10003,7 +10003,7 @@ var Zl = class Fn {
10003
10003
  }
10004
10004
  clone() {
10005
10005
  const t = structuredClone(this.#s);
10006
- return Fn.fromBuffer(new Uint8Array(this.data.toBuffer()), t);
10006
+ return Mn.fromBuffer(new Uint8Array(this.data.toBuffer()), t);
10007
10007
  }
10008
10008
  get maximumFeeRate() {
10009
10009
  return this.#s.maximumFeeRate;
@@ -10029,7 +10029,7 @@ var Zl = class Fn {
10029
10029
  }
10030
10030
  addInput(t, r = !0) {
10031
10031
  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);
10032
+ fs(t, t, "addInput"), r && Xe(this.data.inputs, "addInput", this.#t.hasSignatures), t.witnessScript && Yr(t.witnessScript);
10033
10033
  const n = t.witnessUtxo ? {
10034
10034
  ...t,
10035
10035
  witnessUtxo: {
@@ -10053,10 +10053,10 @@ var Zl = class Fn {
10053
10053
  const { address: o } = t, { network: a } = this.#s, f = Yo(o, a);
10054
10054
  t = Object.assign({}, t, { script: f });
10055
10055
  }
10056
- return ls(t, t, "addOutput"), this.data.addOutput(t), this.#t.invalidate("outputs"), this;
10056
+ return cs(t, t, "addOutput"), this.data.addOutput(t), this.#t.invalidate("outputs"), this;
10057
10057
  }
10058
10058
  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");
10059
+ if (r && (this.data.inputs = this.data.inputs.filter((i) => !i.partialSig)), !this.data.inputs.every(Dn)) throw new Error("Not finalized");
10060
10060
  if (t || (this.#t.computeFeeRate(this.data.inputs, r, jt), this.#t.checkFees(this.#s)), this.#t.extractedTx) return this.#t.extractedTx;
10061
10061
  const n = this.#t.tx.clone();
10062
10062
  return this.#t.finalizeAndComputeAmounts(this.data.inputs, n, !0, r, jt), n;
@@ -10074,14 +10074,14 @@ var Zl = class Fn {
10074
10074
  const i = mt(this.data.inputs, t);
10075
10075
  return Lt(i) ? this.#o(t, i, void 0, r) : this.#i(t, i, r, n ?? !0);
10076
10076
  }
10077
- finalizeTaprootInput(t, r, n = fs) {
10077
+ finalizeTaprootInput(t, r, n = us) {
10078
10078
  const i = mt(this.data.inputs, t);
10079
10079
  if (Lt(i)) return this.#o(t, i, r, n);
10080
10080
  throw new Error(`Cannot finalize input #${t}. Not Taproot.`);
10081
10081
  }
10082
10082
  getInputType(t) {
10083
10083
  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);
10084
+ return (n.type === "raw" ? "" : n.type + "-") + gi(n.meaningfulScript);
10085
10085
  }
10086
10086
  inputHasPubkey(t, r) {
10087
10087
  const n = mt(this.data.inputs, t);
@@ -10192,7 +10192,7 @@ var Zl = class Fn {
10192
10192
  return this.data.updateGlobal(t), this;
10193
10193
  }
10194
10194
  updateInput(t, r) {
10195
- r.witnessScript && Yr(r.witnessScript), cs(this.data.inputs[t], r, "updateInput");
10195
+ r.witnessScript && Yr(r.witnessScript), fs(this.data.inputs[t], r, "updateInput");
10196
10196
  const n = r.witnessUtxo ? {
10197
10197
  ...r,
10198
10198
  witnessUtxo: {
@@ -10204,7 +10204,7 @@ var Zl = class Fn {
10204
10204
  }
10205
10205
  updateOutput(t, r) {
10206
10206
  const n = this.data.outputs[t];
10207
- return ls(n, r, "updateOutput"), this.data.updateOutput(t, r), this;
10207
+ return cs(n, r, "updateOutput"), this.data.updateOutput(t, r), this;
10208
10208
  }
10209
10209
  addUnknownKeyValToGlobal(t) {
10210
10210
  return this.data.addUnknownKeyValToGlobal(t), this;
@@ -10232,9 +10232,9 @@ var Zl = class Fn {
10232
10232
  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
10233
  return this.data.clearFinalizedInput(t), this;
10234
10234
  }
10235
- #o(t, r, n, i = fs) {
10235
+ #o(t, r, n, i = us) {
10236
10236
  if (!r.witnessUtxo) throw new Error(`Cannot finalize input #${t}. Missing witness utxo.`);
10237
- if (r.tapKeySig && !Cn(r)) {
10237
+ if (r.tapKeySig && !Ln(r)) {
10238
10238
  const o = wr({
10239
10239
  output: r.witnessUtxo.script,
10240
10240
  signature: r.tapKeySig
@@ -10354,10 +10354,10 @@ export {
10354
10354
  Wl as O,
10355
10355
  Ku as P,
10356
10356
  Yt as R,
10357
- ci as S,
10358
- li as T,
10357
+ ui as S,
10358
+ fi as T,
10359
10359
  j as V,
10360
- us as _,
10360
+ hs as _,
10361
10361
  $l as a,
10362
10362
  va as b,
10363
10363
  Wo as c,
@@ -10372,7 +10372,7 @@ export {
10372
10372
  De as m,
10373
10373
  Pf as n,
10374
10374
  Tf as o,
10375
- _n as p,
10375
+ Bn as p,
10376
10376
  qo as r,
10377
10377
  Ql as s,
10378
10378
  Zl as t,