@btc-vision/bitcoin 7.0.0-beta.0 → 7.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -13
- package/benchmark-compare/BENCHMARK.md +74 -59
- package/benchmark-compare/compare.bench.ts +249 -96
- package/benchmark-compare/harness.ts +23 -25
- package/benchmark-compare/package.json +1 -0
- package/browser/address.d.ts +4 -4
- package/browser/address.d.ts.map +1 -1
- package/browser/chunks/{psbt-parallel-B-dfm5GZ.js → psbt-parallel-jZ6QcCnM.js} +3128 -2731
- package/browser/index.d.ts +1 -1
- package/browser/index.d.ts.map +1 -1
- package/browser/index.js +603 -585
- package/browser/io/base58check.d.ts +1 -25
- package/browser/io/base58check.d.ts.map +1 -1
- package/browser/io/base64.d.ts.map +1 -1
- package/browser/networks.d.ts +1 -0
- package/browser/networks.d.ts.map +1 -1
- package/browser/payments/bip341.d.ts +17 -0
- package/browser/payments/bip341.d.ts.map +1 -1
- package/browser/payments/index.d.ts +3 -2
- package/browser/payments/index.d.ts.map +1 -1
- package/browser/payments/p2mr.d.ts +169 -0
- package/browser/payments/p2mr.d.ts.map +1 -0
- package/browser/payments/types.d.ts +11 -1
- package/browser/payments/types.d.ts.map +1 -1
- package/browser/psbt/bip371.d.ts +30 -0
- package/browser/psbt/bip371.d.ts.map +1 -1
- package/browser/psbt/psbtutils.d.ts +1 -0
- package/browser/psbt/psbtutils.d.ts.map +1 -1
- package/browser/psbt.d.ts.map +1 -1
- package/browser/workers/index.js +9 -9
- package/build/address.d.ts +4 -4
- package/build/address.d.ts.map +1 -1
- package/build/address.js +11 -1
- package/build/address.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/io/base58check.d.ts +1 -25
- package/build/io/base58check.d.ts.map +1 -1
- package/build/io/base58check.js +1 -31
- package/build/io/base58check.js.map +1 -1
- package/build/io/base64.d.ts.map +1 -1
- package/build/io/base64.js +3 -0
- package/build/io/base64.js.map +1 -1
- package/build/networks.d.ts +1 -0
- package/build/networks.d.ts.map +1 -1
- package/build/networks.js +12 -0
- package/build/networks.js.map +1 -1
- package/build/payments/bip341.d.ts +17 -0
- package/build/payments/bip341.d.ts.map +1 -1
- package/build/payments/bip341.js +32 -1
- package/build/payments/bip341.js.map +1 -1
- package/build/payments/index.d.ts +3 -2
- package/build/payments/index.d.ts.map +1 -1
- package/build/payments/index.js +2 -1
- package/build/payments/index.js.map +1 -1
- package/build/payments/p2mr.d.ts +178 -0
- package/build/payments/p2mr.d.ts.map +1 -0
- package/build/payments/p2mr.js +555 -0
- package/build/payments/p2mr.js.map +1 -0
- package/build/payments/types.d.ts +11 -1
- package/build/payments/types.d.ts.map +1 -1
- package/build/payments/types.js +1 -0
- package/build/payments/types.js.map +1 -1
- package/build/psbt/bip371.d.ts +30 -0
- package/build/psbt/bip371.d.ts.map +1 -1
- package/build/psbt/bip371.js +80 -15
- package/build/psbt/bip371.js.map +1 -1
- package/build/psbt/psbtutils.d.ts +1 -0
- package/build/psbt/psbtutils.d.ts.map +1 -1
- package/build/psbt/psbtutils.js +2 -0
- package/build/psbt/psbtutils.js.map +1 -1
- package/build/psbt.d.ts.map +1 -1
- package/build/psbt.js +3 -2
- package/build/psbt.js.map +1 -1
- package/build/pubkey.js +1 -1
- package/build/pubkey.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/documentation/README.md +122 -0
- package/documentation/address.md +820 -0
- package/documentation/block.md +679 -0
- package/documentation/crypto.md +461 -0
- package/documentation/ecc.md +584 -0
- package/documentation/errors.md +656 -0
- package/documentation/io.md +942 -0
- package/documentation/networks.md +625 -0
- package/documentation/p2mr.md +380 -0
- package/documentation/payments.md +1485 -0
- package/documentation/psbt.md +1400 -0
- package/documentation/script.md +730 -0
- package/documentation/taproot.md +670 -0
- package/documentation/transaction.md +943 -0
- package/documentation/types.md +587 -0
- package/documentation/workers.md +1007 -0
- package/eslint.config.js +3 -0
- package/package.json +17 -14
- package/src/address.ts +22 -10
- package/src/index.ts +1 -0
- package/src/io/base58check.ts +1 -35
- package/src/io/base64.ts +5 -0
- package/src/networks.ts +13 -0
- package/src/payments/bip341.ts +36 -1
- package/src/payments/index.ts +4 -0
- package/src/payments/p2mr.ts +660 -0
- package/src/payments/types.ts +12 -0
- package/src/psbt/bip371.ts +84 -13
- package/src/psbt/psbtutils.ts +2 -0
- package/src/psbt.ts +4 -2
- package/src/pubkey.ts +1 -1
- package/test/bitcoin.core.spec.ts +1 -1
- package/test/fixtures/p2mr.json +270 -0
- package/test/integration/taproot.spec.ts +7 -3
- package/test/opnetTestnet.spec.ts +302 -0
- package/test/payments.spec.ts +3 -1
- package/test/psbt.spec.ts +297 -2
- package/test/tsconfig.json +2 -2
package/browser/index.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
1
|
+
import { d as Me, a as _, t as De, i as Ge, b as Ve, c as le, e as ze, o as M, f as G, p as dt, g as gt, h as fe, j as Ft, k as je, l as yt, m as zt, n as Bt, q as pe, r as de, s as ge, P as Ht, u as D, v as Xe, L as Ye, M as qe, w as Ze, x as Je, y as Qe, z as tn, A as en, B as nn, C as rn, D as sn, E as on, F as an, G as wt, H as ye, I as cn, J as un, K as hn, N as we, O as ln, Q as fn, R as pn, S as St, T as At, U as k, V, W as B, X as st, Y as dn, Z as It, _ as b, $ as Y, a0 as z, a1 as O, a2 as gn, a3 as yn, a4 as et, a5 as it, a6 as Et, a7 as Se, a8 as jt, a9 as wn, aa as Sn, ab as En, ac as mn, ad as bn, ae as Tn, af as nt, ag as rt, ah as Xt, ai as Yt, aj as qt, ak as Zt, al as An, am as Q, an as In, ao as kn, ap as vn, aq as xn } from "./chunks/psbt-parallel-jZ6QcCnM.js";
|
|
2
|
+
import { ar as ci, as as ui, at as hi, au as li, av as fi, aw as pi, ax as di, ay as gi, az as yi, aA as wi, aB as Si, aC as Ei, aD as mi, aE as bi, aF as Ti, aG as Ai, aH as Ii, aI as ki, aJ as vi, aK as xi, aL as _i, aM as Ui, aN as Pi, aO as Ni, aP as Hi, aQ as Oi, aR as Ri, aS as Ki, aT as Ci, aU as Fi, aV as Bi, aW as Wi, aX as $i, aY as Li, aZ as Mi, a_ as Di, a$ as Gi, b0 as Vi, b1 as zi, b2 as ji, b3 as Xi, b4 as Yi, b5 as qi, b6 as Zi, b7 as Ji, b8 as Qi, b9 as to, ba as eo, bb as no, bc as ro } from "./chunks/psbt-parallel-jZ6QcCnM.js";
|
|
3
|
+
function _n(e) {
|
|
4
|
+
if (e.startsWith("0x"))
|
|
5
|
+
throw new Error("Invalid base64 string: should not start with 0x");
|
|
4
6
|
const t = atob(e), n = new Uint8Array(t.length);
|
|
5
7
|
for (let r = 0; r < t.length; r++)
|
|
6
8
|
n[r] = t.charCodeAt(r);
|
|
7
9
|
return n;
|
|
8
10
|
}
|
|
9
|
-
function
|
|
11
|
+
function ei(e) {
|
|
10
12
|
let t = "";
|
|
11
13
|
for (let n = 0; n < e.length; n++)
|
|
12
14
|
t += String.fromCharCode(e[n]);
|
|
13
15
|
return btoa(t);
|
|
14
16
|
}
|
|
15
|
-
const q = 40, Z = 2, J = 15,
|
|
17
|
+
const q = 40, Z = 2, J = 15, Ee = 16, ot = 16, mt = 2, bt = 80, Un = "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.", me = (e) => {
|
|
16
18
|
try {
|
|
17
19
|
const t = e.subarray(2);
|
|
18
20
|
if (t.length < Z || t.length > q)
|
|
@@ -28,7 +30,7 @@ const q = 40, Z = 2, J = 15, we = 16, ot = 16, mt = 2, bt = 80, In = "WARNING: S
|
|
|
28
30
|
}
|
|
29
31
|
return !1;
|
|
30
32
|
};
|
|
31
|
-
function
|
|
33
|
+
function be(e, t) {
|
|
32
34
|
if (!(e instanceof Uint8Array)) throw new TypeError("output must be a Uint8Array");
|
|
33
35
|
if (!t.bech32Opnet) throw new Error("Network does not support opnet");
|
|
34
36
|
const n = e[0];
|
|
@@ -44,12 +46,12 @@ function Ee(e, t) {
|
|
|
44
46
|
if (a.length < Z || a.length > q)
|
|
45
47
|
throw new TypeError("Invalid program length for segwit address");
|
|
46
48
|
const u = n === M.OP_0 ? 0 : n !== void 0 && n >= M.OP_1 && n <= M.OP_16 ? n - (M.OP_1 - 1) : -1;
|
|
47
|
-
if (u < J || u >
|
|
49
|
+
if (u < J || u > Ee)
|
|
48
50
|
throw new TypeError(`Invalid segwit version ${u}`);
|
|
49
|
-
const l = [u, ...
|
|
50
|
-
return
|
|
51
|
+
const l = [u, ..._.bech32m.toWords(a)];
|
|
52
|
+
return _.bech32m.encode(t.bech32Opnet, l);
|
|
51
53
|
}
|
|
52
|
-
function
|
|
54
|
+
function Te(e, t) {
|
|
53
55
|
const n = e.subarray(2);
|
|
54
56
|
if (n.length < Z || n.length > q)
|
|
55
57
|
throw new TypeError("Invalid program length for segwit address");
|
|
@@ -62,24 +64,24 @@ function me(e, t) {
|
|
|
62
64
|
throw new TypeError(`Invalid script for segwit address ${e[1]} !== ${n.length}`);
|
|
63
65
|
return at(n, s, t.bech32, t.bech32Opnet);
|
|
64
66
|
}
|
|
65
|
-
function
|
|
66
|
-
const t = new Uint8Array(
|
|
67
|
+
function Ae(e) {
|
|
68
|
+
const t = new Uint8Array(Me(e));
|
|
67
69
|
if (t.length < 21) throw new TypeError(e + " is too short");
|
|
68
70
|
if (t.length > 21) throw new TypeError(e + " is too long");
|
|
69
71
|
const n = t[0], r = t.subarray(1);
|
|
70
72
|
return { version: n, hash: r };
|
|
71
73
|
}
|
|
72
74
|
function Ot(e, t) {
|
|
73
|
-
if (!
|
|
74
|
-
if (!
|
|
75
|
-
const n =
|
|
76
|
-
return n[0] = t, n.set(e, 1),
|
|
75
|
+
if (!Ge(e)) throw new TypeError("Expected 20 bytes hash");
|
|
76
|
+
if (!Ve(t)) throw new TypeError("Expected UInt8 version");
|
|
77
|
+
const n = le(21);
|
|
78
|
+
return n[0] = t, n.set(e, 1), ze(n);
|
|
77
79
|
}
|
|
78
80
|
function at(e, t, n, r) {
|
|
79
|
-
const s =
|
|
80
|
-
return s.unshift(t), t === ot && r ?
|
|
81
|
+
const s = _.bech32.toWords(e);
|
|
82
|
+
return s.unshift(t), t === ot && r ? _.bech32m.encode(r, s) : t === 0 ? _.bech32.encode(n, s) : _.bech32m.encode(n, s);
|
|
81
83
|
}
|
|
82
|
-
function
|
|
84
|
+
function Ie(e, t) {
|
|
83
85
|
t = t || G;
|
|
84
86
|
const n = e.length;
|
|
85
87
|
if (n === 25 && e[0] === 118 && e[1] === 169 && e[2] === 20 && e[23] === 136 && e[24] === 172)
|
|
@@ -91,25 +93,29 @@ function Te(e, t) {
|
|
|
91
93
|
if (n === 34 && e[0] === 0 && e[1] === 32)
|
|
92
94
|
return at(e.subarray(2, 34), 0, t.bech32);
|
|
93
95
|
if (n === 34 && e[0] === 81 && e[1] === 32) {
|
|
94
|
-
const r =
|
|
95
|
-
return r.unshift(1),
|
|
96
|
+
const r = _.bech32m.toWords(e.subarray(2, 34));
|
|
97
|
+
return r.unshift(1), _.bech32m.encode(t.bech32, r);
|
|
98
|
+
}
|
|
99
|
+
if (n === 34 && e[0] === 82 && e[1] === 32) {
|
|
100
|
+
const r = _.bech32m.toWords(e.subarray(2, 34));
|
|
101
|
+
return r.unshift(2), _.bech32m.encode(t.bech32, r);
|
|
96
102
|
}
|
|
97
103
|
try {
|
|
98
|
-
return
|
|
104
|
+
return be(e, t);
|
|
99
105
|
} catch {
|
|
100
106
|
}
|
|
101
107
|
try {
|
|
102
|
-
return
|
|
108
|
+
return Te(e, t);
|
|
103
109
|
} catch {
|
|
104
110
|
}
|
|
105
|
-
throw new Error(
|
|
111
|
+
throw new Error(De(e) + " has no matching Address");
|
|
106
112
|
}
|
|
107
|
-
function
|
|
113
|
+
function ke(e, t) {
|
|
108
114
|
let n, r;
|
|
109
115
|
t && "bech32" in t ? n = t : t && typeof t == "object" ? (n = t.network || G, r = t.onFutureSegwitWarning) : n = G;
|
|
110
116
|
let s, i;
|
|
111
117
|
try {
|
|
112
|
-
s =
|
|
118
|
+
s = Ae(e);
|
|
113
119
|
} catch {
|
|
114
120
|
}
|
|
115
121
|
if (s) {
|
|
@@ -119,7 +125,7 @@ function Ae(e, t) {
|
|
|
119
125
|
return gt({ hash: s.hash }).output;
|
|
120
126
|
} else {
|
|
121
127
|
try {
|
|
122
|
-
i =
|
|
128
|
+
i = fe(e);
|
|
123
129
|
} catch {
|
|
124
130
|
}
|
|
125
131
|
if (i) {
|
|
@@ -127,46 +133,50 @@ function Ae(e, t) {
|
|
|
127
133
|
throw new Error(e + " has an invalid prefix");
|
|
128
134
|
if (i.version === 0) {
|
|
129
135
|
if (i.data.length === 20)
|
|
130
|
-
return Ft({ hash:
|
|
136
|
+
return Ft({ hash: je(i.data) }).output;
|
|
131
137
|
if (i.data.length === 32)
|
|
132
|
-
return yt({ hash:
|
|
138
|
+
return yt({ hash: zt(i.data) }).output;
|
|
133
139
|
} else if (i.version === 1) {
|
|
134
140
|
if (i.data.length === 32)
|
|
135
141
|
return Bt({ pubkey: i.data }).output;
|
|
136
|
-
} else
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
} else {
|
|
143
|
+
if (i.version === 2 && i.data.length === 32)
|
|
144
|
+
return pe({ hash: zt(i.data) }).output;
|
|
145
|
+
if (i.version === ot) {
|
|
146
|
+
if (!n.bech32Opnet) throw new Error(e + " has an invalid prefix");
|
|
147
|
+
return de({
|
|
148
|
+
program: i.data,
|
|
149
|
+
network: n
|
|
150
|
+
}).output;
|
|
151
|
+
} else if (i.version >= mt && i.version <= J && i.data.length >= Z && i.data.length <= q)
|
|
152
|
+
return i.version !== ot && r && r(Un), ge([
|
|
153
|
+
i.version + bt,
|
|
154
|
+
i.data
|
|
155
|
+
]);
|
|
156
|
+
}
|
|
147
157
|
}
|
|
148
158
|
}
|
|
149
159
|
throw new TypeError(e + " has no matching Script");
|
|
150
160
|
}
|
|
151
|
-
const
|
|
161
|
+
const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
152
162
|
__proto__: null,
|
|
153
|
-
FUTURE_MAX_VERSION:
|
|
163
|
+
FUTURE_MAX_VERSION: Ee,
|
|
154
164
|
FUTURE_OPNET_VERSION: ot,
|
|
155
165
|
FUTURE_SEGWIT_MAX_SIZE: q,
|
|
156
166
|
FUTURE_SEGWIT_MAX_VERSION: J,
|
|
157
167
|
FUTURE_SEGWIT_MIN_SIZE: Z,
|
|
158
168
|
FUTURE_SEGWIT_MIN_VERSION: mt,
|
|
159
169
|
FUTURE_SEGWIT_VERSION_DIFF: bt,
|
|
160
|
-
_toFutureSegwitAddress:
|
|
161
|
-
fromBase58Check:
|
|
162
|
-
fromBech32:
|
|
163
|
-
fromOutputScript:
|
|
164
|
-
isUnknownSegwitVersion:
|
|
170
|
+
_toFutureSegwitAddress: Te,
|
|
171
|
+
fromBase58Check: Ae,
|
|
172
|
+
fromBech32: fe,
|
|
173
|
+
fromOutputScript: Ie,
|
|
174
|
+
isUnknownSegwitVersion: me,
|
|
165
175
|
toBase58Check: Ot,
|
|
166
176
|
toBech32: at,
|
|
167
|
-
toFutureOPNetAddress:
|
|
168
|
-
toOutputScript:
|
|
169
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
177
|
+
toFutureOPNetAddress: be,
|
|
178
|
+
toOutputScript: ke
|
|
179
|
+
}, Symbol.toStringTag, { value: "Module" })), Jt = M;
|
|
170
180
|
class j {
|
|
171
181
|
// Static public fields
|
|
172
182
|
static NAME = Ht.Embed;
|
|
@@ -281,23 +291,23 @@ class j {
|
|
|
281
291
|
if (this.#n)
|
|
282
292
|
return this.#n;
|
|
283
293
|
if (this.#s)
|
|
284
|
-
return
|
|
294
|
+
return ge([Jt.OP_RETURN].concat(this.#s));
|
|
285
295
|
}
|
|
286
296
|
#h() {
|
|
287
297
|
if (this.#n) {
|
|
288
298
|
const t = D(this.#n);
|
|
289
299
|
if (!t)
|
|
290
300
|
throw new TypeError("Output is invalid");
|
|
291
|
-
if (t[0] !==
|
|
301
|
+
if (t[0] !== Jt.OP_RETURN)
|
|
292
302
|
throw new TypeError("Output is invalid");
|
|
293
303
|
if (!t.slice(1).every((n) => n instanceof Uint8Array))
|
|
294
304
|
throw new TypeError("Output is invalid");
|
|
295
|
-
if (this.#s && !
|
|
305
|
+
if (this.#s && !Xe(this.#s, this.data))
|
|
296
306
|
throw new TypeError("Data mismatch");
|
|
297
307
|
}
|
|
298
308
|
}
|
|
299
309
|
}
|
|
300
|
-
function
|
|
310
|
+
function Nn(e, t) {
|
|
301
311
|
if (!e.data && !e.output)
|
|
302
312
|
throw new TypeError("Not enough data");
|
|
303
313
|
const n = new j(
|
|
@@ -310,81 +320,85 @@ function vn(e, t) {
|
|
|
310
320
|
);
|
|
311
321
|
return Object.assign(n.toPayment(), e);
|
|
312
322
|
}
|
|
313
|
-
const
|
|
323
|
+
const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
314
324
|
__proto__: null,
|
|
315
325
|
Embed: j,
|
|
316
|
-
LEAF_VERSION_TAPSCRIPT:
|
|
317
|
-
MAX_TAPTREE_DEPTH:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
+
LEAF_VERSION_TAPSCRIPT: Ye,
|
|
327
|
+
MAX_TAPTREE_DEPTH: qe,
|
|
328
|
+
P2MR: Ze,
|
|
329
|
+
P2MS: Je,
|
|
330
|
+
P2OP: Qe,
|
|
331
|
+
P2PK: tn,
|
|
332
|
+
P2PKH: en,
|
|
333
|
+
P2SH: nn,
|
|
334
|
+
P2TR: rn,
|
|
335
|
+
P2WPKH: sn,
|
|
336
|
+
P2WSH: on,
|
|
326
337
|
PaymentType: Ht,
|
|
327
|
-
findScriptPath:
|
|
328
|
-
p2data:
|
|
338
|
+
findScriptPath: an,
|
|
339
|
+
p2data: Nn,
|
|
340
|
+
p2mr: pe,
|
|
329
341
|
p2ms: wt,
|
|
330
|
-
p2op:
|
|
331
|
-
p2pk:
|
|
342
|
+
p2op: de,
|
|
343
|
+
p2pk: ye,
|
|
332
344
|
p2pkh: dt,
|
|
333
345
|
p2sh: gt,
|
|
334
346
|
p2tr: Bt,
|
|
335
347
|
p2wpkh: Ft,
|
|
336
348
|
p2wsh: yt,
|
|
337
|
-
rootHashFromPath:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
349
|
+
rootHashFromPath: cn,
|
|
350
|
+
rootHashFromPathP2MR: un,
|
|
351
|
+
tapBranchHash: hn,
|
|
352
|
+
tapleafHash: we,
|
|
353
|
+
toHashTree: ln,
|
|
354
|
+
tweakKey: fn
|
|
341
355
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
342
356
|
class v extends Error {
|
|
343
357
|
constructor(t) {
|
|
344
358
|
super(t), this.name = "BitcoinError", Error.captureStackTrace && Error.captureStackTrace(this, v);
|
|
345
359
|
}
|
|
346
360
|
}
|
|
347
|
-
class
|
|
361
|
+
class On extends v {
|
|
348
362
|
constructor(t) {
|
|
349
363
|
super(t), this.name = "ValidationError";
|
|
350
364
|
}
|
|
351
365
|
}
|
|
352
|
-
class
|
|
366
|
+
class Rn extends v {
|
|
353
367
|
constructor(t) {
|
|
354
368
|
super(t), this.name = "InvalidInputError";
|
|
355
369
|
}
|
|
356
370
|
}
|
|
357
|
-
class
|
|
371
|
+
class Kn extends v {
|
|
358
372
|
constructor(t) {
|
|
359
373
|
super(t), this.name = "InvalidOutputError";
|
|
360
374
|
}
|
|
361
375
|
}
|
|
362
|
-
class
|
|
376
|
+
class Cn extends v {
|
|
363
377
|
constructor(t) {
|
|
364
378
|
super(t), this.name = "ScriptError";
|
|
365
379
|
}
|
|
366
380
|
}
|
|
367
|
-
class
|
|
381
|
+
class Fn extends v {
|
|
368
382
|
constructor(t) {
|
|
369
383
|
super(t), this.name = "PsbtError";
|
|
370
384
|
}
|
|
371
385
|
}
|
|
372
|
-
class
|
|
386
|
+
class Bn extends v {
|
|
373
387
|
constructor(t) {
|
|
374
388
|
super(t), this.name = "EccError";
|
|
375
389
|
}
|
|
376
390
|
}
|
|
377
|
-
class
|
|
391
|
+
class Wn extends v {
|
|
378
392
|
constructor(t) {
|
|
379
393
|
super(t), this.name = "AddressError";
|
|
380
394
|
}
|
|
381
395
|
}
|
|
382
|
-
class
|
|
396
|
+
class $n extends v {
|
|
383
397
|
constructor(t) {
|
|
384
398
|
super(t), this.name = "SignatureError";
|
|
385
399
|
}
|
|
386
400
|
}
|
|
387
|
-
function
|
|
401
|
+
function Ln(e, t) {
|
|
388
402
|
if (!Array.isArray(e)) throw TypeError("Expected values Array");
|
|
389
403
|
if (typeof t != "function") throw TypeError("Expected digest Function");
|
|
390
404
|
let n = e.length;
|
|
@@ -399,7 +413,7 @@ function Cn(e, t) {
|
|
|
399
413
|
}
|
|
400
414
|
return r[0];
|
|
401
415
|
}
|
|
402
|
-
const kt = new TypeError("Cannot compute merkle root for zero transactions"), vt = new TypeError("Cannot compute witness commit for non-segwit block"),
|
|
416
|
+
const kt = new TypeError("Cannot compute merkle root for zero transactions"), vt = new TypeError("Cannot compute witness commit for non-segwit block"), Mn = St("6a24aa21a9ed");
|
|
403
417
|
class F {
|
|
404
418
|
/** Block version number */
|
|
405
419
|
version = 1;
|
|
@@ -425,7 +439,7 @@ class F {
|
|
|
425
439
|
*/
|
|
426
440
|
static fromBuffer(t) {
|
|
427
441
|
if (t.length < 80) throw new Error("Buffer too small (< 80 bytes)");
|
|
428
|
-
const n = new
|
|
442
|
+
const n = new pn(t), r = new F();
|
|
429
443
|
if (r.version = n.readInt32LE(), r.prevHash = n.readBytes(32), r.merkleRoot = n.readBytes(32), r.timestamp = n.readUInt32LE(), r.bits = n.readUInt32LE(), r.nonce = n.readUInt32LE(), t.length === 80) return r;
|
|
430
444
|
const s = () => {
|
|
431
445
|
const a = b.fromBuffer(n.data.subarray(n.offset), !0);
|
|
@@ -453,7 +467,7 @@ class F {
|
|
|
453
467
|
* @returns 32-byte target threshold
|
|
454
468
|
*/
|
|
455
469
|
static calculateTarget(t) {
|
|
456
|
-
const n = ((t & 4278190080) >> 24) - 3, r = t & 8388607, s =
|
|
470
|
+
const n = ((t & 4278190080) >> 24) - 3, r = t & 8388607, s = le(32), i = 29 - n;
|
|
457
471
|
return s[i] = r >> 16 & 255, s[i + 1] = r >> 8 & 255, s[i + 2] = r & 255, s;
|
|
458
472
|
}
|
|
459
473
|
/**
|
|
@@ -467,8 +481,8 @@ class F {
|
|
|
467
481
|
if (!Array.isArray(t))
|
|
468
482
|
throw new TypeError("Expected an array of transactions");
|
|
469
483
|
if (t.length === 0) throw kt;
|
|
470
|
-
if (n && !
|
|
471
|
-
const r = t.map((i) => i.getHash(n)), s =
|
|
484
|
+
if (n && !Qt(t)) throw vt;
|
|
485
|
+
const r = t.map((i) => i.getHash(n)), s = Ln(r, At);
|
|
472
486
|
if (n) {
|
|
473
487
|
const a = t[0]?.ins[0]?.witness[0];
|
|
474
488
|
if (!a) throw new TypeError("Missing witness in coinbase");
|
|
@@ -482,11 +496,11 @@ class F {
|
|
|
482
496
|
* @returns 32-byte witness commitment or null if not found
|
|
483
497
|
*/
|
|
484
498
|
getWitnessCommit() {
|
|
485
|
-
if (!this.transactions || !
|
|
499
|
+
if (!this.transactions || !Qt(this.transactions)) return null;
|
|
486
500
|
const t = this.transactions[0];
|
|
487
501
|
if (!t) return null;
|
|
488
502
|
const n = t.outs.filter(
|
|
489
|
-
(s) => k(s.script.subarray(0, 6),
|
|
503
|
+
(s) => k(s.script.subarray(0, 6), Mn)
|
|
490
504
|
).map((s) => s.script.subarray(6, 38));
|
|
491
505
|
if (n.length === 0) return null;
|
|
492
506
|
const r = n[n.length - 1];
|
|
@@ -504,7 +518,7 @@ class F {
|
|
|
504
518
|
* @returns True if any transaction has witness data
|
|
505
519
|
*/
|
|
506
520
|
hasWitness() {
|
|
507
|
-
return this.transactions ?
|
|
521
|
+
return this.transactions ? Dn(this.transactions) : !1;
|
|
508
522
|
}
|
|
509
523
|
/**
|
|
510
524
|
* Calculates the weight of this block.
|
|
@@ -554,7 +568,7 @@ class F {
|
|
|
554
568
|
toBuffer(t) {
|
|
555
569
|
if (!this.prevHash) throw new TypeError("Block prevHash is required");
|
|
556
570
|
if (!this.merkleRoot) throw new TypeError("Block merkleRoot is required");
|
|
557
|
-
const n = new Uint8Array(this.byteLength(t)), r = new
|
|
571
|
+
const n = new Uint8Array(this.byteLength(t)), r = new dn(n);
|
|
558
572
|
return r.writeInt32LE(this.version), r.writeBytes(this.prevHash), r.writeBytes(this.merkleRoot), r.writeUInt32LE(this.timestamp), r.writeUInt32LE(this.bits), r.writeUInt32LE(this.nonce), t || !this.transactions || (r.writeVarInt(this.transactions.length), this.transactions.forEach((s) => {
|
|
559
573
|
const i = s.byteLength();
|
|
560
574
|
s.toBuffer(n.subarray(r.offset)), r.offset += i;
|
|
@@ -597,19 +611,19 @@ class F {
|
|
|
597
611
|
return It(this.witnessCommit, t) === 0;
|
|
598
612
|
}
|
|
599
613
|
}
|
|
600
|
-
function
|
|
614
|
+
function Qt(e) {
|
|
601
615
|
const t = e[0];
|
|
602
616
|
return t?.ins?.[0]?.witness ? t.ins[0].witness.length > 0 : !1;
|
|
603
617
|
}
|
|
604
|
-
function
|
|
618
|
+
function Dn(e) {
|
|
605
619
|
return e.some(
|
|
606
620
|
(t) => t.ins?.some((n) => n.witness && n.witness.length > 0)
|
|
607
621
|
);
|
|
608
622
|
}
|
|
609
|
-
var
|
|
623
|
+
var U;
|
|
610
624
|
(function(e) {
|
|
611
625
|
e[e.UNSIGNED_TX = 0] = "UNSIGNED_TX", e[e.GLOBAL_XPUB = 1] = "GLOBAL_XPUB";
|
|
612
|
-
})(
|
|
626
|
+
})(U || (U = {}));
|
|
613
627
|
var p;
|
|
614
628
|
(function(e) {
|
|
615
629
|
e[e.NON_WITNESS_UTXO = 0] = "NON_WITNESS_UTXO", e[e.WITNESS_UTXO = 1] = "WITNESS_UTXO", e[e.PARTIAL_SIG = 2] = "PARTIAL_SIG", e[e.SIGHASH_TYPE = 3] = "SIGHASH_TYPE", e[e.REDEEM_SCRIPT = 4] = "REDEEM_SCRIPT", e[e.WITNESS_SCRIPT = 5] = "WITNESS_SCRIPT", e[e.BIP32_DERIVATION = 6] = "BIP32_DERIVATION", e[e.FINAL_SCRIPTSIG = 7] = "FINAL_SCRIPTSIG", e[e.FINAL_SCRIPTWITNESS = 8] = "FINAL_SCRIPTWITNESS", e[e.POR_COMMITMENT = 9] = "POR_COMMITMENT", e[e.TAP_KEY_SIG = 19] = "TAP_KEY_SIG", e[e.TAP_SCRIPT_SIG = 20] = "TAP_SCRIPT_SIG", e[e.TAP_LEAF_SCRIPT = 21] = "TAP_LEAF_SCRIPT", e[e.TAP_BIP32_DERIVATION = 22] = "TAP_BIP32_DERIVATION", e[e.TAP_INTERNAL_KEY = 23] = "TAP_INTERNAL_KEY", e[e.TAP_MERKLE_ROOT = 24] = "TAP_MERKLE_ROOT";
|
|
@@ -621,14 +635,14 @@ var E;
|
|
|
621
635
|
const ct = "0123456789abcdefABCDEF", ut = ct.split("").map((e) => e.codePointAt(0)), ht = Array(256).fill(!0).map((e, t) => {
|
|
622
636
|
const n = String.fromCodePoint(t), r = ct.indexOf(n);
|
|
623
637
|
return r < 0 ? void 0 : r < 16 ? r : r - 6;
|
|
624
|
-
}),
|
|
625
|
-
function
|
|
626
|
-
return
|
|
638
|
+
}), ve = new TextEncoder(), xe = new TextDecoder();
|
|
639
|
+
function Gn(e) {
|
|
640
|
+
return xe.decode(e);
|
|
627
641
|
}
|
|
628
|
-
function
|
|
629
|
-
return
|
|
642
|
+
function Vn(e) {
|
|
643
|
+
return ve.encode(e);
|
|
630
644
|
}
|
|
631
|
-
function
|
|
645
|
+
function P(e) {
|
|
632
646
|
const t = e.reduce((s, i) => s + i.length, 0), n = new Uint8Array(t);
|
|
633
647
|
let r = 0;
|
|
634
648
|
for (const s of e)
|
|
@@ -637,22 +651,22 @@ function U(e) {
|
|
|
637
651
|
}
|
|
638
652
|
function d(e) {
|
|
639
653
|
const t = e || new Uint8Array();
|
|
640
|
-
return t.length > 512 ?
|
|
654
|
+
return t.length > 512 ? jn(t) : zn(t);
|
|
641
655
|
}
|
|
642
|
-
function
|
|
656
|
+
function zn(e) {
|
|
643
657
|
let t = "";
|
|
644
658
|
for (let n = 0; n < e.length; ++n)
|
|
645
659
|
t += ct[ht[ut[e[n] >> 4]]], t += ct[ht[ut[e[n] & 15]]];
|
|
646
660
|
return t;
|
|
647
661
|
}
|
|
648
|
-
function
|
|
662
|
+
function jn(e) {
|
|
649
663
|
const t = new Uint8Array(e.length * 2);
|
|
650
664
|
for (let n = 0; n < e.length; ++n)
|
|
651
665
|
t[n * 2] = ut[e[n] >> 4], t[n * 2 + 1] = ut[e[n] & 15];
|
|
652
|
-
return
|
|
666
|
+
return xe.decode(t);
|
|
653
667
|
}
|
|
654
|
-
function
|
|
655
|
-
const t =
|
|
668
|
+
function Xn(e) {
|
|
669
|
+
const t = ve.encode(e || ""), n = new Uint8Array(Math.floor(t.length / 2));
|
|
656
670
|
let r;
|
|
657
671
|
for (r = 0; r < n.length; r++) {
|
|
658
672
|
const s = ht[t[r * 2]], i = ht[t[r * 2 + 1]];
|
|
@@ -662,16 +676,16 @@ function Dn(e) {
|
|
|
662
676
|
}
|
|
663
677
|
return r === n.length ? n : n.slice(0, r);
|
|
664
678
|
}
|
|
665
|
-
function
|
|
679
|
+
function Yn(e) {
|
|
666
680
|
return btoa(String.fromCharCode(...e));
|
|
667
681
|
}
|
|
668
|
-
function
|
|
682
|
+
function qn(e) {
|
|
669
683
|
const t = atob(e), n = new Uint8Array(t.length);
|
|
670
684
|
for (let r = 0; r < t.length; r++)
|
|
671
685
|
n[r] = t.charCodeAt(r);
|
|
672
686
|
return n;
|
|
673
687
|
}
|
|
674
|
-
function
|
|
688
|
+
function N(e, t) {
|
|
675
689
|
const n = Math.min(e.length, t.length);
|
|
676
690
|
for (let r = 0; r < n; ++r)
|
|
677
691
|
if (e[r] !== t[r])
|
|
@@ -685,7 +699,7 @@ function Wt(e, t, n, r) {
|
|
|
685
699
|
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${n}`);
|
|
686
700
|
return r === "LE" ? (e[t] = n & 255, e[t + 1] = n >> 8 & 255, e[t + 2] = n >> 16 & 255, e[t + 3] = n >> 24 & 255) : (e[t] = n >> 24 & 255, e[t + 1] = n >> 16 & 255, e[t + 2] = n >> 8 & 255, e[t + 3] = n & 255), t + 4;
|
|
687
701
|
}
|
|
688
|
-
function
|
|
702
|
+
function te(e, t) {
|
|
689
703
|
if (t + 1 > e.length)
|
|
690
704
|
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
691
705
|
return e[t];
|
|
@@ -701,14 +715,14 @@ function Tt(e, t, n) {
|
|
|
701
715
|
return r = (r << 8) + e[t] >>> 0, r = (r << 8) + e[t + 1] >>> 0, r = (r << 8) + e[t + 2] >>> 0, r = (r << 8) + e[t + 3] >>> 0, r;
|
|
702
716
|
}
|
|
703
717
|
}
|
|
704
|
-
function
|
|
718
|
+
function Zn(e, t, n, r) {
|
|
705
719
|
if (t + 8 > e.length)
|
|
706
720
|
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
707
721
|
if (n > 0x7fffffffffffffffn || n < -0x8000000000000000n)
|
|
708
722
|
throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${n}`);
|
|
709
723
|
return r = r.toUpperCase(), r === "LE" ? (e[t] = Number(n & 0xffn), e[t + 1] = Number(n >> 8n & 0xffn), e[t + 2] = Number(n >> 16n & 0xffn), e[t + 3] = Number(n >> 24n & 0xffn), e[t + 4] = Number(n >> 32n & 0xffn), e[t + 5] = Number(n >> 40n & 0xffn), e[t + 6] = Number(n >> 48n & 0xffn), e[t + 7] = Number(n >> 56n & 0xffn)) : (e[t] = Number(n >> 56n & 0xffn), e[t + 1] = Number(n >> 48n & 0xffn), e[t + 2] = Number(n >> 40n & 0xffn), e[t + 3] = Number(n >> 32n & 0xffn), e[t + 4] = Number(n >> 24n & 0xffn), e[t + 5] = Number(n >> 16n & 0xffn), e[t + 6] = Number(n >> 8n & 0xffn), e[t + 7] = Number(n & 0xffn)), t + 8;
|
|
710
724
|
}
|
|
711
|
-
function
|
|
725
|
+
function Jn(e, t, n) {
|
|
712
726
|
if (t + 8 > e.length)
|
|
713
727
|
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
714
728
|
n = n.toUpperCase();
|
|
@@ -720,9 +734,9 @@ function jn(e, t, n) {
|
|
|
720
734
|
return s = (s << 8n) + BigInt(e[t]), s = (s << 8n) + BigInt(e[t + 1]), s = (s << 8n) + BigInt(e[t + 2]), s = (s << 8n) + BigInt(e[t + 3]), s = (s << 8n) + BigInt(e[t + 4]), s = (s << 8n) + BigInt(e[t + 5]), s = (s << 8n) + BigInt(e[t + 6]), s = (s << 8n) + BigInt(e[t + 7]), e[t] <= 127 ? s : s - 0x10000000000000000n;
|
|
721
735
|
}
|
|
722
736
|
}
|
|
723
|
-
const
|
|
724
|
-
function
|
|
725
|
-
if (e.key[0] !==
|
|
737
|
+
const Qn = (e) => [...Array(e).keys()];
|
|
738
|
+
function tr(e) {
|
|
739
|
+
if (e.key[0] !== U.GLOBAL_XPUB)
|
|
726
740
|
throw new Error(
|
|
727
741
|
"Decode Error: could not decode globalXpub with key 0x" + d(e.key)
|
|
728
742
|
);
|
|
@@ -739,14 +753,14 @@ function Yn(e) {
|
|
|
739
753
|
extendedPubkey: t,
|
|
740
754
|
path: "m"
|
|
741
755
|
};
|
|
742
|
-
for (const r of
|
|
756
|
+
for (const r of Qn(e.value.length / 4 - 1)) {
|
|
743
757
|
const s = Tt(e.value, r * 4 + 4, "LE"), i = !!(s & 2147483648), o = s & 2147483647;
|
|
744
758
|
n.path += "/" + o.toString(10) + (i ? "'" : "");
|
|
745
759
|
}
|
|
746
760
|
return n;
|
|
747
761
|
}
|
|
748
|
-
function
|
|
749
|
-
const t = new Uint8Array([
|
|
762
|
+
function er(e) {
|
|
763
|
+
const t = new Uint8Array([U.GLOBAL_XPUB]), n = P([t, e.extendedPubkey]), r = e.path.split("/"), s = new Uint8Array(r.length * 4);
|
|
750
764
|
s.set(e.masterFingerprint, 0);
|
|
751
765
|
let i = 4;
|
|
752
766
|
return r.slice(1).forEach((o) => {
|
|
@@ -758,118 +772,118 @@ function qn(e) {
|
|
|
758
772
|
value: s
|
|
759
773
|
};
|
|
760
774
|
}
|
|
761
|
-
const
|
|
762
|
-
function
|
|
775
|
+
const nr = "{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";
|
|
776
|
+
function rr(e) {
|
|
763
777
|
const t = e.extendedPubkey, n = e.masterFingerprint, r = e.path;
|
|
764
778
|
return t instanceof Uint8Array && t.length === 78 && [2, 3].indexOf(t[45]) > -1 && n instanceof Uint8Array && n.length === 4 && typeof r == "string" && !!r.match(/^m(\/\d+'?)*$/);
|
|
765
779
|
}
|
|
766
|
-
function
|
|
780
|
+
function sr(e, t, n) {
|
|
767
781
|
const r = d(t.extendedPubkey);
|
|
768
|
-
return n.has(r) ? !1 : (n.add(r), e.filter((s) =>
|
|
782
|
+
return n.has(r) ? !1 : (n.add(r), e.filter((s) => N(s.extendedPubkey, t.extendedPubkey)).length === 0);
|
|
769
783
|
}
|
|
770
|
-
const
|
|
784
|
+
const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
771
785
|
__proto__: null,
|
|
772
|
-
canAddToArray:
|
|
773
|
-
check:
|
|
774
|
-
decode:
|
|
775
|
-
encode:
|
|
776
|
-
expected:
|
|
786
|
+
canAddToArray: sr,
|
|
787
|
+
check: rr,
|
|
788
|
+
decode: tr,
|
|
789
|
+
encode: er,
|
|
790
|
+
expected: nr
|
|
777
791
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
778
|
-
function
|
|
792
|
+
function or(e) {
|
|
779
793
|
return {
|
|
780
|
-
key: new Uint8Array([
|
|
794
|
+
key: new Uint8Array([U.UNSIGNED_TX]),
|
|
781
795
|
value: e.toBuffer()
|
|
782
796
|
};
|
|
783
797
|
}
|
|
784
|
-
const
|
|
798
|
+
const ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
785
799
|
__proto__: null,
|
|
786
|
-
encode:
|
|
800
|
+
encode: or
|
|
787
801
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
788
|
-
function
|
|
802
|
+
function cr(e) {
|
|
789
803
|
if (e.key[0] !== p.FINAL_SCRIPTSIG)
|
|
790
804
|
throw new Error(
|
|
791
805
|
"Decode Error: could not decode finalScriptSig with key 0x" + d(e.key)
|
|
792
806
|
);
|
|
793
807
|
return e.value;
|
|
794
808
|
}
|
|
795
|
-
function
|
|
809
|
+
function ur(e) {
|
|
796
810
|
return {
|
|
797
811
|
key: new Uint8Array([p.FINAL_SCRIPTSIG]),
|
|
798
812
|
value: e
|
|
799
813
|
};
|
|
800
814
|
}
|
|
801
|
-
const
|
|
802
|
-
function
|
|
815
|
+
const hr = "Uint8Array";
|
|
816
|
+
function lr(e) {
|
|
803
817
|
return e instanceof Uint8Array;
|
|
804
818
|
}
|
|
805
|
-
function
|
|
819
|
+
function fr(e, t) {
|
|
806
820
|
return !!e && !!t && e.finalScriptSig === void 0;
|
|
807
821
|
}
|
|
808
|
-
const
|
|
822
|
+
const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
809
823
|
__proto__: null,
|
|
810
|
-
canAdd:
|
|
811
|
-
check:
|
|
812
|
-
decode:
|
|
813
|
-
encode:
|
|
814
|
-
expected:
|
|
824
|
+
canAdd: fr,
|
|
825
|
+
check: lr,
|
|
826
|
+
decode: cr,
|
|
827
|
+
encode: ur,
|
|
828
|
+
expected: hr
|
|
815
829
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
816
|
-
function
|
|
830
|
+
function dr(e) {
|
|
817
831
|
if (e.key[0] !== p.FINAL_SCRIPTWITNESS)
|
|
818
832
|
throw new Error(
|
|
819
833
|
"Decode Error: could not decode finalScriptWitness with key 0x" + d(e.key)
|
|
820
834
|
);
|
|
821
835
|
return e.value;
|
|
822
836
|
}
|
|
823
|
-
function
|
|
837
|
+
function gr(e) {
|
|
824
838
|
return {
|
|
825
839
|
key: new Uint8Array([p.FINAL_SCRIPTWITNESS]),
|
|
826
840
|
value: e
|
|
827
841
|
};
|
|
828
842
|
}
|
|
829
|
-
const
|
|
830
|
-
function
|
|
843
|
+
const yr = "Uint8Array";
|
|
844
|
+
function wr(e) {
|
|
831
845
|
return e instanceof Uint8Array;
|
|
832
846
|
}
|
|
833
|
-
function
|
|
847
|
+
function Sr(e, t) {
|
|
834
848
|
return !!e && !!t && e.finalScriptWitness === void 0;
|
|
835
849
|
}
|
|
836
|
-
const
|
|
850
|
+
const Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
837
851
|
__proto__: null,
|
|
838
|
-
canAdd:
|
|
839
|
-
check:
|
|
840
|
-
decode:
|
|
841
|
-
encode:
|
|
842
|
-
expected:
|
|
852
|
+
canAdd: Sr,
|
|
853
|
+
check: wr,
|
|
854
|
+
decode: dr,
|
|
855
|
+
encode: gr,
|
|
856
|
+
expected: yr
|
|
843
857
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
844
|
-
function
|
|
858
|
+
function mr(e) {
|
|
845
859
|
if (e.key[0] !== p.NON_WITNESS_UTXO)
|
|
846
860
|
throw new Error(
|
|
847
861
|
"Decode Error: could not decode nonWitnessUtxo with key 0x" + d(e.key)
|
|
848
862
|
);
|
|
849
863
|
return e.value;
|
|
850
864
|
}
|
|
851
|
-
function
|
|
865
|
+
function br(e) {
|
|
852
866
|
return {
|
|
853
867
|
key: new Uint8Array([p.NON_WITNESS_UTXO]),
|
|
854
868
|
value: e
|
|
855
869
|
};
|
|
856
870
|
}
|
|
857
|
-
const
|
|
858
|
-
function
|
|
871
|
+
const Tr = "Uint8Array";
|
|
872
|
+
function Ar(e) {
|
|
859
873
|
return e instanceof Uint8Array;
|
|
860
874
|
}
|
|
861
|
-
function
|
|
875
|
+
function Ir(e, t) {
|
|
862
876
|
return !!e && !!t && e.nonWitnessUtxo === void 0;
|
|
863
877
|
}
|
|
864
|
-
const
|
|
878
|
+
const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
865
879
|
__proto__: null,
|
|
866
|
-
canAdd:
|
|
867
|
-
check:
|
|
868
|
-
decode:
|
|
869
|
-
encode:
|
|
870
|
-
expected:
|
|
880
|
+
canAdd: Ir,
|
|
881
|
+
check: Ar,
|
|
882
|
+
decode: mr,
|
|
883
|
+
encode: br,
|
|
884
|
+
expected: Tr
|
|
871
885
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
872
|
-
function
|
|
886
|
+
function vr(e) {
|
|
873
887
|
if (e.key[0] !== p.PARTIAL_SIG)
|
|
874
888
|
throw new Error(
|
|
875
889
|
"Decode Error: could not decode partialSig with key 0x" + d(e.key)
|
|
@@ -883,123 +897,123 @@ function br(e) {
|
|
|
883
897
|
signature: e.value
|
|
884
898
|
};
|
|
885
899
|
}
|
|
886
|
-
function
|
|
900
|
+
function xr(e) {
|
|
887
901
|
const t = new Uint8Array([p.PARTIAL_SIG]);
|
|
888
902
|
return {
|
|
889
|
-
key:
|
|
903
|
+
key: P([t, e.pubkey]),
|
|
890
904
|
value: e.signature
|
|
891
905
|
};
|
|
892
906
|
}
|
|
893
|
-
const
|
|
894
|
-
function
|
|
895
|
-
return e.pubkey instanceof Uint8Array && e.signature instanceof Uint8Array && [33, 65].includes(e.pubkey.length) && [2, 3, 4].includes(e.pubkey[0]) &&
|
|
907
|
+
const _r = "{ pubkey: Uint8Array; signature: Uint8Array; }";
|
|
908
|
+
function Ur(e) {
|
|
909
|
+
return e.pubkey instanceof Uint8Array && e.signature instanceof Uint8Array && [33, 65].includes(e.pubkey.length) && [2, 3, 4].includes(e.pubkey[0]) && Pr(e.signature);
|
|
896
910
|
}
|
|
897
|
-
function
|
|
911
|
+
function Pr(e) {
|
|
898
912
|
if (!(e instanceof Uint8Array) || e.length < 9 || e[0] !== 48 || e.length !== e[1] + 3 || e[2] !== 2) return !1;
|
|
899
913
|
const t = e[3];
|
|
900
914
|
if (t > 33 || t < 1 || e[3 + t + 1] !== 2) return !1;
|
|
901
915
|
const n = e[3 + t + 2];
|
|
902
916
|
return !(n > 33 || n < 1 || e.length !== 3 + t + 2 + n + 2);
|
|
903
917
|
}
|
|
904
|
-
function
|
|
918
|
+
function Nr(e, t, n) {
|
|
905
919
|
const r = d(t.pubkey);
|
|
906
|
-
return n.has(r) ? !1 : (n.add(r), e.filter((s) =>
|
|
920
|
+
return n.has(r) ? !1 : (n.add(r), e.filter((s) => N(s.pubkey, t.pubkey) === 0).length === 0);
|
|
907
921
|
}
|
|
908
|
-
const
|
|
922
|
+
const Hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
909
923
|
__proto__: null,
|
|
910
|
-
canAddToArray:
|
|
911
|
-
check:
|
|
912
|
-
decode:
|
|
913
|
-
encode:
|
|
914
|
-
expected:
|
|
924
|
+
canAddToArray: Nr,
|
|
925
|
+
check: Ur,
|
|
926
|
+
decode: vr,
|
|
927
|
+
encode: xr,
|
|
928
|
+
expected: _r
|
|
915
929
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
916
|
-
function
|
|
930
|
+
function Or(e) {
|
|
917
931
|
if (e.key[0] !== p.POR_COMMITMENT)
|
|
918
932
|
throw new Error(
|
|
919
933
|
"Decode Error: could not decode porCommitment with key 0x" + d(e.key)
|
|
920
934
|
);
|
|
921
|
-
return
|
|
935
|
+
return Gn(e.value);
|
|
922
936
|
}
|
|
923
|
-
function
|
|
937
|
+
function Rr(e) {
|
|
924
938
|
return {
|
|
925
939
|
key: new Uint8Array([p.POR_COMMITMENT]),
|
|
926
|
-
value:
|
|
940
|
+
value: Vn(e)
|
|
927
941
|
};
|
|
928
942
|
}
|
|
929
|
-
const
|
|
930
|
-
function
|
|
943
|
+
const Kr = "string";
|
|
944
|
+
function Cr(e) {
|
|
931
945
|
return typeof e == "string";
|
|
932
946
|
}
|
|
933
|
-
function
|
|
947
|
+
function Fr(e, t) {
|
|
934
948
|
return !!e && !!t && e.porCommitment === void 0;
|
|
935
949
|
}
|
|
936
|
-
const
|
|
950
|
+
const Br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
937
951
|
__proto__: null,
|
|
938
|
-
canAdd:
|
|
939
|
-
check:
|
|
940
|
-
decode:
|
|
941
|
-
encode:
|
|
942
|
-
expected:
|
|
952
|
+
canAdd: Fr,
|
|
953
|
+
check: Cr,
|
|
954
|
+
decode: Or,
|
|
955
|
+
encode: Rr,
|
|
956
|
+
expected: Kr
|
|
943
957
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
944
|
-
function
|
|
958
|
+
function Wr(e) {
|
|
945
959
|
if (e.key[0] !== p.SIGHASH_TYPE)
|
|
946
960
|
throw new Error(
|
|
947
961
|
"Decode Error: could not decode sighashType with key 0x" + d(e.key)
|
|
948
962
|
);
|
|
949
963
|
return Number(Tt(e.value, 0, "LE"));
|
|
950
964
|
}
|
|
951
|
-
function
|
|
965
|
+
function $r(e) {
|
|
952
966
|
const t = Uint8Array.from([p.SIGHASH_TYPE]), n = new Uint8Array(4);
|
|
953
967
|
return Wt(n, 0, e, "LE"), {
|
|
954
968
|
key: t,
|
|
955
969
|
value: n
|
|
956
970
|
};
|
|
957
971
|
}
|
|
958
|
-
const
|
|
959
|
-
function
|
|
972
|
+
const Lr = "number";
|
|
973
|
+
function Mr(e) {
|
|
960
974
|
return typeof e == "number";
|
|
961
975
|
}
|
|
962
|
-
function
|
|
976
|
+
function Dr(e, t) {
|
|
963
977
|
return !!e && !!t && e.sighashType === void 0;
|
|
964
978
|
}
|
|
965
|
-
const
|
|
979
|
+
const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
966
980
|
__proto__: null,
|
|
967
|
-
canAdd:
|
|
968
|
-
check:
|
|
969
|
-
decode:
|
|
970
|
-
encode:
|
|
971
|
-
expected:
|
|
981
|
+
canAdd: Dr,
|
|
982
|
+
check: Mr,
|
|
983
|
+
decode: Wr,
|
|
984
|
+
encode: $r,
|
|
985
|
+
expected: Lr
|
|
972
986
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
973
|
-
function
|
|
987
|
+
function Vr(e) {
|
|
974
988
|
if (e.key[0] !== p.TAP_KEY_SIG || e.key.length !== 1)
|
|
975
989
|
throw new Error(
|
|
976
990
|
"Decode Error: could not decode tapKeySig with key 0x" + d(e.key)
|
|
977
991
|
);
|
|
978
|
-
if (!
|
|
992
|
+
if (!_e(e.value))
|
|
979
993
|
throw new Error(
|
|
980
994
|
"Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature"
|
|
981
995
|
);
|
|
982
996
|
return e.value;
|
|
983
997
|
}
|
|
984
|
-
function
|
|
998
|
+
function zr(e) {
|
|
985
999
|
return { key: Uint8Array.from([p.TAP_KEY_SIG]), value: e };
|
|
986
1000
|
}
|
|
987
|
-
const
|
|
988
|
-
function
|
|
1001
|
+
const jr = "Uint8Array";
|
|
1002
|
+
function _e(e) {
|
|
989
1003
|
return e instanceof Uint8Array && (e.length === 64 || e.length === 65);
|
|
990
1004
|
}
|
|
991
|
-
function
|
|
1005
|
+
function Xr(e, t) {
|
|
992
1006
|
return !!e && !!t && e.tapKeySig === void 0;
|
|
993
1007
|
}
|
|
994
|
-
const
|
|
1008
|
+
const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
995
1009
|
__proto__: null,
|
|
996
|
-
canAdd:
|
|
997
|
-
check:
|
|
998
|
-
decode:
|
|
999
|
-
encode:
|
|
1000
|
-
expected:
|
|
1010
|
+
canAdd: Xr,
|
|
1011
|
+
check: _e,
|
|
1012
|
+
decode: Vr,
|
|
1013
|
+
encode: zr,
|
|
1014
|
+
expected: jr
|
|
1001
1015
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1002
|
-
function
|
|
1016
|
+
function qr(e) {
|
|
1003
1017
|
if (e.key[0] !== p.TAP_LEAF_SCRIPT)
|
|
1004
1018
|
throw new Error(
|
|
1005
1019
|
"Decode Error: could not decode tapLeafScript with key 0x" + d(e.key)
|
|
@@ -1016,57 +1030,57 @@ function Vr(e) {
|
|
|
1016
1030
|
const n = e.value.slice(0, -1);
|
|
1017
1031
|
return { controlBlock: e.key.slice(1), script: n, leafVersion: t };
|
|
1018
1032
|
}
|
|
1019
|
-
function
|
|
1033
|
+
function Zr(e) {
|
|
1020
1034
|
const t = Uint8Array.from([p.TAP_LEAF_SCRIPT]), n = Uint8Array.from([e.leafVersion]);
|
|
1021
1035
|
return {
|
|
1022
|
-
key:
|
|
1023
|
-
value:
|
|
1036
|
+
key: P([t, e.controlBlock]),
|
|
1037
|
+
value: P([e.script, n])
|
|
1024
1038
|
};
|
|
1025
1039
|
}
|
|
1026
|
-
const
|
|
1027
|
-
function
|
|
1040
|
+
const Jr = "{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";
|
|
1041
|
+
function Qr(e) {
|
|
1028
1042
|
return e.controlBlock instanceof Uint8Array && (e.controlBlock.length - 1) % 32 === 0 && (e.controlBlock[0] & 254) === e.leafVersion && e.script instanceof Uint8Array;
|
|
1029
1043
|
}
|
|
1030
|
-
function
|
|
1044
|
+
function ts(e, t, n) {
|
|
1031
1045
|
const r = d(t.controlBlock);
|
|
1032
|
-
return n.has(r) ? !1 : (n.add(r), e.filter((s) =>
|
|
1046
|
+
return n.has(r) ? !1 : (n.add(r), e.filter((s) => N(s.controlBlock, t.controlBlock) === 0).length === 0);
|
|
1033
1047
|
}
|
|
1034
|
-
const
|
|
1048
|
+
const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1035
1049
|
__proto__: null,
|
|
1036
|
-
canAddToArray:
|
|
1037
|
-
check:
|
|
1038
|
-
decode:
|
|
1039
|
-
encode:
|
|
1040
|
-
expected:
|
|
1050
|
+
canAddToArray: ts,
|
|
1051
|
+
check: Qr,
|
|
1052
|
+
decode: qr,
|
|
1053
|
+
encode: Zr,
|
|
1054
|
+
expected: Jr
|
|
1041
1055
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1042
|
-
function
|
|
1056
|
+
function ns(e) {
|
|
1043
1057
|
if (e.key[0] !== p.TAP_MERKLE_ROOT || e.key.length !== 1)
|
|
1044
1058
|
throw new Error(
|
|
1045
1059
|
"Decode Error: could not decode tapMerkleRoot with key 0x" + d(e.key)
|
|
1046
1060
|
);
|
|
1047
|
-
if (!
|
|
1061
|
+
if (!Ue(e.value))
|
|
1048
1062
|
throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");
|
|
1049
1063
|
return e.value;
|
|
1050
1064
|
}
|
|
1051
|
-
function
|
|
1065
|
+
function rs(e) {
|
|
1052
1066
|
return { key: Uint8Array.from([p.TAP_MERKLE_ROOT]), value: e };
|
|
1053
1067
|
}
|
|
1054
|
-
const
|
|
1055
|
-
function
|
|
1068
|
+
const ss = "Uint8Array";
|
|
1069
|
+
function Ue(e) {
|
|
1056
1070
|
return e instanceof Uint8Array && e.length === 32;
|
|
1057
1071
|
}
|
|
1058
|
-
function
|
|
1072
|
+
function is(e, t) {
|
|
1059
1073
|
return !!e && !!t && e.tapMerkleRoot === void 0;
|
|
1060
1074
|
}
|
|
1061
|
-
const
|
|
1075
|
+
const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1062
1076
|
__proto__: null,
|
|
1063
|
-
canAdd:
|
|
1064
|
-
check:
|
|
1065
|
-
decode:
|
|
1066
|
-
encode:
|
|
1067
|
-
expected:
|
|
1077
|
+
canAdd: is,
|
|
1078
|
+
check: Ue,
|
|
1079
|
+
decode: ns,
|
|
1080
|
+
encode: rs,
|
|
1081
|
+
expected: ss
|
|
1068
1082
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1069
|
-
function
|
|
1083
|
+
function as(e) {
|
|
1070
1084
|
if (e.key[0] !== p.TAP_SCRIPT_SIG)
|
|
1071
1085
|
throw new Error(
|
|
1072
1086
|
"Decode Error: could not decode tapScriptSig with key 0x" + d(e.key)
|
|
@@ -1086,37 +1100,37 @@ function ns(e) {
|
|
|
1086
1100
|
signature: e.value
|
|
1087
1101
|
};
|
|
1088
1102
|
}
|
|
1089
|
-
function
|
|
1103
|
+
function cs(e) {
|
|
1090
1104
|
const t = Uint8Array.from([p.TAP_SCRIPT_SIG]);
|
|
1091
1105
|
return {
|
|
1092
|
-
key:
|
|
1106
|
+
key: P([t, e.pubkey, e.leafHash]),
|
|
1093
1107
|
value: e.signature
|
|
1094
1108
|
};
|
|
1095
1109
|
}
|
|
1096
|
-
const
|
|
1097
|
-
function
|
|
1110
|
+
const us = "{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";
|
|
1111
|
+
function hs(e) {
|
|
1098
1112
|
return e.pubkey instanceof Uint8Array && e.leafHash instanceof Uint8Array && e.signature instanceof Uint8Array && e.pubkey.length === 32 && e.leafHash.length === 32 && (e.signature.length === 64 || e.signature.length === 65);
|
|
1099
1113
|
}
|
|
1100
|
-
function
|
|
1114
|
+
function ls(e, t, n) {
|
|
1101
1115
|
const r = d(t.pubkey) + d(t.leafHash);
|
|
1102
1116
|
return n.has(r) ? !1 : (n.add(r), e.filter(
|
|
1103
|
-
(s) =>
|
|
1117
|
+
(s) => N(s.pubkey, t.pubkey) === 0 && N(s.leafHash, t.leafHash) === 0
|
|
1104
1118
|
).length === 0);
|
|
1105
1119
|
}
|
|
1106
|
-
const
|
|
1120
|
+
const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1107
1121
|
__proto__: null,
|
|
1108
|
-
canAddToArray:
|
|
1109
|
-
check:
|
|
1110
|
-
decode:
|
|
1111
|
-
encode:
|
|
1112
|
-
expected:
|
|
1122
|
+
canAddToArray: ls,
|
|
1123
|
+
check: hs,
|
|
1124
|
+
decode: as,
|
|
1125
|
+
encode: cs,
|
|
1126
|
+
expected: us
|
|
1113
1127
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1114
|
-
function
|
|
1128
|
+
function ps(e) {
|
|
1115
1129
|
if (e.key[0] !== p.WITNESS_UTXO)
|
|
1116
1130
|
throw new Error(
|
|
1117
1131
|
"Decode Error: could not decode witnessUtxo with key 0x" + d(e.key)
|
|
1118
1132
|
);
|
|
1119
|
-
const t =
|
|
1133
|
+
const t = Jn(e.value, 0, "LE");
|
|
1120
1134
|
let n = 8;
|
|
1121
1135
|
const { numberValue: r, bytes: s } = Y(
|
|
1122
1136
|
e.value,
|
|
@@ -1131,29 +1145,29 @@ function cs(e) {
|
|
|
1131
1145
|
value: t
|
|
1132
1146
|
};
|
|
1133
1147
|
}
|
|
1134
|
-
function
|
|
1148
|
+
function ds(e) {
|
|
1135
1149
|
const { script: t, value: n } = e, r = V(t.length), s = new Uint8Array(8 + r + t.length);
|
|
1136
|
-
return
|
|
1150
|
+
return Zn(s, 0, BigInt(n), "LE"), z(t.length, s, 8), s.set(t, 8 + r), {
|
|
1137
1151
|
key: Uint8Array.from([p.WITNESS_UTXO]),
|
|
1138
1152
|
value: s
|
|
1139
1153
|
};
|
|
1140
1154
|
}
|
|
1141
|
-
const
|
|
1142
|
-
function
|
|
1155
|
+
const gs = "{ script: Uint8Array; value: bigint; }";
|
|
1156
|
+
function ys(e) {
|
|
1143
1157
|
return e.script instanceof Uint8Array && typeof e.value == "bigint";
|
|
1144
1158
|
}
|
|
1145
|
-
function
|
|
1159
|
+
function ws(e, t) {
|
|
1146
1160
|
return !!e && !!t && e.witnessUtxo === void 0;
|
|
1147
1161
|
}
|
|
1148
|
-
const
|
|
1162
|
+
const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1149
1163
|
__proto__: null,
|
|
1150
|
-
canAdd:
|
|
1151
|
-
check:
|
|
1152
|
-
decode:
|
|
1153
|
-
encode:
|
|
1154
|
-
expected:
|
|
1164
|
+
canAdd: ws,
|
|
1165
|
+
check: ys,
|
|
1166
|
+
decode: ps,
|
|
1167
|
+
encode: ds,
|
|
1168
|
+
expected: gs
|
|
1155
1169
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1156
|
-
function
|
|
1170
|
+
function Es(e) {
|
|
1157
1171
|
if (e.key[0] !== E.TAP_TREE || e.key.length !== 1)
|
|
1158
1172
|
throw new Error(
|
|
1159
1173
|
"Decode Error: could not decode tapTree with key 0x" + d(e.key)
|
|
@@ -1173,7 +1187,7 @@ function ds(e) {
|
|
|
1173
1187
|
}
|
|
1174
1188
|
return { leaves: n };
|
|
1175
1189
|
}
|
|
1176
|
-
function
|
|
1190
|
+
function ms(e) {
|
|
1177
1191
|
const t = Uint8Array.from([E.TAP_TREE]), n = [].concat(
|
|
1178
1192
|
...e.leaves.map((r) => [
|
|
1179
1193
|
Uint8Array.of(r.depth, r.leafVersion),
|
|
@@ -1183,27 +1197,27 @@ function gs(e) {
|
|
|
1183
1197
|
);
|
|
1184
1198
|
return {
|
|
1185
1199
|
key: t,
|
|
1186
|
-
value:
|
|
1200
|
+
value: P(n)
|
|
1187
1201
|
};
|
|
1188
1202
|
}
|
|
1189
|
-
const
|
|
1190
|
-
function
|
|
1203
|
+
const bs = "{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";
|
|
1204
|
+
function Ts(e) {
|
|
1191
1205
|
return Array.isArray(e.leaves) && e.leaves.every(
|
|
1192
1206
|
(t) => t.depth >= 0 && t.depth <= 128 && (t.leafVersion & 254) === t.leafVersion && t.script instanceof Uint8Array
|
|
1193
1207
|
);
|
|
1194
1208
|
}
|
|
1195
|
-
function
|
|
1209
|
+
function As(e, t) {
|
|
1196
1210
|
return !!e && !!t && e.tapTree === void 0;
|
|
1197
1211
|
}
|
|
1198
|
-
const
|
|
1212
|
+
const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1199
1213
|
__proto__: null,
|
|
1200
|
-
canAdd:
|
|
1201
|
-
check:
|
|
1202
|
-
decode:
|
|
1203
|
-
encode:
|
|
1204
|
-
expected:
|
|
1205
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1206
|
-
function $t(e, t =
|
|
1214
|
+
canAdd: As,
|
|
1215
|
+
check: Ts,
|
|
1216
|
+
decode: Es,
|
|
1217
|
+
encode: ms,
|
|
1218
|
+
expected: bs
|
|
1219
|
+
}, Symbol.toStringTag, { value: "Module" })), ks = (e) => [...Array(e).keys()], vs = (e) => e.length === 33 && [2, 3].includes(e[0]) || e.length === 65 && e[0] === 4;
|
|
1220
|
+
function $t(e, t = vs) {
|
|
1207
1221
|
function n(a) {
|
|
1208
1222
|
if (a.key[0] !== e)
|
|
1209
1223
|
throw new Error(
|
|
@@ -1223,14 +1237,14 @@ function $t(e, t = bs) {
|
|
|
1223
1237
|
pubkey: u,
|
|
1224
1238
|
path: "m"
|
|
1225
1239
|
};
|
|
1226
|
-
for (const f of
|
|
1240
|
+
for (const f of ks(a.value.length / 4 - 1)) {
|
|
1227
1241
|
const c = Tt(a.value, f * 4 + 4, "LE"), h = !!(c & 2147483648), S = c & 2147483647;
|
|
1228
1242
|
l.path += "/" + S.toString(10) + (h ? "'" : "");
|
|
1229
1243
|
}
|
|
1230
1244
|
return l;
|
|
1231
1245
|
}
|
|
1232
1246
|
function r(a) {
|
|
1233
|
-
const u = Uint8Array.from([e]), l =
|
|
1247
|
+
const u = Uint8Array.from([e]), l = P([u, a.pubkey]), f = a.path.split("/"), c = new Uint8Array(f.length * 4);
|
|
1234
1248
|
c.set(a.masterFingerprint, 0);
|
|
1235
1249
|
let h = 4;
|
|
1236
1250
|
return f.slice(1).forEach((S) => {
|
|
@@ -1248,7 +1262,7 @@ function $t(e, t = bs) {
|
|
|
1248
1262
|
}
|
|
1249
1263
|
function o(a, u, l) {
|
|
1250
1264
|
const f = d(u.pubkey);
|
|
1251
|
-
return l.has(f) ? !1 : (l.add(f), a.filter((c) =>
|
|
1265
|
+
return l.has(f) ? !1 : (l.add(f), a.filter((c) => N(c.pubkey, u.pubkey) === 0).length === 0);
|
|
1252
1266
|
}
|
|
1253
1267
|
return {
|
|
1254
1268
|
decode: n,
|
|
@@ -1269,7 +1283,7 @@ function Lt(e) {
|
|
|
1269
1283
|
return r;
|
|
1270
1284
|
}
|
|
1271
1285
|
}
|
|
1272
|
-
function
|
|
1286
|
+
function Pe(e) {
|
|
1273
1287
|
function t(o) {
|
|
1274
1288
|
if (o.key[0] !== e)
|
|
1275
1289
|
throw new Error(
|
|
@@ -1298,9 +1312,9 @@ function _e(e) {
|
|
|
1298
1312
|
canAdd: i
|
|
1299
1313
|
};
|
|
1300
1314
|
}
|
|
1301
|
-
const
|
|
1302
|
-
function
|
|
1303
|
-
const t = $t(e,
|
|
1315
|
+
const xs = (e) => e.length === 32;
|
|
1316
|
+
function Ne(e) {
|
|
1317
|
+
const t = $t(e, xs);
|
|
1304
1318
|
function n(o) {
|
|
1305
1319
|
const { numberValue: a, bytes: u } = Y(
|
|
1306
1320
|
o.value
|
|
@@ -1315,7 +1329,7 @@ function Ue(e) {
|
|
|
1315
1329
|
function r(o) {
|
|
1316
1330
|
const a = t.encode(o), u = V(o.leafHashes.length), l = new Uint8Array(u);
|
|
1317
1331
|
z(o.leafHashes.length, l);
|
|
1318
|
-
const f =
|
|
1332
|
+
const f = P([l, ...o.leafHashes, a.value]);
|
|
1319
1333
|
return { ...a, value: f };
|
|
1320
1334
|
}
|
|
1321
1335
|
const s = "{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";
|
|
@@ -1332,7 +1346,7 @@ function Ue(e) {
|
|
|
1332
1346
|
canAddToArray: t.canAddToArray
|
|
1333
1347
|
};
|
|
1334
1348
|
}
|
|
1335
|
-
function
|
|
1349
|
+
function He(e) {
|
|
1336
1350
|
function t(o) {
|
|
1337
1351
|
if (o.key[0] !== e || o.key.length !== 1)
|
|
1338
1352
|
throw new Error(
|
|
@@ -1362,7 +1376,7 @@ function Pe(e) {
|
|
|
1362
1376
|
canAdd: i
|
|
1363
1377
|
};
|
|
1364
1378
|
}
|
|
1365
|
-
function
|
|
1379
|
+
function Oe(e) {
|
|
1366
1380
|
function t(o) {
|
|
1367
1381
|
if (o.key[0] !== e)
|
|
1368
1382
|
throw new Error(
|
|
@@ -1392,58 +1406,58 @@ function Ne(e) {
|
|
|
1392
1406
|
};
|
|
1393
1407
|
}
|
|
1394
1408
|
const Mt = {
|
|
1395
|
-
unsignedTx:
|
|
1396
|
-
globalXpub:
|
|
1409
|
+
unsignedTx: ar,
|
|
1410
|
+
globalXpub: ir,
|
|
1397
1411
|
// pass an Array of key bytes that require pubkey beside the key
|
|
1398
1412
|
checkPubkey: Lt([])
|
|
1399
1413
|
}, m = {
|
|
1400
|
-
nonWitnessUtxo:
|
|
1401
|
-
partialSig:
|
|
1402
|
-
sighashType:
|
|
1403
|
-
finalScriptSig:
|
|
1404
|
-
finalScriptWitness:
|
|
1405
|
-
porCommitment:
|
|
1406
|
-
witnessUtxo:
|
|
1414
|
+
nonWitnessUtxo: kr,
|
|
1415
|
+
partialSig: Hr,
|
|
1416
|
+
sighashType: Gr,
|
|
1417
|
+
finalScriptSig: pr,
|
|
1418
|
+
finalScriptWitness: Er,
|
|
1419
|
+
porCommitment: Br,
|
|
1420
|
+
witnessUtxo: Ss,
|
|
1407
1421
|
bip32Derivation: $t(p.BIP32_DERIVATION),
|
|
1408
|
-
redeemScript:
|
|
1409
|
-
witnessScript:
|
|
1422
|
+
redeemScript: Pe(p.REDEEM_SCRIPT),
|
|
1423
|
+
witnessScript: Oe(p.WITNESS_SCRIPT),
|
|
1410
1424
|
checkPubkey: Lt([
|
|
1411
1425
|
p.PARTIAL_SIG,
|
|
1412
1426
|
p.BIP32_DERIVATION
|
|
1413
1427
|
]),
|
|
1414
|
-
tapKeySig:
|
|
1415
|
-
tapScriptSig:
|
|
1416
|
-
tapLeafScript:
|
|
1417
|
-
tapBip32Derivation:
|
|
1428
|
+
tapKeySig: Yr,
|
|
1429
|
+
tapScriptSig: fs,
|
|
1430
|
+
tapLeafScript: es,
|
|
1431
|
+
tapBip32Derivation: Ne(
|
|
1418
1432
|
p.TAP_BIP32_DERIVATION
|
|
1419
1433
|
),
|
|
1420
|
-
tapInternalKey:
|
|
1421
|
-
tapMerkleRoot:
|
|
1422
|
-
},
|
|
1434
|
+
tapInternalKey: He(p.TAP_INTERNAL_KEY),
|
|
1435
|
+
tapMerkleRoot: os
|
|
1436
|
+
}, H = {
|
|
1423
1437
|
bip32Derivation: $t(E.BIP32_DERIVATION),
|
|
1424
|
-
redeemScript:
|
|
1425
|
-
witnessScript:
|
|
1438
|
+
redeemScript: Pe(E.REDEEM_SCRIPT),
|
|
1439
|
+
witnessScript: Oe(E.WITNESS_SCRIPT),
|
|
1426
1440
|
checkPubkey: Lt([E.BIP32_DERIVATION]),
|
|
1427
|
-
tapBip32Derivation:
|
|
1441
|
+
tapBip32Derivation: Ne(
|
|
1428
1442
|
E.TAP_BIP32_DERIVATION
|
|
1429
1443
|
),
|
|
1430
|
-
tapTree:
|
|
1431
|
-
tapInternalKey:
|
|
1432
|
-
},
|
|
1444
|
+
tapTree: Is,
|
|
1445
|
+
tapInternalKey: He(E.TAP_INTERNAL_KEY)
|
|
1446
|
+
}, _s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1433
1447
|
__proto__: null,
|
|
1434
1448
|
globals: Mt,
|
|
1435
1449
|
inputs: m,
|
|
1436
|
-
outputs:
|
|
1450
|
+
outputs: H
|
|
1437
1451
|
}, Symbol.toStringTag, { value: "Module" })), lt = (e) => [...Array(e).keys()];
|
|
1438
|
-
function
|
|
1439
|
-
const t = e.map(
|
|
1440
|
-
return t.push(Uint8Array.from([0])),
|
|
1452
|
+
function ee(e) {
|
|
1453
|
+
const t = e.map(Us);
|
|
1454
|
+
return t.push(Uint8Array.from([0])), P(t);
|
|
1441
1455
|
}
|
|
1442
|
-
function
|
|
1456
|
+
function Us(e) {
|
|
1443
1457
|
const t = e.key.length, n = e.value.length, r = V(t), s = V(n), i = new Uint8Array(r + t + s + n);
|
|
1444
1458
|
return z(t, i, 0), i.set(e.key, r), z(n, i, r + t), i.set(e.value, r + t + s), i;
|
|
1445
1459
|
}
|
|
1446
|
-
function
|
|
1460
|
+
function Ps(e, t) {
|
|
1447
1461
|
let n = 0;
|
|
1448
1462
|
function r() {
|
|
1449
1463
|
const { numberValue: w, bytes: I } = Y(e, n);
|
|
@@ -1456,7 +1470,7 @@ function ks(e, t) {
|
|
|
1456
1470
|
return n += 4, w;
|
|
1457
1471
|
}
|
|
1458
1472
|
function i() {
|
|
1459
|
-
const w =
|
|
1473
|
+
const w = te(e, n);
|
|
1460
1474
|
return n += 1, w;
|
|
1461
1475
|
}
|
|
1462
1476
|
function o() {
|
|
@@ -1469,7 +1483,7 @@ function ks(e, t) {
|
|
|
1469
1483
|
function a() {
|
|
1470
1484
|
if (n >= e.length)
|
|
1471
1485
|
throw new Error("Format Error: Unexpected End of PSBT");
|
|
1472
|
-
const w =
|
|
1486
|
+
const w = te(e, n) === 0;
|
|
1473
1487
|
return w && n++, w;
|
|
1474
1488
|
}
|
|
1475
1489
|
if (s() !== 1886610036)
|
|
@@ -1488,7 +1502,7 @@ function ks(e, t) {
|
|
|
1488
1502
|
l[I] = 1, u.push(w);
|
|
1489
1503
|
}
|
|
1490
1504
|
const f = u.filter(
|
|
1491
|
-
(w) => w.key[0] ===
|
|
1505
|
+
(w) => w.key[0] === U.UNSIGNED_TX
|
|
1492
1506
|
);
|
|
1493
1507
|
if (f.length !== 1)
|
|
1494
1508
|
throw new Error("Format Error: Only one UNSIGNED_TX allowed");
|
|
@@ -1517,32 +1531,32 @@ function ks(e, t) {
|
|
|
1517
1531
|
}
|
|
1518
1532
|
y.push(R);
|
|
1519
1533
|
}
|
|
1520
|
-
return
|
|
1534
|
+
return Re(c, {
|
|
1521
1535
|
globalMapKeyVals: u,
|
|
1522
1536
|
inputKeyVals: g,
|
|
1523
1537
|
outputKeyVals: y
|
|
1524
1538
|
});
|
|
1525
1539
|
}
|
|
1526
1540
|
function A(e, t, n) {
|
|
1527
|
-
if (
|
|
1541
|
+
if (N(t, Uint8Array.from([n])))
|
|
1528
1542
|
throw new Error(
|
|
1529
1543
|
// `Format Error: Invalid ${type} key: ${keyBuf.toString('hex')}`,
|
|
1530
1544
|
`Format Error: Invalid ${e} key: ${d(t)}`
|
|
1531
1545
|
);
|
|
1532
1546
|
}
|
|
1533
|
-
function
|
|
1547
|
+
function Re(e, { globalMapKeyVals: t, inputKeyVals: n, outputKeyVals: r }) {
|
|
1534
1548
|
const s = {
|
|
1535
1549
|
unsignedTx: e
|
|
1536
1550
|
};
|
|
1537
1551
|
let i = 0;
|
|
1538
1552
|
for (const f of t)
|
|
1539
1553
|
switch (f.key[0]) {
|
|
1540
|
-
case
|
|
1541
|
-
if (A("global", f.key,
|
|
1554
|
+
case U.UNSIGNED_TX:
|
|
1555
|
+
if (A("global", f.key, U.UNSIGNED_TX), i > 0)
|
|
1542
1556
|
throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");
|
|
1543
1557
|
i++;
|
|
1544
1558
|
break;
|
|
1545
|
-
case
|
|
1559
|
+
case U.GLOBAL_XPUB:
|
|
1546
1560
|
s.globalXpub === void 0 && (s.globalXpub = []), s.globalXpub.push(Mt.globalXpub.decode(f));
|
|
1547
1561
|
break;
|
|
1548
1562
|
default:
|
|
@@ -1627,31 +1641,31 @@ function He(e, { globalMapKeyVals: t, inputKeyVals: n, outputKeyVals: r }) {
|
|
|
1627
1641
|
for (const f of lt(a)) {
|
|
1628
1642
|
const c = {};
|
|
1629
1643
|
for (const h of r[f])
|
|
1630
|
-
switch (
|
|
1644
|
+
switch (H.checkPubkey(h), h.key[0]) {
|
|
1631
1645
|
case E.REDEEM_SCRIPT:
|
|
1632
1646
|
if (A("output", h.key, E.REDEEM_SCRIPT), c.redeemScript !== void 0)
|
|
1633
1647
|
throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");
|
|
1634
|
-
c.redeemScript =
|
|
1648
|
+
c.redeemScript = H.redeemScript.decode(h);
|
|
1635
1649
|
break;
|
|
1636
1650
|
case E.WITNESS_SCRIPT:
|
|
1637
1651
|
if (A("output", h.key, E.WITNESS_SCRIPT), c.witnessScript !== void 0)
|
|
1638
1652
|
throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");
|
|
1639
|
-
c.witnessScript =
|
|
1653
|
+
c.witnessScript = H.witnessScript.decode(h);
|
|
1640
1654
|
break;
|
|
1641
1655
|
case E.BIP32_DERIVATION:
|
|
1642
1656
|
c.bip32Derivation === void 0 && (c.bip32Derivation = []), c.bip32Derivation.push(
|
|
1643
|
-
|
|
1657
|
+
H.bip32Derivation.decode(h)
|
|
1644
1658
|
);
|
|
1645
1659
|
break;
|
|
1646
1660
|
case E.TAP_INTERNAL_KEY:
|
|
1647
|
-
A("output", h.key, E.TAP_INTERNAL_KEY), c.tapInternalKey =
|
|
1661
|
+
A("output", h.key, E.TAP_INTERNAL_KEY), c.tapInternalKey = H.tapInternalKey.decode(h);
|
|
1648
1662
|
break;
|
|
1649
1663
|
case E.TAP_TREE:
|
|
1650
|
-
A("output", h.key, E.TAP_TREE), c.tapTree =
|
|
1664
|
+
A("output", h.key, E.TAP_TREE), c.tapTree = H.tapTree.decode(h);
|
|
1651
1665
|
break;
|
|
1652
1666
|
case E.TAP_BIP32_DERIVATION:
|
|
1653
1667
|
c.tapBip32Derivation === void 0 && (c.tapBip32Derivation = []), c.tapBip32Derivation.push(
|
|
1654
|
-
|
|
1668
|
+
H.tapBip32Derivation.decode(h)
|
|
1655
1669
|
);
|
|
1656
1670
|
break;
|
|
1657
1671
|
default:
|
|
@@ -1661,17 +1675,17 @@ function He(e, { globalMapKeyVals: t, inputKeyVals: n, outputKeyVals: r }) {
|
|
|
1661
1675
|
}
|
|
1662
1676
|
return { globalMap: s, inputs: u, outputs: l };
|
|
1663
1677
|
}
|
|
1664
|
-
function
|
|
1678
|
+
function Ns({ globalMap: e, inputs: t, outputs: n }) {
|
|
1665
1679
|
const { globalKeyVals: r, inputKeyVals: s, outputKeyVals: i } = Rt({
|
|
1666
1680
|
globalMap: e,
|
|
1667
1681
|
inputs: t,
|
|
1668
1682
|
outputs: n
|
|
1669
|
-
}), o =
|
|
1670
|
-
return f.set([112, 115, 98, 116, 255], 0),
|
|
1683
|
+
}), o = ee(r), a = (c) => c.length === 0 ? [Uint8Array.from([0])] : c.map(ee), u = a(s), l = a(i), f = new Uint8Array(5);
|
|
1684
|
+
return f.set([112, 115, 98, 116, 255], 0), P(
|
|
1671
1685
|
[f, o].concat(u, l)
|
|
1672
1686
|
);
|
|
1673
1687
|
}
|
|
1674
|
-
const
|
|
1688
|
+
const Hs = (e, t) => N(e.key, t.key);
|
|
1675
1689
|
function xt(e, t) {
|
|
1676
1690
|
const n = /* @__PURE__ */ new Set(), r = Object.entries(e).reduce((i, [o, a]) => {
|
|
1677
1691
|
if (o === "unknownKeyVals") return i;
|
|
@@ -1686,25 +1700,25 @@ function xt(e, t) {
|
|
|
1686
1700
|
n.add(c);
|
|
1687
1701
|
}), i.concat(l);
|
|
1688
1702
|
}, []), s = e.unknownKeyVals ? e.unknownKeyVals.filter((i) => !n.has(d(i.key))) : [];
|
|
1689
|
-
return r.concat(s).sort(
|
|
1703
|
+
return r.concat(s).sort(Hs);
|
|
1690
1704
|
}
|
|
1691
1705
|
function Rt({ globalMap: e, inputs: t, outputs: n }) {
|
|
1692
1706
|
return {
|
|
1693
1707
|
globalKeyVals: xt(e, Mt),
|
|
1694
1708
|
inputKeyVals: t.map((r) => xt(r, m)),
|
|
1695
|
-
outputKeyVals: n.map((r) => xt(r,
|
|
1709
|
+
outputKeyVals: n.map((r) => xt(r, H))
|
|
1696
1710
|
};
|
|
1697
1711
|
}
|
|
1698
|
-
function
|
|
1712
|
+
function Os(e) {
|
|
1699
1713
|
const t = e[0], n = Rt(t), r = e.slice(1);
|
|
1700
1714
|
if (r.length === 0) throw new Error("Combine: Nothing to combine");
|
|
1701
|
-
const s =
|
|
1715
|
+
const s = ne(t);
|
|
1702
1716
|
if (s === void 0)
|
|
1703
1717
|
throw new Error("Combine: Self missing transaction");
|
|
1704
1718
|
const i = C(n.globalKeyVals), o = n.inputKeyVals.map(C), a = n.outputKeyVals.map(C);
|
|
1705
1719
|
for (const u of r) {
|
|
1706
|
-
const l =
|
|
1707
|
-
if (l === void 0 ||
|
|
1720
|
+
const l = ne(u);
|
|
1721
|
+
if (l === void 0 || N(l.toBuffer(), s.toBuffer()) !== 0)
|
|
1708
1722
|
throw new Error(
|
|
1709
1723
|
"Combine: One of the Psbts does not have the same transaction."
|
|
1710
1724
|
);
|
|
@@ -1733,7 +1747,7 @@ function _s(e) {
|
|
|
1733
1747
|
)
|
|
1734
1748
|
);
|
|
1735
1749
|
}
|
|
1736
|
-
return
|
|
1750
|
+
return Re(s, {
|
|
1737
1751
|
globalMapKeyVals: n.globalKeyVals,
|
|
1738
1752
|
inputKeyVals: n.inputKeyVals,
|
|
1739
1753
|
outputKeyVals: n.outputKeyVals
|
|
@@ -1746,7 +1760,7 @@ function _t(e, t, n) {
|
|
|
1746
1760
|
t.push(s), e.add(r);
|
|
1747
1761
|
};
|
|
1748
1762
|
}
|
|
1749
|
-
function
|
|
1763
|
+
function ne(e) {
|
|
1750
1764
|
return e.globalMap.unsignedTx;
|
|
1751
1765
|
}
|
|
1752
1766
|
function C(e) {
|
|
@@ -1773,7 +1787,7 @@ function Ut(e, t, n) {
|
|
|
1773
1787
|
throw new Error(
|
|
1774
1788
|
"Use the method for your specific key instead of addUnknownKeyVal*"
|
|
1775
1789
|
);
|
|
1776
|
-
if (t && t.filter((r) =>
|
|
1790
|
+
if (t && t.filter((r) => N(r.key, e.key) === 0).length !== 0)
|
|
1777
1791
|
throw new Error(`Duplicate Key: ${d(e.key)}`);
|
|
1778
1792
|
}
|
|
1779
1793
|
function Pt(e) {
|
|
@@ -1782,7 +1796,7 @@ function Pt(e) {
|
|
|
1782
1796
|
Number(isNaN(Number(n))) && t++;
|
|
1783
1797
|
}), t;
|
|
1784
1798
|
}
|
|
1785
|
-
function
|
|
1799
|
+
function Rs(e, t) {
|
|
1786
1800
|
let n = !1;
|
|
1787
1801
|
if (t.nonWitnessUtxo || t.witnessUtxo) {
|
|
1788
1802
|
const r = !!t.redeemScript, s = !!t.witnessScript, i = !r || !!t.finalScriptSig, o = !s || !!t.finalScriptWitness, a = !!t.finalScriptSig || !!t.finalScriptWitness;
|
|
@@ -1793,7 +1807,7 @@ function Us(e, t) {
|
|
|
1793
1807
|
`Input #${e} has too much or too little data to clean`
|
|
1794
1808
|
);
|
|
1795
1809
|
}
|
|
1796
|
-
function
|
|
1810
|
+
function re(e, t, n, r) {
|
|
1797
1811
|
throw new Error(
|
|
1798
1812
|
`Data for ${e} key ${t} is incorrect: Expected ${n} and got ${JSON.stringify(r)}`
|
|
1799
1813
|
);
|
|
@@ -1803,80 +1817,80 @@ function Dt(e) {
|
|
|
1803
1817
|
for (const r of Object.keys(t)) {
|
|
1804
1818
|
const s = t[r], { canAdd: i, canAddToArray: o, check: a, expected: u } = (
|
|
1805
1819
|
// @ts-ignore
|
|
1806
|
-
|
|
1820
|
+
_s[e + "s"][r] || {}
|
|
1807
1821
|
), l = !!o;
|
|
1808
1822
|
if (a)
|
|
1809
1823
|
if (l) {
|
|
1810
1824
|
if (!Array.isArray(s) || // @ts-ignore
|
|
1811
1825
|
n[r] && !Array.isArray(n[r]))
|
|
1812
1826
|
throw new Error(`Key type ${r} must be an array`);
|
|
1813
|
-
s.every(a) ||
|
|
1827
|
+
s.every(a) || re(e, r, u, s);
|
|
1814
1828
|
const f = n[r] || [], c = /* @__PURE__ */ new Set();
|
|
1815
1829
|
if (!s.every((h) => o(f, h, c)))
|
|
1816
1830
|
throw new Error("Can not add duplicate data to array");
|
|
1817
1831
|
n[r] = f.concat(s);
|
|
1818
1832
|
} else {
|
|
1819
|
-
if (a(s) ||
|
|
1833
|
+
if (a(s) || re(e, r, u, s), !i(n, s))
|
|
1820
1834
|
throw new Error(`Can not add duplicate data to ${e}`);
|
|
1821
1835
|
n[r] = s;
|
|
1822
1836
|
}
|
|
1823
1837
|
}
|
|
1824
1838
|
};
|
|
1825
1839
|
}
|
|
1826
|
-
const
|
|
1827
|
-
function
|
|
1840
|
+
const Ks = Dt("global"), Ke = Dt("input"), Ce = Dt("output");
|
|
1841
|
+
function Cs(e, t) {
|
|
1828
1842
|
const n = e.length - 1, r = T(e, n);
|
|
1829
|
-
|
|
1843
|
+
Ke(t, r);
|
|
1830
1844
|
}
|
|
1831
|
-
function
|
|
1845
|
+
function Fs(e, t) {
|
|
1832
1846
|
const n = e.length - 1, r = X(e, n);
|
|
1833
|
-
|
|
1847
|
+
Ce(t, r);
|
|
1834
1848
|
}
|
|
1835
|
-
let
|
|
1849
|
+
let se = class {
|
|
1836
1850
|
constructor(t) {
|
|
1837
1851
|
this.inputs = [], this.outputs = [], this.globalMap = {
|
|
1838
1852
|
unsignedTx: t
|
|
1839
1853
|
};
|
|
1840
1854
|
}
|
|
1841
1855
|
static fromBase64(t, n) {
|
|
1842
|
-
const r =
|
|
1856
|
+
const r = qn(t);
|
|
1843
1857
|
return this.fromBuffer(r, n);
|
|
1844
1858
|
}
|
|
1845
1859
|
static fromHex(t, n) {
|
|
1846
|
-
const r =
|
|
1860
|
+
const r = Xn(t);
|
|
1847
1861
|
return this.fromBuffer(r, n);
|
|
1848
1862
|
}
|
|
1849
1863
|
static fromBuffer(t, n) {
|
|
1850
|
-
const r =
|
|
1864
|
+
const r = Ps(t, n), s = new this(r.globalMap.unsignedTx);
|
|
1851
1865
|
return Object.assign(s, r), s;
|
|
1852
1866
|
}
|
|
1853
1867
|
toBase64() {
|
|
1854
1868
|
const t = this.toBuffer();
|
|
1855
|
-
return
|
|
1869
|
+
return Yn(t);
|
|
1856
1870
|
}
|
|
1857
1871
|
toHex() {
|
|
1858
1872
|
const t = this.toBuffer();
|
|
1859
1873
|
return d(t);
|
|
1860
1874
|
}
|
|
1861
1875
|
toBuffer() {
|
|
1862
|
-
return
|
|
1876
|
+
return Ns(this);
|
|
1863
1877
|
}
|
|
1864
1878
|
updateGlobal(t) {
|
|
1865
|
-
return
|
|
1879
|
+
return Ks(t, this.globalMap), this;
|
|
1866
1880
|
}
|
|
1867
1881
|
updateInput(t, n) {
|
|
1868
1882
|
const r = T(this.inputs, t);
|
|
1869
|
-
return
|
|
1883
|
+
return Ke(n, r), this;
|
|
1870
1884
|
}
|
|
1871
1885
|
updateOutput(t, n) {
|
|
1872
1886
|
const r = X(this.outputs, t);
|
|
1873
|
-
return
|
|
1887
|
+
return Ce(n, r), this;
|
|
1874
1888
|
}
|
|
1875
1889
|
addUnknownKeyValToGlobal(t) {
|
|
1876
1890
|
return Ut(
|
|
1877
1891
|
t,
|
|
1878
1892
|
this.globalMap.unknownKeyVals,
|
|
1879
|
-
Pt(
|
|
1893
|
+
Pt(U)
|
|
1880
1894
|
), this.globalMap.unknownKeyVals || (this.globalMap.unknownKeyVals = []), this.globalMap.unknownKeyVals.push(t), this;
|
|
1881
1895
|
}
|
|
1882
1896
|
addUnknownKeyValToInput(t, n) {
|
|
@@ -1896,7 +1910,7 @@ let re = class {
|
|
|
1896
1910
|
throw new Error("unknownKeyVals must be an Array");
|
|
1897
1911
|
return n.forEach(
|
|
1898
1912
|
(s) => this.addUnknownKeyValToInput(r, s)
|
|
1899
|
-
),
|
|
1913
|
+
), Cs(this.inputs, t), this;
|
|
1900
1914
|
}
|
|
1901
1915
|
addOutput(t) {
|
|
1902
1916
|
this.globalMap.unsignedTx.addOutput(t), this.outputs.push({
|
|
@@ -1907,11 +1921,11 @@ let re = class {
|
|
|
1907
1921
|
throw new Error("unknownKeyVals must be an Array");
|
|
1908
1922
|
return n.forEach(
|
|
1909
1923
|
(s) => this.addUnknownKeyValToOutput(r, s)
|
|
1910
|
-
),
|
|
1924
|
+
), Fs(this.outputs, t), this;
|
|
1911
1925
|
}
|
|
1912
1926
|
clearFinalizedInput(t) {
|
|
1913
1927
|
const n = T(this.inputs, t);
|
|
1914
|
-
|
|
1928
|
+
Rs(t, n);
|
|
1915
1929
|
for (const r of Object.keys(n))
|
|
1916
1930
|
[
|
|
1917
1931
|
"witnessUtxo",
|
|
@@ -1923,7 +1937,7 @@ let re = class {
|
|
|
1923
1937
|
return this;
|
|
1924
1938
|
}
|
|
1925
1939
|
combine(...t) {
|
|
1926
|
-
const n =
|
|
1940
|
+
const n = Os([this].concat(t));
|
|
1927
1941
|
return Object.assign(this, n), this;
|
|
1928
1942
|
}
|
|
1929
1943
|
getTransaction() {
|
|
@@ -1941,28 +1955,28 @@ function Nt(e) {
|
|
|
1941
1955
|
function Kt(e) {
|
|
1942
1956
|
return !!e.finalScriptSig || !!e.finalScriptWitness;
|
|
1943
1957
|
}
|
|
1944
|
-
function
|
|
1958
|
+
function Bs(e) {
|
|
1945
1959
|
if (!e.ins.every(
|
|
1946
1960
|
(n) => n.script && n.script.length === 0 && n.witness && n.witness.length === 0
|
|
1947
1961
|
))
|
|
1948
1962
|
throw new Error("Format Error: Transaction ScriptSigs are not empty");
|
|
1949
1963
|
}
|
|
1950
|
-
function
|
|
1964
|
+
function Fe(e, t) {
|
|
1951
1965
|
const n = st(new Uint8Array(t.hash)), r = `${B(n)}:${t.index}`;
|
|
1952
1966
|
if (e.txInCache[r]) throw new Error("Duplicate input detected.");
|
|
1953
1967
|
e.txInCache[r] = 1;
|
|
1954
1968
|
}
|
|
1955
|
-
function
|
|
1969
|
+
function Ws(e, t) {
|
|
1956
1970
|
e.ins.forEach((n) => {
|
|
1957
|
-
|
|
1971
|
+
Fe(t, n);
|
|
1958
1972
|
});
|
|
1959
1973
|
}
|
|
1960
1974
|
function $(e, t, n) {
|
|
1961
1975
|
n !== !1 && e.forEach((r) => {
|
|
1962
|
-
if (
|
|
1976
|
+
if (O(r) ? gn(r, t) : yn(r, t)) throw new Error("Can not modify transaction, signatures exist.");
|
|
1963
1977
|
});
|
|
1964
1978
|
}
|
|
1965
|
-
function
|
|
1979
|
+
function $s(e) {
|
|
1966
1980
|
if (!e.sighashType || !e.partialSig) return;
|
|
1967
1981
|
const { partialSig: t, sighashType: n } = e;
|
|
1968
1982
|
t.forEach((r) => {
|
|
@@ -1971,11 +1985,11 @@ function Ks(e) {
|
|
|
1971
1985
|
throw new Error("Signature sighash does not match input sighash type");
|
|
1972
1986
|
});
|
|
1973
1987
|
}
|
|
1974
|
-
function
|
|
1988
|
+
function Be(e, t, n) {
|
|
1975
1989
|
if (!it(e, t))
|
|
1976
1990
|
throw new Error(`Can not ${n} for this input with the key ${B(e)}`);
|
|
1977
1991
|
}
|
|
1978
|
-
function
|
|
1992
|
+
function We(e, t) {
|
|
1979
1993
|
return (n, r, s, i) => {
|
|
1980
1994
|
const o = e({
|
|
1981
1995
|
redeem: { output: s }
|
|
@@ -1986,8 +2000,8 @@ function Fe(e, t) {
|
|
|
1986
2000
|
);
|
|
1987
2001
|
};
|
|
1988
2002
|
}
|
|
1989
|
-
const
|
|
1990
|
-
function
|
|
2003
|
+
const ie = We(gt, "Redeem script"), oe = We(yt, "Witness script");
|
|
2004
|
+
function ae(e) {
|
|
1991
2005
|
let t = 0;
|
|
1992
2006
|
function n(o) {
|
|
1993
2007
|
return t += o, e.subarray(t - o, t);
|
|
@@ -2006,7 +2020,7 @@ function oe(e) {
|
|
|
2006
2020
|
}
|
|
2007
2021
|
return i();
|
|
2008
2022
|
}
|
|
2009
|
-
function
|
|
2023
|
+
function Ls(e) {
|
|
2010
2024
|
let t = e & b.SIGHASH_ANYONECANPAY ? "SIGHASH_ANYONECANPAY | " : "";
|
|
2011
2025
|
switch (e & 31) {
|
|
2012
2026
|
case b.SIGHASH_ALL:
|
|
@@ -2021,31 +2035,31 @@ function Cs(e) {
|
|
|
2021
2035
|
}
|
|
2022
2036
|
return t;
|
|
2023
2037
|
}
|
|
2024
|
-
function
|
|
2038
|
+
function Ms(e) {
|
|
2025
2039
|
if (e.length === 65) {
|
|
2026
2040
|
const t = e[64] & 1, n = new Uint8Array(e.subarray(0, 33));
|
|
2027
2041
|
return n[0] = 2 | t, n;
|
|
2028
2042
|
}
|
|
2029
2043
|
return new Uint8Array(e);
|
|
2030
2044
|
}
|
|
2031
|
-
function
|
|
2032
|
-
return e.length === 33 &&
|
|
2045
|
+
function ce(e) {
|
|
2046
|
+
return e.length === 33 && mn(e);
|
|
2033
2047
|
}
|
|
2034
|
-
function
|
|
2035
|
-
return
|
|
2048
|
+
function Ds(e) {
|
|
2049
|
+
return bn(e);
|
|
2036
2050
|
}
|
|
2037
2051
|
function Gt(e) {
|
|
2038
|
-
return Et(e) ? "witnesspubkeyhash" :
|
|
2052
|
+
return Et(e) ? "witnesspubkeyhash" : wn(e) ? "pubkeyhash" : Sn(e) ? "multisig" : En(e) ? "pubkey" : "nonstandard";
|
|
2039
2053
|
}
|
|
2040
2054
|
function L(e) {
|
|
2041
2055
|
return [...Array(e).keys()];
|
|
2042
2056
|
}
|
|
2043
2057
|
function ft(e) {
|
|
2044
|
-
if (Et(e) ||
|
|
2058
|
+
if (Et(e) || Se(e))
|
|
2045
2059
|
throw new Error("P2WPKH or P2SH can not be contained within P2WSH");
|
|
2046
2060
|
}
|
|
2047
2061
|
function pt(e, t, n, r, s) {
|
|
2048
|
-
const i =
|
|
2062
|
+
const i = Se(e), o = i && r && jt(r), a = jt(e);
|
|
2049
2063
|
if (i && r === void 0)
|
|
2050
2064
|
throw new Error("scriptPubkey is P2SH but redeemScript missing");
|
|
2051
2065
|
let u;
|
|
@@ -2053,14 +2067,14 @@ function pt(e, t, n, r, s) {
|
|
|
2053
2067
|
if (!s)
|
|
2054
2068
|
throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
|
|
2055
2069
|
if (!r) throw new Error("P2SH-P2WSH requires redeemScript");
|
|
2056
|
-
u = s,
|
|
2070
|
+
u = s, ie(t, e, r, n), oe(t, r, s, n), ft(u);
|
|
2057
2071
|
} else if (a) {
|
|
2058
2072
|
if (!s)
|
|
2059
2073
|
throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");
|
|
2060
|
-
u = s,
|
|
2074
|
+
u = s, oe(t, e, s, n), ft(u);
|
|
2061
2075
|
} else if (i) {
|
|
2062
2076
|
if (!r) throw new Error("P2SH requires redeemScript");
|
|
2063
|
-
u = r,
|
|
2077
|
+
u = r, ie(t, e, r, n);
|
|
2064
2078
|
} else
|
|
2065
2079
|
u = e;
|
|
2066
2080
|
return {
|
|
@@ -2068,7 +2082,7 @@ function pt(e, t, n, r, s) {
|
|
|
2068
2082
|
type: o ? "p2sh-p2wsh" : i ? "p2sh" : a ? "p2wsh" : "raw"
|
|
2069
2083
|
};
|
|
2070
2084
|
}
|
|
2071
|
-
class
|
|
2085
|
+
class Gs {
|
|
2072
2086
|
nonWitnessUtxoTxCache;
|
|
2073
2087
|
nonWitnessUtxoBufCache;
|
|
2074
2088
|
txInCache;
|
|
@@ -2182,13 +2196,13 @@ class Ws {
|
|
|
2182
2196
|
const n = D(t);
|
|
2183
2197
|
if (!n) return;
|
|
2184
2198
|
const r = n[n.length - 1];
|
|
2185
|
-
if (!(!(r instanceof Uint8Array) ||
|
|
2199
|
+
if (!(!(r instanceof Uint8Array) || ce(r) || Ds(r) || !D(r)))
|
|
2186
2200
|
return r;
|
|
2187
2201
|
}
|
|
2188
2202
|
redeemFromFinalWitnessScript(t) {
|
|
2189
2203
|
if (!t) return;
|
|
2190
|
-
const n =
|
|
2191
|
-
if (!(!r ||
|
|
2204
|
+
const n = ae(t), r = n[n.length - 1];
|
|
2205
|
+
if (!(!r || ce(r) || !D(r)))
|
|
2192
2206
|
return r;
|
|
2193
2207
|
}
|
|
2194
2208
|
/**
|
|
@@ -2199,7 +2213,7 @@ class Ws {
|
|
|
2199
2213
|
let o = 0n;
|
|
2200
2214
|
t.forEach((h, S) => {
|
|
2201
2215
|
const g = n.ins[S];
|
|
2202
|
-
if (r && h.finalScriptSig && (g.script = h.finalScriptSig), r && h.finalScriptWitness && (g.witness =
|
|
2216
|
+
if (r && h.finalScriptSig && (g.script = h.finalScriptSig), r && h.finalScriptWitness && (g.witness = ae(h.finalScriptWitness)), h.witnessUtxo)
|
|
2203
2217
|
o += h.witnessUtxo.value;
|
|
2204
2218
|
else if (h.nonWitnessUtxo) {
|
|
2205
2219
|
if (!i)
|
|
@@ -2231,14 +2245,14 @@ class Ws {
|
|
|
2231
2245
|
const i = this.getNonWitnessUtxoTx(n, t, r), o = this.tx.ins[t].index;
|
|
2232
2246
|
s.script = i.outs[o].script;
|
|
2233
2247
|
} else n.witnessUtxo && (s.script = n.witnessUtxo.script);
|
|
2234
|
-
return (n.witnessScript || s.script && Et(s.script) || s.script &&
|
|
2248
|
+
return (n.witnessScript || s.script && Et(s.script) || s.script && me(s.script)) && (s.isSegwit = !0), s;
|
|
2235
2249
|
}
|
|
2236
2250
|
getPrevoutTaprootKey(t, n, r) {
|
|
2237
2251
|
const { script: s } = this.getScriptAndAmountFromUtxo(t, n, r);
|
|
2238
|
-
return
|
|
2252
|
+
return Tn(s) ? s.subarray(2, 34) : null;
|
|
2239
2253
|
}
|
|
2240
2254
|
}
|
|
2241
|
-
class
|
|
2255
|
+
class Vs {
|
|
2242
2256
|
#t;
|
|
2243
2257
|
#e;
|
|
2244
2258
|
constructor(t, n) {
|
|
@@ -2251,11 +2265,11 @@ class $s {
|
|
|
2251
2265
|
!1,
|
|
2252
2266
|
s
|
|
2253
2267
|
);
|
|
2254
|
-
return
|
|
2268
|
+
return Be(r, u, "sign"), { hash: o, sighashType: a };
|
|
2255
2269
|
}
|
|
2256
2270
|
getHashForSig(t, n, r, s) {
|
|
2257
2271
|
const i = this.#t.tx, o = n.sighashType || b.SIGHASH_ALL;
|
|
2258
|
-
|
|
2272
|
+
ue(o, s);
|
|
2259
2273
|
let a, u;
|
|
2260
2274
|
if (n.nonWitnessUtxo) {
|
|
2261
2275
|
const h = this.#t.getNonWitnessUtxoTx(
|
|
@@ -2312,7 +2326,7 @@ PROCEED WITH CAUTION!
|
|
|
2312
2326
|
}
|
|
2313
2327
|
getTaprootHashesForSig(t, n, r, s, i, o) {
|
|
2314
2328
|
const a = this.#t.tx, u = n.sighashType || b.SIGHASH_DEFAULT;
|
|
2315
|
-
if (
|
|
2329
|
+
if (ue(u, o), !this.#t.prevOuts) {
|
|
2316
2330
|
const g = r.map(
|
|
2317
2331
|
(y, w) => this.#t.getScriptAndAmountFromUtxo(w, y, this.#e)
|
|
2318
2332
|
);
|
|
@@ -2337,7 +2351,7 @@ PROCEED WITH CAUTION!
|
|
|
2337
2351
|
}
|
|
2338
2352
|
}
|
|
2339
2353
|
const S = (n.tapLeafScript || []).filter((g) => it(s, g.script)).map((g) => {
|
|
2340
|
-
const y =
|
|
2354
|
+
const y = we({
|
|
2341
2355
|
output: g.script,
|
|
2342
2356
|
version: g.leafVersion
|
|
2343
2357
|
});
|
|
@@ -2405,15 +2419,15 @@ PROCEED WITH CAUTION!
|
|
|
2405
2419
|
};
|
|
2406
2420
|
}
|
|
2407
2421
|
}
|
|
2408
|
-
function
|
|
2422
|
+
function ue(e, t) {
|
|
2409
2423
|
if (t && !t.includes(e)) {
|
|
2410
|
-
const n =
|
|
2424
|
+
const n = Ls(e);
|
|
2411
2425
|
throw new Error(
|
|
2412
2426
|
`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${n}`
|
|
2413
2427
|
);
|
|
2414
2428
|
}
|
|
2415
2429
|
}
|
|
2416
|
-
class
|
|
2430
|
+
class zs {
|
|
2417
2431
|
#t;
|
|
2418
2432
|
#e;
|
|
2419
2433
|
constructor(t, n) {
|
|
@@ -2421,7 +2435,7 @@ class Ls {
|
|
|
2421
2435
|
}
|
|
2422
2436
|
getFinalScripts(t, n, r, s, i, o, a = !0, u) {
|
|
2423
2437
|
const l = Gt(r);
|
|
2424
|
-
if (
|
|
2438
|
+
if (!$e(n, r, l) && a)
|
|
2425
2439
|
throw new Error(`Can not finalize input #${t}`);
|
|
2426
2440
|
if (!n.partialSig) throw new Error("Input missing partial signatures");
|
|
2427
2441
|
return Vt(
|
|
@@ -2438,9 +2452,9 @@ class Ls {
|
|
|
2438
2452
|
return this.#t.getScriptFromInput(t, n, this.#e);
|
|
2439
2453
|
}
|
|
2440
2454
|
}
|
|
2441
|
-
function
|
|
2455
|
+
function js(e, t, n, r, s, i, o = !0, a) {
|
|
2442
2456
|
const u = Gt(n);
|
|
2443
|
-
if (
|
|
2457
|
+
if (!$e(t, n, u) && o)
|
|
2444
2458
|
throw new Error(`Can not finalize input #${e}`);
|
|
2445
2459
|
if (!t.partialSig) throw new Error("Input missing partial signatures");
|
|
2446
2460
|
return Vt(
|
|
@@ -2455,21 +2469,21 @@ function Ms(e, t, n, r, s, i, o = !0, a) {
|
|
|
2455
2469
|
}
|
|
2456
2470
|
function Vt(e, t, n, r, s, i, o) {
|
|
2457
2471
|
let a, u;
|
|
2458
|
-
const l =
|
|
2472
|
+
const l = Xs(e, t, n), f = i ? yt({ redeem: l }) : null, c = s ? gt({ redeem: f || l }) : null;
|
|
2459
2473
|
return r ? (f && f.witness ? u = rt(f.witness) : l && l.witness ? u = rt(l.witness) : u = rt(o ?? [new Uint8Array([0])]), c && (a = c?.input)) : c ? a = c?.input : l ? a = l.input : a = Array.isArray(o) && o[0] ? o[0] : new Uint8Array([1]), { finalScriptSig: a, finalScriptWitness: u };
|
|
2460
2474
|
}
|
|
2461
|
-
function
|
|
2475
|
+
function $e(e, t, n) {
|
|
2462
2476
|
switch (n) {
|
|
2463
2477
|
case "pubkey":
|
|
2464
2478
|
case "pubkeyhash":
|
|
2465
2479
|
case "witnesspubkeyhash":
|
|
2466
|
-
return
|
|
2480
|
+
return he(1, e.partialSig);
|
|
2467
2481
|
case "multisig": {
|
|
2468
2482
|
const r = wt({
|
|
2469
2483
|
output: t
|
|
2470
2484
|
});
|
|
2471
2485
|
if (r.m === void 0) throw new Error("Cannot determine m for multisig");
|
|
2472
|
-
return
|
|
2486
|
+
return he(r.m, e.partialSig, r.pubkeys);
|
|
2473
2487
|
}
|
|
2474
2488
|
case "nonstandard":
|
|
2475
2489
|
return !0;
|
|
@@ -2477,20 +2491,20 @@ function Be(e, t, n) {
|
|
|
2477
2491
|
return !1;
|
|
2478
2492
|
}
|
|
2479
2493
|
}
|
|
2480
|
-
function
|
|
2494
|
+
function he(e, t, n) {
|
|
2481
2495
|
if (!t) return !1;
|
|
2482
2496
|
let r;
|
|
2483
2497
|
if (n ? r = n.map((s) => {
|
|
2484
|
-
const i =
|
|
2498
|
+
const i = Ms(s);
|
|
2485
2499
|
return t.find((o) => k(o.pubkey, i));
|
|
2486
2500
|
}).filter((s) => !!s) : r = t, r.length > e) throw new Error("Too many signatures");
|
|
2487
2501
|
return r.length === e;
|
|
2488
2502
|
}
|
|
2489
|
-
function
|
|
2503
|
+
function Xs(e, t, n) {
|
|
2490
2504
|
const r = e;
|
|
2491
2505
|
switch (t) {
|
|
2492
2506
|
case "multisig": {
|
|
2493
|
-
const s =
|
|
2507
|
+
const s = Ys(e, n);
|
|
2494
2508
|
return wt({
|
|
2495
2509
|
output: r,
|
|
2496
2510
|
signatures: s
|
|
@@ -2498,7 +2512,7 @@ function Ds(e, t, n) {
|
|
|
2498
2512
|
}
|
|
2499
2513
|
case "pubkey": {
|
|
2500
2514
|
const s = n[0];
|
|
2501
|
-
return
|
|
2515
|
+
return ye({
|
|
2502
2516
|
output: r,
|
|
2503
2517
|
signature: s.signature
|
|
2504
2518
|
});
|
|
@@ -2523,7 +2537,7 @@ function Ds(e, t, n) {
|
|
|
2523
2537
|
throw new Error(`Unknown script type: ${t}`);
|
|
2524
2538
|
}
|
|
2525
2539
|
}
|
|
2526
|
-
function
|
|
2540
|
+
function Ys(e, t) {
|
|
2527
2541
|
const n = wt({ output: e });
|
|
2528
2542
|
if (!n.pubkeys) throw new Error("Cannot extract pubkeys from multisig script");
|
|
2529
2543
|
const r = [];
|
|
@@ -2533,11 +2547,11 @@ function Gs(e, t) {
|
|
|
2533
2547
|
}
|
|
2534
2548
|
return r;
|
|
2535
2549
|
}
|
|
2536
|
-
const
|
|
2537
|
-
class
|
|
2550
|
+
const qs = new Uint8Array([2, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
2551
|
+
class Le {
|
|
2538
2552
|
tx;
|
|
2539
|
-
constructor(t =
|
|
2540
|
-
this.tx = b.fromBuffer(t),
|
|
2553
|
+
constructor(t = qs) {
|
|
2554
|
+
this.tx = b.fromBuffer(t), Bs(this.tx), Object.defineProperty(this, "tx", {
|
|
2541
2555
|
enumerable: !1,
|
|
2542
2556
|
writable: !0
|
|
2543
2557
|
});
|
|
@@ -2563,15 +2577,15 @@ class We {
|
|
|
2563
2577
|
return this.tx.toBuffer();
|
|
2564
2578
|
}
|
|
2565
2579
|
}
|
|
2566
|
-
const
|
|
2580
|
+
const Zs = (e) => new Le(e), Js = {
|
|
2567
2581
|
network: G,
|
|
2568
2582
|
maximumFeeRate: 5e3
|
|
2569
2583
|
};
|
|
2570
2584
|
function x(e) {
|
|
2571
2585
|
return b.fromBuffer(e);
|
|
2572
2586
|
}
|
|
2573
|
-
function
|
|
2574
|
-
return
|
|
2587
|
+
function Qs(e, t, n, r, s, i, o = !0, a) {
|
|
2588
|
+
return js(
|
|
2575
2589
|
e,
|
|
2576
2590
|
t,
|
|
2577
2591
|
n,
|
|
@@ -2582,7 +2596,7 @@ function Xs(e, t, n, r, s, i, o = !0, a) {
|
|
|
2582
2596
|
a
|
|
2583
2597
|
);
|
|
2584
2598
|
}
|
|
2585
|
-
function
|
|
2599
|
+
function ri(e, t, n, r, s, i, o) {
|
|
2586
2600
|
return Vt(
|
|
2587
2601
|
e,
|
|
2588
2602
|
t,
|
|
@@ -2594,10 +2608,10 @@ function Js(e, t, n, r, s, i, o) {
|
|
|
2594
2608
|
);
|
|
2595
2609
|
}
|
|
2596
2610
|
class Ct {
|
|
2597
|
-
constructor(t = {}, n = new
|
|
2598
|
-
this.data = n, this.#n = Object.assign({},
|
|
2611
|
+
constructor(t = {}, n = new se(new Le())) {
|
|
2612
|
+
this.data = n, this.#n = Object.assign({}, Js, t);
|
|
2599
2613
|
const r = this.data.globalMap.unsignedTx.tx;
|
|
2600
|
-
this.#t = new
|
|
2614
|
+
this.#t = new Gs(r), t.version === 3 ? this.setVersionTRUC() : this.data.inputs.length === 0 && this.setVersion(2);
|
|
2601
2615
|
}
|
|
2602
2616
|
#t;
|
|
2603
2617
|
#e;
|
|
@@ -2620,7 +2634,7 @@ class Ct {
|
|
|
2620
2634
|
}
|
|
2621
2635
|
get txInputs() {
|
|
2622
2636
|
return this.#t.tx.ins.map((t) => ({
|
|
2623
|
-
hash:
|
|
2637
|
+
hash: Xt(t.hash),
|
|
2624
2638
|
index: t.index,
|
|
2625
2639
|
sequence: t.sequence
|
|
2626
2640
|
}));
|
|
@@ -2629,11 +2643,11 @@ class Ct {
|
|
|
2629
2643
|
return this.#t.tx.outs.map((t) => {
|
|
2630
2644
|
let n;
|
|
2631
2645
|
try {
|
|
2632
|
-
n =
|
|
2646
|
+
n = Ie(t.script, this.#n.network);
|
|
2633
2647
|
} catch {
|
|
2634
2648
|
}
|
|
2635
2649
|
return {
|
|
2636
|
-
script:
|
|
2650
|
+
script: Xt(t.script),
|
|
2637
2651
|
value: t.value,
|
|
2638
2652
|
address: n
|
|
2639
2653
|
};
|
|
@@ -2641,14 +2655,14 @@ class Ct {
|
|
|
2641
2655
|
}
|
|
2642
2656
|
/** Lazily initialized signer - created on first access */
|
|
2643
2657
|
get #r() {
|
|
2644
|
-
return this.#e || (this.#e = new
|
|
2658
|
+
return this.#e || (this.#e = new Vs(this.#t, x)), this.#e;
|
|
2645
2659
|
}
|
|
2646
2660
|
/** Lazily initialized finalizer - created on first access */
|
|
2647
2661
|
get #o() {
|
|
2648
|
-
return this.#s || (this.#s = new
|
|
2662
|
+
return this.#s || (this.#s = new zs(this.#t, x)), this.#s;
|
|
2649
2663
|
}
|
|
2650
2664
|
static fromBase64(t, n = {}) {
|
|
2651
|
-
const r =
|
|
2665
|
+
const r = _n(t);
|
|
2652
2666
|
return this.fromBuffer(r, n);
|
|
2653
2667
|
}
|
|
2654
2668
|
static fromHex(t, n = {}) {
|
|
@@ -2656,8 +2670,8 @@ class Ct {
|
|
|
2656
2670
|
return this.fromBuffer(r, n);
|
|
2657
2671
|
}
|
|
2658
2672
|
static fromBuffer(t, n = {}) {
|
|
2659
|
-
const r =
|
|
2660
|
-
return
|
|
2673
|
+
const r = se.fromBuffer(t, Zs), s = new Ct(n, r);
|
|
2674
|
+
return Ws(s.#t.tx, s.#t), s.#t.hasSignatures = s.data.inputs.some(
|
|
2661
2675
|
(i) => i.partialSig?.length || i.tapKeySig || i.tapScriptSig?.length || i.finalScriptSig || i.finalScriptWitness
|
|
2662
2676
|
), s;
|
|
2663
2677
|
}
|
|
@@ -2696,7 +2710,7 @@ class Ct {
|
|
|
2696
2710
|
throw new Error(
|
|
2697
2711
|
"Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]"
|
|
2698
2712
|
);
|
|
2699
|
-
|
|
2713
|
+
Yt(t, t, "addInput"), n && $(this.data.inputs, "addInput", this.#t.hasSignatures), t.witnessScript && ft(t.witnessScript);
|
|
2700
2714
|
const r = t.witnessUtxo ? {
|
|
2701
2715
|
...t,
|
|
2702
2716
|
witnessUtxo: {
|
|
@@ -2706,7 +2720,7 @@ class Ct {
|
|
|
2706
2720
|
} : t;
|
|
2707
2721
|
this.data.addInput(r);
|
|
2708
2722
|
const s = this.#t.tx.ins[this.#t.tx.ins.length - 1];
|
|
2709
|
-
|
|
2723
|
+
Fe(this.#t, s);
|
|
2710
2724
|
const i = this.data.inputs.length - 1, o = this.data.inputs[i];
|
|
2711
2725
|
return o.nonWitnessUtxo && this.#t.addNonWitnessTxCache(o, i, x), this.#t.invalidate("full"), this;
|
|
2712
2726
|
}
|
|
@@ -2720,10 +2734,10 @@ class Ct {
|
|
|
2720
2734
|
"Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]"
|
|
2721
2735
|
);
|
|
2722
2736
|
if (n && $(this.data.inputs, "addOutput", this.#t.hasSignatures), r) {
|
|
2723
|
-
const { address: i } = t, { network: o } = this.#n, a =
|
|
2737
|
+
const { address: i } = t, { network: o } = this.#n, a = ke(i, o);
|
|
2724
2738
|
t = Object.assign({}, t, { script: a });
|
|
2725
2739
|
}
|
|
2726
|
-
return
|
|
2740
|
+
return qt(t, t, "addOutput"), this.data.addOutput(t), this.#t.invalidate("outputs"), this;
|
|
2727
2741
|
}
|
|
2728
2742
|
extractTransaction(t, n) {
|
|
2729
2743
|
if (n && (this.data.inputs = this.data.inputs.filter(
|
|
@@ -2750,7 +2764,7 @@ class Ct {
|
|
|
2750
2764
|
}
|
|
2751
2765
|
finalizeInput(t, n, r) {
|
|
2752
2766
|
const s = T(this.data.inputs, t);
|
|
2753
|
-
return
|
|
2767
|
+
return O(s) ? this.#i(
|
|
2754
2768
|
t,
|
|
2755
2769
|
s,
|
|
2756
2770
|
void 0,
|
|
@@ -2762,9 +2776,9 @@ class Ct {
|
|
|
2762
2776
|
r ?? !0
|
|
2763
2777
|
);
|
|
2764
2778
|
}
|
|
2765
|
-
finalizeTaprootInput(t, n, r =
|
|
2779
|
+
finalizeTaprootInput(t, n, r = Zt) {
|
|
2766
2780
|
const s = T(this.data.inputs, t);
|
|
2767
|
-
if (
|
|
2781
|
+
if (O(s))
|
|
2768
2782
|
return this.#i(
|
|
2769
2783
|
t,
|
|
2770
2784
|
s,
|
|
@@ -2806,7 +2820,7 @@ class Ct {
|
|
|
2806
2820
|
}
|
|
2807
2821
|
validateSignaturesOfInput(t, n, r) {
|
|
2808
2822
|
const s = this.data.inputs[t];
|
|
2809
|
-
return
|
|
2823
|
+
return O(s) ? this.#u(t, n, r) : this.#c(t, n, r);
|
|
2810
2824
|
}
|
|
2811
2825
|
signAllInputsHD(t, n = [b.SIGHASH_ALL]) {
|
|
2812
2826
|
if (!t || !t.publicKey || !t.fingerprint)
|
|
@@ -2887,13 +2901,13 @@ class Ct {
|
|
|
2887
2901
|
if (!n || !n.publicKey)
|
|
2888
2902
|
throw new Error("Need Signer to sign input");
|
|
2889
2903
|
const s = T(this.data.inputs, t);
|
|
2890
|
-
return
|
|
2904
|
+
return O(s) ? this.#l(t, s, n, void 0, r) : this.#h(t, n, r);
|
|
2891
2905
|
}
|
|
2892
2906
|
signTaprootInput(t, n, r, s) {
|
|
2893
2907
|
if (!n || !n.publicKey)
|
|
2894
2908
|
throw new Error("Need Signer to sign input");
|
|
2895
2909
|
const i = T(this.data.inputs, t);
|
|
2896
|
-
if (
|
|
2910
|
+
if (O(i))
|
|
2897
2911
|
return this.#l(
|
|
2898
2912
|
t,
|
|
2899
2913
|
i,
|
|
@@ -2906,7 +2920,7 @@ class Ct {
|
|
|
2906
2920
|
async signInputAsync(t, n, r) {
|
|
2907
2921
|
if (!n || !n.publicKey) throw new Error("Need Signer to sign input");
|
|
2908
2922
|
const s = T(this.data.inputs, t);
|
|
2909
|
-
return
|
|
2923
|
+
return O(s) ? this.#f(
|
|
2910
2924
|
t,
|
|
2911
2925
|
s,
|
|
2912
2926
|
n,
|
|
@@ -2917,7 +2931,7 @@ class Ct {
|
|
|
2917
2931
|
async signTaprootInputAsync(t, n, r, s) {
|
|
2918
2932
|
if (!n || !n.publicKey) throw new Error("Need Signer to sign input");
|
|
2919
2933
|
const i = T(this.data.inputs, t);
|
|
2920
|
-
if (
|
|
2934
|
+
if (O(i))
|
|
2921
2935
|
return this.#f(
|
|
2922
2936
|
t,
|
|
2923
2937
|
i,
|
|
@@ -2940,7 +2954,7 @@ class Ct {
|
|
|
2940
2954
|
return this.data.updateGlobal(t), this;
|
|
2941
2955
|
}
|
|
2942
2956
|
updateInput(t, n) {
|
|
2943
|
-
n.witnessScript && ft(n.witnessScript),
|
|
2957
|
+
n.witnessScript && ft(n.witnessScript), Yt(this.data.inputs[t], n, "updateInput");
|
|
2944
2958
|
const r = n.witnessUtxo ? {
|
|
2945
2959
|
...n,
|
|
2946
2960
|
witnessUtxo: {
|
|
@@ -2956,7 +2970,7 @@ class Ct {
|
|
|
2956
2970
|
}
|
|
2957
2971
|
updateOutput(t, n) {
|
|
2958
2972
|
const r = this.data.outputs[t];
|
|
2959
|
-
return
|
|
2973
|
+
return qt(r, n, "updateOutput"), this.data.updateOutput(t, n), this;
|
|
2960
2974
|
}
|
|
2961
2975
|
addUnknownKeyValToGlobal(t) {
|
|
2962
2976
|
return this.data.addUnknownKeyValToGlobal(t), this;
|
|
@@ -2985,13 +2999,13 @@ class Ct {
|
|
|
2985
2999
|
throw new Error(`Can not sign for input #${t} with the key ${B(o)}`);
|
|
2986
3000
|
return a;
|
|
2987
3001
|
}
|
|
2988
|
-
#a(t, n, r =
|
|
3002
|
+
#a(t, n, r = Qs, s = !0) {
|
|
2989
3003
|
const { script: i, isP2SH: o, isP2WSH: a, isSegwit: u } = this.#o.getScriptFromInput(
|
|
2990
3004
|
t,
|
|
2991
3005
|
n
|
|
2992
3006
|
);
|
|
2993
3007
|
if (!i) throw new Error(`No script found for input #${t}`);
|
|
2994
|
-
|
|
3008
|
+
$s(n);
|
|
2995
3009
|
const { finalScriptSig: l, finalScriptWitness: f } = r(
|
|
2996
3010
|
t,
|
|
2997
3011
|
n,
|
|
@@ -3005,10 +3019,10 @@ class Ct {
|
|
|
3005
3019
|
throw new Error(`Unknown error finalizing input #${t}`);
|
|
3006
3020
|
return this.data.clearFinalizedInput(t), this;
|
|
3007
3021
|
}
|
|
3008
|
-
#i(t, n, r, s =
|
|
3022
|
+
#i(t, n, r, s = Zt) {
|
|
3009
3023
|
if (!n.witnessUtxo)
|
|
3010
3024
|
throw new Error(`Cannot finalize input #${t}. Missing witness utxo.`);
|
|
3011
|
-
if (n.tapKeySig) {
|
|
3025
|
+
if (n.tapKeySig && !An(n)) {
|
|
3012
3026
|
const i = Bt({
|
|
3013
3027
|
output: n.witnessUtxo.script,
|
|
3014
3028
|
signature: n.tapKeySig
|
|
@@ -3044,7 +3058,7 @@ class Ct {
|
|
|
3044
3058
|
}),
|
|
3045
3059
|
!0
|
|
3046
3060
|
) : { hash: u, script: l };
|
|
3047
|
-
f = g.hashType, u = y, l = w,
|
|
3061
|
+
f = g.hashType, u = y, l = w, Be(S, w, "verify"), a.push(n(S, y, g.signature));
|
|
3048
3062
|
}
|
|
3049
3063
|
return a.every((c) => c);
|
|
3050
3064
|
}
|
|
@@ -3168,153 +3182,157 @@ class Ct {
|
|
|
3168
3182
|
}
|
|
3169
3183
|
}
|
|
3170
3184
|
}
|
|
3171
|
-
const
|
|
3185
|
+
const si = {
|
|
3172
3186
|
BitcoinError: v,
|
|
3173
|
-
ValidationError:
|
|
3174
|
-
InvalidInputError:
|
|
3175
|
-
InvalidOutputError:
|
|
3176
|
-
ScriptError:
|
|
3177
|
-
PsbtError:
|
|
3178
|
-
EccError:
|
|
3179
|
-
AddressError:
|
|
3180
|
-
SignatureError:
|
|
3181
|
-
},
|
|
3182
|
-
networks:
|
|
3183
|
-
address:
|
|
3184
|
-
payments:
|
|
3185
|
-
script:
|
|
3186
|
-
crypto:
|
|
3187
|
-
Transaction:
|
|
3187
|
+
ValidationError: On,
|
|
3188
|
+
InvalidInputError: Rn,
|
|
3189
|
+
InvalidOutputError: Kn,
|
|
3190
|
+
ScriptError: Cn,
|
|
3191
|
+
PsbtError: Fn,
|
|
3192
|
+
EccError: Bn,
|
|
3193
|
+
AddressError: Wn,
|
|
3194
|
+
SignatureError: $n
|
|
3195
|
+
}, ii = {
|
|
3196
|
+
networks: xn,
|
|
3197
|
+
address: Pn,
|
|
3198
|
+
payments: Hn,
|
|
3199
|
+
script: vn,
|
|
3200
|
+
crypto: kn,
|
|
3201
|
+
Transaction: In
|
|
3188
3202
|
};
|
|
3189
3203
|
export {
|
|
3190
|
-
|
|
3204
|
+
Wn as AddressError,
|
|
3191
3205
|
v as BitcoinError,
|
|
3192
3206
|
F as Block,
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3207
|
+
ci as EccContext,
|
|
3208
|
+
Bn as EccError,
|
|
3209
|
+
Ee as FUTURE_MAX_VERSION,
|
|
3196
3210
|
ot as FUTURE_OPNET_VERSION,
|
|
3197
3211
|
q as FUTURE_SEGWIT_MAX_SIZE,
|
|
3198
3212
|
J as FUTURE_SEGWIT_MAX_VERSION,
|
|
3199
3213
|
Z as FUTURE_SEGWIT_MIN_SIZE,
|
|
3200
3214
|
mt as FUTURE_SEGWIT_MIN_VERSION,
|
|
3201
3215
|
bt as FUTURE_SEGWIT_VERSION_DIFF,
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3216
|
+
Rn as InvalidInputError,
|
|
3217
|
+
Kn as InvalidOutputError,
|
|
3218
|
+
Ye as LEAF_VERSION_TAPSCRIPT,
|
|
3219
|
+
qe as MAX_TAPTREE_DEPTH,
|
|
3206
3220
|
Ht as PaymentType,
|
|
3207
3221
|
Ct as Psbt,
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3222
|
+
Gs as PsbtCache,
|
|
3223
|
+
Fn as PsbtError,
|
|
3224
|
+
zs as PsbtFinalizer,
|
|
3225
|
+
Vs as PsbtSigner,
|
|
3226
|
+
Le as PsbtTransaction,
|
|
3227
|
+
Cn as ScriptError,
|
|
3228
|
+
$n as SignatureError,
|
|
3229
|
+
ui as SignatureType,
|
|
3230
|
+
hi as TAGGED_HASH_PREFIXES,
|
|
3231
|
+
li as TAGS,
|
|
3232
|
+
fi as TAPLEAF_VERSION_MASK,
|
|
3219
3233
|
b as Transaction,
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3234
|
+
On as ValidationError,
|
|
3235
|
+
pi as WorkerSigningPool,
|
|
3236
|
+
Te as _toFutureSegwitAddress,
|
|
3237
|
+
Pn as address,
|
|
3238
|
+
le as alloc,
|
|
3239
|
+
di as applySignaturesToPsbt,
|
|
3240
|
+
gi as assertPrivateKey,
|
|
3241
|
+
yi as assertXOnlyPublicKey,
|
|
3242
|
+
yn as checkInputForSig,
|
|
3243
|
+
Yt as checkTaprootInputFields,
|
|
3244
|
+
gn as checkTaprootInputForSigs,
|
|
3245
|
+
qt as checkTaprootOutputFields,
|
|
3246
|
+
Xt as clone,
|
|
3233
3247
|
It as compare,
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3248
|
+
wi as concat,
|
|
3249
|
+
kn as crypto,
|
|
3250
|
+
Si as decompressPublicKey,
|
|
3251
|
+
ii as default,
|
|
3238
3252
|
k as equals,
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3253
|
+
si as errors,
|
|
3254
|
+
an as findScriptPath,
|
|
3255
|
+
Ae as fromBase58Check,
|
|
3256
|
+
_n as fromBase64,
|
|
3257
|
+
fe as fromBech32,
|
|
3244
3258
|
St as fromHex,
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3259
|
+
Ie as fromOutputScript,
|
|
3260
|
+
Ei as fromUtf8,
|
|
3261
|
+
mi as getEccLib,
|
|
3262
|
+
Qs as getFinalScripts,
|
|
3263
|
+
bi as getPsigsFromInputFinalScripts,
|
|
3264
|
+
Ti as getSigningPool,
|
|
3265
|
+
Ai as getTapKeySigFromWitness,
|
|
3266
|
+
Ii as hash160,
|
|
3253
3267
|
At as hash256,
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3268
|
+
ki as initEccLib,
|
|
3269
|
+
Ge as isBytes20,
|
|
3270
|
+
vi as isBytes32,
|
|
3271
|
+
xi as isHex,
|
|
3272
|
+
_i as isP2A,
|
|
3273
|
+
Ui as isP2MR,
|
|
3274
|
+
An as isP2MRInput,
|
|
3275
|
+
Sn as isP2MS,
|
|
3276
|
+
Pi as isP2OP,
|
|
3277
|
+
En as isP2PK,
|
|
3278
|
+
wn as isP2PKH,
|
|
3279
|
+
Se as isP2SHScript,
|
|
3280
|
+
Tn as isP2TR,
|
|
3265
3281
|
Et as isP2WPKH,
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3282
|
+
jt as isP2WSHScript,
|
|
3283
|
+
Ni as isPoint,
|
|
3284
|
+
Hi as isPrivateKey,
|
|
3285
|
+
Oi as isSatoshi,
|
|
3286
|
+
Ri as isSchnorrSignature,
|
|
3287
|
+
Ki as isScript,
|
|
3288
|
+
Ci as isSignature,
|
|
3289
|
+
O as isTaprootInput,
|
|
3290
|
+
Fi as isTaprootOutput,
|
|
3291
|
+
me as isUnknownSegwitVersion,
|
|
3292
|
+
Bi as isXOnlyPublicKey,
|
|
3293
|
+
Wi as isZero,
|
|
3294
|
+
xn as networks,
|
|
3279
3295
|
M as opcodes,
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3296
|
+
Hn as payments,
|
|
3297
|
+
ri as prepareFinalScripts,
|
|
3298
|
+
$i as prepareSigningTasks,
|
|
3283
3299
|
it as pubkeyInScript,
|
|
3284
|
-
|
|
3285
|
-
|
|
3300
|
+
Li as pubkeyPositionInScript,
|
|
3301
|
+
Mi as pubkeysMatch,
|
|
3286
3302
|
st as reverse,
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3303
|
+
Di as reverseCopy,
|
|
3304
|
+
Gi as ripemd160,
|
|
3305
|
+
cn as rootHashFromPath,
|
|
3306
|
+
un as rootHashFromPathP2MR,
|
|
3307
|
+
vn as script,
|
|
3291
3308
|
Q as serializeTaprootSignature,
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3309
|
+
Vi as sha1,
|
|
3310
|
+
zi as sha256,
|
|
3311
|
+
ji as signPsbtParallel,
|
|
3312
|
+
Xi as signatureBlocksAction,
|
|
3313
|
+
Yi as taggedHash,
|
|
3314
|
+
hn as tapBranchHash,
|
|
3315
|
+
Zt as tapScriptFinalizer,
|
|
3316
|
+
qi as tapTreeFromList,
|
|
3317
|
+
Zi as tapTreeToList,
|
|
3318
|
+
Ji as tapTweakHash,
|
|
3319
|
+
we as tapleafHash,
|
|
3302
3320
|
Ot as toBase58Check,
|
|
3303
|
-
|
|
3321
|
+
ei as toBase64,
|
|
3304
3322
|
at as toBech32,
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3323
|
+
je as toBytes20,
|
|
3324
|
+
zt as toBytes32,
|
|
3325
|
+
be as toFutureOPNetAddress,
|
|
3326
|
+
ln as toHashTree,
|
|
3309
3327
|
B as toHex,
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3328
|
+
ke as toOutputScript,
|
|
3329
|
+
Qi as toSatoshi,
|
|
3330
|
+
to as toUtf8,
|
|
3313
3331
|
nt as toXOnly,
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3332
|
+
Zs as transactionFromBuffer,
|
|
3333
|
+
eo as tweakInternalPubKey,
|
|
3334
|
+
fn as tweakKey,
|
|
3335
|
+
no as varuint,
|
|
3318
3336
|
rt as witnessStackToScriptWitness,
|
|
3319
|
-
|
|
3337
|
+
ro as xor
|
|
3320
3338
|
};
|