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