@btc-vision/bitcoin 7.0.0-alpha.0 → 7.0.0-alpha.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.
- package/browser/address.d.ts +1 -1
- package/browser/address.d.ts.map +1 -1
- package/browser/block.d.ts.map +1 -1
- package/browser/crypto.d.ts +1 -1
- package/browser/ecc/context.d.ts +4 -4
- package/browser/ecc/context.d.ts.map +1 -1
- package/browser/ecc/types.d.ts +1 -1
- package/browser/ecc/types.d.ts.map +1 -1
- package/browser/index.d.ts +1 -1
- package/browser/index.d.ts.map +1 -1
- package/browser/index.js +648 -653
- package/browser/io/BinaryReader.d.ts +15 -15
- package/browser/io/BinaryReader.d.ts.map +1 -1
- package/browser/io/BinaryWriter.d.ts +17 -17
- package/browser/io/BinaryWriter.d.ts.map +1 -1
- package/browser/io/MemoryPool.d.ts +20 -20
- package/browser/io/MemoryPool.d.ts.map +1 -1
- package/browser/payments/bip341.d.ts +1 -1
- package/browser/payments/bip341.d.ts.map +1 -1
- package/browser/payments/embed.d.ts +1 -1
- package/browser/payments/embed.d.ts.map +1 -1
- package/browser/payments/p2ms.d.ts.map +1 -1
- package/browser/payments/p2op.d.ts +1 -1
- package/browser/payments/p2op.d.ts.map +1 -1
- package/browser/payments/p2pk.d.ts +1 -1
- package/browser/payments/p2pk.d.ts.map +1 -1
- package/browser/payments/p2pkh.d.ts +1 -1
- package/browser/payments/p2pkh.d.ts.map +1 -1
- package/browser/payments/p2sh.d.ts.map +1 -1
- package/browser/payments/p2tr.d.ts +2 -2
- package/browser/payments/p2tr.d.ts.map +1 -1
- package/browser/payments/p2wpkh.d.ts +1 -1
- package/browser/payments/p2wpkh.d.ts.map +1 -1
- package/browser/payments/p2wsh.d.ts.map +1 -1
- package/browser/payments/types.d.ts +1 -1
- package/browser/payments/types.d.ts.map +1 -1
- package/browser/psbt/bip371.d.ts.map +1 -1
- package/browser/psbt/types.d.ts +2 -2
- package/browser/psbt/types.d.ts.map +1 -1
- package/browser/psbt/validation.d.ts.map +1 -1
- package/browser/psbt.d.ts +1 -1
- package/browser/psbt.d.ts.map +1 -1
- package/browser/script.d.ts.map +1 -1
- package/browser/transaction.d.ts.map +1 -1
- package/browser/types.d.ts +1 -1
- package/browser/types.d.ts.map +1 -1
- package/browser/workers/WorkerSigningPool.d.ts +17 -17
- package/browser/workers/WorkerSigningPool.d.ts.map +1 -1
- package/browser/workers/WorkerSigningPool.node.d.ts +12 -12
- package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -1
- package/browser/workers/psbt-parallel.d.ts +1 -1
- package/browser/workers/psbt-parallel.d.ts.map +1 -1
- package/browser/workers/types.d.ts.map +1 -1
- package/build/address.d.ts +1 -1
- package/build/address.d.ts.map +1 -1
- package/build/address.js +3 -2
- package/build/address.js.map +1 -1
- package/build/block.d.ts.map +1 -1
- package/build/block.js +2 -4
- package/build/block.js.map +1 -1
- package/build/crypto.d.ts +1 -1
- package/build/ecc/context.d.ts +4 -4
- package/build/ecc/context.d.ts.map +1 -1
- package/build/ecc/context.js +7 -7
- package/build/ecc/context.js.map +1 -1
- package/build/ecc/types.d.ts +1 -1
- package/build/ecc/types.d.ts.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/io/BinaryReader.d.ts +15 -15
- package/build/io/BinaryReader.d.ts.map +1 -1
- package/build/io/BinaryReader.js +17 -17
- package/build/io/BinaryReader.js.map +1 -1
- package/build/io/BinaryWriter.d.ts +17 -17
- package/build/io/BinaryWriter.d.ts.map +1 -1
- package/build/io/BinaryWriter.js +39 -39
- package/build/io/BinaryWriter.js.map +1 -1
- package/build/io/MemoryPool.d.ts +20 -20
- package/build/io/MemoryPool.d.ts.map +1 -1
- package/build/io/MemoryPool.js +28 -28
- package/build/io/MemoryPool.js.map +1 -1
- package/build/payments/bip341.d.ts +1 -2
- package/build/payments/bip341.d.ts.map +1 -1
- package/build/payments/bip341.js +1 -2
- package/build/payments/bip341.js.map +1 -1
- package/build/payments/embed.d.ts +1 -1
- package/build/payments/embed.d.ts.map +1 -1
- package/build/payments/embed.js +14 -14
- package/build/payments/embed.js.map +1 -1
- package/build/payments/p2ms.d.ts.map +1 -1
- package/build/payments/p2ms.js +21 -21
- package/build/payments/p2ms.js.map +1 -1
- package/build/payments/p2op.d.ts +1 -1
- package/build/payments/p2op.d.ts.map +1 -1
- package/build/payments/p2op.js +18 -18
- package/build/payments/p2op.js.map +1 -1
- package/build/payments/p2pk.d.ts +1 -1
- package/build/payments/p2pk.d.ts.map +1 -1
- package/build/payments/p2pk.js +17 -17
- package/build/payments/p2pk.js.map +1 -1
- package/build/payments/p2pkh.d.ts +1 -1
- package/build/payments/p2pkh.d.ts.map +1 -1
- package/build/payments/p2pkh.js +20 -20
- package/build/payments/p2pkh.js.map +1 -1
- package/build/payments/p2sh.d.ts.map +1 -1
- package/build/payments/p2sh.js +22 -20
- package/build/payments/p2sh.js.map +1 -1
- package/build/payments/p2tr.d.ts +2 -2
- package/build/payments/p2tr.d.ts.map +1 -1
- package/build/payments/p2tr.js +23 -23
- package/build/payments/p2tr.js.map +1 -1
- package/build/payments/p2wpkh.d.ts +1 -1
- package/build/payments/p2wpkh.d.ts.map +1 -1
- package/build/payments/p2wpkh.js +20 -20
- package/build/payments/p2wpkh.js.map +1 -1
- package/build/payments/p2wsh.d.ts.map +1 -1
- package/build/payments/p2wsh.js +22 -22
- package/build/payments/p2wsh.js.map +1 -1
- package/build/payments/types.d.ts +1 -1
- package/build/payments/types.d.ts.map +1 -1
- package/build/psbt/bip371.d.ts.map +1 -1
- package/build/psbt/bip371.js +6 -2
- package/build/psbt/bip371.js.map +1 -1
- package/build/psbt/psbtutils.js +1 -1
- package/build/psbt/psbtutils.js.map +1 -1
- package/build/psbt/types.d.ts +2 -2
- package/build/psbt/types.d.ts.map +1 -1
- package/build/psbt/validation.d.ts.map +1 -1
- package/build/psbt/validation.js +1 -1
- package/build/psbt/validation.js.map +1 -1
- package/build/psbt.d.ts +1 -1
- package/build/psbt.d.ts.map +1 -1
- package/build/psbt.js +6 -12
- package/build/psbt.js.map +1 -1
- package/build/script.d.ts.map +1 -1
- package/build/script.js +2 -2
- package/build/script.js.map +1 -1
- package/build/transaction.d.ts.map +1 -1
- package/build/transaction.js +1 -1
- package/build/transaction.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/types.d.ts +1 -1
- package/build/types.d.ts.map +1 -1
- package/build/types.js +3 -9
- package/build/types.js.map +1 -1
- package/build/workers/WorkerSigningPool.d.ts +17 -17
- package/build/workers/WorkerSigningPool.d.ts.map +1 -1
- package/build/workers/WorkerSigningPool.js +25 -25
- package/build/workers/WorkerSigningPool.js.map +1 -1
- package/build/workers/WorkerSigningPool.node.d.ts +12 -12
- package/build/workers/WorkerSigningPool.node.d.ts.map +1 -1
- package/build/workers/WorkerSigningPool.node.js +23 -23
- package/build/workers/WorkerSigningPool.node.js.map +1 -1
- package/build/workers/psbt-parallel.d.ts +1 -1
- package/build/workers/psbt-parallel.d.ts.map +1 -1
- package/build/workers/psbt-parallel.js.map +1 -1
- package/build/workers/types.d.ts.map +1 -1
- package/build/workers/types.js.map +1 -1
- package/package.json +3 -2
- package/src/address.ts +13 -4
- package/src/block.ts +15 -8
- package/src/crypto.ts +1 -1
- package/src/ecc/context.ts +12 -9
- package/src/ecc/types.ts +1 -8
- package/src/index.ts +12 -13
- package/src/io/BinaryReader.ts +18 -18
- package/src/io/BinaryWriter.ts +43 -43
- package/src/io/MemoryPool.ts +32 -32
- package/src/payments/bip341.ts +2 -4
- package/src/payments/embed.ts +18 -18
- package/src/payments/p2ms.ts +32 -25
- package/src/payments/p2op.ts +22 -22
- package/src/payments/p2pk.ts +20 -20
- package/src/payments/p2pkh.ts +25 -25
- package/src/payments/p2sh.ts +30 -27
- package/src/payments/p2tr.ts +31 -31
- package/src/payments/p2wpkh.ts +25 -25
- package/src/payments/p2wsh.ts +27 -27
- package/src/payments/types.ts +1 -1
- package/src/psbt/bip371.ts +7 -3
- package/src/psbt/psbtutils.ts +1 -1
- package/src/psbt/types.ts +2 -9
- package/src/psbt/validation.ts +4 -11
- package/src/psbt.ts +107 -83
- package/src/script.ts +4 -7
- package/src/transaction.ts +9 -6
- package/src/types.ts +15 -17
- package/src/workers/WorkerSigningPool.node.ts +31 -31
- package/src/workers/WorkerSigningPool.ts +35 -39
- package/src/workers/psbt-parallel.ts +2 -7
- package/src/workers/types.ts +5 -1
- package/typedoc.json +29 -0
package/browser/index.js
CHANGED
|
@@ -851,23 +851,6 @@ class yr {
|
|
|
851
851
|
constructor(t, r = 0) {
|
|
852
852
|
this.#e = t, this.#o = new DataView(t.buffer, t.byteOffset, t.byteLength), this.#t = r;
|
|
853
853
|
}
|
|
854
|
-
/**
|
|
855
|
-
* Creates a BinaryReader from a hex string.
|
|
856
|
-
*
|
|
857
|
-
* @param hex - Hex string (with or without 0x prefix)
|
|
858
|
-
* @returns A new BinaryReader instance
|
|
859
|
-
*
|
|
860
|
-
* @example
|
|
861
|
-
* ```typescript
|
|
862
|
-
* import { BinaryReader } from '@btc-vision/bitcoin';
|
|
863
|
-
*
|
|
864
|
-
* const reader = BinaryReader.fromHex('01000000');
|
|
865
|
-
* const version = reader.readInt32LE(); // 1
|
|
866
|
-
* ```
|
|
867
|
-
*/
|
|
868
|
-
static fromHex(t) {
|
|
869
|
-
return new yr(J(t));
|
|
870
|
-
}
|
|
871
854
|
/**
|
|
872
855
|
* Current read position in the buffer.
|
|
873
856
|
*/
|
|
@@ -903,6 +886,23 @@ class yr {
|
|
|
903
886
|
get data() {
|
|
904
887
|
return this.#e;
|
|
905
888
|
}
|
|
889
|
+
/**
|
|
890
|
+
* Creates a BinaryReader from a hex string.
|
|
891
|
+
*
|
|
892
|
+
* @param hex - Hex string (with or without 0x prefix)
|
|
893
|
+
* @returns A new BinaryReader instance
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```typescript
|
|
897
|
+
* import { BinaryReader } from '@btc-vision/bitcoin';
|
|
898
|
+
*
|
|
899
|
+
* const reader = BinaryReader.fromHex('01000000');
|
|
900
|
+
* const version = reader.readInt32LE(); // 1
|
|
901
|
+
* ```
|
|
902
|
+
*/
|
|
903
|
+
static fromHex(t) {
|
|
904
|
+
return new yr(J(t));
|
|
905
|
+
}
|
|
906
906
|
/**
|
|
907
907
|
* Reads an 8-bit unsigned integer.
|
|
908
908
|
*
|
|
@@ -1187,25 +1187,6 @@ class V {
|
|
|
1187
1187
|
constructor(t, r = 0) {
|
|
1188
1188
|
typeof t == "number" ? (this.#e = new Uint8Array(t), this.#t = 0) : (this.#e = t, this.#t = r), this.#o = new DataView(this.#e.buffer, this.#e.byteOffset, this.#e.byteLength);
|
|
1189
1189
|
}
|
|
1190
|
-
/**
|
|
1191
|
-
* Creates a BinaryWriter with automatic capacity management.
|
|
1192
|
-
*
|
|
1193
|
-
* Initial capacity is 256 bytes, grows as needed.
|
|
1194
|
-
*
|
|
1195
|
-
* @returns A new GrowableBinaryWriter instance
|
|
1196
|
-
*
|
|
1197
|
-
* @example
|
|
1198
|
-
* ```typescript
|
|
1199
|
-
* import { BinaryWriter } from '@btc-vision/bitcoin';
|
|
1200
|
-
*
|
|
1201
|
-
* const writer = BinaryWriter.growable();
|
|
1202
|
-
* writer.writeUInt32LE(1);
|
|
1203
|
-
* writer.writeBytes(new Uint8Array(1000)); // Automatically grows
|
|
1204
|
-
* ```
|
|
1205
|
-
*/
|
|
1206
|
-
static growable(t = 256) {
|
|
1207
|
-
return new yh(t);
|
|
1208
|
-
}
|
|
1209
1190
|
/**
|
|
1210
1191
|
* Current write position in the buffer.
|
|
1211
1192
|
*/
|
|
@@ -1241,6 +1222,25 @@ class V {
|
|
|
1241
1222
|
get data() {
|
|
1242
1223
|
return this.#e;
|
|
1243
1224
|
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Creates a BinaryWriter with automatic capacity management.
|
|
1227
|
+
*
|
|
1228
|
+
* Initial capacity is 256 bytes, grows as needed.
|
|
1229
|
+
*
|
|
1230
|
+
* @returns A new GrowableBinaryWriter instance
|
|
1231
|
+
*
|
|
1232
|
+
* @example
|
|
1233
|
+
* ```typescript
|
|
1234
|
+
* import { BinaryWriter } from '@btc-vision/bitcoin';
|
|
1235
|
+
*
|
|
1236
|
+
* const writer = BinaryWriter.growable();
|
|
1237
|
+
* writer.writeUInt32LE(1);
|
|
1238
|
+
* writer.writeBytes(new Uint8Array(1000)); // Automatically grows
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
static growable(t = 256) {
|
|
1242
|
+
return new yh(t);
|
|
1243
|
+
}
|
|
1244
1244
|
/**
|
|
1245
1245
|
* Writes an 8-bit unsigned integer.
|
|
1246
1246
|
*
|
|
@@ -1569,21 +1569,6 @@ class yh {
|
|
|
1569
1569
|
get capacity() {
|
|
1570
1570
|
return this.#e.length;
|
|
1571
1571
|
}
|
|
1572
|
-
/**
|
|
1573
|
-
* Ensures the buffer has enough space for additional bytes.
|
|
1574
|
-
*
|
|
1575
|
-
* @param additionalBytes - Number of additional bytes needed
|
|
1576
|
-
*/
|
|
1577
|
-
#s(t) {
|
|
1578
|
-
const r = this.#t + t;
|
|
1579
|
-
if (r <= this.#e.length)
|
|
1580
|
-
return;
|
|
1581
|
-
let n = this.#e.length * 2;
|
|
1582
|
-
for (; n < r; )
|
|
1583
|
-
n *= 2;
|
|
1584
|
-
const i = new Uint8Array(n);
|
|
1585
|
-
i.set(this.#e.subarray(0, this.#t)), this.#e = i, this.#o = new DataView(this.#e.buffer);
|
|
1586
|
-
}
|
|
1587
1572
|
writeUInt8(t) {
|
|
1588
1573
|
return this.#s(1), this.#e[this.#t++] = t & 255, this;
|
|
1589
1574
|
}
|
|
@@ -1630,6 +1615,21 @@ class yh {
|
|
|
1630
1615
|
toHex() {
|
|
1631
1616
|
return gt(this.finish());
|
|
1632
1617
|
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Ensures the buffer has enough space for additional bytes.
|
|
1620
|
+
*
|
|
1621
|
+
* @param additionalBytes - Number of additional bytes needed
|
|
1622
|
+
*/
|
|
1623
|
+
#s(t) {
|
|
1624
|
+
const r = this.#t + t;
|
|
1625
|
+
if (r <= this.#e.length)
|
|
1626
|
+
return;
|
|
1627
|
+
let n = this.#e.length * 2;
|
|
1628
|
+
for (; n < r; )
|
|
1629
|
+
n *= 2;
|
|
1630
|
+
const i = new Uint8Array(n);
|
|
1631
|
+
i.set(this.#e.subarray(0, this.#t)), this.#e = i, this.#o = new DataView(this.#e.buffer);
|
|
1632
|
+
}
|
|
1633
1633
|
}
|
|
1634
1634
|
function mh(e) {
|
|
1635
1635
|
const t = atob(e), r = new Uint8Array(t.length);
|
|
@@ -1741,31 +1741,6 @@ class $i {
|
|
|
1741
1741
|
const r = t + 4;
|
|
1742
1742
|
this.#e = new SharedArrayBuffer(r), this.#o = new Uint8Array(this.#e, 0, t), this.#t = new Int32Array(this.#e, t, 1), this.#s = t;
|
|
1743
1743
|
}
|
|
1744
|
-
/**
|
|
1745
|
-
* Creates a MemoryPool from an existing SharedArrayBuffer.
|
|
1746
|
-
*
|
|
1747
|
-
* Useful for sharing a pool between Workers.
|
|
1748
|
-
*
|
|
1749
|
-
* @param buffer - Existing SharedArrayBuffer
|
|
1750
|
-
* @returns A new MemoryPool instance wrapping the buffer
|
|
1751
|
-
*
|
|
1752
|
-
* @example
|
|
1753
|
-
* ```typescript
|
|
1754
|
-
* // Main thread
|
|
1755
|
-
* const pool = new MemoryPool(1024 * 1024);
|
|
1756
|
-
* worker.postMessage({ buffer: pool.sharedBuffer });
|
|
1757
|
-
*
|
|
1758
|
-
* // Worker thread
|
|
1759
|
-
* self.onmessage = (e) => {
|
|
1760
|
-
* const pool = MemoryPool.fromSharedBuffer(e.data.buffer);
|
|
1761
|
-
* const mem = pool.alloc(100);
|
|
1762
|
-
* };
|
|
1763
|
-
* ```
|
|
1764
|
-
*/
|
|
1765
|
-
static fromSharedBuffer(t) {
|
|
1766
|
-
const r = Object.create($i.prototype), n = t.byteLength - 4;
|
|
1767
|
-
return Object.defineProperty(r, "#buffer", { value: t }), Object.defineProperty(r, "#data", { value: new Uint8Array(t, 0, n) }), Object.defineProperty(r, "#control", { value: new Int32Array(t, n, 1) }), Object.defineProperty(r, "#maxSize", { value: n }), r;
|
|
1768
|
-
}
|
|
1769
1744
|
/**
|
|
1770
1745
|
* Total capacity of the pool in bytes.
|
|
1771
1746
|
*/
|
|
@@ -1794,6 +1769,31 @@ class $i {
|
|
|
1794
1769
|
get sharedBuffer() {
|
|
1795
1770
|
return this.#e;
|
|
1796
1771
|
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Creates a MemoryPool from an existing SharedArrayBuffer.
|
|
1774
|
+
*
|
|
1775
|
+
* Useful for sharing a pool between Workers.
|
|
1776
|
+
*
|
|
1777
|
+
* @param buffer - Existing SharedArrayBuffer
|
|
1778
|
+
* @returns A new MemoryPool instance wrapping the buffer
|
|
1779
|
+
*
|
|
1780
|
+
* @example
|
|
1781
|
+
* ```typescript
|
|
1782
|
+
* // Main thread
|
|
1783
|
+
* const pool = new MemoryPool(1024 * 1024);
|
|
1784
|
+
* worker.postMessage({ buffer: pool.sharedBuffer });
|
|
1785
|
+
*
|
|
1786
|
+
* // Worker thread
|
|
1787
|
+
* self.onmessage = (e) => {
|
|
1788
|
+
* const pool = MemoryPool.fromSharedBuffer(e.data.buffer);
|
|
1789
|
+
* const mem = pool.alloc(100);
|
|
1790
|
+
* };
|
|
1791
|
+
* ```
|
|
1792
|
+
*/
|
|
1793
|
+
static fromSharedBuffer(t) {
|
|
1794
|
+
const r = Object.create($i.prototype), n = t.byteLength - 4;
|
|
1795
|
+
return Object.defineProperty(r, "#buffer", { value: t }), Object.defineProperty(r, "#data", { value: new Uint8Array(t, 0, n) }), Object.defineProperty(r, "#control", { value: new Int32Array(t, n, 1) }), Object.defineProperty(r, "#maxSize", { value: n }), r;
|
|
1796
|
+
}
|
|
1797
1797
|
/**
|
|
1798
1798
|
* Allocates memory from the pool.
|
|
1799
1799
|
*
|
|
@@ -3598,6 +3598,22 @@ class Xt {
|
|
|
3598
3598
|
return new Xt({ output: t, network: r });
|
|
3599
3599
|
}
|
|
3600
3600
|
// Private helper methods
|
|
3601
|
+
/**
|
|
3602
|
+
* Converts to a plain P2OPPayment object for backwards compatibility.
|
|
3603
|
+
*
|
|
3604
|
+
* @returns A P2OPPayment object
|
|
3605
|
+
*/
|
|
3606
|
+
toPayment() {
|
|
3607
|
+
return {
|
|
3608
|
+
name: this.name,
|
|
3609
|
+
network: this.network,
|
|
3610
|
+
address: this.address,
|
|
3611
|
+
program: this.program,
|
|
3612
|
+
deploymentVersion: this.deploymentVersion,
|
|
3613
|
+
hash160: this.hash160,
|
|
3614
|
+
output: this.output
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3601
3617
|
#b() {
|
|
3602
3618
|
if (!this.#E) {
|
|
3603
3619
|
if (this.#t) {
|
|
@@ -3612,6 +3628,7 @@ class Xt {
|
|
|
3612
3628
|
}
|
|
3613
3629
|
return this.#y;
|
|
3614
3630
|
}
|
|
3631
|
+
// Private computation methods
|
|
3615
3632
|
#S() {
|
|
3616
3633
|
if (typeof this.#r < "u" && typeof this.#n < "u") {
|
|
3617
3634
|
if (this.#n.length !== 20)
|
|
@@ -3621,7 +3638,6 @@ class Xt {
|
|
|
3621
3638
|
return lt([new Uint8Array([this.#r]), this.#n]);
|
|
3622
3639
|
}
|
|
3623
3640
|
}
|
|
3624
|
-
// Private computation methods
|
|
3625
3641
|
#A() {
|
|
3626
3642
|
if (this.#t)
|
|
3627
3643
|
return this.#t;
|
|
@@ -3667,6 +3683,7 @@ class Xt {
|
|
|
3667
3683
|
if (t)
|
|
3668
3684
|
return t.subarray(1);
|
|
3669
3685
|
}
|
|
3686
|
+
// Validation
|
|
3670
3687
|
#x() {
|
|
3671
3688
|
if (this.#i)
|
|
3672
3689
|
return this.#i;
|
|
@@ -3674,7 +3691,6 @@ class Xt {
|
|
|
3674
3691
|
if (t)
|
|
3675
3692
|
return Z([qn.OP_16, t]);
|
|
3676
3693
|
}
|
|
3677
|
-
// Validation
|
|
3678
3694
|
#k() {
|
|
3679
3695
|
let t = q(0);
|
|
3680
3696
|
if (this.#t) {
|
|
@@ -3713,22 +3729,6 @@ class Xt {
|
|
|
3713
3729
|
if (this.#n && !T(this.#n, t.subarray(1)))
|
|
3714
3730
|
throw new TypeError("hash160 mismatch");
|
|
3715
3731
|
}
|
|
3716
|
-
/**
|
|
3717
|
-
* Converts to a plain P2OPPayment object for backwards compatibility.
|
|
3718
|
-
*
|
|
3719
|
-
* @returns A P2OPPayment object
|
|
3720
|
-
*/
|
|
3721
|
-
toPayment() {
|
|
3722
|
-
return {
|
|
3723
|
-
name: this.name,
|
|
3724
|
-
network: this.network,
|
|
3725
|
-
address: this.address,
|
|
3726
|
-
program: this.program,
|
|
3727
|
-
deploymentVersion: this.deploymentVersion,
|
|
3728
|
-
hash160: this.hash160,
|
|
3729
|
-
output: this.output
|
|
3730
|
-
};
|
|
3731
|
-
}
|
|
3732
3732
|
}
|
|
3733
3733
|
function mn(e, t) {
|
|
3734
3734
|
if (!e.address && !e.output && !e.program && (typeof e.deploymentVersion > "u" || !e.hash160))
|
|
@@ -5179,6 +5179,24 @@ class qt {
|
|
|
5179
5179
|
return new qt({ output: t, network: r });
|
|
5180
5180
|
}
|
|
5181
5181
|
// Private helper methods
|
|
5182
|
+
/**
|
|
5183
|
+
* Converts to a plain P2PKHPayment object for backwards compatibility.
|
|
5184
|
+
*
|
|
5185
|
+
* @returns A P2PKHPayment object
|
|
5186
|
+
*/
|
|
5187
|
+
toPayment() {
|
|
5188
|
+
return {
|
|
5189
|
+
name: this.name,
|
|
5190
|
+
network: this.network,
|
|
5191
|
+
address: this.address,
|
|
5192
|
+
hash: this.hash,
|
|
5193
|
+
pubkey: this.pubkey,
|
|
5194
|
+
signature: this.signature,
|
|
5195
|
+
output: this.output,
|
|
5196
|
+
input: this.input,
|
|
5197
|
+
witness: this.witness
|
|
5198
|
+
};
|
|
5199
|
+
}
|
|
5182
5200
|
#U() {
|
|
5183
5201
|
if (!this.#x) {
|
|
5184
5202
|
if (this.#t) {
|
|
@@ -5192,10 +5210,10 @@ class qt {
|
|
|
5192
5210
|
}
|
|
5193
5211
|
return this.#I;
|
|
5194
5212
|
}
|
|
5213
|
+
// Private computation methods
|
|
5195
5214
|
#P() {
|
|
5196
5215
|
return this.#v || (this.#h && (this.#k = M(this.#h) ?? void 0), this.#v = !0), this.#k;
|
|
5197
5216
|
}
|
|
5198
|
-
// Private computation methods
|
|
5199
5217
|
#O() {
|
|
5200
5218
|
if (this.#t)
|
|
5201
5219
|
return this.#t;
|
|
@@ -5258,11 +5276,11 @@ class qt {
|
|
|
5258
5276
|
}
|
|
5259
5277
|
return Z([this.#n, t]);
|
|
5260
5278
|
}
|
|
5279
|
+
// Validation
|
|
5261
5280
|
#L() {
|
|
5262
5281
|
if (this.input)
|
|
5263
5282
|
return [];
|
|
5264
5283
|
}
|
|
5265
|
-
// Validation
|
|
5266
5284
|
#N() {
|
|
5267
5285
|
let t = new Uint8Array(0);
|
|
5268
5286
|
if (this.#t) {
|
|
@@ -5324,24 +5342,6 @@ class qt {
|
|
|
5324
5342
|
throw new TypeError("Hash mismatch (input)");
|
|
5325
5343
|
}
|
|
5326
5344
|
}
|
|
5327
|
-
/**
|
|
5328
|
-
* Converts to a plain P2PKHPayment object for backwards compatibility.
|
|
5329
|
-
*
|
|
5330
|
-
* @returns A P2PKHPayment object
|
|
5331
|
-
*/
|
|
5332
|
-
toPayment() {
|
|
5333
|
-
return {
|
|
5334
|
-
name: this.name,
|
|
5335
|
-
network: this.network,
|
|
5336
|
-
address: this.address,
|
|
5337
|
-
hash: this.hash,
|
|
5338
|
-
pubkey: this.pubkey,
|
|
5339
|
-
signature: this.signature,
|
|
5340
|
-
output: this.output,
|
|
5341
|
-
input: this.input,
|
|
5342
|
-
witness: this.witness
|
|
5343
|
-
};
|
|
5344
|
-
}
|
|
5345
5345
|
}
|
|
5346
5346
|
function Te(e, t) {
|
|
5347
5347
|
if (!e.address && !e.hash && !e.output && !e.pubkey && !e.input)
|
|
@@ -5519,6 +5519,23 @@ class Zt {
|
|
|
5519
5519
|
return new Zt({ output: t, network: r });
|
|
5520
5520
|
}
|
|
5521
5521
|
// Private helper methods
|
|
5522
|
+
/**
|
|
5523
|
+
* Converts to a plain P2SHPayment object for backwards compatibility.
|
|
5524
|
+
*
|
|
5525
|
+
* @returns A P2SHPayment object
|
|
5526
|
+
*/
|
|
5527
|
+
toPayment() {
|
|
5528
|
+
return {
|
|
5529
|
+
name: this.name,
|
|
5530
|
+
network: this.network,
|
|
5531
|
+
address: this.address,
|
|
5532
|
+
hash: this.hash,
|
|
5533
|
+
output: this.output,
|
|
5534
|
+
input: this.input,
|
|
5535
|
+
redeem: this.redeem,
|
|
5536
|
+
witness: this.witness
|
|
5537
|
+
};
|
|
5538
|
+
}
|
|
5522
5539
|
#k() {
|
|
5523
5540
|
if (!this.#A) {
|
|
5524
5541
|
if (this.#t) {
|
|
@@ -5535,6 +5552,7 @@ class Zt {
|
|
|
5535
5552
|
#v() {
|
|
5536
5553
|
return this.#T || (this.#n && (this.#m = M(this.#n) ?? void 0), this.#T = !0), this.#m;
|
|
5537
5554
|
}
|
|
5555
|
+
// Private computation methods
|
|
5538
5556
|
#U() {
|
|
5539
5557
|
if (!this.#x) {
|
|
5540
5558
|
const t = this.#v();
|
|
@@ -5551,7 +5569,6 @@ class Zt {
|
|
|
5551
5569
|
}
|
|
5552
5570
|
return this.#I;
|
|
5553
5571
|
}
|
|
5554
|
-
// Private computation methods
|
|
5555
5572
|
#P() {
|
|
5556
5573
|
if (this.#t)
|
|
5557
5574
|
return this.#t;
|
|
@@ -5583,7 +5600,9 @@ class Zt {
|
|
|
5583
5600
|
return this.#n;
|
|
5584
5601
|
const t = this.#i;
|
|
5585
5602
|
if (!(!t || !t.input || !t.output))
|
|
5586
|
-
return Z(
|
|
5603
|
+
return Z(
|
|
5604
|
+
[].concat(M(t.input), t.output)
|
|
5605
|
+
);
|
|
5587
5606
|
}
|
|
5588
5607
|
#H() {
|
|
5589
5608
|
if (this.#i)
|
|
@@ -5591,6 +5610,7 @@ class Zt {
|
|
|
5591
5610
|
if (this.#n)
|
|
5592
5611
|
return this.#U();
|
|
5593
5612
|
}
|
|
5613
|
+
// Validation
|
|
5594
5614
|
#R() {
|
|
5595
5615
|
if (this.#h)
|
|
5596
5616
|
return this.#h;
|
|
@@ -5600,7 +5620,6 @@ class Zt {
|
|
|
5600
5620
|
if (this.input)
|
|
5601
5621
|
return [];
|
|
5602
5622
|
}
|
|
5603
|
-
// Validation
|
|
5604
5623
|
#C(t) {
|
|
5605
5624
|
if (t.output) {
|
|
5606
5625
|
const r = M(t.output);
|
|
@@ -5684,23 +5703,6 @@ class Zt {
|
|
|
5684
5703
|
if (this.#h && this.#i && this.#i.witness && !Ae(this.#i.witness, this.#h))
|
|
5685
5704
|
throw new TypeError("Witness and redeem.witness mismatch");
|
|
5686
5705
|
}
|
|
5687
|
-
/**
|
|
5688
|
-
* Converts to a plain P2SHPayment object for backwards compatibility.
|
|
5689
|
-
*
|
|
5690
|
-
* @returns A P2SHPayment object
|
|
5691
|
-
*/
|
|
5692
|
-
toPayment() {
|
|
5693
|
-
return {
|
|
5694
|
-
name: this.name,
|
|
5695
|
-
network: this.network,
|
|
5696
|
-
address: this.address,
|
|
5697
|
-
hash: this.hash,
|
|
5698
|
-
output: this.output,
|
|
5699
|
-
input: this.input,
|
|
5700
|
-
redeem: this.redeem,
|
|
5701
|
-
witness: this.witness
|
|
5702
|
-
};
|
|
5703
|
-
}
|
|
5704
5706
|
}
|
|
5705
5707
|
function xe(e, t) {
|
|
5706
5708
|
if (!e.address && !e.hash && !e.output && !e.redeem && !e.input)
|
|
@@ -5725,6 +5727,12 @@ class mt {
|
|
|
5725
5727
|
constructor(t) {
|
|
5726
5728
|
this.#o = t;
|
|
5727
5729
|
}
|
|
5730
|
+
/**
|
|
5731
|
+
* The underlying ECC library instance.
|
|
5732
|
+
*/
|
|
5733
|
+
get lib() {
|
|
5734
|
+
return this.#o;
|
|
5735
|
+
}
|
|
5728
5736
|
/**
|
|
5729
5737
|
* Initializes the ECC context with the provided library.
|
|
5730
5738
|
* The library is verified before being set as active.
|
|
@@ -5797,12 +5805,6 @@ class mt {
|
|
|
5797
5805
|
static isInitialized() {
|
|
5798
5806
|
return mt.#e !== void 0;
|
|
5799
5807
|
}
|
|
5800
|
-
/**
|
|
5801
|
-
* The underlying ECC library instance.
|
|
5802
|
-
*/
|
|
5803
|
-
get lib() {
|
|
5804
|
-
return this.#o;
|
|
5805
|
-
}
|
|
5806
5808
|
}
|
|
5807
5809
|
function yl(e) {
|
|
5808
5810
|
if (e === void 0) {
|
|
@@ -5856,7 +5858,10 @@ function Ba(e) {
|
|
|
5856
5858
|
if (typeof e.xOnlyPointAddTweak != "function")
|
|
5857
5859
|
throw new Error("ECC library missing xOnlyPointAddTweak function");
|
|
5858
5860
|
for (const n of _a) {
|
|
5859
|
-
const i = e.xOnlyPointAddTweak(
|
|
5861
|
+
const i = e.xOnlyPointAddTweak(
|
|
5862
|
+
J(n.pubkey),
|
|
5863
|
+
J(n.tweak)
|
|
5864
|
+
);
|
|
5860
5865
|
if (n.result === null) {
|
|
5861
5866
|
if (i !== null)
|
|
5862
5867
|
throw new Error(
|
|
@@ -6135,6 +6140,27 @@ class Qt {
|
|
|
6135
6140
|
return new Qt({ signature: t, internalPubkey: r, network: n });
|
|
6136
6141
|
}
|
|
6137
6142
|
// Private helper methods
|
|
6143
|
+
/**
|
|
6144
|
+
* Converts to a plain P2TRPayment object for backwards compatibility.
|
|
6145
|
+
*
|
|
6146
|
+
* @returns A P2TRPayment object
|
|
6147
|
+
*/
|
|
6148
|
+
toPayment() {
|
|
6149
|
+
return {
|
|
6150
|
+
name: this.name,
|
|
6151
|
+
network: this.network,
|
|
6152
|
+
address: this.address,
|
|
6153
|
+
pubkey: this.pubkey,
|
|
6154
|
+
internalPubkey: this.internalPubkey,
|
|
6155
|
+
hash: this.hash,
|
|
6156
|
+
scriptTree: this.#i,
|
|
6157
|
+
signature: this.signature,
|
|
6158
|
+
output: this.output,
|
|
6159
|
+
redeem: this.redeem,
|
|
6160
|
+
redeemVersion: this.redeemVersion,
|
|
6161
|
+
witness: this.witness
|
|
6162
|
+
};
|
|
6163
|
+
}
|
|
6138
6164
|
#L() {
|
|
6139
6165
|
if (!this.#_) {
|
|
6140
6166
|
if (this.#t) {
|
|
@@ -6152,10 +6178,10 @@ class Qt {
|
|
|
6152
6178
|
#N() {
|
|
6153
6179
|
return this.#H || (this.#c && this.#c.length > 0 && (this.#c.length >= 2 && this.#c[this.#c.length - 1][0] === Na ? this.#B = this.#c.slice(0, -1) : this.#B = this.#c.slice()), this.#H = !0), this.#B;
|
|
6154
6180
|
}
|
|
6181
|
+
// Private computation methods
|
|
6155
6182
|
#M() {
|
|
6156
6183
|
return this.#C || (this.#i ? this.#R = ur(this.#i) : this.#n && (this.#R = { hash: this.#n }), this.#C = !0), this.#R;
|
|
6157
6184
|
}
|
|
6158
|
-
// Private computation methods
|
|
6159
6185
|
#K() {
|
|
6160
6186
|
if (this.#t)
|
|
6161
6187
|
return this.#t;
|
|
@@ -6226,6 +6252,7 @@ class Qt {
|
|
|
6226
6252
|
#j() {
|
|
6227
6253
|
return this.#f !== void 0 ? this.#f : this.#u && this.#u.redeemVersion !== void 0 && this.#u.redeemVersion !== null ? this.#u.redeemVersion : Ne;
|
|
6228
6254
|
}
|
|
6255
|
+
// Validation
|
|
6229
6256
|
#z() {
|
|
6230
6257
|
if (this.#c)
|
|
6231
6258
|
return this.#c;
|
|
@@ -6248,7 +6275,6 @@ class Qt {
|
|
|
6248
6275
|
if (this.#h)
|
|
6249
6276
|
return [this.#h];
|
|
6250
6277
|
}
|
|
6251
|
-
// Validation
|
|
6252
6278
|
#X() {
|
|
6253
6279
|
let t = new Uint8Array(0);
|
|
6254
6280
|
if (this.#t) {
|
|
@@ -6342,27 +6368,6 @@ class Qt {
|
|
|
6342
6368
|
throw new Error("Incorrect parity");
|
|
6343
6369
|
}
|
|
6344
6370
|
}
|
|
6345
|
-
/**
|
|
6346
|
-
* Converts to a plain P2TRPayment object for backwards compatibility.
|
|
6347
|
-
*
|
|
6348
|
-
* @returns A P2TRPayment object
|
|
6349
|
-
*/
|
|
6350
|
-
toPayment() {
|
|
6351
|
-
return {
|
|
6352
|
-
name: this.name,
|
|
6353
|
-
network: this.network,
|
|
6354
|
-
address: this.address,
|
|
6355
|
-
pubkey: this.pubkey,
|
|
6356
|
-
internalPubkey: this.internalPubkey,
|
|
6357
|
-
hash: this.hash,
|
|
6358
|
-
scriptTree: this.#i,
|
|
6359
|
-
signature: this.signature,
|
|
6360
|
-
output: this.output,
|
|
6361
|
-
redeem: this.redeem,
|
|
6362
|
-
redeemVersion: this.redeemVersion,
|
|
6363
|
-
witness: this.witness
|
|
6364
|
-
};
|
|
6365
|
-
}
|
|
6366
6371
|
}
|
|
6367
6372
|
function ke(e, t) {
|
|
6368
6373
|
if (!e.address && !e.output && !e.pubkey && !e.internalPubkey && !(e.witness && e.witness.length > 1))
|
|
@@ -6549,6 +6554,25 @@ class Jt {
|
|
|
6549
6554
|
return new Jt({ output: t, network: r });
|
|
6550
6555
|
}
|
|
6551
6556
|
// Private helper methods
|
|
6557
|
+
/**
|
|
6558
|
+
* Converts to a plain P2WPKHPayment object for backwards compatibility.
|
|
6559
|
+
*
|
|
6560
|
+
* @returns A P2WPKHPayment object
|
|
6561
|
+
*/
|
|
6562
|
+
toPayment() {
|
|
6563
|
+
return {
|
|
6564
|
+
name: this.name,
|
|
6565
|
+
network: this.network,
|
|
6566
|
+
address: this.address,
|
|
6567
|
+
hash: this.hash,
|
|
6568
|
+
pubkey: this.pubkey,
|
|
6569
|
+
signature: this.signature,
|
|
6570
|
+
output: this.output,
|
|
6571
|
+
input: this.input,
|
|
6572
|
+
witness: this.witness
|
|
6573
|
+
};
|
|
6574
|
+
}
|
|
6575
|
+
// Private computation methods
|
|
6552
6576
|
#I() {
|
|
6553
6577
|
if (!this.#T) {
|
|
6554
6578
|
if (this.#t) {
|
|
@@ -6563,7 +6587,6 @@ class Jt {
|
|
|
6563
6587
|
}
|
|
6564
6588
|
return this.#m;
|
|
6565
6589
|
}
|
|
6566
|
-
// Private computation methods
|
|
6567
6590
|
#x() {
|
|
6568
6591
|
if (this.#t)
|
|
6569
6592
|
return this.#t;
|
|
@@ -6606,13 +6629,13 @@ class Jt {
|
|
|
6606
6629
|
if (this.witness)
|
|
6607
6630
|
return La;
|
|
6608
6631
|
}
|
|
6632
|
+
// Validation
|
|
6609
6633
|
#_() {
|
|
6610
6634
|
if (this.#h)
|
|
6611
6635
|
return this.#h;
|
|
6612
6636
|
if (!(!this.#r || !this.#n))
|
|
6613
6637
|
return [this.#n, this.#r];
|
|
6614
6638
|
}
|
|
6615
|
-
// Validation
|
|
6616
6639
|
#B() {
|
|
6617
6640
|
let t = new Uint8Array(0);
|
|
6618
6641
|
if (this.#t) {
|
|
@@ -6662,24 +6685,6 @@ class Jt {
|
|
|
6662
6685
|
throw new TypeError("Hash mismatch");
|
|
6663
6686
|
}
|
|
6664
6687
|
}
|
|
6665
|
-
/**
|
|
6666
|
-
* Converts to a plain P2WPKHPayment object for backwards compatibility.
|
|
6667
|
-
*
|
|
6668
|
-
* @returns A P2WPKHPayment object
|
|
6669
|
-
*/
|
|
6670
|
-
toPayment() {
|
|
6671
|
-
return {
|
|
6672
|
-
name: this.name,
|
|
6673
|
-
network: this.network,
|
|
6674
|
-
address: this.address,
|
|
6675
|
-
hash: this.hash,
|
|
6676
|
-
pubkey: this.pubkey,
|
|
6677
|
-
signature: this.signature,
|
|
6678
|
-
output: this.output,
|
|
6679
|
-
input: this.input,
|
|
6680
|
-
witness: this.witness
|
|
6681
|
-
};
|
|
6682
|
-
}
|
|
6683
6688
|
}
|
|
6684
6689
|
function We(e, t) {
|
|
6685
6690
|
if (!e.address && !e.hash && !e.output && !e.pubkey && !e.witness)
|
|
@@ -6853,6 +6858,24 @@ class te {
|
|
|
6853
6858
|
return new te({ output: t, network: r });
|
|
6854
6859
|
}
|
|
6855
6860
|
// Private helper methods
|
|
6861
|
+
/**
|
|
6862
|
+
* Converts to a plain P2WSHPayment object for backwards compatibility.
|
|
6863
|
+
*
|
|
6864
|
+
* @returns A P2WSHPayment object
|
|
6865
|
+
*/
|
|
6866
|
+
toPayment() {
|
|
6867
|
+
const t = this.witness, r = this.redeem;
|
|
6868
|
+
return {
|
|
6869
|
+
name: this.name,
|
|
6870
|
+
network: this.network,
|
|
6871
|
+
address: this.address,
|
|
6872
|
+
hash: this.hash,
|
|
6873
|
+
output: this.output,
|
|
6874
|
+
input: this.input,
|
|
6875
|
+
redeem: r,
|
|
6876
|
+
witness: t
|
|
6877
|
+
};
|
|
6878
|
+
}
|
|
6856
6879
|
#T() {
|
|
6857
6880
|
if (!this.#S) {
|
|
6858
6881
|
if (this.#t) {
|
|
@@ -6867,10 +6890,10 @@ class te {
|
|
|
6867
6890
|
}
|
|
6868
6891
|
return this.#b;
|
|
6869
6892
|
}
|
|
6893
|
+
// Private computation methods
|
|
6870
6894
|
#I() {
|
|
6871
6895
|
return this.#m || (this.#n?.input && (this.#A = M(this.#n.input) ?? void 0), this.#m = !0), this.#A;
|
|
6872
6896
|
}
|
|
6873
|
-
// Private computation methods
|
|
6874
6897
|
#x() {
|
|
6875
6898
|
if (this.#t)
|
|
6876
6899
|
return this.#t;
|
|
@@ -6911,6 +6934,7 @@ class te {
|
|
|
6911
6934
|
witness: this.#i.slice(0, -1)
|
|
6912
6935
|
};
|
|
6913
6936
|
}
|
|
6937
|
+
// Validation
|
|
6914
6938
|
#O() {
|
|
6915
6939
|
if (this.#i)
|
|
6916
6940
|
return this.#i;
|
|
@@ -6926,7 +6950,6 @@ class te {
|
|
|
6926
6950
|
return !t.output || !t.witness ? void 0 : [].concat(t.witness, t.output);
|
|
6927
6951
|
}
|
|
6928
6952
|
}
|
|
6929
|
-
// Validation
|
|
6930
6953
|
#_() {
|
|
6931
6954
|
let t = new Uint8Array(0);
|
|
6932
6955
|
if (this.#t) {
|
|
@@ -6992,24 +7015,6 @@ class te {
|
|
|
6992
7015
|
throw new TypeError("Witness contains uncompressed pubkey");
|
|
6993
7016
|
}
|
|
6994
7017
|
}
|
|
6995
|
-
/**
|
|
6996
|
-
* Converts to a plain P2WSHPayment object for backwards compatibility.
|
|
6997
|
-
*
|
|
6998
|
-
* @returns A P2WSHPayment object
|
|
6999
|
-
*/
|
|
7000
|
-
toPayment() {
|
|
7001
|
-
const t = this.witness, r = this.redeem;
|
|
7002
|
-
return {
|
|
7003
|
-
name: this.name,
|
|
7004
|
-
network: this.network,
|
|
7005
|
-
address: this.address,
|
|
7006
|
-
hash: this.hash,
|
|
7007
|
-
output: this.output,
|
|
7008
|
-
input: this.input,
|
|
7009
|
-
redeem: r,
|
|
7010
|
-
witness: t
|
|
7011
|
-
};
|
|
7012
|
-
}
|
|
7013
7018
|
}
|
|
7014
7019
|
function Ue(e, t) {
|
|
7015
7020
|
if (!e.address && !e.hash && !e.output && !e.redeem && !e.witness)
|
|
@@ -7324,6 +7329,22 @@ class ge {
|
|
|
7324
7329
|
return new ge({ signature: t, pubkey: r, network: n });
|
|
7325
7330
|
}
|
|
7326
7331
|
// Private computation methods
|
|
7332
|
+
/**
|
|
7333
|
+
* Converts to a plain P2PKPayment object for backwards compatibility.
|
|
7334
|
+
*
|
|
7335
|
+
* @returns A P2PKPayment object
|
|
7336
|
+
*/
|
|
7337
|
+
toPayment() {
|
|
7338
|
+
return {
|
|
7339
|
+
name: this.name,
|
|
7340
|
+
network: this.network,
|
|
7341
|
+
pubkey: this.pubkey,
|
|
7342
|
+
signature: this.signature,
|
|
7343
|
+
output: this.output,
|
|
7344
|
+
input: this.input,
|
|
7345
|
+
witness: this.witness
|
|
7346
|
+
};
|
|
7347
|
+
}
|
|
7327
7348
|
#g() {
|
|
7328
7349
|
if (this.#t)
|
|
7329
7350
|
return this.#t;
|
|
@@ -7353,11 +7374,11 @@ class ge {
|
|
|
7353
7374
|
if (t)
|
|
7354
7375
|
return Z([t]);
|
|
7355
7376
|
}
|
|
7377
|
+
// Validation
|
|
7356
7378
|
#S() {
|
|
7357
7379
|
if (this.input)
|
|
7358
7380
|
return [];
|
|
7359
7381
|
}
|
|
7360
|
-
// Validation
|
|
7361
7382
|
#A() {
|
|
7362
7383
|
if (this.#r) {
|
|
7363
7384
|
if (this.#r[this.#r.length - 1] !== di.OP_CHECKSIG)
|
|
@@ -7382,22 +7403,6 @@ class ge {
|
|
|
7382
7403
|
throw new TypeError("Input has invalid signature");
|
|
7383
7404
|
}
|
|
7384
7405
|
}
|
|
7385
|
-
/**
|
|
7386
|
-
* Converts to a plain P2PKPayment object for backwards compatibility.
|
|
7387
|
-
*
|
|
7388
|
-
* @returns A P2PKPayment object
|
|
7389
|
-
*/
|
|
7390
|
-
toPayment() {
|
|
7391
|
-
return {
|
|
7392
|
-
name: this.name,
|
|
7393
|
-
network: this.network,
|
|
7394
|
-
pubkey: this.pubkey,
|
|
7395
|
-
signature: this.signature,
|
|
7396
|
-
output: this.output,
|
|
7397
|
-
input: this.input,
|
|
7398
|
-
witness: this.witness
|
|
7399
|
-
};
|
|
7400
|
-
}
|
|
7401
7406
|
}
|
|
7402
7407
|
function Tn(e, t) {
|
|
7403
7408
|
if (!e.input && !e.output && !e.pubkey && !e.signature)
|
|
@@ -7503,6 +7508,19 @@ class Me {
|
|
|
7503
7508
|
return new Me({ output: t, network: r });
|
|
7504
7509
|
}
|
|
7505
7510
|
// Private computation methods
|
|
7511
|
+
/**
|
|
7512
|
+
* Converts to a plain EmbedPayment object for backwards compatibility.
|
|
7513
|
+
*
|
|
7514
|
+
* @returns An EmbedPayment object
|
|
7515
|
+
*/
|
|
7516
|
+
toPayment() {
|
|
7517
|
+
return {
|
|
7518
|
+
name: this.name,
|
|
7519
|
+
network: this.network,
|
|
7520
|
+
data: this.data,
|
|
7521
|
+
output: this.output
|
|
7522
|
+
};
|
|
7523
|
+
}
|
|
7506
7524
|
#a() {
|
|
7507
7525
|
if (this.#t)
|
|
7508
7526
|
return this.#t;
|
|
@@ -7511,13 +7529,13 @@ class Me {
|
|
|
7511
7529
|
return t?.slice(1);
|
|
7512
7530
|
}
|
|
7513
7531
|
}
|
|
7532
|
+
// Validation
|
|
7514
7533
|
#c() {
|
|
7515
7534
|
if (this.#s)
|
|
7516
7535
|
return this.#s;
|
|
7517
7536
|
if (this.#t)
|
|
7518
7537
|
return Z([wi.OP_RETURN].concat(this.#t));
|
|
7519
7538
|
}
|
|
7520
|
-
// Validation
|
|
7521
7539
|
#u() {
|
|
7522
7540
|
if (this.#s) {
|
|
7523
7541
|
const t = M(this.#s);
|
|
@@ -7531,19 +7549,6 @@ class Me {
|
|
|
7531
7549
|
throw new TypeError("Data mismatch");
|
|
7532
7550
|
}
|
|
7533
7551
|
}
|
|
7534
|
-
/**
|
|
7535
|
-
* Converts to a plain EmbedPayment object for backwards compatibility.
|
|
7536
|
-
*
|
|
7537
|
-
* @returns An EmbedPayment object
|
|
7538
|
-
*/
|
|
7539
|
-
toPayment() {
|
|
7540
|
-
return {
|
|
7541
|
-
name: this.name,
|
|
7542
|
-
network: this.network,
|
|
7543
|
-
data: this.data,
|
|
7544
|
-
output: this.output
|
|
7545
|
-
};
|
|
7546
|
-
}
|
|
7547
7552
|
}
|
|
7548
7553
|
function Wa(e, t) {
|
|
7549
7554
|
if (!e.data && !e.output)
|
|
@@ -7711,10 +7716,28 @@ class ye {
|
|
|
7711
7716
|
return new ye({ signatures: t, m: r, pubkeys: n, network: i });
|
|
7712
7717
|
}
|
|
7713
7718
|
// Private helper methods
|
|
7719
|
+
/**
|
|
7720
|
+
* Converts to a plain P2MSPayment object for backwards compatibility.
|
|
7721
|
+
*
|
|
7722
|
+
* @returns A P2MSPayment object
|
|
7723
|
+
*/
|
|
7724
|
+
toPayment() {
|
|
7725
|
+
return {
|
|
7726
|
+
name: this.name,
|
|
7727
|
+
network: this.network,
|
|
7728
|
+
m: this.m,
|
|
7729
|
+
n: this.n,
|
|
7730
|
+
pubkeys: this.pubkeys,
|
|
7731
|
+
signatures: this.signatures,
|
|
7732
|
+
output: this.output,
|
|
7733
|
+
input: this.input,
|
|
7734
|
+
witness: this.witness
|
|
7735
|
+
};
|
|
7736
|
+
}
|
|
7737
|
+
// Private computation methods
|
|
7714
7738
|
#I(t) {
|
|
7715
7739
|
this.#T || (this.#T = !0, this.#m = M(t) ?? [], this.#a = this.#m[0] - qe, this.#c = this.#m[this.#m.length - 2] - qe, this.#u = this.#m.slice(1, -2), this.#p = !0, this.#g = !0, this.#y = !0);
|
|
7716
7740
|
}
|
|
7717
|
-
// Private computation methods
|
|
7718
7741
|
#x() {
|
|
7719
7742
|
if (this.#t !== void 0)
|
|
7720
7743
|
return this.#t;
|
|
@@ -7759,11 +7782,11 @@ class ye {
|
|
|
7759
7782
|
if (this.#n)
|
|
7760
7783
|
return Z([fe.OP_0].concat(this.#n));
|
|
7761
7784
|
}
|
|
7785
|
+
// Validation
|
|
7762
7786
|
#_() {
|
|
7763
7787
|
if (this.input)
|
|
7764
7788
|
return [];
|
|
7765
7789
|
}
|
|
7766
|
-
// Validation
|
|
7767
7790
|
#B(t) {
|
|
7768
7791
|
return oe(t) || this.#o.allowIncomplete && t === fe.OP_0;
|
|
7769
7792
|
}
|
|
@@ -7817,24 +7840,6 @@ class ye {
|
|
|
7817
7840
|
throw new TypeError("Signature count mismatch");
|
|
7818
7841
|
}
|
|
7819
7842
|
}
|
|
7820
|
-
/**
|
|
7821
|
-
* Converts to a plain P2MSPayment object for backwards compatibility.
|
|
7822
|
-
*
|
|
7823
|
-
* @returns A P2MSPayment object
|
|
7824
|
-
*/
|
|
7825
|
-
toPayment() {
|
|
7826
|
-
return {
|
|
7827
|
-
name: this.name,
|
|
7828
|
-
network: this.network,
|
|
7829
|
-
m: this.m,
|
|
7830
|
-
n: this.n,
|
|
7831
|
-
pubkeys: this.pubkeys,
|
|
7832
|
-
signatures: this.signatures,
|
|
7833
|
-
output: this.output,
|
|
7834
|
-
input: this.input,
|
|
7835
|
-
witness: this.witness
|
|
7836
|
-
};
|
|
7837
|
-
}
|
|
7838
7843
|
}
|
|
7839
7844
|
function Ge(e, t) {
|
|
7840
7845
|
if (!e.input && !e.output && !(e.pubkeys && e.m !== void 0) && !e.signatures)
|
|
@@ -7890,9 +7895,7 @@ function Va(e) {
|
|
|
7890
7895
|
const t = e.length;
|
|
7891
7896
|
return ft(t) + e.reduce((r, n) => r + pt(n), 0);
|
|
7892
7897
|
}
|
|
7893
|
-
const Vt = new Uint8Array(0), gi = [], Ze = J(
|
|
7894
|
-
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
7895
|
-
), yi = J("0000000000000000000000000000000000000000000000000000000000000001"), Da = 0xffffffffffffffffn;
|
|
7898
|
+
const Vt = new Uint8Array(0), gi = [], Ze = J("0000000000000000000000000000000000000000000000000000000000000000"), yi = J("0000000000000000000000000000000000000000000000000000000000000001"), Da = 0xffffffffffffffffn;
|
|
7896
7899
|
class v {
|
|
7897
7900
|
static DEFAULT_SEQUENCE = 4294967295;
|
|
7898
7901
|
static SIGHASH_DEFAULT = 0;
|
|
@@ -8125,7 +8128,9 @@ class v {
|
|
|
8125
8128
|
B.writeBytes(K.hash), B.writeUInt32LE(K.index);
|
|
8126
8129
|
}), E = rt(B.finish()), B = new V(8 * this.ins.length), n.forEach((K) => B.writeUInt64LE(K)), A = rt(B.finish()), B = new V(
|
|
8127
8130
|
r.map(pt).reduce((K, it) => K + it)
|
|
8128
|
-
), r.forEach(
|
|
8131
|
+
), r.forEach(
|
|
8132
|
+
(K) => B.writeVarBytes(K)
|
|
8133
|
+
), S = rt(B.finish()), B = new V(4 * this.ins.length), this.ins.forEach((K) => B.writeUInt32LE(K.sequence)), I = rt(B.finish());
|
|
8129
8134
|
}
|
|
8130
8135
|
if (l || y) {
|
|
8131
8136
|
if (y && t < this.outs.length) {
|
|
@@ -8316,7 +8321,52 @@ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
8316
8321
|
__proto__: null,
|
|
8317
8322
|
Transaction: v
|
|
8318
8323
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8319
|
-
|
|
8324
|
+
class bt extends Error {
|
|
8325
|
+
constructor(t) {
|
|
8326
|
+
super(t), this.name = "BitcoinError", Error.captureStackTrace && Error.captureStackTrace(this, bt);
|
|
8327
|
+
}
|
|
8328
|
+
}
|
|
8329
|
+
class ja extends bt {
|
|
8330
|
+
constructor(t) {
|
|
8331
|
+
super(t), this.name = "ValidationError";
|
|
8332
|
+
}
|
|
8333
|
+
}
|
|
8334
|
+
class za extends bt {
|
|
8335
|
+
constructor(t) {
|
|
8336
|
+
super(t), this.name = "InvalidInputError";
|
|
8337
|
+
}
|
|
8338
|
+
}
|
|
8339
|
+
class Xa extends bt {
|
|
8340
|
+
constructor(t) {
|
|
8341
|
+
super(t), this.name = "InvalidOutputError";
|
|
8342
|
+
}
|
|
8343
|
+
}
|
|
8344
|
+
class Ya extends bt {
|
|
8345
|
+
constructor(t) {
|
|
8346
|
+
super(t), this.name = "ScriptError";
|
|
8347
|
+
}
|
|
8348
|
+
}
|
|
8349
|
+
class qa extends bt {
|
|
8350
|
+
constructor(t) {
|
|
8351
|
+
super(t), this.name = "PsbtError";
|
|
8352
|
+
}
|
|
8353
|
+
}
|
|
8354
|
+
class Za extends bt {
|
|
8355
|
+
constructor(t) {
|
|
8356
|
+
super(t), this.name = "EccError";
|
|
8357
|
+
}
|
|
8358
|
+
}
|
|
8359
|
+
class Qa extends bt {
|
|
8360
|
+
constructor(t) {
|
|
8361
|
+
super(t), this.name = "AddressError";
|
|
8362
|
+
}
|
|
8363
|
+
}
|
|
8364
|
+
class Ja extends bt {
|
|
8365
|
+
constructor(t) {
|
|
8366
|
+
super(t), this.name = "SignatureError";
|
|
8367
|
+
}
|
|
8368
|
+
}
|
|
8369
|
+
function tu(e, t) {
|
|
8320
8370
|
if (!Array.isArray(e)) throw TypeError("Expected values Array");
|
|
8321
8371
|
if (typeof t != "function") throw TypeError("Expected digest Function");
|
|
8322
8372
|
let r = e.length;
|
|
@@ -8331,7 +8381,7 @@ function ja(e, t) {
|
|
|
8331
8381
|
}
|
|
8332
8382
|
return n[0];
|
|
8333
8383
|
}
|
|
8334
|
-
const $r = new TypeError("Cannot compute merkle root for zero transactions"), Wr = new TypeError("Cannot compute witness commit for non-segwit block"),
|
|
8384
|
+
const $r = new TypeError("Cannot compute merkle root for zero transactions"), Wr = new TypeError("Cannot compute witness commit for non-segwit block"), eu = J("6a24aa21a9ed");
|
|
8335
8385
|
class le {
|
|
8336
8386
|
/** Block version number */
|
|
8337
8387
|
version = 1;
|
|
@@ -8360,10 +8410,7 @@ class le {
|
|
|
8360
8410
|
const r = new yr(t), n = new le();
|
|
8361
8411
|
if (n.version = r.readInt32LE(), n.prevHash = r.readBytes(32), n.merkleRoot = r.readBytes(32), n.timestamp = r.readUInt32LE(), n.bits = r.readUInt32LE(), n.nonce = r.readUInt32LE(), t.length === 80) return n;
|
|
8362
8412
|
const i = () => {
|
|
8363
|
-
const f = v.fromBuffer(
|
|
8364
|
-
r.data.subarray(r.offset),
|
|
8365
|
-
!0
|
|
8366
|
-
);
|
|
8413
|
+
const f = v.fromBuffer(r.data.subarray(r.offset), !0);
|
|
8367
8414
|
return r.offset += f.byteLength(), f;
|
|
8368
8415
|
}, o = r.readVarInt();
|
|
8369
8416
|
n.transactions = [];
|
|
@@ -8403,7 +8450,7 @@ class le {
|
|
|
8403
8450
|
throw new TypeError("Expected an array of transactions");
|
|
8404
8451
|
if (t.length === 0) throw $r;
|
|
8405
8452
|
if (r && !mi(t)) throw Wr;
|
|
8406
|
-
const n = t.map((o) => o.getHash(r)), i =
|
|
8453
|
+
const n = t.map((o) => o.getHash(r)), i = tu(n, yt);
|
|
8407
8454
|
if (r) {
|
|
8408
8455
|
const o = t[0].ins[0].witness[0], a = new Uint8Array(i.length + o.length);
|
|
8409
8456
|
return a.set(i), a.set(o, i.length), yt(a);
|
|
@@ -8416,7 +8463,9 @@ class le {
|
|
|
8416
8463
|
*/
|
|
8417
8464
|
getWitnessCommit() {
|
|
8418
8465
|
if (!this.transactions || !mi(this.transactions)) return null;
|
|
8419
|
-
const t = this.transactions[0].outs.filter(
|
|
8466
|
+
const t = this.transactions[0].outs.filter(
|
|
8467
|
+
(n) => T(n.script.subarray(0, 6), eu)
|
|
8468
|
+
).map((n) => n.script.subarray(6, 38));
|
|
8420
8469
|
if (t.length === 0) return null;
|
|
8421
8470
|
const r = t[t.length - 1];
|
|
8422
8471
|
return r instanceof Uint8Array && r.length === 32 ? r : null;
|
|
@@ -8433,7 +8482,7 @@ class le {
|
|
|
8433
8482
|
* @returns True if any transaction has witness data
|
|
8434
8483
|
*/
|
|
8435
8484
|
hasWitness() {
|
|
8436
|
-
return this.transactions ?
|
|
8485
|
+
return this.transactions ? ru(this.transactions) : !1;
|
|
8437
8486
|
}
|
|
8438
8487
|
/**
|
|
8439
8488
|
* Calculates the weight of this block.
|
|
@@ -8530,7 +8579,7 @@ function mi(e) {
|
|
|
8530
8579
|
const t = e[0];
|
|
8531
8580
|
return t?.ins?.[0]?.witness ? t.ins[0].witness.length > 0 : !1;
|
|
8532
8581
|
}
|
|
8533
|
-
function
|
|
8582
|
+
function ru(e) {
|
|
8534
8583
|
return e.some(
|
|
8535
8584
|
(t) => t.ins?.some((r) => r.witness && r.witness.length > 0)
|
|
8536
8585
|
);
|
|
@@ -8551,10 +8600,10 @@ const fr = "0123456789abcdefABCDEF", lr = fr.split("").map((e) => e.codePointAt(
|
|
|
8551
8600
|
const r = String.fromCodePoint(t), n = fr.indexOf(r);
|
|
8552
8601
|
return n < 0 ? void 0 : n < 16 ? n : n - 6;
|
|
8553
8602
|
}), Ps = new TextEncoder(), Os = new TextDecoder();
|
|
8554
|
-
function
|
|
8603
|
+
function nu(e) {
|
|
8555
8604
|
return Os.decode(e);
|
|
8556
8605
|
}
|
|
8557
|
-
function
|
|
8606
|
+
function iu(e) {
|
|
8558
8607
|
return Ps.encode(e);
|
|
8559
8608
|
}
|
|
8560
8609
|
function Pt(e) {
|
|
@@ -8566,21 +8615,21 @@ function Pt(e) {
|
|
|
8566
8615
|
}
|
|
8567
8616
|
function H(e) {
|
|
8568
8617
|
const t = e || new Uint8Array();
|
|
8569
|
-
return t.length > 512 ?
|
|
8618
|
+
return t.length > 512 ? ou(t) : su(t);
|
|
8570
8619
|
}
|
|
8571
|
-
function
|
|
8620
|
+
function su(e) {
|
|
8572
8621
|
let t = "";
|
|
8573
8622
|
for (let r = 0; r < e.length; ++r)
|
|
8574
8623
|
t += fr[pr[lr[e[r] >> 4]]], t += fr[pr[lr[e[r] & 15]]];
|
|
8575
8624
|
return t;
|
|
8576
8625
|
}
|
|
8577
|
-
function
|
|
8626
|
+
function ou(e) {
|
|
8578
8627
|
const t = new Uint8Array(e.length * 2);
|
|
8579
8628
|
for (let r = 0; r < e.length; ++r)
|
|
8580
8629
|
t[r * 2] = lr[e[r] >> 4], t[r * 2 + 1] = lr[e[r] & 15];
|
|
8581
8630
|
return Os.decode(t);
|
|
8582
8631
|
}
|
|
8583
|
-
function
|
|
8632
|
+
function hu(e) {
|
|
8584
8633
|
const t = Ps.encode(e || ""), r = new Uint8Array(Math.floor(t.length / 2));
|
|
8585
8634
|
let n;
|
|
8586
8635
|
for (n = 0; n < r.length; n++) {
|
|
@@ -8591,10 +8640,10 @@ function Ja(e) {
|
|
|
8591
8640
|
}
|
|
8592
8641
|
return n === r.length ? r : r.slice(0, n);
|
|
8593
8642
|
}
|
|
8594
|
-
function
|
|
8643
|
+
function au(e) {
|
|
8595
8644
|
return btoa(String.fromCharCode(...e));
|
|
8596
8645
|
}
|
|
8597
|
-
function
|
|
8646
|
+
function uu(e) {
|
|
8598
8647
|
const t = atob(e), r = new Uint8Array(t.length);
|
|
8599
8648
|
for (let n = 0; n < t.length; n++)
|
|
8600
8649
|
r[n] = t.charCodeAt(n);
|
|
@@ -8630,14 +8679,14 @@ function xr(e, t, r) {
|
|
|
8630
8679
|
return n = (n << 8) + e[t] >>> 0, n = (n << 8) + e[t + 1] >>> 0, n = (n << 8) + e[t + 2] >>> 0, n = (n << 8) + e[t + 3] >>> 0, n;
|
|
8631
8680
|
}
|
|
8632
8681
|
}
|
|
8633
|
-
function
|
|
8682
|
+
function cu(e, t, r, n) {
|
|
8634
8683
|
if (t + 8 > e.length)
|
|
8635
8684
|
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
8636
8685
|
if (r > 0x7fffffffffffffffn || r < -0x8000000000000000n)
|
|
8637
8686
|
throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);
|
|
8638
8687
|
return n = n.toUpperCase(), n === "LE" ? (e[t] = Number(r & 0xffn), e[t + 1] = Number(r >> 8n & 0xffn), e[t + 2] = Number(r >> 16n & 0xffn), e[t + 3] = Number(r >> 24n & 0xffn), e[t + 4] = Number(r >> 32n & 0xffn), e[t + 5] = Number(r >> 40n & 0xffn), e[t + 6] = Number(r >> 48n & 0xffn), e[t + 7] = Number(r >> 56n & 0xffn)) : (e[t] = Number(r >> 56n & 0xffn), e[t + 1] = Number(r >> 48n & 0xffn), e[t + 2] = Number(r >> 40n & 0xffn), e[t + 3] = Number(r >> 32n & 0xffn), e[t + 4] = Number(r >> 24n & 0xffn), e[t + 5] = Number(r >> 16n & 0xffn), e[t + 6] = Number(r >> 8n & 0xffn), e[t + 7] = Number(r & 0xffn)), t + 8;
|
|
8639
8688
|
}
|
|
8640
|
-
function
|
|
8689
|
+
function fu(e, t, r) {
|
|
8641
8690
|
if (t + 8 > e.length)
|
|
8642
8691
|
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
8643
8692
|
r = r.toUpperCase();
|
|
@@ -8649,8 +8698,8 @@ function nu(e, t, r) {
|
|
|
8649
8698
|
return i = (i << 8n) + BigInt(e[t]), i = (i << 8n) + BigInt(e[t + 1]), i = (i << 8n) + BigInt(e[t + 2]), i = (i << 8n) + BigInt(e[t + 3]), i = (i << 8n) + BigInt(e[t + 4]), i = (i << 8n) + BigInt(e[t + 5]), i = (i << 8n) + BigInt(e[t + 6]), i = (i << 8n) + BigInt(e[t + 7]), e[t] <= 127 ? i : i - 0x10000000000000000n;
|
|
8650
8699
|
}
|
|
8651
8700
|
}
|
|
8652
|
-
const
|
|
8653
|
-
function
|
|
8701
|
+
const lu = (e) => [...Array(e).keys()];
|
|
8702
|
+
function pu(e) {
|
|
8654
8703
|
if (e.key[0] !== vt.GLOBAL_XPUB)
|
|
8655
8704
|
throw new Error(
|
|
8656
8705
|
"Decode Error: could not decode globalXpub with key 0x" + H(e.key)
|
|
@@ -8668,13 +8717,13 @@ function su(e) {
|
|
|
8668
8717
|
extendedPubkey: t,
|
|
8669
8718
|
path: "m"
|
|
8670
8719
|
};
|
|
8671
|
-
for (const n of
|
|
8720
|
+
for (const n of lu(e.value.length / 4 - 1)) {
|
|
8672
8721
|
const i = xr(e.value, n * 4 + 4, "LE"), o = !!(i & 2147483648), a = i & 2147483647;
|
|
8673
8722
|
r.path += "/" + a.toString(10) + (o ? "'" : "");
|
|
8674
8723
|
}
|
|
8675
8724
|
return r;
|
|
8676
8725
|
}
|
|
8677
|
-
function
|
|
8726
|
+
function du(e) {
|
|
8678
8727
|
const t = new Uint8Array([vt.GLOBAL_XPUB]), r = Pt([t, e.extendedPubkey]), n = e.path.split("/"), i = new Uint8Array(n.length * 4);
|
|
8679
8728
|
i.set(e.masterFingerprint, 0);
|
|
8680
8729
|
let o = 4;
|
|
@@ -8687,118 +8736,118 @@ function ou(e) {
|
|
|
8687
8736
|
value: i
|
|
8688
8737
|
};
|
|
8689
8738
|
}
|
|
8690
|
-
const
|
|
8691
|
-
function
|
|
8739
|
+
const wu = "{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";
|
|
8740
|
+
function gu(e) {
|
|
8692
8741
|
const t = e.extendedPubkey, r = e.masterFingerprint, n = e.path;
|
|
8693
8742
|
return t instanceof Uint8Array && t.length === 78 && [2, 3].indexOf(t[45]) > -1 && r instanceof Uint8Array && r.length === 4 && typeof n == "string" && !!n.match(/^m(\/\d+'?)*$/);
|
|
8694
8743
|
}
|
|
8695
|
-
function
|
|
8744
|
+
function yu(e, t, r) {
|
|
8696
8745
|
const n = H(t.extendedPubkey);
|
|
8697
8746
|
return r.has(n) ? !1 : (r.add(n), e.filter((i) => Ot(i.extendedPubkey, t.extendedPubkey)).length === 0);
|
|
8698
8747
|
}
|
|
8699
|
-
const
|
|
8748
|
+
const mu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8700
8749
|
__proto__: null,
|
|
8701
|
-
canAddToArray:
|
|
8702
|
-
check:
|
|
8703
|
-
decode:
|
|
8704
|
-
encode:
|
|
8705
|
-
expected:
|
|
8750
|
+
canAddToArray: yu,
|
|
8751
|
+
check: gu,
|
|
8752
|
+
decode: pu,
|
|
8753
|
+
encode: du,
|
|
8754
|
+
expected: wu
|
|
8706
8755
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8707
|
-
function
|
|
8756
|
+
function Eu(e) {
|
|
8708
8757
|
return {
|
|
8709
8758
|
key: new Uint8Array([vt.UNSIGNED_TX]),
|
|
8710
8759
|
value: e.toBuffer()
|
|
8711
8760
|
};
|
|
8712
8761
|
}
|
|
8713
|
-
const
|
|
8762
|
+
const bu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8714
8763
|
__proto__: null,
|
|
8715
|
-
encode:
|
|
8764
|
+
encode: Eu
|
|
8716
8765
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8717
|
-
function
|
|
8766
|
+
function Su(e) {
|
|
8718
8767
|
if (e.key[0] !== x.FINAL_SCRIPTSIG)
|
|
8719
8768
|
throw new Error(
|
|
8720
8769
|
"Decode Error: could not decode finalScriptSig with key 0x" + H(e.key)
|
|
8721
8770
|
);
|
|
8722
8771
|
return e.value;
|
|
8723
8772
|
}
|
|
8724
|
-
function
|
|
8773
|
+
function Au(e) {
|
|
8725
8774
|
return {
|
|
8726
8775
|
key: new Uint8Array([x.FINAL_SCRIPTSIG]),
|
|
8727
8776
|
value: e
|
|
8728
8777
|
};
|
|
8729
8778
|
}
|
|
8730
|
-
const
|
|
8731
|
-
function
|
|
8779
|
+
const Iu = "Uint8Array";
|
|
8780
|
+
function Tu(e) {
|
|
8732
8781
|
return e instanceof Uint8Array;
|
|
8733
8782
|
}
|
|
8734
|
-
function
|
|
8783
|
+
function xu(e, t) {
|
|
8735
8784
|
return !!e && !!t && e.finalScriptSig === void 0;
|
|
8736
8785
|
}
|
|
8737
|
-
const
|
|
8786
|
+
const ku = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8738
8787
|
__proto__: null,
|
|
8739
|
-
canAdd:
|
|
8740
|
-
check:
|
|
8741
|
-
decode:
|
|
8742
|
-
encode:
|
|
8743
|
-
expected:
|
|
8788
|
+
canAdd: xu,
|
|
8789
|
+
check: Tu,
|
|
8790
|
+
decode: Su,
|
|
8791
|
+
encode: Au,
|
|
8792
|
+
expected: Iu
|
|
8744
8793
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8745
|
-
function
|
|
8794
|
+
function Uu(e) {
|
|
8746
8795
|
if (e.key[0] !== x.FINAL_SCRIPTWITNESS)
|
|
8747
8796
|
throw new Error(
|
|
8748
8797
|
"Decode Error: could not decode finalScriptWitness with key 0x" + H(e.key)
|
|
8749
8798
|
);
|
|
8750
8799
|
return e.value;
|
|
8751
8800
|
}
|
|
8752
|
-
function
|
|
8801
|
+
function vu(e) {
|
|
8753
8802
|
return {
|
|
8754
8803
|
key: new Uint8Array([x.FINAL_SCRIPTWITNESS]),
|
|
8755
8804
|
value: e
|
|
8756
8805
|
};
|
|
8757
8806
|
}
|
|
8758
|
-
const
|
|
8759
|
-
function
|
|
8807
|
+
const Pu = "Uint8Array";
|
|
8808
|
+
function Ou(e) {
|
|
8760
8809
|
return e instanceof Uint8Array;
|
|
8761
8810
|
}
|
|
8762
|
-
function
|
|
8811
|
+
function _u(e, t) {
|
|
8763
8812
|
return !!e && !!t && e.finalScriptWitness === void 0;
|
|
8764
8813
|
}
|
|
8765
|
-
const
|
|
8814
|
+
const Bu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8766
8815
|
__proto__: null,
|
|
8767
|
-
canAdd:
|
|
8768
|
-
check:
|
|
8769
|
-
decode:
|
|
8770
|
-
encode:
|
|
8771
|
-
expected:
|
|
8816
|
+
canAdd: _u,
|
|
8817
|
+
check: Ou,
|
|
8818
|
+
decode: Uu,
|
|
8819
|
+
encode: vu,
|
|
8820
|
+
expected: Pu
|
|
8772
8821
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8773
|
-
function
|
|
8822
|
+
function Hu(e) {
|
|
8774
8823
|
if (e.key[0] !== x.NON_WITNESS_UTXO)
|
|
8775
8824
|
throw new Error(
|
|
8776
8825
|
"Decode Error: could not decode nonWitnessUtxo with key 0x" + H(e.key)
|
|
8777
8826
|
);
|
|
8778
8827
|
return e.value;
|
|
8779
8828
|
}
|
|
8780
|
-
function
|
|
8829
|
+
function Ru(e) {
|
|
8781
8830
|
return {
|
|
8782
8831
|
key: new Uint8Array([x.NON_WITNESS_UTXO]),
|
|
8783
8832
|
value: e
|
|
8784
8833
|
};
|
|
8785
8834
|
}
|
|
8786
|
-
const
|
|
8787
|
-
function
|
|
8835
|
+
const Cu = "Uint8Array";
|
|
8836
|
+
function Nu(e) {
|
|
8788
8837
|
return e instanceof Uint8Array;
|
|
8789
8838
|
}
|
|
8790
|
-
function
|
|
8839
|
+
function Lu(e, t) {
|
|
8791
8840
|
return !!e && !!t && e.nonWitnessUtxo === void 0;
|
|
8792
8841
|
}
|
|
8793
|
-
const
|
|
8842
|
+
const Mu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8794
8843
|
__proto__: null,
|
|
8795
|
-
canAdd:
|
|
8796
|
-
check:
|
|
8797
|
-
decode:
|
|
8798
|
-
encode:
|
|
8799
|
-
expected:
|
|
8844
|
+
canAdd: Lu,
|
|
8845
|
+
check: Nu,
|
|
8846
|
+
decode: Hu,
|
|
8847
|
+
encode: Ru,
|
|
8848
|
+
expected: Cu
|
|
8800
8849
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8801
|
-
function
|
|
8850
|
+
function Ku(e) {
|
|
8802
8851
|
if (e.key[0] !== x.PARTIAL_SIG)
|
|
8803
8852
|
throw new Error(
|
|
8804
8853
|
"Decode Error: could not decode partialSig with key 0x" + H(e.key)
|
|
@@ -8812,94 +8861,94 @@ function _u(e) {
|
|
|
8812
8861
|
signature: e.value
|
|
8813
8862
|
};
|
|
8814
8863
|
}
|
|
8815
|
-
function
|
|
8864
|
+
function $u(e) {
|
|
8816
8865
|
const t = new Uint8Array([x.PARTIAL_SIG]);
|
|
8817
8866
|
return {
|
|
8818
8867
|
key: Pt([t, e.pubkey]),
|
|
8819
8868
|
value: e.signature
|
|
8820
8869
|
};
|
|
8821
8870
|
}
|
|
8822
|
-
const
|
|
8823
|
-
function
|
|
8824
|
-
return e.pubkey instanceof Uint8Array && e.signature instanceof Uint8Array && [33, 65].includes(e.pubkey.length) && [2, 3, 4].includes(e.pubkey[0]) &&
|
|
8871
|
+
const Wu = "{ pubkey: Uint8Array; signature: Uint8Array; }";
|
|
8872
|
+
function Fu(e) {
|
|
8873
|
+
return e.pubkey instanceof Uint8Array && e.signature instanceof Uint8Array && [33, 65].includes(e.pubkey.length) && [2, 3, 4].includes(e.pubkey[0]) && Vu(e.signature);
|
|
8825
8874
|
}
|
|
8826
|
-
function
|
|
8875
|
+
function Vu(e) {
|
|
8827
8876
|
if (!(e instanceof Uint8Array) || e.length < 9 || e[0] !== 48 || e.length !== e[1] + 3 || e[2] !== 2) return !1;
|
|
8828
8877
|
const t = e[3];
|
|
8829
8878
|
if (t > 33 || t < 1 || e[3 + t + 1] !== 2) return !1;
|
|
8830
8879
|
const r = e[3 + t + 2];
|
|
8831
8880
|
return !(r > 33 || r < 1 || e.length !== 3 + t + 2 + r + 2);
|
|
8832
8881
|
}
|
|
8833
|
-
function
|
|
8882
|
+
function Du(e, t, r) {
|
|
8834
8883
|
const n = H(t.pubkey);
|
|
8835
8884
|
return r.has(n) ? !1 : (r.add(n), e.filter((i) => Ot(i.pubkey, t.pubkey) === 0).length === 0);
|
|
8836
8885
|
}
|
|
8837
|
-
const
|
|
8886
|
+
const Gu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8838
8887
|
__proto__: null,
|
|
8839
|
-
canAddToArray:
|
|
8840
|
-
check:
|
|
8841
|
-
decode:
|
|
8842
|
-
encode:
|
|
8843
|
-
expected:
|
|
8888
|
+
canAddToArray: Du,
|
|
8889
|
+
check: Fu,
|
|
8890
|
+
decode: Ku,
|
|
8891
|
+
encode: $u,
|
|
8892
|
+
expected: Wu
|
|
8844
8893
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8845
|
-
function
|
|
8894
|
+
function ju(e) {
|
|
8846
8895
|
if (e.key[0] !== x.POR_COMMITMENT)
|
|
8847
8896
|
throw new Error(
|
|
8848
8897
|
"Decode Error: could not decode porCommitment with key 0x" + H(e.key)
|
|
8849
8898
|
);
|
|
8850
|
-
return
|
|
8899
|
+
return nu(e.value);
|
|
8851
8900
|
}
|
|
8852
|
-
function
|
|
8901
|
+
function zu(e) {
|
|
8853
8902
|
return {
|
|
8854
8903
|
key: new Uint8Array([x.POR_COMMITMENT]),
|
|
8855
|
-
value:
|
|
8904
|
+
value: iu(e)
|
|
8856
8905
|
};
|
|
8857
8906
|
}
|
|
8858
|
-
const
|
|
8859
|
-
function
|
|
8907
|
+
const Xu = "string";
|
|
8908
|
+
function Yu(e) {
|
|
8860
8909
|
return typeof e == "string";
|
|
8861
8910
|
}
|
|
8862
|
-
function
|
|
8911
|
+
function qu(e, t) {
|
|
8863
8912
|
return !!e && !!t && e.porCommitment === void 0;
|
|
8864
8913
|
}
|
|
8865
|
-
const
|
|
8914
|
+
const Zu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8866
8915
|
__proto__: null,
|
|
8867
|
-
canAdd:
|
|
8868
|
-
check:
|
|
8869
|
-
decode:
|
|
8870
|
-
encode:
|
|
8871
|
-
expected:
|
|
8916
|
+
canAdd: qu,
|
|
8917
|
+
check: Yu,
|
|
8918
|
+
decode: ju,
|
|
8919
|
+
encode: zu,
|
|
8920
|
+
expected: Xu
|
|
8872
8921
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8873
|
-
function
|
|
8922
|
+
function Qu(e) {
|
|
8874
8923
|
if (e.key[0] !== x.SIGHASH_TYPE)
|
|
8875
8924
|
throw new Error(
|
|
8876
8925
|
"Decode Error: could not decode sighashType with key 0x" + H(e.key)
|
|
8877
8926
|
);
|
|
8878
8927
|
return Number(xr(e.value, 0, "LE"));
|
|
8879
8928
|
}
|
|
8880
|
-
function
|
|
8929
|
+
function Ju(e) {
|
|
8881
8930
|
const t = Uint8Array.from([x.SIGHASH_TYPE]), r = new Uint8Array(4);
|
|
8882
8931
|
return xn(r, 0, e, "LE"), {
|
|
8883
8932
|
key: t,
|
|
8884
8933
|
value: r
|
|
8885
8934
|
};
|
|
8886
8935
|
}
|
|
8887
|
-
const
|
|
8888
|
-
function
|
|
8936
|
+
const tc = "number";
|
|
8937
|
+
function ec(e) {
|
|
8889
8938
|
return typeof e == "number";
|
|
8890
8939
|
}
|
|
8891
|
-
function
|
|
8940
|
+
function rc(e, t) {
|
|
8892
8941
|
return !!e && !!t && e.sighashType === void 0;
|
|
8893
8942
|
}
|
|
8894
|
-
const
|
|
8943
|
+
const nc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8895
8944
|
__proto__: null,
|
|
8896
|
-
canAdd:
|
|
8897
|
-
check:
|
|
8898
|
-
decode:
|
|
8899
|
-
encode:
|
|
8900
|
-
expected:
|
|
8945
|
+
canAdd: rc,
|
|
8946
|
+
check: ec,
|
|
8947
|
+
decode: Qu,
|
|
8948
|
+
encode: Ju,
|
|
8949
|
+
expected: tc
|
|
8901
8950
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8902
|
-
function
|
|
8951
|
+
function ic(e) {
|
|
8903
8952
|
if (e.key[0] !== x.TAP_KEY_SIG || e.key.length !== 1)
|
|
8904
8953
|
throw new Error(
|
|
8905
8954
|
"Decode Error: could not decode tapKeySig with key 0x" + H(e.key)
|
|
@@ -8910,25 +8959,25 @@ function qu(e) {
|
|
|
8910
8959
|
);
|
|
8911
8960
|
return e.value;
|
|
8912
8961
|
}
|
|
8913
|
-
function
|
|
8962
|
+
function sc(e) {
|
|
8914
8963
|
return { key: Uint8Array.from([x.TAP_KEY_SIG]), value: e };
|
|
8915
8964
|
}
|
|
8916
|
-
const
|
|
8965
|
+
const oc = "Uint8Array";
|
|
8917
8966
|
function _s(e) {
|
|
8918
8967
|
return e instanceof Uint8Array && (e.length === 64 || e.length === 65);
|
|
8919
8968
|
}
|
|
8920
|
-
function
|
|
8969
|
+
function hc(e, t) {
|
|
8921
8970
|
return !!e && !!t && e.tapKeySig === void 0;
|
|
8922
8971
|
}
|
|
8923
|
-
const
|
|
8972
|
+
const ac = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8924
8973
|
__proto__: null,
|
|
8925
|
-
canAdd:
|
|
8974
|
+
canAdd: hc,
|
|
8926
8975
|
check: _s,
|
|
8927
|
-
decode:
|
|
8928
|
-
encode:
|
|
8929
|
-
expected:
|
|
8976
|
+
decode: ic,
|
|
8977
|
+
encode: sc,
|
|
8978
|
+
expected: oc
|
|
8930
8979
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8931
|
-
function
|
|
8980
|
+
function uc(e) {
|
|
8932
8981
|
if (e.key[0] !== x.TAP_LEAF_SCRIPT)
|
|
8933
8982
|
throw new Error(
|
|
8934
8983
|
"Decode Error: could not decode tapLeafScript with key 0x" + H(e.key)
|
|
@@ -8945,30 +8994,30 @@ function ec(e) {
|
|
|
8945
8994
|
const r = e.value.slice(0, -1);
|
|
8946
8995
|
return { controlBlock: e.key.slice(1), script: r, leafVersion: t };
|
|
8947
8996
|
}
|
|
8948
|
-
function
|
|
8997
|
+
function cc(e) {
|
|
8949
8998
|
const t = Uint8Array.from([x.TAP_LEAF_SCRIPT]), r = Uint8Array.from([e.leafVersion]);
|
|
8950
8999
|
return {
|
|
8951
9000
|
key: Pt([t, e.controlBlock]),
|
|
8952
9001
|
value: Pt([e.script, r])
|
|
8953
9002
|
};
|
|
8954
9003
|
}
|
|
8955
|
-
const
|
|
8956
|
-
function
|
|
9004
|
+
const fc = "{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";
|
|
9005
|
+
function lc(e) {
|
|
8957
9006
|
return e.controlBlock instanceof Uint8Array && (e.controlBlock.length - 1) % 32 === 0 && (e.controlBlock[0] & 254) === e.leafVersion && e.script instanceof Uint8Array;
|
|
8958
9007
|
}
|
|
8959
|
-
function
|
|
9008
|
+
function pc(e, t, r) {
|
|
8960
9009
|
const n = H(t.controlBlock);
|
|
8961
9010
|
return r.has(n) ? !1 : (r.add(n), e.filter((i) => Ot(i.controlBlock, t.controlBlock) === 0).length === 0);
|
|
8962
9011
|
}
|
|
8963
|
-
const
|
|
9012
|
+
const dc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8964
9013
|
__proto__: null,
|
|
8965
|
-
canAddToArray:
|
|
8966
|
-
check:
|
|
8967
|
-
decode:
|
|
8968
|
-
encode:
|
|
8969
|
-
expected:
|
|
9014
|
+
canAddToArray: pc,
|
|
9015
|
+
check: lc,
|
|
9016
|
+
decode: uc,
|
|
9017
|
+
encode: cc,
|
|
9018
|
+
expected: fc
|
|
8970
9019
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8971
|
-
function
|
|
9020
|
+
function wc(e) {
|
|
8972
9021
|
if (e.key[0] !== x.TAP_MERKLE_ROOT || e.key.length !== 1)
|
|
8973
9022
|
throw new Error(
|
|
8974
9023
|
"Decode Error: could not decode tapMerkleRoot with key 0x" + H(e.key)
|
|
@@ -8977,25 +9026,25 @@ function hc(e) {
|
|
|
8977
9026
|
throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");
|
|
8978
9027
|
return e.value;
|
|
8979
9028
|
}
|
|
8980
|
-
function
|
|
9029
|
+
function gc(e) {
|
|
8981
9030
|
return { key: Uint8Array.from([x.TAP_MERKLE_ROOT]), value: e };
|
|
8982
9031
|
}
|
|
8983
|
-
const
|
|
9032
|
+
const yc = "Uint8Array";
|
|
8984
9033
|
function Bs(e) {
|
|
8985
9034
|
return e instanceof Uint8Array && e.length === 32;
|
|
8986
9035
|
}
|
|
8987
|
-
function
|
|
9036
|
+
function mc(e, t) {
|
|
8988
9037
|
return !!e && !!t && e.tapMerkleRoot === void 0;
|
|
8989
9038
|
}
|
|
8990
|
-
const
|
|
9039
|
+
const Ec = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8991
9040
|
__proto__: null,
|
|
8992
|
-
canAdd:
|
|
9041
|
+
canAdd: mc,
|
|
8993
9042
|
check: Bs,
|
|
8994
|
-
decode:
|
|
8995
|
-
encode:
|
|
8996
|
-
expected:
|
|
9043
|
+
decode: wc,
|
|
9044
|
+
encode: gc,
|
|
9045
|
+
expected: yc
|
|
8997
9046
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8998
|
-
function
|
|
9047
|
+
function bc(e) {
|
|
8999
9048
|
if (e.key[0] !== x.TAP_SCRIPT_SIG)
|
|
9000
9049
|
throw new Error(
|
|
9001
9050
|
"Decode Error: could not decode tapScriptSig with key 0x" + H(e.key)
|
|
@@ -9015,37 +9064,37 @@ function lc(e) {
|
|
|
9015
9064
|
signature: e.value
|
|
9016
9065
|
};
|
|
9017
9066
|
}
|
|
9018
|
-
function
|
|
9067
|
+
function Sc(e) {
|
|
9019
9068
|
const t = Uint8Array.from([x.TAP_SCRIPT_SIG]);
|
|
9020
9069
|
return {
|
|
9021
9070
|
key: Pt([t, e.pubkey, e.leafHash]),
|
|
9022
9071
|
value: e.signature
|
|
9023
9072
|
};
|
|
9024
9073
|
}
|
|
9025
|
-
const
|
|
9026
|
-
function
|
|
9074
|
+
const Ac = "{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";
|
|
9075
|
+
function Ic(e) {
|
|
9027
9076
|
return e.pubkey instanceof Uint8Array && e.leafHash instanceof Uint8Array && e.signature instanceof Uint8Array && e.pubkey.length === 32 && e.leafHash.length === 32 && (e.signature.length === 64 || e.signature.length === 65);
|
|
9028
9077
|
}
|
|
9029
|
-
function
|
|
9078
|
+
function Tc(e, t, r) {
|
|
9030
9079
|
const n = H(t.pubkey) + H(t.leafHash);
|
|
9031
9080
|
return r.has(n) ? !1 : (r.add(n), e.filter(
|
|
9032
9081
|
(i) => Ot(i.pubkey, t.pubkey) === 0 && Ot(i.leafHash, t.leafHash) === 0
|
|
9033
9082
|
).length === 0);
|
|
9034
9083
|
}
|
|
9035
|
-
const
|
|
9084
|
+
const xc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9036
9085
|
__proto__: null,
|
|
9037
|
-
canAddToArray:
|
|
9038
|
-
check:
|
|
9039
|
-
decode:
|
|
9040
|
-
encode:
|
|
9041
|
-
expected:
|
|
9086
|
+
canAddToArray: Tc,
|
|
9087
|
+
check: Ic,
|
|
9088
|
+
decode: bc,
|
|
9089
|
+
encode: Sc,
|
|
9090
|
+
expected: Ac
|
|
9042
9091
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
9043
|
-
function
|
|
9092
|
+
function kc(e) {
|
|
9044
9093
|
if (e.key[0] !== x.WITNESS_UTXO)
|
|
9045
9094
|
throw new Error(
|
|
9046
9095
|
"Decode Error: could not decode witnessUtxo with key 0x" + H(e.key)
|
|
9047
9096
|
);
|
|
9048
|
-
const t =
|
|
9097
|
+
const t = fu(e.value, 0, "LE");
|
|
9049
9098
|
let r = 8;
|
|
9050
9099
|
const { numberValue: n, bytes: i } = Ie(
|
|
9051
9100
|
e.value,
|
|
@@ -9060,29 +9109,29 @@ function mc(e) {
|
|
|
9060
9109
|
value: t
|
|
9061
9110
|
};
|
|
9062
9111
|
}
|
|
9063
|
-
function
|
|
9112
|
+
function Uc(e) {
|
|
9064
9113
|
const { script: t, value: r } = e, n = ft(t.length), i = new Uint8Array(8 + n + t.length);
|
|
9065
|
-
return
|
|
9114
|
+
return cu(i, 0, BigInt(r), "LE"), Dt(t.length, i, 8), i.set(t, 8 + n), {
|
|
9066
9115
|
key: Uint8Array.from([x.WITNESS_UTXO]),
|
|
9067
9116
|
value: i
|
|
9068
9117
|
};
|
|
9069
9118
|
}
|
|
9070
|
-
const
|
|
9071
|
-
function
|
|
9119
|
+
const vc = "{ script: Uint8Array; value: bigint; }";
|
|
9120
|
+
function Pc(e) {
|
|
9072
9121
|
return e.script instanceof Uint8Array && typeof e.value == "bigint";
|
|
9073
9122
|
}
|
|
9074
|
-
function
|
|
9123
|
+
function Oc(e, t) {
|
|
9075
9124
|
return !!e && !!t && e.witnessUtxo === void 0;
|
|
9076
9125
|
}
|
|
9077
|
-
const
|
|
9126
|
+
const _c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9078
9127
|
__proto__: null,
|
|
9079
|
-
canAdd:
|
|
9080
|
-
check:
|
|
9081
|
-
decode:
|
|
9082
|
-
encode:
|
|
9083
|
-
expected:
|
|
9128
|
+
canAdd: Oc,
|
|
9129
|
+
check: Pc,
|
|
9130
|
+
decode: kc,
|
|
9131
|
+
encode: Uc,
|
|
9132
|
+
expected: vc
|
|
9084
9133
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
9085
|
-
function
|
|
9134
|
+
function Bc(e) {
|
|
9086
9135
|
if (e.key[0] !== D.TAP_TREE || e.key.length !== 1)
|
|
9087
9136
|
throw new Error(
|
|
9088
9137
|
"Decode Error: could not decode tapTree with key 0x" + H(e.key)
|
|
@@ -9102,7 +9151,7 @@ function Tc(e) {
|
|
|
9102
9151
|
}
|
|
9103
9152
|
return { leaves: r };
|
|
9104
9153
|
}
|
|
9105
|
-
function
|
|
9154
|
+
function Hc(e) {
|
|
9106
9155
|
const t = Uint8Array.from([D.TAP_TREE]), r = [].concat(
|
|
9107
9156
|
...e.leaves.map((n) => [
|
|
9108
9157
|
Uint8Array.of(n.depth, n.leafVersion),
|
|
@@ -9115,24 +9164,24 @@ function xc(e) {
|
|
|
9115
9164
|
value: Pt(r)
|
|
9116
9165
|
};
|
|
9117
9166
|
}
|
|
9118
|
-
const
|
|
9119
|
-
function
|
|
9167
|
+
const Rc = "{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";
|
|
9168
|
+
function Cc(e) {
|
|
9120
9169
|
return Array.isArray(e.leaves) && e.leaves.every(
|
|
9121
9170
|
(t) => t.depth >= 0 && t.depth <= 128 && (t.leafVersion & 254) === t.leafVersion && t.script instanceof Uint8Array
|
|
9122
9171
|
);
|
|
9123
9172
|
}
|
|
9124
|
-
function
|
|
9173
|
+
function Nc(e, t) {
|
|
9125
9174
|
return !!e && !!t && e.tapTree === void 0;
|
|
9126
9175
|
}
|
|
9127
|
-
const
|
|
9176
|
+
const Lc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9128
9177
|
__proto__: null,
|
|
9129
|
-
canAdd:
|
|
9130
|
-
check:
|
|
9131
|
-
decode:
|
|
9132
|
-
encode:
|
|
9133
|
-
expected:
|
|
9134
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
9135
|
-
function kn(e, t =
|
|
9178
|
+
canAdd: Nc,
|
|
9179
|
+
check: Cc,
|
|
9180
|
+
decode: Bc,
|
|
9181
|
+
encode: Hc,
|
|
9182
|
+
expected: Rc
|
|
9183
|
+
}, Symbol.toStringTag, { value: "Module" })), Mc = (e) => [...Array(e).keys()], Kc = (e) => e.length === 33 && [2, 3].includes(e[0]) || e.length === 65 && e[0] === 4;
|
|
9184
|
+
function kn(e, t = Kc) {
|
|
9136
9185
|
function r(f) {
|
|
9137
9186
|
if (f.key[0] !== e)
|
|
9138
9187
|
throw new Error(
|
|
@@ -9152,7 +9201,7 @@ function kn(e, t = _c) {
|
|
|
9152
9201
|
pubkey: d,
|
|
9153
9202
|
path: "m"
|
|
9154
9203
|
};
|
|
9155
|
-
for (const u of
|
|
9204
|
+
for (const u of Mc(f.value.length / 4 - 1)) {
|
|
9156
9205
|
const l = xr(f.value, u * 4 + 4, "LE"), y = !!(l & 2147483648), E = l & 2147483647;
|
|
9157
9206
|
w.path += "/" + E.toString(10) + (y ? "'" : "");
|
|
9158
9207
|
}
|
|
@@ -9227,9 +9276,9 @@ function Hs(e) {
|
|
|
9227
9276
|
canAdd: o
|
|
9228
9277
|
};
|
|
9229
9278
|
}
|
|
9230
|
-
const
|
|
9279
|
+
const $c = (e) => e.length === 32;
|
|
9231
9280
|
function Rs(e) {
|
|
9232
|
-
const t = kn(e,
|
|
9281
|
+
const t = kn(e, $c);
|
|
9233
9282
|
function r(a) {
|
|
9234
9283
|
const { numberValue: f, bytes: d } = Ie(
|
|
9235
9284
|
a.value
|
|
@@ -9321,18 +9370,18 @@ function Ns(e) {
|
|
|
9321
9370
|
};
|
|
9322
9371
|
}
|
|
9323
9372
|
const vn = {
|
|
9324
|
-
unsignedTx:
|
|
9325
|
-
globalXpub:
|
|
9373
|
+
unsignedTx: bu,
|
|
9374
|
+
globalXpub: mu,
|
|
9326
9375
|
// pass an Array of key bytes that require pubkey beside the key
|
|
9327
9376
|
checkPubkey: Un([])
|
|
9328
9377
|
}, z = {
|
|
9329
|
-
nonWitnessUtxo:
|
|
9330
|
-
partialSig:
|
|
9331
|
-
sighashType:
|
|
9332
|
-
finalScriptSig:
|
|
9333
|
-
finalScriptWitness:
|
|
9334
|
-
porCommitment:
|
|
9335
|
-
witnessUtxo:
|
|
9378
|
+
nonWitnessUtxo: Mu,
|
|
9379
|
+
partialSig: Gu,
|
|
9380
|
+
sighashType: nc,
|
|
9381
|
+
finalScriptSig: ku,
|
|
9382
|
+
finalScriptWitness: Bu,
|
|
9383
|
+
porCommitment: Zu,
|
|
9384
|
+
witnessUtxo: _c,
|
|
9336
9385
|
bip32Derivation: kn(x.BIP32_DERIVATION),
|
|
9337
9386
|
redeemScript: Hs(x.REDEEM_SCRIPT),
|
|
9338
9387
|
witnessScript: Ns(x.WITNESS_SCRIPT),
|
|
@@ -9340,14 +9389,14 @@ const vn = {
|
|
|
9340
9389
|
x.PARTIAL_SIG,
|
|
9341
9390
|
x.BIP32_DERIVATION
|
|
9342
9391
|
]),
|
|
9343
|
-
tapKeySig:
|
|
9344
|
-
tapScriptSig:
|
|
9345
|
-
tapLeafScript:
|
|
9392
|
+
tapKeySig: ac,
|
|
9393
|
+
tapScriptSig: xc,
|
|
9394
|
+
tapLeafScript: dc,
|
|
9346
9395
|
tapBip32Derivation: Rs(
|
|
9347
9396
|
x.TAP_BIP32_DERIVATION
|
|
9348
9397
|
),
|
|
9349
9398
|
tapInternalKey: Cs(x.TAP_INTERNAL_KEY),
|
|
9350
|
-
tapMerkleRoot:
|
|
9399
|
+
tapMerkleRoot: Ec
|
|
9351
9400
|
}, Bt = {
|
|
9352
9401
|
bip32Derivation: kn(D.BIP32_DERIVATION),
|
|
9353
9402
|
redeemScript: Hs(D.REDEEM_SCRIPT),
|
|
@@ -9356,23 +9405,23 @@ const vn = {
|
|
|
9356
9405
|
tapBip32Derivation: Rs(
|
|
9357
9406
|
D.TAP_BIP32_DERIVATION
|
|
9358
9407
|
),
|
|
9359
|
-
tapTree:
|
|
9408
|
+
tapTree: Lc,
|
|
9360
9409
|
tapInternalKey: Cs(D.TAP_INTERNAL_KEY)
|
|
9361
|
-
},
|
|
9410
|
+
}, Wc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9362
9411
|
__proto__: null,
|
|
9363
9412
|
globals: vn,
|
|
9364
9413
|
inputs: z,
|
|
9365
9414
|
outputs: Bt
|
|
9366
9415
|
}, Symbol.toStringTag, { value: "Module" })), dr = (e) => [...Array(e).keys()];
|
|
9367
9416
|
function bi(e) {
|
|
9368
|
-
const t = e.map(
|
|
9417
|
+
const t = e.map(Fc);
|
|
9369
9418
|
return t.push(Uint8Array.from([0])), Pt(t);
|
|
9370
9419
|
}
|
|
9371
|
-
function
|
|
9420
|
+
function Fc(e) {
|
|
9372
9421
|
const t = e.key.length, r = e.value.length, n = ft(t), i = ft(r), o = new Uint8Array(n + t + i + r);
|
|
9373
9422
|
return Dt(t, o, 0), o.set(e.key, n), Dt(r, o, n + t), o.set(e.value, n + t + i), o;
|
|
9374
9423
|
}
|
|
9375
|
-
function
|
|
9424
|
+
function Vc(e, t) {
|
|
9376
9425
|
let r = 0;
|
|
9377
9426
|
function n() {
|
|
9378
9427
|
const { numberValue: I, bytes: P } = Ie(e, r);
|
|
@@ -9590,7 +9639,7 @@ function Ls(e, { globalMapKeyVals: t, inputKeyVals: r, outputKeyVals: n }) {
|
|
|
9590
9639
|
}
|
|
9591
9640
|
return { globalMap: i, inputs: d, outputs: w };
|
|
9592
9641
|
}
|
|
9593
|
-
function
|
|
9642
|
+
function Dc({ globalMap: e, inputs: t, outputs: r }) {
|
|
9594
9643
|
const { globalKeyVals: n, inputKeyVals: i, outputKeyVals: o } = sn({
|
|
9595
9644
|
globalMap: e,
|
|
9596
9645
|
inputs: t,
|
|
@@ -9600,7 +9649,7 @@ function Nc({ globalMap: e, inputs: t, outputs: r }) {
|
|
|
9600
9649
|
[u, a].concat(d, w)
|
|
9601
9650
|
);
|
|
9602
9651
|
}
|
|
9603
|
-
const
|
|
9652
|
+
const Gc = (e, t) => Ot(e.key, t.key);
|
|
9604
9653
|
function Fr(e, t) {
|
|
9605
9654
|
const r = /* @__PURE__ */ new Set(), n = Object.entries(e).reduce((o, [a, f]) => {
|
|
9606
9655
|
if (a === "unknownKeyVals") return o;
|
|
@@ -9615,7 +9664,7 @@ function Fr(e, t) {
|
|
|
9615
9664
|
r.add(l);
|
|
9616
9665
|
}), o.concat(w);
|
|
9617
9666
|
}, []), i = e.unknownKeyVals ? e.unknownKeyVals.filter((o) => !r.has(H(o.key))) : [];
|
|
9618
|
-
return n.concat(i).sort(
|
|
9667
|
+
return n.concat(i).sort(Gc);
|
|
9619
9668
|
}
|
|
9620
9669
|
function sn({ globalMap: e, inputs: t, outputs: r }) {
|
|
9621
9670
|
return {
|
|
@@ -9624,7 +9673,7 @@ function sn({ globalMap: e, inputs: t, outputs: r }) {
|
|
|
9624
9673
|
outputKeyVals: r.map((n) => Fr(n, Bt))
|
|
9625
9674
|
};
|
|
9626
9675
|
}
|
|
9627
|
-
function
|
|
9676
|
+
function jc(e) {
|
|
9628
9677
|
const t = e[0], r = sn(t), n = e.slice(1);
|
|
9629
9678
|
if (n.length === 0) throw new Error("Combine: Nothing to combine");
|
|
9630
9679
|
const i = Si(t);
|
|
@@ -9711,7 +9760,7 @@ function Gr(e) {
|
|
|
9711
9760
|
Number(isNaN(Number(r))) && t++;
|
|
9712
9761
|
}), t;
|
|
9713
9762
|
}
|
|
9714
|
-
function
|
|
9763
|
+
function zc(e, t) {
|
|
9715
9764
|
let r = !1;
|
|
9716
9765
|
if (t.nonWitnessUtxo || t.witnessUtxo) {
|
|
9717
9766
|
const n = !!t.redeemScript, i = !!t.witnessScript, o = !n || !!t.finalScriptSig, a = !i || !!t.finalScriptWitness, f = !!t.finalScriptSig || !!t.finalScriptWitness;
|
|
@@ -9732,7 +9781,7 @@ function Pn(e) {
|
|
|
9732
9781
|
for (const n of Object.keys(t)) {
|
|
9733
9782
|
const i = t[n], { canAdd: o, canAddToArray: a, check: f, expected: d } = (
|
|
9734
9783
|
// @ts-ignore
|
|
9735
|
-
|
|
9784
|
+
Wc[e + "s"][n] || {}
|
|
9736
9785
|
), w = !!a;
|
|
9737
9786
|
if (f)
|
|
9738
9787
|
if (w) {
|
|
@@ -9752,12 +9801,12 @@ function Pn(e) {
|
|
|
9752
9801
|
}
|
|
9753
9802
|
};
|
|
9754
9803
|
}
|
|
9755
|
-
const
|
|
9756
|
-
function
|
|
9804
|
+
const Xc = Pn("global"), Ms = Pn("input"), Ks = Pn("output");
|
|
9805
|
+
function Yc(e, t) {
|
|
9757
9806
|
const r = e.length - 1, n = Q(e, r);
|
|
9758
9807
|
Ms(t, n);
|
|
9759
9808
|
}
|
|
9760
|
-
function
|
|
9809
|
+
function qc(e, t) {
|
|
9761
9810
|
const r = e.length - 1, n = Ke(e, r);
|
|
9762
9811
|
Ks(t, n);
|
|
9763
9812
|
}
|
|
@@ -9768,30 +9817,30 @@ let Ii = class {
|
|
|
9768
9817
|
};
|
|
9769
9818
|
}
|
|
9770
9819
|
static fromBase64(t, r) {
|
|
9771
|
-
const n =
|
|
9820
|
+
const n = uu(t);
|
|
9772
9821
|
return this.fromBuffer(n, r);
|
|
9773
9822
|
}
|
|
9774
9823
|
static fromHex(t, r) {
|
|
9775
|
-
const n =
|
|
9824
|
+
const n = hu(t);
|
|
9776
9825
|
return this.fromBuffer(n, r);
|
|
9777
9826
|
}
|
|
9778
9827
|
static fromBuffer(t, r) {
|
|
9779
|
-
const n =
|
|
9828
|
+
const n = Vc(t, r), i = new this(n.globalMap.unsignedTx);
|
|
9780
9829
|
return Object.assign(i, n), i;
|
|
9781
9830
|
}
|
|
9782
9831
|
toBase64() {
|
|
9783
9832
|
const t = this.toBuffer();
|
|
9784
|
-
return
|
|
9833
|
+
return au(t);
|
|
9785
9834
|
}
|
|
9786
9835
|
toHex() {
|
|
9787
9836
|
const t = this.toBuffer();
|
|
9788
9837
|
return H(t);
|
|
9789
9838
|
}
|
|
9790
9839
|
toBuffer() {
|
|
9791
|
-
return
|
|
9840
|
+
return Dc(this);
|
|
9792
9841
|
}
|
|
9793
9842
|
updateGlobal(t) {
|
|
9794
|
-
return
|
|
9843
|
+
return Xc(t, this.globalMap), this;
|
|
9795
9844
|
}
|
|
9796
9845
|
updateInput(t, r) {
|
|
9797
9846
|
const n = Q(this.inputs, t);
|
|
@@ -9825,7 +9874,7 @@ let Ii = class {
|
|
|
9825
9874
|
throw new Error("unknownKeyVals must be an Array");
|
|
9826
9875
|
return r.forEach(
|
|
9827
9876
|
(i) => this.addUnknownKeyValToInput(n, i)
|
|
9828
|
-
),
|
|
9877
|
+
), Yc(this.inputs, t), this;
|
|
9829
9878
|
}
|
|
9830
9879
|
addOutput(t) {
|
|
9831
9880
|
this.globalMap.unsignedTx.addOutput(t), this.outputs.push({
|
|
@@ -9836,11 +9885,11 @@ let Ii = class {
|
|
|
9836
9885
|
throw new Error("unknownKeyVals must be an Array");
|
|
9837
9886
|
return r.forEach(
|
|
9838
9887
|
(i) => this.addUnknownKeyValToOutput(n, i)
|
|
9839
|
-
),
|
|
9888
|
+
), qc(this.outputs, t), this;
|
|
9840
9889
|
}
|
|
9841
9890
|
clearFinalizedInput(t) {
|
|
9842
9891
|
const r = Q(this.inputs, t);
|
|
9843
|
-
|
|
9892
|
+
zc(t, r);
|
|
9844
9893
|
for (const n of Object.keys(r))
|
|
9845
9894
|
[
|
|
9846
9895
|
"witnessUtxo",
|
|
@@ -9852,7 +9901,7 @@ let Ii = class {
|
|
|
9852
9901
|
return this;
|
|
9853
9902
|
}
|
|
9854
9903
|
combine(...t) {
|
|
9855
|
-
const r =
|
|
9904
|
+
const r = jc([this].concat(t));
|
|
9856
9905
|
return Object.assign(this, r), this;
|
|
9857
9906
|
}
|
|
9858
9907
|
getTransaction() {
|
|
@@ -9868,7 +9917,7 @@ function Gt(e) {
|
|
|
9868
9917
|
}
|
|
9869
9918
|
};
|
|
9870
9919
|
}
|
|
9871
|
-
const
|
|
9920
|
+
const Zc = Gt(Ge), Qc = Gt(Tn), Jc = Gt(Te), kr = Gt(We), Ti = Gt(Ue), $s = Gt(xe), On = Gt(ke), El = Gt(mn), bl = (e) => e.length === 4 && e[0] === 81 && // OP_1
|
|
9872
9921
|
e[1] === 2 && // push 2 bytes
|
|
9873
9922
|
e[2] === 78 && e[3] === 115;
|
|
9874
9923
|
function He(e) {
|
|
@@ -9897,8 +9946,8 @@ function Ws(e, t) {
|
|
|
9897
9946
|
function Ur(e, t) {
|
|
9898
9947
|
return Ws(e, t) !== -1;
|
|
9899
9948
|
}
|
|
9900
|
-
function
|
|
9901
|
-
return
|
|
9949
|
+
function tf(e, t) {
|
|
9950
|
+
return ef(e).some((n) => Fs(n, re.decode, t));
|
|
9902
9951
|
}
|
|
9903
9952
|
function Fs(e, t, r) {
|
|
9904
9953
|
const { hashType: n } = t(e), i = [];
|
|
@@ -9912,24 +9961,24 @@ function Fs(e, t, r) {
|
|
|
9912
9961
|
}
|
|
9913
9962
|
return i.indexOf(r) === -1;
|
|
9914
9963
|
}
|
|
9915
|
-
function
|
|
9964
|
+
function ef(e) {
|
|
9916
9965
|
const { partialSig: t } = e;
|
|
9917
9966
|
let r;
|
|
9918
9967
|
if (!t || t.length === 0) {
|
|
9919
9968
|
if (!e.finalScriptSig && !e.finalScriptWitness) return [];
|
|
9920
|
-
r =
|
|
9969
|
+
r = rf(e);
|
|
9921
9970
|
} else
|
|
9922
9971
|
r = t;
|
|
9923
9972
|
return r.map((n) => new Uint8Array(n.signature));
|
|
9924
9973
|
}
|
|
9925
|
-
function
|
|
9974
|
+
function rf(e) {
|
|
9926
9975
|
const t = e.finalScriptSig ? M(new Uint8Array(e.finalScriptSig)) || [] : [], r = e.finalScriptWitness ? M(new Uint8Array(e.finalScriptWitness)) || [] : [];
|
|
9927
9976
|
return t.concat(r).filter((n) => n instanceof Uint8Array && oe(n)).map((n) => ({ signature: n }));
|
|
9928
9977
|
}
|
|
9929
9978
|
function xi(e, t, r) {
|
|
9930
|
-
const n =
|
|
9979
|
+
const n = yf(t, e, r);
|
|
9931
9980
|
try {
|
|
9932
|
-
const o =
|
|
9981
|
+
const o = wf(t, n).concat(new Uint8Array(n.script)).concat(new Uint8Array(n.controlBlock));
|
|
9933
9982
|
return { finalScriptWitness: He(o) };
|
|
9934
9983
|
} catch (i) {
|
|
9935
9984
|
throw new Error(`Can not finalize taproot input #${e}: ${i}`);
|
|
@@ -9946,22 +9995,22 @@ function jr(e, t) {
|
|
|
9946
9995
|
return e && !!(e.tapInternalKey || e.tapTree || e.tapBip32Derivation && e.tapBip32Derivation.length || t && On(t));
|
|
9947
9996
|
}
|
|
9948
9997
|
function ki(e, t, r) {
|
|
9949
|
-
|
|
9998
|
+
lf(e, t, r), df(e, t, r);
|
|
9950
9999
|
}
|
|
9951
10000
|
function Ui(e, t, r) {
|
|
9952
|
-
|
|
10001
|
+
pf(e, t, r), nf(e, t);
|
|
9953
10002
|
}
|
|
9954
|
-
function
|
|
10003
|
+
function nf(e, t) {
|
|
9955
10004
|
if (!t.tapTree && !t.tapInternalKey) return;
|
|
9956
10005
|
const r = t.tapInternalKey || e.tapInternalKey, n = t.tapTree || e.tapTree;
|
|
9957
10006
|
if (r) {
|
|
9958
|
-
const i = e.script, o =
|
|
10007
|
+
const i = e.script, o = sf(r, n);
|
|
9959
10008
|
if (i && !T(i, o))
|
|
9960
10009
|
throw new Error("Error adding output. Script or address missmatch.");
|
|
9961
10010
|
}
|
|
9962
10011
|
}
|
|
9963
|
-
function
|
|
9964
|
-
const r = t &&
|
|
10012
|
+
function sf(e, t) {
|
|
10013
|
+
const r = t && of(t.leaves), { output: n } = ke({
|
|
9965
10014
|
internalPubkey: new Uint8Array(e),
|
|
9966
10015
|
scriptTree: r
|
|
9967
10016
|
});
|
|
@@ -9981,32 +10030,32 @@ function Al(e) {
|
|
|
9981
10030
|
throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");
|
|
9982
10031
|
return on(e);
|
|
9983
10032
|
}
|
|
9984
|
-
function
|
|
10033
|
+
function of(e = []) {
|
|
9985
10034
|
return e.length === 1 && e[0].depth === 0 ? {
|
|
9986
10035
|
output: new Uint8Array(e[0].script),
|
|
9987
10036
|
version: e[0].leafVersion
|
|
9988
|
-
} :
|
|
10037
|
+
} : ff(e);
|
|
9989
10038
|
}
|
|
9990
|
-
function
|
|
9991
|
-
return
|
|
10039
|
+
function hf(e, t) {
|
|
10040
|
+
return uf(e).some((n) => Fs(n, af, t));
|
|
9992
10041
|
}
|
|
9993
|
-
function
|
|
10042
|
+
function af(e) {
|
|
9994
10043
|
return {
|
|
9995
10044
|
signature: e.subarray(0, 64),
|
|
9996
10045
|
hashType: e.subarray(64)[0] || v.SIGHASH_DEFAULT
|
|
9997
10046
|
};
|
|
9998
10047
|
}
|
|
9999
|
-
function
|
|
10048
|
+
function uf(e) {
|
|
10000
10049
|
const t = [];
|
|
10001
10050
|
if (e.tapKeySig && t.push(new Uint8Array(e.tapKeySig)), e.tapScriptSig && t.push(...e.tapScriptSig.map((r) => new Uint8Array(r.signature))), !t.length) {
|
|
10002
|
-
const r =
|
|
10051
|
+
const r = cf(
|
|
10003
10052
|
e.finalScriptWitness ? new Uint8Array(e.finalScriptWitness) : void 0
|
|
10004
10053
|
);
|
|
10005
10054
|
r && t.push(r);
|
|
10006
10055
|
}
|
|
10007
10056
|
return t;
|
|
10008
10057
|
}
|
|
10009
|
-
function
|
|
10058
|
+
function cf(e) {
|
|
10010
10059
|
if (!e) return;
|
|
10011
10060
|
const t = e.subarray(2);
|
|
10012
10061
|
if (t.length === 64 || t.length === 65) return t;
|
|
@@ -10019,7 +10068,7 @@ function on(e, t = [], r = 0) {
|
|
|
10019
10068
|
script: e.output
|
|
10020
10069
|
}), t) : (e[0] && on(e[0], t, r + 1), e[1] && on(e[1], t, r + 1), t) : [];
|
|
10021
10070
|
}
|
|
10022
|
-
function
|
|
10071
|
+
function ff(e) {
|
|
10023
10072
|
let t;
|
|
10024
10073
|
for (const r of e)
|
|
10025
10074
|
if (t = hn(r, t), !t) throw new Error("No room left to insert tapleaf in tree");
|
|
@@ -10038,21 +10087,21 @@ function hn(e, t, r = 0) {
|
|
|
10038
10087
|
const i = hn(e, t && t[1], r + 1);
|
|
10039
10088
|
if (i) return [t && t[0], i];
|
|
10040
10089
|
}
|
|
10041
|
-
function
|
|
10090
|
+
function lf(e, t, r) {
|
|
10042
10091
|
const n = wt(e) && me(t), i = me(e) && wt(t), o = e === t && wt(t) && me(t);
|
|
10043
10092
|
if (n || i || o)
|
|
10044
10093
|
throw new Error(
|
|
10045
10094
|
`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`
|
|
10046
10095
|
);
|
|
10047
10096
|
}
|
|
10048
|
-
function
|
|
10097
|
+
function pf(e, t, r) {
|
|
10049
10098
|
const n = jr(e) && me(t), i = me(e) && jr(t), o = e === t && jr(t) && me(t);
|
|
10050
10099
|
if (n || i || o)
|
|
10051
10100
|
throw new Error(
|
|
10052
10101
|
`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`
|
|
10053
10102
|
);
|
|
10054
10103
|
}
|
|
10055
|
-
function
|
|
10104
|
+
function df(e, t, r) {
|
|
10056
10105
|
if (t.tapMerkleRoot) {
|
|
10057
10106
|
const n = new Uint8Array(t.tapMerkleRoot), i = (t.tapLeafScript || []).every(
|
|
10058
10107
|
(a) => zr(a, n)
|
|
@@ -10077,14 +10126,14 @@ function zr(e, t) {
|
|
|
10077
10126
|
}), n = ar(new Uint8Array(e.controlBlock), r);
|
|
10078
10127
|
return T(n, t);
|
|
10079
10128
|
}
|
|
10080
|
-
function
|
|
10129
|
+
function wf(e, t) {
|
|
10081
10130
|
const r = new Uint8Array(t.script), n = Ut({
|
|
10082
10131
|
output: r,
|
|
10083
10132
|
version: t.leafVersion
|
|
10084
10133
|
});
|
|
10085
|
-
return (e.tapScriptSig || []).filter((i) => T(new Uint8Array(i.leafHash), n)).map((i) =>
|
|
10134
|
+
return (e.tapScriptSig || []).filter((i) => T(new Uint8Array(i.leafHash), n)).map((i) => gf(r, i)).sort((i, o) => o.positionInScript - i.positionInScript).map((i) => new Uint8Array(i.signature));
|
|
10086
10135
|
}
|
|
10087
|
-
function
|
|
10136
|
+
function gf(e, t) {
|
|
10088
10137
|
return Object.assign(
|
|
10089
10138
|
{
|
|
10090
10139
|
positionInScript: Ws(new Uint8Array(t.pubkey), e)
|
|
@@ -10092,20 +10141,20 @@ function af(e, t) {
|
|
|
10092
10141
|
t
|
|
10093
10142
|
);
|
|
10094
10143
|
}
|
|
10095
|
-
function
|
|
10144
|
+
function yf(e, t, r) {
|
|
10096
10145
|
const { tapScriptSig: n } = e;
|
|
10097
10146
|
if (!n || !n.length)
|
|
10098
10147
|
throw new Error(
|
|
10099
10148
|
`Can not finalize taproot input #${t}. No tapleaf script signature provided.`
|
|
10100
10149
|
);
|
|
10101
|
-
const i = (e.tapLeafScript || []).sort((o, a) => o.controlBlock.length - a.controlBlock.length).find((o) =>
|
|
10150
|
+
const i = (e.tapLeafScript || []).sort((o, a) => o.controlBlock.length - a.controlBlock.length).find((o) => mf(o, n, r));
|
|
10102
10151
|
if (!i)
|
|
10103
10152
|
throw new Error(
|
|
10104
10153
|
`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`
|
|
10105
10154
|
);
|
|
10106
10155
|
return i;
|
|
10107
10156
|
}
|
|
10108
|
-
function
|
|
10157
|
+
function mf(e, t, r) {
|
|
10109
10158
|
const n = Ut({
|
|
10110
10159
|
output: new Uint8Array(e.script),
|
|
10111
10160
|
version: e.leafVersion
|
|
@@ -10126,7 +10175,7 @@ function Xr(e) {
|
|
|
10126
10175
|
function Vs(e) {
|
|
10127
10176
|
return !!e.finalScriptSig || !!e.finalScriptWitness;
|
|
10128
10177
|
}
|
|
10129
|
-
function
|
|
10178
|
+
function Ef(e) {
|
|
10130
10179
|
if (!e.ins.every(
|
|
10131
10180
|
(r) => r.script && r.script.length === 0 && r.witness && r.witness.length === 0
|
|
10132
10181
|
))
|
|
@@ -10137,17 +10186,17 @@ function Ds(e, t) {
|
|
|
10137
10186
|
if (e.txInCache[n]) throw new Error("Duplicate input detected.");
|
|
10138
10187
|
e.txInCache[n] = 1;
|
|
10139
10188
|
}
|
|
10140
|
-
function
|
|
10189
|
+
function bf(e, t) {
|
|
10141
10190
|
e.ins.forEach((r) => {
|
|
10142
10191
|
Ds(t, r);
|
|
10143
10192
|
});
|
|
10144
10193
|
}
|
|
10145
10194
|
function _e(e, t, r) {
|
|
10146
10195
|
r !== !1 && e.forEach((n) => {
|
|
10147
|
-
if (wt(n) ?
|
|
10196
|
+
if (wt(n) ? hf(n, t) : tf(n, t)) throw new Error("Can not modify transaction, signatures exist.");
|
|
10148
10197
|
});
|
|
10149
10198
|
}
|
|
10150
|
-
function
|
|
10199
|
+
function Sf(e) {
|
|
10151
10200
|
if (!e.sighashType || !e.partialSig) return;
|
|
10152
10201
|
const { partialSig: t, sighashType: r } = e;
|
|
10153
10202
|
t.forEach((n) => {
|
|
@@ -10158,9 +10207,7 @@ function pf(e) {
|
|
|
10158
10207
|
}
|
|
10159
10208
|
function Gs(e, t, r) {
|
|
10160
10209
|
if (!Ur(e, t))
|
|
10161
|
-
throw new Error(
|
|
10162
|
-
`Can not ${r} for this input with the key ${gt(e)}`
|
|
10163
|
-
);
|
|
10210
|
+
throw new Error(`Can not ${r} for this input with the key ${gt(e)}`);
|
|
10164
10211
|
}
|
|
10165
10212
|
function js(e, t) {
|
|
10166
10213
|
return (r, n, i, o) => {
|
|
@@ -10193,7 +10240,7 @@ function zs(e) {
|
|
|
10193
10240
|
}
|
|
10194
10241
|
return o();
|
|
10195
10242
|
}
|
|
10196
|
-
function
|
|
10243
|
+
function Af(e) {
|
|
10197
10244
|
let t = e & v.SIGHASH_ANYONECANPAY ? "SIGHASH_ANYONECANPAY | " : "";
|
|
10198
10245
|
switch (e & 31) {
|
|
10199
10246
|
case v.SIGHASH_ALL:
|
|
@@ -10208,7 +10255,7 @@ function df(e) {
|
|
|
10208
10255
|
}
|
|
10209
10256
|
return t;
|
|
10210
10257
|
}
|
|
10211
|
-
function
|
|
10258
|
+
function If(e) {
|
|
10212
10259
|
if (e.length === 65) {
|
|
10213
10260
|
const t = e[64] & 1, r = new Uint8Array(e.subarray(0, 33));
|
|
10214
10261
|
return r[0] = 2 | t, r;
|
|
@@ -10218,11 +10265,11 @@ function wf(e) {
|
|
|
10218
10265
|
function Xs(e) {
|
|
10219
10266
|
return e.length === 33 && ts(e);
|
|
10220
10267
|
}
|
|
10221
|
-
function
|
|
10268
|
+
function Tf(e) {
|
|
10222
10269
|
return oe(e);
|
|
10223
10270
|
}
|
|
10224
10271
|
function Ys(e) {
|
|
10225
|
-
return kr(e) ? "witnesspubkeyhash" :
|
|
10272
|
+
return kr(e) ? "witnesspubkeyhash" : Jc(e) ? "pubkeyhash" : Zc(e) ? "multisig" : Qc(e) ? "pubkey" : "nonstandard";
|
|
10226
10273
|
}
|
|
10227
10274
|
function Be(e) {
|
|
10228
10275
|
return [...Array(e).keys()];
|
|
@@ -10255,7 +10302,7 @@ function vr(e, t, r, n, i) {
|
|
|
10255
10302
|
type: a ? "p2sh-p2wsh" : o ? "p2sh" : f ? "p2wsh" : "raw"
|
|
10256
10303
|
};
|
|
10257
10304
|
}
|
|
10258
|
-
const
|
|
10305
|
+
const xf = {
|
|
10259
10306
|
/**
|
|
10260
10307
|
* A bitcoinjs Network object. This is only used if you pass an `address`
|
|
10261
10308
|
* parameter to addOutput. Otherwise it is not needed and can be left default.
|
|
@@ -10271,7 +10318,7 @@ const yf = {
|
|
|
10271
10318
|
};
|
|
10272
10319
|
class an {
|
|
10273
10320
|
constructor(t = {}, r = new Ii(new qs())) {
|
|
10274
|
-
this.data = r, this.#o = Object.assign({},
|
|
10321
|
+
this.data = r, this.#o = Object.assign({}, xf, t), this.#e = {
|
|
10275
10322
|
nonWitnessUtxoTxCache: [],
|
|
10276
10323
|
nonWitnessUtxoBufCache: [],
|
|
10277
10324
|
txInCache: {},
|
|
@@ -10336,8 +10383,8 @@ class an {
|
|
|
10336
10383
|
return this.fromBuffer(n, r);
|
|
10337
10384
|
}
|
|
10338
10385
|
static fromBuffer(t, r = {}) {
|
|
10339
|
-
const n = Ii.fromBuffer(t,
|
|
10340
|
-
return
|
|
10386
|
+
const n = Ii.fromBuffer(t, kf), i = new an(r, n);
|
|
10387
|
+
return bf(i.#e.tx, i.#e), i.#e.hasSignatures = i.data.inputs.some(
|
|
10341
10388
|
(o) => o.partialSig?.length || o.tapKeySig || o.tapScriptSig?.length || o.finalScriptSig || o.finalScriptWitness
|
|
10342
10389
|
), i;
|
|
10343
10390
|
}
|
|
@@ -10422,9 +10469,11 @@ class an {
|
|
|
10422
10469
|
return this.data.addOutput(t), o.fee = void 0, o.feeRate = void 0, o.extractedTx = void 0, o.taprootHashCache = void 0, this;
|
|
10423
10470
|
}
|
|
10424
10471
|
extractTransaction(t, r) {
|
|
10425
|
-
if (r && (this.data.inputs = this.data.inputs.filter(
|
|
10472
|
+
if (r && (this.data.inputs = this.data.inputs.filter(
|
|
10473
|
+
(o) => !o.partialSig
|
|
10474
|
+
)), !this.data.inputs.every(Vs)) throw new Error("Not finalized");
|
|
10426
10475
|
const n = this.#e;
|
|
10427
|
-
if (t ||
|
|
10476
|
+
if (t || vf(this, n, this.#o), n.extractedTx) return n.extractedTx;
|
|
10428
10477
|
const i = n.tx.clone();
|
|
10429
10478
|
return to(this.data.inputs, i, n, !0, r), i;
|
|
10430
10479
|
}
|
|
@@ -10473,14 +10522,14 @@ class an {
|
|
|
10473
10522
|
n,
|
|
10474
10523
|
t,
|
|
10475
10524
|
"input",
|
|
10476
|
-
r.redeemScript ||
|
|
10477
|
-
r.witnessScript ||
|
|
10525
|
+
r.redeemScript || Lf(r.finalScriptSig),
|
|
10526
|
+
r.witnessScript || Mf(r.finalScriptWitness)
|
|
10478
10527
|
), o = i.type === "raw" ? "" : i.type + "-", a = Ys(i.meaningfulScript);
|
|
10479
10528
|
return o + a;
|
|
10480
10529
|
}
|
|
10481
10530
|
inputHasPubkey(t, r) {
|
|
10482
10531
|
const n = Q(this.data.inputs, t);
|
|
10483
|
-
return
|
|
10532
|
+
return Cf(r, n, t, this.#e);
|
|
10484
10533
|
}
|
|
10485
10534
|
inputHasHDKey(t, r) {
|
|
10486
10535
|
const n = Q(this.data.inputs, t), i = _i(r);
|
|
@@ -10488,7 +10537,7 @@ class an {
|
|
|
10488
10537
|
}
|
|
10489
10538
|
outputHasPubkey(t, r) {
|
|
10490
10539
|
const n = Ke(this.data.outputs, t);
|
|
10491
|
-
return
|
|
10540
|
+
return Nf(r, n, t, this.#e);
|
|
10492
10541
|
}
|
|
10493
10542
|
outputHasHDKey(t, r) {
|
|
10494
10543
|
const n = Ke(this.data.outputs, t), i = _i(r);
|
|
@@ -10693,19 +10742,17 @@ class an {
|
|
|
10693
10742
|
o
|
|
10694
10743
|
);
|
|
10695
10744
|
if (!f || !f.length)
|
|
10696
|
-
throw new Error(
|
|
10697
|
-
`Can not sign for input #${t} with the key ${gt(a)}`
|
|
10698
|
-
);
|
|
10745
|
+
throw new Error(`Can not sign for input #${t} with the key ${gt(a)}`);
|
|
10699
10746
|
return f;
|
|
10700
10747
|
}
|
|
10701
|
-
#t(t, r, n =
|
|
10702
|
-
const { script: o, isP2SH: a, isP2WSH: f, isSegwit: d } =
|
|
10748
|
+
#t(t, r, n = Pf, i = !0) {
|
|
10749
|
+
const { script: o, isP2SH: a, isP2WSH: f, isSegwit: d } = Hf(
|
|
10703
10750
|
t,
|
|
10704
10751
|
r,
|
|
10705
10752
|
this.#e
|
|
10706
10753
|
);
|
|
10707
10754
|
if (!o) throw new Error(`No script found for input #${t}`);
|
|
10708
|
-
|
|
10755
|
+
Sf(r);
|
|
10709
10756
|
const { finalScriptSig: w, finalScriptWitness: u } = n(
|
|
10710
10757
|
t,
|
|
10711
10758
|
r,
|
|
@@ -10769,7 +10816,7 @@ class an {
|
|
|
10769
10816
|
throw new Error("No signatures to validate");
|
|
10770
10817
|
if (typeof r != "function")
|
|
10771
10818
|
throw new Error("Need validator function to validate signatures");
|
|
10772
|
-
const f = n ? we(n) : void 0, d = f ? un(t, i, this.data.inputs, f, this.#e) :
|
|
10819
|
+
const f = n ? we(n) : void 0, d = f ? un(t, i, this.data.inputs, f, this.#e) : _f(t, i, this.data.inputs, this.#e);
|
|
10773
10820
|
if (!d.length) throw new Error("No signatures for this pubkey");
|
|
10774
10821
|
const w = d.find((l) => !l.leafHash);
|
|
10775
10822
|
let u = 0;
|
|
@@ -10893,11 +10940,11 @@ class an {
|
|
|
10893
10940
|
this.data.updateInput(t, E), this.#e.hasSignatures = !0;
|
|
10894
10941
|
}
|
|
10895
10942
|
}
|
|
10896
|
-
const
|
|
10943
|
+
const kf = (e) => new qs(e);
|
|
10897
10944
|
class qs {
|
|
10898
10945
|
tx;
|
|
10899
10946
|
constructor(t = new Uint8Array([2, 0, 0, 0, 0, 0, 0, 0, 0, 0])) {
|
|
10900
|
-
this.tx = v.fromBuffer(t),
|
|
10947
|
+
this.tx = v.fromBuffer(t), Ef(this.tx), Object.defineProperty(this, "tx", {
|
|
10901
10948
|
enumerable: !1,
|
|
10902
10949
|
writable: !0
|
|
10903
10950
|
});
|
|
@@ -10923,7 +10970,7 @@ class qs {
|
|
|
10923
10970
|
return this.tx.toBuffer();
|
|
10924
10971
|
}
|
|
10925
10972
|
}
|
|
10926
|
-
function
|
|
10973
|
+
function Uf(e, t, r) {
|
|
10927
10974
|
switch (r) {
|
|
10928
10975
|
case "pubkey":
|
|
10929
10976
|
case "pubkeyhash":
|
|
@@ -10946,7 +10993,7 @@ function Oi(e, t, r) {
|
|
|
10946
10993
|
if (!t) return !1;
|
|
10947
10994
|
let n;
|
|
10948
10995
|
if (r ? n = r.map((i) => {
|
|
10949
|
-
const o =
|
|
10996
|
+
const o = If(i);
|
|
10950
10997
|
return t.find((a) => T(a.pubkey, o));
|
|
10951
10998
|
}).filter((i) => !!i) : n = t, n.length > e) throw new Error("Too many signatures");
|
|
10952
10999
|
return n.length === e;
|
|
@@ -10959,7 +11006,7 @@ function _i(e) {
|
|
|
10959
11006
|
return !!T(i, t.pubkey);
|
|
10960
11007
|
};
|
|
10961
11008
|
}
|
|
10962
|
-
function
|
|
11009
|
+
function vf(e, t, r) {
|
|
10963
11010
|
const n = t.feeRate || e.getFeeRate();
|
|
10964
11011
|
if (!t.extractedTx) throw new Error("Transaction not extracted");
|
|
10965
11012
|
const i = t.extractedTx.virtualSize(), o = n * i;
|
|
@@ -10978,12 +11025,12 @@ function Bi(e, t, r, n, i = !1) {
|
|
|
10978
11025
|
if (f === void 0) throw new Error(`Failed to calculate ${t}`);
|
|
10979
11026
|
return f;
|
|
10980
11027
|
}
|
|
10981
|
-
function
|
|
11028
|
+
function Pf(e, t, r, n, i, o, a = !0, f) {
|
|
10982
11029
|
const d = Ys(r);
|
|
10983
|
-
if (!
|
|
11030
|
+
if (!Uf(t, r, d) && a)
|
|
10984
11031
|
throw new Error(`Can not finalize input #${e}`);
|
|
10985
11032
|
if (!t.partialSig) throw new Error("Input missing partial signatures");
|
|
10986
|
-
return
|
|
11033
|
+
return Of(
|
|
10987
11034
|
r,
|
|
10988
11035
|
d,
|
|
10989
11036
|
t.partialSig,
|
|
@@ -10993,9 +11040,9 @@ function Sf(e, t, r, n, i, o, a = !0, f) {
|
|
|
10993
11040
|
f
|
|
10994
11041
|
);
|
|
10995
11042
|
}
|
|
10996
|
-
function
|
|
11043
|
+
function Of(e, t, r, n, i, o, a) {
|
|
10997
11044
|
let f, d;
|
|
10998
|
-
const w =
|
|
11045
|
+
const w = Bf(e, t, r), u = o ? Ue({ redeem: w }) : null, l = i ? xe({ redeem: u || w }) : null;
|
|
10999
11046
|
return n ? (u && u.witness ? d = He(u.witness) : w && w.witness ? d = He(w.witness) : d = He(a ?? [new Uint8Array([0])]), l && (f = l?.input)) : l ? f = l?.input : w ? f = w.input : f = Array.isArray(a) && a[0] ? a[0] : new Uint8Array([1]), {
|
|
11000
11047
|
finalScriptSig: f,
|
|
11001
11048
|
finalScriptWitness: d
|
|
@@ -11041,12 +11088,7 @@ function Zs(e, t, r, n, i) {
|
|
|
11041
11088
|
t.witnessScript
|
|
11042
11089
|
), l = w;
|
|
11043
11090
|
if (["p2sh-p2wsh", "p2wsh"].indexOf(u) >= 0)
|
|
11044
|
-
f = o.hashForWitnessV0(
|
|
11045
|
-
e,
|
|
11046
|
-
l,
|
|
11047
|
-
d.value,
|
|
11048
|
-
a
|
|
11049
|
-
);
|
|
11091
|
+
f = o.hashForWitnessV0(e, l, d.value, a);
|
|
11050
11092
|
else if (kr(w)) {
|
|
11051
11093
|
const y = Te({
|
|
11052
11094
|
hash: w.subarray(2)
|
|
@@ -11076,7 +11118,7 @@ PROCEED WITH CAUTION!
|
|
|
11076
11118
|
hash: f
|
|
11077
11119
|
};
|
|
11078
11120
|
}
|
|
11079
|
-
function
|
|
11121
|
+
function _f(e, t, r, n) {
|
|
11080
11122
|
const i = [];
|
|
11081
11123
|
if (t.tapInternalKey) {
|
|
11082
11124
|
const a = Qs(e, t, n);
|
|
@@ -11100,9 +11142,7 @@ function Ri(e) {
|
|
|
11100
11142
|
function un(e, t, r, n, i, o, a) {
|
|
11101
11143
|
const f = i.tx, d = t.sighashType || v.SIGHASH_DEFAULT;
|
|
11102
11144
|
if (Js(d, a), !i.prevOuts) {
|
|
11103
|
-
const A = r.map(
|
|
11104
|
-
(S, I) => _n(I, S, i)
|
|
11105
|
-
);
|
|
11145
|
+
const A = r.map((S, I) => _n(I, S, i));
|
|
11106
11146
|
i.prevOuts = A, i.signingScripts = A.map((S) => S.script), i.values = A.map((S) => S.value);
|
|
11107
11147
|
}
|
|
11108
11148
|
const w = i.signingScripts, u = i.values;
|
|
@@ -11149,17 +11189,17 @@ function un(e, t, r, n, i, o, a) {
|
|
|
11149
11189
|
}
|
|
11150
11190
|
function Js(e, t) {
|
|
11151
11191
|
if (t && t.indexOf(e) < 0) {
|
|
11152
|
-
const r =
|
|
11192
|
+
const r = Af(e);
|
|
11153
11193
|
throw new Error(
|
|
11154
11194
|
`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`
|
|
11155
11195
|
);
|
|
11156
11196
|
}
|
|
11157
11197
|
}
|
|
11158
|
-
function
|
|
11198
|
+
function Bf(e, t, r) {
|
|
11159
11199
|
const n = e;
|
|
11160
11200
|
switch (t) {
|
|
11161
11201
|
case "multisig": {
|
|
11162
|
-
const i =
|
|
11202
|
+
const i = Rf(e, r);
|
|
11163
11203
|
return Ge({
|
|
11164
11204
|
output: n,
|
|
11165
11205
|
signatures: i
|
|
@@ -11186,7 +11226,7 @@ function Tf(e, t, r) {
|
|
|
11186
11226
|
throw new Error(`Unknown script type: ${t}`);
|
|
11187
11227
|
}
|
|
11188
11228
|
}
|
|
11189
|
-
function
|
|
11229
|
+
function Hf(e, t, r) {
|
|
11190
11230
|
const n = r.tx, i = {
|
|
11191
11231
|
script: null,
|
|
11192
11232
|
isSegwit: !1,
|
|
@@ -11231,7 +11271,7 @@ function Ci(e, t, r) {
|
|
|
11231
11271
|
return a;
|
|
11232
11272
|
});
|
|
11233
11273
|
}
|
|
11234
|
-
function
|
|
11274
|
+
function Rf(e, t) {
|
|
11235
11275
|
const r = Ge({ output: e });
|
|
11236
11276
|
if (!r.pubkeys) throw new Error("Cannot extract pubkeys from multisig script");
|
|
11237
11277
|
const n = [];
|
|
@@ -11302,7 +11342,7 @@ function _n(e, t, r) {
|
|
|
11302
11342
|
} else
|
|
11303
11343
|
throw new Error("Can't find pubkey in input without Utxo data");
|
|
11304
11344
|
}
|
|
11305
|
-
function
|
|
11345
|
+
function Cf(e, t, r, n) {
|
|
11306
11346
|
const i = eo(r, t, n), { meaningfulScript: o } = vr(
|
|
11307
11347
|
i,
|
|
11308
11348
|
r,
|
|
@@ -11312,7 +11352,7 @@ function Uf(e, t, r, n) {
|
|
|
11312
11352
|
);
|
|
11313
11353
|
return Ur(e, o);
|
|
11314
11354
|
}
|
|
11315
|
-
function
|
|
11355
|
+
function Nf(e, t, r, n) {
|
|
11316
11356
|
const i = n.tx.outs[r].script, { meaningfulScript: o } = vr(
|
|
11317
11357
|
i,
|
|
11318
11358
|
r,
|
|
@@ -11322,65 +11362,20 @@ function vf(e, t, r, n) {
|
|
|
11322
11362
|
);
|
|
11323
11363
|
return Ur(e, o);
|
|
11324
11364
|
}
|
|
11325
|
-
function
|
|
11365
|
+
function Lf(e) {
|
|
11326
11366
|
if (!e) return;
|
|
11327
11367
|
const t = M(e);
|
|
11328
11368
|
if (!t) return;
|
|
11329
11369
|
const r = t[t.length - 1];
|
|
11330
|
-
if (!(!(r instanceof Uint8Array) || Xs(r) ||
|
|
11370
|
+
if (!(!(r instanceof Uint8Array) || Xs(r) || Tf(r) || !M(r)))
|
|
11331
11371
|
return r;
|
|
11332
11372
|
}
|
|
11333
|
-
function
|
|
11373
|
+
function Mf(e) {
|
|
11334
11374
|
if (!e) return;
|
|
11335
11375
|
const t = zs(e), r = t[t.length - 1];
|
|
11336
11376
|
if (!(Xs(r) || !M(r)))
|
|
11337
11377
|
return r;
|
|
11338
11378
|
}
|
|
11339
|
-
class bt extends Error {
|
|
11340
|
-
constructor(t) {
|
|
11341
|
-
super(t), this.name = "BitcoinError", Error.captureStackTrace && Error.captureStackTrace(this, bt);
|
|
11342
|
-
}
|
|
11343
|
-
}
|
|
11344
|
-
class _f extends bt {
|
|
11345
|
-
constructor(t) {
|
|
11346
|
-
super(t), this.name = "ValidationError";
|
|
11347
|
-
}
|
|
11348
|
-
}
|
|
11349
|
-
class Bf extends bt {
|
|
11350
|
-
constructor(t) {
|
|
11351
|
-
super(t), this.name = "InvalidInputError";
|
|
11352
|
-
}
|
|
11353
|
-
}
|
|
11354
|
-
class Hf extends bt {
|
|
11355
|
-
constructor(t) {
|
|
11356
|
-
super(t), this.name = "InvalidOutputError";
|
|
11357
|
-
}
|
|
11358
|
-
}
|
|
11359
|
-
class Rf extends bt {
|
|
11360
|
-
constructor(t) {
|
|
11361
|
-
super(t), this.name = "ScriptError";
|
|
11362
|
-
}
|
|
11363
|
-
}
|
|
11364
|
-
class Cf extends bt {
|
|
11365
|
-
constructor(t) {
|
|
11366
|
-
super(t), this.name = "PsbtError";
|
|
11367
|
-
}
|
|
11368
|
-
}
|
|
11369
|
-
class Nf extends bt {
|
|
11370
|
-
constructor(t) {
|
|
11371
|
-
super(t), this.name = "EccError";
|
|
11372
|
-
}
|
|
11373
|
-
}
|
|
11374
|
-
class Lf extends bt {
|
|
11375
|
-
constructor(t) {
|
|
11376
|
-
super(t), this.name = "AddressError";
|
|
11377
|
-
}
|
|
11378
|
-
}
|
|
11379
|
-
class Mf extends bt {
|
|
11380
|
-
constructor(t) {
|
|
11381
|
-
super(t), this.name = "SignatureError";
|
|
11382
|
-
}
|
|
11383
|
-
}
|
|
11384
11379
|
function Kf(e) {
|
|
11385
11380
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
11386
11381
|
}
|
|
@@ -11894,27 +11889,6 @@ class ut {
|
|
|
11894
11889
|
constructor(t = {}) {
|
|
11895
11890
|
this.#o = { ...jf, ...t }, this.#n = this.#o.preserveWorkers;
|
|
11896
11891
|
}
|
|
11897
|
-
/**
|
|
11898
|
-
* Gets the singleton pool instance.
|
|
11899
|
-
*
|
|
11900
|
-
* @param config - Optional configuration (only used on first call)
|
|
11901
|
-
* @returns The singleton pool instance
|
|
11902
|
-
*
|
|
11903
|
-
* @example
|
|
11904
|
-
* ```typescript
|
|
11905
|
-
* const pool = WorkerSigningPool.getInstance({ workerCount: 8 });
|
|
11906
|
-
* ```
|
|
11907
|
-
*/
|
|
11908
|
-
static getInstance(t) {
|
|
11909
|
-
return ut.#e || (ut.#e = new ut(t)), ut.#e;
|
|
11910
|
-
}
|
|
11911
|
-
/**
|
|
11912
|
-
* Resets the singleton instance (for testing).
|
|
11913
|
-
*/
|
|
11914
|
-
static resetInstance() {
|
|
11915
|
-
ut.#e && (ut.#e.shutdown().catch(() => {
|
|
11916
|
-
}), ut.#e = null);
|
|
11917
|
-
}
|
|
11918
11892
|
/**
|
|
11919
11893
|
* Number of workers in the pool.
|
|
11920
11894
|
*/
|
|
@@ -11939,6 +11913,27 @@ class ut {
|
|
|
11939
11913
|
get isPreservingWorkers() {
|
|
11940
11914
|
return this.#n;
|
|
11941
11915
|
}
|
|
11916
|
+
/**
|
|
11917
|
+
* Gets the singleton pool instance.
|
|
11918
|
+
*
|
|
11919
|
+
* @param config - Optional configuration (only used on first call)
|
|
11920
|
+
* @returns The singleton pool instance
|
|
11921
|
+
*
|
|
11922
|
+
* @example
|
|
11923
|
+
* ```typescript
|
|
11924
|
+
* const pool = WorkerSigningPool.getInstance({ workerCount: 8 });
|
|
11925
|
+
* ```
|
|
11926
|
+
*/
|
|
11927
|
+
static getInstance(t) {
|
|
11928
|
+
return ut.#e || (ut.#e = new ut(t)), ut.#e;
|
|
11929
|
+
}
|
|
11930
|
+
/**
|
|
11931
|
+
* Resets the singleton instance (for testing).
|
|
11932
|
+
*/
|
|
11933
|
+
static resetInstance() {
|
|
11934
|
+
ut.#e && (ut.#e.shutdown().catch(() => {
|
|
11935
|
+
}), ut.#e = null);
|
|
11936
|
+
}
|
|
11942
11937
|
/**
|
|
11943
11938
|
* Enables worker preservation between signing batches.
|
|
11944
11939
|
*
|
|
@@ -12340,14 +12335,14 @@ const Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
12340
12335
|
signPsbtParallel: Xf
|
|
12341
12336
|
}, Symbol.toStringTag, { value: "Module" })), Tl = {
|
|
12342
12337
|
BitcoinError: bt,
|
|
12343
|
-
ValidationError:
|
|
12344
|
-
InvalidInputError:
|
|
12345
|
-
InvalidOutputError:
|
|
12346
|
-
ScriptError:
|
|
12347
|
-
PsbtError:
|
|
12348
|
-
EccError:
|
|
12349
|
-
AddressError:
|
|
12350
|
-
SignatureError:
|
|
12338
|
+
ValidationError: ja,
|
|
12339
|
+
InvalidInputError: za,
|
|
12340
|
+
InvalidOutputError: Xa,
|
|
12341
|
+
ScriptError: Ya,
|
|
12342
|
+
PsbtError: qa,
|
|
12343
|
+
EccError: Za,
|
|
12344
|
+
AddressError: Qa,
|
|
12345
|
+
SignatureError: Ja
|
|
12351
12346
|
}, xl = {
|
|
12352
12347
|
networks: Do,
|
|
12353
12348
|
address: $a,
|
|
@@ -12357,11 +12352,11 @@ const Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
12357
12352
|
Transaction: Ga
|
|
12358
12353
|
};
|
|
12359
12354
|
export {
|
|
12360
|
-
|
|
12355
|
+
Qa as AddressError,
|
|
12361
12356
|
bt as BitcoinError,
|
|
12362
12357
|
le as Block,
|
|
12363
12358
|
mt as EccContext,
|
|
12364
|
-
|
|
12359
|
+
Za as EccError,
|
|
12365
12360
|
Ss as FUTURE_MAX_VERSION,
|
|
12366
12361
|
cr as FUTURE_OPNET_VERSION,
|
|
12367
12362
|
Fe as FUTURE_SEGWIT_MAX_SIZE,
|
|
@@ -12369,32 +12364,32 @@ export {
|
|
|
12369
12364
|
Ve as FUTURE_SEGWIT_MIN_SIZE,
|
|
12370
12365
|
Ir as FUTURE_SEGWIT_MIN_VERSION,
|
|
12371
12366
|
Tr as FUTURE_SEGWIT_VERSION_DIFF,
|
|
12372
|
-
|
|
12373
|
-
|
|
12367
|
+
za as InvalidInputError,
|
|
12368
|
+
Xa as InvalidOutputError,
|
|
12374
12369
|
Ne as LEAF_VERSION_TAPSCRIPT,
|
|
12375
12370
|
In as MAX_TAPTREE_DEPTH,
|
|
12376
12371
|
$i as MemoryPool,
|
|
12377
12372
|
X as PaymentType,
|
|
12378
12373
|
an as Psbt,
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12374
|
+
qa as PsbtError,
|
|
12375
|
+
Ya as ScriptError,
|
|
12376
|
+
Ja as SignatureError,
|
|
12382
12377
|
Bn as SignatureType,
|
|
12383
12378
|
ol as SimpleMemoryPool,
|
|
12384
12379
|
cs as TAGGED_HASH_PREFIXES,
|
|
12385
12380
|
la as TAGS,
|
|
12386
12381
|
Je as TAPLEAF_VERSION_MASK,
|
|
12387
12382
|
v as Transaction,
|
|
12388
|
-
|
|
12383
|
+
ja as ValidationError,
|
|
12389
12384
|
ut as WorkerSigningPool,
|
|
12390
12385
|
Ts as _toFutureSegwitAddress,
|
|
12391
12386
|
$a as address,
|
|
12392
12387
|
q as alloc,
|
|
12393
12388
|
gl as assertPrivateKey,
|
|
12394
12389
|
wl as assertXOnlyPublicKey,
|
|
12395
|
-
|
|
12390
|
+
tf as checkInputForSig,
|
|
12396
12391
|
ki as checkTaprootInputFields,
|
|
12397
|
-
|
|
12392
|
+
hf as checkTaprootInputForSigs,
|
|
12398
12393
|
Ui as checkTaprootOutputFields,
|
|
12399
12394
|
jn as clone,
|
|
12400
12395
|
Et as compare,
|
|
@@ -12412,10 +12407,10 @@ export {
|
|
|
12412
12407
|
Us as fromOutputScript,
|
|
12413
12408
|
il as fromUtf8,
|
|
12414
12409
|
bs as getEccLib,
|
|
12415
|
-
|
|
12416
|
-
|
|
12410
|
+
Pf as getFinalScripts,
|
|
12411
|
+
rf as getPsigsFromInputFinalScripts,
|
|
12417
12412
|
lo as getSigningPool,
|
|
12418
|
-
|
|
12413
|
+
cf as getTapKeySigFromWitness,
|
|
12419
12414
|
st as hash160,
|
|
12420
12415
|
yt as hash256,
|
|
12421
12416
|
yl as initEccLib,
|
|
@@ -12423,10 +12418,10 @@ export {
|
|
|
12423
12418
|
Mh as isBytes32,
|
|
12424
12419
|
el as isHex,
|
|
12425
12420
|
bl as isP2A,
|
|
12426
|
-
|
|
12421
|
+
Zc as isP2MS,
|
|
12427
12422
|
El as isP2OP,
|
|
12428
|
-
|
|
12429
|
-
|
|
12423
|
+
Qc as isP2PK,
|
|
12424
|
+
Jc as isP2PKH,
|
|
12430
12425
|
$s as isP2SHScript,
|
|
12431
12426
|
On as isP2TR,
|
|
12432
12427
|
kr as isP2WPKH,
|
|
@@ -12445,7 +12440,7 @@ export {
|
|
|
12445
12440
|
Do as networks,
|
|
12446
12441
|
C as opcodes,
|
|
12447
12442
|
Fa as payments,
|
|
12448
|
-
|
|
12443
|
+
Of as prepareFinalScripts,
|
|
12449
12444
|
Ur as pubkeyInScript,
|
|
12450
12445
|
Ws as pubkeyPositionInScript,
|
|
12451
12446
|
Xe as pubkeysMatch,
|
|
@@ -12461,7 +12456,7 @@ export {
|
|
|
12461
12456
|
Fs as signatureBlocksAction,
|
|
12462
12457
|
$e as taggedHash,
|
|
12463
12458
|
xi as tapScriptFinalizer,
|
|
12464
|
-
|
|
12459
|
+
of as tapTreeFromList,
|
|
12465
12460
|
Al as tapTreeToList,
|
|
12466
12461
|
Ra as tapTweakHash,
|
|
12467
12462
|
Ut as tapleafHash,
|