@btc-vision/bitcoin 6.5.1 → 6.5.3
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/chunks/crypto-0PweVewC.js +2033 -0
- package/browser/chunks/{payments-BE4vwHhV.js → payments-CgasufRS.js} +410 -408
- package/browser/chunks/psbt-BIwOrKer.js +4096 -0
- package/browser/chunks/{script-COWGdiOo.js → script-CROJPzz_.js} +96 -96
- package/browser/chunks/{transaction-BiXwH2v4.js → transaction-DchBu35N.js} +158 -147
- package/browser/chunks/{utils-BKmkTzNZ.js → utils-CO5kmxe9.js} +225 -223
- package/browser/crypto.d.ts +1 -1
- package/browser/hooks/HookedSigner.d.ts +1 -1
- package/browser/index.d.ts +23 -1
- package/browser/index.js +6 -6
- package/browser/payments/index.d.ts +2 -2
- package/browser/payments/lazy.d.ts +1 -1
- package/browser/psbt/bip371.d.ts +5 -1
- package/browser/psbt.d.ts +1 -1
- package/browser/typeforce.d.ts +38 -0
- package/browser/types.d.ts +22 -20
- package/build/address.js +2 -2
- package/build/bip66.js +2 -2
- package/build/block.js +2 -2
- package/build/crypto.d.ts +1 -1
- package/build/crypto.js +2 -3
- package/build/hooks/HookedSigner.d.ts +1 -1
- package/build/index.d.ts +23 -1
- package/build/payments/bip341.js +1 -1
- package/build/payments/index.d.ts +2 -2
- package/build/payments/lazy.d.ts +1 -1
- package/build/payments/p2op.js +3 -3
- package/build/payments/p2pk.js +1 -1
- package/build/payments/p2pkh.js +3 -3
- package/build/payments/p2sh.js +3 -3
- package/build/payments/p2tr.js +9 -5
- package/build/payments/p2wpkh.js +3 -3
- package/build/payments/p2wsh.js +2 -2
- package/build/psbt/bip371.d.ts +5 -1
- package/build/psbt/bip371.js +10 -7
- package/build/psbt/psbtutils.js +5 -4
- package/build/psbt.d.ts +1 -1
- package/build/psbt.js +78 -45
- package/build/script.js +2 -2
- package/build/script_signature.js +7 -7
- package/build/transaction.js +22 -10
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/types.d.ts +22 -20
- package/build/types.js +10 -9
- package/package.json +32 -57
- package/src/address.ts +2 -2
- package/src/bip66.ts +2 -2
- package/src/block.ts +8 -5
- package/src/crypto.ts +3 -4
- package/src/ecc_lib.ts +1 -1
- package/src/hooks/HookedSigner.ts +1 -1
- package/src/index.ts +34 -12
- package/src/payments/bip341.ts +1 -1
- package/src/payments/embed.ts +1 -2
- package/src/payments/index.ts +4 -4
- package/src/payments/lazy.ts +3 -3
- package/src/payments/p2op.ts +4 -3
- package/src/payments/p2pk.ts +1 -1
- package/src/payments/p2pkh.ts +3 -3
- package/src/payments/p2sh.ts +13 -5
- package/src/payments/p2tr.ts +8 -9
- package/src/payments/p2wpkh.ts +3 -3
- package/src/payments/p2wsh.ts +4 -4
- package/src/psbt/bip371.ts +22 -13
- package/src/psbt/psbtutils.ts +8 -5
- package/src/psbt.ts +127 -80
- package/src/script.ts +4 -4
- package/src/script_signature.ts +7 -7
- package/src/transaction.ts +31 -18
- package/src/typeforce.d.ts +38 -0
- package/src/types.ts +34 -29
- package/test/address.spec.ts +12 -4
- package/test/bitcoin.core.spec.ts +1 -1
- package/test/block.spec.ts +1 -1
- package/test/bufferutils.spec.ts +1 -1
- package/test/crypto.spec.ts +3 -2
- package/test/fixtures/address.json +1 -1
- package/test/integration/addresses.spec.ts +1 -1
- package/test/integration/bip32.spec.ts +2 -2
- package/test/integration/blocks.spec.ts +1 -1
- package/test/integration/cltv.spec.ts +3 -3
- package/test/integration/csv.spec.ts +3 -3
- package/test/integration/payments.spec.ts +1 -1
- package/test/integration/taproot.spec.ts +8 -7
- package/test/integration/transactions.spec.ts +2 -2
- package/test/payments.spec.ts +4 -3
- package/test/psbt.spec.ts +106 -74
- package/test/script.spec.ts +73 -7
- package/test/script_number.spec.ts +1 -1
- package/test/script_signature.spec.ts +1 -1
- package/test/transaction.spec.ts +1 -1
- package/test/tsconfig.json +1 -1
- package/test/types.spec.ts +1 -1
- package/vitest.config.ts +16 -0
- package/.babelrc +0 -13
- package/.mocharc.json +0 -13
- package/browser/chunks/crypto-C6FlKKmp.js +0 -2006
- package/browser/chunks/psbt-Dlosf9CT.js +0 -3853
- package/cjs/package.json +0 -3
- package/gulpfile.js +0 -42
- package/src/crypto/crypto-browser.js +0 -75
- package/test/ts-node-register.js +0 -7
- package/webpack.config.js +0 -79
|
@@ -0,0 +1,4096 @@
|
|
|
1
|
+
import { B as l, h as ot, c as xr } from "./crypto-0PweVewC.js";
|
|
2
|
+
import { o as Ce, t as Or, c as Cr, d as he, i as Hn, s as Se, a as Pr, b as Nr } from "./script-CROJPzz_.js";
|
|
3
|
+
import { t as Hr, a as Ur, H as Br, U as Rr, i as Fr, b as Un, c as Ot, r as Bn } from "./utils-CO5kmxe9.js";
|
|
4
|
+
import { p as _e, a as me, b as $e, c as ve, d as Ie, e as Rn, t as Kr, f as Ye, M as Fn, L as Lr, r as Mr, g as Kn, h as Ze, i as Wr } from "./payments-CgasufRS.js";
|
|
5
|
+
import { T as I, a as Gr } from "./transaction-DchBu35N.js";
|
|
6
|
+
const Je = {
|
|
7
|
+
/**
|
|
8
|
+
* The message prefix used for signing Bitcoin messages.
|
|
9
|
+
*/
|
|
10
|
+
messagePrefix: `Bitcoin Signed Message:
|
|
11
|
+
`,
|
|
12
|
+
/**
|
|
13
|
+
* The Bech32 prefix used for Bitcoin addresses.
|
|
14
|
+
*/
|
|
15
|
+
bech32: "bc",
|
|
16
|
+
bech32Opnet: "op",
|
|
17
|
+
/**
|
|
18
|
+
* The BIP32 key prefixes for Bitcoin.
|
|
19
|
+
*/
|
|
20
|
+
bip32: {
|
|
21
|
+
/**
|
|
22
|
+
* The public key prefix for BIP32 extended public keys.
|
|
23
|
+
*/
|
|
24
|
+
public: 76067358,
|
|
25
|
+
/**
|
|
26
|
+
* The private key prefix for BIP32 extended private keys.
|
|
27
|
+
*/
|
|
28
|
+
private: 76066276
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* The prefix for Bitcoin public key hashes.
|
|
32
|
+
*/
|
|
33
|
+
pubKeyHash: 0,
|
|
34
|
+
/**
|
|
35
|
+
* The prefix for Bitcoin script hashes.
|
|
36
|
+
*/
|
|
37
|
+
scriptHash: 5,
|
|
38
|
+
/**
|
|
39
|
+
* The prefix for Bitcoin Wallet Import Format (WIF) private keys.
|
|
40
|
+
*/
|
|
41
|
+
wif: 128
|
|
42
|
+
}, Xr = {
|
|
43
|
+
messagePrefix: `Bitcoin Signed Message:
|
|
44
|
+
`,
|
|
45
|
+
bech32: "bcrt",
|
|
46
|
+
bech32Opnet: "opr",
|
|
47
|
+
bip32: {
|
|
48
|
+
public: 70617039,
|
|
49
|
+
private: 70615956
|
|
50
|
+
},
|
|
51
|
+
pubKeyHash: 111,
|
|
52
|
+
scriptHash: 196,
|
|
53
|
+
wif: 239
|
|
54
|
+
}, qr = {
|
|
55
|
+
messagePrefix: `Bitcoin Signed Message:
|
|
56
|
+
`,
|
|
57
|
+
bech32: "tb",
|
|
58
|
+
bech32Opnet: "opt",
|
|
59
|
+
bip32: {
|
|
60
|
+
public: 70617039,
|
|
61
|
+
private: 70615956
|
|
62
|
+
},
|
|
63
|
+
pubKeyHash: 111,
|
|
64
|
+
scriptHash: 196,
|
|
65
|
+
wif: 239
|
|
66
|
+
}, Dr = {
|
|
67
|
+
messagePrefix: `Dogecoin Signed Message:
|
|
68
|
+
`,
|
|
69
|
+
bech32: "",
|
|
70
|
+
// Dogecoin does not currently use Bech32
|
|
71
|
+
bech32Opnet: "",
|
|
72
|
+
bip32: {
|
|
73
|
+
public: 49990397,
|
|
74
|
+
private: 49988504
|
|
75
|
+
},
|
|
76
|
+
pubKeyHash: 30,
|
|
77
|
+
scriptHash: 22,
|
|
78
|
+
wif: 158
|
|
79
|
+
}, Vr = {
|
|
80
|
+
messagePrefix: `Dogecoin Signed Message:
|
|
81
|
+
`,
|
|
82
|
+
bech32: "",
|
|
83
|
+
// Dogecoin testnet does not currently use Bech32
|
|
84
|
+
bech32Opnet: "",
|
|
85
|
+
bip32: {
|
|
86
|
+
public: 70429096,
|
|
87
|
+
private: 70427203
|
|
88
|
+
},
|
|
89
|
+
pubKeyHash: 113,
|
|
90
|
+
scriptHash: 196,
|
|
91
|
+
wif: 241
|
|
92
|
+
}, jr = {
|
|
93
|
+
messagePrefix: `Litecoin Signed Message:
|
|
94
|
+
`,
|
|
95
|
+
bech32: "ltc",
|
|
96
|
+
bech32Opnet: "opl",
|
|
97
|
+
bip32: {
|
|
98
|
+
public: 27108450,
|
|
99
|
+
private: 27106558
|
|
100
|
+
},
|
|
101
|
+
pubKeyHash: 48,
|
|
102
|
+
scriptHash: 50,
|
|
103
|
+
wif: 176
|
|
104
|
+
}, zr = {
|
|
105
|
+
messagePrefix: `Litecoin Signed Message:
|
|
106
|
+
`,
|
|
107
|
+
bech32: "tltc",
|
|
108
|
+
bech32Opnet: "oplt",
|
|
109
|
+
bip32: {
|
|
110
|
+
public: 70709117,
|
|
111
|
+
private: 70711009
|
|
112
|
+
},
|
|
113
|
+
pubKeyHash: 111,
|
|
114
|
+
scriptHash: 58,
|
|
115
|
+
wif: 239
|
|
116
|
+
}, $r = {
|
|
117
|
+
messagePrefix: `Bitcoin Signed Message:
|
|
118
|
+
`,
|
|
119
|
+
// Cashaddr prefix differs from bech32 for general usage, but we can set it similarly.
|
|
120
|
+
// Actual cashaddr prefix is "bitcoincash", but this field is for bech32 which BCH doesn't fully use for segwit (it doesn't have segwit).
|
|
121
|
+
bech32: "bitcoincash",
|
|
122
|
+
bech32Opnet: "opbch",
|
|
123
|
+
bip32: {
|
|
124
|
+
public: 76067358,
|
|
125
|
+
private: 76066276
|
|
126
|
+
},
|
|
127
|
+
pubKeyHash: 0,
|
|
128
|
+
scriptHash: 5,
|
|
129
|
+
wif: 128
|
|
130
|
+
}, Yr = {
|
|
131
|
+
messagePrefix: `Bitcoin Signed Message:
|
|
132
|
+
`,
|
|
133
|
+
bech32: "bchtest",
|
|
134
|
+
bech32Opnet: "opbcht",
|
|
135
|
+
bip32: {
|
|
136
|
+
public: 70617039,
|
|
137
|
+
private: 70615956
|
|
138
|
+
},
|
|
139
|
+
pubKeyHash: 111,
|
|
140
|
+
scriptHash: 196,
|
|
141
|
+
wif: 239
|
|
142
|
+
}, Zr = {
|
|
143
|
+
// Historically Dash used DarkCoin message prefix, and most implementations use this:
|
|
144
|
+
// As of Dash Core 0.17, this has not changed in code.
|
|
145
|
+
messagePrefix: `DarkCoin Signed Message:
|
|
146
|
+
`,
|
|
147
|
+
bech32: "",
|
|
148
|
+
// Dash does not use Bech32
|
|
149
|
+
bech32Opnet: "",
|
|
150
|
+
bip32: {
|
|
151
|
+
public: 50221772,
|
|
152
|
+
private: 50221816
|
|
153
|
+
},
|
|
154
|
+
pubKeyHash: 76,
|
|
155
|
+
scriptHash: 16,
|
|
156
|
+
wif: 204
|
|
157
|
+
}, Jr = {
|
|
158
|
+
messagePrefix: `DarkCoin Signed Message:
|
|
159
|
+
`,
|
|
160
|
+
bech32: "",
|
|
161
|
+
// Dash testnet does not use Bech32
|
|
162
|
+
bech32Opnet: "",
|
|
163
|
+
bip32: {
|
|
164
|
+
public: 981492128,
|
|
165
|
+
private: 981489719
|
|
166
|
+
},
|
|
167
|
+
pubKeyHash: 140,
|
|
168
|
+
scriptHash: 19,
|
|
169
|
+
wif: 239
|
|
170
|
+
}, Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
171
|
+
__proto__: null,
|
|
172
|
+
bitcoin: Je,
|
|
173
|
+
bitcoinCash: $r,
|
|
174
|
+
bitcoinCashTestnet: Yr,
|
|
175
|
+
dash: Zr,
|
|
176
|
+
dashTestnet: Jr,
|
|
177
|
+
dogecoin: Dr,
|
|
178
|
+
dogecoinTestnet: Vr,
|
|
179
|
+
litecoin: jr,
|
|
180
|
+
litecoinTestnet: zr,
|
|
181
|
+
regtest: Xr,
|
|
182
|
+
testnet: qr
|
|
183
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
184
|
+
var se = {}, Ct;
|
|
185
|
+
function es() {
|
|
186
|
+
if (Ct) return se;
|
|
187
|
+
Ct = 1, Object.defineProperty(se, "__esModule", { value: !0 }), se.bech32m = se.bech32 = void 0;
|
|
188
|
+
const t = "qpzry9x8gf2tvdw0s3jn54khce6mua7l", e = {};
|
|
189
|
+
for (let u = 0; u < t.length; u++) {
|
|
190
|
+
const f = t.charAt(u);
|
|
191
|
+
e[f] = u;
|
|
192
|
+
}
|
|
193
|
+
function n(u) {
|
|
194
|
+
const f = u >> 25;
|
|
195
|
+
return (u & 33554431) << 5 ^ -(f >> 0 & 1) & 996825010 ^ -(f >> 1 & 1) & 642813549 ^ -(f >> 2 & 1) & 513874426 ^ -(f >> 3 & 1) & 1027748829 ^ -(f >> 4 & 1) & 705979059;
|
|
196
|
+
}
|
|
197
|
+
function r(u) {
|
|
198
|
+
let f = 1;
|
|
199
|
+
for (let p = 0; p < u.length; ++p) {
|
|
200
|
+
const g = u.charCodeAt(p);
|
|
201
|
+
if (g < 33 || g > 126)
|
|
202
|
+
return "Invalid prefix (" + u + ")";
|
|
203
|
+
f = n(f) ^ g >> 5;
|
|
204
|
+
}
|
|
205
|
+
f = n(f);
|
|
206
|
+
for (let p = 0; p < u.length; ++p) {
|
|
207
|
+
const g = u.charCodeAt(p);
|
|
208
|
+
f = n(f) ^ g & 31;
|
|
209
|
+
}
|
|
210
|
+
return f;
|
|
211
|
+
}
|
|
212
|
+
function c(u, f, p, g) {
|
|
213
|
+
let y = 0, h = 0;
|
|
214
|
+
const d = (1 << p) - 1, w = [];
|
|
215
|
+
for (let E = 0; E < u.length; ++E)
|
|
216
|
+
for (y = y << f | u[E], h += f; h >= p; )
|
|
217
|
+
h -= p, w.push(y >> h & d);
|
|
218
|
+
if (g)
|
|
219
|
+
h > 0 && w.push(y << p - h & d);
|
|
220
|
+
else {
|
|
221
|
+
if (h >= f)
|
|
222
|
+
return "Excess padding";
|
|
223
|
+
if (y << p - h & d)
|
|
224
|
+
return "Non-zero padding";
|
|
225
|
+
}
|
|
226
|
+
return w;
|
|
227
|
+
}
|
|
228
|
+
function s(u) {
|
|
229
|
+
return c(u, 8, 5, !0);
|
|
230
|
+
}
|
|
231
|
+
function o(u) {
|
|
232
|
+
const f = c(u, 5, 8, !1);
|
|
233
|
+
if (Array.isArray(f))
|
|
234
|
+
return f;
|
|
235
|
+
}
|
|
236
|
+
function i(u) {
|
|
237
|
+
const f = c(u, 5, 8, !1);
|
|
238
|
+
if (Array.isArray(f))
|
|
239
|
+
return f;
|
|
240
|
+
throw new Error(f);
|
|
241
|
+
}
|
|
242
|
+
function a(u) {
|
|
243
|
+
let f;
|
|
244
|
+
u === "bech32" ? f = 1 : f = 734539939;
|
|
245
|
+
function p(d, w, E) {
|
|
246
|
+
if (E = E || 90, d.length + 7 + w.length > E)
|
|
247
|
+
throw new TypeError("Exceeds length limit");
|
|
248
|
+
d = d.toLowerCase();
|
|
249
|
+
let S = r(d);
|
|
250
|
+
if (typeof S == "string")
|
|
251
|
+
throw new Error(S);
|
|
252
|
+
let b = d + "1";
|
|
253
|
+
for (let _ = 0; _ < w.length; ++_) {
|
|
254
|
+
const v = w[_];
|
|
255
|
+
if (v >> 5 !== 0)
|
|
256
|
+
throw new Error("Non 5-bit word");
|
|
257
|
+
S = n(S) ^ v, b += t.charAt(v);
|
|
258
|
+
}
|
|
259
|
+
for (let _ = 0; _ < 6; ++_)
|
|
260
|
+
S = n(S);
|
|
261
|
+
S ^= f;
|
|
262
|
+
for (let _ = 0; _ < 6; ++_) {
|
|
263
|
+
const v = S >> (5 - _) * 5 & 31;
|
|
264
|
+
b += t.charAt(v);
|
|
265
|
+
}
|
|
266
|
+
return b;
|
|
267
|
+
}
|
|
268
|
+
function g(d, w) {
|
|
269
|
+
if (w = w || 90, d.length < 8)
|
|
270
|
+
return d + " too short";
|
|
271
|
+
if (d.length > w)
|
|
272
|
+
return "Exceeds length limit";
|
|
273
|
+
const E = d.toLowerCase(), S = d.toUpperCase();
|
|
274
|
+
if (d !== E && d !== S)
|
|
275
|
+
return "Mixed-case string " + d;
|
|
276
|
+
d = E;
|
|
277
|
+
const b = d.lastIndexOf("1");
|
|
278
|
+
if (b === -1)
|
|
279
|
+
return "No separator character for " + d;
|
|
280
|
+
if (b === 0)
|
|
281
|
+
return "Missing prefix for " + d;
|
|
282
|
+
const _ = d.slice(0, b), v = d.slice(b + 1);
|
|
283
|
+
if (v.length < 6)
|
|
284
|
+
return "Data too short";
|
|
285
|
+
let C = r(_);
|
|
286
|
+
if (typeof C == "string")
|
|
287
|
+
return C;
|
|
288
|
+
const m = [];
|
|
289
|
+
for (let k = 0; k < v.length; ++k) {
|
|
290
|
+
const U = v.charAt(k), R = e[U];
|
|
291
|
+
if (R === void 0)
|
|
292
|
+
return "Unknown character " + U;
|
|
293
|
+
C = n(C) ^ R, !(k + 6 >= v.length) && m.push(R);
|
|
294
|
+
}
|
|
295
|
+
return C !== f ? "Invalid checksum for " + d : { prefix: _, words: m };
|
|
296
|
+
}
|
|
297
|
+
function y(d, w) {
|
|
298
|
+
const E = g(d, w);
|
|
299
|
+
if (typeof E == "object")
|
|
300
|
+
return E;
|
|
301
|
+
}
|
|
302
|
+
function h(d, w) {
|
|
303
|
+
const E = g(d, w);
|
|
304
|
+
if (typeof E == "object")
|
|
305
|
+
return E;
|
|
306
|
+
throw new Error(E);
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
decodeUnsafe: y,
|
|
310
|
+
decode: h,
|
|
311
|
+
encode: p,
|
|
312
|
+
toWords: s,
|
|
313
|
+
fromWordsUnsafe: o,
|
|
314
|
+
fromWords: i
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
return se.bech32 = a("bech32"), se.bech32m = a("bech32m"), se;
|
|
318
|
+
}
|
|
319
|
+
var M = es();
|
|
320
|
+
function ts(t) {
|
|
321
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
322
|
+
}
|
|
323
|
+
function vt(t, ...e) {
|
|
324
|
+
if (!ts(t))
|
|
325
|
+
throw new Error("Uint8Array expected");
|
|
326
|
+
if (e.length > 0 && !e.includes(t.length))
|
|
327
|
+
throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
|
|
328
|
+
}
|
|
329
|
+
function Pt(t, e = !0) {
|
|
330
|
+
if (t.destroyed)
|
|
331
|
+
throw new Error("Hash instance has been destroyed");
|
|
332
|
+
if (e && t.finished)
|
|
333
|
+
throw new Error("Hash#digest() has already been called");
|
|
334
|
+
}
|
|
335
|
+
function ns(t, e) {
|
|
336
|
+
vt(t);
|
|
337
|
+
const n = e.outputLen;
|
|
338
|
+
if (t.length < n)
|
|
339
|
+
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
340
|
+
}
|
|
341
|
+
function dt(...t) {
|
|
342
|
+
for (let e = 0; e < t.length; e++)
|
|
343
|
+
t[e].fill(0);
|
|
344
|
+
}
|
|
345
|
+
function it(t) {
|
|
346
|
+
return new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
347
|
+
}
|
|
348
|
+
function B(t, e) {
|
|
349
|
+
return t << 32 - e | t >>> e;
|
|
350
|
+
}
|
|
351
|
+
function rs(t) {
|
|
352
|
+
if (typeof t != "string")
|
|
353
|
+
throw new Error("string expected");
|
|
354
|
+
return new Uint8Array(new TextEncoder().encode(t));
|
|
355
|
+
}
|
|
356
|
+
function Ln(t) {
|
|
357
|
+
return typeof t == "string" && (t = rs(t)), vt(t), t;
|
|
358
|
+
}
|
|
359
|
+
class ss {
|
|
360
|
+
}
|
|
361
|
+
function os(t) {
|
|
362
|
+
const e = (r) => t().update(Ln(r)).digest(), n = t();
|
|
363
|
+
return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
|
|
364
|
+
}
|
|
365
|
+
function is(t, e, n, r) {
|
|
366
|
+
if (typeof t.setBigUint64 == "function")
|
|
367
|
+
return t.setBigUint64(e, n, r);
|
|
368
|
+
const c = BigInt(32), s = BigInt(4294967295), o = Number(n >> c & s), i = Number(n & s), a = r ? 4 : 0, u = r ? 0 : 4;
|
|
369
|
+
t.setUint32(e + a, o, r), t.setUint32(e + u, i, r);
|
|
370
|
+
}
|
|
371
|
+
function cs(t, e, n) {
|
|
372
|
+
return t & e ^ ~t & n;
|
|
373
|
+
}
|
|
374
|
+
function as(t, e, n) {
|
|
375
|
+
return t & e ^ t & n ^ e & n;
|
|
376
|
+
}
|
|
377
|
+
class us extends ss {
|
|
378
|
+
constructor(e, n, r, c) {
|
|
379
|
+
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = n, this.padOffset = r, this.isLE = c, this.buffer = new Uint8Array(e), this.view = it(this.buffer);
|
|
380
|
+
}
|
|
381
|
+
update(e) {
|
|
382
|
+
Pt(this), e = Ln(e), vt(e);
|
|
383
|
+
const { view: n, buffer: r, blockLen: c } = this, s = e.length;
|
|
384
|
+
for (let o = 0; o < s; ) {
|
|
385
|
+
const i = Math.min(c - this.pos, s - o);
|
|
386
|
+
if (i === c) {
|
|
387
|
+
const a = it(e);
|
|
388
|
+
for (; c <= s - o; o += c)
|
|
389
|
+
this.process(a, o);
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
r.set(e.subarray(o, o + i), this.pos), this.pos += i, o += i, this.pos === c && (this.process(n, 0), this.pos = 0);
|
|
393
|
+
}
|
|
394
|
+
return this.length += e.length, this.roundClean(), this;
|
|
395
|
+
}
|
|
396
|
+
digestInto(e) {
|
|
397
|
+
Pt(this), ns(e, this), this.finished = !0;
|
|
398
|
+
const { buffer: n, view: r, blockLen: c, isLE: s } = this;
|
|
399
|
+
let { pos: o } = this;
|
|
400
|
+
n[o++] = 128, dt(this.buffer.subarray(o)), this.padOffset > c - o && (this.process(r, 0), o = 0);
|
|
401
|
+
for (let p = o; p < c; p++)
|
|
402
|
+
n[p] = 0;
|
|
403
|
+
is(r, c - 8, BigInt(this.length * 8), s), this.process(r, 0);
|
|
404
|
+
const i = it(e), a = this.outputLen;
|
|
405
|
+
if (a % 4)
|
|
406
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
407
|
+
const u = a / 4, f = this.get();
|
|
408
|
+
if (u > f.length)
|
|
409
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
410
|
+
for (let p = 0; p < u; p++)
|
|
411
|
+
i.setUint32(4 * p, f[p], s);
|
|
412
|
+
}
|
|
413
|
+
digest() {
|
|
414
|
+
const { buffer: e, outputLen: n } = this;
|
|
415
|
+
this.digestInto(e);
|
|
416
|
+
const r = e.slice(0, n);
|
|
417
|
+
return this.destroy(), r;
|
|
418
|
+
}
|
|
419
|
+
_cloneInto(e) {
|
|
420
|
+
e || (e = new this.constructor()), e.set(...this.get());
|
|
421
|
+
const { blockLen: n, buffer: r, length: c, finished: s, destroyed: o, pos: i } = this;
|
|
422
|
+
return e.destroyed = o, e.finished = s, e.length = c, e.pos = i, c % n && e.buffer.set(r), e;
|
|
423
|
+
}
|
|
424
|
+
clone() {
|
|
425
|
+
return this._cloneInto();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
const W = /* @__PURE__ */ Uint32Array.from([
|
|
429
|
+
1779033703,
|
|
430
|
+
3144134277,
|
|
431
|
+
1013904242,
|
|
432
|
+
2773480762,
|
|
433
|
+
1359893119,
|
|
434
|
+
2600822924,
|
|
435
|
+
528734635,
|
|
436
|
+
1541459225
|
|
437
|
+
]), fs = /* @__PURE__ */ Uint32Array.from([
|
|
438
|
+
1116352408,
|
|
439
|
+
1899447441,
|
|
440
|
+
3049323471,
|
|
441
|
+
3921009573,
|
|
442
|
+
961987163,
|
|
443
|
+
1508970993,
|
|
444
|
+
2453635748,
|
|
445
|
+
2870763221,
|
|
446
|
+
3624381080,
|
|
447
|
+
310598401,
|
|
448
|
+
607225278,
|
|
449
|
+
1426881987,
|
|
450
|
+
1925078388,
|
|
451
|
+
2162078206,
|
|
452
|
+
2614888103,
|
|
453
|
+
3248222580,
|
|
454
|
+
3835390401,
|
|
455
|
+
4022224774,
|
|
456
|
+
264347078,
|
|
457
|
+
604807628,
|
|
458
|
+
770255983,
|
|
459
|
+
1249150122,
|
|
460
|
+
1555081692,
|
|
461
|
+
1996064986,
|
|
462
|
+
2554220882,
|
|
463
|
+
2821834349,
|
|
464
|
+
2952996808,
|
|
465
|
+
3210313671,
|
|
466
|
+
3336571891,
|
|
467
|
+
3584528711,
|
|
468
|
+
113926993,
|
|
469
|
+
338241895,
|
|
470
|
+
666307205,
|
|
471
|
+
773529912,
|
|
472
|
+
1294757372,
|
|
473
|
+
1396182291,
|
|
474
|
+
1695183700,
|
|
475
|
+
1986661051,
|
|
476
|
+
2177026350,
|
|
477
|
+
2456956037,
|
|
478
|
+
2730485921,
|
|
479
|
+
2820302411,
|
|
480
|
+
3259730800,
|
|
481
|
+
3345764771,
|
|
482
|
+
3516065817,
|
|
483
|
+
3600352804,
|
|
484
|
+
4094571909,
|
|
485
|
+
275423344,
|
|
486
|
+
430227734,
|
|
487
|
+
506948616,
|
|
488
|
+
659060556,
|
|
489
|
+
883997877,
|
|
490
|
+
958139571,
|
|
491
|
+
1322822218,
|
|
492
|
+
1537002063,
|
|
493
|
+
1747873779,
|
|
494
|
+
1955562222,
|
|
495
|
+
2024104815,
|
|
496
|
+
2227730452,
|
|
497
|
+
2361852424,
|
|
498
|
+
2428436474,
|
|
499
|
+
2756734187,
|
|
500
|
+
3204031479,
|
|
501
|
+
3329325298
|
|
502
|
+
]), G = /* @__PURE__ */ new Uint32Array(64);
|
|
503
|
+
class ps extends us {
|
|
504
|
+
constructor(e = 32) {
|
|
505
|
+
super(64, e, 8, !1), this.A = W[0] | 0, this.B = W[1] | 0, this.C = W[2] | 0, this.D = W[3] | 0, this.E = W[4] | 0, this.F = W[5] | 0, this.G = W[6] | 0, this.H = W[7] | 0;
|
|
506
|
+
}
|
|
507
|
+
get() {
|
|
508
|
+
const { A: e, B: n, C: r, D: c, E: s, F: o, G: i, H: a } = this;
|
|
509
|
+
return [e, n, r, c, s, o, i, a];
|
|
510
|
+
}
|
|
511
|
+
// prettier-ignore
|
|
512
|
+
set(e, n, r, c, s, o, i, a) {
|
|
513
|
+
this.A = e | 0, this.B = n | 0, this.C = r | 0, this.D = c | 0, this.E = s | 0, this.F = o | 0, this.G = i | 0, this.H = a | 0;
|
|
514
|
+
}
|
|
515
|
+
process(e, n) {
|
|
516
|
+
for (let p = 0; p < 16; p++, n += 4)
|
|
517
|
+
G[p] = e.getUint32(n, !1);
|
|
518
|
+
for (let p = 16; p < 64; p++) {
|
|
519
|
+
const g = G[p - 15], y = G[p - 2], h = B(g, 7) ^ B(g, 18) ^ g >>> 3, d = B(y, 17) ^ B(y, 19) ^ y >>> 10;
|
|
520
|
+
G[p] = d + G[p - 7] + h + G[p - 16] | 0;
|
|
521
|
+
}
|
|
522
|
+
let { A: r, B: c, C: s, D: o, E: i, F: a, G: u, H: f } = this;
|
|
523
|
+
for (let p = 0; p < 64; p++) {
|
|
524
|
+
const g = B(i, 6) ^ B(i, 11) ^ B(i, 25), y = f + g + cs(i, a, u) + fs[p] + G[p] | 0, d = (B(r, 2) ^ B(r, 13) ^ B(r, 22)) + as(r, c, s) | 0;
|
|
525
|
+
f = u, u = a, a = i, i = o + y | 0, o = s, s = c, c = r, r = y + d | 0;
|
|
526
|
+
}
|
|
527
|
+
r = r + this.A | 0, c = c + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, i = i + this.E | 0, a = a + this.F | 0, u = u + this.G | 0, f = f + this.H | 0, this.set(r, c, s, o, i, a, u, f);
|
|
528
|
+
}
|
|
529
|
+
roundClean() {
|
|
530
|
+
dt(G);
|
|
531
|
+
}
|
|
532
|
+
destroy() {
|
|
533
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), dt(this.buffer);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
const hs = /* @__PURE__ */ os(() => new ps()), Nt = hs;
|
|
537
|
+
function ls(t) {
|
|
538
|
+
if (t.length >= 255)
|
|
539
|
+
throw new TypeError("Alphabet too long");
|
|
540
|
+
const e = new Uint8Array(256);
|
|
541
|
+
for (let u = 0; u < e.length; u++)
|
|
542
|
+
e[u] = 255;
|
|
543
|
+
for (let u = 0; u < t.length; u++) {
|
|
544
|
+
const f = t.charAt(u), p = f.charCodeAt(0);
|
|
545
|
+
if (e[p] !== 255)
|
|
546
|
+
throw new TypeError(f + " is ambiguous");
|
|
547
|
+
e[p] = u;
|
|
548
|
+
}
|
|
549
|
+
const n = t.length, r = t.charAt(0), c = Math.log(n) / Math.log(256), s = Math.log(256) / Math.log(n);
|
|
550
|
+
function o(u) {
|
|
551
|
+
if (u instanceof Uint8Array || (ArrayBuffer.isView(u) ? u = new Uint8Array(u.buffer, u.byteOffset, u.byteLength) : Array.isArray(u) && (u = Uint8Array.from(u))), !(u instanceof Uint8Array))
|
|
552
|
+
throw new TypeError("Expected Uint8Array");
|
|
553
|
+
if (u.length === 0)
|
|
554
|
+
return "";
|
|
555
|
+
let f = 0, p = 0, g = 0;
|
|
556
|
+
const y = u.length;
|
|
557
|
+
for (; g !== y && u[g] === 0; )
|
|
558
|
+
g++, f++;
|
|
559
|
+
const h = (y - g) * s + 1 >>> 0, d = new Uint8Array(h);
|
|
560
|
+
for (; g !== y; ) {
|
|
561
|
+
let S = u[g], b = 0;
|
|
562
|
+
for (let _ = h - 1; (S !== 0 || b < p) && _ !== -1; _--, b++)
|
|
563
|
+
S += 256 * d[_] >>> 0, d[_] = S % n >>> 0, S = S / n >>> 0;
|
|
564
|
+
if (S !== 0)
|
|
565
|
+
throw new Error("Non-zero carry");
|
|
566
|
+
p = b, g++;
|
|
567
|
+
}
|
|
568
|
+
let w = h - p;
|
|
569
|
+
for (; w !== h && d[w] === 0; )
|
|
570
|
+
w++;
|
|
571
|
+
let E = r.repeat(f);
|
|
572
|
+
for (; w < h; ++w)
|
|
573
|
+
E += t.charAt(d[w]);
|
|
574
|
+
return E;
|
|
575
|
+
}
|
|
576
|
+
function i(u) {
|
|
577
|
+
if (typeof u != "string")
|
|
578
|
+
throw new TypeError("Expected String");
|
|
579
|
+
if (u.length === 0)
|
|
580
|
+
return new Uint8Array();
|
|
581
|
+
let f = 0, p = 0, g = 0;
|
|
582
|
+
for (; u[f] === r; )
|
|
583
|
+
p++, f++;
|
|
584
|
+
const y = (u.length - f) * c + 1 >>> 0, h = new Uint8Array(y);
|
|
585
|
+
for (; f < u.length; ) {
|
|
586
|
+
const S = u.charCodeAt(f);
|
|
587
|
+
if (S > 255)
|
|
588
|
+
return;
|
|
589
|
+
let b = e[S];
|
|
590
|
+
if (b === 255)
|
|
591
|
+
return;
|
|
592
|
+
let _ = 0;
|
|
593
|
+
for (let v = y - 1; (b !== 0 || _ < g) && v !== -1; v--, _++)
|
|
594
|
+
b += n * h[v] >>> 0, h[v] = b % 256 >>> 0, b = b / 256 >>> 0;
|
|
595
|
+
if (b !== 0)
|
|
596
|
+
throw new Error("Non-zero carry");
|
|
597
|
+
g = _, f++;
|
|
598
|
+
}
|
|
599
|
+
let d = y - g;
|
|
600
|
+
for (; d !== y && h[d] === 0; )
|
|
601
|
+
d++;
|
|
602
|
+
const w = new Uint8Array(p + (y - d));
|
|
603
|
+
let E = p;
|
|
604
|
+
for (; d !== y; )
|
|
605
|
+
w[E++] = h[d++];
|
|
606
|
+
return w;
|
|
607
|
+
}
|
|
608
|
+
function a(u) {
|
|
609
|
+
const f = i(u);
|
|
610
|
+
if (f)
|
|
611
|
+
return f;
|
|
612
|
+
throw new Error("Non-base" + n + " character");
|
|
613
|
+
}
|
|
614
|
+
return {
|
|
615
|
+
encode: o,
|
|
616
|
+
decodeUnsafe: i,
|
|
617
|
+
decode: a
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
var ds = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
621
|
+
const ct = ls(ds);
|
|
622
|
+
function gs(t) {
|
|
623
|
+
function e(s) {
|
|
624
|
+
var o = Uint8Array.from(s), i = t(o), a = o.length + 4, u = new Uint8Array(a);
|
|
625
|
+
return u.set(o, 0), u.set(i.subarray(0, 4), o.length), ct.encode(u);
|
|
626
|
+
}
|
|
627
|
+
function n(s) {
|
|
628
|
+
var o = s.slice(0, -4), i = s.slice(-4), a = t(o);
|
|
629
|
+
if (!(i[0] ^ a[0] | i[1] ^ a[1] | i[2] ^ a[2] | i[3] ^ a[3]))
|
|
630
|
+
return o;
|
|
631
|
+
}
|
|
632
|
+
function r(s) {
|
|
633
|
+
var o = ct.decodeUnsafe(s);
|
|
634
|
+
if (o != null)
|
|
635
|
+
return n(o);
|
|
636
|
+
}
|
|
637
|
+
function c(s) {
|
|
638
|
+
var o = ct.decode(s), i = n(o);
|
|
639
|
+
if (i == null)
|
|
640
|
+
throw new Error("Invalid checksum");
|
|
641
|
+
return i;
|
|
642
|
+
}
|
|
643
|
+
return {
|
|
644
|
+
encode: e,
|
|
645
|
+
decode: c,
|
|
646
|
+
decodeUnsafe: r
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
function ys(t) {
|
|
650
|
+
return Nt(Nt(t));
|
|
651
|
+
}
|
|
652
|
+
const Mn = gs(ys), ke = 40, Ae = 2, xe = 15, Wn = 16, De = 16, Qe = 2, et = 80, Ss = "WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.", Gn = (t) => {
|
|
653
|
+
try {
|
|
654
|
+
const e = l.from(t.subarray(2));
|
|
655
|
+
if (e.length < Ae || e.length > ke)
|
|
656
|
+
throw new TypeError("Invalid program length for segwit address");
|
|
657
|
+
const n = t[0] - et;
|
|
658
|
+
if (n < Qe || n > xe + 1)
|
|
659
|
+
throw new TypeError("Invalid version for segwit address");
|
|
660
|
+
if (n === 1) throw new TypeError("taproot");
|
|
661
|
+
return !0;
|
|
662
|
+
} catch {
|
|
663
|
+
}
|
|
664
|
+
return !1;
|
|
665
|
+
};
|
|
666
|
+
function Xn(t, e) {
|
|
667
|
+
if (!l.isBuffer(t)) throw new TypeError("output must be a Buffer");
|
|
668
|
+
if (!e.bech32Opnet) throw new Error("Network does not support opnet");
|
|
669
|
+
const n = t[0];
|
|
670
|
+
let r = 1, c;
|
|
671
|
+
if (t[1] < 76)
|
|
672
|
+
c = t[1], r = 2;
|
|
673
|
+
else if (t[1] === 76)
|
|
674
|
+
c = t[2], r = 3;
|
|
675
|
+
else
|
|
676
|
+
throw new TypeError("Unsupported push opcode in script");
|
|
677
|
+
const s = l.from(t.subarray(r, r + c));
|
|
678
|
+
if (s.length < Ae || s.length > ke)
|
|
679
|
+
throw new TypeError("Invalid program length for segwit address");
|
|
680
|
+
const o = n === Ce.OP_0 ? 0 : n >= Ce.OP_1 && n <= Ce.OP_16 ? n - (Ce.OP_1 - 1) : -1;
|
|
681
|
+
if (o < xe || o > Wn)
|
|
682
|
+
throw new TypeError(`Invalid segwit version ${o}`);
|
|
683
|
+
const i = [o, ...M.bech32m.toWords(s)];
|
|
684
|
+
return M.bech32m.encode(e.bech32Opnet, i);
|
|
685
|
+
}
|
|
686
|
+
function qn(t, e) {
|
|
687
|
+
const n = l.from(t.subarray(2));
|
|
688
|
+
if (n.length < Ae || n.length > ke)
|
|
689
|
+
throw new TypeError("Invalid program length for segwit address");
|
|
690
|
+
const r = t[0] - et;
|
|
691
|
+
if (r < Qe || r > xe)
|
|
692
|
+
throw new TypeError("Invalid version for segwit address");
|
|
693
|
+
if (t[1] !== n.length)
|
|
694
|
+
throw new TypeError(`Invalid script for segwit address ${t[1]} !== ${n.length}`);
|
|
695
|
+
return jn(n, r, e.bech32, e.bech32Opnet);
|
|
696
|
+
}
|
|
697
|
+
function Dn(t) {
|
|
698
|
+
const e = l.from(Mn.decode(t));
|
|
699
|
+
if (e.length < 21) throw new TypeError(t + " is too short");
|
|
700
|
+
if (e.length > 21) throw new TypeError(t + " is too long");
|
|
701
|
+
const n = e.readUInt8(0), r = l.from(e.subarray(1));
|
|
702
|
+
return { version: n, hash: r };
|
|
703
|
+
}
|
|
704
|
+
function Vn(t) {
|
|
705
|
+
let e, n;
|
|
706
|
+
try {
|
|
707
|
+
e = M.bech32.decode(t);
|
|
708
|
+
} catch {
|
|
709
|
+
}
|
|
710
|
+
if (e) {
|
|
711
|
+
if (n = e.words[0], n !== 0) throw new TypeError(t + " uses wrong encoding");
|
|
712
|
+
} else if (e = M.bech32m.decode(t), n = e.words[0], n === 0) throw new TypeError(t + " uses wrong encoding");
|
|
713
|
+
const r = M.bech32.fromWords(e.words.slice(1));
|
|
714
|
+
return {
|
|
715
|
+
version: n,
|
|
716
|
+
prefix: e.prefix,
|
|
717
|
+
data: l.from(r)
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
function bs(t, e) {
|
|
721
|
+
Hr(Ur(Br, Rr), [t, e]);
|
|
722
|
+
const n = l.allocUnsafe(21);
|
|
723
|
+
return n.writeUInt8(e, 0), t.copy(n, 1), Mn.encode(n);
|
|
724
|
+
}
|
|
725
|
+
function jn(t, e, n, r) {
|
|
726
|
+
const c = M.bech32.toWords(t);
|
|
727
|
+
return c.unshift(e), e === De && r ? M.bech32m.encode(r, c) : e === 0 ? M.bech32.encode(n, c) : M.bech32m.encode(n, c);
|
|
728
|
+
}
|
|
729
|
+
function zn(t, e) {
|
|
730
|
+
e = e || Je;
|
|
731
|
+
try {
|
|
732
|
+
return _e({ output: t, network: e }).address;
|
|
733
|
+
} catch {
|
|
734
|
+
}
|
|
735
|
+
try {
|
|
736
|
+
return me({ output: t, network: e }).address;
|
|
737
|
+
} catch {
|
|
738
|
+
}
|
|
739
|
+
try {
|
|
740
|
+
return $e({ output: t, network: e }).address;
|
|
741
|
+
} catch {
|
|
742
|
+
}
|
|
743
|
+
try {
|
|
744
|
+
return ve({ output: t, network: e }).address;
|
|
745
|
+
} catch {
|
|
746
|
+
}
|
|
747
|
+
try {
|
|
748
|
+
return Ie({ output: t, network: e }).address;
|
|
749
|
+
} catch {
|
|
750
|
+
}
|
|
751
|
+
try {
|
|
752
|
+
return Xn(t, e);
|
|
753
|
+
} catch {
|
|
754
|
+
}
|
|
755
|
+
try {
|
|
756
|
+
return qn(t, e);
|
|
757
|
+
} catch {
|
|
758
|
+
}
|
|
759
|
+
throw new Error(Or(t) + " has no matching Address");
|
|
760
|
+
}
|
|
761
|
+
function $n(t, e) {
|
|
762
|
+
e = e || Je;
|
|
763
|
+
let n, r;
|
|
764
|
+
try {
|
|
765
|
+
n = Dn(t);
|
|
766
|
+
} catch {
|
|
767
|
+
}
|
|
768
|
+
if (n) {
|
|
769
|
+
if (n.version === e.pubKeyHash)
|
|
770
|
+
return _e({ hash: n.hash }).output;
|
|
771
|
+
if (n.version === e.scriptHash)
|
|
772
|
+
return me({ hash: n.hash }).output;
|
|
773
|
+
} else {
|
|
774
|
+
try {
|
|
775
|
+
r = Vn(t);
|
|
776
|
+
} catch {
|
|
777
|
+
}
|
|
778
|
+
if (r) {
|
|
779
|
+
if (r.prefix !== e.bech32 && e.bech32Opnet && r.prefix !== e.bech32Opnet)
|
|
780
|
+
throw new Error(t + " has an invalid prefix");
|
|
781
|
+
if (r.version === 0) {
|
|
782
|
+
if (r.data.length === 20)
|
|
783
|
+
return $e({ hash: r.data }).output;
|
|
784
|
+
if (r.data.length === 32)
|
|
785
|
+
return ve({ hash: r.data }).output;
|
|
786
|
+
} else if (r.version === 1) {
|
|
787
|
+
if (r.data.length === 32)
|
|
788
|
+
return Ie({ pubkey: r.data }).output;
|
|
789
|
+
} else if (r.version === De) {
|
|
790
|
+
if (!e.bech32Opnet) throw new Error(t + " has an invalid prefix");
|
|
791
|
+
return Rn({
|
|
792
|
+
program: r.data,
|
|
793
|
+
network: e
|
|
794
|
+
}).output;
|
|
795
|
+
} else if (r.version >= Qe && r.version <= xe && r.data.length >= Ae && r.data.length <= ke)
|
|
796
|
+
return r.version !== De && console.warn(Ss), Cr([
|
|
797
|
+
r.version + et,
|
|
798
|
+
r.data
|
|
799
|
+
]);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
throw new TypeError(t + " has no matching Script");
|
|
803
|
+
}
|
|
804
|
+
const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
805
|
+
__proto__: null,
|
|
806
|
+
FUTURE_MAX_VERSION: Wn,
|
|
807
|
+
FUTURE_OPNET_VERSION: De,
|
|
808
|
+
FUTURE_SEGWIT_MAX_SIZE: ke,
|
|
809
|
+
FUTURE_SEGWIT_MAX_VERSION: xe,
|
|
810
|
+
FUTURE_SEGWIT_MIN_SIZE: Ae,
|
|
811
|
+
FUTURE_SEGWIT_MIN_VERSION: Qe,
|
|
812
|
+
FUTURE_SEGWIT_VERSION_DIFF: et,
|
|
813
|
+
_toFutureSegwitAddress: qn,
|
|
814
|
+
fromBase58Check: Dn,
|
|
815
|
+
fromBech32: Vn,
|
|
816
|
+
fromOutputScript: zn,
|
|
817
|
+
isUnknownSegwitVersion: Gn,
|
|
818
|
+
toBase58Check: bs,
|
|
819
|
+
toBech32: jn,
|
|
820
|
+
toFutureOPNetAddress: Xn,
|
|
821
|
+
toOutputScript: $n
|
|
822
|
+
}, Symbol.toStringTag, { value: "Module" })), be = {};
|
|
823
|
+
function Qo(t) {
|
|
824
|
+
t ? t !== be.eccLib && (Es(t), be.eccLib = t) : be.eccLib = t;
|
|
825
|
+
}
|
|
826
|
+
function ei() {
|
|
827
|
+
if (!be.eccLib)
|
|
828
|
+
throw new Error(
|
|
829
|
+
"No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance"
|
|
830
|
+
);
|
|
831
|
+
return be.eccLib;
|
|
832
|
+
}
|
|
833
|
+
const F = (t) => l.from(t, "hex");
|
|
834
|
+
function Es(t) {
|
|
835
|
+
P(typeof t.isXOnlyPoint == "function"), P(t.isXOnlyPoint(F("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))), P(t.isXOnlyPoint(F("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))), P(t.isXOnlyPoint(F("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))), P(t.isXOnlyPoint(F("0000000000000000000000000000000000000000000000000000000000000001"))), P(
|
|
836
|
+
!t.isXOnlyPoint(F("0000000000000000000000000000000000000000000000000000000000000000"))
|
|
837
|
+
), P(
|
|
838
|
+
!t.isXOnlyPoint(F("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))
|
|
839
|
+
), P(typeof t.xOnlyPointAddTweak == "function"), Ts.forEach((e) => {
|
|
840
|
+
const n = t.xOnlyPointAddTweak(F(e.pubkey), F(e.tweak));
|
|
841
|
+
e.result === null ? P(n === null) : (P(n !== null), P(n.parity === e.parity), P(l.from(n.xOnlyPubkey).equals(F(e.result))));
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
function P(t) {
|
|
845
|
+
if (!t) throw new Error("ecc library invalid");
|
|
846
|
+
}
|
|
847
|
+
const Ts = [
|
|
848
|
+
{
|
|
849
|
+
pubkey: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
|
|
850
|
+
tweak: "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",
|
|
851
|
+
parity: -1,
|
|
852
|
+
result: null
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
pubkey: "1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",
|
|
856
|
+
tweak: "a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",
|
|
857
|
+
parity: 1,
|
|
858
|
+
result: "e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
pubkey: "2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",
|
|
862
|
+
tweak: "823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",
|
|
863
|
+
parity: 0,
|
|
864
|
+
result: "9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"
|
|
865
|
+
}
|
|
866
|
+
];
|
|
867
|
+
const _s = {
|
|
868
|
+
p: 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,
|
|
869
|
+
n: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
|
|
870
|
+
b: 7n,
|
|
871
|
+
Gx: 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,
|
|
872
|
+
Gy: 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n
|
|
873
|
+
}, { p: ie, n: Yn, Gx: ms, Gy: vs, b: Zn } = _s, Xe = 32, gt = 64, N = (t = "") => {
|
|
874
|
+
throw new Error(t);
|
|
875
|
+
}, Jn = (t) => typeof t == "bigint", Qn = (t) => typeof t == "string", Is = (t) => t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array", Te = (t, e) => !Is(t) || typeof e == "number" && e > 0 && t.length !== e ? N("Uint8Array expected") : t, er = (t) => new Uint8Array(t), ks = (t) => Uint8Array.from(t), tr = (t, e) => t.toString(16).padStart(e, "0"), nr = (t) => Array.from(Te(t)).map((e) => tr(e, 2)).join(""), K = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }, Ht = (t) => {
|
|
876
|
+
if (t >= K._0 && t <= K._9)
|
|
877
|
+
return t - K._0;
|
|
878
|
+
if (t >= K.A && t <= K.F)
|
|
879
|
+
return t - (K.A - 10);
|
|
880
|
+
if (t >= K.a && t <= K.f)
|
|
881
|
+
return t - (K.a - 10);
|
|
882
|
+
}, rr = (t) => {
|
|
883
|
+
const e = "hex invalid";
|
|
884
|
+
if (!Qn(t))
|
|
885
|
+
return N(e);
|
|
886
|
+
const n = t.length, r = n / 2;
|
|
887
|
+
if (n % 2)
|
|
888
|
+
return N(e);
|
|
889
|
+
const c = er(r);
|
|
890
|
+
for (let s = 0, o = 0; s < r; s++, o += 2) {
|
|
891
|
+
const i = Ht(t.charCodeAt(o)), a = Ht(t.charCodeAt(o + 1));
|
|
892
|
+
if (i === void 0 || a === void 0)
|
|
893
|
+
return N(e);
|
|
894
|
+
c[s] = i * 16 + a;
|
|
895
|
+
}
|
|
896
|
+
return c;
|
|
897
|
+
}, sr = (t, e) => Te(Qn(t) ? rr(t) : ks(Te(t)), e), Ut = (...t) => {
|
|
898
|
+
const e = er(t.reduce((r, c) => r + Te(c).length, 0));
|
|
899
|
+
let n = 0;
|
|
900
|
+
return t.forEach((r) => {
|
|
901
|
+
e.set(r, n), n += r.length;
|
|
902
|
+
}), e;
|
|
903
|
+
}, Ve = BigInt, Oe = (t, e, n, r = "bad number: out of range") => Jn(t) && e <= t && t < n ? t : N(r), T = (t, e = ie) => {
|
|
904
|
+
const n = t % e;
|
|
905
|
+
return n >= 0n ? n : e + n;
|
|
906
|
+
}, As = (t, e) => {
|
|
907
|
+
(t === 0n || e <= 0n) && N("no inverse n=" + t + " mod=" + e);
|
|
908
|
+
let n = T(t, e), r = e, c = 0n, s = 1n;
|
|
909
|
+
for (; n !== 0n; ) {
|
|
910
|
+
const o = r / n, i = r % n, a = c - s * o;
|
|
911
|
+
r = n, n = i, c = s, s = a;
|
|
912
|
+
}
|
|
913
|
+
return r === 1n ? T(c, e) : N("no inverse");
|
|
914
|
+
}, Bt = (t) => t instanceof O ? t : N("Point expected"), or = (t) => T(T(t * t) * t + Zn), Rt = (t) => Oe(t, 0n, ie), qe = (t) => Oe(t, 1n, ie), xs = (t) => Oe(t, 1n, Yn), yt = (t) => (t & 1n) === 0n, ir = (t) => Uint8Array.of(t), Os = (t) => ir(yt(t) ? 2 : 3), Cs = (t) => {
|
|
915
|
+
const e = or(qe(t));
|
|
916
|
+
let n = 1n;
|
|
917
|
+
for (let r = e, c = (ie + 1n) / 4n; c > 0n; c >>= 1n)
|
|
918
|
+
c & 1n && (n = n * r % ie), r = r * r % ie;
|
|
919
|
+
return T(n * n) === e ? n : N("sqrt invalid");
|
|
920
|
+
};
|
|
921
|
+
class O {
|
|
922
|
+
static BASE;
|
|
923
|
+
static ZERO;
|
|
924
|
+
px;
|
|
925
|
+
py;
|
|
926
|
+
pz;
|
|
927
|
+
constructor(e, n, r) {
|
|
928
|
+
this.px = Rt(e), this.py = qe(n), this.pz = Rt(r), Object.freeze(this);
|
|
929
|
+
}
|
|
930
|
+
/** Convert Uint8Array or hex string to Point. */
|
|
931
|
+
static fromBytes(e) {
|
|
932
|
+
Te(e);
|
|
933
|
+
let n;
|
|
934
|
+
const r = e[0], c = e.subarray(1), s = Ft(c, 0, Xe), o = e.length;
|
|
935
|
+
if (o === Xe + 1 && [2, 3].includes(r)) {
|
|
936
|
+
let i = Cs(s);
|
|
937
|
+
const a = yt(i);
|
|
938
|
+
yt(Ve(r)) !== a && (i = T(-i)), n = new O(s, i, 1n);
|
|
939
|
+
}
|
|
940
|
+
return o === gt + 1 && r === 4 && (n = new O(s, Ft(c, Xe, gt), 1n)), n ? n.assertValidity() : N("bad point: not on curve");
|
|
941
|
+
}
|
|
942
|
+
/** Equality check: compare points P&Q. */
|
|
943
|
+
equals(e) {
|
|
944
|
+
const { px: n, py: r, pz: c } = this, { px: s, py: o, pz: i } = Bt(e), a = T(n * i), u = T(s * c), f = T(r * i), p = T(o * c);
|
|
945
|
+
return a === u && f === p;
|
|
946
|
+
}
|
|
947
|
+
is0() {
|
|
948
|
+
return this.equals(oe);
|
|
949
|
+
}
|
|
950
|
+
/** Flip point over y coordinate. */
|
|
951
|
+
negate() {
|
|
952
|
+
return new O(this.px, T(-this.py), this.pz);
|
|
953
|
+
}
|
|
954
|
+
/** Point doubling: P+P, complete formula. */
|
|
955
|
+
double() {
|
|
956
|
+
return this.add(this);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Point addition: P+Q, complete, exception-free formula
|
|
960
|
+
* (Renes-Costello-Batina, algo 1 of [2015/1060](https://eprint.iacr.org/2015/1060)).
|
|
961
|
+
* Cost: `12M + 0S + 3*a + 3*b3 + 23add`.
|
|
962
|
+
*/
|
|
963
|
+
// prettier-ignore
|
|
964
|
+
add(e) {
|
|
965
|
+
const { px: n, py: r, pz: c } = this, { px: s, py: o, pz: i } = Bt(e), a = 0n, u = Zn;
|
|
966
|
+
let f = 0n, p = 0n, g = 0n;
|
|
967
|
+
const y = T(u * 3n);
|
|
968
|
+
let h = T(n * s), d = T(r * o), w = T(c * i), E = T(n + r), S = T(s + o);
|
|
969
|
+
E = T(E * S), S = T(h + d), E = T(E - S), S = T(n + c);
|
|
970
|
+
let b = T(s + i);
|
|
971
|
+
return S = T(S * b), b = T(h + w), S = T(S - b), b = T(r + c), f = T(o + i), b = T(b * f), f = T(d + w), b = T(b - f), g = T(a * S), f = T(y * w), g = T(f + g), f = T(d - g), g = T(d + g), p = T(f * g), d = T(h + h), d = T(d + h), w = T(a * w), S = T(y * S), d = T(d + w), w = T(h - w), w = T(a * w), S = T(S + w), h = T(d * S), p = T(p + h), h = T(b * S), f = T(E * f), f = T(f - h), h = T(E * d), g = T(b * g), g = T(g + h), new O(f, p, g);
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Point-by-scalar multiplication. Scalar must be in range 1 <= n < CURVE.n.
|
|
975
|
+
* Uses {@link wNAF} for base point.
|
|
976
|
+
* Uses fake point to mitigate side-channel leakage.
|
|
977
|
+
* @param n scalar by which point is multiplied
|
|
978
|
+
* @param safe safe mode guards against timing attacks; unsafe mode is faster
|
|
979
|
+
*/
|
|
980
|
+
multiply(e, n = !0) {
|
|
981
|
+
if (!n && e === 0n)
|
|
982
|
+
return oe;
|
|
983
|
+
if (xs(e), e === 1n)
|
|
984
|
+
return this;
|
|
985
|
+
if (this.equals(fe))
|
|
986
|
+
return Bs(e).p;
|
|
987
|
+
let r = oe, c = fe;
|
|
988
|
+
for (let s = this; e > 0n; s = s.double(), e >>= 1n)
|
|
989
|
+
e & 1n ? r = r.add(s) : n && (c = c.add(s));
|
|
990
|
+
return r;
|
|
991
|
+
}
|
|
992
|
+
/** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
|
|
993
|
+
toAffine() {
|
|
994
|
+
const { px: e, py: n, pz: r } = this;
|
|
995
|
+
if (this.equals(oe))
|
|
996
|
+
return { x: 0n, y: 0n };
|
|
997
|
+
if (r === 1n)
|
|
998
|
+
return { x: e, y: n };
|
|
999
|
+
const c = As(r, ie);
|
|
1000
|
+
return T(r * c) !== 1n && N("inverse invalid"), { x: T(e * c), y: T(n * c) };
|
|
1001
|
+
}
|
|
1002
|
+
/** Checks if the point is valid and on-curve. */
|
|
1003
|
+
assertValidity() {
|
|
1004
|
+
const { x: e, y: n } = this.toAffine();
|
|
1005
|
+
return qe(e), qe(n), T(n * n) === or(e) ? this : N("bad point: not on curve");
|
|
1006
|
+
}
|
|
1007
|
+
/** Converts point to 33/65-byte Uint8Array. */
|
|
1008
|
+
toBytes(e = !0) {
|
|
1009
|
+
const { x: n, y: r } = this.assertValidity().toAffine(), c = Kt(n);
|
|
1010
|
+
return e ? Ut(Os(r), c) : Ut(ir(4), c, Kt(r));
|
|
1011
|
+
}
|
|
1012
|
+
/** Create 3d xyz point from 2d xy. (0, 0) => (0, 1, 0), not (0, 0, 1) */
|
|
1013
|
+
static fromAffine(e) {
|
|
1014
|
+
const { x: n, y: r } = e;
|
|
1015
|
+
return n === 0n && r === 0n ? oe : new O(n, r, 1n);
|
|
1016
|
+
}
|
|
1017
|
+
toHex(e) {
|
|
1018
|
+
return nr(this.toBytes(e));
|
|
1019
|
+
}
|
|
1020
|
+
static fromPrivateKey(e) {
|
|
1021
|
+
return fe.multiply(Ns(e));
|
|
1022
|
+
}
|
|
1023
|
+
static fromHex(e) {
|
|
1024
|
+
return O.fromBytes(sr(e));
|
|
1025
|
+
}
|
|
1026
|
+
get x() {
|
|
1027
|
+
return this.toAffine().x;
|
|
1028
|
+
}
|
|
1029
|
+
get y() {
|
|
1030
|
+
return this.toAffine().y;
|
|
1031
|
+
}
|
|
1032
|
+
toRawBytes(e) {
|
|
1033
|
+
return this.toBytes(e);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
const fe = new O(ms, vs, 1n), oe = new O(0n, 1n, 0n);
|
|
1037
|
+
O.BASE = fe;
|
|
1038
|
+
O.ZERO = oe;
|
|
1039
|
+
const cr = (t) => Ve("0x" + (nr(t) || "0")), Ft = (t, e, n) => cr(t.subarray(e, n)), Ps = 2n ** 256n, Kt = (t) => rr(tr(Oe(t, 0n, Ps), gt)), Ns = (t) => {
|
|
1040
|
+
const e = Jn(t) ? t : cr(sr(t, Xe));
|
|
1041
|
+
return Oe(e, 1n, Yn, "private key invalid 3");
|
|
1042
|
+
}, je = 8, Hs = 256, ar = Math.ceil(Hs / je) + 1, St = 2 ** (je - 1), Us = () => {
|
|
1043
|
+
const t = [];
|
|
1044
|
+
let e = fe, n = e;
|
|
1045
|
+
for (let r = 0; r < ar; r++) {
|
|
1046
|
+
n = e, t.push(n);
|
|
1047
|
+
for (let c = 1; c < St; c++)
|
|
1048
|
+
n = n.add(e), t.push(n);
|
|
1049
|
+
e = n.double();
|
|
1050
|
+
}
|
|
1051
|
+
return t;
|
|
1052
|
+
};
|
|
1053
|
+
let Lt;
|
|
1054
|
+
const Mt = (t, e) => {
|
|
1055
|
+
const n = e.negate();
|
|
1056
|
+
return t ? n : e;
|
|
1057
|
+
}, Bs = (t) => {
|
|
1058
|
+
const e = Lt || (Lt = Us());
|
|
1059
|
+
let n = oe, r = fe;
|
|
1060
|
+
const c = 2 ** je, s = c, o = Ve(c - 1), i = Ve(je);
|
|
1061
|
+
for (let a = 0; a < ar; a++) {
|
|
1062
|
+
let u = Number(t & o);
|
|
1063
|
+
t >>= i, u > St && (u -= s, t += 1n);
|
|
1064
|
+
const f = a * St, p = f, g = f + Math.abs(u) - 1, y = a % 2 !== 0, h = u < 0;
|
|
1065
|
+
u === 0 ? r = r.add(Mt(y, e[p])) : n = n.add(Mt(h, e[g]));
|
|
1066
|
+
}
|
|
1067
|
+
return { p: n, f: r };
|
|
1068
|
+
};
|
|
1069
|
+
var ce = {}, Wt;
|
|
1070
|
+
function le() {
|
|
1071
|
+
if (Wt) return ce;
|
|
1072
|
+
Wt = 1, Object.defineProperty(ce, "__esModule", { value: !0 });
|
|
1073
|
+
const t = 9007199254740991;
|
|
1074
|
+
function e(s) {
|
|
1075
|
+
if (s < 0 || s > t || s % 1 !== 0)
|
|
1076
|
+
throw new RangeError("value out of range");
|
|
1077
|
+
}
|
|
1078
|
+
function n(s, o, i) {
|
|
1079
|
+
if (e(s), o || (o = l.allocUnsafe(c(s))), !l.isBuffer(o))
|
|
1080
|
+
throw new TypeError("buffer must be a Buffer instance");
|
|
1081
|
+
return i || (i = 0), s < 253 ? (o.writeUInt8(s, i), Object.assign(n, { bytes: 1 })) : s <= 65535 ? (o.writeUInt8(253, i), o.writeUInt16LE(s, i + 1), Object.assign(n, { bytes: 3 })) : s <= 4294967295 ? (o.writeUInt8(254, i), o.writeUInt32LE(s, i + 1), Object.assign(n, { bytes: 5 })) : (o.writeUInt8(255, i), o.writeUInt32LE(s >>> 0, i + 1), o.writeUInt32LE(s / 4294967296 | 0, i + 5), Object.assign(n, { bytes: 9 })), o;
|
|
1082
|
+
}
|
|
1083
|
+
ce.encode = n;
|
|
1084
|
+
function r(s, o) {
|
|
1085
|
+
if (!l.isBuffer(s))
|
|
1086
|
+
throw new TypeError("buffer must be a Buffer instance");
|
|
1087
|
+
o || (o = 0);
|
|
1088
|
+
const i = s.readUInt8(o);
|
|
1089
|
+
if (i < 253)
|
|
1090
|
+
return Object.assign(r, { bytes: 1 }), i;
|
|
1091
|
+
if (i === 253)
|
|
1092
|
+
return Object.assign(r, { bytes: 3 }), s.readUInt16LE(o + 1);
|
|
1093
|
+
if (i === 254)
|
|
1094
|
+
return Object.assign(r, { bytes: 5 }), s.readUInt32LE(o + 1);
|
|
1095
|
+
{
|
|
1096
|
+
Object.assign(r, { bytes: 9 });
|
|
1097
|
+
const a = s.readUInt32LE(o + 1), f = s.readUInt32LE(o + 5) * 4294967296 + a;
|
|
1098
|
+
return e(f), f;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
ce.decode = r;
|
|
1102
|
+
function c(s) {
|
|
1103
|
+
return e(s), s < 253 ? 1 : s <= 65535 ? 3 : s <= 4294967295 ? 5 : 9;
|
|
1104
|
+
}
|
|
1105
|
+
return ce.encodingLength = c, ce;
|
|
1106
|
+
}
|
|
1107
|
+
var bt = le();
|
|
1108
|
+
const we = (t) => {
|
|
1109
|
+
const e = t.length === 32 ? t : t.subarray(1, 33);
|
|
1110
|
+
return l.isBuffer(e) ? e : l.from(e);
|
|
1111
|
+
};
|
|
1112
|
+
function Gt(t, e, n) {
|
|
1113
|
+
const r = $s(e, t, n);
|
|
1114
|
+
try {
|
|
1115
|
+
const s = js(e, r).concat(r.script).concat(r.controlBlock);
|
|
1116
|
+
return { finalScriptWitness: Ee(s) };
|
|
1117
|
+
} catch (c) {
|
|
1118
|
+
throw new Error(`Can not finalize taproot input #${t}: ${c}`);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
function Pe(t, e) {
|
|
1122
|
+
const n = e ? l.from([e]) : l.from([]);
|
|
1123
|
+
return l.concat([t, n]);
|
|
1124
|
+
}
|
|
1125
|
+
function H(t) {
|
|
1126
|
+
return t && !!(t.tapInternalKey || t.tapMerkleRoot || t.tapLeafScript && t.tapLeafScript.length || t.tapBip32Derivation && t.tapBip32Derivation.length || t.witnessUtxo && It(t.witnessUtxo.script));
|
|
1127
|
+
}
|
|
1128
|
+
function at(t, e) {
|
|
1129
|
+
return t && !!(t.tapInternalKey || t.tapTree || t.tapBip32Derivation && t.tapBip32Derivation.length || e && It(e));
|
|
1130
|
+
}
|
|
1131
|
+
function Xt(t, e, n) {
|
|
1132
|
+
qs(t, e, n), Vs(t, e, n);
|
|
1133
|
+
}
|
|
1134
|
+
function qt(t, e, n) {
|
|
1135
|
+
Ds(t, e, n), Rs(t, e);
|
|
1136
|
+
}
|
|
1137
|
+
function Rs(t, e) {
|
|
1138
|
+
if (!e.tapTree && !e.tapInternalKey) return;
|
|
1139
|
+
const n = e.tapInternalKey || t.tapInternalKey, r = e.tapTree || t.tapTree;
|
|
1140
|
+
if (n) {
|
|
1141
|
+
const c = t.script, s = Fs(n, r);
|
|
1142
|
+
if (c && !c.equals(s))
|
|
1143
|
+
throw new Error("Error adding output. Script or address missmatch.");
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
function Fs(t, e) {
|
|
1147
|
+
const n = e && Ks(e.leaves), { output: r } = Ie({
|
|
1148
|
+
internalPubkey: t,
|
|
1149
|
+
scriptTree: n
|
|
1150
|
+
});
|
|
1151
|
+
if (!r) throw new Error("Failed to generate taproot script pubkey");
|
|
1152
|
+
return r;
|
|
1153
|
+
}
|
|
1154
|
+
function ti(t, e) {
|
|
1155
|
+
const n = e.tapInternalKey, r = n && Kr(n, e.tapMerkleRoot);
|
|
1156
|
+
if (!r)
|
|
1157
|
+
throw new Error(
|
|
1158
|
+
`Cannot tweak tap internal key for input #${t}. Public key: ${n && n.toString("hex")}`
|
|
1159
|
+
);
|
|
1160
|
+
return r.x;
|
|
1161
|
+
}
|
|
1162
|
+
function ni(t) {
|
|
1163
|
+
if (!Fr(t))
|
|
1164
|
+
throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");
|
|
1165
|
+
return wt(t);
|
|
1166
|
+
}
|
|
1167
|
+
function Ks(t = []) {
|
|
1168
|
+
return t.length === 1 && t[0].depth === 0 ? {
|
|
1169
|
+
output: t[0].script,
|
|
1170
|
+
version: t[0].leafVersion
|
|
1171
|
+
} : Xs(t);
|
|
1172
|
+
}
|
|
1173
|
+
function Ls(t, e) {
|
|
1174
|
+
return Ws(t).some((r) => pr(r, Ms, e));
|
|
1175
|
+
}
|
|
1176
|
+
function Ms(t) {
|
|
1177
|
+
return {
|
|
1178
|
+
signature: t.subarray(0, 64),
|
|
1179
|
+
hashType: t.subarray(64)[0] || I.SIGHASH_DEFAULT
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
function Ws(t) {
|
|
1183
|
+
const e = [];
|
|
1184
|
+
if (t.tapKeySig && e.push(t.tapKeySig), t.tapScriptSig && e.push(...t.tapScriptSig.map((n) => n.signature)), !e.length) {
|
|
1185
|
+
const n = Gs(t.finalScriptWitness);
|
|
1186
|
+
n && e.push(n);
|
|
1187
|
+
}
|
|
1188
|
+
return e;
|
|
1189
|
+
}
|
|
1190
|
+
function Gs(t) {
|
|
1191
|
+
if (!t) return;
|
|
1192
|
+
const e = t.subarray(2);
|
|
1193
|
+
if (e.length === 64 || e.length === 65) return e;
|
|
1194
|
+
}
|
|
1195
|
+
function wt(t, e = [], n = 0) {
|
|
1196
|
+
if (n > Fn) throw new Error("Max taptree depth exceeded.");
|
|
1197
|
+
return t ? Un(t) ? (e.push({
|
|
1198
|
+
depth: n,
|
|
1199
|
+
leafVersion: t.version || Lr,
|
|
1200
|
+
script: t.output
|
|
1201
|
+
}), e) : (t[0] && wt(t[0], e, n + 1), t[1] && wt(t[1], e, n + 1), e) : [];
|
|
1202
|
+
}
|
|
1203
|
+
function Xs(t) {
|
|
1204
|
+
let e;
|
|
1205
|
+
for (const n of t)
|
|
1206
|
+
if (e = Et(n, e), !e) throw new Error("No room left to insert tapleaf in tree");
|
|
1207
|
+
return e;
|
|
1208
|
+
}
|
|
1209
|
+
function Et(t, e, n = 0) {
|
|
1210
|
+
if (n > Fn) throw new Error("Max taptree depth exceeded.");
|
|
1211
|
+
if (t.depth === n)
|
|
1212
|
+
return e ? void 0 : {
|
|
1213
|
+
output: t.script,
|
|
1214
|
+
version: t.leafVersion
|
|
1215
|
+
};
|
|
1216
|
+
if (Un(e)) return;
|
|
1217
|
+
const r = Et(t, e && e[0], n + 1);
|
|
1218
|
+
if (r) return [r, e && e[1]];
|
|
1219
|
+
const c = Et(t, e && e[1], n + 1);
|
|
1220
|
+
if (c) return [e && e[0], c];
|
|
1221
|
+
}
|
|
1222
|
+
function qs(t, e, n) {
|
|
1223
|
+
const r = H(t) && pe(e), c = pe(t) && H(e), s = t === e && H(e) && pe(e);
|
|
1224
|
+
if (r || c || s)
|
|
1225
|
+
throw new Error(
|
|
1226
|
+
`Invalid arguments for Psbt.${n}. Cannot use both taproot and non-taproot fields.`
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
function Ds(t, e, n) {
|
|
1230
|
+
const r = at(t) && pe(e), c = pe(t) && at(e), s = t === e && at(e) && pe(e);
|
|
1231
|
+
if (r || c || s)
|
|
1232
|
+
throw new Error(
|
|
1233
|
+
`Invalid arguments for Psbt.${n}. Cannot use both taproot and non-taproot fields.`
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
function Vs(t, e, n) {
|
|
1237
|
+
if (e.tapMerkleRoot) {
|
|
1238
|
+
const r = (e.tapLeafScript || []).every(
|
|
1239
|
+
(s) => ut(s, e.tapMerkleRoot)
|
|
1240
|
+
), c = (t.tapLeafScript || []).every(
|
|
1241
|
+
(s) => ut(s, e.tapMerkleRoot)
|
|
1242
|
+
);
|
|
1243
|
+
if (!r || !c)
|
|
1244
|
+
throw new Error(`Invalid arguments for Psbt.${n}. Tapleaf not part of taptree.`);
|
|
1245
|
+
} else if (t.tapMerkleRoot && !(e.tapLeafScript || []).every(
|
|
1246
|
+
(c) => ut(c, t.tapMerkleRoot)
|
|
1247
|
+
))
|
|
1248
|
+
throw new Error(`Invalid arguments for Psbt.${n}. Tapleaf not part of taptree.`);
|
|
1249
|
+
}
|
|
1250
|
+
function ut(t, e) {
|
|
1251
|
+
if (!e) return !0;
|
|
1252
|
+
const n = Ye({
|
|
1253
|
+
output: t.script,
|
|
1254
|
+
version: t.leafVersion
|
|
1255
|
+
});
|
|
1256
|
+
return Mr(t.controlBlock, n).equals(e);
|
|
1257
|
+
}
|
|
1258
|
+
function js(t, e) {
|
|
1259
|
+
const n = Ye({
|
|
1260
|
+
output: e.script,
|
|
1261
|
+
version: e.leafVersion
|
|
1262
|
+
});
|
|
1263
|
+
return (t.tapScriptSig || []).filter((r) => r.leafHash.equals(n)).map((r) => zs(e.script, r)).sort((r, c) => c.positionInScript - r.positionInScript).map((r) => r.signature);
|
|
1264
|
+
}
|
|
1265
|
+
function zs(t, e) {
|
|
1266
|
+
return Object.assign(
|
|
1267
|
+
{
|
|
1268
|
+
positionInScript: fr(e.pubkey, t)
|
|
1269
|
+
},
|
|
1270
|
+
e
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
function $s(t, e, n) {
|
|
1274
|
+
const { tapScriptSig: r } = t;
|
|
1275
|
+
if (!r || !r.length)
|
|
1276
|
+
throw new Error(
|
|
1277
|
+
`Can not finalize taproot input #${e}. No tapleaf script signature provided.`
|
|
1278
|
+
);
|
|
1279
|
+
const c = (t.tapLeafScript || []).sort((s, o) => s.controlBlock.length - o.controlBlock.length).find((s) => Ys(s, r, n));
|
|
1280
|
+
if (!c)
|
|
1281
|
+
throw new Error(
|
|
1282
|
+
`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`
|
|
1283
|
+
);
|
|
1284
|
+
return c;
|
|
1285
|
+
}
|
|
1286
|
+
function Ys(t, e, n) {
|
|
1287
|
+
const r = Ye({
|
|
1288
|
+
output: t.script,
|
|
1289
|
+
version: t.leafVersion
|
|
1290
|
+
});
|
|
1291
|
+
return (!n || n.equals(r)) && e.find((s) => s.leafHash.equals(r)) !== void 0;
|
|
1292
|
+
}
|
|
1293
|
+
function pe(t) {
|
|
1294
|
+
return t && !!(t.redeemScript || t.witnessScript || t.bip32Derivation && t.bip32Derivation.length);
|
|
1295
|
+
}
|
|
1296
|
+
function ne(t) {
|
|
1297
|
+
return (e) => {
|
|
1298
|
+
try {
|
|
1299
|
+
return t({ output: e }), !0;
|
|
1300
|
+
} catch {
|
|
1301
|
+
return !1;
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
const Zs = ne(Ze), Js = ne(Kn), Qs = ne(_e), tt = ne($e), Dt = ne(ve), ur = ne(me), It = ne(Ie), ri = ne(Rn), si = (t) => t.length === 4 && t[0] === 81 && // OP_1
|
|
1306
|
+
t[1] === 2 && // push 2 bytes
|
|
1307
|
+
t[2] === 78 && t[3] === 115;
|
|
1308
|
+
function Ee(t) {
|
|
1309
|
+
let e = l.allocUnsafe(0);
|
|
1310
|
+
function n(o) {
|
|
1311
|
+
e = l.concat([e, l.from(o)]);
|
|
1312
|
+
}
|
|
1313
|
+
function r(o) {
|
|
1314
|
+
const i = e.length, a = bt.encodingLength(o);
|
|
1315
|
+
e = l.concat([e, l.allocUnsafe(a)]), bt.encode(o, e, i);
|
|
1316
|
+
}
|
|
1317
|
+
function c(o) {
|
|
1318
|
+
r(o.length), n(o);
|
|
1319
|
+
}
|
|
1320
|
+
function s(o) {
|
|
1321
|
+
r(o.length), o.forEach(c);
|
|
1322
|
+
}
|
|
1323
|
+
return s(t), e;
|
|
1324
|
+
}
|
|
1325
|
+
function eo(t) {
|
|
1326
|
+
if (t.length === 32)
|
|
1327
|
+
return;
|
|
1328
|
+
if (![33, 65].includes(t.length)) {
|
|
1329
|
+
console.warn(
|
|
1330
|
+
`Unsupported key length=${t.length}. Must be 33 (compressed) or 65 (uncompressed).`
|
|
1331
|
+
);
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
let e;
|
|
1335
|
+
try {
|
|
1336
|
+
e = O.fromHex(t);
|
|
1337
|
+
} catch {
|
|
1338
|
+
throw new Error("Invalid secp256k1 public key bytes. Cannot parse.");
|
|
1339
|
+
}
|
|
1340
|
+
const n = Vt(e.x), r = Vt(e.y), s = e.y % 2n === 0n ? 6 : 7, o = l.alloc(65);
|
|
1341
|
+
o[0] = s, n.copy(o, 1), r.copy(o, 33);
|
|
1342
|
+
const i = l.concat([l.from([4]), n, r]);
|
|
1343
|
+
return {
|
|
1344
|
+
hybrid: o,
|
|
1345
|
+
uncompressed: i
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
function Vt(t) {
|
|
1349
|
+
let e = t.toString(16);
|
|
1350
|
+
return e = e.padStart(64, "0"), e.length > 64 && (e = e.slice(-64)), l.from(e, "hex");
|
|
1351
|
+
}
|
|
1352
|
+
function Ne(t, e) {
|
|
1353
|
+
if (t.equals(e)) return !0;
|
|
1354
|
+
if (t.length === 65 && e.length === 65) {
|
|
1355
|
+
const n = l.from(t), r = l.from(e);
|
|
1356
|
+
return (n[0] === 6 || n[0] === 7) && (n[0] = 4), (r[0] === 6 || r[0] === 7) && (r[0] = 4), n.equals(r);
|
|
1357
|
+
}
|
|
1358
|
+
return !1;
|
|
1359
|
+
}
|
|
1360
|
+
function fr(t, e) {
|
|
1361
|
+
const n = he(e);
|
|
1362
|
+
if (n === null) throw new Error("Unknown script error");
|
|
1363
|
+
const r = ot(t), c = we(t), s = eo(t), o = s?.hybrid ? ot(s.hybrid) : void 0, i = s?.uncompressed ? ot(s.uncompressed) : void 0;
|
|
1364
|
+
return n.findIndex((a) => {
|
|
1365
|
+
if (typeof a == "number") return !1;
|
|
1366
|
+
if (Ne(a, t) || Ne(a, c) || a.equals(r) || s && (Ne(a, s.uncompressed) || Ne(a, s.hybrid) || o && a.equals(o) || i && a.equals(i)))
|
|
1367
|
+
return !0;
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
function nt(t, e) {
|
|
1371
|
+
return fr(t, e) !== -1;
|
|
1372
|
+
}
|
|
1373
|
+
function to(t, e) {
|
|
1374
|
+
return no(t).some((r) => pr(r, Se.decode, e));
|
|
1375
|
+
}
|
|
1376
|
+
function pr(t, e, n) {
|
|
1377
|
+
const { hashType: r } = e(t), c = [];
|
|
1378
|
+
switch (r & I.SIGHASH_ANYONECANPAY && c.push("addInput"), r & 31) {
|
|
1379
|
+
case I.SIGHASH_ALL:
|
|
1380
|
+
break;
|
|
1381
|
+
case I.SIGHASH_SINGLE:
|
|
1382
|
+
case I.SIGHASH_NONE:
|
|
1383
|
+
c.push("addOutput"), c.push("setInputSequence");
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
return c.indexOf(n) === -1;
|
|
1387
|
+
}
|
|
1388
|
+
function no(t) {
|
|
1389
|
+
const { partialSig: e } = t;
|
|
1390
|
+
let n;
|
|
1391
|
+
if (!e || e.length === 0) {
|
|
1392
|
+
if (!t.finalScriptSig && !t.finalScriptWitness) return [];
|
|
1393
|
+
n = ro(t);
|
|
1394
|
+
} else
|
|
1395
|
+
n = e;
|
|
1396
|
+
return n.map((r) => r.signature);
|
|
1397
|
+
}
|
|
1398
|
+
function ro(t) {
|
|
1399
|
+
const e = t.finalScriptSig ? he(t.finalScriptSig) || [] : [], n = t.finalScriptWitness ? he(t.finalScriptWitness) || [] : [];
|
|
1400
|
+
return e.concat(n).filter((r) => l.isBuffer(r) && Hn(r)).map((r) => ({ signature: r }));
|
|
1401
|
+
}
|
|
1402
|
+
var He = {}, Ue = {}, ft = {}, ae = {}, ue = {}, pt = {}, jt;
|
|
1403
|
+
function A() {
|
|
1404
|
+
return jt || (jt = 1, (function(t) {
|
|
1405
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), (function(e) {
|
|
1406
|
+
e[e.UNSIGNED_TX = 0] = "UNSIGNED_TX", e[e.GLOBAL_XPUB = 1] = "GLOBAL_XPUB";
|
|
1407
|
+
})(t.GlobalTypes || (t.GlobalTypes = {})), t.GLOBAL_TYPE_NAMES = ["unsignedTx", "globalXpub"], (function(e) {
|
|
1408
|
+
e[e.NON_WITNESS_UTXO = 0] = "NON_WITNESS_UTXO", e[e.WITNESS_UTXO = 1] = "WITNESS_UTXO", e[e.PARTIAL_SIG = 2] = "PARTIAL_SIG", e[e.SIGHASH_TYPE = 3] = "SIGHASH_TYPE", e[e.REDEEM_SCRIPT = 4] = "REDEEM_SCRIPT", e[e.WITNESS_SCRIPT = 5] = "WITNESS_SCRIPT", e[e.BIP32_DERIVATION = 6] = "BIP32_DERIVATION", e[e.FINAL_SCRIPTSIG = 7] = "FINAL_SCRIPTSIG", e[e.FINAL_SCRIPTWITNESS = 8] = "FINAL_SCRIPTWITNESS", e[e.POR_COMMITMENT = 9] = "POR_COMMITMENT", e[e.TAP_KEY_SIG = 19] = "TAP_KEY_SIG", e[e.TAP_SCRIPT_SIG = 20] = "TAP_SCRIPT_SIG", e[e.TAP_LEAF_SCRIPT = 21] = "TAP_LEAF_SCRIPT", e[e.TAP_BIP32_DERIVATION = 22] = "TAP_BIP32_DERIVATION", e[e.TAP_INTERNAL_KEY = 23] = "TAP_INTERNAL_KEY", e[e.TAP_MERKLE_ROOT = 24] = "TAP_MERKLE_ROOT";
|
|
1409
|
+
})(t.InputTypes || (t.InputTypes = {})), t.INPUT_TYPE_NAMES = [
|
|
1410
|
+
"nonWitnessUtxo",
|
|
1411
|
+
"witnessUtxo",
|
|
1412
|
+
"partialSig",
|
|
1413
|
+
"sighashType",
|
|
1414
|
+
"redeemScript",
|
|
1415
|
+
"witnessScript",
|
|
1416
|
+
"bip32Derivation",
|
|
1417
|
+
"finalScriptSig",
|
|
1418
|
+
"finalScriptWitness",
|
|
1419
|
+
"porCommitment",
|
|
1420
|
+
"tapKeySig",
|
|
1421
|
+
"tapScriptSig",
|
|
1422
|
+
"tapLeafScript",
|
|
1423
|
+
"tapBip32Derivation",
|
|
1424
|
+
"tapInternalKey",
|
|
1425
|
+
"tapMerkleRoot"
|
|
1426
|
+
], (function(e) {
|
|
1427
|
+
e[e.REDEEM_SCRIPT = 0] = "REDEEM_SCRIPT", e[e.WITNESS_SCRIPT = 1] = "WITNESS_SCRIPT", e[e.BIP32_DERIVATION = 2] = "BIP32_DERIVATION", e[e.TAP_INTERNAL_KEY = 5] = "TAP_INTERNAL_KEY", e[e.TAP_TREE = 6] = "TAP_TREE", e[e.TAP_BIP32_DERIVATION = 7] = "TAP_BIP32_DERIVATION";
|
|
1428
|
+
})(t.OutputTypes || (t.OutputTypes = {})), t.OUTPUT_TYPE_NAMES = [
|
|
1429
|
+
"redeemScript",
|
|
1430
|
+
"witnessScript",
|
|
1431
|
+
"bip32Derivation",
|
|
1432
|
+
"tapInternalKey",
|
|
1433
|
+
"tapTree",
|
|
1434
|
+
"tapBip32Derivation"
|
|
1435
|
+
];
|
|
1436
|
+
})(pt)), pt;
|
|
1437
|
+
}
|
|
1438
|
+
var X = {}, zt;
|
|
1439
|
+
function so() {
|
|
1440
|
+
if (zt) return X;
|
|
1441
|
+
zt = 1, Object.defineProperty(X, "__esModule", { value: !0 });
|
|
1442
|
+
const t = A(), e = (o) => [...Array(o).keys()];
|
|
1443
|
+
function n(o) {
|
|
1444
|
+
if (o.key[0] !== t.GlobalTypes.GLOBAL_XPUB)
|
|
1445
|
+
throw new Error(
|
|
1446
|
+
"Decode Error: could not decode globalXpub with key 0x" + o.key.toString("hex")
|
|
1447
|
+
);
|
|
1448
|
+
if (o.key.length !== 79 || ![2, 3].includes(o.key[46]))
|
|
1449
|
+
throw new Error(
|
|
1450
|
+
"Decode Error: globalXpub has invalid extended pubkey in key 0x" + o.key.toString("hex")
|
|
1451
|
+
);
|
|
1452
|
+
if (o.value.length / 4 % 1 !== 0)
|
|
1453
|
+
throw new Error(
|
|
1454
|
+
"Decode Error: Global GLOBAL_XPUB value length should be multiple of 4"
|
|
1455
|
+
);
|
|
1456
|
+
const i = o.key.slice(1), a = {
|
|
1457
|
+
masterFingerprint: o.value.slice(0, 4),
|
|
1458
|
+
extendedPubkey: i,
|
|
1459
|
+
path: "m"
|
|
1460
|
+
};
|
|
1461
|
+
for (const u of e(o.value.length / 4 - 1)) {
|
|
1462
|
+
const f = o.value.readUInt32LE(u * 4 + 4), p = !!(f & 2147483648), g = f & 2147483647;
|
|
1463
|
+
a.path += "/" + g.toString(10) + (p ? "'" : "");
|
|
1464
|
+
}
|
|
1465
|
+
return a;
|
|
1466
|
+
}
|
|
1467
|
+
X.decode = n;
|
|
1468
|
+
function r(o) {
|
|
1469
|
+
const i = l.from([t.GlobalTypes.GLOBAL_XPUB]), a = l.concat([i, o.extendedPubkey]), u = o.path.split("/"), f = l.allocUnsafe(u.length * 4);
|
|
1470
|
+
o.masterFingerprint.copy(f, 0);
|
|
1471
|
+
let p = 4;
|
|
1472
|
+
return u.slice(1).forEach((g) => {
|
|
1473
|
+
const y = g.slice(-1) === "'";
|
|
1474
|
+
let h = 2147483647 & parseInt(y ? g.slice(0, -1) : g, 10);
|
|
1475
|
+
y && (h += 2147483648), f.writeUInt32LE(h, p), p += 4;
|
|
1476
|
+
}), {
|
|
1477
|
+
key: a,
|
|
1478
|
+
value: f
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
X.encode = r, X.expected = "{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }";
|
|
1482
|
+
function c(o) {
|
|
1483
|
+
const i = o.extendedPubkey, a = o.masterFingerprint, u = o.path;
|
|
1484
|
+
return l.isBuffer(i) && i.length === 78 && [2, 3].indexOf(i[45]) > -1 && l.isBuffer(a) && a.length === 4 && typeof u == "string" && !!u.match(/^m(\/\d+'?)*$/);
|
|
1485
|
+
}
|
|
1486
|
+
X.check = c;
|
|
1487
|
+
function s(o, i, a) {
|
|
1488
|
+
const u = i.extendedPubkey.toString("hex");
|
|
1489
|
+
return a.has(u) ? !1 : (a.add(u), o.filter((f) => f.extendedPubkey.equals(i.extendedPubkey)).length === 0);
|
|
1490
|
+
}
|
|
1491
|
+
return X.canAddToArray = s, X;
|
|
1492
|
+
}
|
|
1493
|
+
var Be = {}, $t;
|
|
1494
|
+
function oo() {
|
|
1495
|
+
if ($t) return Be;
|
|
1496
|
+
$t = 1, Object.defineProperty(Be, "__esModule", { value: !0 });
|
|
1497
|
+
const t = A();
|
|
1498
|
+
function e(n) {
|
|
1499
|
+
return {
|
|
1500
|
+
key: l.from([t.GlobalTypes.UNSIGNED_TX]),
|
|
1501
|
+
value: n.toBuffer()
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
return Be.encode = e, Be;
|
|
1505
|
+
}
|
|
1506
|
+
var q = {}, Yt;
|
|
1507
|
+
function io() {
|
|
1508
|
+
if (Yt) return q;
|
|
1509
|
+
Yt = 1, Object.defineProperty(q, "__esModule", { value: !0 });
|
|
1510
|
+
const t = A();
|
|
1511
|
+
function e(s) {
|
|
1512
|
+
if (s.key[0] !== t.InputTypes.FINAL_SCRIPTSIG)
|
|
1513
|
+
throw new Error(
|
|
1514
|
+
"Decode Error: could not decode finalScriptSig with key 0x" + s.key.toString("hex")
|
|
1515
|
+
);
|
|
1516
|
+
return s.value;
|
|
1517
|
+
}
|
|
1518
|
+
q.decode = e;
|
|
1519
|
+
function n(s) {
|
|
1520
|
+
return {
|
|
1521
|
+
key: l.from([t.InputTypes.FINAL_SCRIPTSIG]),
|
|
1522
|
+
value: s
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
q.encode = n, q.expected = "Buffer";
|
|
1526
|
+
function r(s) {
|
|
1527
|
+
return l.isBuffer(s);
|
|
1528
|
+
}
|
|
1529
|
+
q.check = r;
|
|
1530
|
+
function c(s, o) {
|
|
1531
|
+
return !!s && !!o && s.finalScriptSig === void 0;
|
|
1532
|
+
}
|
|
1533
|
+
return q.canAdd = c, q;
|
|
1534
|
+
}
|
|
1535
|
+
var D = {}, Zt;
|
|
1536
|
+
function co() {
|
|
1537
|
+
if (Zt) return D;
|
|
1538
|
+
Zt = 1, Object.defineProperty(D, "__esModule", { value: !0 });
|
|
1539
|
+
const t = A();
|
|
1540
|
+
function e(s) {
|
|
1541
|
+
if (s.key[0] !== t.InputTypes.FINAL_SCRIPTWITNESS)
|
|
1542
|
+
throw new Error(
|
|
1543
|
+
"Decode Error: could not decode finalScriptWitness with key 0x" + s.key.toString("hex")
|
|
1544
|
+
);
|
|
1545
|
+
return s.value;
|
|
1546
|
+
}
|
|
1547
|
+
D.decode = e;
|
|
1548
|
+
function n(s) {
|
|
1549
|
+
return {
|
|
1550
|
+
key: l.from([t.InputTypes.FINAL_SCRIPTWITNESS]),
|
|
1551
|
+
value: s
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
D.encode = n, D.expected = "Buffer";
|
|
1555
|
+
function r(s) {
|
|
1556
|
+
return l.isBuffer(s);
|
|
1557
|
+
}
|
|
1558
|
+
D.check = r;
|
|
1559
|
+
function c(s, o) {
|
|
1560
|
+
return !!s && !!o && s.finalScriptWitness === void 0;
|
|
1561
|
+
}
|
|
1562
|
+
return D.canAdd = c, D;
|
|
1563
|
+
}
|
|
1564
|
+
var V = {}, Jt;
|
|
1565
|
+
function ao() {
|
|
1566
|
+
if (Jt) return V;
|
|
1567
|
+
Jt = 1, Object.defineProperty(V, "__esModule", { value: !0 });
|
|
1568
|
+
const t = A();
|
|
1569
|
+
function e(s) {
|
|
1570
|
+
if (s.key[0] !== t.InputTypes.NON_WITNESS_UTXO)
|
|
1571
|
+
throw new Error(
|
|
1572
|
+
"Decode Error: could not decode nonWitnessUtxo with key 0x" + s.key.toString("hex")
|
|
1573
|
+
);
|
|
1574
|
+
return s.value;
|
|
1575
|
+
}
|
|
1576
|
+
V.decode = e;
|
|
1577
|
+
function n(s) {
|
|
1578
|
+
return {
|
|
1579
|
+
key: l.from([t.InputTypes.NON_WITNESS_UTXO]),
|
|
1580
|
+
value: s
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
V.encode = n, V.expected = "Buffer";
|
|
1584
|
+
function r(s) {
|
|
1585
|
+
return l.isBuffer(s);
|
|
1586
|
+
}
|
|
1587
|
+
V.check = r;
|
|
1588
|
+
function c(s, o) {
|
|
1589
|
+
return !!s && !!o && s.nonWitnessUtxo === void 0;
|
|
1590
|
+
}
|
|
1591
|
+
return V.canAdd = c, V;
|
|
1592
|
+
}
|
|
1593
|
+
var j = {}, Qt;
|
|
1594
|
+
function uo() {
|
|
1595
|
+
if (Qt) return j;
|
|
1596
|
+
Qt = 1, Object.defineProperty(j, "__esModule", { value: !0 });
|
|
1597
|
+
const t = A();
|
|
1598
|
+
function e(o) {
|
|
1599
|
+
if (o.key[0] !== t.InputTypes.PARTIAL_SIG)
|
|
1600
|
+
throw new Error(
|
|
1601
|
+
"Decode Error: could not decode partialSig with key 0x" + o.key.toString("hex")
|
|
1602
|
+
);
|
|
1603
|
+
if (!(o.key.length === 34 || o.key.length === 66) || ![2, 3, 4].includes(o.key[1]))
|
|
1604
|
+
throw new Error(
|
|
1605
|
+
"Decode Error: partialSig has invalid pubkey in key 0x" + o.key.toString("hex")
|
|
1606
|
+
);
|
|
1607
|
+
return {
|
|
1608
|
+
pubkey: o.key.slice(1),
|
|
1609
|
+
signature: o.value
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
j.decode = e;
|
|
1613
|
+
function n(o) {
|
|
1614
|
+
const i = l.from([t.InputTypes.PARTIAL_SIG]);
|
|
1615
|
+
return {
|
|
1616
|
+
key: l.concat([i, o.pubkey]),
|
|
1617
|
+
value: o.signature
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
j.encode = n, j.expected = "{ pubkey: Buffer; signature: Buffer; }";
|
|
1621
|
+
function r(o) {
|
|
1622
|
+
return l.isBuffer(o.pubkey) && l.isBuffer(o.signature) && [33, 65].includes(o.pubkey.length) && [2, 3, 4].includes(o.pubkey[0]) && c(o.signature);
|
|
1623
|
+
}
|
|
1624
|
+
j.check = r;
|
|
1625
|
+
function c(o) {
|
|
1626
|
+
if (!l.isBuffer(o) || o.length < 9 || o[0] !== 48 || o.length !== o[1] + 3 || o[2] !== 2) return !1;
|
|
1627
|
+
const i = o[3];
|
|
1628
|
+
if (i > 33 || i < 1 || o[3 + i + 1] !== 2) return !1;
|
|
1629
|
+
const a = o[3 + i + 2];
|
|
1630
|
+
return !(a > 33 || a < 1 || o.length !== 3 + i + 2 + a + 2);
|
|
1631
|
+
}
|
|
1632
|
+
function s(o, i, a) {
|
|
1633
|
+
const u = i.pubkey.toString("hex");
|
|
1634
|
+
return a.has(u) ? !1 : (a.add(u), o.filter((f) => f.pubkey.equals(i.pubkey)).length === 0);
|
|
1635
|
+
}
|
|
1636
|
+
return j.canAddToArray = s, j;
|
|
1637
|
+
}
|
|
1638
|
+
var z = {}, en;
|
|
1639
|
+
function fo() {
|
|
1640
|
+
if (en) return z;
|
|
1641
|
+
en = 1, Object.defineProperty(z, "__esModule", { value: !0 });
|
|
1642
|
+
const t = A();
|
|
1643
|
+
function e(s) {
|
|
1644
|
+
if (s.key[0] !== t.InputTypes.POR_COMMITMENT)
|
|
1645
|
+
throw new Error(
|
|
1646
|
+
"Decode Error: could not decode porCommitment with key 0x" + s.key.toString("hex")
|
|
1647
|
+
);
|
|
1648
|
+
return s.value.toString("utf8");
|
|
1649
|
+
}
|
|
1650
|
+
z.decode = e;
|
|
1651
|
+
function n(s) {
|
|
1652
|
+
return {
|
|
1653
|
+
key: l.from([t.InputTypes.POR_COMMITMENT]),
|
|
1654
|
+
value: l.from(s, "utf8")
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
z.encode = n, z.expected = "string";
|
|
1658
|
+
function r(s) {
|
|
1659
|
+
return typeof s == "string";
|
|
1660
|
+
}
|
|
1661
|
+
z.check = r;
|
|
1662
|
+
function c(s, o) {
|
|
1663
|
+
return !!s && !!o && s.porCommitment === void 0;
|
|
1664
|
+
}
|
|
1665
|
+
return z.canAdd = c, z;
|
|
1666
|
+
}
|
|
1667
|
+
var $ = {}, tn;
|
|
1668
|
+
function po() {
|
|
1669
|
+
if (tn) return $;
|
|
1670
|
+
tn = 1, Object.defineProperty($, "__esModule", { value: !0 });
|
|
1671
|
+
const t = A();
|
|
1672
|
+
function e(s) {
|
|
1673
|
+
if (s.key[0] !== t.InputTypes.SIGHASH_TYPE)
|
|
1674
|
+
throw new Error(
|
|
1675
|
+
"Decode Error: could not decode sighashType with key 0x" + s.key.toString("hex")
|
|
1676
|
+
);
|
|
1677
|
+
return s.value.readUInt32LE(0);
|
|
1678
|
+
}
|
|
1679
|
+
$.decode = e;
|
|
1680
|
+
function n(s) {
|
|
1681
|
+
const o = l.from([t.InputTypes.SIGHASH_TYPE]), i = l.allocUnsafe(4);
|
|
1682
|
+
return i.writeUInt32LE(s, 0), {
|
|
1683
|
+
key: o,
|
|
1684
|
+
value: i
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
$.encode = n, $.expected = "number";
|
|
1688
|
+
function r(s) {
|
|
1689
|
+
return typeof s == "number";
|
|
1690
|
+
}
|
|
1691
|
+
$.check = r;
|
|
1692
|
+
function c(s, o) {
|
|
1693
|
+
return !!s && !!o && s.sighashType === void 0;
|
|
1694
|
+
}
|
|
1695
|
+
return $.canAdd = c, $;
|
|
1696
|
+
}
|
|
1697
|
+
var Y = {}, nn;
|
|
1698
|
+
function ho() {
|
|
1699
|
+
if (nn) return Y;
|
|
1700
|
+
nn = 1, Object.defineProperty(Y, "__esModule", { value: !0 });
|
|
1701
|
+
const t = A();
|
|
1702
|
+
function e(s) {
|
|
1703
|
+
if (s.key[0] !== t.InputTypes.TAP_KEY_SIG || s.key.length !== 1)
|
|
1704
|
+
throw new Error(
|
|
1705
|
+
"Decode Error: could not decode tapKeySig with key 0x" + s.key.toString("hex")
|
|
1706
|
+
);
|
|
1707
|
+
if (!r(s.value))
|
|
1708
|
+
throw new Error(
|
|
1709
|
+
"Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature"
|
|
1710
|
+
);
|
|
1711
|
+
return s.value;
|
|
1712
|
+
}
|
|
1713
|
+
Y.decode = e;
|
|
1714
|
+
function n(s) {
|
|
1715
|
+
return { key: l.from([t.InputTypes.TAP_KEY_SIG]), value: s };
|
|
1716
|
+
}
|
|
1717
|
+
Y.encode = n, Y.expected = "Buffer";
|
|
1718
|
+
function r(s) {
|
|
1719
|
+
return l.isBuffer(s) && (s.length === 64 || s.length === 65);
|
|
1720
|
+
}
|
|
1721
|
+
Y.check = r;
|
|
1722
|
+
function c(s, o) {
|
|
1723
|
+
return !!s && !!o && s.tapKeySig === void 0;
|
|
1724
|
+
}
|
|
1725
|
+
return Y.canAdd = c, Y;
|
|
1726
|
+
}
|
|
1727
|
+
var Z = {}, rn;
|
|
1728
|
+
function lo() {
|
|
1729
|
+
if (rn) return Z;
|
|
1730
|
+
rn = 1, Object.defineProperty(Z, "__esModule", { value: !0 });
|
|
1731
|
+
const t = A();
|
|
1732
|
+
function e(s) {
|
|
1733
|
+
if (s.key[0] !== t.InputTypes.TAP_LEAF_SCRIPT)
|
|
1734
|
+
throw new Error(
|
|
1735
|
+
"Decode Error: could not decode tapLeafScript with key 0x" + s.key.toString("hex")
|
|
1736
|
+
);
|
|
1737
|
+
if ((s.key.length - 2) % 32 !== 0)
|
|
1738
|
+
throw new Error(
|
|
1739
|
+
"Decode Error: tapLeafScript has invalid control block in key 0x" + s.key.toString("hex")
|
|
1740
|
+
);
|
|
1741
|
+
const o = s.value[s.value.length - 1];
|
|
1742
|
+
if ((s.key[1] & 254) !== o)
|
|
1743
|
+
throw new Error(
|
|
1744
|
+
"Decode Error: tapLeafScript bad leaf version in key 0x" + s.key.toString("hex")
|
|
1745
|
+
);
|
|
1746
|
+
const i = s.value.slice(0, -1);
|
|
1747
|
+
return { controlBlock: s.key.slice(1), script: i, leafVersion: o };
|
|
1748
|
+
}
|
|
1749
|
+
Z.decode = e;
|
|
1750
|
+
function n(s) {
|
|
1751
|
+
const o = l.from([t.InputTypes.TAP_LEAF_SCRIPT]), i = l.from([s.leafVersion]);
|
|
1752
|
+
return {
|
|
1753
|
+
key: l.concat([o, s.controlBlock]),
|
|
1754
|
+
value: l.concat([s.script, i])
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
Z.encode = n, Z.expected = "{ controlBlock: Buffer; leafVersion: number, script: Buffer; }";
|
|
1758
|
+
function r(s) {
|
|
1759
|
+
return l.isBuffer(s.controlBlock) && (s.controlBlock.length - 1) % 32 === 0 && (s.controlBlock[0] & 254) === s.leafVersion && l.isBuffer(s.script);
|
|
1760
|
+
}
|
|
1761
|
+
Z.check = r;
|
|
1762
|
+
function c(s, o, i) {
|
|
1763
|
+
const a = o.controlBlock.toString("hex");
|
|
1764
|
+
return i.has(a) ? !1 : (i.add(a), s.filter((u) => u.controlBlock.equals(o.controlBlock)).length === 0);
|
|
1765
|
+
}
|
|
1766
|
+
return Z.canAddToArray = c, Z;
|
|
1767
|
+
}
|
|
1768
|
+
var J = {}, sn;
|
|
1769
|
+
function go() {
|
|
1770
|
+
if (sn) return J;
|
|
1771
|
+
sn = 1, Object.defineProperty(J, "__esModule", { value: !0 });
|
|
1772
|
+
const t = A();
|
|
1773
|
+
function e(s) {
|
|
1774
|
+
if (s.key[0] !== t.InputTypes.TAP_MERKLE_ROOT || s.key.length !== 1)
|
|
1775
|
+
throw new Error(
|
|
1776
|
+
"Decode Error: could not decode tapMerkleRoot with key 0x" + s.key.toString("hex")
|
|
1777
|
+
);
|
|
1778
|
+
if (!r(s.value))
|
|
1779
|
+
throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");
|
|
1780
|
+
return s.value;
|
|
1781
|
+
}
|
|
1782
|
+
J.decode = e;
|
|
1783
|
+
function n(s) {
|
|
1784
|
+
return { key: l.from([t.InputTypes.TAP_MERKLE_ROOT]), value: s };
|
|
1785
|
+
}
|
|
1786
|
+
J.encode = n, J.expected = "Buffer";
|
|
1787
|
+
function r(s) {
|
|
1788
|
+
return l.isBuffer(s) && s.length === 32;
|
|
1789
|
+
}
|
|
1790
|
+
J.check = r;
|
|
1791
|
+
function c(s, o) {
|
|
1792
|
+
return !!s && !!o && s.tapMerkleRoot === void 0;
|
|
1793
|
+
}
|
|
1794
|
+
return J.canAdd = c, J;
|
|
1795
|
+
}
|
|
1796
|
+
var Q = {}, on;
|
|
1797
|
+
function yo() {
|
|
1798
|
+
if (on) return Q;
|
|
1799
|
+
on = 1, Object.defineProperty(Q, "__esModule", { value: !0 });
|
|
1800
|
+
const t = A();
|
|
1801
|
+
function e(s) {
|
|
1802
|
+
if (s.key[0] !== t.InputTypes.TAP_SCRIPT_SIG)
|
|
1803
|
+
throw new Error(
|
|
1804
|
+
"Decode Error: could not decode tapScriptSig with key 0x" + s.key.toString("hex")
|
|
1805
|
+
);
|
|
1806
|
+
if (s.key.length !== 65)
|
|
1807
|
+
throw new Error(
|
|
1808
|
+
"Decode Error: tapScriptSig has invalid key 0x" + s.key.toString("hex")
|
|
1809
|
+
);
|
|
1810
|
+
if (s.value.length !== 64 && s.value.length !== 65)
|
|
1811
|
+
throw new Error(
|
|
1812
|
+
"Decode Error: tapScriptSig has invalid signature in key 0x" + s.key.toString("hex")
|
|
1813
|
+
);
|
|
1814
|
+
const o = s.key.slice(1, 33), i = s.key.slice(33);
|
|
1815
|
+
return {
|
|
1816
|
+
pubkey: o,
|
|
1817
|
+
leafHash: i,
|
|
1818
|
+
signature: s.value
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
Q.decode = e;
|
|
1822
|
+
function n(s) {
|
|
1823
|
+
const o = l.from([t.InputTypes.TAP_SCRIPT_SIG]);
|
|
1824
|
+
return {
|
|
1825
|
+
key: l.concat([o, s.pubkey, s.leafHash]),
|
|
1826
|
+
value: s.signature
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
Q.encode = n, Q.expected = "{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }";
|
|
1830
|
+
function r(s) {
|
|
1831
|
+
return l.isBuffer(s.pubkey) && l.isBuffer(s.leafHash) && l.isBuffer(s.signature) && s.pubkey.length === 32 && s.leafHash.length === 32 && (s.signature.length === 64 || s.signature.length === 65);
|
|
1832
|
+
}
|
|
1833
|
+
Q.check = r;
|
|
1834
|
+
function c(s, o, i) {
|
|
1835
|
+
const a = o.pubkey.toString("hex") + o.leafHash.toString("hex");
|
|
1836
|
+
return i.has(a) ? !1 : (i.add(a), s.filter(
|
|
1837
|
+
(u) => u.pubkey.equals(o.pubkey) && u.leafHash.equals(o.leafHash)
|
|
1838
|
+
).length === 0);
|
|
1839
|
+
}
|
|
1840
|
+
return Q.canAddToArray = c, Q;
|
|
1841
|
+
}
|
|
1842
|
+
var ee = {}, L = {}, cn;
|
|
1843
|
+
function kt() {
|
|
1844
|
+
if (cn) return L;
|
|
1845
|
+
cn = 1, Object.defineProperty(L, "__esModule", { value: !0 });
|
|
1846
|
+
const t = le();
|
|
1847
|
+
L.range = (i) => [...Array(i).keys()];
|
|
1848
|
+
function e(i) {
|
|
1849
|
+
if (i.length < 1) return i;
|
|
1850
|
+
let a = i.length - 1, u = 0;
|
|
1851
|
+
for (let f = 0; f < i.length / 2; f++)
|
|
1852
|
+
u = i[f], i[f] = i[a], i[a] = u, a--;
|
|
1853
|
+
return i;
|
|
1854
|
+
}
|
|
1855
|
+
L.reverseBuffer = e;
|
|
1856
|
+
function n(i) {
|
|
1857
|
+
const a = i.map(r);
|
|
1858
|
+
return a.push(l.from([0])), l.concat(a);
|
|
1859
|
+
}
|
|
1860
|
+
L.keyValsToBuffer = n;
|
|
1861
|
+
function r(i) {
|
|
1862
|
+
const a = i.key.length, u = i.value.length, f = t.encodingLength(a), p = t.encodingLength(u), g = l.allocUnsafe(
|
|
1863
|
+
f + a + p + u
|
|
1864
|
+
);
|
|
1865
|
+
return t.encode(a, g, 0), i.key.copy(g, f), t.encode(u, g, f + a), i.value.copy(g, f + a + p), g;
|
|
1866
|
+
}
|
|
1867
|
+
L.keyValToBuffer = r;
|
|
1868
|
+
function c(i, a) {
|
|
1869
|
+
if (typeof i != "number")
|
|
1870
|
+
throw new Error("cannot write a non-number as a number");
|
|
1871
|
+
if (i < 0)
|
|
1872
|
+
throw new Error("specified a negative value for writing an unsigned value");
|
|
1873
|
+
if (i > a) throw new Error("RangeError: value out of range");
|
|
1874
|
+
if (Math.floor(i) !== i)
|
|
1875
|
+
throw new Error("value has a fractional component");
|
|
1876
|
+
}
|
|
1877
|
+
function s(i, a) {
|
|
1878
|
+
const u = i.readUInt32LE(a);
|
|
1879
|
+
let f = i.readUInt32LE(a + 4);
|
|
1880
|
+
return f *= 4294967296, c(f + u, 9007199254740991), f + u;
|
|
1881
|
+
}
|
|
1882
|
+
L.readUInt64LE = s;
|
|
1883
|
+
function o(i, a, u) {
|
|
1884
|
+
return c(a, 9007199254740991), i.writeInt32LE(a & -1, u), i.writeUInt32LE(Math.floor(a / 4294967296), u + 4), u + 8;
|
|
1885
|
+
}
|
|
1886
|
+
return L.writeUInt64LE = o, L;
|
|
1887
|
+
}
|
|
1888
|
+
var an;
|
|
1889
|
+
function So() {
|
|
1890
|
+
if (an) return ee;
|
|
1891
|
+
an = 1, Object.defineProperty(ee, "__esModule", { value: !0 });
|
|
1892
|
+
const t = A(), e = kt(), n = le();
|
|
1893
|
+
function r(i) {
|
|
1894
|
+
if (i.key[0] !== t.InputTypes.WITNESS_UTXO)
|
|
1895
|
+
throw new Error(
|
|
1896
|
+
"Decode Error: could not decode witnessUtxo with key 0x" + i.key.toString("hex")
|
|
1897
|
+
);
|
|
1898
|
+
const a = e.readUInt64LE(i.value, 0);
|
|
1899
|
+
let u = 8;
|
|
1900
|
+
const f = n.decode(i.value, u);
|
|
1901
|
+
u += n.encodingLength(f);
|
|
1902
|
+
const p = i.value.slice(u);
|
|
1903
|
+
if (p.length !== f)
|
|
1904
|
+
throw new Error("Decode Error: WITNESS_UTXO script is not proper length");
|
|
1905
|
+
return {
|
|
1906
|
+
script: p,
|
|
1907
|
+
value: a
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
ee.decode = r;
|
|
1911
|
+
function c(i) {
|
|
1912
|
+
const { script: a, value: u } = i, f = n.encodingLength(a.length), p = l.allocUnsafe(8 + f + a.length);
|
|
1913
|
+
return e.writeUInt64LE(p, u, 0), n.encode(a.length, p, 8), a.copy(p, 8 + f), {
|
|
1914
|
+
key: l.from([t.InputTypes.WITNESS_UTXO]),
|
|
1915
|
+
value: p
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
ee.encode = c, ee.expected = "{ script: Buffer; value: number; }";
|
|
1919
|
+
function s(i) {
|
|
1920
|
+
return l.isBuffer(i.script) && typeof i.value == "number";
|
|
1921
|
+
}
|
|
1922
|
+
ee.check = s;
|
|
1923
|
+
function o(i, a) {
|
|
1924
|
+
return !!i && !!a && i.witnessUtxo === void 0;
|
|
1925
|
+
}
|
|
1926
|
+
return ee.canAdd = o, ee;
|
|
1927
|
+
}
|
|
1928
|
+
var te = {}, un;
|
|
1929
|
+
function bo() {
|
|
1930
|
+
if (un) return te;
|
|
1931
|
+
un = 1, Object.defineProperty(te, "__esModule", { value: !0 });
|
|
1932
|
+
const t = A(), e = le();
|
|
1933
|
+
function n(o) {
|
|
1934
|
+
if (o.key[0] !== t.OutputTypes.TAP_TREE || o.key.length !== 1)
|
|
1935
|
+
throw new Error(
|
|
1936
|
+
"Decode Error: could not decode tapTree with key 0x" + o.key.toString("hex")
|
|
1937
|
+
);
|
|
1938
|
+
let i = 0;
|
|
1939
|
+
const a = [];
|
|
1940
|
+
for (; i < o.value.length; ) {
|
|
1941
|
+
const u = o.value[i++], f = o.value[i++], p = e.decode(o.value, i);
|
|
1942
|
+
i += e.encodingLength(p), a.push({
|
|
1943
|
+
depth: u,
|
|
1944
|
+
leafVersion: f,
|
|
1945
|
+
script: o.value.slice(i, i + p)
|
|
1946
|
+
}), i += p;
|
|
1947
|
+
}
|
|
1948
|
+
return { leaves: a };
|
|
1949
|
+
}
|
|
1950
|
+
te.decode = n;
|
|
1951
|
+
function r(o) {
|
|
1952
|
+
const i = l.from([t.OutputTypes.TAP_TREE]), a = [].concat(
|
|
1953
|
+
...o.leaves.map((u) => [
|
|
1954
|
+
l.of(u.depth, u.leafVersion),
|
|
1955
|
+
e.encode(u.script.length),
|
|
1956
|
+
u.script
|
|
1957
|
+
])
|
|
1958
|
+
);
|
|
1959
|
+
return {
|
|
1960
|
+
key: i,
|
|
1961
|
+
value: l.concat(a)
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
te.encode = r, te.expected = "{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }";
|
|
1965
|
+
function c(o) {
|
|
1966
|
+
return Array.isArray(o.leaves) && o.leaves.every(
|
|
1967
|
+
(i) => i.depth >= 0 && i.depth <= 128 && (i.leafVersion & 254) === i.leafVersion && l.isBuffer(i.script)
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
te.check = c;
|
|
1971
|
+
function s(o, i) {
|
|
1972
|
+
return !!o && !!i && o.tapTree === void 0;
|
|
1973
|
+
}
|
|
1974
|
+
return te.canAdd = s, te;
|
|
1975
|
+
}
|
|
1976
|
+
var Re = {}, fn;
|
|
1977
|
+
function hr() {
|
|
1978
|
+
if (fn) return Re;
|
|
1979
|
+
fn = 1, Object.defineProperty(Re, "__esModule", { value: !0 });
|
|
1980
|
+
const t = (r) => [...Array(r).keys()], e = (r) => r.length === 33 && [2, 3].includes(r[0]) || r.length === 65 && r[0] === 4;
|
|
1981
|
+
function n(r, c = e) {
|
|
1982
|
+
function s(f) {
|
|
1983
|
+
if (f.key[0] !== r)
|
|
1984
|
+
throw new Error(
|
|
1985
|
+
"Decode Error: could not decode bip32Derivation with key 0x" + f.key.toString("hex")
|
|
1986
|
+
);
|
|
1987
|
+
const p = f.key.slice(1);
|
|
1988
|
+
if (!c(p))
|
|
1989
|
+
throw new Error(
|
|
1990
|
+
"Decode Error: bip32Derivation has invalid pubkey in key 0x" + f.key.toString("hex")
|
|
1991
|
+
);
|
|
1992
|
+
if (f.value.length / 4 % 1 !== 0)
|
|
1993
|
+
throw new Error(
|
|
1994
|
+
"Decode Error: Input BIP32_DERIVATION value length should be multiple of 4"
|
|
1995
|
+
);
|
|
1996
|
+
const g = {
|
|
1997
|
+
masterFingerprint: f.value.slice(0, 4),
|
|
1998
|
+
pubkey: p,
|
|
1999
|
+
path: "m"
|
|
2000
|
+
};
|
|
2001
|
+
for (const y of t(f.value.length / 4 - 1)) {
|
|
2002
|
+
const h = f.value.readUInt32LE(y * 4 + 4), d = !!(h & 2147483648), w = h & 2147483647;
|
|
2003
|
+
g.path += "/" + w.toString(10) + (d ? "'" : "");
|
|
2004
|
+
}
|
|
2005
|
+
return g;
|
|
2006
|
+
}
|
|
2007
|
+
function o(f) {
|
|
2008
|
+
const p = l.from([r]), g = l.concat([p, f.pubkey]), y = f.path.split("/"), h = l.allocUnsafe(y.length * 4);
|
|
2009
|
+
f.masterFingerprint.copy(h, 0);
|
|
2010
|
+
let d = 4;
|
|
2011
|
+
return y.slice(1).forEach((w) => {
|
|
2012
|
+
const E = w.slice(-1) === "'";
|
|
2013
|
+
let S = 2147483647 & parseInt(E ? w.slice(0, -1) : w, 10);
|
|
2014
|
+
E && (S += 2147483648), h.writeUInt32LE(S, d), d += 4;
|
|
2015
|
+
}), {
|
|
2016
|
+
key: g,
|
|
2017
|
+
value: h
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
const i = "{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }";
|
|
2021
|
+
function a(f) {
|
|
2022
|
+
return l.isBuffer(f.pubkey) && l.isBuffer(f.masterFingerprint) && typeof f.path == "string" && c(f.pubkey) && f.masterFingerprint.length === 4;
|
|
2023
|
+
}
|
|
2024
|
+
function u(f, p, g) {
|
|
2025
|
+
const y = p.pubkey.toString("hex");
|
|
2026
|
+
return g.has(y) ? !1 : (g.add(y), f.filter((h) => h.pubkey.equals(p.pubkey)).length === 0);
|
|
2027
|
+
}
|
|
2028
|
+
return {
|
|
2029
|
+
decode: s,
|
|
2030
|
+
encode: o,
|
|
2031
|
+
check: a,
|
|
2032
|
+
expected: i,
|
|
2033
|
+
canAddToArray: u
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
return Re.makeConverter = n, Re;
|
|
2037
|
+
}
|
|
2038
|
+
var Fe = {}, pn;
|
|
2039
|
+
function wo() {
|
|
2040
|
+
if (pn) return Fe;
|
|
2041
|
+
pn = 1, Object.defineProperty(Fe, "__esModule", { value: !0 });
|
|
2042
|
+
function t(e) {
|
|
2043
|
+
return n;
|
|
2044
|
+
function n(r) {
|
|
2045
|
+
let c;
|
|
2046
|
+
if (e.includes(r.key[0]) && (c = r.key.slice(1), !(c.length === 33 || c.length === 65) || ![2, 3, 4].includes(c[0])))
|
|
2047
|
+
throw new Error(
|
|
2048
|
+
"Format Error: invalid pubkey in key 0x" + r.key.toString("hex")
|
|
2049
|
+
);
|
|
2050
|
+
return c;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
return Fe.makeChecker = t, Fe;
|
|
2054
|
+
}
|
|
2055
|
+
var Ke = {}, hn;
|
|
2056
|
+
function Eo() {
|
|
2057
|
+
if (hn) return Ke;
|
|
2058
|
+
hn = 1, Object.defineProperty(Ke, "__esModule", { value: !0 });
|
|
2059
|
+
function t(e) {
|
|
2060
|
+
function n(i) {
|
|
2061
|
+
if (i.key[0] !== e)
|
|
2062
|
+
throw new Error(
|
|
2063
|
+
"Decode Error: could not decode redeemScript with key 0x" + i.key.toString("hex")
|
|
2064
|
+
);
|
|
2065
|
+
return i.value;
|
|
2066
|
+
}
|
|
2067
|
+
function r(i) {
|
|
2068
|
+
return {
|
|
2069
|
+
key: l.from([e]),
|
|
2070
|
+
value: i
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2073
|
+
const c = "Buffer";
|
|
2074
|
+
function s(i) {
|
|
2075
|
+
return l.isBuffer(i);
|
|
2076
|
+
}
|
|
2077
|
+
function o(i, a) {
|
|
2078
|
+
return !!i && !!a && i.redeemScript === void 0;
|
|
2079
|
+
}
|
|
2080
|
+
return {
|
|
2081
|
+
decode: n,
|
|
2082
|
+
encode: r,
|
|
2083
|
+
check: s,
|
|
2084
|
+
expected: c,
|
|
2085
|
+
canAdd: o
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
return Ke.makeConverter = t, Ke;
|
|
2089
|
+
}
|
|
2090
|
+
var Le = {}, ln;
|
|
2091
|
+
function To() {
|
|
2092
|
+
if (ln) return Le;
|
|
2093
|
+
ln = 1, Object.defineProperty(Le, "__esModule", { value: !0 });
|
|
2094
|
+
const t = le(), e = hr(), n = (c) => c.length === 32;
|
|
2095
|
+
function r(c) {
|
|
2096
|
+
const s = e.makeConverter(c, n);
|
|
2097
|
+
function o(f) {
|
|
2098
|
+
const p = t.decode(f.value), g = t.encodingLength(p), y = s.decode({
|
|
2099
|
+
key: f.key,
|
|
2100
|
+
value: f.value.slice(g + p * 32)
|
|
2101
|
+
}), h = new Array(p);
|
|
2102
|
+
for (let d = 0, w = g; d < p; d++, w += 32)
|
|
2103
|
+
h[d] = f.value.slice(w, w + 32);
|
|
2104
|
+
return Object.assign({}, y, { leafHashes: h });
|
|
2105
|
+
}
|
|
2106
|
+
function i(f) {
|
|
2107
|
+
const p = s.encode(f), g = t.encodingLength(f.leafHashes.length), y = l.allocUnsafe(g);
|
|
2108
|
+
t.encode(f.leafHashes.length, y);
|
|
2109
|
+
const h = l.concat([y, ...f.leafHashes, p.value]);
|
|
2110
|
+
return Object.assign({}, p, { value: h });
|
|
2111
|
+
}
|
|
2112
|
+
const a = "{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }";
|
|
2113
|
+
function u(f) {
|
|
2114
|
+
return Array.isArray(f.leafHashes) && f.leafHashes.every(
|
|
2115
|
+
(p) => l.isBuffer(p) && p.length === 32
|
|
2116
|
+
) && s.check(f);
|
|
2117
|
+
}
|
|
2118
|
+
return {
|
|
2119
|
+
decode: o,
|
|
2120
|
+
encode: i,
|
|
2121
|
+
check: u,
|
|
2122
|
+
expected: a,
|
|
2123
|
+
canAddToArray: s.canAddToArray
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
return Le.makeConverter = r, Le;
|
|
2127
|
+
}
|
|
2128
|
+
var Me = {}, dn;
|
|
2129
|
+
function _o() {
|
|
2130
|
+
if (dn) return Me;
|
|
2131
|
+
dn = 1, Object.defineProperty(Me, "__esModule", { value: !0 });
|
|
2132
|
+
function t(e) {
|
|
2133
|
+
function n(i) {
|
|
2134
|
+
if (i.key[0] !== e || i.key.length !== 1)
|
|
2135
|
+
throw new Error(
|
|
2136
|
+
"Decode Error: could not decode tapInternalKey with key 0x" + i.key.toString("hex")
|
|
2137
|
+
);
|
|
2138
|
+
if (i.value.length !== 32)
|
|
2139
|
+
throw new Error(
|
|
2140
|
+
"Decode Error: tapInternalKey not a 32-byte x-only pubkey"
|
|
2141
|
+
);
|
|
2142
|
+
return i.value;
|
|
2143
|
+
}
|
|
2144
|
+
function r(i) {
|
|
2145
|
+
return { key: l.from([e]), value: i };
|
|
2146
|
+
}
|
|
2147
|
+
const c = "Buffer";
|
|
2148
|
+
function s(i) {
|
|
2149
|
+
return l.isBuffer(i) && i.length === 32;
|
|
2150
|
+
}
|
|
2151
|
+
function o(i, a) {
|
|
2152
|
+
return !!i && !!a && i.tapInternalKey === void 0;
|
|
2153
|
+
}
|
|
2154
|
+
return {
|
|
2155
|
+
decode: n,
|
|
2156
|
+
encode: r,
|
|
2157
|
+
check: s,
|
|
2158
|
+
expected: c,
|
|
2159
|
+
canAdd: o
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
return Me.makeConverter = t, Me;
|
|
2163
|
+
}
|
|
2164
|
+
var We = {}, gn;
|
|
2165
|
+
function mo() {
|
|
2166
|
+
if (gn) return We;
|
|
2167
|
+
gn = 1, Object.defineProperty(We, "__esModule", { value: !0 });
|
|
2168
|
+
function t(e) {
|
|
2169
|
+
function n(i) {
|
|
2170
|
+
if (i.key[0] !== e)
|
|
2171
|
+
throw new Error(
|
|
2172
|
+
"Decode Error: could not decode witnessScript with key 0x" + i.key.toString("hex")
|
|
2173
|
+
);
|
|
2174
|
+
return i.value;
|
|
2175
|
+
}
|
|
2176
|
+
function r(i) {
|
|
2177
|
+
return {
|
|
2178
|
+
key: l.from([e]),
|
|
2179
|
+
value: i
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
const c = "Buffer";
|
|
2183
|
+
function s(i) {
|
|
2184
|
+
return l.isBuffer(i);
|
|
2185
|
+
}
|
|
2186
|
+
function o(i, a) {
|
|
2187
|
+
return !!i && !!a && i.witnessScript === void 0;
|
|
2188
|
+
}
|
|
2189
|
+
return {
|
|
2190
|
+
decode: n,
|
|
2191
|
+
encode: r,
|
|
2192
|
+
check: s,
|
|
2193
|
+
expected: c,
|
|
2194
|
+
canAdd: o
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
return We.makeConverter = t, We;
|
|
2198
|
+
}
|
|
2199
|
+
var yn;
|
|
2200
|
+
function At() {
|
|
2201
|
+
if (yn) return ue;
|
|
2202
|
+
yn = 1, Object.defineProperty(ue, "__esModule", { value: !0 });
|
|
2203
|
+
const t = A(), e = so(), n = oo(), r = io(), c = co(), s = ao(), o = uo(), i = fo(), a = po(), u = ho(), f = lo(), p = go(), g = yo(), y = So(), h = bo(), d = hr(), w = wo(), E = Eo(), S = To(), b = _o(), _ = mo(), v = {
|
|
2204
|
+
unsignedTx: n,
|
|
2205
|
+
globalXpub: e,
|
|
2206
|
+
// pass an Array of key bytes that require pubkey beside the key
|
|
2207
|
+
checkPubkey: w.makeChecker([])
|
|
2208
|
+
};
|
|
2209
|
+
ue.globals = v;
|
|
2210
|
+
const C = {
|
|
2211
|
+
nonWitnessUtxo: s,
|
|
2212
|
+
partialSig: o,
|
|
2213
|
+
sighashType: a,
|
|
2214
|
+
finalScriptSig: r,
|
|
2215
|
+
finalScriptWitness: c,
|
|
2216
|
+
porCommitment: i,
|
|
2217
|
+
witnessUtxo: y,
|
|
2218
|
+
bip32Derivation: d.makeConverter(
|
|
2219
|
+
t.InputTypes.BIP32_DERIVATION
|
|
2220
|
+
),
|
|
2221
|
+
redeemScript: E.makeConverter(
|
|
2222
|
+
t.InputTypes.REDEEM_SCRIPT
|
|
2223
|
+
),
|
|
2224
|
+
witnessScript: _.makeConverter(
|
|
2225
|
+
t.InputTypes.WITNESS_SCRIPT
|
|
2226
|
+
),
|
|
2227
|
+
checkPubkey: w.makeChecker([
|
|
2228
|
+
t.InputTypes.PARTIAL_SIG,
|
|
2229
|
+
t.InputTypes.BIP32_DERIVATION
|
|
2230
|
+
]),
|
|
2231
|
+
tapKeySig: u,
|
|
2232
|
+
tapScriptSig: g,
|
|
2233
|
+
tapLeafScript: f,
|
|
2234
|
+
tapBip32Derivation: S.makeConverter(
|
|
2235
|
+
t.InputTypes.TAP_BIP32_DERIVATION
|
|
2236
|
+
),
|
|
2237
|
+
tapInternalKey: b.makeConverter(
|
|
2238
|
+
t.InputTypes.TAP_INTERNAL_KEY
|
|
2239
|
+
),
|
|
2240
|
+
tapMerkleRoot: p
|
|
2241
|
+
};
|
|
2242
|
+
ue.inputs = C;
|
|
2243
|
+
const m = {
|
|
2244
|
+
bip32Derivation: d.makeConverter(
|
|
2245
|
+
t.OutputTypes.BIP32_DERIVATION
|
|
2246
|
+
),
|
|
2247
|
+
redeemScript: E.makeConverter(
|
|
2248
|
+
t.OutputTypes.REDEEM_SCRIPT
|
|
2249
|
+
),
|
|
2250
|
+
witnessScript: _.makeConverter(
|
|
2251
|
+
t.OutputTypes.WITNESS_SCRIPT
|
|
2252
|
+
),
|
|
2253
|
+
checkPubkey: w.makeChecker([
|
|
2254
|
+
t.OutputTypes.BIP32_DERIVATION
|
|
2255
|
+
]),
|
|
2256
|
+
tapBip32Derivation: S.makeConverter(
|
|
2257
|
+
t.OutputTypes.TAP_BIP32_DERIVATION
|
|
2258
|
+
),
|
|
2259
|
+
tapTree: h,
|
|
2260
|
+
tapInternalKey: b.makeConverter(
|
|
2261
|
+
t.OutputTypes.TAP_INTERNAL_KEY
|
|
2262
|
+
)
|
|
2263
|
+
};
|
|
2264
|
+
return ue.outputs = m, ue;
|
|
2265
|
+
}
|
|
2266
|
+
var Sn;
|
|
2267
|
+
function vo() {
|
|
2268
|
+
if (Sn) return ae;
|
|
2269
|
+
Sn = 1, Object.defineProperty(ae, "__esModule", { value: !0 });
|
|
2270
|
+
const t = At(), e = kt(), n = le(), r = A();
|
|
2271
|
+
function c(i, a) {
|
|
2272
|
+
let u = 0;
|
|
2273
|
+
function f() {
|
|
2274
|
+
const m = n.decode(i, u);
|
|
2275
|
+
u += n.encodingLength(m);
|
|
2276
|
+
const k = i.slice(u, u + m);
|
|
2277
|
+
return u += m, k;
|
|
2278
|
+
}
|
|
2279
|
+
function p() {
|
|
2280
|
+
const m = i.readUInt32BE(u);
|
|
2281
|
+
return u += 4, m;
|
|
2282
|
+
}
|
|
2283
|
+
function g() {
|
|
2284
|
+
const m = i.readUInt8(u);
|
|
2285
|
+
return u += 1, m;
|
|
2286
|
+
}
|
|
2287
|
+
function y() {
|
|
2288
|
+
const m = f(), k = f();
|
|
2289
|
+
return {
|
|
2290
|
+
key: m,
|
|
2291
|
+
value: k
|
|
2292
|
+
};
|
|
2293
|
+
}
|
|
2294
|
+
function h() {
|
|
2295
|
+
if (u >= i.length)
|
|
2296
|
+
throw new Error("Format Error: Unexpected End of PSBT");
|
|
2297
|
+
const m = i.readUInt8(u) === 0;
|
|
2298
|
+
return m && u++, m;
|
|
2299
|
+
}
|
|
2300
|
+
if (p() !== 1886610036)
|
|
2301
|
+
throw new Error("Format Error: Invalid Magic Number");
|
|
2302
|
+
if (g() !== 255)
|
|
2303
|
+
throw new Error(
|
|
2304
|
+
"Format Error: Magic Number must be followed by 0xff separator"
|
|
2305
|
+
);
|
|
2306
|
+
const d = [], w = {};
|
|
2307
|
+
for (; !h(); ) {
|
|
2308
|
+
const m = y(), k = m.key.toString("hex");
|
|
2309
|
+
if (w[k])
|
|
2310
|
+
throw new Error(
|
|
2311
|
+
"Format Error: Keys must be unique for global keymap: key " + k
|
|
2312
|
+
);
|
|
2313
|
+
w[k] = 1, d.push(m);
|
|
2314
|
+
}
|
|
2315
|
+
const E = d.filter(
|
|
2316
|
+
(m) => m.key[0] === r.GlobalTypes.UNSIGNED_TX
|
|
2317
|
+
);
|
|
2318
|
+
if (E.length !== 1)
|
|
2319
|
+
throw new Error("Format Error: Only one UNSIGNED_TX allowed");
|
|
2320
|
+
const S = a(E[0].value), { inputCount: b, outputCount: _ } = S.getInputOutputCounts(), v = [], C = [];
|
|
2321
|
+
for (const m of e.range(b)) {
|
|
2322
|
+
const k = {}, U = [];
|
|
2323
|
+
for (; !h(); ) {
|
|
2324
|
+
const R = y(), re = R.key.toString("hex");
|
|
2325
|
+
if (k[re])
|
|
2326
|
+
throw new Error(
|
|
2327
|
+
"Format Error: Keys must be unique for each input: input index " + m + " key " + re
|
|
2328
|
+
);
|
|
2329
|
+
k[re] = 1, U.push(R);
|
|
2330
|
+
}
|
|
2331
|
+
v.push(U);
|
|
2332
|
+
}
|
|
2333
|
+
for (const m of e.range(_)) {
|
|
2334
|
+
const k = {}, U = [];
|
|
2335
|
+
for (; !h(); ) {
|
|
2336
|
+
const R = y(), re = R.key.toString("hex");
|
|
2337
|
+
if (k[re])
|
|
2338
|
+
throw new Error(
|
|
2339
|
+
"Format Error: Keys must be unique for each output: output index " + m + " key " + re
|
|
2340
|
+
);
|
|
2341
|
+
k[re] = 1, U.push(R);
|
|
2342
|
+
}
|
|
2343
|
+
C.push(U);
|
|
2344
|
+
}
|
|
2345
|
+
return o(S, {
|
|
2346
|
+
globalMapKeyVals: d,
|
|
2347
|
+
inputKeyVals: v,
|
|
2348
|
+
outputKeyVals: C
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
ae.psbtFromBuffer = c;
|
|
2352
|
+
function s(i, a, u) {
|
|
2353
|
+
if (!a.equals(l.from([u])))
|
|
2354
|
+
throw new Error(
|
|
2355
|
+
`Format Error: Invalid ${i} key: ${a.toString("hex")}`
|
|
2356
|
+
);
|
|
2357
|
+
}
|
|
2358
|
+
ae.checkKeyBuffer = s;
|
|
2359
|
+
function o(i, { globalMapKeyVals: a, inputKeyVals: u, outputKeyVals: f }) {
|
|
2360
|
+
const p = {
|
|
2361
|
+
unsignedTx: i
|
|
2362
|
+
};
|
|
2363
|
+
let g = 0;
|
|
2364
|
+
for (const E of a)
|
|
2365
|
+
switch (E.key[0]) {
|
|
2366
|
+
case r.GlobalTypes.UNSIGNED_TX:
|
|
2367
|
+
if (s(
|
|
2368
|
+
"global",
|
|
2369
|
+
E.key,
|
|
2370
|
+
r.GlobalTypes.UNSIGNED_TX
|
|
2371
|
+
), g > 0)
|
|
2372
|
+
throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");
|
|
2373
|
+
g++;
|
|
2374
|
+
break;
|
|
2375
|
+
case r.GlobalTypes.GLOBAL_XPUB:
|
|
2376
|
+
p.globalXpub === void 0 && (p.globalXpub = []), p.globalXpub.push(t.globals.globalXpub.decode(E));
|
|
2377
|
+
break;
|
|
2378
|
+
default:
|
|
2379
|
+
p.unknownKeyVals || (p.unknownKeyVals = []), p.unknownKeyVals.push(E);
|
|
2380
|
+
}
|
|
2381
|
+
const y = u.length, h = f.length, d = [], w = [];
|
|
2382
|
+
for (const E of e.range(y)) {
|
|
2383
|
+
const S = {};
|
|
2384
|
+
for (const b of u[E])
|
|
2385
|
+
switch (t.inputs.checkPubkey(b), b.key[0]) {
|
|
2386
|
+
case r.InputTypes.NON_WITNESS_UTXO:
|
|
2387
|
+
if (s(
|
|
2388
|
+
"input",
|
|
2389
|
+
b.key,
|
|
2390
|
+
r.InputTypes.NON_WITNESS_UTXO
|
|
2391
|
+
), S.nonWitnessUtxo !== void 0)
|
|
2392
|
+
throw new Error(
|
|
2393
|
+
"Format Error: Input has multiple NON_WITNESS_UTXO"
|
|
2394
|
+
);
|
|
2395
|
+
S.nonWitnessUtxo = t.inputs.nonWitnessUtxo.decode(b);
|
|
2396
|
+
break;
|
|
2397
|
+
case r.InputTypes.WITNESS_UTXO:
|
|
2398
|
+
if (s(
|
|
2399
|
+
"input",
|
|
2400
|
+
b.key,
|
|
2401
|
+
r.InputTypes.WITNESS_UTXO
|
|
2402
|
+
), S.witnessUtxo !== void 0)
|
|
2403
|
+
throw new Error("Format Error: Input has multiple WITNESS_UTXO");
|
|
2404
|
+
S.witnessUtxo = t.inputs.witnessUtxo.decode(b);
|
|
2405
|
+
break;
|
|
2406
|
+
case r.InputTypes.PARTIAL_SIG:
|
|
2407
|
+
S.partialSig === void 0 && (S.partialSig = []), S.partialSig.push(t.inputs.partialSig.decode(b));
|
|
2408
|
+
break;
|
|
2409
|
+
case r.InputTypes.SIGHASH_TYPE:
|
|
2410
|
+
if (s(
|
|
2411
|
+
"input",
|
|
2412
|
+
b.key,
|
|
2413
|
+
r.InputTypes.SIGHASH_TYPE
|
|
2414
|
+
), S.sighashType !== void 0)
|
|
2415
|
+
throw new Error("Format Error: Input has multiple SIGHASH_TYPE");
|
|
2416
|
+
S.sighashType = t.inputs.sighashType.decode(b);
|
|
2417
|
+
break;
|
|
2418
|
+
case r.InputTypes.REDEEM_SCRIPT:
|
|
2419
|
+
if (s(
|
|
2420
|
+
"input",
|
|
2421
|
+
b.key,
|
|
2422
|
+
r.InputTypes.REDEEM_SCRIPT
|
|
2423
|
+
), S.redeemScript !== void 0)
|
|
2424
|
+
throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");
|
|
2425
|
+
S.redeemScript = t.inputs.redeemScript.decode(b);
|
|
2426
|
+
break;
|
|
2427
|
+
case r.InputTypes.WITNESS_SCRIPT:
|
|
2428
|
+
if (s(
|
|
2429
|
+
"input",
|
|
2430
|
+
b.key,
|
|
2431
|
+
r.InputTypes.WITNESS_SCRIPT
|
|
2432
|
+
), S.witnessScript !== void 0)
|
|
2433
|
+
throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");
|
|
2434
|
+
S.witnessScript = t.inputs.witnessScript.decode(b);
|
|
2435
|
+
break;
|
|
2436
|
+
case r.InputTypes.BIP32_DERIVATION:
|
|
2437
|
+
S.bip32Derivation === void 0 && (S.bip32Derivation = []), S.bip32Derivation.push(
|
|
2438
|
+
t.inputs.bip32Derivation.decode(b)
|
|
2439
|
+
);
|
|
2440
|
+
break;
|
|
2441
|
+
case r.InputTypes.FINAL_SCRIPTSIG:
|
|
2442
|
+
s(
|
|
2443
|
+
"input",
|
|
2444
|
+
b.key,
|
|
2445
|
+
r.InputTypes.FINAL_SCRIPTSIG
|
|
2446
|
+
), S.finalScriptSig = t.inputs.finalScriptSig.decode(b);
|
|
2447
|
+
break;
|
|
2448
|
+
case r.InputTypes.FINAL_SCRIPTWITNESS:
|
|
2449
|
+
s(
|
|
2450
|
+
"input",
|
|
2451
|
+
b.key,
|
|
2452
|
+
r.InputTypes.FINAL_SCRIPTWITNESS
|
|
2453
|
+
), S.finalScriptWitness = t.inputs.finalScriptWitness.decode(
|
|
2454
|
+
b
|
|
2455
|
+
);
|
|
2456
|
+
break;
|
|
2457
|
+
case r.InputTypes.POR_COMMITMENT:
|
|
2458
|
+
s(
|
|
2459
|
+
"input",
|
|
2460
|
+
b.key,
|
|
2461
|
+
r.InputTypes.POR_COMMITMENT
|
|
2462
|
+
), S.porCommitment = t.inputs.porCommitment.decode(b);
|
|
2463
|
+
break;
|
|
2464
|
+
case r.InputTypes.TAP_KEY_SIG:
|
|
2465
|
+
s(
|
|
2466
|
+
"input",
|
|
2467
|
+
b.key,
|
|
2468
|
+
r.InputTypes.TAP_KEY_SIG
|
|
2469
|
+
), S.tapKeySig = t.inputs.tapKeySig.decode(b);
|
|
2470
|
+
break;
|
|
2471
|
+
case r.InputTypes.TAP_SCRIPT_SIG:
|
|
2472
|
+
S.tapScriptSig === void 0 && (S.tapScriptSig = []), S.tapScriptSig.push(t.inputs.tapScriptSig.decode(b));
|
|
2473
|
+
break;
|
|
2474
|
+
case r.InputTypes.TAP_LEAF_SCRIPT:
|
|
2475
|
+
S.tapLeafScript === void 0 && (S.tapLeafScript = []), S.tapLeafScript.push(t.inputs.tapLeafScript.decode(b));
|
|
2476
|
+
break;
|
|
2477
|
+
case r.InputTypes.TAP_BIP32_DERIVATION:
|
|
2478
|
+
S.tapBip32Derivation === void 0 && (S.tapBip32Derivation = []), S.tapBip32Derivation.push(
|
|
2479
|
+
t.inputs.tapBip32Derivation.decode(b)
|
|
2480
|
+
);
|
|
2481
|
+
break;
|
|
2482
|
+
case r.InputTypes.TAP_INTERNAL_KEY:
|
|
2483
|
+
s(
|
|
2484
|
+
"input",
|
|
2485
|
+
b.key,
|
|
2486
|
+
r.InputTypes.TAP_INTERNAL_KEY
|
|
2487
|
+
), S.tapInternalKey = t.inputs.tapInternalKey.decode(b);
|
|
2488
|
+
break;
|
|
2489
|
+
case r.InputTypes.TAP_MERKLE_ROOT:
|
|
2490
|
+
s(
|
|
2491
|
+
"input",
|
|
2492
|
+
b.key,
|
|
2493
|
+
r.InputTypes.TAP_MERKLE_ROOT
|
|
2494
|
+
), S.tapMerkleRoot = t.inputs.tapMerkleRoot.decode(b);
|
|
2495
|
+
break;
|
|
2496
|
+
default:
|
|
2497
|
+
S.unknownKeyVals || (S.unknownKeyVals = []), S.unknownKeyVals.push(b);
|
|
2498
|
+
}
|
|
2499
|
+
d.push(S);
|
|
2500
|
+
}
|
|
2501
|
+
for (const E of e.range(h)) {
|
|
2502
|
+
const S = {};
|
|
2503
|
+
for (const b of f[E])
|
|
2504
|
+
switch (t.outputs.checkPubkey(b), b.key[0]) {
|
|
2505
|
+
case r.OutputTypes.REDEEM_SCRIPT:
|
|
2506
|
+
if (s(
|
|
2507
|
+
"output",
|
|
2508
|
+
b.key,
|
|
2509
|
+
r.OutputTypes.REDEEM_SCRIPT
|
|
2510
|
+
), S.redeemScript !== void 0)
|
|
2511
|
+
throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");
|
|
2512
|
+
S.redeemScript = t.outputs.redeemScript.decode(b);
|
|
2513
|
+
break;
|
|
2514
|
+
case r.OutputTypes.WITNESS_SCRIPT:
|
|
2515
|
+
if (s(
|
|
2516
|
+
"output",
|
|
2517
|
+
b.key,
|
|
2518
|
+
r.OutputTypes.WITNESS_SCRIPT
|
|
2519
|
+
), S.witnessScript !== void 0)
|
|
2520
|
+
throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");
|
|
2521
|
+
S.witnessScript = t.outputs.witnessScript.decode(b);
|
|
2522
|
+
break;
|
|
2523
|
+
case r.OutputTypes.BIP32_DERIVATION:
|
|
2524
|
+
S.bip32Derivation === void 0 && (S.bip32Derivation = []), S.bip32Derivation.push(
|
|
2525
|
+
t.outputs.bip32Derivation.decode(b)
|
|
2526
|
+
);
|
|
2527
|
+
break;
|
|
2528
|
+
case r.OutputTypes.TAP_INTERNAL_KEY:
|
|
2529
|
+
s(
|
|
2530
|
+
"output",
|
|
2531
|
+
b.key,
|
|
2532
|
+
r.OutputTypes.TAP_INTERNAL_KEY
|
|
2533
|
+
), S.tapInternalKey = t.outputs.tapInternalKey.decode(b);
|
|
2534
|
+
break;
|
|
2535
|
+
case r.OutputTypes.TAP_TREE:
|
|
2536
|
+
s(
|
|
2537
|
+
"output",
|
|
2538
|
+
b.key,
|
|
2539
|
+
r.OutputTypes.TAP_TREE
|
|
2540
|
+
), S.tapTree = t.outputs.tapTree.decode(b);
|
|
2541
|
+
break;
|
|
2542
|
+
case r.OutputTypes.TAP_BIP32_DERIVATION:
|
|
2543
|
+
S.tapBip32Derivation === void 0 && (S.tapBip32Derivation = []), S.tapBip32Derivation.push(
|
|
2544
|
+
t.outputs.tapBip32Derivation.decode(b)
|
|
2545
|
+
);
|
|
2546
|
+
break;
|
|
2547
|
+
default:
|
|
2548
|
+
S.unknownKeyVals || (S.unknownKeyVals = []), S.unknownKeyVals.push(b);
|
|
2549
|
+
}
|
|
2550
|
+
w.push(S);
|
|
2551
|
+
}
|
|
2552
|
+
return { globalMap: p, inputs: d, outputs: w };
|
|
2553
|
+
}
|
|
2554
|
+
return ae.psbtFromKeyVals = o, ae;
|
|
2555
|
+
}
|
|
2556
|
+
var de = {}, bn;
|
|
2557
|
+
function Io() {
|
|
2558
|
+
if (bn) return de;
|
|
2559
|
+
bn = 1, Object.defineProperty(de, "__esModule", { value: !0 });
|
|
2560
|
+
const t = At(), e = kt();
|
|
2561
|
+
function n({ globalMap: o, inputs: i, outputs: a }) {
|
|
2562
|
+
const { globalKeyVals: u, inputKeyVals: f, outputKeyVals: p } = s({
|
|
2563
|
+
globalMap: o,
|
|
2564
|
+
inputs: i,
|
|
2565
|
+
outputs: a
|
|
2566
|
+
}), g = e.keyValsToBuffer(u), y = (E) => E.length === 0 ? [l.from([0])] : E.map(e.keyValsToBuffer), h = y(f), d = y(p), w = l.allocUnsafe(5);
|
|
2567
|
+
return w.writeUIntBE(482972169471, 0, 5), l.concat(
|
|
2568
|
+
[w, g].concat(h, d)
|
|
2569
|
+
);
|
|
2570
|
+
}
|
|
2571
|
+
de.psbtToBuffer = n;
|
|
2572
|
+
const r = (o, i) => o.key.compare(i.key);
|
|
2573
|
+
function c(o, i) {
|
|
2574
|
+
const a = /* @__PURE__ */ new Set(), u = Object.entries(o).reduce((p, [g, y]) => {
|
|
2575
|
+
if (g === "unknownKeyVals") return p;
|
|
2576
|
+
const h = i[g];
|
|
2577
|
+
if (h === void 0) return p;
|
|
2578
|
+
const d = (Array.isArray(y) ? y : [y]).map(
|
|
2579
|
+
h.encode
|
|
2580
|
+
);
|
|
2581
|
+
return d.map((E) => E.key.toString("hex")).forEach((E) => {
|
|
2582
|
+
if (a.has(E))
|
|
2583
|
+
throw new Error("Serialize Error: Duplicate key: " + E);
|
|
2584
|
+
a.add(E);
|
|
2585
|
+
}), p.concat(d);
|
|
2586
|
+
}, []), f = o.unknownKeyVals ? o.unknownKeyVals.filter((p) => !a.has(p.key.toString("hex"))) : [];
|
|
2587
|
+
return u.concat(f).sort(r);
|
|
2588
|
+
}
|
|
2589
|
+
function s({ globalMap: o, inputs: i, outputs: a }) {
|
|
2590
|
+
return {
|
|
2591
|
+
globalKeyVals: c(o, t.globals),
|
|
2592
|
+
inputKeyVals: i.map((u) => c(u, t.inputs)),
|
|
2593
|
+
outputKeyVals: a.map((u) => c(u, t.outputs))
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
return de.psbtToKeyVals = s, de;
|
|
2597
|
+
}
|
|
2598
|
+
var wn;
|
|
2599
|
+
function lr() {
|
|
2600
|
+
return wn || (wn = 1, (function(t) {
|
|
2601
|
+
function e(n) {
|
|
2602
|
+
for (var r in n) t.hasOwnProperty(r) || (t[r] = n[r]);
|
|
2603
|
+
}
|
|
2604
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), e(vo()), e(Io());
|
|
2605
|
+
})(ft)), ft;
|
|
2606
|
+
}
|
|
2607
|
+
var En;
|
|
2608
|
+
function ko() {
|
|
2609
|
+
if (En) return Ue;
|
|
2610
|
+
En = 1, Object.defineProperty(Ue, "__esModule", { value: !0 });
|
|
2611
|
+
const t = lr();
|
|
2612
|
+
function e(s) {
|
|
2613
|
+
const o = s[0], i = t.psbtToKeyVals(o), a = s.slice(1);
|
|
2614
|
+
if (a.length === 0) throw new Error("Combine: Nothing to combine");
|
|
2615
|
+
const u = r(o);
|
|
2616
|
+
if (u === void 0)
|
|
2617
|
+
throw new Error("Combine: Self missing transaction");
|
|
2618
|
+
const f = c(i.globalKeyVals), p = i.inputKeyVals.map(c), g = i.outputKeyVals.map(c);
|
|
2619
|
+
for (const y of a) {
|
|
2620
|
+
const h = r(y);
|
|
2621
|
+
if (h === void 0 || !h.toBuffer().equals(u.toBuffer()))
|
|
2622
|
+
throw new Error(
|
|
2623
|
+
"Combine: One of the Psbts does not have the same transaction."
|
|
2624
|
+
);
|
|
2625
|
+
const d = t.psbtToKeyVals(y);
|
|
2626
|
+
c(d.globalKeyVals).forEach(
|
|
2627
|
+
n(
|
|
2628
|
+
f,
|
|
2629
|
+
i.globalKeyVals,
|
|
2630
|
+
d.globalKeyVals
|
|
2631
|
+
)
|
|
2632
|
+
), d.inputKeyVals.map(c).forEach(
|
|
2633
|
+
(b, _) => b.forEach(
|
|
2634
|
+
n(
|
|
2635
|
+
p[_],
|
|
2636
|
+
i.inputKeyVals[_],
|
|
2637
|
+
d.inputKeyVals[_]
|
|
2638
|
+
)
|
|
2639
|
+
)
|
|
2640
|
+
), d.outputKeyVals.map(c).forEach(
|
|
2641
|
+
(b, _) => b.forEach(
|
|
2642
|
+
n(
|
|
2643
|
+
g[_],
|
|
2644
|
+
i.outputKeyVals[_],
|
|
2645
|
+
d.outputKeyVals[_]
|
|
2646
|
+
)
|
|
2647
|
+
)
|
|
2648
|
+
);
|
|
2649
|
+
}
|
|
2650
|
+
return t.psbtFromKeyVals(u, {
|
|
2651
|
+
globalMapKeyVals: i.globalKeyVals,
|
|
2652
|
+
inputKeyVals: i.inputKeyVals,
|
|
2653
|
+
outputKeyVals: i.outputKeyVals
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
Ue.combine = e;
|
|
2657
|
+
function n(s, o, i) {
|
|
2658
|
+
return (a) => {
|
|
2659
|
+
if (s.has(a)) return;
|
|
2660
|
+
const u = i.filter((f) => f.key.toString("hex") === a)[0];
|
|
2661
|
+
o.push(u), s.add(a);
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
function r(s) {
|
|
2665
|
+
return s.globalMap.unsignedTx;
|
|
2666
|
+
}
|
|
2667
|
+
function c(s) {
|
|
2668
|
+
const o = /* @__PURE__ */ new Set();
|
|
2669
|
+
return s.forEach((i) => {
|
|
2670
|
+
const a = i.key.toString("hex");
|
|
2671
|
+
if (o.has(a))
|
|
2672
|
+
throw new Error("Combine: KeyValue Map keys should be unique");
|
|
2673
|
+
o.add(a);
|
|
2674
|
+
}), o;
|
|
2675
|
+
}
|
|
2676
|
+
return Ue;
|
|
2677
|
+
}
|
|
2678
|
+
var ht = {}, Tn;
|
|
2679
|
+
function dr() {
|
|
2680
|
+
return Tn || (Tn = 1, (function(t) {
|
|
2681
|
+
Object.defineProperty(t, "__esModule", { value: !0 });
|
|
2682
|
+
const e = At();
|
|
2683
|
+
function n(y, h) {
|
|
2684
|
+
const d = y[h];
|
|
2685
|
+
if (d === void 0) throw new Error(`No input #${h}`);
|
|
2686
|
+
return d;
|
|
2687
|
+
}
|
|
2688
|
+
t.checkForInput = n;
|
|
2689
|
+
function r(y, h) {
|
|
2690
|
+
const d = y[h];
|
|
2691
|
+
if (d === void 0) throw new Error(`No output #${h}`);
|
|
2692
|
+
return d;
|
|
2693
|
+
}
|
|
2694
|
+
t.checkForOutput = r;
|
|
2695
|
+
function c(y, h, d) {
|
|
2696
|
+
if (y.key[0] < d)
|
|
2697
|
+
throw new Error(
|
|
2698
|
+
"Use the method for your specific key instead of addUnknownKeyVal*"
|
|
2699
|
+
);
|
|
2700
|
+
if (h && h.filter((w) => w.key.equals(y.key)).length !== 0)
|
|
2701
|
+
throw new Error(`Duplicate Key: ${y.key.toString("hex")}`);
|
|
2702
|
+
}
|
|
2703
|
+
t.checkHasKey = c;
|
|
2704
|
+
function s(y) {
|
|
2705
|
+
let h = 0;
|
|
2706
|
+
return Object.keys(y).forEach((d) => {
|
|
2707
|
+
Number(isNaN(Number(d))) && h++;
|
|
2708
|
+
}), h;
|
|
2709
|
+
}
|
|
2710
|
+
t.getEnumLength = s;
|
|
2711
|
+
function o(y, h) {
|
|
2712
|
+
let d = !1;
|
|
2713
|
+
if (h.nonWitnessUtxo || h.witnessUtxo) {
|
|
2714
|
+
const w = !!h.redeemScript, E = !!h.witnessScript, S = !w || !!h.finalScriptSig, b = !E || !!h.finalScriptWitness, _ = !!h.finalScriptSig || !!h.finalScriptWitness;
|
|
2715
|
+
d = S && b && _;
|
|
2716
|
+
}
|
|
2717
|
+
if (d === !1)
|
|
2718
|
+
throw new Error(
|
|
2719
|
+
`Input #${y} has too much or too little data to clean`
|
|
2720
|
+
);
|
|
2721
|
+
}
|
|
2722
|
+
t.inputCheckUncleanFinalized = o;
|
|
2723
|
+
function i(y, h, d, w) {
|
|
2724
|
+
throw new Error(
|
|
2725
|
+
`Data for ${y} key ${h} is incorrect: Expected ${d} and got ${JSON.stringify(w)}`
|
|
2726
|
+
);
|
|
2727
|
+
}
|
|
2728
|
+
function a(y) {
|
|
2729
|
+
return (h, d) => {
|
|
2730
|
+
for (const w of Object.keys(h)) {
|
|
2731
|
+
const E = h[w], { canAdd: S, canAddToArray: b, check: _, expected: v } = (
|
|
2732
|
+
// @ts-ignore
|
|
2733
|
+
e[y + "s"][w] || {}
|
|
2734
|
+
), C = !!b;
|
|
2735
|
+
if (_)
|
|
2736
|
+
if (C) {
|
|
2737
|
+
if (!Array.isArray(E) || // @ts-ignore
|
|
2738
|
+
d[w] && !Array.isArray(d[w]))
|
|
2739
|
+
throw new Error(`Key type ${w} must be an array`);
|
|
2740
|
+
E.every(_) || i(y, w, v, E);
|
|
2741
|
+
const m = d[w] || [], k = /* @__PURE__ */ new Set();
|
|
2742
|
+
if (!E.every((U) => b(m, U, k)))
|
|
2743
|
+
throw new Error("Can not add duplicate data to array");
|
|
2744
|
+
d[w] = m.concat(E);
|
|
2745
|
+
} else {
|
|
2746
|
+
if (_(E) || i(y, w, v, E), !S(d, E))
|
|
2747
|
+
throw new Error(`Can not add duplicate data to ${y}`);
|
|
2748
|
+
d[w] = E;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
t.updateGlobal = a("global"), t.updateInput = a("input"), t.updateOutput = a("output");
|
|
2754
|
+
function u(y, h) {
|
|
2755
|
+
const d = y.length - 1, w = n(y, d);
|
|
2756
|
+
t.updateInput(h, w);
|
|
2757
|
+
}
|
|
2758
|
+
t.addInputAttributes = u;
|
|
2759
|
+
function f(y, h) {
|
|
2760
|
+
const d = y.length - 1, w = r(y, d);
|
|
2761
|
+
t.updateOutput(h, w);
|
|
2762
|
+
}
|
|
2763
|
+
t.addOutputAttributes = f;
|
|
2764
|
+
function p(y, h) {
|
|
2765
|
+
if (!l.isBuffer(h) || h.length < 4)
|
|
2766
|
+
throw new Error("Set Version: Invalid Transaction");
|
|
2767
|
+
return h.writeUInt32LE(y, 0), h;
|
|
2768
|
+
}
|
|
2769
|
+
t.defaultVersionSetter = p;
|
|
2770
|
+
function g(y, h) {
|
|
2771
|
+
if (!l.isBuffer(h) || h.length < 4)
|
|
2772
|
+
throw new Error("Set Locktime: Invalid Transaction");
|
|
2773
|
+
return h.writeUInt32LE(y, h.length - 4), h;
|
|
2774
|
+
}
|
|
2775
|
+
t.defaultLocktimeSetter = g;
|
|
2776
|
+
})(ht)), ht;
|
|
2777
|
+
}
|
|
2778
|
+
var _n;
|
|
2779
|
+
function Ao() {
|
|
2780
|
+
if (_n) return He;
|
|
2781
|
+
_n = 1, Object.defineProperty(He, "__esModule", { value: !0 });
|
|
2782
|
+
const t = ko(), e = lr(), n = A(), r = dr();
|
|
2783
|
+
class c {
|
|
2784
|
+
constructor(o) {
|
|
2785
|
+
this.inputs = [], this.outputs = [], this.globalMap = {
|
|
2786
|
+
unsignedTx: o
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
static fromBase64(o, i) {
|
|
2790
|
+
const a = l.from(o, "base64");
|
|
2791
|
+
return this.fromBuffer(a, i);
|
|
2792
|
+
}
|
|
2793
|
+
static fromHex(o, i) {
|
|
2794
|
+
const a = l.from(o, "hex");
|
|
2795
|
+
return this.fromBuffer(a, i);
|
|
2796
|
+
}
|
|
2797
|
+
static fromBuffer(o, i) {
|
|
2798
|
+
const a = e.psbtFromBuffer(o, i), u = new this(a.globalMap.unsignedTx);
|
|
2799
|
+
return Object.assign(u, a), u;
|
|
2800
|
+
}
|
|
2801
|
+
toBase64() {
|
|
2802
|
+
return this.toBuffer().toString("base64");
|
|
2803
|
+
}
|
|
2804
|
+
toHex() {
|
|
2805
|
+
return this.toBuffer().toString("hex");
|
|
2806
|
+
}
|
|
2807
|
+
toBuffer() {
|
|
2808
|
+
return e.psbtToBuffer(this);
|
|
2809
|
+
}
|
|
2810
|
+
updateGlobal(o) {
|
|
2811
|
+
return r.updateGlobal(o, this.globalMap), this;
|
|
2812
|
+
}
|
|
2813
|
+
updateInput(o, i) {
|
|
2814
|
+
const a = r.checkForInput(this.inputs, o);
|
|
2815
|
+
return r.updateInput(i, a), this;
|
|
2816
|
+
}
|
|
2817
|
+
updateOutput(o, i) {
|
|
2818
|
+
const a = r.checkForOutput(this.outputs, o);
|
|
2819
|
+
return r.updateOutput(i, a), this;
|
|
2820
|
+
}
|
|
2821
|
+
addUnknownKeyValToGlobal(o) {
|
|
2822
|
+
return r.checkHasKey(
|
|
2823
|
+
o,
|
|
2824
|
+
this.globalMap.unknownKeyVals,
|
|
2825
|
+
r.getEnumLength(n.GlobalTypes)
|
|
2826
|
+
), this.globalMap.unknownKeyVals || (this.globalMap.unknownKeyVals = []), this.globalMap.unknownKeyVals.push(o), this;
|
|
2827
|
+
}
|
|
2828
|
+
addUnknownKeyValToInput(o, i) {
|
|
2829
|
+
const a = r.checkForInput(this.inputs, o);
|
|
2830
|
+
return r.checkHasKey(
|
|
2831
|
+
i,
|
|
2832
|
+
a.unknownKeyVals,
|
|
2833
|
+
r.getEnumLength(n.InputTypes)
|
|
2834
|
+
), a.unknownKeyVals || (a.unknownKeyVals = []), a.unknownKeyVals.push(i), this;
|
|
2835
|
+
}
|
|
2836
|
+
addUnknownKeyValToOutput(o, i) {
|
|
2837
|
+
const a = r.checkForOutput(this.outputs, o);
|
|
2838
|
+
return r.checkHasKey(
|
|
2839
|
+
i,
|
|
2840
|
+
a.unknownKeyVals,
|
|
2841
|
+
r.getEnumLength(n.OutputTypes)
|
|
2842
|
+
), a.unknownKeyVals || (a.unknownKeyVals = []), a.unknownKeyVals.push(i), this;
|
|
2843
|
+
}
|
|
2844
|
+
addInput(o) {
|
|
2845
|
+
this.globalMap.unsignedTx.addInput(o), this.inputs.push({
|
|
2846
|
+
unknownKeyVals: []
|
|
2847
|
+
});
|
|
2848
|
+
const i = o.unknownKeyVals || [], a = this.inputs.length - 1;
|
|
2849
|
+
if (!Array.isArray(i))
|
|
2850
|
+
throw new Error("unknownKeyVals must be an Array");
|
|
2851
|
+
return i.forEach(
|
|
2852
|
+
(u) => this.addUnknownKeyValToInput(a, u)
|
|
2853
|
+
), r.addInputAttributes(this.inputs, o), this;
|
|
2854
|
+
}
|
|
2855
|
+
addOutput(o) {
|
|
2856
|
+
this.globalMap.unsignedTx.addOutput(o), this.outputs.push({
|
|
2857
|
+
unknownKeyVals: []
|
|
2858
|
+
});
|
|
2859
|
+
const i = o.unknownKeyVals || [], a = this.outputs.length - 1;
|
|
2860
|
+
if (!Array.isArray(i))
|
|
2861
|
+
throw new Error("unknownKeyVals must be an Array");
|
|
2862
|
+
return i.forEach(
|
|
2863
|
+
(u) => this.addUnknownKeyValToOutput(a, u)
|
|
2864
|
+
), r.addOutputAttributes(this.outputs, o), this;
|
|
2865
|
+
}
|
|
2866
|
+
clearFinalizedInput(o) {
|
|
2867
|
+
const i = r.checkForInput(this.inputs, o);
|
|
2868
|
+
r.inputCheckUncleanFinalized(o, i);
|
|
2869
|
+
for (const a of Object.keys(i))
|
|
2870
|
+
[
|
|
2871
|
+
"witnessUtxo",
|
|
2872
|
+
"nonWitnessUtxo",
|
|
2873
|
+
"finalScriptSig",
|
|
2874
|
+
"finalScriptWitness",
|
|
2875
|
+
"unknownKeyVals"
|
|
2876
|
+
].includes(a) || delete i[a];
|
|
2877
|
+
return this;
|
|
2878
|
+
}
|
|
2879
|
+
combine(...o) {
|
|
2880
|
+
const i = t.combine([this].concat(o));
|
|
2881
|
+
return Object.assign(this, i), this;
|
|
2882
|
+
}
|
|
2883
|
+
getTransaction() {
|
|
2884
|
+
return this.globalMap.unsignedTx.toBuffer();
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
return He.Psbt = c, He;
|
|
2888
|
+
}
|
|
2889
|
+
var mn = Ao(), x = dr();
|
|
2890
|
+
const vn = bt.decode, xo = {
|
|
2891
|
+
/**
|
|
2892
|
+
* A bitcoinjs Network object. This is only used if you pass an `address`
|
|
2893
|
+
* parameter to addOutput. Otherwise it is not needed and can be left default.
|
|
2894
|
+
*/
|
|
2895
|
+
network: Je,
|
|
2896
|
+
/**
|
|
2897
|
+
* When extractTransaction is called, the fee rate is checked.
|
|
2898
|
+
* THIS IS NOT TO BE RELIED ON.
|
|
2899
|
+
* It is only here as a last ditch effort to prevent sending a 500 BTC fee etc.
|
|
2900
|
+
*/
|
|
2901
|
+
maximumFeeRate: 5e3
|
|
2902
|
+
// satoshi per byte
|
|
2903
|
+
};
|
|
2904
|
+
class Tt {
|
|
2905
|
+
constructor(e = {}, n = new mn.Psbt(new gr())) {
|
|
2906
|
+
this.data = n, this.opts = Object.assign({}, xo, e), this.__CACHE = {
|
|
2907
|
+
__NON_WITNESS_UTXO_TX_CACHE: [],
|
|
2908
|
+
__NON_WITNESS_UTXO_BUF_CACHE: [],
|
|
2909
|
+
__TX_IN_CACHE: {},
|
|
2910
|
+
// unsignedTx.tx property is dynamically added by PsbtBase
|
|
2911
|
+
__TX: this.data.globalMap.unsignedTx.tx,
|
|
2912
|
+
__UNSAFE_SIGN_NONSEGWIT: !1
|
|
2913
|
+
}, e.version === 3 ? this.setVersionTRUC() : this.data.inputs.length === 0 && this.setVersion(2);
|
|
2914
|
+
const r = (c, s, o, i) => {
|
|
2915
|
+
Object.defineProperty(c, s, {
|
|
2916
|
+
enumerable: o,
|
|
2917
|
+
writable: i
|
|
2918
|
+
});
|
|
2919
|
+
};
|
|
2920
|
+
r(this, "__CACHE", !1, !0), r(this, "opts", !1, !0);
|
|
2921
|
+
}
|
|
2922
|
+
get inputCount() {
|
|
2923
|
+
return this.data.inputs.length;
|
|
2924
|
+
}
|
|
2925
|
+
get version() {
|
|
2926
|
+
return this.__CACHE.__TX.version;
|
|
2927
|
+
}
|
|
2928
|
+
set version(e) {
|
|
2929
|
+
this.setVersion(e);
|
|
2930
|
+
}
|
|
2931
|
+
get locktime() {
|
|
2932
|
+
return this.__CACHE.__TX.locktime;
|
|
2933
|
+
}
|
|
2934
|
+
set locktime(e) {
|
|
2935
|
+
this.setLocktime(e);
|
|
2936
|
+
}
|
|
2937
|
+
get txInputs() {
|
|
2938
|
+
return this.__CACHE.__TX.ins.map((e) => ({
|
|
2939
|
+
hash: Ot(e.hash),
|
|
2940
|
+
index: e.index,
|
|
2941
|
+
sequence: e.sequence
|
|
2942
|
+
}));
|
|
2943
|
+
}
|
|
2944
|
+
get txOutputs() {
|
|
2945
|
+
return this.__CACHE.__TX.outs.map((e) => {
|
|
2946
|
+
let n;
|
|
2947
|
+
try {
|
|
2948
|
+
n = zn(e.script, this.opts.network);
|
|
2949
|
+
} catch {
|
|
2950
|
+
}
|
|
2951
|
+
return {
|
|
2952
|
+
script: Ot(e.script),
|
|
2953
|
+
value: e.value,
|
|
2954
|
+
address: n
|
|
2955
|
+
};
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
static fromBase64(e, n = {}) {
|
|
2959
|
+
const r = l.from(e, "base64");
|
|
2960
|
+
return this.fromBuffer(r, n);
|
|
2961
|
+
}
|
|
2962
|
+
static fromHex(e, n = {}) {
|
|
2963
|
+
const r = l.from(e, "hex");
|
|
2964
|
+
return this.fromBuffer(r, n);
|
|
2965
|
+
}
|
|
2966
|
+
static fromBuffer(e, n = {}) {
|
|
2967
|
+
const r = mn.Psbt.fromBuffer(e, Oo), c = new Tt(n, r);
|
|
2968
|
+
return Uo(c.__CACHE.__TX, c.__CACHE), c;
|
|
2969
|
+
}
|
|
2970
|
+
combine(...e) {
|
|
2971
|
+
return this.data.combine(...e.map((n) => n.data)), this;
|
|
2972
|
+
}
|
|
2973
|
+
clone() {
|
|
2974
|
+
const e = JSON.parse(JSON.stringify(this.opts));
|
|
2975
|
+
return Tt.fromBuffer(this.data.toBuffer(), e);
|
|
2976
|
+
}
|
|
2977
|
+
setMaximumFeeRate(e) {
|
|
2978
|
+
Ge(e), this.opts.maximumFeeRate = e;
|
|
2979
|
+
}
|
|
2980
|
+
setVersion(e) {
|
|
2981
|
+
Ge(e), ge(this.data.inputs, "setVersion");
|
|
2982
|
+
const n = this.__CACHE;
|
|
2983
|
+
return n.__TX.version = e, n.__EXTRACTED_TX = void 0, this;
|
|
2984
|
+
}
|
|
2985
|
+
setVersionTRUC() {
|
|
2986
|
+
return this.setVersion(I.TRUC_VERSION);
|
|
2987
|
+
}
|
|
2988
|
+
setLocktime(e) {
|
|
2989
|
+
Ge(e), ge(this.data.inputs, "setLocktime");
|
|
2990
|
+
const n = this.__CACHE;
|
|
2991
|
+
return n.__TX.locktime = e, n.__EXTRACTED_TX = void 0, this;
|
|
2992
|
+
}
|
|
2993
|
+
setInputSequence(e, n) {
|
|
2994
|
+
Ge(n), ge(this.data.inputs, "setInputSequence");
|
|
2995
|
+
const r = this.__CACHE;
|
|
2996
|
+
if (r.__TX.ins.length <= e)
|
|
2997
|
+
throw new Error("Input index too high");
|
|
2998
|
+
return r.__TX.ins[e].sequence = n, r.__EXTRACTED_TX = void 0, this;
|
|
2999
|
+
}
|
|
3000
|
+
addInputs(e, n = !0) {
|
|
3001
|
+
return e.forEach((r) => this.addInput(r, n)), this;
|
|
3002
|
+
}
|
|
3003
|
+
addInput(e, n = !0) {
|
|
3004
|
+
if (!e || e.hash === void 0 || e.index === void 0)
|
|
3005
|
+
throw new Error(
|
|
3006
|
+
"Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]"
|
|
3007
|
+
);
|
|
3008
|
+
Xt(e, e, "addInput"), n && ge(this.data.inputs, "addInput"), e.witnessScript && ze(e.witnessScript);
|
|
3009
|
+
const r = this.__CACHE;
|
|
3010
|
+
this.data.addInput(e);
|
|
3011
|
+
const c = r.__TX.ins[r.__TX.ins.length - 1];
|
|
3012
|
+
br(r, c);
|
|
3013
|
+
const s = this.data.inputs.length - 1, o = this.data.inputs[s];
|
|
3014
|
+
return o.nonWitnessUtxo && mt(this.__CACHE, o, s), r.__FEE = void 0, r.__FEE_RATE = void 0, r.__EXTRACTED_TX = void 0, this;
|
|
3015
|
+
}
|
|
3016
|
+
addOutputs(e) {
|
|
3017
|
+
return e.forEach((n) => this.addOutput(n)), this;
|
|
3018
|
+
}
|
|
3019
|
+
addOutput(e) {
|
|
3020
|
+
const n = "address" in e, r = "script" in e;
|
|
3021
|
+
if (arguments.length > 1 || !e || e.value === void 0 || !n && !r)
|
|
3022
|
+
throw new Error(
|
|
3023
|
+
"Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]"
|
|
3024
|
+
);
|
|
3025
|
+
if (ge(this.data.inputs, "addOutput"), n) {
|
|
3026
|
+
const { address: s } = e, { network: o } = this.opts, i = $n(s, o);
|
|
3027
|
+
e = Object.assign({}, e, { script: i });
|
|
3028
|
+
}
|
|
3029
|
+
qt(e, e, "addOutput");
|
|
3030
|
+
const c = this.__CACHE;
|
|
3031
|
+
return this.data.addOutput(e), c.__FEE = void 0, c.__FEE_RATE = void 0, c.__EXTRACTED_TX = void 0, this;
|
|
3032
|
+
}
|
|
3033
|
+
extractTransaction(e, n) {
|
|
3034
|
+
if (n && (this.data.inputs = this.data.inputs.filter((s) => !s.partialSig)), !this.data.inputs.every(yr)) throw new Error("Not finalized");
|
|
3035
|
+
const r = this.__CACHE;
|
|
3036
|
+
if (e || Po(this, r, this.opts), r.__EXTRACTED_TX) return r.__EXTRACTED_TX;
|
|
3037
|
+
const c = r.__TX.clone();
|
|
3038
|
+
return vr(this.data.inputs, c, r, !0, n), c;
|
|
3039
|
+
}
|
|
3040
|
+
getFeeRate(e = !1) {
|
|
3041
|
+
return On(
|
|
3042
|
+
"__FEE_RATE",
|
|
3043
|
+
"fee rate",
|
|
3044
|
+
this.data.inputs,
|
|
3045
|
+
this.__CACHE,
|
|
3046
|
+
e
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
getFee(e = !1) {
|
|
3050
|
+
return On("__FEE", "fee", this.data.inputs, this.__CACHE, e);
|
|
3051
|
+
}
|
|
3052
|
+
finalizeAllInputs() {
|
|
3053
|
+
return x.checkForInput(this.data.inputs, 0), ye(this.data.inputs.length).forEach((e) => this.finalizeInput(e)), this;
|
|
3054
|
+
}
|
|
3055
|
+
finalizeInput(e, n, r) {
|
|
3056
|
+
const c = x.checkForInput(this.data.inputs, e);
|
|
3057
|
+
return H(c) ? this._finalizeTaprootInput(
|
|
3058
|
+
e,
|
|
3059
|
+
c,
|
|
3060
|
+
void 0,
|
|
3061
|
+
n
|
|
3062
|
+
) : this._finalizeInput(
|
|
3063
|
+
e,
|
|
3064
|
+
c,
|
|
3065
|
+
n,
|
|
3066
|
+
r ?? !0
|
|
3067
|
+
);
|
|
3068
|
+
}
|
|
3069
|
+
finalizeTaprootInput(e, n, r = Gt) {
|
|
3070
|
+
const c = x.checkForInput(this.data.inputs, e);
|
|
3071
|
+
if (H(c))
|
|
3072
|
+
return this._finalizeTaprootInput(
|
|
3073
|
+
e,
|
|
3074
|
+
c,
|
|
3075
|
+
n,
|
|
3076
|
+
r
|
|
3077
|
+
);
|
|
3078
|
+
throw new Error(`Cannot finalize input #${e}. Not Taproot.`);
|
|
3079
|
+
}
|
|
3080
|
+
getInputType(e) {
|
|
3081
|
+
const n = x.checkForInput(this.data.inputs, e), r = Ir(e, n, this.__CACHE), c = st(
|
|
3082
|
+
r,
|
|
3083
|
+
e,
|
|
3084
|
+
"input",
|
|
3085
|
+
n.redeemScript || qo(n.finalScriptSig),
|
|
3086
|
+
n.witnessScript || Do(n.finalScriptWitness)
|
|
3087
|
+
), s = c.type === "raw" ? "" : c.type + "-", o = Ar(c.meaningfulScript);
|
|
3088
|
+
return s + o;
|
|
3089
|
+
}
|
|
3090
|
+
inputHasPubkey(e, n) {
|
|
3091
|
+
const r = x.checkForInput(this.data.inputs, e);
|
|
3092
|
+
return Go(n, r, e, this.__CACHE);
|
|
3093
|
+
}
|
|
3094
|
+
inputHasHDKey(e, n) {
|
|
3095
|
+
const r = x.checkForInput(this.data.inputs, e), c = kn(n);
|
|
3096
|
+
return !!r.bip32Derivation && r.bip32Derivation.some(c);
|
|
3097
|
+
}
|
|
3098
|
+
outputHasPubkey(e, n) {
|
|
3099
|
+
const r = x.checkForOutput(this.data.outputs, e);
|
|
3100
|
+
return Xo(n, r, e, this.__CACHE);
|
|
3101
|
+
}
|
|
3102
|
+
outputHasHDKey(e, n) {
|
|
3103
|
+
const r = x.checkForOutput(this.data.outputs, e), c = kn(n);
|
|
3104
|
+
return !!r.bip32Derivation && r.bip32Derivation.some(c);
|
|
3105
|
+
}
|
|
3106
|
+
validateSignaturesOfAllInputs(e) {
|
|
3107
|
+
return x.checkForInput(this.data.inputs, 0), ye(this.data.inputs.length).map(
|
|
3108
|
+
(r) => this.validateSignaturesOfInput(r, e)
|
|
3109
|
+
).reduce((r, c) => c && r, !0);
|
|
3110
|
+
}
|
|
3111
|
+
validateSignaturesOfInput(e, n, r) {
|
|
3112
|
+
const c = this.data.inputs[e];
|
|
3113
|
+
return H(c) ? this.validateSignaturesOfTaprootInput(e, n, r) : this._validateSignaturesOfInput(e, n, r);
|
|
3114
|
+
}
|
|
3115
|
+
signAllInputsHD(e, n = [I.SIGHASH_ALL]) {
|
|
3116
|
+
if (!e || !e.publicKey || !e.fingerprint)
|
|
3117
|
+
throw new Error("Need HDSigner to sign input");
|
|
3118
|
+
const r = [];
|
|
3119
|
+
for (const c of ye(this.data.inputs.length))
|
|
3120
|
+
try {
|
|
3121
|
+
this.signInputHD(c, e, n), r.push(!0);
|
|
3122
|
+
} catch {
|
|
3123
|
+
r.push(!1);
|
|
3124
|
+
}
|
|
3125
|
+
if (r.every((c) => !c))
|
|
3126
|
+
throw new Error("No inputs were signed");
|
|
3127
|
+
return this;
|
|
3128
|
+
}
|
|
3129
|
+
signAllInputsHDAsync(e, n = [I.SIGHASH_ALL]) {
|
|
3130
|
+
return new Promise((r, c) => {
|
|
3131
|
+
if (!e || !e.publicKey || !e.fingerprint)
|
|
3132
|
+
return c(new Error("Need HDSigner to sign input"));
|
|
3133
|
+
const s = [], o = [];
|
|
3134
|
+
for (const i of ye(this.data.inputs.length))
|
|
3135
|
+
o.push(
|
|
3136
|
+
this.signInputHDAsync(i, e, n).then(
|
|
3137
|
+
() => {
|
|
3138
|
+
s.push(!0);
|
|
3139
|
+
},
|
|
3140
|
+
() => {
|
|
3141
|
+
s.push(!1);
|
|
3142
|
+
}
|
|
3143
|
+
)
|
|
3144
|
+
);
|
|
3145
|
+
return Promise.all(o).then(() => {
|
|
3146
|
+
if (s.every((i) => !i))
|
|
3147
|
+
return c(new Error("No inputs were signed"));
|
|
3148
|
+
r();
|
|
3149
|
+
});
|
|
3150
|
+
});
|
|
3151
|
+
}
|
|
3152
|
+
signInputHD(e, n, r = [I.SIGHASH_ALL]) {
|
|
3153
|
+
if (!n || !n.publicKey || !n.fingerprint)
|
|
3154
|
+
throw new Error("Need HDSigner to sign input");
|
|
3155
|
+
return Nn(e, this.data.inputs, n).forEach((s) => this.signInput(e, s, r)), this;
|
|
3156
|
+
}
|
|
3157
|
+
signInputHDAsync(e, n, r = [I.SIGHASH_ALL]) {
|
|
3158
|
+
return new Promise((c, s) => {
|
|
3159
|
+
if (!n || !n.publicKey || !n.fingerprint)
|
|
3160
|
+
return s(new Error("Need HDSigner to sign input"));
|
|
3161
|
+
const i = Nn(e, this.data.inputs, n).map(
|
|
3162
|
+
(a) => this.signInputAsync(e, a, r)
|
|
3163
|
+
);
|
|
3164
|
+
return Promise.all(i).then(() => {
|
|
3165
|
+
c();
|
|
3166
|
+
}).catch(s);
|
|
3167
|
+
});
|
|
3168
|
+
}
|
|
3169
|
+
signAllInputs(e, n) {
|
|
3170
|
+
if (!e || !e.publicKey) throw new Error("Need Signer to sign input");
|
|
3171
|
+
const r = [];
|
|
3172
|
+
for (const c of ye(this.data.inputs.length))
|
|
3173
|
+
try {
|
|
3174
|
+
this.signInput(c, e, n), r.push(!0);
|
|
3175
|
+
} catch {
|
|
3176
|
+
r.push(!1);
|
|
3177
|
+
}
|
|
3178
|
+
if (r.every((c) => !c))
|
|
3179
|
+
throw new Error("No inputs were signed");
|
|
3180
|
+
return this;
|
|
3181
|
+
}
|
|
3182
|
+
signAllInputsAsync(e, n) {
|
|
3183
|
+
return new Promise((r, c) => {
|
|
3184
|
+
if (!e || !e.publicKey)
|
|
3185
|
+
return c(new Error("Need Signer to sign input"));
|
|
3186
|
+
const s = [], o = [];
|
|
3187
|
+
for (const [i] of this.data.inputs.entries())
|
|
3188
|
+
o.push(
|
|
3189
|
+
this.signInputAsync(i, e, n).then(
|
|
3190
|
+
() => {
|
|
3191
|
+
s.push(!0);
|
|
3192
|
+
},
|
|
3193
|
+
() => {
|
|
3194
|
+
s.push(!1);
|
|
3195
|
+
}
|
|
3196
|
+
)
|
|
3197
|
+
);
|
|
3198
|
+
return Promise.all(o).then(() => {
|
|
3199
|
+
if (s.every((i) => !i))
|
|
3200
|
+
return c(new Error("No inputs were signed"));
|
|
3201
|
+
r();
|
|
3202
|
+
});
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
signInput(e, n, r) {
|
|
3206
|
+
if (!n || !n.publicKey)
|
|
3207
|
+
throw new Error("Need Signer to sign input");
|
|
3208
|
+
const c = x.checkForInput(this.data.inputs, e);
|
|
3209
|
+
return H(c) ? this._signTaprootInput(e, c, n, void 0, r) : this._signInput(e, n, r);
|
|
3210
|
+
}
|
|
3211
|
+
signTaprootInput(e, n, r, c) {
|
|
3212
|
+
if (!n || !n.publicKey)
|
|
3213
|
+
throw new Error("Need Signer to sign input");
|
|
3214
|
+
const s = x.checkForInput(this.data.inputs, e);
|
|
3215
|
+
if (H(s))
|
|
3216
|
+
return this._signTaprootInput(
|
|
3217
|
+
e,
|
|
3218
|
+
s,
|
|
3219
|
+
n,
|
|
3220
|
+
r,
|
|
3221
|
+
c
|
|
3222
|
+
);
|
|
3223
|
+
throw new Error(`Input #${e} is not of type Taproot.`);
|
|
3224
|
+
}
|
|
3225
|
+
signInputAsync(e, n, r) {
|
|
3226
|
+
return Promise.resolve().then(() => {
|
|
3227
|
+
if (!n || !n.publicKey) throw new Error("Need Signer to sign input");
|
|
3228
|
+
const c = x.checkForInput(this.data.inputs, e);
|
|
3229
|
+
return H(c) ? this._signTaprootInputAsync(
|
|
3230
|
+
e,
|
|
3231
|
+
c,
|
|
3232
|
+
n,
|
|
3233
|
+
void 0,
|
|
3234
|
+
r
|
|
3235
|
+
) : this._signInputAsync(e, n, r);
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
signTaprootInputAsync(e, n, r, c) {
|
|
3239
|
+
return Promise.resolve().then(() => {
|
|
3240
|
+
if (!n || !n.publicKey) throw new Error("Need Signer to sign input");
|
|
3241
|
+
const s = x.checkForInput(this.data.inputs, e);
|
|
3242
|
+
if (H(s))
|
|
3243
|
+
return this._signTaprootInputAsync(
|
|
3244
|
+
e,
|
|
3245
|
+
s,
|
|
3246
|
+
n,
|
|
3247
|
+
r,
|
|
3248
|
+
c
|
|
3249
|
+
);
|
|
3250
|
+
throw new Error(`Input #${e} is not of type Taproot.`);
|
|
3251
|
+
});
|
|
3252
|
+
}
|
|
3253
|
+
toBuffer() {
|
|
3254
|
+
return lt(this.__CACHE), this.data.toBuffer();
|
|
3255
|
+
}
|
|
3256
|
+
toHex() {
|
|
3257
|
+
return lt(this.__CACHE), this.data.toHex();
|
|
3258
|
+
}
|
|
3259
|
+
toBase64() {
|
|
3260
|
+
return lt(this.__CACHE), this.data.toBase64();
|
|
3261
|
+
}
|
|
3262
|
+
updateGlobal(e) {
|
|
3263
|
+
return this.data.updateGlobal(e), this;
|
|
3264
|
+
}
|
|
3265
|
+
updateInput(e, n) {
|
|
3266
|
+
return n.witnessScript && ze(n.witnessScript), Xt(this.data.inputs[e], n, "updateInput"), this.data.updateInput(e, n), n.nonWitnessUtxo && mt(this.__CACHE, this.data.inputs[e], e), this;
|
|
3267
|
+
}
|
|
3268
|
+
updateOutput(e, n) {
|
|
3269
|
+
const r = this.data.outputs[e];
|
|
3270
|
+
return qt(r, n, "updateOutput"), this.data.updateOutput(e, n), this;
|
|
3271
|
+
}
|
|
3272
|
+
addUnknownKeyValToGlobal(e) {
|
|
3273
|
+
return this.data.addUnknownKeyValToGlobal(e), this;
|
|
3274
|
+
}
|
|
3275
|
+
addUnknownKeyValToInput(e, n) {
|
|
3276
|
+
return this.data.addUnknownKeyValToInput(e, n), this;
|
|
3277
|
+
}
|
|
3278
|
+
addUnknownKeyValToOutput(e, n) {
|
|
3279
|
+
return this.data.addUnknownKeyValToOutput(e, n), this;
|
|
3280
|
+
}
|
|
3281
|
+
clearFinalizedInput(e) {
|
|
3282
|
+
return this.data.clearFinalizedInput(e), this;
|
|
3283
|
+
}
|
|
3284
|
+
checkTaprootHashesForSig(e, n, r, c, s) {
|
|
3285
|
+
if (typeof r.signSchnorr != "function")
|
|
3286
|
+
throw new Error(`Need Schnorr Signer to sign taproot input #${e}.`);
|
|
3287
|
+
const o = l.isBuffer(r.publicKey) ? r.publicKey : l.from(r.publicKey), i = _t(
|
|
3288
|
+
e,
|
|
3289
|
+
n,
|
|
3290
|
+
this.data.inputs,
|
|
3291
|
+
o,
|
|
3292
|
+
this.__CACHE,
|
|
3293
|
+
c,
|
|
3294
|
+
s
|
|
3295
|
+
);
|
|
3296
|
+
if (!i || !i.length)
|
|
3297
|
+
throw new Error(
|
|
3298
|
+
`Can not sign for input #${e} with the key ${o.toString("hex")}`
|
|
3299
|
+
);
|
|
3300
|
+
return i;
|
|
3301
|
+
}
|
|
3302
|
+
_finalizeInput(e, n, r = Bo, c = !0) {
|
|
3303
|
+
const { script: s, isP2SH: o, isP2WSH: i, isSegwit: a } = Lo(
|
|
3304
|
+
e,
|
|
3305
|
+
n,
|
|
3306
|
+
this.__CACHE
|
|
3307
|
+
);
|
|
3308
|
+
if (!s) throw new Error(`No script found for input #${e}`);
|
|
3309
|
+
No(n);
|
|
3310
|
+
const { finalScriptSig: u, finalScriptWitness: f } = r(
|
|
3311
|
+
e,
|
|
3312
|
+
n,
|
|
3313
|
+
s,
|
|
3314
|
+
a,
|
|
3315
|
+
o,
|
|
3316
|
+
i,
|
|
3317
|
+
c
|
|
3318
|
+
);
|
|
3319
|
+
if (u && this.data.updateInput(e, { finalScriptSig: u }), f && this.data.updateInput(e, { finalScriptWitness: f }), !u && !f)
|
|
3320
|
+
throw new Error(`Unknown error finalizing input #${e}`);
|
|
3321
|
+
return this.data.clearFinalizedInput(e), this;
|
|
3322
|
+
}
|
|
3323
|
+
_finalizeTaprootInput(e, n, r, c = Gt) {
|
|
3324
|
+
if (!n.witnessUtxo)
|
|
3325
|
+
throw new Error(`Cannot finalize input #${e}. Missing witness utxo.`);
|
|
3326
|
+
if (n.tapKeySig) {
|
|
3327
|
+
const s = Ie({
|
|
3328
|
+
output: n.witnessUtxo.script,
|
|
3329
|
+
signature: n.tapKeySig
|
|
3330
|
+
});
|
|
3331
|
+
if (!s.witness) throw new Error("Cannot finalize taproot key spend");
|
|
3332
|
+
const o = Ee(s.witness);
|
|
3333
|
+
this.data.updateInput(e, { finalScriptWitness: o });
|
|
3334
|
+
} else {
|
|
3335
|
+
const { finalScriptWitness: s } = c(
|
|
3336
|
+
e,
|
|
3337
|
+
n,
|
|
3338
|
+
r
|
|
3339
|
+
);
|
|
3340
|
+
this.data.updateInput(e, { finalScriptWitness: s });
|
|
3341
|
+
}
|
|
3342
|
+
return this.data.clearFinalizedInput(e), this;
|
|
3343
|
+
}
|
|
3344
|
+
_validateSignaturesOfInput(e, n, r) {
|
|
3345
|
+
const c = this.data.inputs[e], s = (c || {}).partialSig;
|
|
3346
|
+
if (!c || !s || s.length < 1)
|
|
3347
|
+
throw new Error("No signatures to validate");
|
|
3348
|
+
if (typeof n != "function")
|
|
3349
|
+
throw new Error("Need validator function to validate signatures");
|
|
3350
|
+
const o = r ? s.filter((p) => p.pubkey.equals(r)) : s;
|
|
3351
|
+
if (o.length < 1) throw new Error("No signatures for this pubkey");
|
|
3352
|
+
const i = [];
|
|
3353
|
+
let a, u, f;
|
|
3354
|
+
for (const p of o) {
|
|
3355
|
+
const g = Se.decode(p.signature), { hash: y, script: h } = f !== g.hashType || !a || !u ? Er(
|
|
3356
|
+
e,
|
|
3357
|
+
Object.assign({}, c, {
|
|
3358
|
+
sighashType: g.hashType
|
|
3359
|
+
}),
|
|
3360
|
+
this.__CACHE,
|
|
3361
|
+
!0
|
|
3362
|
+
) : { hash: a, script: u };
|
|
3363
|
+
f = g.hashType, a = y, u = h, Sr(p.pubkey, h, "verify"), i.push(n(p.pubkey, y, g.signature));
|
|
3364
|
+
}
|
|
3365
|
+
return i.every((p) => p);
|
|
3366
|
+
}
|
|
3367
|
+
validateSignaturesOfTaprootInput(e, n, r) {
|
|
3368
|
+
const c = this.data.inputs[e], s = (c || {}).tapKeySig, o = (c || {}).tapScriptSig;
|
|
3369
|
+
if (!c && !s && !(o && !o.length))
|
|
3370
|
+
throw new Error("No signatures to validate");
|
|
3371
|
+
if (typeof n != "function")
|
|
3372
|
+
throw new Error("Need validator function to validate signatures");
|
|
3373
|
+
r = r && we(r);
|
|
3374
|
+
const i = r ? _t(e, c, this.data.inputs, r, this.__CACHE) : Fo(e, c, this.data.inputs, this.__CACHE);
|
|
3375
|
+
if (!i.length) throw new Error("No signatures for this pubkey");
|
|
3376
|
+
const a = i.find((f) => !f.leafHash);
|
|
3377
|
+
let u = 0;
|
|
3378
|
+
if (s && a) {
|
|
3379
|
+
if (!n(
|
|
3380
|
+
a.pubkey,
|
|
3381
|
+
a.hash,
|
|
3382
|
+
Pn(s)
|
|
3383
|
+
)) return !1;
|
|
3384
|
+
u++;
|
|
3385
|
+
}
|
|
3386
|
+
if (o)
|
|
3387
|
+
for (const f of o) {
|
|
3388
|
+
const p = i.find((g) => f.pubkey.equals(g.pubkey));
|
|
3389
|
+
if (p) {
|
|
3390
|
+
if (!n(
|
|
3391
|
+
f.pubkey,
|
|
3392
|
+
p.hash,
|
|
3393
|
+
Pn(f.signature)
|
|
3394
|
+
)) return !1;
|
|
3395
|
+
u++;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
return u > 0;
|
|
3399
|
+
}
|
|
3400
|
+
_signInput(e, n, r = [I.SIGHASH_ALL]) {
|
|
3401
|
+
const c = l.isBuffer(n.publicKey) ? n.publicKey : l.from(n.publicKey), { hash: s, sighashType: o } = Cn(
|
|
3402
|
+
this.data.inputs,
|
|
3403
|
+
e,
|
|
3404
|
+
c,
|
|
3405
|
+
this.__CACHE,
|
|
3406
|
+
r
|
|
3407
|
+
), i = n.sign(s), a = [
|
|
3408
|
+
{
|
|
3409
|
+
pubkey: c,
|
|
3410
|
+
signature: Se.encode(
|
|
3411
|
+
l.isBuffer(i) ? i : l.from(i),
|
|
3412
|
+
o
|
|
3413
|
+
)
|
|
3414
|
+
}
|
|
3415
|
+
];
|
|
3416
|
+
return this.data.updateInput(e, { partialSig: a }), this;
|
|
3417
|
+
}
|
|
3418
|
+
_signTaprootInput(e, n, r, c, s = [I.SIGHASH_DEFAULT]) {
|
|
3419
|
+
const o = l.isBuffer(r.publicKey) ? r.publicKey : l.from(r.publicKey), i = this.checkTaprootHashesForSig(
|
|
3420
|
+
e,
|
|
3421
|
+
n,
|
|
3422
|
+
r,
|
|
3423
|
+
c,
|
|
3424
|
+
s
|
|
3425
|
+
), a = r.signSchnorr.bind(r), u = (g) => l.isBuffer(g) ? g : l.from(g), f = i.filter((g) => !g.leafHash).map(
|
|
3426
|
+
(g) => Pe(u(a(g.hash)), n.sighashType)
|
|
3427
|
+
)[0], p = i.filter((g) => !!g.leafHash).map(
|
|
3428
|
+
(g) => ({
|
|
3429
|
+
pubkey: we(o),
|
|
3430
|
+
signature: Pe(
|
|
3431
|
+
u(a(g.hash)),
|
|
3432
|
+
n.sighashType
|
|
3433
|
+
),
|
|
3434
|
+
leafHash: g.leafHash
|
|
3435
|
+
})
|
|
3436
|
+
);
|
|
3437
|
+
return f && this.data.updateInput(e, { tapKeySig: f }), p.length && this.data.updateInput(e, { tapScriptSig: p }), this;
|
|
3438
|
+
}
|
|
3439
|
+
_signInputAsync(e, n, r = [I.SIGHASH_ALL]) {
|
|
3440
|
+
const c = l.isBuffer(n.publicKey) ? n.publicKey : l.from(n.publicKey), { hash: s, sighashType: o } = Cn(
|
|
3441
|
+
this.data.inputs,
|
|
3442
|
+
e,
|
|
3443
|
+
c,
|
|
3444
|
+
this.__CACHE,
|
|
3445
|
+
r
|
|
3446
|
+
);
|
|
3447
|
+
return Promise.resolve(n.sign(s)).then((i) => {
|
|
3448
|
+
const a = l.isBuffer(i) ? i : l.from(i), u = [
|
|
3449
|
+
{
|
|
3450
|
+
pubkey: c,
|
|
3451
|
+
signature: Se.encode(a, o)
|
|
3452
|
+
}
|
|
3453
|
+
];
|
|
3454
|
+
this.data.updateInput(e, { partialSig: u });
|
|
3455
|
+
});
|
|
3456
|
+
}
|
|
3457
|
+
async _signTaprootInputAsync(e, n, r, c, s = [I.SIGHASH_DEFAULT]) {
|
|
3458
|
+
const o = l.isBuffer(r.publicKey) ? r.publicKey : l.from(r.publicKey), i = this.checkTaprootHashesForSig(
|
|
3459
|
+
e,
|
|
3460
|
+
n,
|
|
3461
|
+
r,
|
|
3462
|
+
c,
|
|
3463
|
+
s
|
|
3464
|
+
), a = r.signSchnorr.bind(r), u = (h) => l.isBuffer(h) ? h : l.from(h), f = [], p = i.filter((h) => !h.leafHash)[0];
|
|
3465
|
+
if (p) {
|
|
3466
|
+
const h = Promise.resolve(a(p.hash)).then((d) => ({
|
|
3467
|
+
tapKeySig: Pe(u(d), n.sighashType)
|
|
3468
|
+
}));
|
|
3469
|
+
f.push(h);
|
|
3470
|
+
}
|
|
3471
|
+
const g = i.filter((h) => !!h.leafHash);
|
|
3472
|
+
if (g.length) {
|
|
3473
|
+
const h = g.map(async (d) => {
|
|
3474
|
+
const w = await a(d.hash);
|
|
3475
|
+
return { tapScriptSig: [
|
|
3476
|
+
{
|
|
3477
|
+
pubkey: we(o),
|
|
3478
|
+
signature: Pe(
|
|
3479
|
+
u(w),
|
|
3480
|
+
n.sighashType
|
|
3481
|
+
),
|
|
3482
|
+
leafHash: d.leafHash
|
|
3483
|
+
}
|
|
3484
|
+
] };
|
|
3485
|
+
});
|
|
3486
|
+
f.push(...h);
|
|
3487
|
+
}
|
|
3488
|
+
const y = await Promise.all(f);
|
|
3489
|
+
for (const h of y)
|
|
3490
|
+
this.data.updateInput(e, h);
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
const Oo = (t) => new gr(t);
|
|
3494
|
+
class gr {
|
|
3495
|
+
constructor(e = l.from([2, 0, 0, 0, 0, 0, 0, 0, 0, 0])) {
|
|
3496
|
+
this.tx = I.fromBuffer(e), Ho(this.tx), Object.defineProperty(this, "tx", {
|
|
3497
|
+
enumerable: !1,
|
|
3498
|
+
writable: !0
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
getInputOutputCounts() {
|
|
3502
|
+
return {
|
|
3503
|
+
inputCount: this.tx.ins.length,
|
|
3504
|
+
outputCount: this.tx.outs.length
|
|
3505
|
+
};
|
|
3506
|
+
}
|
|
3507
|
+
addInput(e) {
|
|
3508
|
+
if (e.hash === void 0 || e.index === void 0 || !l.isBuffer(e.hash) && typeof e.hash != "string" || typeof e.index != "number")
|
|
3509
|
+
throw new Error("Error adding input.");
|
|
3510
|
+
const n = typeof e.hash == "string" ? Bn(l.from(e.hash, "hex")) : e.hash;
|
|
3511
|
+
this.tx.addInput(n, e.index, e.sequence);
|
|
3512
|
+
}
|
|
3513
|
+
addOutput(e) {
|
|
3514
|
+
if (e.script === void 0 || e.value === void 0 || !l.isBuffer(e.script) || typeof e.value != "number")
|
|
3515
|
+
throw new Error("Error adding output.");
|
|
3516
|
+
this.tx.addOutput(e.script, e.value);
|
|
3517
|
+
}
|
|
3518
|
+
toBuffer() {
|
|
3519
|
+
return this.tx.toBuffer();
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
function Co(t, e, n) {
|
|
3523
|
+
switch (n) {
|
|
3524
|
+
case "pubkey":
|
|
3525
|
+
case "pubkeyhash":
|
|
3526
|
+
case "witnesspubkeyhash":
|
|
3527
|
+
return In(1, t.partialSig);
|
|
3528
|
+
case "multisig": {
|
|
3529
|
+
const r = Ze({
|
|
3530
|
+
output: e
|
|
3531
|
+
});
|
|
3532
|
+
return In(r.m, t.partialSig, r.pubkeys);
|
|
3533
|
+
}
|
|
3534
|
+
case "nonstandard":
|
|
3535
|
+
return !0;
|
|
3536
|
+
default:
|
|
3537
|
+
return !1;
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
function lt(t) {
|
|
3541
|
+
if (t.__UNSAFE_SIGN_NONSEGWIT)
|
|
3542
|
+
throw new Error("Not BIP174 compliant, can not export");
|
|
3543
|
+
}
|
|
3544
|
+
function In(t, e, n) {
|
|
3545
|
+
if (!e) return !1;
|
|
3546
|
+
let r;
|
|
3547
|
+
if (n ? r = n.map((c) => {
|
|
3548
|
+
const s = Vo(c);
|
|
3549
|
+
return e.find((o) => o.pubkey.equals(s));
|
|
3550
|
+
}).filter((c) => !!c) : r = e, r.length > t) throw new Error("Too many signatures");
|
|
3551
|
+
return r.length === t;
|
|
3552
|
+
}
|
|
3553
|
+
function yr(t) {
|
|
3554
|
+
return !!t.finalScriptSig || !!t.finalScriptWitness;
|
|
3555
|
+
}
|
|
3556
|
+
function kn(t) {
|
|
3557
|
+
return (e) => {
|
|
3558
|
+
const n = l.isBuffer(t.fingerprint) ? t.fingerprint : l.from(t.fingerprint);
|
|
3559
|
+
if (!e.masterFingerprint.equals(n)) return !1;
|
|
3560
|
+
const r = t.derivePath(e.path).publicKey;
|
|
3561
|
+
return !!(l.isBuffer(r) ? r : l.from(r)).equals(e.pubkey);
|
|
3562
|
+
};
|
|
3563
|
+
}
|
|
3564
|
+
function Ge(t) {
|
|
3565
|
+
if (typeof t != "number" || t !== Math.floor(t) || t > 4294967295 || t < 0)
|
|
3566
|
+
throw new Error("Invalid 32 bit integer");
|
|
3567
|
+
}
|
|
3568
|
+
function Po(t, e, n) {
|
|
3569
|
+
const r = e.__FEE_RATE || t.getFeeRate(), c = e.__EXTRACTED_TX.virtualSize(), s = r * c;
|
|
3570
|
+
if (r >= n.maximumFeeRate)
|
|
3571
|
+
throw new Error(
|
|
3572
|
+
`Warning: You are paying around ${(s / 1e8).toFixed(8)} in fees, which is ${r} satoshi per byte for a transaction with a VSize of ${c} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`
|
|
3573
|
+
);
|
|
3574
|
+
}
|
|
3575
|
+
function ge(t, e) {
|
|
3576
|
+
t.forEach((n) => {
|
|
3577
|
+
if (H(n) ? Ls(n, e) : to(n, e)) throw new Error("Can not modify transaction, signatures exist.");
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
function No(t) {
|
|
3581
|
+
if (!t.sighashType || !t.partialSig) return;
|
|
3582
|
+
const { partialSig: e, sighashType: n } = t;
|
|
3583
|
+
e.forEach((r) => {
|
|
3584
|
+
const { hashType: c } = Se.decode(r.signature);
|
|
3585
|
+
if (n !== c)
|
|
3586
|
+
throw new Error("Signature sighash does not match input sighash type");
|
|
3587
|
+
});
|
|
3588
|
+
}
|
|
3589
|
+
function Sr(t, e, n) {
|
|
3590
|
+
if (!nt(t, e))
|
|
3591
|
+
throw new Error(`Can not ${n} for this input with the key ${t.toString("hex")}`);
|
|
3592
|
+
}
|
|
3593
|
+
function Ho(t) {
|
|
3594
|
+
if (!t.ins.every(
|
|
3595
|
+
(n) => n.script && n.script.length === 0 && n.witness && n.witness.length === 0
|
|
3596
|
+
))
|
|
3597
|
+
throw new Error("Format Error: Transaction ScriptSigs are not empty");
|
|
3598
|
+
}
|
|
3599
|
+
function Uo(t, e) {
|
|
3600
|
+
t.ins.forEach((n) => {
|
|
3601
|
+
br(e, n);
|
|
3602
|
+
});
|
|
3603
|
+
}
|
|
3604
|
+
function br(t, e) {
|
|
3605
|
+
const n = `${Bn(l.from(e.hash)).toString("hex")}:${e.index}`;
|
|
3606
|
+
if (t.__TX_IN_CACHE[n]) throw new Error("Duplicate input detected.");
|
|
3607
|
+
t.__TX_IN_CACHE[n] = 1;
|
|
3608
|
+
}
|
|
3609
|
+
function wr(t, e) {
|
|
3610
|
+
return (n, r, c, s) => {
|
|
3611
|
+
const o = t({
|
|
3612
|
+
redeem: { output: c }
|
|
3613
|
+
}).output;
|
|
3614
|
+
if (!r.equals(o))
|
|
3615
|
+
throw new Error(
|
|
3616
|
+
`${e} for ${s} #${n} doesn't match the scriptPubKey in the prevout`
|
|
3617
|
+
);
|
|
3618
|
+
};
|
|
3619
|
+
}
|
|
3620
|
+
const An = wr(me, "Redeem script"), xn = wr(ve, "Witness script");
|
|
3621
|
+
function On(t, e, n, r, c = !1) {
|
|
3622
|
+
if (!n.every(yr)) throw new Error(`PSBT must be finalized to calculate ${e}`);
|
|
3623
|
+
if (t === "__FEE_RATE" && r.__FEE_RATE) return r.__FEE_RATE;
|
|
3624
|
+
if (t === "__FEE" && r.__FEE) return r.__FEE;
|
|
3625
|
+
let s, o = !0;
|
|
3626
|
+
r.__EXTRACTED_TX ? (s = r.__EXTRACTED_TX, o = !1) : s = r.__TX.clone(), vr(n, s, r, o, c);
|
|
3627
|
+
const i = t === "__FEE_RATE" ? r.__FEE_RATE : r.__FEE;
|
|
3628
|
+
if (i === void 0) throw new Error(`Failed to calculate ${e}`);
|
|
3629
|
+
return i;
|
|
3630
|
+
}
|
|
3631
|
+
function Bo(t, e, n, r, c, s, o = !0, i) {
|
|
3632
|
+
const a = Ar(n);
|
|
3633
|
+
if (!Co(e, n, a) && o)
|
|
3634
|
+
throw new Error(`Can not finalize input #${t}`);
|
|
3635
|
+
return Ro(
|
|
3636
|
+
n,
|
|
3637
|
+
a,
|
|
3638
|
+
e.partialSig,
|
|
3639
|
+
r,
|
|
3640
|
+
c,
|
|
3641
|
+
s,
|
|
3642
|
+
i
|
|
3643
|
+
);
|
|
3644
|
+
}
|
|
3645
|
+
function Ro(t, e, n, r, c, s, o) {
|
|
3646
|
+
let i, a;
|
|
3647
|
+
const u = Ko(t, e, n), f = s ? ve({ redeem: u }) : null, p = c ? me({ redeem: f || u }) : null;
|
|
3648
|
+
return r ? (f ? a = Ee(f.witness) : u ? a = Ee(u.witness) : a = Ee(o ?? [l.from([0])]), p && (i = p?.input)) : p ? i = p?.input : u ? i = u.input : i = Array.isArray(o) && o[0] ? o[0] : l.from([1]), {
|
|
3649
|
+
finalScriptSig: i,
|
|
3650
|
+
finalScriptWitness: a
|
|
3651
|
+
};
|
|
3652
|
+
}
|
|
3653
|
+
function Cn(t, e, n, r, c) {
|
|
3654
|
+
const s = x.checkForInput(t, e), { hash: o, sighashType: i, script: a } = Er(
|
|
3655
|
+
e,
|
|
3656
|
+
s,
|
|
3657
|
+
r,
|
|
3658
|
+
!1,
|
|
3659
|
+
c
|
|
3660
|
+
);
|
|
3661
|
+
return Sr(n, a, "sign"), {
|
|
3662
|
+
hash: o,
|
|
3663
|
+
sighashType: i
|
|
3664
|
+
};
|
|
3665
|
+
}
|
|
3666
|
+
function Er(t, e, n, r, c) {
|
|
3667
|
+
const s = n.__TX, o = e.sighashType || I.SIGHASH_ALL;
|
|
3668
|
+
_r(o, c);
|
|
3669
|
+
let i, a;
|
|
3670
|
+
if (e.nonWitnessUtxo) {
|
|
3671
|
+
const p = rt(n, e, t), g = s.ins[t].hash, y = p.getHash();
|
|
3672
|
+
if (!g.equals(y))
|
|
3673
|
+
throw new Error(
|
|
3674
|
+
`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`
|
|
3675
|
+
);
|
|
3676
|
+
const h = s.ins[t].index;
|
|
3677
|
+
a = p.outs[h];
|
|
3678
|
+
} else if (e.witnessUtxo)
|
|
3679
|
+
a = e.witnessUtxo;
|
|
3680
|
+
else
|
|
3681
|
+
throw new Error("Need a Utxo input item for signing");
|
|
3682
|
+
const { meaningfulScript: u, type: f } = st(
|
|
3683
|
+
a.script,
|
|
3684
|
+
t,
|
|
3685
|
+
"input",
|
|
3686
|
+
e.redeemScript,
|
|
3687
|
+
e.witnessScript
|
|
3688
|
+
);
|
|
3689
|
+
if (["p2sh-p2wsh", "p2wsh"].indexOf(f) >= 0)
|
|
3690
|
+
i = s.hashForWitnessV0(
|
|
3691
|
+
t,
|
|
3692
|
+
u,
|
|
3693
|
+
a.value,
|
|
3694
|
+
o
|
|
3695
|
+
);
|
|
3696
|
+
else if (tt(u)) {
|
|
3697
|
+
const p = _e({
|
|
3698
|
+
hash: u.subarray(2)
|
|
3699
|
+
}).output;
|
|
3700
|
+
i = s.hashForWitnessV0(t, p, a.value, o);
|
|
3701
|
+
} else {
|
|
3702
|
+
if (e.nonWitnessUtxo === void 0 && !n.__UNSAFE_SIGN_NONSEGWIT)
|
|
3703
|
+
throw new Error(
|
|
3704
|
+
`Input #${t} has witnessUtxo but non-segwit script: ` + u.toString("hex")
|
|
3705
|
+
);
|
|
3706
|
+
!r && n.__UNSAFE_SIGN_NONSEGWIT && console.warn(
|
|
3707
|
+
`Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.
|
|
3708
|
+
*********************
|
|
3709
|
+
PROCEED WITH CAUTION!
|
|
3710
|
+
*********************`
|
|
3711
|
+
), i = s.hashForSignature(t, u, o);
|
|
3712
|
+
}
|
|
3713
|
+
return {
|
|
3714
|
+
script: u,
|
|
3715
|
+
sighashType: o,
|
|
3716
|
+
hash: i
|
|
3717
|
+
};
|
|
3718
|
+
}
|
|
3719
|
+
function Fo(t, e, n, r) {
|
|
3720
|
+
const c = [];
|
|
3721
|
+
if (e.tapInternalKey) {
|
|
3722
|
+
const o = Tr(t, e, r);
|
|
3723
|
+
o && c.push(o);
|
|
3724
|
+
}
|
|
3725
|
+
if (e.tapScriptSig) {
|
|
3726
|
+
const o = e.tapScriptSig.map((i) => i.pubkey);
|
|
3727
|
+
c.push(...o);
|
|
3728
|
+
}
|
|
3729
|
+
return c.map(
|
|
3730
|
+
(o) => _t(t, e, n, o, r)
|
|
3731
|
+
).flat();
|
|
3732
|
+
}
|
|
3733
|
+
function Tr(t, e, n) {
|
|
3734
|
+
const { script: r } = xt(t, e, n);
|
|
3735
|
+
return It(r) ? l.from(r.subarray(2, 34)) : null;
|
|
3736
|
+
}
|
|
3737
|
+
function Pn(t) {
|
|
3738
|
+
return t.length === 64 ? t : l.from(t.subarray(0, 64));
|
|
3739
|
+
}
|
|
3740
|
+
function _t(t, e, n, r, c, s, o) {
|
|
3741
|
+
const i = c.__TX, a = e.sighashType || I.SIGHASH_DEFAULT;
|
|
3742
|
+
_r(a, o);
|
|
3743
|
+
const u = n.map(
|
|
3744
|
+
(h, d) => xt(d, h, c)
|
|
3745
|
+
), f = u.map((h) => h.script), p = u.map((h) => h.value), g = [];
|
|
3746
|
+
if (e.tapInternalKey && !s) {
|
|
3747
|
+
const h = Tr(t, e, c) || l.from([]);
|
|
3748
|
+
if (we(r).equals(h)) {
|
|
3749
|
+
const d = i.hashForWitnessV1(
|
|
3750
|
+
t,
|
|
3751
|
+
f,
|
|
3752
|
+
p,
|
|
3753
|
+
a
|
|
3754
|
+
);
|
|
3755
|
+
g.push({ pubkey: r, hash: d });
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
const y = (e.tapLeafScript || []).filter((h) => nt(r, h.script)).map((h) => {
|
|
3759
|
+
const d = Ye({
|
|
3760
|
+
output: h.script,
|
|
3761
|
+
version: h.leafVersion
|
|
3762
|
+
});
|
|
3763
|
+
return Object.assign({ hash: d }, h);
|
|
3764
|
+
}).filter((h) => !s || s.equals(h.hash)).map((h) => {
|
|
3765
|
+
const d = i.hashForWitnessV1(
|
|
3766
|
+
t,
|
|
3767
|
+
f,
|
|
3768
|
+
p,
|
|
3769
|
+
a,
|
|
3770
|
+
h.hash
|
|
3771
|
+
);
|
|
3772
|
+
return {
|
|
3773
|
+
pubkey: r,
|
|
3774
|
+
hash: d,
|
|
3775
|
+
leafHash: h.hash
|
|
3776
|
+
};
|
|
3777
|
+
});
|
|
3778
|
+
return g.concat(y);
|
|
3779
|
+
}
|
|
3780
|
+
function _r(t, e) {
|
|
3781
|
+
if (e && e.indexOf(t) < 0) {
|
|
3782
|
+
const n = Wo(t);
|
|
3783
|
+
throw new Error(
|
|
3784
|
+
`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${n}`
|
|
3785
|
+
);
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
function Ko(t, e, n) {
|
|
3789
|
+
let r;
|
|
3790
|
+
switch (e) {
|
|
3791
|
+
case "multisig": {
|
|
3792
|
+
const c = Mo(t, n);
|
|
3793
|
+
r = Ze({
|
|
3794
|
+
output: t,
|
|
3795
|
+
signatures: c
|
|
3796
|
+
});
|
|
3797
|
+
break;
|
|
3798
|
+
}
|
|
3799
|
+
case "pubkey":
|
|
3800
|
+
r = Kn({
|
|
3801
|
+
output: t,
|
|
3802
|
+
signature: n[0].signature
|
|
3803
|
+
});
|
|
3804
|
+
break;
|
|
3805
|
+
case "pubkeyhash":
|
|
3806
|
+
r = _e({
|
|
3807
|
+
output: t,
|
|
3808
|
+
pubkey: n[0].pubkey,
|
|
3809
|
+
signature: n[0].signature
|
|
3810
|
+
});
|
|
3811
|
+
break;
|
|
3812
|
+
case "witnesspubkeyhash":
|
|
3813
|
+
r = $e({
|
|
3814
|
+
output: t,
|
|
3815
|
+
pubkey: n[0].pubkey,
|
|
3816
|
+
signature: n[0].signature
|
|
3817
|
+
});
|
|
3818
|
+
break;
|
|
3819
|
+
}
|
|
3820
|
+
return r;
|
|
3821
|
+
}
|
|
3822
|
+
function Lo(t, e, n) {
|
|
3823
|
+
const r = n.__TX, c = {
|
|
3824
|
+
script: null,
|
|
3825
|
+
isSegwit: !1,
|
|
3826
|
+
isP2SH: !1,
|
|
3827
|
+
isP2WSH: !1
|
|
3828
|
+
};
|
|
3829
|
+
if (c.isP2SH = !!e.redeemScript, c.isP2WSH = !!e.witnessScript, e.witnessScript)
|
|
3830
|
+
c.script = e.witnessScript;
|
|
3831
|
+
else if (e.redeemScript)
|
|
3832
|
+
c.script = e.redeemScript;
|
|
3833
|
+
else if (e.nonWitnessUtxo) {
|
|
3834
|
+
const s = rt(n, e, t), o = r.ins[t].index;
|
|
3835
|
+
c.script = s.outs[o].script;
|
|
3836
|
+
} else e.witnessUtxo && (c.script = e.witnessUtxo.script);
|
|
3837
|
+
if (e.witnessScript || tt(c.script))
|
|
3838
|
+
c.isSegwit = !0;
|
|
3839
|
+
else
|
|
3840
|
+
try {
|
|
3841
|
+
const s = c.script;
|
|
3842
|
+
if (!s) throw new TypeError("Invalid script for segwit address");
|
|
3843
|
+
c.isSegwit = Gn(s);
|
|
3844
|
+
} catch {
|
|
3845
|
+
}
|
|
3846
|
+
return c;
|
|
3847
|
+
}
|
|
3848
|
+
function Nn(t, e, n) {
|
|
3849
|
+
const r = x.checkForInput(e, t);
|
|
3850
|
+
if (!r.bip32Derivation || r.bip32Derivation.length === 0)
|
|
3851
|
+
throw new Error("Need bip32Derivation to sign with HD");
|
|
3852
|
+
const c = r.bip32Derivation.map((s) => {
|
|
3853
|
+
if (s.masterFingerprint.equals(n.fingerprint))
|
|
3854
|
+
return s;
|
|
3855
|
+
}).filter((s) => !!s);
|
|
3856
|
+
if (c.length === 0)
|
|
3857
|
+
throw new Error(
|
|
3858
|
+
"Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint"
|
|
3859
|
+
);
|
|
3860
|
+
return c.map((s) => {
|
|
3861
|
+
const o = n.derivePath(s.path);
|
|
3862
|
+
if (!s.pubkey.equals(o.publicKey))
|
|
3863
|
+
throw new Error("pubkey did not match bip32Derivation");
|
|
3864
|
+
return o;
|
|
3865
|
+
});
|
|
3866
|
+
}
|
|
3867
|
+
function Mo(t, e) {
|
|
3868
|
+
return Ze({ output: t }).pubkeys.map((r) => (e.filter((c) => c.pubkey.equals(r))[0] || {}).signature).filter((r) => !!r);
|
|
3869
|
+
}
|
|
3870
|
+
function mr(t) {
|
|
3871
|
+
let e = 0;
|
|
3872
|
+
function n(o) {
|
|
3873
|
+
return e += o, t.subarray(e - o, e);
|
|
3874
|
+
}
|
|
3875
|
+
function r() {
|
|
3876
|
+
const o = vn(t, e);
|
|
3877
|
+
return e += vn.bytes, o;
|
|
3878
|
+
}
|
|
3879
|
+
function c() {
|
|
3880
|
+
return n(r());
|
|
3881
|
+
}
|
|
3882
|
+
function s() {
|
|
3883
|
+
const o = r(), i = [];
|
|
3884
|
+
for (let a = 0; a < o; a++) i.push(c());
|
|
3885
|
+
return i;
|
|
3886
|
+
}
|
|
3887
|
+
return s();
|
|
3888
|
+
}
|
|
3889
|
+
function Wo(t) {
|
|
3890
|
+
let e = t & I.SIGHASH_ANYONECANPAY ? "SIGHASH_ANYONECANPAY | " : "";
|
|
3891
|
+
switch (t & 31) {
|
|
3892
|
+
case I.SIGHASH_ALL:
|
|
3893
|
+
e += "SIGHASH_ALL";
|
|
3894
|
+
break;
|
|
3895
|
+
case I.SIGHASH_SINGLE:
|
|
3896
|
+
e += "SIGHASH_SINGLE";
|
|
3897
|
+
break;
|
|
3898
|
+
case I.SIGHASH_NONE:
|
|
3899
|
+
e += "SIGHASH_NONE";
|
|
3900
|
+
break;
|
|
3901
|
+
}
|
|
3902
|
+
return e;
|
|
3903
|
+
}
|
|
3904
|
+
function mt(t, e, n) {
|
|
3905
|
+
t.__NON_WITNESS_UTXO_BUF_CACHE[n] = e.nonWitnessUtxo, t.__NON_WITNESS_UTXO_TX_CACHE[n] = I.fromBuffer(e.nonWitnessUtxo);
|
|
3906
|
+
const r = t, c = n;
|
|
3907
|
+
delete e.nonWitnessUtxo, Object.defineProperty(e, "nonWitnessUtxo", {
|
|
3908
|
+
enumerable: !0,
|
|
3909
|
+
get() {
|
|
3910
|
+
const s = r.__NON_WITNESS_UTXO_BUF_CACHE[c], o = r.__NON_WITNESS_UTXO_TX_CACHE[c];
|
|
3911
|
+
if (s !== void 0)
|
|
3912
|
+
return s;
|
|
3913
|
+
{
|
|
3914
|
+
const i = o.toBuffer();
|
|
3915
|
+
return r.__NON_WITNESS_UTXO_BUF_CACHE[c] = i, i;
|
|
3916
|
+
}
|
|
3917
|
+
},
|
|
3918
|
+
set(s) {
|
|
3919
|
+
r.__NON_WITNESS_UTXO_BUF_CACHE[c] = s;
|
|
3920
|
+
}
|
|
3921
|
+
});
|
|
3922
|
+
}
|
|
3923
|
+
function vr(t, e, n, r, c) {
|
|
3924
|
+
let s = 0;
|
|
3925
|
+
t.forEach((u, f) => {
|
|
3926
|
+
if (r && u.finalScriptSig && (e.ins[f].script = u.finalScriptSig), r && u.finalScriptWitness && (e.ins[f].witness = mr(u.finalScriptWitness)), u.witnessUtxo)
|
|
3927
|
+
s += u.witnessUtxo.value;
|
|
3928
|
+
else if (u.nonWitnessUtxo) {
|
|
3929
|
+
const p = rt(n, u, f), g = e.ins[f].index, y = p.outs[g];
|
|
3930
|
+
s += y.value;
|
|
3931
|
+
}
|
|
3932
|
+
});
|
|
3933
|
+
const o = e.outs.reduce((u, f) => u + f.value, 0), i = s - o;
|
|
3934
|
+
if (!c && i < 0)
|
|
3935
|
+
throw new Error(
|
|
3936
|
+
`Outputs are spending more than Inputs ${s} < ${o}`
|
|
3937
|
+
);
|
|
3938
|
+
const a = e.virtualSize();
|
|
3939
|
+
n.__FEE = i, n.__EXTRACTED_TX = e, n.__FEE_RATE = Math.floor(i / a);
|
|
3940
|
+
}
|
|
3941
|
+
function rt(t, e, n) {
|
|
3942
|
+
const r = t.__NON_WITNESS_UTXO_TX_CACHE;
|
|
3943
|
+
return r[n] || mt(t, e, n), r[n];
|
|
3944
|
+
}
|
|
3945
|
+
function Ir(t, e, n) {
|
|
3946
|
+
const { script: r } = xt(t, e, n);
|
|
3947
|
+
return r;
|
|
3948
|
+
}
|
|
3949
|
+
function xt(t, e, n) {
|
|
3950
|
+
if (e.witnessUtxo !== void 0)
|
|
3951
|
+
return {
|
|
3952
|
+
script: e.witnessUtxo.script,
|
|
3953
|
+
value: e.witnessUtxo.value
|
|
3954
|
+
};
|
|
3955
|
+
if (e.nonWitnessUtxo !== void 0) {
|
|
3956
|
+
const c = rt(n, e, t).outs[n.__TX.ins[t].index];
|
|
3957
|
+
return { script: c.script, value: c.value };
|
|
3958
|
+
} else
|
|
3959
|
+
throw new Error("Can't find pubkey in input without Utxo data");
|
|
3960
|
+
}
|
|
3961
|
+
function Go(t, e, n, r) {
|
|
3962
|
+
const c = Ir(n, e, r), { meaningfulScript: s } = st(
|
|
3963
|
+
c,
|
|
3964
|
+
n,
|
|
3965
|
+
"input",
|
|
3966
|
+
e.redeemScript,
|
|
3967
|
+
e.witnessScript
|
|
3968
|
+
);
|
|
3969
|
+
return nt(t, s);
|
|
3970
|
+
}
|
|
3971
|
+
function Xo(t, e, n, r) {
|
|
3972
|
+
const c = r.__TX.outs[n].script, { meaningfulScript: s } = st(
|
|
3973
|
+
c,
|
|
3974
|
+
n,
|
|
3975
|
+
"output",
|
|
3976
|
+
e.redeemScript,
|
|
3977
|
+
e.witnessScript
|
|
3978
|
+
);
|
|
3979
|
+
return nt(t, s);
|
|
3980
|
+
}
|
|
3981
|
+
function qo(t) {
|
|
3982
|
+
if (!t) return;
|
|
3983
|
+
const e = he(t);
|
|
3984
|
+
if (!e) return;
|
|
3985
|
+
const n = e[e.length - 1];
|
|
3986
|
+
if (!(!l.isBuffer(n) || kr(n) || jo(n) || !he(n)))
|
|
3987
|
+
return n;
|
|
3988
|
+
}
|
|
3989
|
+
function Do(t) {
|
|
3990
|
+
if (!t) return;
|
|
3991
|
+
const e = mr(t), n = e[e.length - 1];
|
|
3992
|
+
if (!(kr(n) || !he(n)))
|
|
3993
|
+
return n;
|
|
3994
|
+
}
|
|
3995
|
+
function Vo(t) {
|
|
3996
|
+
if (t.length === 65) {
|
|
3997
|
+
const e = t[64] & 1, n = l.from(t.subarray(0, 33));
|
|
3998
|
+
return n[0] = 2 | e, n;
|
|
3999
|
+
}
|
|
4000
|
+
return l.from(t);
|
|
4001
|
+
}
|
|
4002
|
+
function kr(t) {
|
|
4003
|
+
return t.length === 33 && Pr(t);
|
|
4004
|
+
}
|
|
4005
|
+
function jo(t) {
|
|
4006
|
+
return Hn(t);
|
|
4007
|
+
}
|
|
4008
|
+
function st(t, e, n, r, c) {
|
|
4009
|
+
const s = ur(t), o = s && r && Dt(r), i = Dt(t);
|
|
4010
|
+
if (s && r === void 0)
|
|
4011
|
+
throw new Error("scriptPubkey is P2SH but redeemScript missing");
|
|
4012
|
+
if ((i || o) && c === void 0)
|
|
4013
|
+
throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
|
|
4014
|
+
let a;
|
|
4015
|
+
return o ? (a = c, An(e, t, r, n), xn(e, r, c, n), ze(a)) : i ? (a = c, xn(e, t, c, n), ze(a)) : s ? (a = r, An(e, t, r, n)) : a = t, {
|
|
4016
|
+
meaningfulScript: a,
|
|
4017
|
+
type: o ? "p2sh-p2wsh" : s ? "p2sh" : i ? "p2wsh" : "raw"
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
function ze(t) {
|
|
4021
|
+
if (tt(t) || ur(t))
|
|
4022
|
+
throw new Error("P2WPKH or P2SH can not be contained within P2WSH");
|
|
4023
|
+
}
|
|
4024
|
+
function Ar(t) {
|
|
4025
|
+
return tt(t) ? "witnesspubkeyhash" : Qs(t) ? "pubkeyhash" : Zs(t) ? "multisig" : Js(t) ? "pubkey" : "nonstandard";
|
|
4026
|
+
}
|
|
4027
|
+
function ye(t) {
|
|
4028
|
+
return [...Array(t).keys()];
|
|
4029
|
+
}
|
|
4030
|
+
const oi = {
|
|
4031
|
+
networks: Qr,
|
|
4032
|
+
address: ws,
|
|
4033
|
+
payments: Wr,
|
|
4034
|
+
script: Nr,
|
|
4035
|
+
crypto: xr,
|
|
4036
|
+
Transaction: Gr
|
|
4037
|
+
};
|
|
4038
|
+
export {
|
|
4039
|
+
nt as $,
|
|
4040
|
+
Wn as A,
|
|
4041
|
+
De as B,
|
|
4042
|
+
Qe as C,
|
|
4043
|
+
et as D,
|
|
4044
|
+
Gn as E,
|
|
4045
|
+
ke as F,
|
|
4046
|
+
Xn as G,
|
|
4047
|
+
Dn as H,
|
|
4048
|
+
bs as I,
|
|
4049
|
+
jn as J,
|
|
4050
|
+
zn as K,
|
|
4051
|
+
$n as L,
|
|
4052
|
+
Zs as M,
|
|
4053
|
+
Js as N,
|
|
4054
|
+
Qs as O,
|
|
4055
|
+
Tt as P,
|
|
4056
|
+
tt as Q,
|
|
4057
|
+
Dt as R,
|
|
4058
|
+
ur as S,
|
|
4059
|
+
It as T,
|
|
4060
|
+
ri as U,
|
|
4061
|
+
si as V,
|
|
4062
|
+
Ee as W,
|
|
4063
|
+
Vt as X,
|
|
4064
|
+
Ne as Y,
|
|
4065
|
+
fr as Z,
|
|
4066
|
+
qn as _,
|
|
4067
|
+
eo as a,
|
|
4068
|
+
to as a0,
|
|
4069
|
+
pr as a1,
|
|
4070
|
+
ro as a2,
|
|
4071
|
+
Je as b,
|
|
4072
|
+
oi as c,
|
|
4073
|
+
M as d,
|
|
4074
|
+
ws as e,
|
|
4075
|
+
Vn as f,
|
|
4076
|
+
ei as g,
|
|
4077
|
+
Qo as h,
|
|
4078
|
+
Mn as i,
|
|
4079
|
+
Bo as j,
|
|
4080
|
+
Gt as k,
|
|
4081
|
+
H as l,
|
|
4082
|
+
at as m,
|
|
4083
|
+
Qr as n,
|
|
4084
|
+
Xt as o,
|
|
4085
|
+
Ro as p,
|
|
4086
|
+
qt as q,
|
|
4087
|
+
ti as r,
|
|
4088
|
+
Pe as s,
|
|
4089
|
+
we as t,
|
|
4090
|
+
ni as u,
|
|
4091
|
+
Ks as v,
|
|
4092
|
+
Ls as w,
|
|
4093
|
+
Gs as x,
|
|
4094
|
+
Ae as y,
|
|
4095
|
+
xe as z
|
|
4096
|
+
};
|