@btc-vision/transaction 1.8.0-alpha.2 → 1.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { d as I, B as h, a as U, t as c, i as Ut, b as Kn, e as Br, c as kt, v as Se, p as qe, u as N } from "./vendors.js";
1
+ import { d as I, B as h, a as U, t as c, i as Ut, b as Kn, e as Cr, c as kt, v as Se, p as $e, u as N } from "./vendors.js";
2
2
  const M = {
3
3
  messagePrefix: `Bitcoin Signed Message:
4
4
  `,
@@ -11,7 +11,7 @@ const M = {
11
11
  pubKeyHash: 0,
12
12
  scriptHash: 5,
13
13
  wif: 128
14
- }, so = {
14
+ }, Ji = {
15
15
  messagePrefix: `Bitcoin Signed Message:
16
16
  `,
17
17
  bech32: "bcrt",
@@ -23,7 +23,7 @@ const M = {
23
23
  pubKeyHash: 111,
24
24
  scriptHash: 196,
25
25
  wif: 239
26
- }, io = {
26
+ }, to = {
27
27
  messagePrefix: `Bitcoin Signed Message:
28
28
  `,
29
29
  bech32: "tb",
@@ -36,7 +36,7 @@ const M = {
36
36
  scriptHash: 196,
37
37
  wif: 239
38
38
  };
39
- function Be(t) {
39
+ function Ce(t) {
40
40
  let e, r;
41
41
  try {
42
42
  e = I.bech32.decode(t);
@@ -240,16 +240,16 @@ const E = {
240
240
  OP_PUBKEYHASH: 253,
241
241
  OP_PUBKEY: 254,
242
242
  OP_INVALIDOPCODE: 255
243
- }, Rr = {};
243
+ }, Br = {};
244
244
  for (const t of Object.keys(E)) {
245
245
  const e = E[t];
246
- Rr[e] = t;
246
+ Br[e] = t;
247
247
  }
248
- function Fr(t) {
248
+ function Rr(t) {
249
249
  return t < E.OP_PUSHDATA1 ? 1 : t <= 255 ? 2 : t <= 65535 ? 3 : 5;
250
250
  }
251
251
  function qn(t, e, r) {
252
- const n = Fr(e);
252
+ const n = Rr(e);
253
253
  return n === 1 ? t.writeUInt8(e, r) : n === 2 ? (t.writeUInt8(E.OP_PUSHDATA1, r), t.writeUInt8(e, r + 1)) : n === 3 ? (t.writeUInt8(E.OP_PUSHDATA2, r), t.writeUInt16LE(e, r + 1)) : (t.writeUInt8(E.OP_PUSHDATA4, r), t.writeUInt32LE(e, r + 1)), n;
254
254
  }
255
255
  function Xn(t, e) {
@@ -299,7 +299,7 @@ function jn(t, e, r) {
299
299
  function zn(t) {
300
300
  return t > 2147483647 ? 5 : t > 8388607 ? 4 : t > 32767 ? 3 : t > 127 ? 2 : t > 0 ? 1 : 0;
301
301
  }
302
- function Lr(t) {
302
+ function Fr(t) {
303
303
  let e = Math.abs(t);
304
304
  const r = zn(e), n = h.allocUnsafe(r), s = t < 0;
305
305
  for (let i = 0; i < r; ++i)
@@ -309,8 +309,8 @@ function Lr(t) {
309
309
  const Yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
310
310
  __proto__: null,
311
311
  decode: jn,
312
- encode: Lr
313
- }, Symbol.toStringTag, { value: "Module" })), Xe = U.alloc(32, 0), je = U.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", "hex");
312
+ encode: Fr
313
+ }, Symbol.toStringTag, { value: "Module" })), qe = U.alloc(32, 0), Xe = U.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", "hex");
314
314
  function at(t, e) {
315
315
  return t.length !== e.length ? !1 : t.every((r, n) => r.equals(e[n]));
316
316
  }
@@ -318,14 +318,14 @@ function W(t) {
318
318
  if (!U.isBuffer(t) || t.length < 33)
319
319
  return !1;
320
320
  const e = t[0], r = t.subarray(1, 33);
321
- if (r.compare(Xe) === 0 || r.compare(je) >= 0)
321
+ if (r.compare(qe) === 0 || r.compare(Xe) >= 0)
322
322
  return !1;
323
323
  if ((e === 2 || e === 3) && t.length === 33)
324
324
  return !0;
325
325
  if (t.length !== 65)
326
326
  return !1;
327
327
  const n = t.subarray(33);
328
- return n.compare(Xe) === 0 || n.compare(je) >= 0 ? !1 : e === 4 || e === 6 || e === 7;
328
+ return n.compare(qe) === 0 || n.compare(Xe) >= 0 ? !1 : e === 4 || e === 6 || e === 7;
329
329
  }
330
330
  const Zn = 21 * 1e14;
331
331
  function qt(t) {
@@ -338,111 +338,114 @@ function ne(t) {
338
338
  const e = t;
339
339
  return U.isBuffer(e.output) ? e.version !== void 0 ? (e.version & Pt) === e.version : !0 : !1;
340
340
  }
341
- function Re(t) {
342
- return globalThis.Array.isArray(t) ? t.length !== 2 ? !1 : t.every((e) => Re(e)) : ne(t);
343
- }
344
- const Qn = c.BufferN(32), Jn = c.BufferN(20), _e = c.BufferN(32), It = c.Number, se = c.Array, ts = c.Boolean, Vr = c.String, V = c.Buffer, Wr = c.Hex, Te = c.maybe, z = c.tuple, Gr = c.UInt8, Y = c.UInt32, es = c.Function, Kr = c.BufferN, Mr = c.Null, rs = c.oneOf, ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
341
+ function Be(t) {
342
+ return globalThis.Array.isArray(t) ? t.length !== 2 ? !1 : t.every((e) => Be(e)) : ne(t);
343
+ }
344
+ c.BufferN(32);
345
+ c.BufferN(20);
346
+ const _e = c.BufferN(32), It = c.Number, se = c.Array;
347
+ c.Boolean;
348
+ const Lr = c.String, V = c.Buffer, Vr = c.Hex, Te = c.maybe, z = c.tuple, Wr = c.UInt8, Y = c.UInt32;
349
+ c.Function;
350
+ const Gr = c.BufferN, Kr = c.Null;
351
+ c.oneOf;
352
+ const ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
345
353
  __proto__: null,
346
354
  Array: se,
347
- Boolean: ts,
348
355
  Buffer: V,
349
- Buffer256bit: Qn,
350
- BufferN: Kr,
351
- Function: es,
352
- Hash160bit: Jn,
356
+ BufferN: Gr,
353
357
  Hash256bit: _e,
354
- Hex: Wr,
355
- Null: Mr,
358
+ Hex: Vr,
359
+ Null: Kr,
356
360
  Number: It,
357
361
  Satoshi: qt,
358
- String: Vr,
362
+ String: Lr,
359
363
  TAPLEAF_VERSION_MASK: Pt,
360
364
  UInt32: Y,
361
- UInt8: Gr,
365
+ UInt8: Wr,
362
366
  isPoint: W,
363
367
  isTapleaf: ne,
364
- isTaptree: Re,
368
+ isTaptree: Be,
365
369
  maybe: Te,
366
- oneOf: rs,
367
370
  stacksEqual: at,
368
371
  tuple: z,
369
372
  typeforce: c
370
- }, Symbol.toStringTag, { value: "Module" })), { typeforce: ns } = ie, ze = h.alloc(1, 0);
373
+ }, Symbol.toStringTag, { value: "Module" })), { typeforce: Qn } = ie, je = h.alloc(1, 0);
371
374
  function oe(t) {
372
375
  const e = t & -129;
373
376
  return e > 0 && e < 4;
374
377
  }
375
- function Ye(t) {
378
+ function ze(t) {
376
379
  let e = 0;
377
380
  for (; t[e] === 0; )
378
381
  ++e;
379
- return e === t.length ? ze : (t = t.subarray(e), t[0] & 128 ? h.concat([ze, t], 1 + t.length) : t);
382
+ return e === t.length ? je : (t = t.subarray(e), t[0] & 128 ? h.concat([je, t], 1 + t.length) : t);
380
383
  }
381
- function Ze(t) {
384
+ function Ye(t) {
382
385
  t[0] === 0 && (t = t.subarray(1));
383
386
  const e = h.alloc(32, 0), r = Math.max(0, 32 - t.length);
384
387
  return t.copy(e, r), e;
385
388
  }
386
- function ss(t) {
389
+ function Jn(t) {
387
390
  const e = t.readUInt8(t.length - 1);
388
391
  if (!oe(e))
389
392
  throw new Error(`Invalid hashType ${e}`);
390
- const r = Dn(t.subarray(0, -1)), n = Ze(r.r), s = Ze(r.s);
393
+ const r = Dn(t.subarray(0, -1)), n = Ye(r.r), s = Ye(r.s);
391
394
  return { signature: h.concat([n, s], 64), hashType: e };
392
395
  }
393
- function is(t, e) {
394
- if (ns({
395
- signature: Kr(64),
396
- hashType: Gr
396
+ function ts(t, e) {
397
+ if (Qn({
398
+ signature: Gr(64),
399
+ hashType: Wr
397
400
  }, { signature: t, hashType: e }), !oe(e))
398
401
  throw new Error(`Invalid hashType ${e}`);
399
402
  const r = h.allocUnsafe(1);
400
403
  r.writeUInt8(e, 0);
401
- const n = Ye(t.subarray(0, 32)), s = Ye(t.subarray(32, 64));
404
+ const n = ze(t.subarray(0, 32)), s = ze(t.subarray(32, 64));
402
405
  return h.concat([$n(n, s), r]);
403
406
  }
404
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
407
+ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
405
408
  __proto__: null,
406
- decode: ss,
407
- encode: is,
409
+ decode: Jn,
410
+ encode: ts,
408
411
  isDefinedHashType: oe
409
- }, Symbol.toStringTag, { value: "Module" })), { typeforce: Nt } = ie, Dr = E.OP_RESERVED;
410
- function us(t) {
412
+ }, Symbol.toStringTag, { value: "Module" })), { typeforce: Nt } = ie, Mr = E.OP_RESERVED;
413
+ function rs(t) {
411
414
  return It(t) && (t === E.OP_0 || t >= E.OP_1 && t <= E.OP_16 || t === E.OP_1NEGATE);
412
415
  }
413
- function $r(t) {
414
- return V(t) || us(t);
416
+ function Dr(t) {
417
+ return V(t) || rs(t);
415
418
  }
416
419
  function ue(t) {
417
- return se(t) && t.every($r);
420
+ return se(t) && t.every(Dr);
418
421
  }
419
- function Fe(t) {
420
- return t.length - t.filter($r).length;
422
+ function Re(t) {
423
+ return t.length - t.filter(Dr).length;
421
424
  }
422
425
  function zt(t) {
423
426
  if (t.length === 0)
424
427
  return E.OP_0;
425
428
  if (t.length === 1) {
426
429
  if (t[0] >= 1 && t[0] <= 16)
427
- return Dr + t[0];
430
+ return Mr + t[0];
428
431
  if (t[0] === 129)
429
432
  return E.OP_1NEGATE;
430
433
  }
431
434
  }
432
- function qr(t) {
435
+ function $r(t) {
433
436
  return h.isBuffer(t);
434
437
  }
435
- function fs(t) {
438
+ function ns(t) {
436
439
  return se(t);
437
440
  }
438
441
  function Yt(t) {
439
442
  return h.isBuffer(t);
440
443
  }
441
444
  function v(t) {
442
- if (qr(t))
445
+ if ($r(t))
443
446
  return t;
444
447
  Nt(se, t);
445
- const e = t.reduce((s, i) => Yt(i) ? i.length === 1 && zt(i) !== void 0 ? s + 1 : s + Fr(i.length) + i.length : s + 1, 0), r = h.allocUnsafe(e);
448
+ const e = t.reduce((s, i) => Yt(i) ? i.length === 1 && zt(i) !== void 0 ? s + 1 : s + Rr(i.length) + i.length : s + 1, 0), r = h.allocUnsafe(e);
446
449
  let n = 0;
447
450
  if (t.forEach((s) => {
448
451
  if (Yt(s)) {
@@ -459,7 +462,7 @@ function v(t) {
459
462
  return r;
460
463
  }
461
464
  function A(t) {
462
- if (fs(t))
465
+ if (ns(t))
463
466
  return t;
464
467
  Nt(V, t);
465
468
  const e = [];
@@ -479,8 +482,8 @@ function A(t) {
479
482
  }
480
483
  return e;
481
484
  }
482
- function Xr(t) {
483
- if (qr(t) && (t = A(t)), !t)
485
+ function qr(t) {
486
+ if ($r(t) && (t = A(t)), !t)
484
487
  throw new Error("Could not convert invalid chunks to ASM");
485
488
  return t.map((e) => {
486
489
  if (Yt(e)) {
@@ -489,35 +492,35 @@ function Xr(t) {
489
492
  return e.toString("hex");
490
493
  e = r;
491
494
  }
492
- return Rr[e];
495
+ return Br[e];
493
496
  }).join(" ");
494
497
  }
495
- function cs(t) {
496
- return Nt(Vr, t), v(t.split(" ").map((e) => E[e] !== void 0 ? E[e] : (Nt(Wr, e), h.from(e, "hex"))));
498
+ function ss(t) {
499
+ return Nt(Lr, t), v(t.split(" ").map((e) => E[e] !== void 0 ? E[e] : (Nt(Vr, e), h.from(e, "hex"))));
497
500
  }
498
- function jr(t) {
499
- return t = A(t), Nt(ue, t), t.map((e) => Yt(e) ? e : e === E.OP_0 ? h.allocUnsafe(0) : Lr(e - Dr));
501
+ function Xr(t) {
502
+ return t = A(t), Nt(ue, t), t.map((e) => Yt(e) ? e : e === E.OP_0 ? h.allocUnsafe(0) : Fr(e - Mr));
500
503
  }
501
- function zr(t) {
504
+ function jr(t) {
502
505
  return W(t);
503
506
  }
504
507
  function Q(t) {
505
508
  return !h.isBuffer(t) || !oe(t[t.length - 1]) ? !1 : Mn(t.subarray(0, -1));
506
509
  }
507
- const as = Yn, dt = os, hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
510
+ const is = Yn, dt = es, os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
508
511
  __proto__: null,
509
512
  compile: v,
510
- countNonPushOnlyOPs: Fe,
513
+ countNonPushOnlyOPs: Re,
511
514
  decompile: A,
512
- fromASM: cs,
513
- isCanonicalPubKey: zr,
515
+ fromASM: ss,
516
+ isCanonicalPubKey: jr,
514
517
  isCanonicalScriptSignature: Q,
515
518
  isPushOnly: ue,
516
- number: as,
519
+ number: is,
517
520
  opcodes: E,
518
521
  signature: dt,
519
- toASM: Xr,
520
- toStack: jr
522
+ toASM: qr,
523
+ toStack: Xr
521
524
  }, Symbol.toStringTag, { value: "Module" }));
522
525
  var K;
523
526
  (function(t) {
@@ -545,8 +548,8 @@ function B(t) {
545
548
  let e;
546
549
  return () => (e !== void 0 || (e = t()), e);
547
550
  }
548
- const Qe = E, Je = 16, tr = 2, er = 40;
549
- function Yr(t, e) {
551
+ const Ze = E, Qe = 16, Je = 2, tr = 40;
552
+ function zr(t, e) {
550
553
  if (!t.address && !t.output && !t.program && (typeof t.deploymentVersion > "u" || !t.hash160))
551
554
  throw new TypeError("At least one of address, output or program must be provided");
552
555
  e = Object.assign({ validate: !0 }, e || {}), c({
@@ -565,7 +568,7 @@ function Yr(t, e) {
565
568
  throw new TypeError("deploymentVersion must fit in one byte");
566
569
  return h.concat([h.of(t.deploymentVersion), t.hash160]);
567
570
  }
568
- }, n = B(() => Be(t.address)), s = t.network || M, i = {
571
+ }, n = B(() => Ce(t.address)), s = t.network || M, i = {
569
572
  name: K.P2OP,
570
573
  network: s,
571
574
  deploymentVersion: 0
@@ -577,7 +580,7 @@ function Yr(t, e) {
577
580
  if (o)
578
581
  return o;
579
582
  if (t.output) {
580
- if (t.output[0] !== Qe.OP_16)
583
+ if (t.output[0] !== Ze.OP_16)
581
584
  throw new TypeError("Invalid P2OP script");
582
585
  let u = 1, f;
583
586
  if (t.output[1] < 76)
@@ -598,23 +601,23 @@ function Yr(t, e) {
598
601
  return i.program.subarray(1);
599
602
  }), y(i, "output", () => {
600
603
  if (i.program)
601
- return v([Qe.OP_16, i.program]);
604
+ return v([Ze.OP_16, i.program]);
602
605
  }), y(i, "address", () => {
603
606
  if (!i.program)
604
607
  return;
605
608
  if (!s.bech32Opnet)
606
609
  throw new TypeError("Network does not support opnet");
607
610
  const o = I.bech32m.toWords(i.program);
608
- return o.unshift(Je), I.bech32m.encode(s.bech32Opnet, o);
611
+ return o.unshift(Qe), I.bech32m.encode(s.bech32Opnet, o);
609
612
  }), e.validate) {
610
613
  let o = U.alloc(0);
611
614
  if (t.address) {
612
615
  const u = n();
613
616
  if (s.bech32Opnet !== u.prefix)
614
617
  throw new TypeError("Invalid prefix or network mismatch");
615
- if (u.version !== Je)
618
+ if (u.version !== Qe)
616
619
  throw new TypeError("Invalid witness version for p2op");
617
- if (u.data.length < tr || u.data.length > er)
620
+ if (u.data.length < Je || u.data.length > tr)
618
621
  throw new TypeError("Invalid witness program length");
619
622
  o = u.data;
620
623
  }
@@ -629,7 +632,7 @@ function Yr(t, e) {
629
632
  throw new TypeError("Program mismatch (output vs other source)");
630
633
  o = u;
631
634
  }
632
- if (o.length < tr || o.length > er)
635
+ if (o.length < Je || o.length > tr)
633
636
  throw new TypeError(`Witness program must be 2–40 bytes. Was ${o.length} bytes`);
634
637
  if (t.deploymentVersion !== void 0 && t.deploymentVersion !== o[0])
635
638
  throw new TypeError("deploymentVersion mismatch");
@@ -638,25 +641,25 @@ function Yr(t, e) {
638
641
  }
639
642
  return Object.assign(i, t);
640
643
  }
641
- function ps(t) {
644
+ function us(t) {
642
645
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
643
646
  }
644
- function Zr(t, e, r = "") {
645
- const n = ps(t), s = t?.length;
647
+ function Yr(t, e, r = "") {
648
+ const n = us(t), s = t?.length;
646
649
  if (!n || e !== void 0) {
647
650
  const o = r && `"${r}" `, u = "", f = n ? `length=${s}` : `type=${typeof t}`;
648
651
  throw new Error(o + "expected Uint8Array" + u + ", got " + f);
649
652
  }
650
653
  return t;
651
654
  }
652
- function rr(t, e = !0) {
655
+ function er(t, e = !0) {
653
656
  if (t.destroyed)
654
657
  throw new Error("Hash instance has been destroyed");
655
658
  if (e && t.finished)
656
659
  throw new Error("Hash#digest() has already been called");
657
660
  }
658
- function ls(t, e) {
659
- Zr(t, void 0, "digestInto() output");
661
+ function fs(t, e) {
662
+ Yr(t, void 0, "digestInto() output");
660
663
  const r = e.outputLen;
661
664
  if (t.length < r)
662
665
  throw new Error('"digestInto() output" expected to be of length >=' + r);
@@ -674,20 +677,20 @@ function q(t, e) {
674
677
  function ft(t, e) {
675
678
  return t << e | t >>> 32 - e >>> 0;
676
679
  }
677
- function Le(t, e = {}) {
680
+ function Fe(t, e = {}) {
678
681
  const r = (s, i) => t(i).update(s).digest(), n = t(void 0);
679
682
  return r.outputLen = n.outputLen, r.blockLen = n.blockLen, r.create = (s) => t(s), Object.assign(r, e), Object.freeze(r);
680
683
  }
681
- const ds = (t) => ({
684
+ const cs = (t) => ({
682
685
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, t])
683
686
  });
684
- function Qr(t, e, r) {
687
+ function Zr(t, e, r) {
685
688
  return t & e ^ ~t & r;
686
689
  }
687
- function Jr(t, e, r) {
690
+ function Qr(t, e, r) {
688
691
  return t & e ^ t & r ^ e & r;
689
692
  }
690
- class Ve {
693
+ class Le {
691
694
  blockLen;
692
695
  outputLen;
693
696
  padOffset;
@@ -703,7 +706,7 @@ class Ve {
703
706
  this.blockLen = e, this.outputLen = r, this.padOffset = n, this.isLE = s, this.buffer = new Uint8Array(e), this.view = we(this.buffer);
704
707
  }
705
708
  update(e) {
706
- rr(this), Zr(e);
709
+ er(this), Yr(e);
707
710
  const { view: r, buffer: n, blockLen: s } = this, i = e.length;
708
711
  for (let o = 0; o < i; ) {
709
712
  const u = Math.min(s - this.pos, i - o);
@@ -718,7 +721,7 @@ class Ve {
718
721
  return this.length += e.length, this.roundClean(), this;
719
722
  }
720
723
  digestInto(e) {
721
- rr(this), ls(e, this), this.finished = !0;
724
+ er(this), fs(e, this), this.finished = !0;
722
725
  const { buffer: r, view: n, blockLen: s, isLE: i } = this;
723
726
  let { pos: o } = this;
724
727
  r[o++] = 128, ht(this.buffer.subarray(o)), this.padOffset > s - o && (this.process(n, 0), o = 0);
@@ -765,7 +768,7 @@ const et = /* @__PURE__ */ Uint32Array.from([
765
768
  271733878,
766
769
  3285377520
767
770
  ]), rt = /* @__PURE__ */ new Uint32Array(80);
768
- class ws extends Ve {
771
+ class as extends Le {
769
772
  A = St[0] | 0;
770
773
  B = St[1] | 0;
771
774
  C = St[2] | 0;
@@ -789,7 +792,7 @@ class ws extends Ve {
789
792
  let { A: n, B: s, C: i, D: o, E: u } = this;
790
793
  for (let f = 0; f < 80; f++) {
791
794
  let a, p;
792
- f < 20 ? (a = Qr(s, i, o), p = 1518500249) : f < 40 ? (a = s ^ i ^ o, p = 1859775393) : f < 60 ? (a = Jr(s, i, o), p = 2400959708) : (a = s ^ i ^ o, p = 3395469782);
795
+ f < 20 ? (a = Zr(s, i, o), p = 1518500249) : f < 40 ? (a = s ^ i ^ o, p = 1859775393) : f < 60 ? (a = Qr(s, i, o), p = 2400959708) : (a = s ^ i ^ o, p = 3395469782);
793
796
  const l = ft(n, 5) + a + u + p + rt[f] | 0;
794
797
  u = o, o = i, i = ft(s, 30), s = n, n = l;
795
798
  }
@@ -802,7 +805,7 @@ class ws extends Ve {
802
805
  this.set(0, 0, 0, 0, 0), ht(this.buffer);
803
806
  }
804
807
  }
805
- const gs = /* @__PURE__ */ Le(() => new ws()), ys = /* @__PURE__ */ Uint8Array.from([
808
+ const hs = /* @__PURE__ */ Fe(() => new as()), ps = /* @__PURE__ */ Uint8Array.from([
806
809
  7,
807
810
  4,
808
811
  13,
@@ -819,36 +822,36 @@ const gs = /* @__PURE__ */ Le(() => new ws()), ys = /* @__PURE__ */ Uint8Array.f
819
822
  14,
820
823
  11,
821
824
  8
822
- ]), tn = Uint8Array.from(new Array(16).fill(0).map((t, e) => e)), ms = tn.map((t) => (9 * t + 5) % 16), en = /* @__PURE__ */ (() => {
823
- const r = [[tn], [ms]];
825
+ ]), Jr = Uint8Array.from(new Array(16).fill(0).map((t, e) => e)), ls = Jr.map((t) => (9 * t + 5) % 16), tn = /* @__PURE__ */ (() => {
826
+ const r = [[Jr], [ls]];
824
827
  for (let n = 0; n < 4; n++)
825
828
  for (let s of r)
826
- s.push(s[n].map((i) => ys[i]));
829
+ s.push(s[n].map((i) => ps[i]));
827
830
  return r;
828
- })(), rn = en[0], nn = en[1], sn = /* @__PURE__ */ [
831
+ })(), en = tn[0], rn = tn[1], nn = /* @__PURE__ */ [
829
832
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
830
833
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
831
834
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
832
835
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
833
836
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
834
- ].map((t) => Uint8Array.from(t)), bs = /* @__PURE__ */ rn.map((t, e) => t.map((r) => sn[e][r])), Es = /* @__PURE__ */ nn.map((t, e) => t.map((r) => sn[e][r])), Ss = /* @__PURE__ */ Uint32Array.from([
837
+ ].map((t) => Uint8Array.from(t)), ds = /* @__PURE__ */ en.map((t, e) => t.map((r) => nn[e][r])), ws = /* @__PURE__ */ rn.map((t, e) => t.map((r) => nn[e][r])), gs = /* @__PURE__ */ Uint32Array.from([
835
838
  0,
836
839
  1518500249,
837
840
  1859775393,
838
841
  2400959708,
839
842
  2840853838
840
- ]), _s = /* @__PURE__ */ Uint32Array.from([
843
+ ]), ys = /* @__PURE__ */ Uint32Array.from([
841
844
  1352829926,
842
845
  1548603684,
843
846
  1836072691,
844
847
  2053994217,
845
848
  0
846
849
  ]);
847
- function nr(t, e, r, n) {
850
+ function rr(t, e, r, n) {
848
851
  return t === 0 ? e ^ r ^ n : t === 1 ? e & r | ~e & n : t === 2 ? (e | ~r) ^ n : t === 3 ? e & n | r & ~n : e ^ (r | ~n);
849
852
  }
850
853
  const Wt = /* @__PURE__ */ new Uint32Array(16);
851
- class Ts extends Ve {
854
+ class ms extends Le {
852
855
  h0 = 1732584193;
853
856
  h1 = -271733879;
854
857
  h2 = -1732584194;
@@ -869,13 +872,13 @@ class Ts extends Ve {
869
872
  Wt[b] = e.getUint32(r, !0);
870
873
  let n = this.h0 | 0, s = n, i = this.h1 | 0, o = i, u = this.h2 | 0, f = u, a = this.h3 | 0, p = a, l = this.h4 | 0, d = l;
871
874
  for (let b = 0; b < 5; b++) {
872
- const w = 4 - b, S = Ss[b], P = _s[b], k = rn[b], H = nn[b], _ = bs[b], O = Es[b];
875
+ const w = 4 - b, S = gs[b], P = ys[b], k = en[b], H = rn[b], _ = ds[b], O = ws[b];
873
876
  for (let T = 0; T < 16; T++) {
874
- const F = ft(n + nr(b, i, u, a) + Wt[k[T]] + S, _[T]) + l | 0;
877
+ const F = ft(n + rr(b, i, u, a) + Wt[k[T]] + S, _[T]) + l | 0;
875
878
  n = l, l = a, a = ft(u, 10) | 0, u = i, i = F;
876
879
  }
877
880
  for (let T = 0; T < 16; T++) {
878
- const F = ft(s + nr(w, o, f, p) + Wt[H[T]] + P, O[T]) + d | 0;
881
+ const F = ft(s + rr(w, o, f, p) + Wt[H[T]] + P, O[T]) + d | 0;
879
882
  s = d, d = p, p = ft(f, 10) | 0, f = o, o = F;
880
883
  }
881
884
  }
@@ -888,7 +891,7 @@ class Ts extends Ve {
888
891
  this.destroyed = !0, ht(this.buffer), this.set(0, 0, 0, 0, 0);
889
892
  }
890
893
  }
891
- const on = /* @__PURE__ */ Le(() => new Ts()), Os = /* @__PURE__ */ Uint32Array.from([
894
+ const sn = /* @__PURE__ */ Fe(() => new ms()), bs = /* @__PURE__ */ Uint32Array.from([
892
895
  1116352408,
893
896
  1899447441,
894
897
  3049323471,
@@ -954,7 +957,7 @@ const on = /* @__PURE__ */ Le(() => new Ts()), Os = /* @__PURE__ */ Uint32Array.
954
957
  3204031479,
955
958
  3329325298
956
959
  ]), nt = /* @__PURE__ */ new Uint32Array(64);
957
- class As extends Ve {
960
+ class Es extends Le {
958
961
  constructor(e) {
959
962
  super(64, e, 8, !1);
960
963
  }
@@ -975,7 +978,7 @@ class As extends Ve {
975
978
  }
976
979
  let { A: n, B: s, C: i, D: o, E: u, F: f, G: a, H: p } = this;
977
980
  for (let l = 0; l < 64; l++) {
978
- const d = q(u, 6) ^ q(u, 11) ^ q(u, 25), b = p + d + Qr(u, f, a) + Os[l] + nt[l] | 0, S = (q(n, 2) ^ q(n, 13) ^ q(n, 22)) + Jr(n, s, i) | 0;
981
+ const d = q(u, 6) ^ q(u, 11) ^ q(u, 25), b = p + d + Zr(u, f, a) + bs[l] + nt[l] | 0, S = (q(n, 2) ^ q(n, 13) ^ q(n, 22)) + Qr(n, s, i) | 0;
979
982
  p = a, a = f, f = u, u = o + b | 0, o = i, i = s, s = n, n = b + S | 0;
980
983
  }
981
984
  n = n + this.A | 0, s = s + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, u = u + this.E | 0, f = f + this.F | 0, a = a + this.G | 0, p = p + this.H | 0, this.set(n, s, i, o, u, f, a, p);
@@ -987,7 +990,7 @@ class As extends Ve {
987
990
  this.set(0, 0, 0, 0, 0, 0, 0, 0), ht(this.buffer);
988
991
  }
989
992
  }
990
- class Ps extends As {
993
+ class Ss extends Es {
991
994
  // We cannot use array here since array allows indexing by variable
992
995
  // which means optimizer/compiler cannot use registers.
993
996
  A = et[0] | 0;
@@ -1002,26 +1005,26 @@ class Ps extends As {
1002
1005
  super(32);
1003
1006
  }
1004
1007
  }
1005
- const Zt = /* @__PURE__ */ Le(
1006
- () => new Ps(),
1007
- /* @__PURE__ */ ds(1)
1008
+ const Zt = /* @__PURE__ */ Fe(
1009
+ () => new Ss(),
1010
+ /* @__PURE__ */ cs(1)
1008
1011
  );
1009
- function Is(t) {
1010
- return h.from(on(Uint8Array.from(t)));
1012
+ function _s(t) {
1013
+ return h.from(sn(Uint8Array.from(t)));
1011
1014
  }
1012
- function Hs(t) {
1013
- return h.from(gs(Uint8Array.from(t)));
1015
+ function Ts(t) {
1016
+ return h.from(hs(Uint8Array.from(t)));
1014
1017
  }
1015
1018
  function D(t) {
1016
1019
  return h.from(Zt(Uint8Array.from(t)));
1017
1020
  }
1018
1021
  function C(t) {
1019
- return h.from(on(Zt(Uint8Array.from(t))));
1022
+ return h.from(sn(Zt(Uint8Array.from(t))));
1020
1023
  }
1021
1024
  function it(t) {
1022
1025
  return h.from(Zt(Zt(Uint8Array.from(t))));
1023
1026
  }
1024
- const vs = [
1027
+ const Os = [
1025
1028
  "BIP0340/challenge",
1026
1029
  "BIP0340/aux",
1027
1030
  "BIP0340/nonce",
@@ -1031,7 +1034,7 @@ const vs = [
1031
1034
  "TapTweak",
1032
1035
  "KeyAgg list",
1033
1036
  "KeyAgg coefficient"
1034
- ], un = {
1037
+ ], on = {
1035
1038
  "BIP0340/challenge": h.from([
1036
1039
  123,
1037
1040
  181,
@@ -1628,59 +1631,59 @@ const vs = [
1628
1631
  ])
1629
1632
  };
1630
1633
  function Rt(t, e) {
1631
- return D(h.concat([un[t], e]));
1634
+ return D(h.concat([on[t], e]));
1632
1635
  }
1633
- const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1636
+ const As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1634
1637
  __proto__: null,
1635
- TAGGED_HASH_PREFIXES: un,
1636
- TAGS: vs,
1638
+ TAGGED_HASH_PREFIXES: on,
1639
+ TAGS: Os,
1637
1640
  hash160: C,
1638
1641
  hash256: it,
1639
- ripemd160: Is,
1640
- sha1: Hs,
1642
+ ripemd160: _s,
1643
+ sha1: Ts,
1641
1644
  sha256: D,
1642
1645
  taggedHash: Rt
1643
1646
  }, Symbol.toStringTag, { value: "Module" }));
1644
- const Us = {
1647
+ const Ps = {
1645
1648
  p: 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,
1646
1649
  n: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
1647
1650
  b: 7n,
1648
1651
  Gx: 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,
1649
1652
  Gy: 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n
1650
- }, { p: ct, n: fn, Gx: ks, Gy: Ns, b: cn } = Us, Xt = 32, Oe = 64, G = (t = "") => {
1653
+ }, { p: ct, n: un, Gx: Is, Gy: Hs, b: fn } = Ps, Xt = 32, Oe = 64, G = (t = "") => {
1651
1654
  throw new Error(t);
1652
- }, an = (t) => typeof t == "bigint", hn = (t) => typeof t == "string", Cs = (t) => t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array", Ct = (t, e) => !Cs(t) || typeof e == "number" && e > 0 && t.length !== e ? G("Uint8Array expected") : t, pn = (t) => new Uint8Array(t), Bs = (t) => Uint8Array.from(t), ln = (t, e) => t.toString(16).padStart(e, "0"), dn = (t) => Array.from(Ct(t)).map((e) => ln(e, 2)).join(""), J = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }, sr = (t) => {
1655
+ }, cn = (t) => typeof t == "bigint", an = (t) => typeof t == "string", vs = (t) => t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array", Ct = (t, e) => !vs(t) || typeof e == "number" && e > 0 && t.length !== e ? G("Uint8Array expected") : t, hn = (t) => new Uint8Array(t), xs = (t) => Uint8Array.from(t), pn = (t, e) => t.toString(16).padStart(e, "0"), ln = (t) => Array.from(Ct(t)).map((e) => pn(e, 2)).join(""), J = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }, nr = (t) => {
1653
1656
  if (t >= J._0 && t <= J._9)
1654
1657
  return t - J._0;
1655
1658
  if (t >= J.A && t <= J.F)
1656
1659
  return t - (J.A - 10);
1657
1660
  if (t >= J.a && t <= J.f)
1658
1661
  return t - (J.a - 10);
1659
- }, wn = (t) => {
1662
+ }, dn = (t) => {
1660
1663
  const e = "hex invalid";
1661
- if (!hn(t))
1664
+ if (!an(t))
1662
1665
  return G(e);
1663
1666
  const r = t.length, n = r / 2;
1664
1667
  if (r % 2)
1665
1668
  return G(e);
1666
- const s = pn(n);
1669
+ const s = hn(n);
1667
1670
  for (let i = 0, o = 0; i < n; i++, o += 2) {
1668
- const u = sr(t.charCodeAt(o)), f = sr(t.charCodeAt(o + 1));
1671
+ const u = nr(t.charCodeAt(o)), f = nr(t.charCodeAt(o + 1));
1669
1672
  if (u === void 0 || f === void 0)
1670
1673
  return G(e);
1671
1674
  s[i] = u * 16 + f;
1672
1675
  }
1673
1676
  return s;
1674
- }, gn = (t, e) => Ct(hn(t) ? wn(t) : Bs(Ct(t)), e), ir = (...t) => {
1675
- const e = pn(t.reduce((n, s) => n + Ct(s).length, 0));
1677
+ }, wn = (t, e) => Ct(an(t) ? dn(t) : xs(Ct(t)), e), sr = (...t) => {
1678
+ const e = hn(t.reduce((n, s) => n + Ct(s).length, 0));
1676
1679
  let r = 0;
1677
1680
  return t.forEach((n) => {
1678
1681
  e.set(n, r), r += n.length;
1679
1682
  }), e;
1680
- }, Qt = BigInt, Ft = (t, e, r, n = "bad number: out of range") => an(t) && e <= t && t < r ? t : G(n), m = (t, e = ct) => {
1683
+ }, Qt = BigInt, Ft = (t, e, r, n = "bad number: out of range") => cn(t) && e <= t && t < r ? t : G(n), m = (t, e = ct) => {
1681
1684
  const r = t % e;
1682
1685
  return r >= 0n ? r : e + r;
1683
- }, Rs = (t, e) => {
1686
+ }, Us = (t, e) => {
1684
1687
  (t === 0n || e <= 0n) && G("no inverse n=" + t + " mod=" + e);
1685
1688
  let r = m(t, e), n = e, s = 0n, i = 1n;
1686
1689
  for (; r !== 0n; ) {
@@ -1688,8 +1691,8 @@ const Us = {
1688
1691
  n = r, r = u, s = i, i = f;
1689
1692
  }
1690
1693
  return n === 1n ? m(s, e) : G("no inverse");
1691
- }, or = (t) => t instanceof R ? t : G("Point expected"), yn = (t) => m(m(t * t) * t + cn), ur = (t) => Ft(t, 0n, ct), jt = (t) => Ft(t, 1n, ct), Fs = (t) => Ft(t, 1n, fn), Ae = (t) => (t & 1n) === 0n, mn = (t) => Uint8Array.of(t), Ls = (t) => mn(Ae(t) ? 2 : 3), Vs = (t) => {
1692
- const e = yn(jt(t));
1694
+ }, ir = (t) => t instanceof R ? t : G("Point expected"), gn = (t) => m(m(t * t) * t + fn), or = (t) => Ft(t, 0n, ct), jt = (t) => Ft(t, 1n, ct), ks = (t) => Ft(t, 1n, un), Ae = (t) => (t & 1n) === 0n, yn = (t) => Uint8Array.of(t), Ns = (t) => yn(Ae(t) ? 2 : 3), Cs = (t) => {
1695
+ const e = gn(jt(t));
1693
1696
  let r = 1n;
1694
1697
  for (let n = e, s = (ct + 1n) / 4n; s > 0n; s >>= 1n)
1695
1698
  s & 1n && (r = r * n % ct), n = n * n % ct;
@@ -1702,23 +1705,23 @@ class R {
1702
1705
  py;
1703
1706
  pz;
1704
1707
  constructor(e, r, n) {
1705
- this.px = ur(e), this.py = jt(r), this.pz = ur(n), Object.freeze(this);
1708
+ this.px = or(e), this.py = jt(r), this.pz = or(n), Object.freeze(this);
1706
1709
  }
1707
1710
  /** Convert Uint8Array or hex string to Point. */
1708
1711
  static fromBytes(e) {
1709
1712
  Ct(e);
1710
1713
  let r;
1711
- const n = e[0], s = e.subarray(1), i = fr(s, 0, Xt), o = e.length;
1714
+ const n = e[0], s = e.subarray(1), i = ur(s, 0, Xt), o = e.length;
1712
1715
  if (o === Xt + 1 && [2, 3].includes(n)) {
1713
- let u = Vs(i);
1716
+ let u = Cs(i);
1714
1717
  const f = Ae(u);
1715
1718
  Ae(Qt(n)) !== f && (u = m(-u)), r = new R(i, u, 1n);
1716
1719
  }
1717
- return o === Oe + 1 && n === 4 && (r = new R(i, fr(s, Xt, Oe), 1n)), r ? r.assertValidity() : G("bad point: not on curve");
1720
+ return o === Oe + 1 && n === 4 && (r = new R(i, ur(s, Xt, Oe), 1n)), r ? r.assertValidity() : G("bad point: not on curve");
1718
1721
  }
1719
1722
  /** Equality check: compare points P&Q. */
1720
1723
  equals(e) {
1721
- const { px: r, py: n, pz: s } = this, { px: i, py: o, pz: u } = or(e), f = m(r * u), a = m(i * s), p = m(n * u), l = m(o * s);
1724
+ const { px: r, py: n, pz: s } = this, { px: i, py: o, pz: u } = ir(e), f = m(r * u), a = m(i * s), p = m(n * u), l = m(o * s);
1722
1725
  return f === a && p === l;
1723
1726
  }
1724
1727
  is0() {
@@ -1739,7 +1742,7 @@ class R {
1739
1742
  */
1740
1743
  // prettier-ignore
1741
1744
  add(e) {
1742
- const { px: r, py: n, pz: s } = this, { px: i, py: o, pz: u } = or(e), f = 0n, a = cn;
1745
+ const { px: r, py: n, pz: s } = this, { px: i, py: o, pz: u } = ir(e), f = 0n, a = fn;
1743
1746
  let p = 0n, l = 0n, d = 0n;
1744
1747
  const b = m(a * 3n);
1745
1748
  let w = m(r * i), S = m(n * o), P = m(s * u), k = m(r + n), H = m(i + o);
@@ -1757,10 +1760,10 @@ class R {
1757
1760
  multiply(e, r = !0) {
1758
1761
  if (!r && e === 0n)
1759
1762
  return ut;
1760
- if (Fs(e), e === 1n)
1763
+ if (ks(e), e === 1n)
1761
1764
  return this;
1762
1765
  if (this.equals(wt))
1763
- return Ds(e).p;
1766
+ return Vs(e).p;
1764
1767
  let n = ut, s = wt;
1765
1768
  for (let i = this; e > 0n; i = i.double(), e >>= 1n)
1766
1769
  e & 1n ? n = n.add(i) : r && (s = s.add(i));
@@ -1773,18 +1776,18 @@ class R {
1773
1776
  return { x: 0n, y: 0n };
1774
1777
  if (n === 1n)
1775
1778
  return { x: e, y: r };
1776
- const s = Rs(n, ct);
1779
+ const s = Us(n, ct);
1777
1780
  return m(n * s) !== 1n && G("inverse invalid"), { x: m(e * s), y: m(r * s) };
1778
1781
  }
1779
1782
  /** Checks if the point is valid and on-curve. */
1780
1783
  assertValidity() {
1781
1784
  const { x: e, y: r } = this.toAffine();
1782
- return jt(e), jt(r), m(r * r) === yn(e) ? this : G("bad point: not on curve");
1785
+ return jt(e), jt(r), m(r * r) === gn(e) ? this : G("bad point: not on curve");
1783
1786
  }
1784
1787
  /** Converts point to 33/65-byte Uint8Array. */
1785
1788
  toBytes(e = !0) {
1786
- const { x: r, y: n } = this.assertValidity().toAffine(), s = cr(r);
1787
- return e ? ir(Ls(n), s) : ir(mn(4), s, cr(n));
1789
+ const { x: r, y: n } = this.assertValidity().toAffine(), s = fr(r);
1790
+ return e ? sr(Ns(n), s) : sr(yn(4), s, fr(n));
1788
1791
  }
1789
1792
  /** Create 3d xyz point from 2d xy. (0, 0) => (0, 1, 0), not (0, 0, 1) */
1790
1793
  static fromAffine(e) {
@@ -1792,13 +1795,13 @@ class R {
1792
1795
  return r === 0n && n === 0n ? ut : new R(r, n, 1n);
1793
1796
  }
1794
1797
  toHex(e) {
1795
- return dn(this.toBytes(e));
1798
+ return ln(this.toBytes(e));
1796
1799
  }
1797
1800
  static fromPrivateKey(e) {
1798
- return wt.multiply(Gs(e));
1801
+ return wt.multiply(Rs(e));
1799
1802
  }
1800
1803
  static fromHex(e) {
1801
- return R.fromBytes(gn(e));
1804
+ return R.fromBytes(wn(e));
1802
1805
  }
1803
1806
  get x() {
1804
1807
  return this.toAffine().x;
@@ -1810,16 +1813,16 @@ class R {
1810
1813
  return this.toBytes(e);
1811
1814
  }
1812
1815
  }
1813
- const wt = new R(ks, Ns, 1n), ut = new R(0n, 1n, 0n);
1816
+ const wt = new R(Is, Hs, 1n), ut = new R(0n, 1n, 0n);
1814
1817
  R.BASE = wt;
1815
1818
  R.ZERO = ut;
1816
- const bn = (t) => Qt("0x" + (dn(t) || "0")), fr = (t, e, r) => bn(t.subarray(e, r)), Ws = 2n ** 256n, cr = (t) => wn(ln(Ft(t, 0n, Ws), Oe)), Gs = (t) => {
1817
- const e = an(t) ? t : bn(gn(t, Xt));
1818
- return Ft(e, 1n, fn, "private key invalid 3");
1819
- }, Jt = 8, Ks = 256, En = Math.ceil(Ks / Jt) + 1, Pe = 2 ** (Jt - 1), Ms = () => {
1819
+ const mn = (t) => Qt("0x" + (ln(t) || "0")), ur = (t, e, r) => mn(t.subarray(e, r)), Bs = 2n ** 256n, fr = (t) => dn(pn(Ft(t, 0n, Bs), Oe)), Rs = (t) => {
1820
+ const e = cn(t) ? t : mn(wn(t, Xt));
1821
+ return Ft(e, 1n, un, "private key invalid 3");
1822
+ }, Jt = 8, Fs = 256, bn = Math.ceil(Fs / Jt) + 1, Pe = 2 ** (Jt - 1), Ls = () => {
1820
1823
  const t = [];
1821
1824
  let e = wt, r = e;
1822
- for (let n = 0; n < En; n++) {
1825
+ for (let n = 0; n < bn; n++) {
1823
1826
  r = e, t.push(r);
1824
1827
  for (let s = 1; s < Pe; s++)
1825
1828
  r = r.add(e), t.push(r);
@@ -1827,26 +1830,26 @@ const bn = (t) => Qt("0x" + (dn(t) || "0")), fr = (t, e, r) => bn(t.subarray(e,
1827
1830
  }
1828
1831
  return t;
1829
1832
  };
1830
- let ar;
1831
- const hr = (t, e) => {
1833
+ let cr;
1834
+ const ar = (t, e) => {
1832
1835
  const r = e.negate();
1833
1836
  return t ? r : e;
1834
- }, Ds = (t) => {
1835
- const e = ar || (ar = Ms());
1837
+ }, Vs = (t) => {
1838
+ const e = cr || (cr = Ls());
1836
1839
  let r = ut, n = wt;
1837
1840
  const s = 2 ** Jt, i = s, o = Qt(s - 1), u = Qt(Jt);
1838
- for (let f = 0; f < En; f++) {
1841
+ for (let f = 0; f < bn; f++) {
1839
1842
  let a = Number(t & o);
1840
1843
  t >>= u, a > Pe && (a -= i, t += 1n);
1841
1844
  const p = f * Pe, l = p, d = p + Math.abs(a) - 1, b = f % 2 !== 0, w = a < 0;
1842
- a === 0 ? n = n.add(hr(b, e[l])) : r = r.add(hr(w, e[d]));
1845
+ a === 0 ? n = n.add(ar(b, e[l])) : r = r.add(ar(w, e[d]));
1843
1846
  }
1844
1847
  return { p: r, f: n };
1845
1848
  }, Ht = (t) => {
1846
1849
  const e = t.length === 32 ? t : t.subarray(1, 33);
1847
1850
  return h.isBuffer(e) ? e : h.from(e);
1848
1851
  };
1849
- function pr(t) {
1852
+ function hr(t) {
1850
1853
  let e = t.toString(16);
1851
1854
  return e = e.padStart(64, "0"), e.length > 64 && (e = e.slice(-64)), h.from(e, "hex");
1852
1855
  }
@@ -1863,7 +1866,7 @@ function Ie(t) {
1863
1866
  } catch {
1864
1867
  throw new Error("Invalid secp256k1 public key bytes. Cannot parse.");
1865
1868
  }
1866
- const r = pr(e.x), n = pr(e.y), i = e.y % 2n === 0n ? 6 : 7, o = h.alloc(65);
1869
+ const r = hr(e.x), n = hr(e.y), i = e.y % 2n === 0n ? 6 : 7, o = h.alloc(65);
1867
1870
  o[0] = i, r.copy(o, 1), n.copy(o, 33);
1868
1871
  const u = h.concat([h.from([4]), r, n]);
1869
1872
  return {
@@ -2093,7 +2096,7 @@ function mt(t, e) {
2093
2096
  throw new TypeError("Redeem.output too short");
2094
2097
  if (a.output.byteLength > 520)
2095
2098
  throw new TypeError("Redeem.output unspendable if larger than 520 bytes");
2096
- if (Fe(p) > 201)
2099
+ if (Re(p) > 201)
2097
2100
  throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
2098
2101
  const l = C(a.output);
2099
2102
  if (u.length > 0 && !u.equals(l))
@@ -2139,17 +2142,17 @@ function mt(t, e) {
2139
2142
  return Object.assign(n, t);
2140
2143
  }
2141
2144
  const vt = {};
2142
- function oo(t) {
2143
- t ? t !== vt.eccLib && ($s(t), vt.eccLib = t) : vt.eccLib = t;
2145
+ function eo(t) {
2146
+ t ? t !== vt.eccLib && (Ws(t), vt.eccLib = t) : vt.eccLib = t;
2144
2147
  }
2145
- function He() {
2148
+ function En() {
2146
2149
  if (!vt.eccLib)
2147
2150
  throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");
2148
2151
  return vt.eccLib;
2149
2152
  }
2150
2153
  const tt = (t) => h.from(t, "hex");
2151
- function $s(t) {
2152
- L(typeof t.isXOnlyPoint == "function"), L(t.isXOnlyPoint(tt("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))), L(t.isXOnlyPoint(tt("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))), L(t.isXOnlyPoint(tt("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))), L(t.isXOnlyPoint(tt("0000000000000000000000000000000000000000000000000000000000000001"))), L(!t.isXOnlyPoint(tt("0000000000000000000000000000000000000000000000000000000000000000"))), L(!t.isXOnlyPoint(tt("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))), L(typeof t.xOnlyPointAddTweak == "function"), qs.forEach((e) => {
2154
+ function Ws(t) {
2155
+ L(typeof t.isXOnlyPoint == "function"), L(t.isXOnlyPoint(tt("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))), L(t.isXOnlyPoint(tt("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))), L(t.isXOnlyPoint(tt("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))), L(t.isXOnlyPoint(tt("0000000000000000000000000000000000000000000000000000000000000001"))), L(!t.isXOnlyPoint(tt("0000000000000000000000000000000000000000000000000000000000000000"))), L(!t.isXOnlyPoint(tt("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))), L(typeof t.xOnlyPointAddTweak == "function"), Gs.forEach((e) => {
2153
2156
  const r = t.xOnlyPointAddTweak(tt(e.pubkey), tt(e.tweak));
2154
2157
  e.result === null ? L(r === null) : (L(r !== null), L(r.parity === e.parity), L(h.from(r.xOnlyPubkey).equals(tt(e.result))));
2155
2158
  });
@@ -2158,7 +2161,7 @@ function L(t) {
2158
2161
  if (!t)
2159
2162
  throw new Error("ecc library invalid");
2160
2163
  }
2161
- const qs = [
2164
+ const Gs = [
2162
2165
  {
2163
2166
  pubkey: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
2164
2167
  tweak: "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",
@@ -2188,15 +2191,15 @@ function _n(t, e) {
2188
2191
  if (Math.floor(t) !== t)
2189
2192
  throw new Error("value has a fractional component");
2190
2193
  }
2191
- function Xs(t, e) {
2194
+ function Ks(t, e) {
2192
2195
  const r = t.readUInt32LE(e);
2193
2196
  let n = t.readUInt32LE(e + 4);
2194
2197
  return n *= 4294967296, _n(n + r, 9007199254740991), n + r;
2195
2198
  }
2196
- function js(t, e, r) {
2199
+ function Ms(t, e, r) {
2197
2200
  return _n(e, 9007199254740991), t.writeInt32LE(e & -1, r), t.writeUInt32LE(Math.floor(e / 4294967296), r + 4), r + 8;
2198
2201
  }
2199
- function We(t) {
2202
+ function Ve(t) {
2200
2203
  if (t.length < 1)
2201
2204
  return t;
2202
2205
  let e = t.length - 1, r = 0;
@@ -2204,7 +2207,7 @@ function We(t) {
2204
2207
  r = t[n], t[n] = t[e], t[e] = r, e--;
2205
2208
  return t;
2206
2209
  }
2207
- function lr(t) {
2210
+ function pr(t) {
2208
2211
  const e = h.allocUnsafe(t.length);
2209
2212
  return t.copy(e), e;
2210
2213
  }
@@ -2225,10 +2228,10 @@ class x {
2225
2228
  this.offset = this.buffer.writeUInt32LE(e, this.offset);
2226
2229
  }
2227
2230
  writeUInt64(e) {
2228
- this.offset = js(this.buffer, e, this.offset);
2231
+ this.offset = Ms(this.buffer, e, this.offset);
2229
2232
  }
2230
2233
  writeVarInt(e) {
2231
- const r = Br(e, this.buffer, this.offset);
2234
+ const r = Cr(e, this.buffer, this.offset);
2232
2235
  this.offset += r.bytes;
2233
2236
  }
2234
2237
  writeSlice(e) {
@@ -2248,7 +2251,7 @@ class x {
2248
2251
  throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`);
2249
2252
  }
2250
2253
  }
2251
- class zs {
2254
+ class Ds {
2252
2255
  constructor(e, r = 0) {
2253
2256
  this.buffer = e, this.offset = r, Sn(z(V, Y), [e, r]);
2254
2257
  }
@@ -2265,7 +2268,7 @@ class zs {
2265
2268
  return this.offset += 4, e;
2266
2269
  }
2267
2270
  readUInt64() {
2268
- const e = Xs(this.buffer, this.offset);
2271
+ const e = Ks(this.buffer, this.offset);
2269
2272
  return this.offset += 8, e;
2270
2273
  }
2271
2274
  readVarInt() {
@@ -2288,7 +2291,7 @@ class zs {
2288
2291
  return r;
2289
2292
  }
2290
2293
  }
2291
- const Ge = 192, Tn = 128, Ys = (t) => "left" in t && "right" in t;
2294
+ const We = 192, Tn = 128, $s = (t) => "left" in t && "right" in t;
2292
2295
  function te(t, e) {
2293
2296
  if (t.length < 33)
2294
2297
  throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);
@@ -2296,7 +2299,7 @@ function te(t, e) {
2296
2299
  let n = e;
2297
2300
  for (let s = 0; s < r; s++) {
2298
2301
  const i = t.subarray(33 + 32 * s, 65 + 32 * s);
2299
- n.compare(i) < 0 ? n = ve(n, i) : n = ve(i, n);
2302
+ n.compare(i) < 0 ? n = He(n, i) : n = He(i, n);
2300
2303
  }
2301
2304
  return n;
2302
2305
  }
@@ -2307,13 +2310,13 @@ function ee(t) {
2307
2310
  e.sort((s, i) => s.hash.compare(i.hash));
2308
2311
  const [r, n] = e;
2309
2312
  return {
2310
- hash: ve(r.hash, n.hash),
2313
+ hash: He(r.hash, n.hash),
2311
2314
  left: r,
2312
2315
  right: n
2313
2316
  };
2314
2317
  }
2315
2318
  function Bt(t, e) {
2316
- if (Ys(t)) {
2319
+ if ($s(t)) {
2317
2320
  const r = Bt(t.left, e);
2318
2321
  if (r !== void 0)
2319
2322
  return [...r, t.right.hash];
@@ -2324,29 +2327,29 @@ function Bt(t, e) {
2324
2327
  return [];
2325
2328
  }
2326
2329
  function Z(t) {
2327
- const e = t.version || Ge;
2328
- return Rt("TapLeaf", U.concat([U.from([e]), Qs(t.output)]));
2330
+ const e = t.version || We;
2331
+ return Rt("TapLeaf", U.concat([U.from([e]), Xs(t.output)]));
2329
2332
  }
2330
- function Zs(t, e) {
2333
+ function qs(t, e) {
2331
2334
  return Rt("TapTweak", U.concat(e ? [t, e] : [t]));
2332
2335
  }
2333
2336
  function At(t, e) {
2334
2337
  if (!U.isBuffer(t) || t.length !== 32 || e && e.length !== 32)
2335
2338
  return null;
2336
- const r = Zs(t, e), n = He().xOnlyPointAddTweak(t, r);
2339
+ const r = qs(t, e), n = En().xOnlyPointAddTweak(t, r);
2337
2340
  return !n || n.xOnlyPubkey === null ? null : {
2338
2341
  parity: n.parity,
2339
2342
  x: U.from(n.xOnlyPubkey)
2340
2343
  };
2341
2344
  }
2342
- function ve(t, e) {
2345
+ function He(t, e) {
2343
2346
  return Rt("TapBranch", U.concat([t, e]));
2344
2347
  }
2345
- function Qs(t) {
2348
+ function Xs(t) {
2346
2349
  const e = kt(t.length), r = U.allocUnsafe(e);
2347
- return Br(t.length, r), U.concat([r, t]);
2350
+ return Cr(t.length, r), U.concat([r, t]);
2348
2351
  }
2349
- const dr = E, wr = 1, Js = 80;
2352
+ const lr = E, dr = 1, js = 80;
2350
2353
  function bt(t, e) {
2351
2354
  if (!t.address && !t.output && !t.pubkey && !t.internalPubkey && !(t.witness && t.witness.length > 1))
2352
2355
  throw new TypeError("Not enough data");
@@ -2360,7 +2363,7 @@ function bt(t, e) {
2360
2363
  pubkey: c.maybe(c.BufferN(32)),
2361
2364
  signature: c.maybe(c.anyOf(c.BufferN(64), c.BufferN(65))),
2362
2365
  witness: c.maybe(c.arrayOf(c.Buffer)),
2363
- scriptTree: c.maybe(Re),
2366
+ scriptTree: c.maybe(Be),
2364
2367
  redeem: c.maybe({
2365
2368
  output: c.maybe(c.Buffer),
2366
2369
  redeemVersion: c.maybe(c.Number),
@@ -2368,9 +2371,9 @@ function bt(t, e) {
2368
2371
  }),
2369
2372
  redeemVersion: c.maybe(c.Number)
2370
2373
  }, t);
2371
- const r = B(() => Be(t.address)), n = B(() => {
2374
+ const r = B(() => Ce(t.address)), n = B(() => {
2372
2375
  if (!(!t.witness || !t.witness.length))
2373
- return t.witness.length >= 2 && t.witness[t.witness.length - 1][0] === Js ? t.witness.slice(0, -1) : t.witness.slice();
2376
+ return t.witness.length >= 2 && t.witness[t.witness.length - 1][0] === js ? t.witness.slice(0, -1) : t.witness.slice();
2374
2377
  }), s = B(() => {
2375
2378
  if (t.scriptTree)
2376
2379
  return ee(t.scriptTree);
@@ -2384,7 +2387,7 @@ function bt(t, e) {
2384
2387
  if (!o.pubkey)
2385
2388
  return;
2386
2389
  const u = I.bech32m.toWords(o.pubkey);
2387
- return u.unshift(wr), I.bech32m.encode(i.bech32, u);
2390
+ return u.unshift(dr), I.bech32m.encode(i.bech32, u);
2388
2391
  }), y(o, "hash", () => {
2389
2392
  const u = s();
2390
2393
  if (u)
@@ -2399,8 +2402,8 @@ function bt(t, e) {
2399
2402
  }
2400
2403
  }), y(o, "output", () => {
2401
2404
  if (o.pubkey)
2402
- return v([dr.OP_1, o.pubkey]);
2403
- }), y(o, "redeemVersion", () => t.redeemVersion ? t.redeemVersion : t.redeem && t.redeem.redeemVersion !== void 0 && t.redeem.redeemVersion !== null ? t.redeem.redeemVersion : Ge), y(o, "redeem", () => {
2405
+ return v([lr.OP_1, o.pubkey]);
2406
+ }), y(o, "redeemVersion", () => t.redeemVersion ? t.redeemVersion : t.redeem && t.redeem.redeemVersion !== void 0 && t.redeem.redeemVersion !== null ? t.redeem.redeemVersion : We), y(o, "redeem", () => {
2404
2407
  const u = n();
2405
2408
  if (!(!u || u.length < 2))
2406
2409
  return {
@@ -2456,7 +2459,7 @@ function bt(t, e) {
2456
2459
  if (t.address) {
2457
2460
  if (i && i.bech32 !== r().prefix)
2458
2461
  throw new TypeError("Invalid prefix or Network mismatch");
2459
- if (r().version !== wr)
2462
+ if (r().version !== dr)
2460
2463
  throw new TypeError("Invalid address version");
2461
2464
  if (r().data.length !== 32)
2462
2465
  throw new TypeError("Invalid address data");
@@ -2468,7 +2471,7 @@ function bt(t, e) {
2468
2471
  u = t.pubkey;
2469
2472
  }
2470
2473
  if (t.output) {
2471
- if (t.output.length !== 34 || t.output[0] !== dr.OP_1 || t.output[1] !== 32)
2474
+ if (t.output.length !== 34 || t.output[0] !== lr.OP_1 || t.output[1] !== 32)
2472
2475
  throw new TypeError("Output is invalid");
2473
2476
  if (u.length > 0 && !u.equals(t.output.subarray(2)))
2474
2477
  throw new TypeError("Pubkey mismatch");
@@ -2480,8 +2483,6 @@ function bt(t, e) {
2480
2483
  throw new TypeError("Pubkey mismatch");
2481
2484
  u = p.x;
2482
2485
  }
2483
- if (u && u.length && !He().isXOnlyPoint(u))
2484
- throw new TypeError("Invalid pubkey for p2tr");
2485
2486
  const f = s();
2486
2487
  if (t.hash && f && !t.hash.equals(f.hash))
2487
2488
  throw new TypeError("Hash mismatch");
@@ -2522,7 +2523,7 @@ function bt(t, e) {
2522
2523
  const d = p.subarray(1, 33);
2523
2524
  if (t.internalPubkey && !t.internalPubkey.equals(d))
2524
2525
  throw new TypeError("Internal pubkey mismatch");
2525
- if (!He().isXOnlyPoint(d))
2526
+ if (!En().isXOnlyPoint(d))
2526
2527
  throw new TypeError("Invalid internalPubkey for p2tr witness");
2527
2528
  const b = p[0] & Pt, w = a[a.length - 2], S = Z({
2528
2529
  output: w,
@@ -2538,7 +2539,7 @@ function bt(t, e) {
2538
2539
  }
2539
2540
  return Object.assign(o, t);
2540
2541
  }
2541
- const gr = E, ti = h.alloc(0);
2542
+ const wr = E, zs = h.alloc(0);
2542
2543
  function Lt(t, e) {
2543
2544
  if (!t.address && !t.hash && !t.output && !t.pubkey && !t.witness)
2544
2545
  throw new TypeError("Not enough data");
@@ -2577,7 +2578,7 @@ function Lt(t, e) {
2577
2578
  return C(t.pubkey || s.pubkey);
2578
2579
  }), y(s, "output", () => {
2579
2580
  if (s.hash)
2580
- return v([gr.OP_0, s.hash]);
2581
+ return v([wr.OP_0, s.hash]);
2581
2582
  }), y(s, "pubkey", () => {
2582
2583
  if (t.pubkey)
2583
2584
  return t.pubkey;
@@ -2588,7 +2589,7 @@ function Lt(t, e) {
2588
2589
  return t.witness[0];
2589
2590
  }), y(s, "input", () => {
2590
2591
  if (s.witness)
2591
- return ti;
2592
+ return zs;
2592
2593
  }), y(s, "witness", () => {
2593
2594
  if (t.pubkey && t.signature)
2594
2595
  return [t.signature, t.pubkey];
@@ -2609,7 +2610,7 @@ function Lt(t, e) {
2609
2610
  i = t.hash;
2610
2611
  }
2611
2612
  if (t.output) {
2612
- if (t.output.length !== 22 || t.output[0] !== gr.OP_0 || t.output[1] !== 20)
2613
+ if (t.output.length !== 22 || t.output[0] !== wr.OP_0 || t.output[1] !== 20)
2613
2614
  throw new TypeError("Output is invalid");
2614
2615
  if (i.length > 0 && !i.equals(t.output.subarray(2)))
2615
2616
  throw new TypeError("Hash mismatch");
@@ -2640,7 +2641,7 @@ function Lt(t, e) {
2640
2641
  }
2641
2642
  return Object.assign(s, t);
2642
2643
  }
2643
- const yr = E, ge = h.alloc(0);
2644
+ const gr = E, ge = h.alloc(0);
2644
2645
  function Kt(t) {
2645
2646
  return !!(h.isBuffer(t) && t.length === 65 && t[0] === 4 && W(t));
2646
2647
  }
@@ -2689,7 +2690,7 @@ function Et(t, e) {
2689
2690
  return D(i.redeem.output);
2690
2691
  }), y(i, "output", () => {
2691
2692
  if (i.hash)
2692
- return v([yr.OP_0, i.hash]);
2693
+ return v([gr.OP_0, i.hash]);
2693
2694
  }), y(i, "redeem", () => {
2694
2695
  if (t.witness)
2695
2696
  return {
@@ -2702,7 +2703,7 @@ function Et(t, e) {
2702
2703
  return ge;
2703
2704
  }), y(i, "witness", () => {
2704
2705
  if (t.redeem && t.redeem.input && t.redeem.input.length > 0 && t.redeem.output && t.redeem.output.length > 0) {
2705
- const o = jr(n());
2706
+ const o = Xr(n());
2706
2707
  return i.redeem = Object.assign({ witness: o }, t.redeem), i.redeem.input = ge, [].concat(o, t.redeem.output);
2707
2708
  }
2708
2709
  if (t.redeem && t.redeem.output && t.redeem.witness)
@@ -2727,7 +2728,7 @@ function Et(t, e) {
2727
2728
  o = t.hash;
2728
2729
  }
2729
2730
  if (t.output) {
2730
- if (t.output.length !== 34 || t.output[0] !== yr.OP_0 || t.output[1] !== 32)
2731
+ if (t.output.length !== 34 || t.output[0] !== gr.OP_0 || t.output[1] !== 32)
2731
2732
  throw new TypeError("Output is invalid");
2732
2733
  const u = t.output.subarray(2);
2733
2734
  if (o.length > 0 && !o.equals(u))
@@ -2745,7 +2746,7 @@ function Et(t, e) {
2745
2746
  throw new TypeError("Redeem.output is invalid");
2746
2747
  if (t.redeem.output.byteLength > 3600)
2747
2748
  throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");
2748
- if (Fe(u) > 201)
2749
+ if (Re(u) > 201)
2749
2750
  throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
2750
2751
  const f = D(t.redeem.output);
2751
2752
  if (o.length > 0 && !o.equals(f))
@@ -2769,13 +2770,13 @@ function Et(t, e) {
2769
2770
  }
2770
2771
  return Object.assign(i, t);
2771
2772
  }
2772
- const fe = 40, ce = 2, ae = 15, ei = 16, xe = 16, Ke = 2, Me = 80, ri = "WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.", ni = (t) => {
2773
+ const fe = 40, ce = 2, ae = 15, Ys = 16, ve = 16, Ge = 2, Ke = 80, Zs = "WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.", Qs = (t) => {
2773
2774
  try {
2774
2775
  const e = h.from(t.subarray(2));
2775
2776
  if (e.length < ce || e.length > fe)
2776
2777
  throw new TypeError("Invalid program length for segwit address");
2777
- const r = t[0] - Me;
2778
- if (r < Ke || r > ae + 1)
2778
+ const r = t[0] - Ke;
2779
+ if (r < Ge || r > ae + 1)
2779
2780
  throw new TypeError("Invalid version for segwit address");
2780
2781
  if (r === 1)
2781
2782
  throw new TypeError("taproot");
@@ -2784,7 +2785,7 @@ const fe = 40, ce = 2, ae = 15, ei = 16, xe = 16, Ke = 2, Me = 80, ri = "WARNING
2784
2785
  }
2785
2786
  return !1;
2786
2787
  };
2787
- function si(t, e) {
2788
+ function Js(t, e) {
2788
2789
  if (!h.isBuffer(t))
2789
2790
  throw new TypeError("output must be a Buffer");
2790
2791
  if (!e.bech32Opnet)
@@ -2801,23 +2802,23 @@ function si(t, e) {
2801
2802
  if (i.length < ce || i.length > fe)
2802
2803
  throw new TypeError("Invalid program length for segwit address");
2803
2804
  const o = r === E.OP_0 ? 0 : r >= E.OP_1 && r <= E.OP_16 ? r - (E.OP_1 - 1) : -1;
2804
- if (o < ae || o > ei)
2805
+ if (o < ae || o > Ys)
2805
2806
  throw new TypeError(`Invalid segwit version ${o}`);
2806
2807
  const u = [o, ...I.bech32m.toWords(i)];
2807
2808
  return I.bech32m.encode(e.bech32Opnet, u);
2808
2809
  }
2809
- function ii(t, e) {
2810
+ function ti(t, e) {
2810
2811
  const r = h.from(t.subarray(2));
2811
2812
  if (r.length < ce || r.length > fe)
2812
2813
  throw new TypeError("Invalid program length for segwit address");
2813
- const n = t[0] - Me;
2814
- if (n < Ke || n > ae)
2814
+ const n = t[0] - Ke;
2815
+ if (n < Ge || n > ae)
2815
2816
  throw new TypeError("Invalid version for segwit address");
2816
2817
  if (t[1] !== r.length)
2817
2818
  throw new TypeError(`Invalid script for segwit address ${t[1]} !== ${r.length}`);
2818
- return ui(r, n, e.bech32, e.bech32Opnet);
2819
+ return ri(r, n, e.bech32, e.bech32Opnet);
2819
2820
  }
2820
- function oi(t) {
2821
+ function ei(t) {
2821
2822
  const e = h.from(Ut.decode(t));
2822
2823
  if (e.length < 21)
2823
2824
  throw new TypeError(t + " is too short");
@@ -2826,11 +2827,11 @@ function oi(t) {
2826
2827
  const r = e.readUInt8(0), n = h.from(e.subarray(1));
2827
2828
  return { version: r, hash: n };
2828
2829
  }
2829
- function ui(t, e, r, n) {
2830
+ function ri(t, e, r, n) {
2830
2831
  const s = I.bech32.toWords(t);
2831
- return s.unshift(e), e === xe && n ? I.bech32m.encode(n, s) : e === 0 ? I.bech32.encode(r, s) : I.bech32m.encode(r, s);
2832
+ return s.unshift(e), e === ve && n ? I.bech32m.encode(n, s) : e === 0 ? I.bech32.encode(r, s) : I.bech32m.encode(r, s);
2832
2833
  }
2833
- function fi(t, e) {
2834
+ function ni(t, e) {
2834
2835
  e = e || M;
2835
2836
  try {
2836
2837
  return yt({ output: t, network: e }).address;
@@ -2853,20 +2854,20 @@ function fi(t, e) {
2853
2854
  } catch {
2854
2855
  }
2855
2856
  try {
2856
- return si(t, e);
2857
+ return Js(t, e);
2857
2858
  } catch {
2858
2859
  }
2859
2860
  try {
2860
- return ii(t, e);
2861
+ return ti(t, e);
2861
2862
  } catch {
2862
2863
  }
2863
- throw new Error(Xr(t) + " has no matching Address");
2864
+ throw new Error(qr(t) + " has no matching Address");
2864
2865
  }
2865
- function ci(t, e) {
2866
+ function si(t, e) {
2866
2867
  e = e || M;
2867
2868
  let r, n;
2868
2869
  try {
2869
- r = oi(t);
2870
+ r = ei(t);
2870
2871
  } catch {
2871
2872
  }
2872
2873
  if (r) {
@@ -2876,7 +2877,7 @@ function ci(t, e) {
2876
2877
  return mt({ hash: r.hash }).output;
2877
2878
  } else {
2878
2879
  try {
2879
- n = Be(t);
2880
+ n = Ce(t);
2880
2881
  } catch {
2881
2882
  }
2882
2883
  if (n) {
@@ -2890,24 +2891,24 @@ function ci(t, e) {
2890
2891
  } else if (n.version === 1) {
2891
2892
  if (n.data.length === 32)
2892
2893
  return bt({ pubkey: n.data }).output;
2893
- } else if (n.version === xe) {
2894
+ } else if (n.version === ve) {
2894
2895
  if (!e.bech32Opnet)
2895
2896
  throw new Error(t + " has an invalid prefix");
2896
- return Yr({
2897
+ return zr({
2897
2898
  program: n.data,
2898
2899
  network: e
2899
2900
  }).output;
2900
- } else if (n.version >= Ke && n.version <= ae && n.data.length >= ce && n.data.length <= fe)
2901
- return n.version !== xe && console.warn(ri), v([
2902
- n.version + Me,
2901
+ } else if (n.version >= Ge && n.version <= ae && n.data.length >= ce && n.data.length <= fe)
2902
+ return n.version !== ve && console.warn(Zs), v([
2903
+ n.version + Ke,
2903
2904
  n.data
2904
2905
  ]);
2905
2906
  }
2906
2907
  }
2907
2908
  throw new TypeError(t + " has no matching Script");
2908
2909
  }
2909
- const mr = E;
2910
- function ai(t, e) {
2910
+ const yr = E;
2911
+ function ii(t, e) {
2911
2912
  if (!t.data && !t.output)
2912
2913
  throw new TypeError("Not enough data");
2913
2914
  e = Object.assign({ validate: !0 }, e || {}), c({
@@ -2918,7 +2919,7 @@ function ai(t, e) {
2918
2919
  const r = t.network || M, n = { name: K.Embed, network: r, data: [] };
2919
2920
  if (y(n, "output", () => {
2920
2921
  if (t.data)
2921
- return v([mr.OP_RETURN].concat(t.data));
2922
+ return v([yr.OP_RETURN].concat(t.data));
2922
2923
  }), y(n, "data", () => {
2923
2924
  if (!t.output)
2924
2925
  return;
@@ -2927,7 +2928,7 @@ function ai(t, e) {
2927
2928
  return s.slice(1);
2928
2929
  }), e.validate && t.output) {
2929
2930
  const s = A(t.output);
2930
- if (s[0] !== mr.OP_RETURN)
2931
+ if (s[0] !== yr.OP_RETURN)
2931
2932
  throw new TypeError("Output is invalid");
2932
2933
  if (!s.slice(1).every(c.Buffer))
2933
2934
  throw new TypeError("Output is invalid");
@@ -3032,8 +3033,8 @@ function Vt(t, e) {
3032
3033
  }
3033
3034
  return Object.assign(s, t);
3034
3035
  }
3035
- const br = E;
3036
- function De(t, e) {
3036
+ const mr = E;
3037
+ function Me(t, e) {
3037
3038
  if (!t.input && !t.output && !t.pubkey && !t.input && !t.signature)
3038
3039
  throw new TypeError("Not enough data");
3039
3040
  e = Object.assign({ validate: !0 }, e || {}), c({
@@ -3050,7 +3051,7 @@ function De(t, e) {
3050
3051
  };
3051
3052
  if (y(s, "output", () => {
3052
3053
  if (t.pubkey)
3053
- return v([t.pubkey, br.OP_CHECKSIG]);
3054
+ return v([t.pubkey, mr.OP_CHECKSIG]);
3054
3055
  }), y(s, "pubkey", () => {
3055
3056
  if (t.output)
3056
3057
  return t.output.subarray(1, -1);
@@ -3065,7 +3066,7 @@ function De(t, e) {
3065
3066
  return [];
3066
3067
  }), e.validate) {
3067
3068
  if (t.output) {
3068
- if (t.output[t.output.length - 1] !== br.OP_CHECKSIG)
3069
+ if (t.output[t.output.length - 1] !== mr.OP_CHECKSIG)
3069
3070
  throw new TypeError("Output is invalid");
3070
3071
  if (!W(s.pubkey))
3071
3072
  throw new TypeError("Output pubkey is invalid");
@@ -3083,18 +3084,18 @@ function De(t, e) {
3083
3084
  }
3084
3085
  return Object.assign(s, t);
3085
3086
  }
3086
- const hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3087
+ const oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3087
3088
  __proto__: null,
3088
- LEAF_VERSION_TAPSCRIPT: Ge,
3089
+ LEAF_VERSION_TAPSCRIPT: We,
3089
3090
  MAX_TAPTREE_DEPTH: Tn,
3090
3091
  get PaymentType() {
3091
3092
  return K;
3092
3093
  },
3093
3094
  findScriptPath: Bt,
3094
- p2data: ai,
3095
+ p2data: ii,
3095
3096
  p2ms: Vt,
3096
- p2op: Yr,
3097
- p2pk: De,
3097
+ p2op: zr,
3098
+ p2pk: Me,
3098
3099
  p2pkh: yt,
3099
3100
  p2sh: mt,
3100
3101
  p2tr: bt,
@@ -3111,15 +3112,15 @@ function j(t) {
3111
3112
  const e = t.length;
3112
3113
  return kt(e) + e;
3113
3114
  }
3114
- function pi(t) {
3115
+ function ui(t) {
3115
3116
  const e = t.length;
3116
3117
  return kt(e) + t.reduce((r, n) => r + j(n), 0);
3117
3118
  }
3118
- const ot = h.allocUnsafe(0), Er = [], ye = h.from("0000000000000000000000000000000000000000000000000000000000000000", "hex"), Sr = h.from("0000000000000000000000000000000000000000000000000000000000000001", "hex"), li = h.from("ffffffffffffffff", "hex"), di = {
3119
+ const ot = h.allocUnsafe(0), br = [], ye = h.from("0000000000000000000000000000000000000000000000000000000000000000", "hex"), Er = h.from("0000000000000000000000000000000000000000000000000000000000000001", "hex"), fi = h.from("ffffffffffffffff", "hex"), ci = {
3119
3120
  script: ot,
3120
- valueBuffer: li
3121
+ valueBuffer: fi
3121
3122
  };
3122
- function wi(t) {
3123
+ function ai(t) {
3123
3124
  return "value" in t;
3124
3125
  }
3125
3126
  class g {
@@ -3127,7 +3128,7 @@ class g {
3127
3128
  this.version = 1, this.locktime = 0, this.ins = [], this.outs = [];
3128
3129
  }
3129
3130
  static fromBuffer(e, r) {
3130
- const n = new zs(e), s = new g();
3131
+ const n = new Ds(e), s = new g();
3131
3132
  s.version = n.readInt32();
3132
3133
  const i = n.readUInt8(), o = n.readUInt8();
3133
3134
  let u = !1;
@@ -3140,7 +3141,7 @@ class g {
3140
3141
  index: d,
3141
3142
  script: b,
3142
3143
  sequence: w,
3143
- witness: Er
3144
+ witness: br
3144
3145
  });
3145
3146
  }
3146
3147
  const a = n.readVarInt();
@@ -3175,12 +3176,12 @@ class g {
3175
3176
  return this.ins.length === 1 && g.isCoinbaseHash(this.ins[0].hash);
3176
3177
  }
3177
3178
  addInput(e, r, n, s) {
3178
- return X(z(_e, Y, Te(Y), Te(V)), [e, r, n, s]), Mr(n) && (n = g.DEFAULT_SEQUENCE), this.ins.push({
3179
+ return X(z(_e, Y, Te(Y), Te(V)), [e, r, n, s]), Kr(n) && (n = g.DEFAULT_SEQUENCE), this.ins.push({
3179
3180
  hash: e,
3180
3181
  index: r,
3181
3182
  script: s || ot,
3182
3183
  sequence: n,
3183
- witness: Er
3184
+ witness: br
3184
3185
  }) - 1;
3185
3186
  }
3186
3187
  addOutput(e, r) {
@@ -3201,7 +3202,7 @@ class g {
3201
3202
  }
3202
3203
  byteLength(e = !0) {
3203
3204
  const r = e && this.hasWitnesses();
3204
- return (r ? 10 : 8) + kt(this.ins.length) + kt(this.outs.length) + this.ins.reduce((n, s) => n + 40 + j(s.script), 0) + this.outs.reduce((n, s) => n + 8 + j(s.script), 0) + (r ? this.ins.reduce((n, s) => n + pi(s.witness), 0) : 0);
3205
+ return (r ? 10 : 8) + kt(this.ins.length) + kt(this.outs.length) + this.ins.reduce((n, s) => n + 40 + j(s.script), 0) + this.outs.reduce((n, s) => n + 8 + j(s.script), 0) + (r ? this.ins.reduce((n, s) => n + ui(s.witness), 0) : 0);
3205
3206
  }
3206
3207
  clone() {
3207
3208
  const e = new g();
@@ -3222,7 +3223,7 @@ class g {
3222
3223
  r,
3223
3224
  n
3224
3225
  ]), e >= this.ins.length)
3225
- return Sr;
3226
+ return Er;
3226
3227
  const s = A(r);
3227
3228
  if (!s)
3228
3229
  throw new Error("Could not decompile prevOutScript");
@@ -3233,10 +3234,10 @@ class g {
3233
3234
  });
3234
3235
  else if ((n & 31) === g.SIGHASH_SINGLE) {
3235
3236
  if (e >= this.outs.length)
3236
- return Sr;
3237
+ return Er;
3237
3238
  o.outs.length = e + 1;
3238
3239
  for (let f = 0; f < e; f++)
3239
- o.outs[f] = di;
3240
+ o.outs[f] = ci;
3240
3241
  o.ins.forEach((f, a) => {
3241
3242
  a !== e && (f.sequence = 0);
3242
3243
  });
@@ -3312,7 +3313,7 @@ class g {
3312
3313
  return e && this.isCoinbase() ? h.alloc(32, 0) : it(this.__toBuffer(void 0, void 0, e));
3313
3314
  }
3314
3315
  getId() {
3315
- return We(this.getHash(!1)).toString("hex");
3316
+ return Ve(this.getHash(!1)).toString("hex");
3316
3317
  }
3317
3318
  toBuffer(e, r) {
3318
3319
  return this.__toBuffer(e, r, !0);
@@ -3334,7 +3335,7 @@ class g {
3334
3335
  return i && (s.writeUInt8(g.ADVANCED_TRANSACTION_MARKER), s.writeUInt8(g.ADVANCED_TRANSACTION_FLAG)), s.writeVarInt(this.ins.length), this.ins.forEach((o) => {
3335
3336
  s.writeSlice(o.hash), s.writeUInt32(o.index), s.writeVarSlice(o.script), s.writeUInt32(o.sequence);
3336
3337
  }), s.writeVarInt(this.outs.length), this.outs.forEach((o) => {
3337
- wi(o) ? s.writeUInt64(o.value) : s.writeSlice(o.valueBuffer), s.writeVarSlice(o.script);
3338
+ ai(o) ? s.writeUInt64(o.value) : s.writeSlice(o.valueBuffer), s.writeVarSlice(o.script);
3338
3339
  }), i && this.ins.forEach((o) => {
3339
3340
  s.writeVector(o.witness);
3340
3341
  }), s.writeUInt32(this.locktime), r !== void 0 ? e.subarray(r, s.offset) : e;
@@ -3362,7 +3363,7 @@ function pt(t) {
3362
3363
  }
3363
3364
  };
3364
3365
  }
3365
- const gi = pt(Vt), yi = pt(De), mi = pt(yt), he = pt(Lt), _r = pt(Et), On = pt(mt), An = pt(bt), uo = (t) => t.length === 4 && t[0] === 81 && t[1] === 2 && t[2] === 78 && t[3] === 115;
3366
+ const hi = pt(Vt), pi = pt(Me), li = pt(yt), he = pt(Lt), Sr = pt(Et), On = pt(mt), An = pt(bt), ro = (t) => t.length === 4 && t[0] === 81 && t[1] === 2 && t[2] === 78 && t[3] === 115;
3366
3367
  function xt(t) {
3367
3368
  let e = h.allocUnsafe(0);
3368
3369
  function r(o) {
@@ -3395,8 +3396,8 @@ function Pn(t, e) {
3395
3396
  function pe(t, e) {
3396
3397
  return Pn(t, e) !== -1;
3397
3398
  }
3398
- function bi(t, e) {
3399
- return Ei(t).some((n) => In(n, dt.decode, e));
3399
+ function di(t, e) {
3400
+ return wi(t).some((n) => In(n, dt.decode, e));
3400
3401
  }
3401
3402
  function In(t, e, r) {
3402
3403
  const { hashType: n } = e(t), s = [];
@@ -3410,25 +3411,25 @@ function In(t, e, r) {
3410
3411
  }
3411
3412
  return s.indexOf(r) === -1;
3412
3413
  }
3413
- function Ei(t) {
3414
+ function wi(t) {
3414
3415
  const { partialSig: e } = t;
3415
3416
  let r;
3416
3417
  if (!e || e.length === 0) {
3417
3418
  if (!t.finalScriptSig && !t.finalScriptWitness)
3418
3419
  return [];
3419
- r = Si(t);
3420
+ r = gi(t);
3420
3421
  } else
3421
3422
  r = e;
3422
3423
  return r.map((n) => n.signature);
3423
3424
  }
3424
- function Si(t) {
3425
+ function gi(t) {
3425
3426
  const e = t.finalScriptSig ? A(t.finalScriptSig) || [] : [], r = t.finalScriptWitness ? A(t.finalScriptWitness) || [] : [];
3426
3427
  return e.concat(r).filter((n) => h.isBuffer(n) && Q(n)).map((n) => ({ signature: n }));
3427
3428
  }
3428
- function Tr(t, e, r) {
3429
- const n = Bi(e, t, r);
3429
+ function _r(t, e, r) {
3430
+ const n = xi(e, t, r);
3430
3431
  try {
3431
- const i = Ni(e, n).concat(n.script).concat(n.controlBlock);
3432
+ const i = Hi(e, n).concat(n.script).concat(n.controlBlock);
3432
3433
  return { finalScriptWitness: xt(i) };
3433
3434
  } catch (s) {
3434
3435
  throw new Error(`Can not finalize taproot input #${t}: ${s}`);
@@ -3444,24 +3445,24 @@ function $(t) {
3444
3445
  function me(t, e) {
3445
3446
  return t && !!(t.tapInternalKey || t.tapTree || t.tapBip32Derivation && t.tapBip32Derivation.length || e);
3446
3447
  }
3447
- function Or(t, e, r) {
3448
- xi(t, e, r), ki(t, e, r);
3448
+ function Tr(t, e, r) {
3449
+ Ai(t, e, r), Ii(t, e, r);
3449
3450
  }
3450
- function Ar(t, e, r) {
3451
- Ui(t, e, r), _i(t, e);
3451
+ function Or(t, e, r) {
3452
+ Pi(t, e, r), yi(t, e);
3452
3453
  }
3453
- function _i(t, e) {
3454
+ function yi(t, e) {
3454
3455
  if (!e.tapTree && !e.tapInternalKey)
3455
3456
  return;
3456
3457
  const r = e.tapInternalKey || t.tapInternalKey, n = e.tapTree || t.tapTree;
3457
3458
  if (r) {
3458
- const s = t.script, i = Ti(r, n);
3459
+ const s = t.script, i = mi(r, n);
3459
3460
  if (s && !s.equals(i))
3460
3461
  throw new Error("Error adding output. Script or address missmatch.");
3461
3462
  }
3462
3463
  }
3463
- function Ti(t, e) {
3464
- const r = e && Oi(e.leaves), { output: n } = bt({
3464
+ function mi(t, e) {
3465
+ const r = e && bi(e.leaves), { output: n } = bt({
3465
3466
  internalPubkey: t,
3466
3467
  scriptTree: r
3467
3468
  });
@@ -3469,44 +3470,44 @@ function Ti(t, e) {
3469
3470
  throw new Error("Failed to generate taproot script pubkey");
3470
3471
  return n;
3471
3472
  }
3472
- function Oi(t = []) {
3473
+ function bi(t = []) {
3473
3474
  return t.length === 1 && t[0].depth === 0 ? {
3474
3475
  output: t[0].script,
3475
3476
  version: t[0].leafVersion
3476
- } : vi(t);
3477
+ } : Oi(t);
3477
3478
  }
3478
- function Ai(t, e) {
3479
- return Ii(t).some((n) => In(n, Pi, e));
3479
+ function Ei(t, e) {
3480
+ return _i(t).some((n) => In(n, Si, e));
3480
3481
  }
3481
- function Pi(t) {
3482
+ function Si(t) {
3482
3483
  return {
3483
3484
  signature: t.subarray(0, 64),
3484
3485
  hashType: t.subarray(64)[0] || g.SIGHASH_DEFAULT
3485
3486
  };
3486
3487
  }
3487
- function Ii(t) {
3488
+ function _i(t) {
3488
3489
  const e = [];
3489
3490
  if (t.tapKeySig && e.push(t.tapKeySig), t.tapScriptSig && e.push(...t.tapScriptSig.map((r) => r.signature)), !e.length) {
3490
- const r = Hi(t.finalScriptWitness);
3491
+ const r = Ti(t.finalScriptWitness);
3491
3492
  r && e.push(r);
3492
3493
  }
3493
3494
  return e;
3494
3495
  }
3495
- function Hi(t) {
3496
+ function Ti(t) {
3496
3497
  if (!t)
3497
3498
  return;
3498
3499
  const e = t.subarray(2);
3499
3500
  if (e.length === 64 || e.length === 65)
3500
3501
  return e;
3501
3502
  }
3502
- function vi(t) {
3503
+ function Oi(t) {
3503
3504
  let e;
3504
3505
  for (const r of t)
3505
- if (e = Ue(r, e), !e)
3506
+ if (e = xe(r, e), !e)
3506
3507
  throw new Error("No room left to insert tapleaf in tree");
3507
3508
  return e;
3508
3509
  }
3509
- function Ue(t, e, r = 0) {
3510
+ function xe(t, e, r = 0) {
3510
3511
  if (r > Tn)
3511
3512
  throw new Error("Max taptree depth exceeded.");
3512
3513
  if (t.depth === r)
@@ -3516,24 +3517,24 @@ function Ue(t, e, r = 0) {
3516
3517
  };
3517
3518
  if (ne(e))
3518
3519
  return;
3519
- const n = Ue(t, e && e[0], r + 1);
3520
+ const n = xe(t, e && e[0], r + 1);
3520
3521
  if (n)
3521
3522
  return [n, e && e[1]];
3522
- const s = Ue(t, e && e[1], r + 1);
3523
+ const s = xe(t, e && e[1], r + 1);
3523
3524
  if (s)
3524
3525
  return [e && e[0], s];
3525
3526
  }
3526
- function xi(t, e, r) {
3527
+ function Ai(t, e, r) {
3527
3528
  const n = $(t) && gt(e), s = gt(t) && $(e), i = t === e && $(e) && gt(e);
3528
3529
  if (n || s || i)
3529
3530
  throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`);
3530
3531
  }
3531
- function Ui(t, e, r) {
3532
+ function Pi(t, e, r) {
3532
3533
  const n = me(t) && gt(e), s = gt(t) && me(e), i = t === e && me(e) && gt(e);
3533
3534
  if (n || s || i)
3534
3535
  throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`);
3535
3536
  }
3536
- function ki(t, e, r) {
3537
+ function Ii(t, e, r) {
3537
3538
  if (e.tapMerkleRoot) {
3538
3539
  const n = (e.tapLeafScript || []).every((i) => be(i, e.tapMerkleRoot)), s = (t.tapLeafScript || []).every((i) => be(i, e.tapMerkleRoot));
3539
3540
  if (!n || !s)
@@ -3550,28 +3551,28 @@ function be(t, e) {
3550
3551
  });
3551
3552
  return te(t.controlBlock, r).equals(e);
3552
3553
  }
3553
- function Ni(t, e) {
3554
+ function Hi(t, e) {
3554
3555
  const r = Z({
3555
3556
  output: e.script,
3556
3557
  version: e.leafVersion
3557
3558
  });
3558
- return (t.tapScriptSig || []).filter((n) => n.leafHash.equals(r)).map((n) => Ci(e.script, n)).sort((n, s) => s.positionInScript - n.positionInScript).map((n) => n.signature);
3559
+ return (t.tapScriptSig || []).filter((n) => n.leafHash.equals(r)).map((n) => vi(e.script, n)).sort((n, s) => s.positionInScript - n.positionInScript).map((n) => n.signature);
3559
3560
  }
3560
- function Ci(t, e) {
3561
+ function vi(t, e) {
3561
3562
  return Object.assign({
3562
3563
  positionInScript: Pn(e.pubkey, t)
3563
3564
  }, e);
3564
3565
  }
3565
- function Bi(t, e, r) {
3566
+ function xi(t, e, r) {
3566
3567
  const { tapScriptSig: n } = t;
3567
3568
  if (!n || !n.length)
3568
3569
  throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);
3569
- const s = (t.tapLeafScript || []).sort((i, o) => i.controlBlock.length - o.controlBlock.length).find((i) => Ri(i, n, r));
3570
+ const s = (t.tapLeafScript || []).sort((i, o) => i.controlBlock.length - o.controlBlock.length).find((i) => Ui(i, n, r));
3570
3571
  if (!s)
3571
3572
  throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);
3572
3573
  return s;
3573
3574
  }
3574
- function Ri(t, e, r) {
3575
+ function Ui(t, e, r) {
3575
3576
  const n = Z({
3576
3577
  output: t.script,
3577
3578
  version: t.leafVersion
@@ -3581,13 +3582,13 @@ function Ri(t, e, r) {
3581
3582
  function gt(t) {
3582
3583
  return t && !!(t.redeemScript || t.witnessScript || t.bip32Derivation && t.bip32Derivation.length);
3583
3584
  }
3584
- const Pr = Se.decode, Fi = {
3585
+ const Ar = Se.decode, ki = {
3585
3586
  network: M,
3586
3587
  maximumFeeRate: 5e3
3587
3588
  };
3588
- class ke {
3589
- constructor(e = {}, r = new qe.Psbt(new Hn())) {
3590
- this.data = r, this.opts = Object.assign({}, Fi, e), this.__CACHE = {
3589
+ class Ue {
3590
+ constructor(e = {}, r = new $e.Psbt(new Hn())) {
3591
+ this.data = r, this.opts = Object.assign({}, ki, e), this.__CACHE = {
3591
3592
  __NON_WITNESS_UTXO_TX_CACHE: [],
3592
3593
  __NON_WITNESS_UTXO_BUF_CACHE: [],
3593
3594
  __TX_IN_CACHE: {},
@@ -3619,7 +3620,7 @@ class ke {
3619
3620
  }
3620
3621
  get txInputs() {
3621
3622
  return this.__CACHE.__TX.ins.map((e) => ({
3622
- hash: lr(e.hash),
3623
+ hash: pr(e.hash),
3623
3624
  index: e.index,
3624
3625
  sequence: e.sequence
3625
3626
  }));
@@ -3628,11 +3629,11 @@ class ke {
3628
3629
  return this.__CACHE.__TX.outs.map((e) => {
3629
3630
  let r;
3630
3631
  try {
3631
- r = fi(e.script, this.opts.network);
3632
+ r = ni(e.script, this.opts.network);
3632
3633
  } catch {
3633
3634
  }
3634
3635
  return {
3635
- script: lr(e.script),
3636
+ script: pr(e.script),
3636
3637
  value: e.value,
3637
3638
  address: r
3638
3639
  };
@@ -3647,15 +3648,15 @@ class ke {
3647
3648
  return this.fromBuffer(n, r);
3648
3649
  }
3649
3650
  static fromBuffer(e, r = {}) {
3650
- const n = qe.Psbt.fromBuffer(e, Li), s = new ke(r, n);
3651
- return Mi(s.__CACHE.__TX, s.__CACHE), s;
3651
+ const n = $e.Psbt.fromBuffer(e, Ni), s = new Ue(r, n);
3652
+ return Li(s.__CACHE.__TX, s.__CACHE), s;
3652
3653
  }
3653
3654
  combine(...e) {
3654
3655
  return this.data.combine(...e.map((r) => r.data)), this;
3655
3656
  }
3656
3657
  clone() {
3657
3658
  const e = JSON.parse(JSON.stringify(this.opts));
3658
- return ke.fromBuffer(this.data.toBuffer(), e);
3659
+ return Ue.fromBuffer(this.data.toBuffer(), e);
3659
3660
  }
3660
3661
  setMaximumFeeRate(e) {
3661
3662
  $t(e), this.opts.maximumFeeRate = e;
@@ -3686,13 +3687,13 @@ class ke {
3686
3687
  addInput(e, r = !0) {
3687
3688
  if (!e || e.hash === void 0 || e.index === void 0)
3688
3689
  throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");
3689
- Or(e, e, "addInput"), r && Tt(this.data.inputs, "addInput"), e.witnessScript && re(e.witnessScript);
3690
+ Tr(e, e, "addInput"), r && Tt(this.data.inputs, "addInput"), e.witnessScript && re(e.witnessScript);
3690
3691
  const n = this.__CACHE;
3691
3692
  this.data.addInput(e);
3692
3693
  const s = n.__TX.ins[n.__TX.ins.length - 1];
3693
3694
  Un(n, s);
3694
3695
  const i = this.data.inputs.length - 1, o = this.data.inputs[i];
3695
- return o.nonWitnessUtxo && Ce(this.__CACHE, o, i), n.__FEE = void 0, n.__FEE_RATE = void 0, n.__EXTRACTED_TX = void 0, this;
3696
+ return o.nonWitnessUtxo && Ne(this.__CACHE, o, i), n.__FEE = void 0, n.__FEE_RATE = void 0, n.__EXTRACTED_TX = void 0, this;
3696
3697
  }
3697
3698
  addOutputs(e) {
3698
3699
  return e.forEach((r) => this.addOutput(r)), this;
@@ -3702,10 +3703,10 @@ class ke {
3702
3703
  if (arguments.length > 1 || !e || e.value === void 0 || !r && !n)
3703
3704
  throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");
3704
3705
  if (Tt(this.data.inputs, "addOutput"), r) {
3705
- const { address: i } = e, { network: o } = this.opts, u = ci(i, o);
3706
+ const { address: i } = e, { network: o } = this.opts, u = si(i, o);
3706
3707
  e = Object.assign({}, e, { script: u });
3707
3708
  }
3708
- Ar(e, e, "addOutput");
3709
+ Or(e, e, "addOutput");
3709
3710
  const s = this.__CACHE;
3710
3711
  return this.data.addOutput(e), s.__FEE = void 0, s.__FEE_RATE = void 0, s.__EXTRACTED_TX = void 0, this;
3711
3712
  }
@@ -3713,16 +3714,16 @@ class ke {
3713
3714
  if (r && (this.data.inputs = this.data.inputs.filter((i) => !i.partialSig)), !this.data.inputs.every(vn))
3714
3715
  throw new Error("Not finalized");
3715
3716
  const n = this.__CACHE;
3716
- if (e || Wi(this, n, this.opts), n.__EXTRACTED_TX)
3717
+ if (e || Bi(this, n, this.opts), n.__EXTRACTED_TX)
3717
3718
  return n.__EXTRACTED_TX;
3718
3719
  const s = n.__TX.clone();
3719
3720
  return Fn(this.data.inputs, s, n, !0, r), s;
3720
3721
  }
3721
3722
  getFeeRate(e = !1) {
3722
- return Ur("__FEE_RATE", "fee rate", this.data.inputs, this.__CACHE, e);
3723
+ return xr("__FEE_RATE", "fee rate", this.data.inputs, this.__CACHE, e);
3723
3724
  }
3724
3725
  getFee(e = !1) {
3725
- return Ur("__FEE", "fee", this.data.inputs, this.__CACHE, e);
3726
+ return xr("__FEE", "fee", this.data.inputs, this.__CACHE, e);
3726
3727
  }
3727
3728
  finalizeAllInputs() {
3728
3729
  return N.checkForInput(this.data.inputs, 0), Ot(this.data.inputs.length).forEach((e) => this.finalizeInput(e)), this;
@@ -3731,30 +3732,30 @@ class ke {
3731
3732
  const s = N.checkForInput(this.data.inputs, e);
3732
3733
  return $(s) ? this._finalizeTaprootInput(e, s, void 0, r) : this._finalizeInput(e, s, r, n ?? !0);
3733
3734
  }
3734
- finalizeTaprootInput(e, r, n = Tr) {
3735
+ finalizeTaprootInput(e, r, n = _r) {
3735
3736
  const s = N.checkForInput(this.data.inputs, e);
3736
3737
  if ($(s))
3737
3738
  return this._finalizeTaprootInput(e, s, r, n);
3738
3739
  throw new Error(`Cannot finalize input #${e}. Not Taproot.`);
3739
3740
  }
3740
3741
  getInputType(e) {
3741
- const r = N.checkForInput(this.data.inputs, e), n = Ln(e, r, this.__CACHE), s = de(n, e, "input", r.redeemScript || Ji(r.finalScriptSig), r.witnessScript || to(r.finalScriptWitness)), i = s.type === "raw" ? "" : s.type + "-", o = Wn(s.meaningfulScript);
3742
+ const r = N.checkForInput(this.data.inputs, e), n = Ln(e, r, this.__CACHE), s = de(n, e, "input", r.redeemScript || ji(r.finalScriptSig), r.witnessScript || zi(r.finalScriptWitness)), i = s.type === "raw" ? "" : s.type + "-", o = Wn(s.meaningfulScript);
3742
3743
  return i + o;
3743
3744
  }
3744
3745
  inputHasPubkey(e, r) {
3745
3746
  const n = N.checkForInput(this.data.inputs, e);
3746
- return Zi(r, n, e, this.__CACHE);
3747
+ return qi(r, n, e, this.__CACHE);
3747
3748
  }
3748
3749
  inputHasHDKey(e, r) {
3749
- const n = N.checkForInput(this.data.inputs, e), s = Hr(r);
3750
+ const n = N.checkForInput(this.data.inputs, e), s = Ir(r);
3750
3751
  return !!n.bip32Derivation && n.bip32Derivation.some(s);
3751
3752
  }
3752
3753
  outputHasPubkey(e, r) {
3753
3754
  const n = N.checkForOutput(this.data.outputs, e);
3754
- return Qi(r, n, e, this.__CACHE);
3755
+ return Xi(r, n, e, this.__CACHE);
3755
3756
  }
3756
3757
  outputHasHDKey(e, r) {
3757
- const n = N.checkForOutput(this.data.outputs, e), s = Hr(r);
3758
+ const n = N.checkForOutput(this.data.outputs, e), s = Ir(r);
3758
3759
  return !!n.bip32Derivation && n.bip32Derivation.some(s);
3759
3760
  }
3760
3761
  validateSignaturesOfAllInputs(e) {
@@ -3799,13 +3800,13 @@ class ke {
3799
3800
  signInputHD(e, r, n = [g.SIGHASH_ALL]) {
3800
3801
  if (!r || !r.publicKey || !r.fingerprint)
3801
3802
  throw new Error("Need HDSigner to sign input");
3802
- return Cr(e, this.data.inputs, r).forEach((i) => this.signInput(e, i, n)), this;
3803
+ return Nr(e, this.data.inputs, r).forEach((i) => this.signInput(e, i, n)), this;
3803
3804
  }
3804
3805
  signInputHDAsync(e, r, n = [g.SIGHASH_ALL]) {
3805
3806
  return new Promise((s, i) => {
3806
3807
  if (!r || !r.publicKey || !r.fingerprint)
3807
3808
  return i(new Error("Need HDSigner to sign input"));
3808
- const u = Cr(e, this.data.inputs, r).map((f) => this.signInputAsync(e, f, n));
3809
+ const u = Nr(e, this.data.inputs, r).map((f) => this.signInputAsync(e, f, n));
3809
3810
  return Promise.all(u).then(() => {
3810
3811
  s();
3811
3812
  }).catch(i);
@@ -3888,11 +3889,11 @@ class ke {
3888
3889
  return this.data.updateGlobal(e), this;
3889
3890
  }
3890
3891
  updateInput(e, r) {
3891
- return r.witnessScript && re(r.witnessScript), Or(this.data.inputs[e], r, "updateInput"), this.data.updateInput(e, r), r.nonWitnessUtxo && Ce(this.__CACHE, this.data.inputs[e], e), this;
3892
+ return r.witnessScript && re(r.witnessScript), Tr(this.data.inputs[e], r, "updateInput"), this.data.updateInput(e, r), r.nonWitnessUtxo && Ne(this.__CACHE, this.data.inputs[e], e), this;
3892
3893
  }
3893
3894
  updateOutput(e, r) {
3894
3895
  const n = this.data.outputs[e];
3895
- return Ar(n, r, "updateOutput"), this.data.updateOutput(e, r), this;
3896
+ return Or(n, r, "updateOutput"), this.data.updateOutput(e, r), this;
3896
3897
  }
3897
3898
  addUnknownKeyValToGlobal(e) {
3898
3899
  return this.data.addUnknownKeyValToGlobal(e), this;
@@ -3909,22 +3910,22 @@ class ke {
3909
3910
  checkTaprootHashesForSig(e, r, n, s, i) {
3910
3911
  if (typeof n.signSchnorr != "function")
3911
3912
  throw new Error(`Need Schnorr Signer to sign taproot input #${e}.`);
3912
- const o = h.isBuffer(n.publicKey) ? n.publicKey : h.from(n.publicKey), u = Ne(e, r, this.data.inputs, o, this.__CACHE, s, i);
3913
+ const o = h.isBuffer(n.publicKey) ? n.publicKey : h.from(n.publicKey), u = ke(e, r, this.data.inputs, o, this.__CACHE, s, i);
3913
3914
  if (!u || !u.length)
3914
3915
  throw new Error(`Can not sign for input #${e} with the key ${o.toString("hex")}`);
3915
3916
  return u;
3916
3917
  }
3917
- _finalizeInput(e, r, n = Di, s = !0) {
3918
- const { script: i, isP2SH: o, isP2WSH: u, isSegwit: f } = ji(e, r, this.__CACHE);
3918
+ _finalizeInput(e, r, n = Vi, s = !0) {
3919
+ const { script: i, isP2SH: o, isP2WSH: u, isSegwit: f } = Mi(e, r, this.__CACHE);
3919
3920
  if (!i)
3920
3921
  throw new Error(`No script found for input #${e}`);
3921
- Gi(r);
3922
+ Ri(r);
3922
3923
  const { finalScriptSig: a, finalScriptWitness: p } = n(e, r, i, f, o, u, s);
3923
3924
  if (a && this.data.updateInput(e, { finalScriptSig: a }), p && this.data.updateInput(e, { finalScriptWitness: p }), !a && !p)
3924
3925
  throw new Error(`Unknown error finalizing input #${e}`);
3925
3926
  return this.data.clearFinalizedInput(e), this;
3926
3927
  }
3927
- _finalizeTaprootInput(e, r, n, s = Tr) {
3928
+ _finalizeTaprootInput(e, r, n, s = _r) {
3928
3929
  if (!r.witnessUtxo)
3929
3930
  throw new Error(`Cannot finalize input #${e}. Missing witness utxo.`);
3930
3931
  if (r.tapKeySig) {
@@ -3968,13 +3969,13 @@ class ke {
3968
3969
  if (typeof r != "function")
3969
3970
  throw new Error("Need validator function to validate signatures");
3970
3971
  n = n && Ht(n);
3971
- const u = n ? Ne(e, s, this.data.inputs, n, this.__CACHE) : qi(e, s, this.data.inputs, this.__CACHE);
3972
+ const u = n ? ke(e, s, this.data.inputs, n, this.__CACHE) : Gi(e, s, this.data.inputs, this.__CACHE);
3972
3973
  if (!u.length)
3973
3974
  throw new Error("No signatures for this pubkey");
3974
3975
  const f = u.find((p) => !p.leafHash);
3975
3976
  let a = 0;
3976
3977
  if (i && f) {
3977
- if (!r(f.pubkey, f.hash, Nr(i)))
3978
+ if (!r(f.pubkey, f.hash, kr(i)))
3978
3979
  return !1;
3979
3980
  a++;
3980
3981
  }
@@ -3982,7 +3983,7 @@ class ke {
3982
3983
  for (const p of o) {
3983
3984
  const l = u.find((d) => p.pubkey.equals(d.pubkey));
3984
3985
  if (l) {
3985
- if (!r(p.pubkey, l.hash, Nr(p.signature)))
3986
+ if (!r(p.pubkey, l.hash, kr(p.signature)))
3986
3987
  return !1;
3987
3988
  a++;
3988
3989
  }
@@ -3990,7 +3991,7 @@ class ke {
3990
3991
  return a > 0;
3991
3992
  }
3992
3993
  _signInput(e, r, n = [g.SIGHASH_ALL]) {
3993
- const s = h.isBuffer(r.publicKey) ? r.publicKey : h.from(r.publicKey), { hash: i, sighashType: o } = kr(this.data.inputs, e, s, this.__CACHE, n), u = r.sign(i), f = [
3994
+ const s = h.isBuffer(r.publicKey) ? r.publicKey : h.from(r.publicKey), { hash: i, sighashType: o } = Ur(this.data.inputs, e, s, this.__CACHE, n), u = r.sign(i), f = [
3994
3995
  {
3995
3996
  pubkey: s,
3996
3997
  signature: dt.encode(h.isBuffer(u) ? u : h.from(u), o)
@@ -4007,7 +4008,7 @@ class ke {
4007
4008
  return p && this.data.updateInput(e, { tapKeySig: p }), l.length && this.data.updateInput(e, { tapScriptSig: l }), this;
4008
4009
  }
4009
4010
  _signInputAsync(e, r, n = [g.SIGHASH_ALL]) {
4010
- const s = h.isBuffer(r.publicKey) ? r.publicKey : h.from(r.publicKey), { hash: i, sighashType: o } = kr(this.data.inputs, e, s, this.__CACHE, n);
4011
+ const s = h.isBuffer(r.publicKey) ? r.publicKey : h.from(r.publicKey), { hash: i, sighashType: o } = Ur(this.data.inputs, e, s, this.__CACHE, n);
4011
4012
  return Promise.resolve(r.sign(i)).then((u) => {
4012
4013
  const f = h.isBuffer(u) ? u : h.from(u), a = [
4013
4014
  {
@@ -4045,10 +4046,10 @@ class ke {
4045
4046
  this.data.updateInput(e, w);
4046
4047
  }
4047
4048
  }
4048
- const Li = (t) => new Hn(t);
4049
+ const Ni = (t) => new Hn(t);
4049
4050
  class Hn {
4050
4051
  constructor(e = h.from([2, 0, 0, 0, 0, 0, 0, 0, 0, 0])) {
4051
- this.tx = g.fromBuffer(e), Ki(this.tx), Object.defineProperty(this, "tx", {
4052
+ this.tx = g.fromBuffer(e), Fi(this.tx), Object.defineProperty(this, "tx", {
4052
4053
  enumerable: !1,
4053
4054
  writable: !0
4054
4055
  });
@@ -4062,7 +4063,7 @@ class Hn {
4062
4063
  addInput(e) {
4063
4064
  if (e.hash === void 0 || e.index === void 0 || !h.isBuffer(e.hash) && typeof e.hash != "string" || typeof e.index != "number")
4064
4065
  throw new Error("Error adding input.");
4065
- const r = typeof e.hash == "string" ? We(h.from(e.hash, "hex")) : e.hash;
4066
+ const r = typeof e.hash == "string" ? Ve(h.from(e.hash, "hex")) : e.hash;
4066
4067
  this.tx.addInput(r, e.index, e.sequence);
4067
4068
  }
4068
4069
  addOutput(e) {
@@ -4074,17 +4075,17 @@ class Hn {
4074
4075
  return this.tx.toBuffer();
4075
4076
  }
4076
4077
  }
4077
- function Vi(t, e, r) {
4078
+ function Ci(t, e, r) {
4078
4079
  switch (r) {
4079
4080
  case "pubkey":
4080
4081
  case "pubkeyhash":
4081
4082
  case "witnesspubkeyhash":
4082
- return Ir(1, t.partialSig);
4083
+ return Pr(1, t.partialSig);
4083
4084
  case "multisig": {
4084
4085
  const n = Vt({
4085
4086
  output: e
4086
4087
  });
4087
- return Ir(n.m, t.partialSig, n.pubkeys);
4088
+ return Pr(n.m, t.partialSig, n.pubkeys);
4088
4089
  }
4089
4090
  case "nonstandard":
4090
4091
  return !0;
@@ -4096,12 +4097,12 @@ function Ee(t) {
4096
4097
  if (t.__UNSAFE_SIGN_NONSEGWIT)
4097
4098
  throw new Error("Not BIP174 compliant, can not export");
4098
4099
  }
4099
- function Ir(t, e, r) {
4100
+ function Pr(t, e, r) {
4100
4101
  if (!e)
4101
4102
  return !1;
4102
4103
  let n;
4103
4104
  if (r ? n = r.map((s) => {
4104
- const i = eo(s);
4105
+ const i = Yi(s);
4105
4106
  return e.find((o) => o.pubkey.equals(i));
4106
4107
  }).filter((s) => !!s) : n = e, n.length > t)
4107
4108
  throw new Error("Too many signatures");
@@ -4110,7 +4111,7 @@ function Ir(t, e, r) {
4110
4111
  function vn(t) {
4111
4112
  return !!t.finalScriptSig || !!t.finalScriptWitness;
4112
4113
  }
4113
- function Hr(t) {
4114
+ function Ir(t) {
4114
4115
  return (e) => {
4115
4116
  const r = h.isBuffer(t.fingerprint) ? t.fingerprint : h.from(t.fingerprint);
4116
4117
  if (!e.masterFingerprint.equals(r))
@@ -4123,18 +4124,18 @@ function $t(t) {
4123
4124
  if (typeof t != "number" || t !== Math.floor(t) || t > 4294967295 || t < 0)
4124
4125
  throw new Error("Invalid 32 bit integer");
4125
4126
  }
4126
- function Wi(t, e, r) {
4127
+ function Bi(t, e, r) {
4127
4128
  const n = e.__FEE_RATE || t.getFeeRate(), s = e.__EXTRACTED_TX.virtualSize(), i = n * s;
4128
4129
  if (n >= r.maximumFeeRate)
4129
4130
  throw new Error(`Warning: You are paying around ${(i / 1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${s} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`);
4130
4131
  }
4131
4132
  function Tt(t, e) {
4132
4133
  t.forEach((r) => {
4133
- if ($(r) ? Ai(r, e) : bi(r, e))
4134
+ if ($(r) ? Ei(r, e) : di(r, e))
4134
4135
  throw new Error("Can not modify transaction, signatures exist.");
4135
4136
  });
4136
4137
  }
4137
- function Gi(t) {
4138
+ function Ri(t) {
4138
4139
  if (!t.sighashType || !t.partialSig)
4139
4140
  return;
4140
4141
  const { partialSig: e, sighashType: r } = t;
@@ -4148,17 +4149,17 @@ function xn(t, e, r) {
4148
4149
  if (!pe(t, e))
4149
4150
  throw new Error(`Can not ${r} for this input with the key ${t.toString("hex")}`);
4150
4151
  }
4151
- function Ki(t) {
4152
+ function Fi(t) {
4152
4153
  if (!t.ins.every((r) => r.script && r.script.length === 0 && r.witness && r.witness.length === 0))
4153
4154
  throw new Error("Format Error: Transaction ScriptSigs are not empty");
4154
4155
  }
4155
- function Mi(t, e) {
4156
+ function Li(t, e) {
4156
4157
  t.ins.forEach((r) => {
4157
4158
  Un(e, r);
4158
4159
  });
4159
4160
  }
4160
4161
  function Un(t, e) {
4161
- const r = `${We(h.from(e.hash)).toString("hex")}:${e.index}`;
4162
+ const r = `${Ve(h.from(e.hash)).toString("hex")}:${e.index}`;
4162
4163
  if (t.__TX_IN_CACHE[r])
4163
4164
  throw new Error("Duplicate input detected.");
4164
4165
  t.__TX_IN_CACHE[r] = 1;
@@ -4172,8 +4173,8 @@ function kn(t, e) {
4172
4173
  throw new Error(`${e} for ${i} #${r} doesn't match the scriptPubKey in the prevout`);
4173
4174
  };
4174
4175
  }
4175
- const vr = kn(mt, "Redeem script"), xr = kn(Et, "Witness script");
4176
- function Ur(t, e, r, n, s = !1) {
4176
+ const Hr = kn(mt, "Redeem script"), vr = kn(Et, "Witness script");
4177
+ function xr(t, e, r, n, s = !1) {
4177
4178
  if (!r.every(vn))
4178
4179
  throw new Error(`PSBT must be finalized to calculate ${e}`);
4179
4180
  if (t === "__FEE_RATE" && n.__FEE_RATE)
@@ -4187,21 +4188,21 @@ function Ur(t, e, r, n, s = !1) {
4187
4188
  throw new Error(`Failed to calculate ${e}`);
4188
4189
  return u;
4189
4190
  }
4190
- function Di(t, e, r, n, s, i, o = !0, u) {
4191
+ function Vi(t, e, r, n, s, i, o = !0, u) {
4191
4192
  const f = Wn(r);
4192
- if (!Vi(e, r, f) && o)
4193
+ if (!Ci(e, r, f) && o)
4193
4194
  throw new Error(`Can not finalize input #${t}`);
4194
- return $i(r, f, e.partialSig, n, s, i, u);
4195
+ return Wi(r, f, e.partialSig, n, s, i, u);
4195
4196
  }
4196
- function $i(t, e, r, n, s, i, o) {
4197
+ function Wi(t, e, r, n, s, i, o) {
4197
4198
  let u, f;
4198
- const a = Xi(t, e, r), p = i ? Et({ redeem: a }) : null, l = s ? mt({ redeem: p || a }) : null;
4199
+ const a = Ki(t, e, r), p = i ? Et({ redeem: a }) : null, l = s ? mt({ redeem: p || a }) : null;
4199
4200
  return n ? (p ? f = xt(p.witness) : a ? f = xt(a.witness) : f = xt(o ?? [h.from([0])]), l && (u = l?.input)) : l ? u = l?.input : a ? u = a.input : u = Array.isArray(o) && o[0] ? o[0] : h.from([1]), {
4200
4201
  finalScriptSig: u,
4201
4202
  finalScriptWitness: f
4202
4203
  };
4203
4204
  }
4204
- function kr(t, e, r, n, s) {
4205
+ function Ur(t, e, r, n, s) {
4205
4206
  const i = N.checkForInput(t, e), { hash: o, sighashType: u, script: f } = Nn(e, i, n, !1, s);
4206
4207
  return xn(r, f, "sign"), {
4207
4208
  hash: o,
@@ -4244,7 +4245,7 @@ PROCEED WITH CAUTION!
4244
4245
  hash: u
4245
4246
  };
4246
4247
  }
4247
- function qi(t, e, r, n) {
4248
+ function Gi(t, e, r, n) {
4248
4249
  const s = [];
4249
4250
  if (e.tapInternalKey) {
4250
4251
  const o = Cn(t, e, n);
@@ -4254,19 +4255,19 @@ function qi(t, e, r, n) {
4254
4255
  const o = e.tapScriptSig.map((u) => u.pubkey);
4255
4256
  s.push(...o);
4256
4257
  }
4257
- return s.map((o) => Ne(t, e, r, o, n)).flat();
4258
+ return s.map((o) => ke(t, e, r, o, n)).flat();
4258
4259
  }
4259
4260
  function Cn(t, e, r) {
4260
- const { script: n } = $e(t, e, r);
4261
+ const { script: n } = De(t, e, r);
4261
4262
  return An(n) ? h.from(n.subarray(2, 34)) : null;
4262
4263
  }
4263
- function Nr(t) {
4264
+ function kr(t) {
4264
4265
  return t.length === 64 ? t : h.from(t.subarray(0, 64));
4265
4266
  }
4266
- function Ne(t, e, r, n, s, i, o) {
4267
+ function ke(t, e, r, n, s, i, o) {
4267
4268
  const u = s.__TX, f = e.sighashType || g.SIGHASH_DEFAULT;
4268
4269
  Bn(f, o);
4269
- const a = r.map((w, S) => $e(S, w, s)), p = a.map((w) => w.script), l = a.map((w) => w.value), d = [];
4270
+ const a = r.map((w, S) => De(S, w, s)), p = a.map((w) => w.script), l = a.map((w) => w.value), d = [];
4270
4271
  if (e.tapInternalKey && !i) {
4271
4272
  const w = Cn(t, e, s) || h.from([]);
4272
4273
  if (Ht(n).equals(w)) {
@@ -4292,15 +4293,15 @@ function Ne(t, e, r, n, s, i, o) {
4292
4293
  }
4293
4294
  function Bn(t, e) {
4294
4295
  if (e && e.indexOf(t) < 0) {
4295
- const r = Yi(t);
4296
+ const r = $i(t);
4296
4297
  throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`);
4297
4298
  }
4298
4299
  }
4299
- function Xi(t, e, r) {
4300
+ function Ki(t, e, r) {
4300
4301
  let n;
4301
4302
  switch (e) {
4302
4303
  case "multisig": {
4303
- const s = zi(t, r);
4304
+ const s = Di(t, r);
4304
4305
  n = Vt({
4305
4306
  output: t,
4306
4307
  signatures: s
@@ -4308,7 +4309,7 @@ function Xi(t, e, r) {
4308
4309
  break;
4309
4310
  }
4310
4311
  case "pubkey":
4311
- n = De({
4312
+ n = Me({
4312
4313
  output: t,
4313
4314
  signature: r[0].signature
4314
4315
  });
@@ -4330,7 +4331,7 @@ function Xi(t, e, r) {
4330
4331
  }
4331
4332
  return n;
4332
4333
  }
4333
- function ji(t, e, r) {
4334
+ function Mi(t, e, r) {
4334
4335
  const n = r.__TX, s = {
4335
4336
  script: null,
4336
4337
  isSegwit: !1,
@@ -4352,12 +4353,12 @@ function ji(t, e, r) {
4352
4353
  const i = s.script;
4353
4354
  if (!i)
4354
4355
  throw new TypeError("Invalid script for segwit address");
4355
- s.isSegwit = ni(i);
4356
+ s.isSegwit = Qs(i);
4356
4357
  } catch {
4357
4358
  }
4358
4359
  return s;
4359
4360
  }
4360
- function Cr(t, e, r) {
4361
+ function Nr(t, e, r) {
4361
4362
  const n = N.checkForInput(e, t);
4362
4363
  if (!n.bip32Derivation || n.bip32Derivation.length === 0)
4363
4364
  throw new Error("Need bip32Derivation to sign with HD");
@@ -4374,7 +4375,7 @@ function Cr(t, e, r) {
4374
4375
  return o;
4375
4376
  });
4376
4377
  }
4377
- function zi(t, e) {
4378
+ function Di(t, e) {
4378
4379
  return Vt({ output: t }).pubkeys.map((n) => (e.filter((s) => s.pubkey.equals(n))[0] || {}).signature).filter((n) => !!n);
4379
4380
  }
4380
4381
  function Rn(t) {
@@ -4383,8 +4384,8 @@ function Rn(t) {
4383
4384
  return e += o, t.subarray(e - o, e);
4384
4385
  }
4385
4386
  function n() {
4386
- const o = Pr(t, e);
4387
- return e += Pr.bytes, o;
4387
+ const o = Ar(t, e);
4388
+ return e += Ar.bytes, o;
4388
4389
  }
4389
4390
  function s() {
4390
4391
  return r(n());
@@ -4397,7 +4398,7 @@ function Rn(t) {
4397
4398
  }
4398
4399
  return i();
4399
4400
  }
4400
- function Yi(t) {
4401
+ function $i(t) {
4401
4402
  let e = t & g.SIGHASH_ANYONECANPAY ? "SIGHASH_ANYONECANPAY | " : "";
4402
4403
  switch (t & 31) {
4403
4404
  case g.SIGHASH_ALL:
@@ -4412,7 +4413,7 @@ function Yi(t) {
4412
4413
  }
4413
4414
  return e;
4414
4415
  }
4415
- function Ce(t, e, r) {
4416
+ function Ne(t, e, r) {
4416
4417
  t.__NON_WITNESS_UTXO_BUF_CACHE[r] = e.nonWitnessUtxo, t.__NON_WITNESS_UTXO_TX_CACHE[r] = g.fromBuffer(e.nonWitnessUtxo);
4417
4418
  const n = t, s = r;
4418
4419
  delete e.nonWitnessUtxo, Object.defineProperty(e, "nonWitnessUtxo", {
@@ -4449,13 +4450,13 @@ function Fn(t, e, r, n, s) {
4449
4450
  }
4450
4451
  function le(t, e, r) {
4451
4452
  const n = t.__NON_WITNESS_UTXO_TX_CACHE;
4452
- return n[r] || Ce(t, e, r), n[r];
4453
+ return n[r] || Ne(t, e, r), n[r];
4453
4454
  }
4454
4455
  function Ln(t, e, r) {
4455
- const { script: n } = $e(t, e, r);
4456
+ const { script: n } = De(t, e, r);
4456
4457
  return n;
4457
4458
  }
4458
- function $e(t, e, r) {
4459
+ function De(t, e, r) {
4459
4460
  if (e.witnessUtxo !== void 0)
4460
4461
  return {
4461
4462
  script: e.witnessUtxo.script,
@@ -4467,32 +4468,32 @@ function $e(t, e, r) {
4467
4468
  } else
4468
4469
  throw new Error("Can't find pubkey in input without Utxo data");
4469
4470
  }
4470
- function Zi(t, e, r, n) {
4471
+ function qi(t, e, r, n) {
4471
4472
  const s = Ln(r, e, n), { meaningfulScript: i } = de(s, r, "input", e.redeemScript, e.witnessScript);
4472
4473
  return pe(t, i);
4473
4474
  }
4474
- function Qi(t, e, r, n) {
4475
+ function Xi(t, e, r, n) {
4475
4476
  const s = n.__TX.outs[r].script, { meaningfulScript: i } = de(s, r, "output", e.redeemScript, e.witnessScript);
4476
4477
  return pe(t, i);
4477
4478
  }
4478
- function Ji(t) {
4479
+ function ji(t) {
4479
4480
  if (!t)
4480
4481
  return;
4481
4482
  const e = A(t);
4482
4483
  if (!e)
4483
4484
  return;
4484
4485
  const r = e[e.length - 1];
4485
- if (!(!h.isBuffer(r) || Vn(r) || ro(r) || !A(r)))
4486
+ if (!(!h.isBuffer(r) || Vn(r) || Zi(r) || !A(r)))
4486
4487
  return r;
4487
4488
  }
4488
- function to(t) {
4489
+ function zi(t) {
4489
4490
  if (!t)
4490
4491
  return;
4491
4492
  const e = Rn(t), r = e[e.length - 1];
4492
4493
  if (!(Vn(r) || !A(r)))
4493
4494
  return r;
4494
4495
  }
4495
- function eo(t) {
4496
+ function Yi(t) {
4496
4497
  if (t.length === 65) {
4497
4498
  const e = t[64] & 1, r = h.from(t.subarray(0, 33));
4498
4499
  return r[0] = 2 | e, r;
@@ -4500,19 +4501,19 @@ function eo(t) {
4500
4501
  return h.from(t);
4501
4502
  }
4502
4503
  function Vn(t) {
4503
- return t.length === 33 && zr(t);
4504
+ return t.length === 33 && jr(t);
4504
4505
  }
4505
- function ro(t) {
4506
+ function Zi(t) {
4506
4507
  return Q(t);
4507
4508
  }
4508
4509
  function de(t, e, r, n, s) {
4509
- const i = On(t), o = i && n && _r(n), u = _r(t);
4510
+ const i = On(t), o = i && n && Sr(n), u = Sr(t);
4510
4511
  if (i && n === void 0)
4511
4512
  throw new Error("scriptPubkey is P2SH but redeemScript missing");
4512
4513
  if ((u || o) && s === void 0)
4513
4514
  throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
4514
4515
  let f;
4515
- return o ? (f = s, vr(e, t, n, r), xr(e, n, s, r), re(f)) : u ? (f = s, xr(e, t, s, r), re(f)) : i ? (f = n, vr(e, t, n, r)) : f = t, {
4516
+ return o ? (f = s, Hr(e, t, n, r), vr(e, n, s, r), re(f)) : u ? (f = s, vr(e, t, s, r), re(f)) : i ? (f = n, Hr(e, t, n, r)) : f = t, {
4516
4517
  meaningfulScript: f,
4517
4518
  type: o ? "p2sh-p2wsh" : i ? "p2sh" : u ? "p2wsh" : "raw"
4518
4519
  };
@@ -4522,57 +4523,57 @@ function re(t) {
4522
4523
  throw new Error("P2WPKH or P2SH can not be contained within P2WSH");
4523
4524
  }
4524
4525
  function Wn(t) {
4525
- return he(t) ? "witnesspubkeyhash" : mi(t) ? "pubkeyhash" : gi(t) ? "multisig" : yi(t) ? "pubkey" : "nonstandard";
4526
+ return he(t) ? "witnesspubkeyhash" : li(t) ? "pubkeyhash" : hi(t) ? "multisig" : pi(t) ? "pubkey" : "nonstandard";
4526
4527
  }
4527
4528
  function Ot(t) {
4528
4529
  return [...Array(t).keys()];
4529
4530
  }
4530
- const fo = {
4531
- payments: hi,
4532
- script: hs,
4533
- crypto: xs
4531
+ const no = {
4532
+ payments: oi,
4533
+ script: os,
4534
+ crypto: As
4534
4535
  };
4535
4536
  export {
4536
- so as A,
4537
+ Ji as A,
4537
4538
  An as B,
4538
4539
  Pn as C,
4539
- Di as D,
4540
- mi as E,
4540
+ Vi as D,
4541
+ li as E,
4541
4542
  he as F,
4542
- ni as G,
4543
- _r as H,
4543
+ Qs as G,
4544
+ Sr as H,
4544
4545
  On as I,
4545
- uo as J,
4546
- yi as K,
4547
- gi as L,
4548
- ke as M,
4549
- Hs as N,
4546
+ ro as J,
4547
+ pi as K,
4548
+ hi as L,
4549
+ Ue as M,
4550
+ Ts as N,
4550
4551
  K as P,
4551
4552
  g as T,
4552
4553
  Et as a,
4553
4554
  M as b,
4554
4555
  Lt as c,
4555
4556
  bt as d,
4556
- fo as e,
4557
+ no as e,
4557
4558
  v as f,
4558
- fi as g,
4559
- ci as h,
4560
- oo as i,
4559
+ ni as g,
4560
+ si as h,
4561
+ eo as i,
4561
4562
  mt as j,
4562
4563
  yt as k,
4563
- De as l,
4564
+ Me as l,
4564
4565
  A as m,
4565
- Be as n,
4566
+ Ce as n,
4566
4567
  E as o,
4567
4568
  Vt as p,
4568
- oi as q,
4569
- as as r,
4569
+ ei as q,
4570
+ is as r,
4570
4571
  Ie as s,
4571
4572
  Ht as t,
4572
4573
  it as u,
4573
4574
  C as v,
4574
- Is as w,
4575
- Zs as x,
4575
+ _s as w,
4576
+ qs as x,
4576
4577
  D as y,
4577
- io as z
4578
+ to as z
4578
4579
  };