@btc-vision/transaction 1.7.25 → 1.7.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/_version.d.ts +1 -1
- package/browser/btc-vision-bitcoin.js +12 -13
- package/browser/index.js +456 -443
- package/browser/noble-curves.js +1045 -1016
- package/browser/noble-hashes.js +918 -728
- package/browser/vendors.js +11418 -15799
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/crypto/crypto-browser.js +9 -16
- package/vite.config.browser.ts +30 -29
- package/browser/bip39.js +0 -204
- package/browser/bitcoin-utils.js +0 -3172
- package/browser/btc-vision-bip32.js +0 -805
- package/browser/btc-vision-logger.js +0 -86
- package/browser/btc-vision-post-quantum.js +0 -542
- package/browser/polyfills.js +0 -4952
- package/browser/scure-base.js +0 -410
- package/webpack.config.js +0 -220
package/browser/bitcoin-utils.js
DELETED
|
@@ -1,3172 +0,0 @@
|
|
|
1
|
-
import { s as Qe, b as mt } from "./noble-hashes.js";
|
|
2
|
-
import { b as kt, r as It, a as At, c as Pt } from "./vendors.js";
|
|
3
|
-
import { g as Jr } from "./bip39.js";
|
|
4
|
-
import { B as S, r as Yr } from "./polyfills.js";
|
|
5
|
-
import { r as xt, a as Ot, b as Rt } from "./noble-curves.js";
|
|
6
|
-
function Nt(e, n) {
|
|
7
|
-
for (var c = 0; c < n.length; c++) {
|
|
8
|
-
const r = n[c];
|
|
9
|
-
if (typeof r != "string" && !Array.isArray(r)) {
|
|
10
|
-
for (const g in r)
|
|
11
|
-
if (g !== "default" && !(g in e)) {
|
|
12
|
-
const o = Object.getOwnPropertyDescriptor(r, g);
|
|
13
|
-
o && Object.defineProperty(e, g, o.get ? o : {
|
|
14
|
-
enumerable: !0,
|
|
15
|
-
get: () => r[g]
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
|
|
21
|
-
}
|
|
22
|
-
var ee = {}, $e;
|
|
23
|
-
function Bt() {
|
|
24
|
-
if ($e) return ee;
|
|
25
|
-
$e = 1, Object.defineProperty(ee, "__esModule", { value: !0 }), ee.bech32m = ee.bech32 = void 0;
|
|
26
|
-
const e = "qpzry9x8gf2tvdw0s3jn54khce6mua7l", n = {};
|
|
27
|
-
for (let f = 0; f < e.length; f++) {
|
|
28
|
-
const d = e.charAt(f);
|
|
29
|
-
n[d] = f;
|
|
30
|
-
}
|
|
31
|
-
function c(f) {
|
|
32
|
-
const d = f >> 25;
|
|
33
|
-
return (f & 33554431) << 5 ^ -(d >> 0 & 1) & 996825010 ^ -(d >> 1 & 1) & 642813549 ^ -(d >> 2 & 1) & 513874426 ^ -(d >> 3 & 1) & 1027748829 ^ -(d >> 4 & 1) & 705979059;
|
|
34
|
-
}
|
|
35
|
-
function r(f) {
|
|
36
|
-
let d = 1;
|
|
37
|
-
for (let v = 0; v < f.length; ++v) {
|
|
38
|
-
const p = f.charCodeAt(v);
|
|
39
|
-
if (p < 33 || p > 126)
|
|
40
|
-
return "Invalid prefix (" + f + ")";
|
|
41
|
-
d = c(d) ^ p >> 5;
|
|
42
|
-
}
|
|
43
|
-
d = c(d);
|
|
44
|
-
for (let v = 0; v < f.length; ++v) {
|
|
45
|
-
const p = f.charCodeAt(v);
|
|
46
|
-
d = c(d) ^ p & 31;
|
|
47
|
-
}
|
|
48
|
-
return d;
|
|
49
|
-
}
|
|
50
|
-
function g(f, d, v, p) {
|
|
51
|
-
let h = 0, s = 0;
|
|
52
|
-
const a = (1 << v) - 1, l = [];
|
|
53
|
-
for (let E = 0; E < f.length; ++E)
|
|
54
|
-
for (h = h << d | f[E], s += d; s >= v; )
|
|
55
|
-
s -= v, l.push(h >> s & a);
|
|
56
|
-
if (p)
|
|
57
|
-
s > 0 && l.push(h << v - s & a);
|
|
58
|
-
else {
|
|
59
|
-
if (s >= d)
|
|
60
|
-
return "Excess padding";
|
|
61
|
-
if (h << v - s & a)
|
|
62
|
-
return "Non-zero padding";
|
|
63
|
-
}
|
|
64
|
-
return l;
|
|
65
|
-
}
|
|
66
|
-
function o(f) {
|
|
67
|
-
return g(f, 8, 5, !0);
|
|
68
|
-
}
|
|
69
|
-
function i(f) {
|
|
70
|
-
const d = g(f, 5, 8, !1);
|
|
71
|
-
if (Array.isArray(d))
|
|
72
|
-
return d;
|
|
73
|
-
}
|
|
74
|
-
function t(f) {
|
|
75
|
-
const d = g(f, 5, 8, !1);
|
|
76
|
-
if (Array.isArray(d))
|
|
77
|
-
return d;
|
|
78
|
-
throw new Error(d);
|
|
79
|
-
}
|
|
80
|
-
function u(f) {
|
|
81
|
-
let d;
|
|
82
|
-
f === "bech32" ? d = 1 : d = 734539939;
|
|
83
|
-
function v(a, l, E) {
|
|
84
|
-
if (E = E || 90, a.length + 7 + l.length > E)
|
|
85
|
-
throw new TypeError("Exceeds length limit");
|
|
86
|
-
a = a.toLowerCase();
|
|
87
|
-
let b = r(a);
|
|
88
|
-
if (typeof b == "string")
|
|
89
|
-
throw new Error(b);
|
|
90
|
-
let w = a + "1";
|
|
91
|
-
for (let m = 0; m < l.length; ++m) {
|
|
92
|
-
const x = l[m];
|
|
93
|
-
if (x >> 5 !== 0)
|
|
94
|
-
throw new Error("Non 5-bit word");
|
|
95
|
-
b = c(b) ^ x, w += e.charAt(x);
|
|
96
|
-
}
|
|
97
|
-
for (let m = 0; m < 6; ++m)
|
|
98
|
-
b = c(b);
|
|
99
|
-
b ^= d;
|
|
100
|
-
for (let m = 0; m < 6; ++m) {
|
|
101
|
-
const x = b >> (5 - m) * 5 & 31;
|
|
102
|
-
w += e.charAt(x);
|
|
103
|
-
}
|
|
104
|
-
return w;
|
|
105
|
-
}
|
|
106
|
-
function p(a, l) {
|
|
107
|
-
if (l = l || 90, a.length < 8)
|
|
108
|
-
return a + " too short";
|
|
109
|
-
if (a.length > l)
|
|
110
|
-
return "Exceeds length limit";
|
|
111
|
-
const E = a.toLowerCase(), b = a.toUpperCase();
|
|
112
|
-
if (a !== E && a !== b)
|
|
113
|
-
return "Mixed-case string " + a;
|
|
114
|
-
a = E;
|
|
115
|
-
const w = a.lastIndexOf("1");
|
|
116
|
-
if (w === -1)
|
|
117
|
-
return "No separator character for " + a;
|
|
118
|
-
if (w === 0)
|
|
119
|
-
return "Missing prefix for " + a;
|
|
120
|
-
const m = a.slice(0, w), x = a.slice(w + 1);
|
|
121
|
-
if (x.length < 6)
|
|
122
|
-
return "Data too short";
|
|
123
|
-
let _ = r(m);
|
|
124
|
-
if (typeof _ == "string")
|
|
125
|
-
return _;
|
|
126
|
-
const I = [];
|
|
127
|
-
for (let A = 0; A < x.length; ++A) {
|
|
128
|
-
const P = x.charAt(A), O = n[P];
|
|
129
|
-
if (O === void 0)
|
|
130
|
-
return "Unknown character " + P;
|
|
131
|
-
_ = c(_) ^ O, !(A + 6 >= x.length) && I.push(O);
|
|
132
|
-
}
|
|
133
|
-
return _ !== d ? "Invalid checksum for " + a : { prefix: m, words: I };
|
|
134
|
-
}
|
|
135
|
-
function h(a, l) {
|
|
136
|
-
const E = p(a, l);
|
|
137
|
-
if (typeof E == "object")
|
|
138
|
-
return E;
|
|
139
|
-
}
|
|
140
|
-
function s(a, l) {
|
|
141
|
-
const E = p(a, l);
|
|
142
|
-
if (typeof E == "object")
|
|
143
|
-
return E;
|
|
144
|
-
throw new Error(E);
|
|
145
|
-
}
|
|
146
|
-
return {
|
|
147
|
-
decodeUnsafe: h,
|
|
148
|
-
decode: s,
|
|
149
|
-
encode: v,
|
|
150
|
-
toWords: o,
|
|
151
|
-
fromWordsUnsafe: i,
|
|
152
|
-
fromWords: t
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
return ee.bech32 = u("bech32"), ee.bech32m = u("bech32m"), ee;
|
|
156
|
-
}
|
|
157
|
-
var Ln = Bt(), Ut = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
158
|
-
const xe = kt(Ut);
|
|
159
|
-
function Kt(e) {
|
|
160
|
-
function n(o) {
|
|
161
|
-
var i = Uint8Array.from(o), t = e(i), u = i.length + 4, f = new Uint8Array(u);
|
|
162
|
-
return f.set(i, 0), f.set(t.subarray(0, 4), i.length), xe.encode(f);
|
|
163
|
-
}
|
|
164
|
-
function c(o) {
|
|
165
|
-
var i = o.slice(0, -4), t = o.slice(-4), u = e(i);
|
|
166
|
-
if (!(t[0] ^ u[0] | t[1] ^ u[1] | t[2] ^ u[2] | t[3] ^ u[3]))
|
|
167
|
-
return i;
|
|
168
|
-
}
|
|
169
|
-
function r(o) {
|
|
170
|
-
var i = xe.decodeUnsafe(o);
|
|
171
|
-
if (i != null)
|
|
172
|
-
return c(i);
|
|
173
|
-
}
|
|
174
|
-
function g(o) {
|
|
175
|
-
var i = xe.decode(o), t = c(i);
|
|
176
|
-
if (t == null)
|
|
177
|
-
throw new Error("Invalid checksum");
|
|
178
|
-
return t;
|
|
179
|
-
}
|
|
180
|
-
return {
|
|
181
|
-
encode: n,
|
|
182
|
-
decode: g,
|
|
183
|
-
decodeUnsafe: r
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function Ct(e) {
|
|
187
|
-
return Qe(Qe(e));
|
|
188
|
-
}
|
|
189
|
-
const qn = Kt(Ct);
|
|
190
|
-
var Oe, er;
|
|
191
|
-
function He() {
|
|
192
|
-
if (er) return Oe;
|
|
193
|
-
er = 1;
|
|
194
|
-
var e = {
|
|
195
|
-
Array: function(c) {
|
|
196
|
-
return c != null && c.constructor === Array;
|
|
197
|
-
},
|
|
198
|
-
Boolean: function(c) {
|
|
199
|
-
return typeof c == "boolean";
|
|
200
|
-
},
|
|
201
|
-
Function: function(c) {
|
|
202
|
-
return typeof c == "function";
|
|
203
|
-
},
|
|
204
|
-
Nil: function(c) {
|
|
205
|
-
return c == null;
|
|
206
|
-
},
|
|
207
|
-
Number: function(c) {
|
|
208
|
-
return typeof c == "number";
|
|
209
|
-
},
|
|
210
|
-
Object: function(c) {
|
|
211
|
-
return typeof c == "object";
|
|
212
|
-
},
|
|
213
|
-
String: function(c) {
|
|
214
|
-
return typeof c == "string";
|
|
215
|
-
},
|
|
216
|
-
"": function() {
|
|
217
|
-
return !0;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
e.Null = e.Nil;
|
|
221
|
-
for (var n in e)
|
|
222
|
-
e[n].toJSON = function(c) {
|
|
223
|
-
return c;
|
|
224
|
-
}.bind(null, n);
|
|
225
|
-
return Oe = e, Oe;
|
|
226
|
-
}
|
|
227
|
-
var Re, rr;
|
|
228
|
-
function zr() {
|
|
229
|
-
if (rr) return Re;
|
|
230
|
-
rr = 1;
|
|
231
|
-
var e = He();
|
|
232
|
-
function n(p) {
|
|
233
|
-
return p.name || p.toString().match(/function (.*?)\s*\(/)[1];
|
|
234
|
-
}
|
|
235
|
-
function c(p) {
|
|
236
|
-
return e.Nil(p) ? "" : n(p.constructor);
|
|
237
|
-
}
|
|
238
|
-
function r(p) {
|
|
239
|
-
return e.Function(p) ? "" : e.String(p) ? JSON.stringify(p) : p && e.Object(p) ? "" : p;
|
|
240
|
-
}
|
|
241
|
-
function g(p, h) {
|
|
242
|
-
Error.captureStackTrace && Error.captureStackTrace(p, h);
|
|
243
|
-
}
|
|
244
|
-
function o(p) {
|
|
245
|
-
return e.Function(p) ? p.toJSON ? p.toJSON() : n(p) : e.Array(p) ? "Array" : p && e.Object(p) ? "Object" : p !== void 0 ? p : "";
|
|
246
|
-
}
|
|
247
|
-
function i(p, h, s) {
|
|
248
|
-
var a = r(h);
|
|
249
|
-
return "Expected " + o(p) + ", got" + (s !== "" ? " " + s : "") + (a !== "" ? " " + a : "");
|
|
250
|
-
}
|
|
251
|
-
function t(p, h, s) {
|
|
252
|
-
s = s || c(h), this.message = i(p, h, s), g(this, t), this.__type = p, this.__value = h, this.__valueTypeName = s;
|
|
253
|
-
}
|
|
254
|
-
t.prototype = Object.create(Error.prototype), t.prototype.constructor = t;
|
|
255
|
-
function u(p, h, s, a, l) {
|
|
256
|
-
var E = '" of type ';
|
|
257
|
-
return h === "key" && (E = '" with key type '), i('property "' + o(s) + E + o(p), a, l);
|
|
258
|
-
}
|
|
259
|
-
function f(p, h, s, a, l) {
|
|
260
|
-
p ? (l = l || c(a), this.message = u(p, s, h, a, l)) : this.message = 'Unexpected property "' + h + '"', g(this, t), this.__label = s, this.__property = h, this.__type = p, this.__value = a, this.__valueTypeName = l;
|
|
261
|
-
}
|
|
262
|
-
f.prototype = Object.create(Error.prototype), f.prototype.constructor = t;
|
|
263
|
-
function d(p, h) {
|
|
264
|
-
return new t(p, {}, h);
|
|
265
|
-
}
|
|
266
|
-
function v(p, h, s) {
|
|
267
|
-
return p instanceof f ? (h = h + "." + p.__property, p = new f(
|
|
268
|
-
p.__type,
|
|
269
|
-
h,
|
|
270
|
-
p.__label,
|
|
271
|
-
p.__value,
|
|
272
|
-
p.__valueTypeName
|
|
273
|
-
)) : p instanceof t && (p = new f(
|
|
274
|
-
p.__type,
|
|
275
|
-
h,
|
|
276
|
-
s,
|
|
277
|
-
p.__value,
|
|
278
|
-
p.__valueTypeName
|
|
279
|
-
)), g(p), p;
|
|
280
|
-
}
|
|
281
|
-
return Re = {
|
|
282
|
-
TfTypeError: t,
|
|
283
|
-
TfPropertyTypeError: f,
|
|
284
|
-
tfCustomError: d,
|
|
285
|
-
tfSubError: v,
|
|
286
|
-
tfJSON: o,
|
|
287
|
-
getValueTypeName: c
|
|
288
|
-
}, Re;
|
|
289
|
-
}
|
|
290
|
-
var Ne, tr;
|
|
291
|
-
function Lt() {
|
|
292
|
-
if (tr) return Ne;
|
|
293
|
-
tr = 1;
|
|
294
|
-
var e = He(), n = zr();
|
|
295
|
-
function c(_) {
|
|
296
|
-
return S.isBuffer(_);
|
|
297
|
-
}
|
|
298
|
-
function r(_) {
|
|
299
|
-
return typeof _ == "string" && /^([0-9a-f]{2})+$/i.test(_);
|
|
300
|
-
}
|
|
301
|
-
function g(_, I) {
|
|
302
|
-
var A = _.toJSON();
|
|
303
|
-
function P(O) {
|
|
304
|
-
if (!_(O)) return !1;
|
|
305
|
-
if (O.length === I) return !0;
|
|
306
|
-
throw n.tfCustomError(A + "(Length: " + I + ")", A + "(Length: " + O.length + ")");
|
|
307
|
-
}
|
|
308
|
-
return P.toJSON = function() {
|
|
309
|
-
return A;
|
|
310
|
-
}, P;
|
|
311
|
-
}
|
|
312
|
-
var o = g.bind(null, e.Array), i = g.bind(null, c), t = g.bind(null, r), u = g.bind(null, e.String);
|
|
313
|
-
function f(_, I, A) {
|
|
314
|
-
A = A || e.Number;
|
|
315
|
-
function P(O, U) {
|
|
316
|
-
return A(O, U) && O > _ && O < I;
|
|
317
|
-
}
|
|
318
|
-
return P.toJSON = function() {
|
|
319
|
-
return `${A.toJSON()} between [${_}, ${I}]`;
|
|
320
|
-
}, P;
|
|
321
|
-
}
|
|
322
|
-
var d = Math.pow(2, 53) - 1;
|
|
323
|
-
function v(_) {
|
|
324
|
-
return typeof _ == "number" && isFinite(_);
|
|
325
|
-
}
|
|
326
|
-
function p(_) {
|
|
327
|
-
return _ << 24 >> 24 === _;
|
|
328
|
-
}
|
|
329
|
-
function h(_) {
|
|
330
|
-
return _ << 16 >> 16 === _;
|
|
331
|
-
}
|
|
332
|
-
function s(_) {
|
|
333
|
-
return (_ | 0) === _;
|
|
334
|
-
}
|
|
335
|
-
function a(_) {
|
|
336
|
-
return typeof _ == "number" && _ >= -d && _ <= d && Math.floor(_) === _;
|
|
337
|
-
}
|
|
338
|
-
function l(_) {
|
|
339
|
-
return (_ & 255) === _;
|
|
340
|
-
}
|
|
341
|
-
function E(_) {
|
|
342
|
-
return (_ & 65535) === _;
|
|
343
|
-
}
|
|
344
|
-
function b(_) {
|
|
345
|
-
return _ >>> 0 === _;
|
|
346
|
-
}
|
|
347
|
-
function w(_) {
|
|
348
|
-
return typeof _ == "number" && _ >= 0 && _ <= d && Math.floor(_) === _;
|
|
349
|
-
}
|
|
350
|
-
var m = {
|
|
351
|
-
ArrayN: o,
|
|
352
|
-
Buffer: c,
|
|
353
|
-
BufferN: i,
|
|
354
|
-
Finite: v,
|
|
355
|
-
Hex: r,
|
|
356
|
-
HexN: t,
|
|
357
|
-
Int8: p,
|
|
358
|
-
Int16: h,
|
|
359
|
-
Int32: s,
|
|
360
|
-
Int53: a,
|
|
361
|
-
Range: f,
|
|
362
|
-
StringN: u,
|
|
363
|
-
UInt8: l,
|
|
364
|
-
UInt16: E,
|
|
365
|
-
UInt32: b,
|
|
366
|
-
UInt53: w
|
|
367
|
-
};
|
|
368
|
-
for (var x in m)
|
|
369
|
-
m[x].toJSON = function(_) {
|
|
370
|
-
return _;
|
|
371
|
-
}.bind(null, x);
|
|
372
|
-
return Ne = m, Ne;
|
|
373
|
-
}
|
|
374
|
-
var Be, nr;
|
|
375
|
-
function Zr() {
|
|
376
|
-
if (nr) return Be;
|
|
377
|
-
nr = 1;
|
|
378
|
-
var e = zr(), n = He(), c = e.tfJSON, r = e.TfTypeError, g = e.TfPropertyTypeError, o = e.tfSubError, i = e.getValueTypeName, t = {
|
|
379
|
-
arrayOf: function(h, s) {
|
|
380
|
-
h = u(h), s = s || {};
|
|
381
|
-
function a(l, E) {
|
|
382
|
-
return !n.Array(l) || n.Nil(l) || s.minLength !== void 0 && l.length < s.minLength || s.maxLength !== void 0 && l.length > s.maxLength || s.length !== void 0 && l.length !== s.length ? !1 : l.every(function(b, w) {
|
|
383
|
-
try {
|
|
384
|
-
return f(h, b, E);
|
|
385
|
-
} catch (m) {
|
|
386
|
-
throw o(m, w);
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
return a.toJSON = function() {
|
|
391
|
-
var l = "[" + c(h) + "]";
|
|
392
|
-
return s.length !== void 0 ? l += "{" + s.length + "}" : (s.minLength !== void 0 || s.maxLength !== void 0) && (l += "{" + (s.minLength === void 0 ? 0 : s.minLength) + "," + (s.maxLength === void 0 ? 1 / 0 : s.maxLength) + "}"), l;
|
|
393
|
-
}, a;
|
|
394
|
-
},
|
|
395
|
-
maybe: function p(h) {
|
|
396
|
-
h = u(h);
|
|
397
|
-
function s(a, l) {
|
|
398
|
-
return n.Nil(a) || h(a, l, p);
|
|
399
|
-
}
|
|
400
|
-
return s.toJSON = function() {
|
|
401
|
-
return "?" + c(h);
|
|
402
|
-
}, s;
|
|
403
|
-
},
|
|
404
|
-
map: function(h, s) {
|
|
405
|
-
h = u(h), s && (s = u(s));
|
|
406
|
-
function a(l, E) {
|
|
407
|
-
if (!n.Object(l) || n.Nil(l)) return !1;
|
|
408
|
-
for (var b in l) {
|
|
409
|
-
try {
|
|
410
|
-
s && f(s, b, E);
|
|
411
|
-
} catch (m) {
|
|
412
|
-
throw o(m, b, "key");
|
|
413
|
-
}
|
|
414
|
-
try {
|
|
415
|
-
var w = l[b];
|
|
416
|
-
f(h, w, E);
|
|
417
|
-
} catch (m) {
|
|
418
|
-
throw o(m, b);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return !0;
|
|
422
|
-
}
|
|
423
|
-
return s ? a.toJSON = function() {
|
|
424
|
-
return "{" + c(s) + ": " + c(h) + "}";
|
|
425
|
-
} : a.toJSON = function() {
|
|
426
|
-
return "{" + c(h) + "}";
|
|
427
|
-
}, a;
|
|
428
|
-
},
|
|
429
|
-
object: function(h) {
|
|
430
|
-
var s = {};
|
|
431
|
-
for (var a in h)
|
|
432
|
-
s[a] = u(h[a]);
|
|
433
|
-
function l(E, b) {
|
|
434
|
-
if (!n.Object(E) || n.Nil(E)) return !1;
|
|
435
|
-
var w;
|
|
436
|
-
try {
|
|
437
|
-
for (w in s) {
|
|
438
|
-
var m = s[w], x = E[w];
|
|
439
|
-
f(m, x, b);
|
|
440
|
-
}
|
|
441
|
-
} catch (_) {
|
|
442
|
-
throw o(_, w);
|
|
443
|
-
}
|
|
444
|
-
if (b) {
|
|
445
|
-
for (w in E)
|
|
446
|
-
if (!s[w])
|
|
447
|
-
throw new g(void 0, w);
|
|
448
|
-
}
|
|
449
|
-
return !0;
|
|
450
|
-
}
|
|
451
|
-
return l.toJSON = function() {
|
|
452
|
-
return c(s);
|
|
453
|
-
}, l;
|
|
454
|
-
},
|
|
455
|
-
anyOf: function() {
|
|
456
|
-
var h = [].slice.call(arguments).map(u);
|
|
457
|
-
function s(a, l) {
|
|
458
|
-
return h.some(function(E) {
|
|
459
|
-
try {
|
|
460
|
-
return f(E, a, l);
|
|
461
|
-
} catch {
|
|
462
|
-
return !1;
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
return s.toJSON = function() {
|
|
467
|
-
return h.map(c).join("|");
|
|
468
|
-
}, s;
|
|
469
|
-
},
|
|
470
|
-
allOf: function() {
|
|
471
|
-
var h = [].slice.call(arguments).map(u);
|
|
472
|
-
function s(a, l) {
|
|
473
|
-
return h.every(function(E) {
|
|
474
|
-
try {
|
|
475
|
-
return f(E, a, l);
|
|
476
|
-
} catch {
|
|
477
|
-
return !1;
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
return s.toJSON = function() {
|
|
482
|
-
return h.map(c).join(" & ");
|
|
483
|
-
}, s;
|
|
484
|
-
},
|
|
485
|
-
quacksLike: function(h) {
|
|
486
|
-
function s(a) {
|
|
487
|
-
return h === i(a);
|
|
488
|
-
}
|
|
489
|
-
return s.toJSON = function() {
|
|
490
|
-
return h;
|
|
491
|
-
}, s;
|
|
492
|
-
},
|
|
493
|
-
tuple: function() {
|
|
494
|
-
var h = [].slice.call(arguments).map(u);
|
|
495
|
-
function s(a, l) {
|
|
496
|
-
return n.Nil(a) || n.Nil(a.length) || l && a.length !== h.length ? !1 : h.every(function(E, b) {
|
|
497
|
-
try {
|
|
498
|
-
return f(E, a[b], l);
|
|
499
|
-
} catch (w) {
|
|
500
|
-
throw o(w, b);
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
return s.toJSON = function() {
|
|
505
|
-
return "(" + h.map(c).join(", ") + ")";
|
|
506
|
-
}, s;
|
|
507
|
-
},
|
|
508
|
-
value: function(h) {
|
|
509
|
-
function s(a) {
|
|
510
|
-
return a === h;
|
|
511
|
-
}
|
|
512
|
-
return s.toJSON = function() {
|
|
513
|
-
return h;
|
|
514
|
-
}, s;
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
t.oneOf = t.anyOf;
|
|
518
|
-
function u(p) {
|
|
519
|
-
if (n.String(p))
|
|
520
|
-
return p[0] === "?" ? t.maybe(p.slice(1)) : n[p] || t.quacksLike(p);
|
|
521
|
-
if (p && n.Object(p)) {
|
|
522
|
-
if (n.Array(p)) {
|
|
523
|
-
if (p.length !== 1) throw new TypeError("Expected compile() parameter of type Array of length 1");
|
|
524
|
-
return t.arrayOf(p[0]);
|
|
525
|
-
}
|
|
526
|
-
return t.object(p);
|
|
527
|
-
} else if (n.Function(p))
|
|
528
|
-
return p;
|
|
529
|
-
return t.value(p);
|
|
530
|
-
}
|
|
531
|
-
function f(p, h, s, a) {
|
|
532
|
-
if (n.Function(p)) {
|
|
533
|
-
if (p(h, s)) return !0;
|
|
534
|
-
throw new r(a || p, h);
|
|
535
|
-
}
|
|
536
|
-
return f(u(p), h, s);
|
|
537
|
-
}
|
|
538
|
-
for (var d in n)
|
|
539
|
-
f[d] = n[d];
|
|
540
|
-
for (d in t)
|
|
541
|
-
f[d] = t[d];
|
|
542
|
-
var v = Lt();
|
|
543
|
-
for (d in v)
|
|
544
|
-
f[d] = v[d];
|
|
545
|
-
return f.compile = u, f.TfTypeError = r, f.TfPropertyTypeError = g, Be = f, Be;
|
|
546
|
-
}
|
|
547
|
-
var qt = Zr();
|
|
548
|
-
const Mn = /* @__PURE__ */ Jr(qt), Qr = "0123456789abcdefABCDEF";
|
|
549
|
-
Qr.split("").map((e) => e.codePointAt(0));
|
|
550
|
-
Array(256).fill(!0).map((e, n) => {
|
|
551
|
-
const c = String.fromCodePoint(n), r = Qr.indexOf(c);
|
|
552
|
-
return r < 0 ? void 0 : r < 16 ? r : r - 6;
|
|
553
|
-
});
|
|
554
|
-
new TextEncoder();
|
|
555
|
-
new TextDecoder();
|
|
556
|
-
function Mt(e, n, c, r) {
|
|
557
|
-
if (n + 2 > e.length)
|
|
558
|
-
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
559
|
-
if (r = r.toUpperCase(), c > 65535)
|
|
560
|
-
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${c}`);
|
|
561
|
-
r === "LE" ? (e[n] = c & 255, e[n + 1] = c >> 8 & 255) : (e[n] = c >> 8 & 255, e[n + 1] = c & 255);
|
|
562
|
-
}
|
|
563
|
-
function Dt(e, n, c, r) {
|
|
564
|
-
if (n + 4 > e.length)
|
|
565
|
-
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
566
|
-
if (r = r.toUpperCase(), c > 4294967295)
|
|
567
|
-
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${c}`);
|
|
568
|
-
r === "LE" ? (e[n] = c & 255, e[n + 1] = c >> 8 & 255, e[n + 2] = c >> 16 & 255, e[n + 3] = c >> 24 & 255) : (e[n] = c >> 24 & 255, e[n + 1] = c >> 16 & 255, e[n + 2] = c >> 8 & 255, e[n + 3] = c & 255);
|
|
569
|
-
}
|
|
570
|
-
function Ft(e, n, c, r) {
|
|
571
|
-
if (n + 8 > e.length)
|
|
572
|
-
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
573
|
-
if (r = r.toUpperCase(), c > 0xffffffffffffffffn)
|
|
574
|
-
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${c}`);
|
|
575
|
-
r === "LE" ? (e[n] = Number(c & 0xffn), e[n + 1] = Number(c >> 8n & 0xffn), e[n + 2] = Number(c >> 16n & 0xffn), e[n + 3] = Number(c >> 24n & 0xffn), e[n + 4] = Number(c >> 32n & 0xffn), e[n + 5] = Number(c >> 40n & 0xffn), e[n + 6] = Number(c >> 48n & 0xffn), e[n + 7] = Number(c >> 56n & 0xffn)) : (e[n] = Number(c >> 56n & 0xffn), e[n + 1] = Number(c >> 48n & 0xffn), e[n + 2] = Number(c >> 40n & 0xffn), e[n + 3] = Number(c >> 32n & 0xffn), e[n + 4] = Number(c >> 24n & 0xffn), e[n + 5] = Number(c >> 16n & 0xffn), e[n + 6] = Number(c >> 8n & 0xffn), e[n + 7] = Number(c & 0xffn));
|
|
576
|
-
}
|
|
577
|
-
function jt(e, n, c) {
|
|
578
|
-
if (n + 2 > e.length)
|
|
579
|
-
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
580
|
-
if (c = c.toUpperCase(), c === "LE") {
|
|
581
|
-
let r = 0;
|
|
582
|
-
return r = (r << 8) + e[n + 1], r = (r << 8) + e[n], r;
|
|
583
|
-
} else {
|
|
584
|
-
let r = 0;
|
|
585
|
-
return r = (r << 8) + e[n], r = (r << 8) + e[n + 1], r;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
function Wt(e, n, c) {
|
|
589
|
-
if (n + 4 > e.length)
|
|
590
|
-
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
591
|
-
if (c = c.toUpperCase(), c === "LE") {
|
|
592
|
-
let r = 0;
|
|
593
|
-
return r = (r << 8) + e[n + 3] >>> 0, r = (r << 8) + e[n + 2] >>> 0, r = (r << 8) + e[n + 1] >>> 0, r = (r << 8) + e[n] >>> 0, r;
|
|
594
|
-
} else {
|
|
595
|
-
let r = 0;
|
|
596
|
-
return r = (r << 8) + e[n] >>> 0, r = (r << 8) + e[n + 1] >>> 0, r = (r << 8) + e[n + 2] >>> 0, r = (r << 8) + e[n + 3] >>> 0, r;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
function Ht(e, n, c) {
|
|
600
|
-
if (n + 8 > e.length)
|
|
601
|
-
throw new Error("Offset is outside the bounds of Uint8Array");
|
|
602
|
-
if (c = c.toUpperCase(), c === "LE") {
|
|
603
|
-
let r = 0n;
|
|
604
|
-
return r = (r << 8n) + BigInt(e[n + 7]), r = (r << 8n) + BigInt(e[n + 6]), r = (r << 8n) + BigInt(e[n + 5]), r = (r << 8n) + BigInt(e[n + 4]), r = (r << 8n) + BigInt(e[n + 3]), r = (r << 8n) + BigInt(e[n + 2]), r = (r << 8n) + BigInt(e[n + 1]), r = (r << 8n) + BigInt(e[n]), r;
|
|
605
|
-
} else {
|
|
606
|
-
let r = 0n;
|
|
607
|
-
return r = (r << 8n) + BigInt(e[n]), r = (r << 8n) + BigInt(e[n + 1]), r = (r << 8n) + BigInt(e[n + 2]), r = (r << 8n) + BigInt(e[n + 3]), r = (r << 8n) + BigInt(e[n + 4]), r = (r << 8n) + BigInt(e[n + 5]), r = (r << 8n) + BigInt(e[n + 6]), r = (r << 8n) + BigInt(e[n + 7]), r;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
const Gt = (e) => {
|
|
611
|
-
if (e < 0 || e > 0xffffffffffffffffn)
|
|
612
|
-
throw new RangeError("value out of range");
|
|
613
|
-
};
|
|
614
|
-
function Vt(e) {
|
|
615
|
-
if (e < 0 || e > Number.MAX_SAFE_INTEGER || e % 1 !== 0)
|
|
616
|
-
throw new RangeError("value out of range");
|
|
617
|
-
}
|
|
618
|
-
function $r(e) {
|
|
619
|
-
typeof e == "number" ? Vt(e) : Gt(e);
|
|
620
|
-
}
|
|
621
|
-
function Dn(e, n, c) {
|
|
622
|
-
$r(e), c === void 0 && (c = 0), n === void 0 && (n = new Uint8Array(Xt(e)));
|
|
623
|
-
let r = 0;
|
|
624
|
-
return e < 253 ? (n.set([Number(e)], c), r = 1) : e <= 65535 ? (n.set([253], c), Mt(n, c + 1, Number(e), "LE"), r = 3) : e <= 4294967295 ? (n.set([254], c), Dt(n, c + 1, Number(e), "LE"), r = 5) : (n.set([255], c), Ft(n, c + 1, BigInt(e), "LE"), r = 9), { buffer: n, bytes: r };
|
|
625
|
-
}
|
|
626
|
-
function Fn(e, n) {
|
|
627
|
-
n === void 0 && (n = 0);
|
|
628
|
-
const c = e.at(n);
|
|
629
|
-
if (c === void 0)
|
|
630
|
-
throw new Error("buffer too small");
|
|
631
|
-
if (c < 253)
|
|
632
|
-
return { numberValue: c, bigintValue: BigInt(c), bytes: 1 };
|
|
633
|
-
if (c === 253) {
|
|
634
|
-
const r = jt(e, n + 1, "LE");
|
|
635
|
-
return {
|
|
636
|
-
numberValue: r,
|
|
637
|
-
bigintValue: BigInt(r),
|
|
638
|
-
bytes: 3
|
|
639
|
-
};
|
|
640
|
-
} else if (c === 254) {
|
|
641
|
-
const r = Wt(e, n + 1, "LE");
|
|
642
|
-
return {
|
|
643
|
-
numberValue: r,
|
|
644
|
-
bigintValue: BigInt(r),
|
|
645
|
-
bytes: 5
|
|
646
|
-
};
|
|
647
|
-
} else {
|
|
648
|
-
const r = Ht(e, n + 1, "LE");
|
|
649
|
-
return { numberValue: r <= Number.MAX_SAFE_INTEGER ? Number(r) : null, bigintValue: r, bytes: 9 };
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
function Xt(e) {
|
|
653
|
-
return $r(e), e < 253 ? 1 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
|
|
654
|
-
}
|
|
655
|
-
var ie = {}, or;
|
|
656
|
-
function de() {
|
|
657
|
-
if (or) return ie;
|
|
658
|
-
or = 1, Object.defineProperty(ie, "__esModule", { value: !0 });
|
|
659
|
-
const e = 9007199254740991;
|
|
660
|
-
function n(o) {
|
|
661
|
-
if (o < 0 || o > e || o % 1 !== 0)
|
|
662
|
-
throw new RangeError("value out of range");
|
|
663
|
-
}
|
|
664
|
-
function c(o, i, t) {
|
|
665
|
-
if (n(o), i || (i = S.allocUnsafe(g(o))), !S.isBuffer(i))
|
|
666
|
-
throw new TypeError("buffer must be a Buffer instance");
|
|
667
|
-
return t || (t = 0), o < 253 ? (i.writeUInt8(o, t), Object.assign(c, { bytes: 1 })) : o <= 65535 ? (i.writeUInt8(253, t), i.writeUInt16LE(o, t + 1), Object.assign(c, { bytes: 3 })) : o <= 4294967295 ? (i.writeUInt8(254, t), i.writeUInt32LE(o, t + 1), Object.assign(c, { bytes: 5 })) : (i.writeUInt8(255, t), i.writeUInt32LE(o >>> 0, t + 1), i.writeUInt32LE(o / 4294967296 | 0, t + 5), Object.assign(c, { bytes: 9 })), i;
|
|
668
|
-
}
|
|
669
|
-
ie.encode = c;
|
|
670
|
-
function r(o, i) {
|
|
671
|
-
if (!S.isBuffer(o))
|
|
672
|
-
throw new TypeError("buffer must be a Buffer instance");
|
|
673
|
-
i || (i = 0);
|
|
674
|
-
const t = o.readUInt8(i);
|
|
675
|
-
if (t < 253)
|
|
676
|
-
return Object.assign(r, { bytes: 1 }), t;
|
|
677
|
-
if (t === 253)
|
|
678
|
-
return Object.assign(r, { bytes: 3 }), o.readUInt16LE(i + 1);
|
|
679
|
-
if (t === 254)
|
|
680
|
-
return Object.assign(r, { bytes: 5 }), o.readUInt32LE(i + 1);
|
|
681
|
-
{
|
|
682
|
-
Object.assign(r, { bytes: 9 });
|
|
683
|
-
const u = o.readUInt32LE(i + 1), d = o.readUInt32LE(i + 5) * 4294967296 + u;
|
|
684
|
-
return n(d), d;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
ie.decode = r;
|
|
688
|
-
function g(o) {
|
|
689
|
-
return n(o), o < 253 ? 1 : o <= 65535 ? 3 : o <= 4294967295 ? 5 : 9;
|
|
690
|
-
}
|
|
691
|
-
return ie.encodingLength = g, ie;
|
|
692
|
-
}
|
|
693
|
-
var jn = de(), be = {}, ge = {}, Ue = {}, ce = {}, ue = {}, Ke = {}, ir;
|
|
694
|
-
function B() {
|
|
695
|
-
return ir || (ir = 1, (function(e) {
|
|
696
|
-
Object.defineProperty(e, "__esModule", { value: !0 }), (function(n) {
|
|
697
|
-
n[n.UNSIGNED_TX = 0] = "UNSIGNED_TX", n[n.GLOBAL_XPUB = 1] = "GLOBAL_XPUB";
|
|
698
|
-
})(e.GlobalTypes || (e.GlobalTypes = {})), e.GLOBAL_TYPE_NAMES = ["unsignedTx", "globalXpub"], (function(n) {
|
|
699
|
-
n[n.NON_WITNESS_UTXO = 0] = "NON_WITNESS_UTXO", n[n.WITNESS_UTXO = 1] = "WITNESS_UTXO", n[n.PARTIAL_SIG = 2] = "PARTIAL_SIG", n[n.SIGHASH_TYPE = 3] = "SIGHASH_TYPE", n[n.REDEEM_SCRIPT = 4] = "REDEEM_SCRIPT", n[n.WITNESS_SCRIPT = 5] = "WITNESS_SCRIPT", n[n.BIP32_DERIVATION = 6] = "BIP32_DERIVATION", n[n.FINAL_SCRIPTSIG = 7] = "FINAL_SCRIPTSIG", n[n.FINAL_SCRIPTWITNESS = 8] = "FINAL_SCRIPTWITNESS", n[n.POR_COMMITMENT = 9] = "POR_COMMITMENT", n[n.TAP_KEY_SIG = 19] = "TAP_KEY_SIG", n[n.TAP_SCRIPT_SIG = 20] = "TAP_SCRIPT_SIG", n[n.TAP_LEAF_SCRIPT = 21] = "TAP_LEAF_SCRIPT", n[n.TAP_BIP32_DERIVATION = 22] = "TAP_BIP32_DERIVATION", n[n.TAP_INTERNAL_KEY = 23] = "TAP_INTERNAL_KEY", n[n.TAP_MERKLE_ROOT = 24] = "TAP_MERKLE_ROOT";
|
|
700
|
-
})(e.InputTypes || (e.InputTypes = {})), e.INPUT_TYPE_NAMES = [
|
|
701
|
-
"nonWitnessUtxo",
|
|
702
|
-
"witnessUtxo",
|
|
703
|
-
"partialSig",
|
|
704
|
-
"sighashType",
|
|
705
|
-
"redeemScript",
|
|
706
|
-
"witnessScript",
|
|
707
|
-
"bip32Derivation",
|
|
708
|
-
"finalScriptSig",
|
|
709
|
-
"finalScriptWitness",
|
|
710
|
-
"porCommitment",
|
|
711
|
-
"tapKeySig",
|
|
712
|
-
"tapScriptSig",
|
|
713
|
-
"tapLeafScript",
|
|
714
|
-
"tapBip32Derivation",
|
|
715
|
-
"tapInternalKey",
|
|
716
|
-
"tapMerkleRoot"
|
|
717
|
-
], (function(n) {
|
|
718
|
-
n[n.REDEEM_SCRIPT = 0] = "REDEEM_SCRIPT", n[n.WITNESS_SCRIPT = 1] = "WITNESS_SCRIPT", n[n.BIP32_DERIVATION = 2] = "BIP32_DERIVATION", n[n.TAP_INTERNAL_KEY = 5] = "TAP_INTERNAL_KEY", n[n.TAP_TREE = 6] = "TAP_TREE", n[n.TAP_BIP32_DERIVATION = 7] = "TAP_BIP32_DERIVATION";
|
|
719
|
-
})(e.OutputTypes || (e.OutputTypes = {})), e.OUTPUT_TYPE_NAMES = [
|
|
720
|
-
"redeemScript",
|
|
721
|
-
"witnessScript",
|
|
722
|
-
"bip32Derivation",
|
|
723
|
-
"tapInternalKey",
|
|
724
|
-
"tapTree",
|
|
725
|
-
"tapBip32Derivation"
|
|
726
|
-
];
|
|
727
|
-
})(Ke)), Ke;
|
|
728
|
-
}
|
|
729
|
-
var M = {}, cr;
|
|
730
|
-
function Jt() {
|
|
731
|
-
if (cr) return M;
|
|
732
|
-
cr = 1, Object.defineProperty(M, "__esModule", { value: !0 });
|
|
733
|
-
const e = B(), n = (i) => [...Array(i).keys()];
|
|
734
|
-
function c(i) {
|
|
735
|
-
if (i.key[0] !== e.GlobalTypes.GLOBAL_XPUB)
|
|
736
|
-
throw new Error(
|
|
737
|
-
"Decode Error: could not decode globalXpub with key 0x" + i.key.toString("hex")
|
|
738
|
-
);
|
|
739
|
-
if (i.key.length !== 79 || ![2, 3].includes(i.key[46]))
|
|
740
|
-
throw new Error(
|
|
741
|
-
"Decode Error: globalXpub has invalid extended pubkey in key 0x" + i.key.toString("hex")
|
|
742
|
-
);
|
|
743
|
-
if (i.value.length / 4 % 1 !== 0)
|
|
744
|
-
throw new Error(
|
|
745
|
-
"Decode Error: Global GLOBAL_XPUB value length should be multiple of 4"
|
|
746
|
-
);
|
|
747
|
-
const t = i.key.slice(1), u = {
|
|
748
|
-
masterFingerprint: i.value.slice(0, 4),
|
|
749
|
-
extendedPubkey: t,
|
|
750
|
-
path: "m"
|
|
751
|
-
};
|
|
752
|
-
for (const f of n(i.value.length / 4 - 1)) {
|
|
753
|
-
const d = i.value.readUInt32LE(f * 4 + 4), v = !!(d & 2147483648), p = d & 2147483647;
|
|
754
|
-
u.path += "/" + p.toString(10) + (v ? "'" : "");
|
|
755
|
-
}
|
|
756
|
-
return u;
|
|
757
|
-
}
|
|
758
|
-
M.decode = c;
|
|
759
|
-
function r(i) {
|
|
760
|
-
const t = S.from([e.GlobalTypes.GLOBAL_XPUB]), u = S.concat([t, i.extendedPubkey]), f = i.path.split("/"), d = S.allocUnsafe(f.length * 4);
|
|
761
|
-
i.masterFingerprint.copy(d, 0);
|
|
762
|
-
let v = 4;
|
|
763
|
-
return f.slice(1).forEach((p) => {
|
|
764
|
-
const h = p.slice(-1) === "'";
|
|
765
|
-
let s = 2147483647 & parseInt(h ? p.slice(0, -1) : p, 10);
|
|
766
|
-
h && (s += 2147483648), d.writeUInt32LE(s, v), v += 4;
|
|
767
|
-
}), {
|
|
768
|
-
key: u,
|
|
769
|
-
value: d
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
M.encode = r, M.expected = "{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }";
|
|
773
|
-
function g(i) {
|
|
774
|
-
const t = i.extendedPubkey, u = i.masterFingerprint, f = i.path;
|
|
775
|
-
return S.isBuffer(t) && t.length === 78 && [2, 3].indexOf(t[45]) > -1 && S.isBuffer(u) && u.length === 4 && typeof f == "string" && !!f.match(/^m(\/\d+'?)*$/);
|
|
776
|
-
}
|
|
777
|
-
M.check = g;
|
|
778
|
-
function o(i, t, u) {
|
|
779
|
-
const f = t.extendedPubkey.toString("hex");
|
|
780
|
-
return u.has(f) ? !1 : (u.add(f), i.filter((d) => d.extendedPubkey.equals(t.extendedPubkey)).length === 0);
|
|
781
|
-
}
|
|
782
|
-
return M.canAddToArray = o, M;
|
|
783
|
-
}
|
|
784
|
-
var Ee = {}, ur;
|
|
785
|
-
function Yt() {
|
|
786
|
-
if (ur) return Ee;
|
|
787
|
-
ur = 1, Object.defineProperty(Ee, "__esModule", { value: !0 });
|
|
788
|
-
const e = B();
|
|
789
|
-
function n(c) {
|
|
790
|
-
return {
|
|
791
|
-
key: S.from([e.GlobalTypes.UNSIGNED_TX]),
|
|
792
|
-
value: c.toBuffer()
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
return Ee.encode = n, Ee;
|
|
796
|
-
}
|
|
797
|
-
var D = {}, fr;
|
|
798
|
-
function zt() {
|
|
799
|
-
if (fr) return D;
|
|
800
|
-
fr = 1, Object.defineProperty(D, "__esModule", { value: !0 });
|
|
801
|
-
const e = B();
|
|
802
|
-
function n(o) {
|
|
803
|
-
if (o.key[0] !== e.InputTypes.FINAL_SCRIPTSIG)
|
|
804
|
-
throw new Error(
|
|
805
|
-
"Decode Error: could not decode finalScriptSig with key 0x" + o.key.toString("hex")
|
|
806
|
-
);
|
|
807
|
-
return o.value;
|
|
808
|
-
}
|
|
809
|
-
D.decode = n;
|
|
810
|
-
function c(o) {
|
|
811
|
-
return {
|
|
812
|
-
key: S.from([e.InputTypes.FINAL_SCRIPTSIG]),
|
|
813
|
-
value: o
|
|
814
|
-
};
|
|
815
|
-
}
|
|
816
|
-
D.encode = c, D.expected = "Buffer";
|
|
817
|
-
function r(o) {
|
|
818
|
-
return S.isBuffer(o);
|
|
819
|
-
}
|
|
820
|
-
D.check = r;
|
|
821
|
-
function g(o, i) {
|
|
822
|
-
return !!o && !!i && o.finalScriptSig === void 0;
|
|
823
|
-
}
|
|
824
|
-
return D.canAdd = g, D;
|
|
825
|
-
}
|
|
826
|
-
var F = {}, ar;
|
|
827
|
-
function Zt() {
|
|
828
|
-
if (ar) return F;
|
|
829
|
-
ar = 1, Object.defineProperty(F, "__esModule", { value: !0 });
|
|
830
|
-
const e = B();
|
|
831
|
-
function n(o) {
|
|
832
|
-
if (o.key[0] !== e.InputTypes.FINAL_SCRIPTWITNESS)
|
|
833
|
-
throw new Error(
|
|
834
|
-
"Decode Error: could not decode finalScriptWitness with key 0x" + o.key.toString("hex")
|
|
835
|
-
);
|
|
836
|
-
return o.value;
|
|
837
|
-
}
|
|
838
|
-
F.decode = n;
|
|
839
|
-
function c(o) {
|
|
840
|
-
return {
|
|
841
|
-
key: S.from([e.InputTypes.FINAL_SCRIPTWITNESS]),
|
|
842
|
-
value: o
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
F.encode = c, F.expected = "Buffer";
|
|
846
|
-
function r(o) {
|
|
847
|
-
return S.isBuffer(o);
|
|
848
|
-
}
|
|
849
|
-
F.check = r;
|
|
850
|
-
function g(o, i) {
|
|
851
|
-
return !!o && !!i && o.finalScriptWitness === void 0;
|
|
852
|
-
}
|
|
853
|
-
return F.canAdd = g, F;
|
|
854
|
-
}
|
|
855
|
-
var j = {}, sr;
|
|
856
|
-
function Qt() {
|
|
857
|
-
if (sr) return j;
|
|
858
|
-
sr = 1, Object.defineProperty(j, "__esModule", { value: !0 });
|
|
859
|
-
const e = B();
|
|
860
|
-
function n(o) {
|
|
861
|
-
if (o.key[0] !== e.InputTypes.NON_WITNESS_UTXO)
|
|
862
|
-
throw new Error(
|
|
863
|
-
"Decode Error: could not decode nonWitnessUtxo with key 0x" + o.key.toString("hex")
|
|
864
|
-
);
|
|
865
|
-
return o.value;
|
|
866
|
-
}
|
|
867
|
-
j.decode = n;
|
|
868
|
-
function c(o) {
|
|
869
|
-
return {
|
|
870
|
-
key: S.from([e.InputTypes.NON_WITNESS_UTXO]),
|
|
871
|
-
value: o
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
j.encode = c, j.expected = "Buffer";
|
|
875
|
-
function r(o) {
|
|
876
|
-
return S.isBuffer(o);
|
|
877
|
-
}
|
|
878
|
-
j.check = r;
|
|
879
|
-
function g(o, i) {
|
|
880
|
-
return !!o && !!i && o.nonWitnessUtxo === void 0;
|
|
881
|
-
}
|
|
882
|
-
return j.canAdd = g, j;
|
|
883
|
-
}
|
|
884
|
-
var W = {}, dr;
|
|
885
|
-
function $t() {
|
|
886
|
-
if (dr) return W;
|
|
887
|
-
dr = 1, Object.defineProperty(W, "__esModule", { value: !0 });
|
|
888
|
-
const e = B();
|
|
889
|
-
function n(i) {
|
|
890
|
-
if (i.key[0] !== e.InputTypes.PARTIAL_SIG)
|
|
891
|
-
throw new Error(
|
|
892
|
-
"Decode Error: could not decode partialSig with key 0x" + i.key.toString("hex")
|
|
893
|
-
);
|
|
894
|
-
if (!(i.key.length === 34 || i.key.length === 66) || ![2, 3, 4].includes(i.key[1]))
|
|
895
|
-
throw new Error(
|
|
896
|
-
"Decode Error: partialSig has invalid pubkey in key 0x" + i.key.toString("hex")
|
|
897
|
-
);
|
|
898
|
-
return {
|
|
899
|
-
pubkey: i.key.slice(1),
|
|
900
|
-
signature: i.value
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
W.decode = n;
|
|
904
|
-
function c(i) {
|
|
905
|
-
const t = S.from([e.InputTypes.PARTIAL_SIG]);
|
|
906
|
-
return {
|
|
907
|
-
key: S.concat([t, i.pubkey]),
|
|
908
|
-
value: i.signature
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
W.encode = c, W.expected = "{ pubkey: Buffer; signature: Buffer; }";
|
|
912
|
-
function r(i) {
|
|
913
|
-
return S.isBuffer(i.pubkey) && S.isBuffer(i.signature) && [33, 65].includes(i.pubkey.length) && [2, 3, 4].includes(i.pubkey[0]) && g(i.signature);
|
|
914
|
-
}
|
|
915
|
-
W.check = r;
|
|
916
|
-
function g(i) {
|
|
917
|
-
if (!S.isBuffer(i) || i.length < 9 || i[0] !== 48 || i.length !== i[1] + 3 || i[2] !== 2) return !1;
|
|
918
|
-
const t = i[3];
|
|
919
|
-
if (t > 33 || t < 1 || i[3 + t + 1] !== 2) return !1;
|
|
920
|
-
const u = i[3 + t + 2];
|
|
921
|
-
return !(u > 33 || u < 1 || i.length !== 3 + t + 2 + u + 2);
|
|
922
|
-
}
|
|
923
|
-
function o(i, t, u) {
|
|
924
|
-
const f = t.pubkey.toString("hex");
|
|
925
|
-
return u.has(f) ? !1 : (u.add(f), i.filter((d) => d.pubkey.equals(t.pubkey)).length === 0);
|
|
926
|
-
}
|
|
927
|
-
return W.canAddToArray = o, W;
|
|
928
|
-
}
|
|
929
|
-
var H = {}, lr;
|
|
930
|
-
function en() {
|
|
931
|
-
if (lr) return H;
|
|
932
|
-
lr = 1, Object.defineProperty(H, "__esModule", { value: !0 });
|
|
933
|
-
const e = B();
|
|
934
|
-
function n(o) {
|
|
935
|
-
if (o.key[0] !== e.InputTypes.POR_COMMITMENT)
|
|
936
|
-
throw new Error(
|
|
937
|
-
"Decode Error: could not decode porCommitment with key 0x" + o.key.toString("hex")
|
|
938
|
-
);
|
|
939
|
-
return o.value.toString("utf8");
|
|
940
|
-
}
|
|
941
|
-
H.decode = n;
|
|
942
|
-
function c(o) {
|
|
943
|
-
return {
|
|
944
|
-
key: S.from([e.InputTypes.POR_COMMITMENT]),
|
|
945
|
-
value: S.from(o, "utf8")
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
H.encode = c, H.expected = "string";
|
|
949
|
-
function r(o) {
|
|
950
|
-
return typeof o == "string";
|
|
951
|
-
}
|
|
952
|
-
H.check = r;
|
|
953
|
-
function g(o, i) {
|
|
954
|
-
return !!o && !!i && o.porCommitment === void 0;
|
|
955
|
-
}
|
|
956
|
-
return H.canAdd = g, H;
|
|
957
|
-
}
|
|
958
|
-
var G = {}, pr;
|
|
959
|
-
function rn() {
|
|
960
|
-
if (pr) return G;
|
|
961
|
-
pr = 1, Object.defineProperty(G, "__esModule", { value: !0 });
|
|
962
|
-
const e = B();
|
|
963
|
-
function n(o) {
|
|
964
|
-
if (o.key[0] !== e.InputTypes.SIGHASH_TYPE)
|
|
965
|
-
throw new Error(
|
|
966
|
-
"Decode Error: could not decode sighashType with key 0x" + o.key.toString("hex")
|
|
967
|
-
);
|
|
968
|
-
return o.value.readUInt32LE(0);
|
|
969
|
-
}
|
|
970
|
-
G.decode = n;
|
|
971
|
-
function c(o) {
|
|
972
|
-
const i = S.from([e.InputTypes.SIGHASH_TYPE]), t = S.allocUnsafe(4);
|
|
973
|
-
return t.writeUInt32LE(o, 0), {
|
|
974
|
-
key: i,
|
|
975
|
-
value: t
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
G.encode = c, G.expected = "number";
|
|
979
|
-
function r(o) {
|
|
980
|
-
return typeof o == "number";
|
|
981
|
-
}
|
|
982
|
-
G.check = r;
|
|
983
|
-
function g(o, i) {
|
|
984
|
-
return !!o && !!i && o.sighashType === void 0;
|
|
985
|
-
}
|
|
986
|
-
return G.canAdd = g, G;
|
|
987
|
-
}
|
|
988
|
-
var V = {}, hr;
|
|
989
|
-
function tn() {
|
|
990
|
-
if (hr) return V;
|
|
991
|
-
hr = 1, Object.defineProperty(V, "__esModule", { value: !0 });
|
|
992
|
-
const e = B();
|
|
993
|
-
function n(o) {
|
|
994
|
-
if (o.key[0] !== e.InputTypes.TAP_KEY_SIG || o.key.length !== 1)
|
|
995
|
-
throw new Error(
|
|
996
|
-
"Decode Error: could not decode tapKeySig with key 0x" + o.key.toString("hex")
|
|
997
|
-
);
|
|
998
|
-
if (!r(o.value))
|
|
999
|
-
throw new Error(
|
|
1000
|
-
"Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature"
|
|
1001
|
-
);
|
|
1002
|
-
return o.value;
|
|
1003
|
-
}
|
|
1004
|
-
V.decode = n;
|
|
1005
|
-
function c(o) {
|
|
1006
|
-
return { key: S.from([e.InputTypes.TAP_KEY_SIG]), value: o };
|
|
1007
|
-
}
|
|
1008
|
-
V.encode = c, V.expected = "Buffer";
|
|
1009
|
-
function r(o) {
|
|
1010
|
-
return S.isBuffer(o) && (o.length === 64 || o.length === 65);
|
|
1011
|
-
}
|
|
1012
|
-
V.check = r;
|
|
1013
|
-
function g(o, i) {
|
|
1014
|
-
return !!o && !!i && o.tapKeySig === void 0;
|
|
1015
|
-
}
|
|
1016
|
-
return V.canAdd = g, V;
|
|
1017
|
-
}
|
|
1018
|
-
var X = {}, yr;
|
|
1019
|
-
function nn() {
|
|
1020
|
-
if (yr) return X;
|
|
1021
|
-
yr = 1, Object.defineProperty(X, "__esModule", { value: !0 });
|
|
1022
|
-
const e = B();
|
|
1023
|
-
function n(o) {
|
|
1024
|
-
if (o.key[0] !== e.InputTypes.TAP_LEAF_SCRIPT)
|
|
1025
|
-
throw new Error(
|
|
1026
|
-
"Decode Error: could not decode tapLeafScript with key 0x" + o.key.toString("hex")
|
|
1027
|
-
);
|
|
1028
|
-
if ((o.key.length - 2) % 32 !== 0)
|
|
1029
|
-
throw new Error(
|
|
1030
|
-
"Decode Error: tapLeafScript has invalid control block in key 0x" + o.key.toString("hex")
|
|
1031
|
-
);
|
|
1032
|
-
const i = o.value[o.value.length - 1];
|
|
1033
|
-
if ((o.key[1] & 254) !== i)
|
|
1034
|
-
throw new Error(
|
|
1035
|
-
"Decode Error: tapLeafScript bad leaf version in key 0x" + o.key.toString("hex")
|
|
1036
|
-
);
|
|
1037
|
-
const t = o.value.slice(0, -1);
|
|
1038
|
-
return { controlBlock: o.key.slice(1), script: t, leafVersion: i };
|
|
1039
|
-
}
|
|
1040
|
-
X.decode = n;
|
|
1041
|
-
function c(o) {
|
|
1042
|
-
const i = S.from([e.InputTypes.TAP_LEAF_SCRIPT]), t = S.from([o.leafVersion]);
|
|
1043
|
-
return {
|
|
1044
|
-
key: S.concat([i, o.controlBlock]),
|
|
1045
|
-
value: S.concat([o.script, t])
|
|
1046
|
-
};
|
|
1047
|
-
}
|
|
1048
|
-
X.encode = c, X.expected = "{ controlBlock: Buffer; leafVersion: number, script: Buffer; }";
|
|
1049
|
-
function r(o) {
|
|
1050
|
-
return S.isBuffer(o.controlBlock) && (o.controlBlock.length - 1) % 32 === 0 && (o.controlBlock[0] & 254) === o.leafVersion && S.isBuffer(o.script);
|
|
1051
|
-
}
|
|
1052
|
-
X.check = r;
|
|
1053
|
-
function g(o, i, t) {
|
|
1054
|
-
const u = i.controlBlock.toString("hex");
|
|
1055
|
-
return t.has(u) ? !1 : (t.add(u), o.filter((f) => f.controlBlock.equals(i.controlBlock)).length === 0);
|
|
1056
|
-
}
|
|
1057
|
-
return X.canAddToArray = g, X;
|
|
1058
|
-
}
|
|
1059
|
-
var J = {}, br;
|
|
1060
|
-
function on() {
|
|
1061
|
-
if (br) return J;
|
|
1062
|
-
br = 1, Object.defineProperty(J, "__esModule", { value: !0 });
|
|
1063
|
-
const e = B();
|
|
1064
|
-
function n(o) {
|
|
1065
|
-
if (o.key[0] !== e.InputTypes.TAP_MERKLE_ROOT || o.key.length !== 1)
|
|
1066
|
-
throw new Error(
|
|
1067
|
-
"Decode Error: could not decode tapMerkleRoot with key 0x" + o.key.toString("hex")
|
|
1068
|
-
);
|
|
1069
|
-
if (!r(o.value))
|
|
1070
|
-
throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");
|
|
1071
|
-
return o.value;
|
|
1072
|
-
}
|
|
1073
|
-
J.decode = n;
|
|
1074
|
-
function c(o) {
|
|
1075
|
-
return { key: S.from([e.InputTypes.TAP_MERKLE_ROOT]), value: o };
|
|
1076
|
-
}
|
|
1077
|
-
J.encode = c, J.expected = "Buffer";
|
|
1078
|
-
function r(o) {
|
|
1079
|
-
return S.isBuffer(o) && o.length === 32;
|
|
1080
|
-
}
|
|
1081
|
-
J.check = r;
|
|
1082
|
-
function g(o, i) {
|
|
1083
|
-
return !!o && !!i && o.tapMerkleRoot === void 0;
|
|
1084
|
-
}
|
|
1085
|
-
return J.canAdd = g, J;
|
|
1086
|
-
}
|
|
1087
|
-
var Y = {}, gr;
|
|
1088
|
-
function cn() {
|
|
1089
|
-
if (gr) return Y;
|
|
1090
|
-
gr = 1, Object.defineProperty(Y, "__esModule", { value: !0 });
|
|
1091
|
-
const e = B();
|
|
1092
|
-
function n(o) {
|
|
1093
|
-
if (o.key[0] !== e.InputTypes.TAP_SCRIPT_SIG)
|
|
1094
|
-
throw new Error(
|
|
1095
|
-
"Decode Error: could not decode tapScriptSig with key 0x" + o.key.toString("hex")
|
|
1096
|
-
);
|
|
1097
|
-
if (o.key.length !== 65)
|
|
1098
|
-
throw new Error(
|
|
1099
|
-
"Decode Error: tapScriptSig has invalid key 0x" + o.key.toString("hex")
|
|
1100
|
-
);
|
|
1101
|
-
if (o.value.length !== 64 && o.value.length !== 65)
|
|
1102
|
-
throw new Error(
|
|
1103
|
-
"Decode Error: tapScriptSig has invalid signature in key 0x" + o.key.toString("hex")
|
|
1104
|
-
);
|
|
1105
|
-
const i = o.key.slice(1, 33), t = o.key.slice(33);
|
|
1106
|
-
return {
|
|
1107
|
-
pubkey: i,
|
|
1108
|
-
leafHash: t,
|
|
1109
|
-
signature: o.value
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
Y.decode = n;
|
|
1113
|
-
function c(o) {
|
|
1114
|
-
const i = S.from([e.InputTypes.TAP_SCRIPT_SIG]);
|
|
1115
|
-
return {
|
|
1116
|
-
key: S.concat([i, o.pubkey, o.leafHash]),
|
|
1117
|
-
value: o.signature
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
Y.encode = c, Y.expected = "{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }";
|
|
1121
|
-
function r(o) {
|
|
1122
|
-
return S.isBuffer(o.pubkey) && S.isBuffer(o.leafHash) && S.isBuffer(o.signature) && o.pubkey.length === 32 && o.leafHash.length === 32 && (o.signature.length === 64 || o.signature.length === 65);
|
|
1123
|
-
}
|
|
1124
|
-
Y.check = r;
|
|
1125
|
-
function g(o, i, t) {
|
|
1126
|
-
const u = i.pubkey.toString("hex") + i.leafHash.toString("hex");
|
|
1127
|
-
return t.has(u) ? !1 : (t.add(u), o.filter(
|
|
1128
|
-
(f) => f.pubkey.equals(i.pubkey) && f.leafHash.equals(i.leafHash)
|
|
1129
|
-
).length === 0);
|
|
1130
|
-
}
|
|
1131
|
-
return Y.canAddToArray = g, Y;
|
|
1132
|
-
}
|
|
1133
|
-
var z = {}, L = {}, Er;
|
|
1134
|
-
function Ge() {
|
|
1135
|
-
if (Er) return L;
|
|
1136
|
-
Er = 1, Object.defineProperty(L, "__esModule", { value: !0 });
|
|
1137
|
-
const e = de();
|
|
1138
|
-
L.range = (t) => [...Array(t).keys()];
|
|
1139
|
-
function n(t) {
|
|
1140
|
-
if (t.length < 1) return t;
|
|
1141
|
-
let u = t.length - 1, f = 0;
|
|
1142
|
-
for (let d = 0; d < t.length / 2; d++)
|
|
1143
|
-
f = t[d], t[d] = t[u], t[u] = f, u--;
|
|
1144
|
-
return t;
|
|
1145
|
-
}
|
|
1146
|
-
L.reverseBuffer = n;
|
|
1147
|
-
function c(t) {
|
|
1148
|
-
const u = t.map(r);
|
|
1149
|
-
return u.push(S.from([0])), S.concat(u);
|
|
1150
|
-
}
|
|
1151
|
-
L.keyValsToBuffer = c;
|
|
1152
|
-
function r(t) {
|
|
1153
|
-
const u = t.key.length, f = t.value.length, d = e.encodingLength(u), v = e.encodingLength(f), p = S.allocUnsafe(
|
|
1154
|
-
d + u + v + f
|
|
1155
|
-
);
|
|
1156
|
-
return e.encode(u, p, 0), t.key.copy(p, d), e.encode(f, p, d + u), t.value.copy(p, d + u + v), p;
|
|
1157
|
-
}
|
|
1158
|
-
L.keyValToBuffer = r;
|
|
1159
|
-
function g(t, u) {
|
|
1160
|
-
if (typeof t != "number")
|
|
1161
|
-
throw new Error("cannot write a non-number as a number");
|
|
1162
|
-
if (t < 0)
|
|
1163
|
-
throw new Error("specified a negative value for writing an unsigned value");
|
|
1164
|
-
if (t > u) throw new Error("RangeError: value out of range");
|
|
1165
|
-
if (Math.floor(t) !== t)
|
|
1166
|
-
throw new Error("value has a fractional component");
|
|
1167
|
-
}
|
|
1168
|
-
function o(t, u) {
|
|
1169
|
-
const f = t.readUInt32LE(u);
|
|
1170
|
-
let d = t.readUInt32LE(u + 4);
|
|
1171
|
-
return d *= 4294967296, g(d + f, 9007199254740991), d + f;
|
|
1172
|
-
}
|
|
1173
|
-
L.readUInt64LE = o;
|
|
1174
|
-
function i(t, u, f) {
|
|
1175
|
-
return g(u, 9007199254740991), t.writeInt32LE(u & -1, f), t.writeUInt32LE(Math.floor(u / 4294967296), f + 4), f + 8;
|
|
1176
|
-
}
|
|
1177
|
-
return L.writeUInt64LE = i, L;
|
|
1178
|
-
}
|
|
1179
|
-
var wr;
|
|
1180
|
-
function un() {
|
|
1181
|
-
if (wr) return z;
|
|
1182
|
-
wr = 1, Object.defineProperty(z, "__esModule", { value: !0 });
|
|
1183
|
-
const e = B(), n = Ge(), c = de();
|
|
1184
|
-
function r(t) {
|
|
1185
|
-
if (t.key[0] !== e.InputTypes.WITNESS_UTXO)
|
|
1186
|
-
throw new Error(
|
|
1187
|
-
"Decode Error: could not decode witnessUtxo with key 0x" + t.key.toString("hex")
|
|
1188
|
-
);
|
|
1189
|
-
const u = n.readUInt64LE(t.value, 0);
|
|
1190
|
-
let f = 8;
|
|
1191
|
-
const d = c.decode(t.value, f);
|
|
1192
|
-
f += c.encodingLength(d);
|
|
1193
|
-
const v = t.value.slice(f);
|
|
1194
|
-
if (v.length !== d)
|
|
1195
|
-
throw new Error("Decode Error: WITNESS_UTXO script is not proper length");
|
|
1196
|
-
return {
|
|
1197
|
-
script: v,
|
|
1198
|
-
value: u
|
|
1199
|
-
};
|
|
1200
|
-
}
|
|
1201
|
-
z.decode = r;
|
|
1202
|
-
function g(t) {
|
|
1203
|
-
const { script: u, value: f } = t, d = c.encodingLength(u.length), v = S.allocUnsafe(8 + d + u.length);
|
|
1204
|
-
return n.writeUInt64LE(v, f, 0), c.encode(u.length, v, 8), u.copy(v, 8 + d), {
|
|
1205
|
-
key: S.from([e.InputTypes.WITNESS_UTXO]),
|
|
1206
|
-
value: v
|
|
1207
|
-
};
|
|
1208
|
-
}
|
|
1209
|
-
z.encode = g, z.expected = "{ script: Buffer; value: number; }";
|
|
1210
|
-
function o(t) {
|
|
1211
|
-
return S.isBuffer(t.script) && typeof t.value == "number";
|
|
1212
|
-
}
|
|
1213
|
-
z.check = o;
|
|
1214
|
-
function i(t, u) {
|
|
1215
|
-
return !!t && !!u && t.witnessUtxo === void 0;
|
|
1216
|
-
}
|
|
1217
|
-
return z.canAdd = i, z;
|
|
1218
|
-
}
|
|
1219
|
-
var Z = {}, vr;
|
|
1220
|
-
function fn() {
|
|
1221
|
-
if (vr) return Z;
|
|
1222
|
-
vr = 1, Object.defineProperty(Z, "__esModule", { value: !0 });
|
|
1223
|
-
const e = B(), n = de();
|
|
1224
|
-
function c(i) {
|
|
1225
|
-
if (i.key[0] !== e.OutputTypes.TAP_TREE || i.key.length !== 1)
|
|
1226
|
-
throw new Error(
|
|
1227
|
-
"Decode Error: could not decode tapTree with key 0x" + i.key.toString("hex")
|
|
1228
|
-
);
|
|
1229
|
-
let t = 0;
|
|
1230
|
-
const u = [];
|
|
1231
|
-
for (; t < i.value.length; ) {
|
|
1232
|
-
const f = i.value[t++], d = i.value[t++], v = n.decode(i.value, t);
|
|
1233
|
-
t += n.encodingLength(v), u.push({
|
|
1234
|
-
depth: f,
|
|
1235
|
-
leafVersion: d,
|
|
1236
|
-
script: i.value.slice(t, t + v)
|
|
1237
|
-
}), t += v;
|
|
1238
|
-
}
|
|
1239
|
-
return { leaves: u };
|
|
1240
|
-
}
|
|
1241
|
-
Z.decode = c;
|
|
1242
|
-
function r(i) {
|
|
1243
|
-
const t = S.from([e.OutputTypes.TAP_TREE]), u = [].concat(
|
|
1244
|
-
...i.leaves.map((f) => [
|
|
1245
|
-
S.of(f.depth, f.leafVersion),
|
|
1246
|
-
n.encode(f.script.length),
|
|
1247
|
-
f.script
|
|
1248
|
-
])
|
|
1249
|
-
);
|
|
1250
|
-
return {
|
|
1251
|
-
key: t,
|
|
1252
|
-
value: S.concat(u)
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
Z.encode = r, Z.expected = "{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }";
|
|
1256
|
-
function g(i) {
|
|
1257
|
-
return Array.isArray(i.leaves) && i.leaves.every(
|
|
1258
|
-
(t) => t.depth >= 0 && t.depth <= 128 && (t.leafVersion & 254) === t.leafVersion && S.isBuffer(t.script)
|
|
1259
|
-
);
|
|
1260
|
-
}
|
|
1261
|
-
Z.check = g;
|
|
1262
|
-
function o(i, t) {
|
|
1263
|
-
return !!i && !!t && i.tapTree === void 0;
|
|
1264
|
-
}
|
|
1265
|
-
return Z.canAdd = o, Z;
|
|
1266
|
-
}
|
|
1267
|
-
var we = {}, Sr;
|
|
1268
|
-
function et() {
|
|
1269
|
-
if (Sr) return we;
|
|
1270
|
-
Sr = 1, Object.defineProperty(we, "__esModule", { value: !0 });
|
|
1271
|
-
const e = (r) => [...Array(r).keys()], n = (r) => r.length === 33 && [2, 3].includes(r[0]) || r.length === 65 && r[0] === 4;
|
|
1272
|
-
function c(r, g = n) {
|
|
1273
|
-
function o(d) {
|
|
1274
|
-
if (d.key[0] !== r)
|
|
1275
|
-
throw new Error(
|
|
1276
|
-
"Decode Error: could not decode bip32Derivation with key 0x" + d.key.toString("hex")
|
|
1277
|
-
);
|
|
1278
|
-
const v = d.key.slice(1);
|
|
1279
|
-
if (!g(v))
|
|
1280
|
-
throw new Error(
|
|
1281
|
-
"Decode Error: bip32Derivation has invalid pubkey in key 0x" + d.key.toString("hex")
|
|
1282
|
-
);
|
|
1283
|
-
if (d.value.length / 4 % 1 !== 0)
|
|
1284
|
-
throw new Error(
|
|
1285
|
-
"Decode Error: Input BIP32_DERIVATION value length should be multiple of 4"
|
|
1286
|
-
);
|
|
1287
|
-
const p = {
|
|
1288
|
-
masterFingerprint: d.value.slice(0, 4),
|
|
1289
|
-
pubkey: v,
|
|
1290
|
-
path: "m"
|
|
1291
|
-
};
|
|
1292
|
-
for (const h of e(d.value.length / 4 - 1)) {
|
|
1293
|
-
const s = d.value.readUInt32LE(h * 4 + 4), a = !!(s & 2147483648), l = s & 2147483647;
|
|
1294
|
-
p.path += "/" + l.toString(10) + (a ? "'" : "");
|
|
1295
|
-
}
|
|
1296
|
-
return p;
|
|
1297
|
-
}
|
|
1298
|
-
function i(d) {
|
|
1299
|
-
const v = S.from([r]), p = S.concat([v, d.pubkey]), h = d.path.split("/"), s = S.allocUnsafe(h.length * 4);
|
|
1300
|
-
d.masterFingerprint.copy(s, 0);
|
|
1301
|
-
let a = 4;
|
|
1302
|
-
return h.slice(1).forEach((l) => {
|
|
1303
|
-
const E = l.slice(-1) === "'";
|
|
1304
|
-
let b = 2147483647 & parseInt(E ? l.slice(0, -1) : l, 10);
|
|
1305
|
-
E && (b += 2147483648), s.writeUInt32LE(b, a), a += 4;
|
|
1306
|
-
}), {
|
|
1307
|
-
key: p,
|
|
1308
|
-
value: s
|
|
1309
|
-
};
|
|
1310
|
-
}
|
|
1311
|
-
const t = "{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }";
|
|
1312
|
-
function u(d) {
|
|
1313
|
-
return S.isBuffer(d.pubkey) && S.isBuffer(d.masterFingerprint) && typeof d.path == "string" && g(d.pubkey) && d.masterFingerprint.length === 4;
|
|
1314
|
-
}
|
|
1315
|
-
function f(d, v, p) {
|
|
1316
|
-
const h = v.pubkey.toString("hex");
|
|
1317
|
-
return p.has(h) ? !1 : (p.add(h), d.filter((s) => s.pubkey.equals(v.pubkey)).length === 0);
|
|
1318
|
-
}
|
|
1319
|
-
return {
|
|
1320
|
-
decode: o,
|
|
1321
|
-
encode: i,
|
|
1322
|
-
check: u,
|
|
1323
|
-
expected: t,
|
|
1324
|
-
canAddToArray: f
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
return we.makeConverter = c, we;
|
|
1328
|
-
}
|
|
1329
|
-
var ve = {}, _r;
|
|
1330
|
-
function an() {
|
|
1331
|
-
if (_r) return ve;
|
|
1332
|
-
_r = 1, Object.defineProperty(ve, "__esModule", { value: !0 });
|
|
1333
|
-
function e(n) {
|
|
1334
|
-
return c;
|
|
1335
|
-
function c(r) {
|
|
1336
|
-
let g;
|
|
1337
|
-
if (n.includes(r.key[0]) && (g = r.key.slice(1), !(g.length === 33 || g.length === 65) || ![2, 3, 4].includes(g[0])))
|
|
1338
|
-
throw new Error(
|
|
1339
|
-
"Format Error: invalid pubkey in key 0x" + r.key.toString("hex")
|
|
1340
|
-
);
|
|
1341
|
-
return g;
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
return ve.makeChecker = e, ve;
|
|
1345
|
-
}
|
|
1346
|
-
var Se = {}, Tr;
|
|
1347
|
-
function sn() {
|
|
1348
|
-
if (Tr) return Se;
|
|
1349
|
-
Tr = 1, Object.defineProperty(Se, "__esModule", { value: !0 });
|
|
1350
|
-
function e(n) {
|
|
1351
|
-
function c(t) {
|
|
1352
|
-
if (t.key[0] !== n)
|
|
1353
|
-
throw new Error(
|
|
1354
|
-
"Decode Error: could not decode redeemScript with key 0x" + t.key.toString("hex")
|
|
1355
|
-
);
|
|
1356
|
-
return t.value;
|
|
1357
|
-
}
|
|
1358
|
-
function r(t) {
|
|
1359
|
-
return {
|
|
1360
|
-
key: S.from([n]),
|
|
1361
|
-
value: t
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
const g = "Buffer";
|
|
1365
|
-
function o(t) {
|
|
1366
|
-
return S.isBuffer(t);
|
|
1367
|
-
}
|
|
1368
|
-
function i(t, u) {
|
|
1369
|
-
return !!t && !!u && t.redeemScript === void 0;
|
|
1370
|
-
}
|
|
1371
|
-
return {
|
|
1372
|
-
decode: c,
|
|
1373
|
-
encode: r,
|
|
1374
|
-
check: o,
|
|
1375
|
-
expected: g,
|
|
1376
|
-
canAdd: i
|
|
1377
|
-
};
|
|
1378
|
-
}
|
|
1379
|
-
return Se.makeConverter = e, Se;
|
|
1380
|
-
}
|
|
1381
|
-
var _e = {}, mr;
|
|
1382
|
-
function dn() {
|
|
1383
|
-
if (mr) return _e;
|
|
1384
|
-
mr = 1, Object.defineProperty(_e, "__esModule", { value: !0 });
|
|
1385
|
-
const e = de(), n = et(), c = (g) => g.length === 32;
|
|
1386
|
-
function r(g) {
|
|
1387
|
-
const o = n.makeConverter(g, c);
|
|
1388
|
-
function i(d) {
|
|
1389
|
-
const v = e.decode(d.value), p = e.encodingLength(v), h = o.decode({
|
|
1390
|
-
key: d.key,
|
|
1391
|
-
value: d.value.slice(p + v * 32)
|
|
1392
|
-
}), s = new Array(v);
|
|
1393
|
-
for (let a = 0, l = p; a < v; a++, l += 32)
|
|
1394
|
-
s[a] = d.value.slice(l, l + 32);
|
|
1395
|
-
return Object.assign({}, h, { leafHashes: s });
|
|
1396
|
-
}
|
|
1397
|
-
function t(d) {
|
|
1398
|
-
const v = o.encode(d), p = e.encodingLength(d.leafHashes.length), h = S.allocUnsafe(p);
|
|
1399
|
-
e.encode(d.leafHashes.length, h);
|
|
1400
|
-
const s = S.concat([h, ...d.leafHashes, v.value]);
|
|
1401
|
-
return Object.assign({}, v, { value: s });
|
|
1402
|
-
}
|
|
1403
|
-
const u = "{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }";
|
|
1404
|
-
function f(d) {
|
|
1405
|
-
return Array.isArray(d.leafHashes) && d.leafHashes.every(
|
|
1406
|
-
(v) => S.isBuffer(v) && v.length === 32
|
|
1407
|
-
) && o.check(d);
|
|
1408
|
-
}
|
|
1409
|
-
return {
|
|
1410
|
-
decode: i,
|
|
1411
|
-
encode: t,
|
|
1412
|
-
check: f,
|
|
1413
|
-
expected: u,
|
|
1414
|
-
canAddToArray: o.canAddToArray
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
return _e.makeConverter = r, _e;
|
|
1418
|
-
}
|
|
1419
|
-
var Te = {}, kr;
|
|
1420
|
-
function ln() {
|
|
1421
|
-
if (kr) return Te;
|
|
1422
|
-
kr = 1, Object.defineProperty(Te, "__esModule", { value: !0 });
|
|
1423
|
-
function e(n) {
|
|
1424
|
-
function c(t) {
|
|
1425
|
-
if (t.key[0] !== n || t.key.length !== 1)
|
|
1426
|
-
throw new Error(
|
|
1427
|
-
"Decode Error: could not decode tapInternalKey with key 0x" + t.key.toString("hex")
|
|
1428
|
-
);
|
|
1429
|
-
if (t.value.length !== 32)
|
|
1430
|
-
throw new Error(
|
|
1431
|
-
"Decode Error: tapInternalKey not a 32-byte x-only pubkey"
|
|
1432
|
-
);
|
|
1433
|
-
return t.value;
|
|
1434
|
-
}
|
|
1435
|
-
function r(t) {
|
|
1436
|
-
return { key: S.from([n]), value: t };
|
|
1437
|
-
}
|
|
1438
|
-
const g = "Buffer";
|
|
1439
|
-
function o(t) {
|
|
1440
|
-
return S.isBuffer(t) && t.length === 32;
|
|
1441
|
-
}
|
|
1442
|
-
function i(t, u) {
|
|
1443
|
-
return !!t && !!u && t.tapInternalKey === void 0;
|
|
1444
|
-
}
|
|
1445
|
-
return {
|
|
1446
|
-
decode: c,
|
|
1447
|
-
encode: r,
|
|
1448
|
-
check: o,
|
|
1449
|
-
expected: g,
|
|
1450
|
-
canAdd: i
|
|
1451
|
-
};
|
|
1452
|
-
}
|
|
1453
|
-
return Te.makeConverter = e, Te;
|
|
1454
|
-
}
|
|
1455
|
-
var me = {}, Ir;
|
|
1456
|
-
function pn() {
|
|
1457
|
-
if (Ir) return me;
|
|
1458
|
-
Ir = 1, Object.defineProperty(me, "__esModule", { value: !0 });
|
|
1459
|
-
function e(n) {
|
|
1460
|
-
function c(t) {
|
|
1461
|
-
if (t.key[0] !== n)
|
|
1462
|
-
throw new Error(
|
|
1463
|
-
"Decode Error: could not decode witnessScript with key 0x" + t.key.toString("hex")
|
|
1464
|
-
);
|
|
1465
|
-
return t.value;
|
|
1466
|
-
}
|
|
1467
|
-
function r(t) {
|
|
1468
|
-
return {
|
|
1469
|
-
key: S.from([n]),
|
|
1470
|
-
value: t
|
|
1471
|
-
};
|
|
1472
|
-
}
|
|
1473
|
-
const g = "Buffer";
|
|
1474
|
-
function o(t) {
|
|
1475
|
-
return S.isBuffer(t);
|
|
1476
|
-
}
|
|
1477
|
-
function i(t, u) {
|
|
1478
|
-
return !!t && !!u && t.witnessScript === void 0;
|
|
1479
|
-
}
|
|
1480
|
-
return {
|
|
1481
|
-
decode: c,
|
|
1482
|
-
encode: r,
|
|
1483
|
-
check: o,
|
|
1484
|
-
expected: g,
|
|
1485
|
-
canAdd: i
|
|
1486
|
-
};
|
|
1487
|
-
}
|
|
1488
|
-
return me.makeConverter = e, me;
|
|
1489
|
-
}
|
|
1490
|
-
var Ar;
|
|
1491
|
-
function Ve() {
|
|
1492
|
-
if (Ar) return ue;
|
|
1493
|
-
Ar = 1, Object.defineProperty(ue, "__esModule", { value: !0 });
|
|
1494
|
-
const e = B(), n = Jt(), c = Yt(), r = zt(), g = Zt(), o = Qt(), i = $t(), t = en(), u = rn(), f = tn(), d = nn(), v = on(), p = cn(), h = un(), s = fn(), a = et(), l = an(), E = sn(), b = dn(), w = ln(), m = pn(), x = {
|
|
1495
|
-
unsignedTx: c,
|
|
1496
|
-
globalXpub: n,
|
|
1497
|
-
// pass an Array of key bytes that require pubkey beside the key
|
|
1498
|
-
checkPubkey: l.makeChecker([])
|
|
1499
|
-
};
|
|
1500
|
-
ue.globals = x;
|
|
1501
|
-
const _ = {
|
|
1502
|
-
nonWitnessUtxo: o,
|
|
1503
|
-
partialSig: i,
|
|
1504
|
-
sighashType: u,
|
|
1505
|
-
finalScriptSig: r,
|
|
1506
|
-
finalScriptWitness: g,
|
|
1507
|
-
porCommitment: t,
|
|
1508
|
-
witnessUtxo: h,
|
|
1509
|
-
bip32Derivation: a.makeConverter(
|
|
1510
|
-
e.InputTypes.BIP32_DERIVATION
|
|
1511
|
-
),
|
|
1512
|
-
redeemScript: E.makeConverter(
|
|
1513
|
-
e.InputTypes.REDEEM_SCRIPT
|
|
1514
|
-
),
|
|
1515
|
-
witnessScript: m.makeConverter(
|
|
1516
|
-
e.InputTypes.WITNESS_SCRIPT
|
|
1517
|
-
),
|
|
1518
|
-
checkPubkey: l.makeChecker([
|
|
1519
|
-
e.InputTypes.PARTIAL_SIG,
|
|
1520
|
-
e.InputTypes.BIP32_DERIVATION
|
|
1521
|
-
]),
|
|
1522
|
-
tapKeySig: f,
|
|
1523
|
-
tapScriptSig: p,
|
|
1524
|
-
tapLeafScript: d,
|
|
1525
|
-
tapBip32Derivation: b.makeConverter(
|
|
1526
|
-
e.InputTypes.TAP_BIP32_DERIVATION
|
|
1527
|
-
),
|
|
1528
|
-
tapInternalKey: w.makeConverter(
|
|
1529
|
-
e.InputTypes.TAP_INTERNAL_KEY
|
|
1530
|
-
),
|
|
1531
|
-
tapMerkleRoot: v
|
|
1532
|
-
};
|
|
1533
|
-
ue.inputs = _;
|
|
1534
|
-
const I = {
|
|
1535
|
-
bip32Derivation: a.makeConverter(
|
|
1536
|
-
e.OutputTypes.BIP32_DERIVATION
|
|
1537
|
-
),
|
|
1538
|
-
redeemScript: E.makeConverter(
|
|
1539
|
-
e.OutputTypes.REDEEM_SCRIPT
|
|
1540
|
-
),
|
|
1541
|
-
witnessScript: m.makeConverter(
|
|
1542
|
-
e.OutputTypes.WITNESS_SCRIPT
|
|
1543
|
-
),
|
|
1544
|
-
checkPubkey: l.makeChecker([
|
|
1545
|
-
e.OutputTypes.BIP32_DERIVATION
|
|
1546
|
-
]),
|
|
1547
|
-
tapBip32Derivation: b.makeConverter(
|
|
1548
|
-
e.OutputTypes.TAP_BIP32_DERIVATION
|
|
1549
|
-
),
|
|
1550
|
-
tapTree: s,
|
|
1551
|
-
tapInternalKey: w.makeConverter(
|
|
1552
|
-
e.OutputTypes.TAP_INTERNAL_KEY
|
|
1553
|
-
)
|
|
1554
|
-
};
|
|
1555
|
-
return ue.outputs = I, ue;
|
|
1556
|
-
}
|
|
1557
|
-
var Pr;
|
|
1558
|
-
function hn() {
|
|
1559
|
-
if (Pr) return ce;
|
|
1560
|
-
Pr = 1, Object.defineProperty(ce, "__esModule", { value: !0 });
|
|
1561
|
-
const e = Ve(), n = Ge(), c = de(), r = B();
|
|
1562
|
-
function g(t, u) {
|
|
1563
|
-
let f = 0;
|
|
1564
|
-
function d() {
|
|
1565
|
-
const I = c.decode(t, f);
|
|
1566
|
-
f += c.encodingLength(I);
|
|
1567
|
-
const A = t.slice(f, f + I);
|
|
1568
|
-
return f += I, A;
|
|
1569
|
-
}
|
|
1570
|
-
function v() {
|
|
1571
|
-
const I = t.readUInt32BE(f);
|
|
1572
|
-
return f += 4, I;
|
|
1573
|
-
}
|
|
1574
|
-
function p() {
|
|
1575
|
-
const I = t.readUInt8(f);
|
|
1576
|
-
return f += 1, I;
|
|
1577
|
-
}
|
|
1578
|
-
function h() {
|
|
1579
|
-
const I = d(), A = d();
|
|
1580
|
-
return {
|
|
1581
|
-
key: I,
|
|
1582
|
-
value: A
|
|
1583
|
-
};
|
|
1584
|
-
}
|
|
1585
|
-
function s() {
|
|
1586
|
-
if (f >= t.length)
|
|
1587
|
-
throw new Error("Format Error: Unexpected End of PSBT");
|
|
1588
|
-
const I = t.readUInt8(f) === 0;
|
|
1589
|
-
return I && f++, I;
|
|
1590
|
-
}
|
|
1591
|
-
if (v() !== 1886610036)
|
|
1592
|
-
throw new Error("Format Error: Invalid Magic Number");
|
|
1593
|
-
if (p() !== 255)
|
|
1594
|
-
throw new Error(
|
|
1595
|
-
"Format Error: Magic Number must be followed by 0xff separator"
|
|
1596
|
-
);
|
|
1597
|
-
const a = [], l = {};
|
|
1598
|
-
for (; !s(); ) {
|
|
1599
|
-
const I = h(), A = I.key.toString("hex");
|
|
1600
|
-
if (l[A])
|
|
1601
|
-
throw new Error(
|
|
1602
|
-
"Format Error: Keys must be unique for global keymap: key " + A
|
|
1603
|
-
);
|
|
1604
|
-
l[A] = 1, a.push(I);
|
|
1605
|
-
}
|
|
1606
|
-
const E = a.filter(
|
|
1607
|
-
(I) => I.key[0] === r.GlobalTypes.UNSIGNED_TX
|
|
1608
|
-
);
|
|
1609
|
-
if (E.length !== 1)
|
|
1610
|
-
throw new Error("Format Error: Only one UNSIGNED_TX allowed");
|
|
1611
|
-
const b = u(E[0].value), { inputCount: w, outputCount: m } = b.getInputOutputCounts(), x = [], _ = [];
|
|
1612
|
-
for (const I of n.range(w)) {
|
|
1613
|
-
const A = {}, P = [];
|
|
1614
|
-
for (; !s(); ) {
|
|
1615
|
-
const O = h(), U = O.key.toString("hex");
|
|
1616
|
-
if (A[U])
|
|
1617
|
-
throw new Error(
|
|
1618
|
-
"Format Error: Keys must be unique for each input: input index " + I + " key " + U
|
|
1619
|
-
);
|
|
1620
|
-
A[U] = 1, P.push(O);
|
|
1621
|
-
}
|
|
1622
|
-
x.push(P);
|
|
1623
|
-
}
|
|
1624
|
-
for (const I of n.range(m)) {
|
|
1625
|
-
const A = {}, P = [];
|
|
1626
|
-
for (; !s(); ) {
|
|
1627
|
-
const O = h(), U = O.key.toString("hex");
|
|
1628
|
-
if (A[U])
|
|
1629
|
-
throw new Error(
|
|
1630
|
-
"Format Error: Keys must be unique for each output: output index " + I + " key " + U
|
|
1631
|
-
);
|
|
1632
|
-
A[U] = 1, P.push(O);
|
|
1633
|
-
}
|
|
1634
|
-
_.push(P);
|
|
1635
|
-
}
|
|
1636
|
-
return i(b, {
|
|
1637
|
-
globalMapKeyVals: a,
|
|
1638
|
-
inputKeyVals: x,
|
|
1639
|
-
outputKeyVals: _
|
|
1640
|
-
});
|
|
1641
|
-
}
|
|
1642
|
-
ce.psbtFromBuffer = g;
|
|
1643
|
-
function o(t, u, f) {
|
|
1644
|
-
if (!u.equals(S.from([f])))
|
|
1645
|
-
throw new Error(
|
|
1646
|
-
`Format Error: Invalid ${t} key: ${u.toString("hex")}`
|
|
1647
|
-
);
|
|
1648
|
-
}
|
|
1649
|
-
ce.checkKeyBuffer = o;
|
|
1650
|
-
function i(t, { globalMapKeyVals: u, inputKeyVals: f, outputKeyVals: d }) {
|
|
1651
|
-
const v = {
|
|
1652
|
-
unsignedTx: t
|
|
1653
|
-
};
|
|
1654
|
-
let p = 0;
|
|
1655
|
-
for (const E of u)
|
|
1656
|
-
switch (E.key[0]) {
|
|
1657
|
-
case r.GlobalTypes.UNSIGNED_TX:
|
|
1658
|
-
if (o(
|
|
1659
|
-
"global",
|
|
1660
|
-
E.key,
|
|
1661
|
-
r.GlobalTypes.UNSIGNED_TX
|
|
1662
|
-
), p > 0)
|
|
1663
|
-
throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");
|
|
1664
|
-
p++;
|
|
1665
|
-
break;
|
|
1666
|
-
case r.GlobalTypes.GLOBAL_XPUB:
|
|
1667
|
-
v.globalXpub === void 0 && (v.globalXpub = []), v.globalXpub.push(e.globals.globalXpub.decode(E));
|
|
1668
|
-
break;
|
|
1669
|
-
default:
|
|
1670
|
-
v.unknownKeyVals || (v.unknownKeyVals = []), v.unknownKeyVals.push(E);
|
|
1671
|
-
}
|
|
1672
|
-
const h = f.length, s = d.length, a = [], l = [];
|
|
1673
|
-
for (const E of n.range(h)) {
|
|
1674
|
-
const b = {};
|
|
1675
|
-
for (const w of f[E])
|
|
1676
|
-
switch (e.inputs.checkPubkey(w), w.key[0]) {
|
|
1677
|
-
case r.InputTypes.NON_WITNESS_UTXO:
|
|
1678
|
-
if (o(
|
|
1679
|
-
"input",
|
|
1680
|
-
w.key,
|
|
1681
|
-
r.InputTypes.NON_WITNESS_UTXO
|
|
1682
|
-
), b.nonWitnessUtxo !== void 0)
|
|
1683
|
-
throw new Error(
|
|
1684
|
-
"Format Error: Input has multiple NON_WITNESS_UTXO"
|
|
1685
|
-
);
|
|
1686
|
-
b.nonWitnessUtxo = e.inputs.nonWitnessUtxo.decode(w);
|
|
1687
|
-
break;
|
|
1688
|
-
case r.InputTypes.WITNESS_UTXO:
|
|
1689
|
-
if (o(
|
|
1690
|
-
"input",
|
|
1691
|
-
w.key,
|
|
1692
|
-
r.InputTypes.WITNESS_UTXO
|
|
1693
|
-
), b.witnessUtxo !== void 0)
|
|
1694
|
-
throw new Error("Format Error: Input has multiple WITNESS_UTXO");
|
|
1695
|
-
b.witnessUtxo = e.inputs.witnessUtxo.decode(w);
|
|
1696
|
-
break;
|
|
1697
|
-
case r.InputTypes.PARTIAL_SIG:
|
|
1698
|
-
b.partialSig === void 0 && (b.partialSig = []), b.partialSig.push(e.inputs.partialSig.decode(w));
|
|
1699
|
-
break;
|
|
1700
|
-
case r.InputTypes.SIGHASH_TYPE:
|
|
1701
|
-
if (o(
|
|
1702
|
-
"input",
|
|
1703
|
-
w.key,
|
|
1704
|
-
r.InputTypes.SIGHASH_TYPE
|
|
1705
|
-
), b.sighashType !== void 0)
|
|
1706
|
-
throw new Error("Format Error: Input has multiple SIGHASH_TYPE");
|
|
1707
|
-
b.sighashType = e.inputs.sighashType.decode(w);
|
|
1708
|
-
break;
|
|
1709
|
-
case r.InputTypes.REDEEM_SCRIPT:
|
|
1710
|
-
if (o(
|
|
1711
|
-
"input",
|
|
1712
|
-
w.key,
|
|
1713
|
-
r.InputTypes.REDEEM_SCRIPT
|
|
1714
|
-
), b.redeemScript !== void 0)
|
|
1715
|
-
throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");
|
|
1716
|
-
b.redeemScript = e.inputs.redeemScript.decode(w);
|
|
1717
|
-
break;
|
|
1718
|
-
case r.InputTypes.WITNESS_SCRIPT:
|
|
1719
|
-
if (o(
|
|
1720
|
-
"input",
|
|
1721
|
-
w.key,
|
|
1722
|
-
r.InputTypes.WITNESS_SCRIPT
|
|
1723
|
-
), b.witnessScript !== void 0)
|
|
1724
|
-
throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");
|
|
1725
|
-
b.witnessScript = e.inputs.witnessScript.decode(w);
|
|
1726
|
-
break;
|
|
1727
|
-
case r.InputTypes.BIP32_DERIVATION:
|
|
1728
|
-
b.bip32Derivation === void 0 && (b.bip32Derivation = []), b.bip32Derivation.push(
|
|
1729
|
-
e.inputs.bip32Derivation.decode(w)
|
|
1730
|
-
);
|
|
1731
|
-
break;
|
|
1732
|
-
case r.InputTypes.FINAL_SCRIPTSIG:
|
|
1733
|
-
o(
|
|
1734
|
-
"input",
|
|
1735
|
-
w.key,
|
|
1736
|
-
r.InputTypes.FINAL_SCRIPTSIG
|
|
1737
|
-
), b.finalScriptSig = e.inputs.finalScriptSig.decode(w);
|
|
1738
|
-
break;
|
|
1739
|
-
case r.InputTypes.FINAL_SCRIPTWITNESS:
|
|
1740
|
-
o(
|
|
1741
|
-
"input",
|
|
1742
|
-
w.key,
|
|
1743
|
-
r.InputTypes.FINAL_SCRIPTWITNESS
|
|
1744
|
-
), b.finalScriptWitness = e.inputs.finalScriptWitness.decode(
|
|
1745
|
-
w
|
|
1746
|
-
);
|
|
1747
|
-
break;
|
|
1748
|
-
case r.InputTypes.POR_COMMITMENT:
|
|
1749
|
-
o(
|
|
1750
|
-
"input",
|
|
1751
|
-
w.key,
|
|
1752
|
-
r.InputTypes.POR_COMMITMENT
|
|
1753
|
-
), b.porCommitment = e.inputs.porCommitment.decode(w);
|
|
1754
|
-
break;
|
|
1755
|
-
case r.InputTypes.TAP_KEY_SIG:
|
|
1756
|
-
o(
|
|
1757
|
-
"input",
|
|
1758
|
-
w.key,
|
|
1759
|
-
r.InputTypes.TAP_KEY_SIG
|
|
1760
|
-
), b.tapKeySig = e.inputs.tapKeySig.decode(w);
|
|
1761
|
-
break;
|
|
1762
|
-
case r.InputTypes.TAP_SCRIPT_SIG:
|
|
1763
|
-
b.tapScriptSig === void 0 && (b.tapScriptSig = []), b.tapScriptSig.push(e.inputs.tapScriptSig.decode(w));
|
|
1764
|
-
break;
|
|
1765
|
-
case r.InputTypes.TAP_LEAF_SCRIPT:
|
|
1766
|
-
b.tapLeafScript === void 0 && (b.tapLeafScript = []), b.tapLeafScript.push(e.inputs.tapLeafScript.decode(w));
|
|
1767
|
-
break;
|
|
1768
|
-
case r.InputTypes.TAP_BIP32_DERIVATION:
|
|
1769
|
-
b.tapBip32Derivation === void 0 && (b.tapBip32Derivation = []), b.tapBip32Derivation.push(
|
|
1770
|
-
e.inputs.tapBip32Derivation.decode(w)
|
|
1771
|
-
);
|
|
1772
|
-
break;
|
|
1773
|
-
case r.InputTypes.TAP_INTERNAL_KEY:
|
|
1774
|
-
o(
|
|
1775
|
-
"input",
|
|
1776
|
-
w.key,
|
|
1777
|
-
r.InputTypes.TAP_INTERNAL_KEY
|
|
1778
|
-
), b.tapInternalKey = e.inputs.tapInternalKey.decode(w);
|
|
1779
|
-
break;
|
|
1780
|
-
case r.InputTypes.TAP_MERKLE_ROOT:
|
|
1781
|
-
o(
|
|
1782
|
-
"input",
|
|
1783
|
-
w.key,
|
|
1784
|
-
r.InputTypes.TAP_MERKLE_ROOT
|
|
1785
|
-
), b.tapMerkleRoot = e.inputs.tapMerkleRoot.decode(w);
|
|
1786
|
-
break;
|
|
1787
|
-
default:
|
|
1788
|
-
b.unknownKeyVals || (b.unknownKeyVals = []), b.unknownKeyVals.push(w);
|
|
1789
|
-
}
|
|
1790
|
-
a.push(b);
|
|
1791
|
-
}
|
|
1792
|
-
for (const E of n.range(s)) {
|
|
1793
|
-
const b = {};
|
|
1794
|
-
for (const w of d[E])
|
|
1795
|
-
switch (e.outputs.checkPubkey(w), w.key[0]) {
|
|
1796
|
-
case r.OutputTypes.REDEEM_SCRIPT:
|
|
1797
|
-
if (o(
|
|
1798
|
-
"output",
|
|
1799
|
-
w.key,
|
|
1800
|
-
r.OutputTypes.REDEEM_SCRIPT
|
|
1801
|
-
), b.redeemScript !== void 0)
|
|
1802
|
-
throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");
|
|
1803
|
-
b.redeemScript = e.outputs.redeemScript.decode(w);
|
|
1804
|
-
break;
|
|
1805
|
-
case r.OutputTypes.WITNESS_SCRIPT:
|
|
1806
|
-
if (o(
|
|
1807
|
-
"output",
|
|
1808
|
-
w.key,
|
|
1809
|
-
r.OutputTypes.WITNESS_SCRIPT
|
|
1810
|
-
), b.witnessScript !== void 0)
|
|
1811
|
-
throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");
|
|
1812
|
-
b.witnessScript = e.outputs.witnessScript.decode(w);
|
|
1813
|
-
break;
|
|
1814
|
-
case r.OutputTypes.BIP32_DERIVATION:
|
|
1815
|
-
b.bip32Derivation === void 0 && (b.bip32Derivation = []), b.bip32Derivation.push(
|
|
1816
|
-
e.outputs.bip32Derivation.decode(w)
|
|
1817
|
-
);
|
|
1818
|
-
break;
|
|
1819
|
-
case r.OutputTypes.TAP_INTERNAL_KEY:
|
|
1820
|
-
o(
|
|
1821
|
-
"output",
|
|
1822
|
-
w.key,
|
|
1823
|
-
r.OutputTypes.TAP_INTERNAL_KEY
|
|
1824
|
-
), b.tapInternalKey = e.outputs.tapInternalKey.decode(w);
|
|
1825
|
-
break;
|
|
1826
|
-
case r.OutputTypes.TAP_TREE:
|
|
1827
|
-
o(
|
|
1828
|
-
"output",
|
|
1829
|
-
w.key,
|
|
1830
|
-
r.OutputTypes.TAP_TREE
|
|
1831
|
-
), b.tapTree = e.outputs.tapTree.decode(w);
|
|
1832
|
-
break;
|
|
1833
|
-
case r.OutputTypes.TAP_BIP32_DERIVATION:
|
|
1834
|
-
b.tapBip32Derivation === void 0 && (b.tapBip32Derivation = []), b.tapBip32Derivation.push(
|
|
1835
|
-
e.outputs.tapBip32Derivation.decode(w)
|
|
1836
|
-
);
|
|
1837
|
-
break;
|
|
1838
|
-
default:
|
|
1839
|
-
b.unknownKeyVals || (b.unknownKeyVals = []), b.unknownKeyVals.push(w);
|
|
1840
|
-
}
|
|
1841
|
-
l.push(b);
|
|
1842
|
-
}
|
|
1843
|
-
return { globalMap: v, inputs: a, outputs: l };
|
|
1844
|
-
}
|
|
1845
|
-
return ce.psbtFromKeyVals = i, ce;
|
|
1846
|
-
}
|
|
1847
|
-
var pe = {}, xr;
|
|
1848
|
-
function yn() {
|
|
1849
|
-
if (xr) return pe;
|
|
1850
|
-
xr = 1, Object.defineProperty(pe, "__esModule", { value: !0 });
|
|
1851
|
-
const e = Ve(), n = Ge();
|
|
1852
|
-
function c({ globalMap: i, inputs: t, outputs: u }) {
|
|
1853
|
-
const { globalKeyVals: f, inputKeyVals: d, outputKeyVals: v } = o({
|
|
1854
|
-
globalMap: i,
|
|
1855
|
-
inputs: t,
|
|
1856
|
-
outputs: u
|
|
1857
|
-
}), p = n.keyValsToBuffer(f), h = (E) => E.length === 0 ? [S.from([0])] : E.map(n.keyValsToBuffer), s = h(d), a = h(v), l = S.allocUnsafe(5);
|
|
1858
|
-
return l.writeUIntBE(482972169471, 0, 5), S.concat(
|
|
1859
|
-
[l, p].concat(s, a)
|
|
1860
|
-
);
|
|
1861
|
-
}
|
|
1862
|
-
pe.psbtToBuffer = c;
|
|
1863
|
-
const r = (i, t) => i.key.compare(t.key);
|
|
1864
|
-
function g(i, t) {
|
|
1865
|
-
const u = /* @__PURE__ */ new Set(), f = Object.entries(i).reduce((v, [p, h]) => {
|
|
1866
|
-
if (p === "unknownKeyVals") return v;
|
|
1867
|
-
const s = t[p];
|
|
1868
|
-
if (s === void 0) return v;
|
|
1869
|
-
const a = (Array.isArray(h) ? h : [h]).map(
|
|
1870
|
-
s.encode
|
|
1871
|
-
);
|
|
1872
|
-
return a.map((E) => E.key.toString("hex")).forEach((E) => {
|
|
1873
|
-
if (u.has(E))
|
|
1874
|
-
throw new Error("Serialize Error: Duplicate key: " + E);
|
|
1875
|
-
u.add(E);
|
|
1876
|
-
}), v.concat(a);
|
|
1877
|
-
}, []), d = i.unknownKeyVals ? i.unknownKeyVals.filter((v) => !u.has(v.key.toString("hex"))) : [];
|
|
1878
|
-
return f.concat(d).sort(r);
|
|
1879
|
-
}
|
|
1880
|
-
function o({ globalMap: i, inputs: t, outputs: u }) {
|
|
1881
|
-
return {
|
|
1882
|
-
globalKeyVals: g(i, e.globals),
|
|
1883
|
-
inputKeyVals: t.map((f) => g(f, e.inputs)),
|
|
1884
|
-
outputKeyVals: u.map((f) => g(f, e.outputs))
|
|
1885
|
-
};
|
|
1886
|
-
}
|
|
1887
|
-
return pe.psbtToKeyVals = o, pe;
|
|
1888
|
-
}
|
|
1889
|
-
var Or;
|
|
1890
|
-
function rt() {
|
|
1891
|
-
return Or || (Or = 1, (function(e) {
|
|
1892
|
-
function n(c) {
|
|
1893
|
-
for (var r in c) e.hasOwnProperty(r) || (e[r] = c[r]);
|
|
1894
|
-
}
|
|
1895
|
-
Object.defineProperty(e, "__esModule", { value: !0 }), n(hn()), n(yn());
|
|
1896
|
-
})(Ue)), Ue;
|
|
1897
|
-
}
|
|
1898
|
-
var Rr;
|
|
1899
|
-
function bn() {
|
|
1900
|
-
if (Rr) return ge;
|
|
1901
|
-
Rr = 1, Object.defineProperty(ge, "__esModule", { value: !0 });
|
|
1902
|
-
const e = rt();
|
|
1903
|
-
function n(o) {
|
|
1904
|
-
const i = o[0], t = e.psbtToKeyVals(i), u = o.slice(1);
|
|
1905
|
-
if (u.length === 0) throw new Error("Combine: Nothing to combine");
|
|
1906
|
-
const f = r(i);
|
|
1907
|
-
if (f === void 0)
|
|
1908
|
-
throw new Error("Combine: Self missing transaction");
|
|
1909
|
-
const d = g(t.globalKeyVals), v = t.inputKeyVals.map(g), p = t.outputKeyVals.map(g);
|
|
1910
|
-
for (const h of u) {
|
|
1911
|
-
const s = r(h);
|
|
1912
|
-
if (s === void 0 || !s.toBuffer().equals(f.toBuffer()))
|
|
1913
|
-
throw new Error(
|
|
1914
|
-
"Combine: One of the Psbts does not have the same transaction."
|
|
1915
|
-
);
|
|
1916
|
-
const a = e.psbtToKeyVals(h);
|
|
1917
|
-
g(a.globalKeyVals).forEach(
|
|
1918
|
-
c(
|
|
1919
|
-
d,
|
|
1920
|
-
t.globalKeyVals,
|
|
1921
|
-
a.globalKeyVals
|
|
1922
|
-
)
|
|
1923
|
-
), a.inputKeyVals.map(g).forEach(
|
|
1924
|
-
(w, m) => w.forEach(
|
|
1925
|
-
c(
|
|
1926
|
-
v[m],
|
|
1927
|
-
t.inputKeyVals[m],
|
|
1928
|
-
a.inputKeyVals[m]
|
|
1929
|
-
)
|
|
1930
|
-
)
|
|
1931
|
-
), a.outputKeyVals.map(g).forEach(
|
|
1932
|
-
(w, m) => w.forEach(
|
|
1933
|
-
c(
|
|
1934
|
-
p[m],
|
|
1935
|
-
t.outputKeyVals[m],
|
|
1936
|
-
a.outputKeyVals[m]
|
|
1937
|
-
)
|
|
1938
|
-
)
|
|
1939
|
-
);
|
|
1940
|
-
}
|
|
1941
|
-
return e.psbtFromKeyVals(f, {
|
|
1942
|
-
globalMapKeyVals: t.globalKeyVals,
|
|
1943
|
-
inputKeyVals: t.inputKeyVals,
|
|
1944
|
-
outputKeyVals: t.outputKeyVals
|
|
1945
|
-
});
|
|
1946
|
-
}
|
|
1947
|
-
ge.combine = n;
|
|
1948
|
-
function c(o, i, t) {
|
|
1949
|
-
return (u) => {
|
|
1950
|
-
if (o.has(u)) return;
|
|
1951
|
-
const f = t.filter((d) => d.key.toString("hex") === u)[0];
|
|
1952
|
-
i.push(f), o.add(u);
|
|
1953
|
-
};
|
|
1954
|
-
}
|
|
1955
|
-
function r(o) {
|
|
1956
|
-
return o.globalMap.unsignedTx;
|
|
1957
|
-
}
|
|
1958
|
-
function g(o) {
|
|
1959
|
-
const i = /* @__PURE__ */ new Set();
|
|
1960
|
-
return o.forEach((t) => {
|
|
1961
|
-
const u = t.key.toString("hex");
|
|
1962
|
-
if (i.has(u))
|
|
1963
|
-
throw new Error("Combine: KeyValue Map keys should be unique");
|
|
1964
|
-
i.add(u);
|
|
1965
|
-
}), i;
|
|
1966
|
-
}
|
|
1967
|
-
return ge;
|
|
1968
|
-
}
|
|
1969
|
-
var Ce = {}, Nr;
|
|
1970
|
-
function tt() {
|
|
1971
|
-
return Nr || (Nr = 1, (function(e) {
|
|
1972
|
-
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
1973
|
-
const n = Ve();
|
|
1974
|
-
function c(h, s) {
|
|
1975
|
-
const a = h[s];
|
|
1976
|
-
if (a === void 0) throw new Error(`No input #${s}`);
|
|
1977
|
-
return a;
|
|
1978
|
-
}
|
|
1979
|
-
e.checkForInput = c;
|
|
1980
|
-
function r(h, s) {
|
|
1981
|
-
const a = h[s];
|
|
1982
|
-
if (a === void 0) throw new Error(`No output #${s}`);
|
|
1983
|
-
return a;
|
|
1984
|
-
}
|
|
1985
|
-
e.checkForOutput = r;
|
|
1986
|
-
function g(h, s, a) {
|
|
1987
|
-
if (h.key[0] < a)
|
|
1988
|
-
throw new Error(
|
|
1989
|
-
"Use the method for your specific key instead of addUnknownKeyVal*"
|
|
1990
|
-
);
|
|
1991
|
-
if (s && s.filter((l) => l.key.equals(h.key)).length !== 0)
|
|
1992
|
-
throw new Error(`Duplicate Key: ${h.key.toString("hex")}`);
|
|
1993
|
-
}
|
|
1994
|
-
e.checkHasKey = g;
|
|
1995
|
-
function o(h) {
|
|
1996
|
-
let s = 0;
|
|
1997
|
-
return Object.keys(h).forEach((a) => {
|
|
1998
|
-
Number(isNaN(Number(a))) && s++;
|
|
1999
|
-
}), s;
|
|
2000
|
-
}
|
|
2001
|
-
e.getEnumLength = o;
|
|
2002
|
-
function i(h, s) {
|
|
2003
|
-
let a = !1;
|
|
2004
|
-
if (s.nonWitnessUtxo || s.witnessUtxo) {
|
|
2005
|
-
const l = !!s.redeemScript, E = !!s.witnessScript, b = !l || !!s.finalScriptSig, w = !E || !!s.finalScriptWitness, m = !!s.finalScriptSig || !!s.finalScriptWitness;
|
|
2006
|
-
a = b && w && m;
|
|
2007
|
-
}
|
|
2008
|
-
if (a === !1)
|
|
2009
|
-
throw new Error(
|
|
2010
|
-
`Input #${h} has too much or too little data to clean`
|
|
2011
|
-
);
|
|
2012
|
-
}
|
|
2013
|
-
e.inputCheckUncleanFinalized = i;
|
|
2014
|
-
function t(h, s, a, l) {
|
|
2015
|
-
throw new Error(
|
|
2016
|
-
`Data for ${h} key ${s} is incorrect: Expected ${a} and got ${JSON.stringify(l)}`
|
|
2017
|
-
);
|
|
2018
|
-
}
|
|
2019
|
-
function u(h) {
|
|
2020
|
-
return (s, a) => {
|
|
2021
|
-
for (const l of Object.keys(s)) {
|
|
2022
|
-
const E = s[l], { canAdd: b, canAddToArray: w, check: m, expected: x } = (
|
|
2023
|
-
// @ts-ignore
|
|
2024
|
-
n[h + "s"][l] || {}
|
|
2025
|
-
), _ = !!w;
|
|
2026
|
-
if (m)
|
|
2027
|
-
if (_) {
|
|
2028
|
-
if (!Array.isArray(E) || // @ts-ignore
|
|
2029
|
-
a[l] && !Array.isArray(a[l]))
|
|
2030
|
-
throw new Error(`Key type ${l} must be an array`);
|
|
2031
|
-
E.every(m) || t(h, l, x, E);
|
|
2032
|
-
const I = a[l] || [], A = /* @__PURE__ */ new Set();
|
|
2033
|
-
if (!E.every((P) => w(I, P, A)))
|
|
2034
|
-
throw new Error("Can not add duplicate data to array");
|
|
2035
|
-
a[l] = I.concat(E);
|
|
2036
|
-
} else {
|
|
2037
|
-
if (m(E) || t(h, l, x, E), !b(a, E))
|
|
2038
|
-
throw new Error(`Can not add duplicate data to ${h}`);
|
|
2039
|
-
a[l] = E;
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
};
|
|
2043
|
-
}
|
|
2044
|
-
e.updateGlobal = u("global"), e.updateInput = u("input"), e.updateOutput = u("output");
|
|
2045
|
-
function f(h, s) {
|
|
2046
|
-
const a = h.length - 1, l = c(h, a);
|
|
2047
|
-
e.updateInput(s, l);
|
|
2048
|
-
}
|
|
2049
|
-
e.addInputAttributes = f;
|
|
2050
|
-
function d(h, s) {
|
|
2051
|
-
const a = h.length - 1, l = r(h, a);
|
|
2052
|
-
e.updateOutput(s, l);
|
|
2053
|
-
}
|
|
2054
|
-
e.addOutputAttributes = d;
|
|
2055
|
-
function v(h, s) {
|
|
2056
|
-
if (!S.isBuffer(s) || s.length < 4)
|
|
2057
|
-
throw new Error("Set Version: Invalid Transaction");
|
|
2058
|
-
return s.writeUInt32LE(h, 0), s;
|
|
2059
|
-
}
|
|
2060
|
-
e.defaultVersionSetter = v;
|
|
2061
|
-
function p(h, s) {
|
|
2062
|
-
if (!S.isBuffer(s) || s.length < 4)
|
|
2063
|
-
throw new Error("Set Locktime: Invalid Transaction");
|
|
2064
|
-
return s.writeUInt32LE(h, s.length - 4), s;
|
|
2065
|
-
}
|
|
2066
|
-
e.defaultLocktimeSetter = p;
|
|
2067
|
-
})(Ce)), Ce;
|
|
2068
|
-
}
|
|
2069
|
-
var Br;
|
|
2070
|
-
function gn() {
|
|
2071
|
-
if (Br) return be;
|
|
2072
|
-
Br = 1, Object.defineProperty(be, "__esModule", { value: !0 });
|
|
2073
|
-
const e = bn(), n = rt(), c = B(), r = tt();
|
|
2074
|
-
class g {
|
|
2075
|
-
constructor(i) {
|
|
2076
|
-
this.inputs = [], this.outputs = [], this.globalMap = {
|
|
2077
|
-
unsignedTx: i
|
|
2078
|
-
};
|
|
2079
|
-
}
|
|
2080
|
-
static fromBase64(i, t) {
|
|
2081
|
-
const u = S.from(i, "base64");
|
|
2082
|
-
return this.fromBuffer(u, t);
|
|
2083
|
-
}
|
|
2084
|
-
static fromHex(i, t) {
|
|
2085
|
-
const u = S.from(i, "hex");
|
|
2086
|
-
return this.fromBuffer(u, t);
|
|
2087
|
-
}
|
|
2088
|
-
static fromBuffer(i, t) {
|
|
2089
|
-
const u = n.psbtFromBuffer(i, t), f = new this(u.globalMap.unsignedTx);
|
|
2090
|
-
return Object.assign(f, u), f;
|
|
2091
|
-
}
|
|
2092
|
-
toBase64() {
|
|
2093
|
-
return this.toBuffer().toString("base64");
|
|
2094
|
-
}
|
|
2095
|
-
toHex() {
|
|
2096
|
-
return this.toBuffer().toString("hex");
|
|
2097
|
-
}
|
|
2098
|
-
toBuffer() {
|
|
2099
|
-
return n.psbtToBuffer(this);
|
|
2100
|
-
}
|
|
2101
|
-
updateGlobal(i) {
|
|
2102
|
-
return r.updateGlobal(i, this.globalMap), this;
|
|
2103
|
-
}
|
|
2104
|
-
updateInput(i, t) {
|
|
2105
|
-
const u = r.checkForInput(this.inputs, i);
|
|
2106
|
-
return r.updateInput(t, u), this;
|
|
2107
|
-
}
|
|
2108
|
-
updateOutput(i, t) {
|
|
2109
|
-
const u = r.checkForOutput(this.outputs, i);
|
|
2110
|
-
return r.updateOutput(t, u), this;
|
|
2111
|
-
}
|
|
2112
|
-
addUnknownKeyValToGlobal(i) {
|
|
2113
|
-
return r.checkHasKey(
|
|
2114
|
-
i,
|
|
2115
|
-
this.globalMap.unknownKeyVals,
|
|
2116
|
-
r.getEnumLength(c.GlobalTypes)
|
|
2117
|
-
), this.globalMap.unknownKeyVals || (this.globalMap.unknownKeyVals = []), this.globalMap.unknownKeyVals.push(i), this;
|
|
2118
|
-
}
|
|
2119
|
-
addUnknownKeyValToInput(i, t) {
|
|
2120
|
-
const u = r.checkForInput(this.inputs, i);
|
|
2121
|
-
return r.checkHasKey(
|
|
2122
|
-
t,
|
|
2123
|
-
u.unknownKeyVals,
|
|
2124
|
-
r.getEnumLength(c.InputTypes)
|
|
2125
|
-
), u.unknownKeyVals || (u.unknownKeyVals = []), u.unknownKeyVals.push(t), this;
|
|
2126
|
-
}
|
|
2127
|
-
addUnknownKeyValToOutput(i, t) {
|
|
2128
|
-
const u = r.checkForOutput(this.outputs, i);
|
|
2129
|
-
return r.checkHasKey(
|
|
2130
|
-
t,
|
|
2131
|
-
u.unknownKeyVals,
|
|
2132
|
-
r.getEnumLength(c.OutputTypes)
|
|
2133
|
-
), u.unknownKeyVals || (u.unknownKeyVals = []), u.unknownKeyVals.push(t), this;
|
|
2134
|
-
}
|
|
2135
|
-
addInput(i) {
|
|
2136
|
-
this.globalMap.unsignedTx.addInput(i), this.inputs.push({
|
|
2137
|
-
unknownKeyVals: []
|
|
2138
|
-
});
|
|
2139
|
-
const t = i.unknownKeyVals || [], u = this.inputs.length - 1;
|
|
2140
|
-
if (!Array.isArray(t))
|
|
2141
|
-
throw new Error("unknownKeyVals must be an Array");
|
|
2142
|
-
return t.forEach(
|
|
2143
|
-
(f) => this.addUnknownKeyValToInput(u, f)
|
|
2144
|
-
), r.addInputAttributes(this.inputs, i), this;
|
|
2145
|
-
}
|
|
2146
|
-
addOutput(i) {
|
|
2147
|
-
this.globalMap.unsignedTx.addOutput(i), this.outputs.push({
|
|
2148
|
-
unknownKeyVals: []
|
|
2149
|
-
});
|
|
2150
|
-
const t = i.unknownKeyVals || [], u = this.outputs.length - 1;
|
|
2151
|
-
if (!Array.isArray(t))
|
|
2152
|
-
throw new Error("unknownKeyVals must be an Array");
|
|
2153
|
-
return t.forEach(
|
|
2154
|
-
(f) => this.addUnknownKeyValToOutput(u, f)
|
|
2155
|
-
), r.addOutputAttributes(this.outputs, i), this;
|
|
2156
|
-
}
|
|
2157
|
-
clearFinalizedInput(i) {
|
|
2158
|
-
const t = r.checkForInput(this.inputs, i);
|
|
2159
|
-
r.inputCheckUncleanFinalized(i, t);
|
|
2160
|
-
for (const u of Object.keys(t))
|
|
2161
|
-
[
|
|
2162
|
-
"witnessUtxo",
|
|
2163
|
-
"nonWitnessUtxo",
|
|
2164
|
-
"finalScriptSig",
|
|
2165
|
-
"finalScriptWitness",
|
|
2166
|
-
"unknownKeyVals"
|
|
2167
|
-
].includes(u) || delete t[u];
|
|
2168
|
-
return this;
|
|
2169
|
-
}
|
|
2170
|
-
combine(...i) {
|
|
2171
|
-
const t = e.combine([this].concat(i));
|
|
2172
|
-
return Object.assign(this, t), this;
|
|
2173
|
-
}
|
|
2174
|
-
getTransaction() {
|
|
2175
|
-
return this.globalMap.unsignedTx.toBuffer();
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
return be.Psbt = g, be;
|
|
2179
|
-
}
|
|
2180
|
-
var Wn = gn(), Hn = tt(), R = {}, Ur;
|
|
2181
|
-
function En() {
|
|
2182
|
-
if (Ur) return R;
|
|
2183
|
-
Ur = 1;
|
|
2184
|
-
var e = /* @__PURE__ */ xt(), n = /* @__PURE__ */ Rt(), c = /* @__PURE__ */ Ot();
|
|
2185
|
-
function r(y) {
|
|
2186
|
-
var T = /* @__PURE__ */ Object.create(null);
|
|
2187
|
-
return y && Object.keys(y).forEach(function(k) {
|
|
2188
|
-
if (k !== "default") {
|
|
2189
|
-
var N = Object.getOwnPropertyDescriptor(y, k);
|
|
2190
|
-
Object.defineProperty(T, k, N.get ? N : {
|
|
2191
|
-
enumerable: !0,
|
|
2192
|
-
get: function() {
|
|
2193
|
-
return y[k];
|
|
2194
|
-
}
|
|
2195
|
-
});
|
|
2196
|
-
}
|
|
2197
|
-
}), T.default = y, Object.freeze(T);
|
|
2198
|
-
}
|
|
2199
|
-
var g = /* @__PURE__ */ r(n), o = /* @__PURE__ */ r(c);
|
|
2200
|
-
const i = e.secp256k1.ProjectivePoint, t = "Expected Private", u = "Expected Point", f = "Expected Tweak", d = "Expected Hash", v = "Expected Signature", p = "Expected Extra Data (32 bytes)", h = "Expected Scalar", s = "Bad Recovery Id", a = 32, l = 32, E = new Uint8Array([
|
|
2201
|
-
255,
|
|
2202
|
-
255,
|
|
2203
|
-
255,
|
|
2204
|
-
255,
|
|
2205
|
-
255,
|
|
2206
|
-
255,
|
|
2207
|
-
255,
|
|
2208
|
-
255,
|
|
2209
|
-
255,
|
|
2210
|
-
255,
|
|
2211
|
-
255,
|
|
2212
|
-
255,
|
|
2213
|
-
255,
|
|
2214
|
-
255,
|
|
2215
|
-
255,
|
|
2216
|
-
254,
|
|
2217
|
-
186,
|
|
2218
|
-
174,
|
|
2219
|
-
220,
|
|
2220
|
-
230,
|
|
2221
|
-
175,
|
|
2222
|
-
72,
|
|
2223
|
-
160,
|
|
2224
|
-
59,
|
|
2225
|
-
191,
|
|
2226
|
-
210,
|
|
2227
|
-
94,
|
|
2228
|
-
140,
|
|
2229
|
-
208,
|
|
2230
|
-
54,
|
|
2231
|
-
65,
|
|
2232
|
-
65
|
|
2233
|
-
]), b = 32, w = new Uint8Array(32), m = new Uint8Array([
|
|
2234
|
-
0,
|
|
2235
|
-
0,
|
|
2236
|
-
0,
|
|
2237
|
-
0,
|
|
2238
|
-
0,
|
|
2239
|
-
0,
|
|
2240
|
-
0,
|
|
2241
|
-
0,
|
|
2242
|
-
0,
|
|
2243
|
-
0,
|
|
2244
|
-
0,
|
|
2245
|
-
0,
|
|
2246
|
-
0,
|
|
2247
|
-
0,
|
|
2248
|
-
0,
|
|
2249
|
-
1,
|
|
2250
|
-
69,
|
|
2251
|
-
81,
|
|
2252
|
-
35,
|
|
2253
|
-
25,
|
|
2254
|
-
80,
|
|
2255
|
-
183,
|
|
2256
|
-
95,
|
|
2257
|
-
196,
|
|
2258
|
-
64,
|
|
2259
|
-
45,
|
|
2260
|
-
161,
|
|
2261
|
-
114,
|
|
2262
|
-
47,
|
|
2263
|
-
201,
|
|
2264
|
-
186,
|
|
2265
|
-
238
|
|
2266
|
-
]), x = BigInt(1);
|
|
2267
|
-
function _(y) {
|
|
2268
|
-
return y instanceof Uint8Array;
|
|
2269
|
-
}
|
|
2270
|
-
function I(y, T) {
|
|
2271
|
-
for (let k = 0; k < 32; ++k)
|
|
2272
|
-
if (y[k] !== T[k])
|
|
2273
|
-
return y[k] < T[k] ? -1 : 1;
|
|
2274
|
-
return 0;
|
|
2275
|
-
}
|
|
2276
|
-
function A(y) {
|
|
2277
|
-
return I(y, w) === 0;
|
|
2278
|
-
}
|
|
2279
|
-
function P(y) {
|
|
2280
|
-
return !(!(y instanceof Uint8Array) || y.length !== l || I(y, E) >= 0);
|
|
2281
|
-
}
|
|
2282
|
-
function O(y) {
|
|
2283
|
-
return y instanceof Uint8Array && y.length === 64 && I(y.subarray(0, 32), E) < 0 && I(y.subarray(32, 64), E) < 0;
|
|
2284
|
-
}
|
|
2285
|
-
function U(y) {
|
|
2286
|
-
return _(y) && y.length === 64 && I(y.subarray(0, 32), m) < 0;
|
|
2287
|
-
}
|
|
2288
|
-
function ot(y) {
|
|
2289
|
-
return !(A(y.subarray(0, 32)) || A(y.subarray(32, 64)));
|
|
2290
|
-
}
|
|
2291
|
-
function ne(y) {
|
|
2292
|
-
return y instanceof Uint8Array && y.length === a;
|
|
2293
|
-
}
|
|
2294
|
-
function ke(y) {
|
|
2295
|
-
return y === void 0 || y instanceof Uint8Array && y.length === b;
|
|
2296
|
-
}
|
|
2297
|
-
function Ie(y) {
|
|
2298
|
-
let T;
|
|
2299
|
-
if (typeof y == "bigint")
|
|
2300
|
-
T = y;
|
|
2301
|
-
else if (typeof y == "number" && Number.isSafeInteger(y) && y >= 0)
|
|
2302
|
-
T = BigInt(y);
|
|
2303
|
-
else if (typeof y == "string") {
|
|
2304
|
-
if (y.length !== 64)
|
|
2305
|
-
throw new Error("Expected 32 bytes of private scalar");
|
|
2306
|
-
T = o.hexToNumber(y);
|
|
2307
|
-
} else if (y instanceof Uint8Array) {
|
|
2308
|
-
if (y.length !== 32)
|
|
2309
|
-
throw new Error("Expected 32 bytes of private scalar");
|
|
2310
|
-
T = o.bytesToNumberBE(y);
|
|
2311
|
-
} else
|
|
2312
|
-
throw new TypeError("Expected valid private scalar");
|
|
2313
|
-
if (T < 0) throw new Error("Expected private scalar >= 0");
|
|
2314
|
-
return T;
|
|
2315
|
-
}
|
|
2316
|
-
function Ae(y) {
|
|
2317
|
-
return e.secp256k1.utils.normPrivateKeyToScalar(y);
|
|
2318
|
-
}
|
|
2319
|
-
function it(y, T) {
|
|
2320
|
-
const k = Ae(y), N = Ie(T), K = o.numberToBytesBE(g.mod(k + N, e.secp256k1.CURVE.n), 32);
|
|
2321
|
-
return e.secp256k1.utils.isValidPrivateKey(K) ? K : null;
|
|
2322
|
-
}
|
|
2323
|
-
function ct(y, T) {
|
|
2324
|
-
const k = Ae(y), N = Ie(T), K = o.numberToBytesBE(g.mod(k - N, e.secp256k1.CURVE.n), 32);
|
|
2325
|
-
return e.secp256k1.utils.isValidPrivateKey(K) ? K : null;
|
|
2326
|
-
}
|
|
2327
|
-
function ut(y) {
|
|
2328
|
-
const T = Ae(y), k = o.numberToBytesBE(e.secp256k1.CURVE.n - T, 32);
|
|
2329
|
-
return e.secp256k1.utils.isValidPrivateKey(k) ? k : null;
|
|
2330
|
-
}
|
|
2331
|
-
function Xe(y, T, k) {
|
|
2332
|
-
const N = le(y), K = Ie(T), $ = i.BASE.multiplyAndAddUnsafe(N, K, x);
|
|
2333
|
-
if (!$) throw new Error("Tweaked point at infinity");
|
|
2334
|
-
return $.toRawBytes(k);
|
|
2335
|
-
}
|
|
2336
|
-
function ft(y, T, k) {
|
|
2337
|
-
const N = le(y), K = typeof T == "string" ? T : o.bytesToHex(T), $ = o.hexToNumber(K);
|
|
2338
|
-
return N.multiply($).toRawBytes(k);
|
|
2339
|
-
}
|
|
2340
|
-
function oe(y, T) {
|
|
2341
|
-
return y === void 0 ? T !== void 0 ? Ye(T) : !0 : !!y;
|
|
2342
|
-
}
|
|
2343
|
-
function Q(y) {
|
|
2344
|
-
try {
|
|
2345
|
-
return y();
|
|
2346
|
-
} catch {
|
|
2347
|
-
return null;
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
function Je(y) {
|
|
2351
|
-
return e.schnorr.utils.lift_x(o.bytesToNumberBE(y));
|
|
2352
|
-
}
|
|
2353
|
-
function le(y) {
|
|
2354
|
-
return y.length === 32 ? Je(y) : i.fromHex(y);
|
|
2355
|
-
}
|
|
2356
|
-
function Pe(y, T) {
|
|
2357
|
-
if (y.length === 32 !== T) return !1;
|
|
2358
|
-
try {
|
|
2359
|
-
return T ? !!Je(y) : !!i.fromHex(y);
|
|
2360
|
-
} catch {
|
|
2361
|
-
return !1;
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
function q(y) {
|
|
2365
|
-
return Pe(y, !1);
|
|
2366
|
-
}
|
|
2367
|
-
function Ye(y) {
|
|
2368
|
-
return Pe(y, !1) && y.length === 33;
|
|
2369
|
-
}
|
|
2370
|
-
function C(y) {
|
|
2371
|
-
return e.secp256k1.utils.isValidPrivateKey(y);
|
|
2372
|
-
}
|
|
2373
|
-
function ye(y) {
|
|
2374
|
-
return Pe(y, !0);
|
|
2375
|
-
}
|
|
2376
|
-
function at(y, T) {
|
|
2377
|
-
if (!ye(y))
|
|
2378
|
-
throw new Error(u);
|
|
2379
|
-
if (!P(T))
|
|
2380
|
-
throw new Error(f);
|
|
2381
|
-
return Q(() => {
|
|
2382
|
-
const k = Xe(y, T, !0);
|
|
2383
|
-
return { parity: k[0] % 2 === 1 ? 1 : 0, xOnlyPubkey: k.slice(1) };
|
|
2384
|
-
});
|
|
2385
|
-
}
|
|
2386
|
-
function ze(y) {
|
|
2387
|
-
if (!q(y))
|
|
2388
|
-
throw new Error(u);
|
|
2389
|
-
return y.slice(1, 33);
|
|
2390
|
-
}
|
|
2391
|
-
function Ze(y, T) {
|
|
2392
|
-
if (!C(y))
|
|
2393
|
-
throw new Error(t);
|
|
2394
|
-
return Q(
|
|
2395
|
-
() => e.secp256k1.getPublicKey(y, oe(T))
|
|
2396
|
-
);
|
|
2397
|
-
}
|
|
2398
|
-
function st(y) {
|
|
2399
|
-
if (!C(y))
|
|
2400
|
-
throw new Error(t);
|
|
2401
|
-
return ze(Ze(y));
|
|
2402
|
-
}
|
|
2403
|
-
function dt(y, T) {
|
|
2404
|
-
if (!q(y))
|
|
2405
|
-
throw new Error(u);
|
|
2406
|
-
return le(y).toRawBytes(oe(T, y));
|
|
2407
|
-
}
|
|
2408
|
-
function lt(y, T, k) {
|
|
2409
|
-
if (!q(y))
|
|
2410
|
-
throw new Error(u);
|
|
2411
|
-
if (!P(T))
|
|
2412
|
-
throw new Error(f);
|
|
2413
|
-
return Q(
|
|
2414
|
-
() => ft(y, T, oe(k, y))
|
|
2415
|
-
);
|
|
2416
|
-
}
|
|
2417
|
-
function pt(y, T, k) {
|
|
2418
|
-
if (!q(y) || !q(T))
|
|
2419
|
-
throw new Error(u);
|
|
2420
|
-
return Q(() => {
|
|
2421
|
-
const N = le(y), K = le(T);
|
|
2422
|
-
return N.equals(K.negate()) ? null : N.add(K).toRawBytes(oe(k, y));
|
|
2423
|
-
});
|
|
2424
|
-
}
|
|
2425
|
-
function ht(y, T, k) {
|
|
2426
|
-
if (!q(y))
|
|
2427
|
-
throw new Error(u);
|
|
2428
|
-
if (!P(T))
|
|
2429
|
-
throw new Error(f);
|
|
2430
|
-
return Q(
|
|
2431
|
-
() => Xe(y, T, oe(k, y))
|
|
2432
|
-
);
|
|
2433
|
-
}
|
|
2434
|
-
function yt(y, T) {
|
|
2435
|
-
if (!C(y))
|
|
2436
|
-
throw new Error(t);
|
|
2437
|
-
if (!P(T))
|
|
2438
|
-
throw new Error(f);
|
|
2439
|
-
return Q(() => it(y, T));
|
|
2440
|
-
}
|
|
2441
|
-
function bt(y, T) {
|
|
2442
|
-
if (!C(y))
|
|
2443
|
-
throw new Error(t);
|
|
2444
|
-
if (!P(T))
|
|
2445
|
-
throw new Error(f);
|
|
2446
|
-
return Q(() => ct(y, T));
|
|
2447
|
-
}
|
|
2448
|
-
function gt(y) {
|
|
2449
|
-
if (!C(y))
|
|
2450
|
-
throw new Error(t);
|
|
2451
|
-
return ut(y);
|
|
2452
|
-
}
|
|
2453
|
-
function Et(y, T, k) {
|
|
2454
|
-
if (!C(T))
|
|
2455
|
-
throw new Error(t);
|
|
2456
|
-
if (!ne(y))
|
|
2457
|
-
throw new Error(h);
|
|
2458
|
-
if (!ke(k))
|
|
2459
|
-
throw new Error(p);
|
|
2460
|
-
return e.secp256k1.sign(y, T, { extraEntropy: k }).toCompactRawBytes();
|
|
2461
|
-
}
|
|
2462
|
-
function wt(y, T, k) {
|
|
2463
|
-
if (!C(T))
|
|
2464
|
-
throw new Error(t);
|
|
2465
|
-
if (!ne(y))
|
|
2466
|
-
throw new Error(h);
|
|
2467
|
-
if (!ke(k))
|
|
2468
|
-
throw new Error(p);
|
|
2469
|
-
const N = e.secp256k1.sign(y, T, { extraEntropy: k });
|
|
2470
|
-
return {
|
|
2471
|
-
signature: N.toCompactRawBytes(),
|
|
2472
|
-
recoveryId: N.recovery
|
|
2473
|
-
};
|
|
2474
|
-
}
|
|
2475
|
-
function vt(y, T, k) {
|
|
2476
|
-
if (!C(T))
|
|
2477
|
-
throw new Error(t);
|
|
2478
|
-
if (!ne(y))
|
|
2479
|
-
throw new Error(h);
|
|
2480
|
-
if (!ke(k))
|
|
2481
|
-
throw new Error(p);
|
|
2482
|
-
return e.schnorr.sign(y, T, k);
|
|
2483
|
-
}
|
|
2484
|
-
function St(y, T, k, N) {
|
|
2485
|
-
if (!ne(y))
|
|
2486
|
-
throw new Error(d);
|
|
2487
|
-
if (!O(T) || !ot(T))
|
|
2488
|
-
throw new Error(v);
|
|
2489
|
-
if (k & 2 && !U(T))
|
|
2490
|
-
throw new Error(s);
|
|
2491
|
-
if (!ye(T.subarray(0, 32)))
|
|
2492
|
-
throw new Error(v);
|
|
2493
|
-
const $ = e.secp256k1.Signature.fromCompact(T).addRecoveryBit(k).recoverPublicKey(y);
|
|
2494
|
-
if (!$) throw new Error(v);
|
|
2495
|
-
return $.toRawBytes(oe(N));
|
|
2496
|
-
}
|
|
2497
|
-
function _t(y, T, k, N) {
|
|
2498
|
-
if (!q(T))
|
|
2499
|
-
throw new Error(u);
|
|
2500
|
-
if (!O(k))
|
|
2501
|
-
throw new Error(v);
|
|
2502
|
-
if (!ne(y))
|
|
2503
|
-
throw new Error(h);
|
|
2504
|
-
return e.secp256k1.verify(k, y, T, { lowS: N });
|
|
2505
|
-
}
|
|
2506
|
-
function Tt(y, T, k) {
|
|
2507
|
-
if (!ye(T))
|
|
2508
|
-
throw new Error(u);
|
|
2509
|
-
if (!O(k))
|
|
2510
|
-
throw new Error(v);
|
|
2511
|
-
if (!ne(y))
|
|
2512
|
-
throw new Error(h);
|
|
2513
|
-
return e.schnorr.verify(k, y, T);
|
|
2514
|
-
}
|
|
2515
|
-
return R.isPoint = q, R.isPointCompressed = Ye, R.isPrivate = C, R.isXOnlyPoint = ye, R.pointAdd = pt, R.pointAddScalar = ht, R.pointCompress = dt, R.pointFromScalar = Ze, R.pointMultiply = lt, R.privateAdd = yt, R.privateNegate = gt, R.privateSub = bt, R.recover = St, R.sign = Et, R.signRecoverable = wt, R.signSchnorr = vt, R.verify = _t, R.verifySchnorr = Tt, R.xOnlyPointAddTweak = at, R.xOnlyPointFromPoint = ze, R.xOnlyPointFromScalar = st, R;
|
|
2516
|
-
}
|
|
2517
|
-
var nt = En();
|
|
2518
|
-
const wn = /* @__PURE__ */ Jr(nt), Gn = /* @__PURE__ */ Nt({
|
|
2519
|
-
__proto__: null,
|
|
2520
|
-
default: wn
|
|
2521
|
-
}, [nt]);
|
|
2522
|
-
var fe = {}, ae = {}, se = {}, Kr;
|
|
2523
|
-
function vn() {
|
|
2524
|
-
if (Kr) return se;
|
|
2525
|
-
Kr = 1;
|
|
2526
|
-
var e = se && se.__importDefault || function(r) {
|
|
2527
|
-
return r && r.__esModule ? r : { default: r };
|
|
2528
|
-
};
|
|
2529
|
-
Object.defineProperty(se, "__esModule", { value: !0 });
|
|
2530
|
-
var n = e(It()), c = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2531
|
-
return se.default = (0, n.default)(c), se;
|
|
2532
|
-
}
|
|
2533
|
-
var Cr;
|
|
2534
|
-
function Sn() {
|
|
2535
|
-
if (Cr) return ae;
|
|
2536
|
-
Cr = 1;
|
|
2537
|
-
var e = ae && ae.__importDefault || function(r) {
|
|
2538
|
-
return r && r.__esModule ? r : { default: r };
|
|
2539
|
-
};
|
|
2540
|
-
Object.defineProperty(ae, "__esModule", { value: !0 }), ae.default = c;
|
|
2541
|
-
var n = e(vn());
|
|
2542
|
-
function c(r) {
|
|
2543
|
-
function g(u) {
|
|
2544
|
-
var f = Uint8Array.from(u), d = r(f), v = f.length + 4, p = new Uint8Array(v);
|
|
2545
|
-
return p.set(f, 0), p.set(d.subarray(0, 4), f.length), n.default.encode(p);
|
|
2546
|
-
}
|
|
2547
|
-
function o(u) {
|
|
2548
|
-
var f = u.slice(0, -4), d = u.slice(-4), v = r(f);
|
|
2549
|
-
if (!(d[0] ^ v[0] | d[1] ^ v[1] | d[2] ^ v[2] | d[3] ^ v[3]))
|
|
2550
|
-
return f;
|
|
2551
|
-
}
|
|
2552
|
-
function i(u) {
|
|
2553
|
-
var f = n.default.decodeUnsafe(u);
|
|
2554
|
-
if (f != null)
|
|
2555
|
-
return o(f);
|
|
2556
|
-
}
|
|
2557
|
-
function t(u) {
|
|
2558
|
-
var f = n.default.decode(u), d = o(f);
|
|
2559
|
-
if (d == null)
|
|
2560
|
-
throw new Error("Invalid checksum");
|
|
2561
|
-
return d;
|
|
2562
|
-
}
|
|
2563
|
-
return {
|
|
2564
|
-
encode: g,
|
|
2565
|
-
decode: t,
|
|
2566
|
-
decodeUnsafe: i
|
|
2567
|
-
};
|
|
2568
|
-
}
|
|
2569
|
-
return ae;
|
|
2570
|
-
}
|
|
2571
|
-
var Lr;
|
|
2572
|
-
function Vn() {
|
|
2573
|
-
if (Lr) return fe;
|
|
2574
|
-
Lr = 1;
|
|
2575
|
-
var e = fe && fe.__importDefault || function(g) {
|
|
2576
|
-
return g && g.__esModule ? g : { default: g };
|
|
2577
|
-
};
|
|
2578
|
-
Object.defineProperty(fe, "__esModule", { value: !0 });
|
|
2579
|
-
var n = /* @__PURE__ */ mt(), c = e(Sn());
|
|
2580
|
-
function r(g) {
|
|
2581
|
-
return (0, n.sha256)((0, n.sha256)(g));
|
|
2582
|
-
}
|
|
2583
|
-
return fe.default = (0, c.default)(r), fe;
|
|
2584
|
-
}
|
|
2585
|
-
var Le = {}, re = {}, te = {}, qr;
|
|
2586
|
-
function _n() {
|
|
2587
|
-
return qr || (qr = 1, Object.defineProperty(te, "__esModule", { value: !0 }), te.testnet = te.bitcoin = void 0, te.bitcoin = {
|
|
2588
|
-
messagePrefix: `Bitcoin Signed Message:
|
|
2589
|
-
`,
|
|
2590
|
-
bech32: "bc",
|
|
2591
|
-
bip32: {
|
|
2592
|
-
public: 76067358,
|
|
2593
|
-
private: 76066276
|
|
2594
|
-
},
|
|
2595
|
-
pubKeyHash: 0,
|
|
2596
|
-
scriptHash: 5,
|
|
2597
|
-
wif: 128
|
|
2598
|
-
}, te.testnet = {
|
|
2599
|
-
messagePrefix: `Bitcoin Signed Message:
|
|
2600
|
-
`,
|
|
2601
|
-
bech32: "tb",
|
|
2602
|
-
bip32: {
|
|
2603
|
-
public: 70617039,
|
|
2604
|
-
private: 70615956
|
|
2605
|
-
},
|
|
2606
|
-
pubKeyHash: 111,
|
|
2607
|
-
scriptHash: 196,
|
|
2608
|
-
wif: 239
|
|
2609
|
-
}), te;
|
|
2610
|
-
}
|
|
2611
|
-
var qe = {}, Mr;
|
|
2612
|
-
function Tn() {
|
|
2613
|
-
return Mr || (Mr = 1, (function(e) {
|
|
2614
|
-
Object.defineProperty(e, "__esModule", { value: !0 }), e.maybe = e.Boolean = e.Array = e.Buffer256bit = e.Network = e.typeforce = void 0, e.typeforce = Zr(), e.Network = e.typeforce.compile({
|
|
2615
|
-
messagePrefix: e.typeforce.oneOf(
|
|
2616
|
-
e.typeforce.Buffer,
|
|
2617
|
-
e.typeforce.String
|
|
2618
|
-
),
|
|
2619
|
-
bip32: {
|
|
2620
|
-
public: e.typeforce.UInt32,
|
|
2621
|
-
private: e.typeforce.UInt32
|
|
2622
|
-
},
|
|
2623
|
-
pubKeyHash: e.typeforce.UInt8,
|
|
2624
|
-
scriptHash: e.typeforce.UInt8,
|
|
2625
|
-
wif: e.typeforce.UInt8
|
|
2626
|
-
}), e.Buffer256bit = e.typeforce.BufferN(32), e.Array = e.typeforce.Array, e.Boolean = e.typeforce.Boolean, e.maybe = e.typeforce.maybe;
|
|
2627
|
-
})(qe)), qe;
|
|
2628
|
-
}
|
|
2629
|
-
var Me, Dr;
|
|
2630
|
-
function mn() {
|
|
2631
|
-
if (Dr) return Me;
|
|
2632
|
-
Dr = 1;
|
|
2633
|
-
var e = Yr().Buffer;
|
|
2634
|
-
function n(c) {
|
|
2635
|
-
if (c.length >= 255)
|
|
2636
|
-
throw new TypeError("Alphabet too long");
|
|
2637
|
-
for (var r = new Uint8Array(256), g = 0; g < r.length; g++)
|
|
2638
|
-
r[g] = 255;
|
|
2639
|
-
for (var o = 0; o < c.length; o++) {
|
|
2640
|
-
var i = c.charAt(o), t = i.charCodeAt(0);
|
|
2641
|
-
if (r[t] !== 255)
|
|
2642
|
-
throw new TypeError(i + " is ambiguous");
|
|
2643
|
-
r[t] = o;
|
|
2644
|
-
}
|
|
2645
|
-
var u = c.length, f = c.charAt(0), d = Math.log(u) / Math.log(256), v = Math.log(256) / Math.log(u);
|
|
2646
|
-
function p(a) {
|
|
2647
|
-
if ((Array.isArray(a) || a instanceof Uint8Array) && (a = e.from(a)), !e.isBuffer(a))
|
|
2648
|
-
throw new TypeError("Expected Buffer");
|
|
2649
|
-
if (a.length === 0)
|
|
2650
|
-
return "";
|
|
2651
|
-
for (var l = 0, E = 0, b = 0, w = a.length; b !== w && a[b] === 0; )
|
|
2652
|
-
b++, l++;
|
|
2653
|
-
for (var m = (w - b) * v + 1 >>> 0, x = new Uint8Array(m); b !== w; ) {
|
|
2654
|
-
for (var _ = a[b], I = 0, A = m - 1; (_ !== 0 || I < E) && A !== -1; A--, I++)
|
|
2655
|
-
_ += 256 * x[A] >>> 0, x[A] = _ % u >>> 0, _ = _ / u >>> 0;
|
|
2656
|
-
if (_ !== 0)
|
|
2657
|
-
throw new Error("Non-zero carry");
|
|
2658
|
-
E = I, b++;
|
|
2659
|
-
}
|
|
2660
|
-
for (var P = m - E; P !== m && x[P] === 0; )
|
|
2661
|
-
P++;
|
|
2662
|
-
for (var O = f.repeat(l); P < m; ++P)
|
|
2663
|
-
O += c.charAt(x[P]);
|
|
2664
|
-
return O;
|
|
2665
|
-
}
|
|
2666
|
-
function h(a) {
|
|
2667
|
-
if (typeof a != "string")
|
|
2668
|
-
throw new TypeError("Expected String");
|
|
2669
|
-
if (a.length === 0)
|
|
2670
|
-
return e.alloc(0);
|
|
2671
|
-
for (var l = 0, E = 0, b = 0; a[l] === f; )
|
|
2672
|
-
E++, l++;
|
|
2673
|
-
for (var w = (a.length - l) * d + 1 >>> 0, m = new Uint8Array(w); l < a.length; ) {
|
|
2674
|
-
var x = a.charCodeAt(l);
|
|
2675
|
-
if (x > 255)
|
|
2676
|
-
return;
|
|
2677
|
-
var _ = r[x];
|
|
2678
|
-
if (_ === 255)
|
|
2679
|
-
return;
|
|
2680
|
-
for (var I = 0, A = w - 1; (_ !== 0 || I < b) && A !== -1; A--, I++)
|
|
2681
|
-
_ += u * m[A] >>> 0, m[A] = _ % 256 >>> 0, _ = _ / 256 >>> 0;
|
|
2682
|
-
if (_ !== 0)
|
|
2683
|
-
throw new Error("Non-zero carry");
|
|
2684
|
-
b = I, l++;
|
|
2685
|
-
}
|
|
2686
|
-
for (var P = w - b; P !== w && m[P] === 0; )
|
|
2687
|
-
P++;
|
|
2688
|
-
var O = e.allocUnsafe(E + (w - P));
|
|
2689
|
-
O.fill(0, 0, E);
|
|
2690
|
-
for (var U = E; P !== w; )
|
|
2691
|
-
O[U++] = m[P++];
|
|
2692
|
-
return O;
|
|
2693
|
-
}
|
|
2694
|
-
function s(a) {
|
|
2695
|
-
var l = h(a);
|
|
2696
|
-
if (l)
|
|
2697
|
-
return l;
|
|
2698
|
-
throw new Error("Non-base" + u + " character");
|
|
2699
|
-
}
|
|
2700
|
-
return {
|
|
2701
|
-
encode: p,
|
|
2702
|
-
decodeUnsafe: h,
|
|
2703
|
-
decode: s
|
|
2704
|
-
};
|
|
2705
|
-
}
|
|
2706
|
-
return Me = n, Me;
|
|
2707
|
-
}
|
|
2708
|
-
var De, Fr;
|
|
2709
|
-
function kn() {
|
|
2710
|
-
if (Fr) return De;
|
|
2711
|
-
Fr = 1;
|
|
2712
|
-
var e = mn(), n = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2713
|
-
return De = e(n), De;
|
|
2714
|
-
}
|
|
2715
|
-
var Fe, jr;
|
|
2716
|
-
function In() {
|
|
2717
|
-
if (jr) return Fe;
|
|
2718
|
-
jr = 1;
|
|
2719
|
-
var e = kn(), n = Yr().Buffer;
|
|
2720
|
-
return Fe = function(c) {
|
|
2721
|
-
function r(t) {
|
|
2722
|
-
var u = c(t);
|
|
2723
|
-
return e.encode(n.concat([
|
|
2724
|
-
t,
|
|
2725
|
-
u
|
|
2726
|
-
], t.length + 4));
|
|
2727
|
-
}
|
|
2728
|
-
function g(t) {
|
|
2729
|
-
var u = t.slice(0, -4), f = t.slice(-4), d = c(u);
|
|
2730
|
-
if (!(f[0] ^ d[0] | f[1] ^ d[1] | f[2] ^ d[2] | f[3] ^ d[3]))
|
|
2731
|
-
return u;
|
|
2732
|
-
}
|
|
2733
|
-
function o(t) {
|
|
2734
|
-
var u = e.decodeUnsafe(t);
|
|
2735
|
-
if (u)
|
|
2736
|
-
return g(u);
|
|
2737
|
-
}
|
|
2738
|
-
function i(t) {
|
|
2739
|
-
var u = e.decode(t), f = g(u);
|
|
2740
|
-
if (!f) throw new Error("Invalid checksum");
|
|
2741
|
-
return f;
|
|
2742
|
-
}
|
|
2743
|
-
return {
|
|
2744
|
-
encode: r,
|
|
2745
|
-
decode: i,
|
|
2746
|
-
decodeUnsafe: o
|
|
2747
|
-
};
|
|
2748
|
-
}, Fe;
|
|
2749
|
-
}
|
|
2750
|
-
var je, Wr;
|
|
2751
|
-
function An() {
|
|
2752
|
-
if (Wr) return je;
|
|
2753
|
-
Wr = 1;
|
|
2754
|
-
var e = At(), n = In();
|
|
2755
|
-
function c(r) {
|
|
2756
|
-
var g = e("sha256").update(r).digest();
|
|
2757
|
-
return e("sha256").update(g).digest();
|
|
2758
|
-
}
|
|
2759
|
-
return je = n(c), je;
|
|
2760
|
-
}
|
|
2761
|
-
var We, Hr;
|
|
2762
|
-
function Pn() {
|
|
2763
|
-
if (Hr) return We;
|
|
2764
|
-
Hr = 1;
|
|
2765
|
-
var e = An();
|
|
2766
|
-
function n(o, i) {
|
|
2767
|
-
if (i !== void 0 && o[0] !== i) throw new Error("Invalid network version");
|
|
2768
|
-
if (o.length === 33)
|
|
2769
|
-
return {
|
|
2770
|
-
version: o[0],
|
|
2771
|
-
privateKey: o.slice(1, 33),
|
|
2772
|
-
compressed: !1
|
|
2773
|
-
};
|
|
2774
|
-
if (o.length !== 34) throw new Error("Invalid WIF length");
|
|
2775
|
-
if (o[33] !== 1) throw new Error("Invalid compression flag");
|
|
2776
|
-
return {
|
|
2777
|
-
version: o[0],
|
|
2778
|
-
privateKey: o.slice(1, 33),
|
|
2779
|
-
compressed: !0
|
|
2780
|
-
};
|
|
2781
|
-
}
|
|
2782
|
-
function c(o, i, t) {
|
|
2783
|
-
var u = new S(t ? 34 : 33);
|
|
2784
|
-
return u.writeUInt8(o, 0), i.copy(u, 1), t && (u[33] = 1), u;
|
|
2785
|
-
}
|
|
2786
|
-
function r(o, i) {
|
|
2787
|
-
return n(e.decode(o), i);
|
|
2788
|
-
}
|
|
2789
|
-
function g(o, i, t) {
|
|
2790
|
-
return typeof o == "number" ? e.encode(c(o, i, t)) : e.encode(
|
|
2791
|
-
c(
|
|
2792
|
-
o.version,
|
|
2793
|
-
o.privateKey,
|
|
2794
|
-
o.compressed
|
|
2795
|
-
)
|
|
2796
|
-
);
|
|
2797
|
-
}
|
|
2798
|
-
return We = {
|
|
2799
|
-
decode: r,
|
|
2800
|
-
decodeRaw: n,
|
|
2801
|
-
encode: g,
|
|
2802
|
-
encodeRaw: c
|
|
2803
|
-
}, We;
|
|
2804
|
-
}
|
|
2805
|
-
var he = {}, Gr;
|
|
2806
|
-
function xn() {
|
|
2807
|
-
if (Gr) return he;
|
|
2808
|
-
Gr = 1, Object.defineProperty(he, "__esModule", { value: !0 }), he.testEcc = void 0;
|
|
2809
|
-
const e = (r) => S.from(r, "hex");
|
|
2810
|
-
function n(r) {
|
|
2811
|
-
c(
|
|
2812
|
-
r.isPoint(
|
|
2813
|
-
e("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")
|
|
2814
|
-
)
|
|
2815
|
-
), c(
|
|
2816
|
-
!r.isPoint(
|
|
2817
|
-
e("030000000000000000000000000000000000000000000000000000000000000005")
|
|
2818
|
-
)
|
|
2819
|
-
), c(
|
|
2820
|
-
r.isPrivate(
|
|
2821
|
-
e("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")
|
|
2822
|
-
)
|
|
2823
|
-
), c(
|
|
2824
|
-
r.isPrivate(
|
|
2825
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")
|
|
2826
|
-
)
|
|
2827
|
-
), c(
|
|
2828
|
-
!r.isPrivate(
|
|
2829
|
-
e("0000000000000000000000000000000000000000000000000000000000000000")
|
|
2830
|
-
)
|
|
2831
|
-
), c(
|
|
2832
|
-
!r.isPrivate(
|
|
2833
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141")
|
|
2834
|
-
)
|
|
2835
|
-
), c(
|
|
2836
|
-
!r.isPrivate(
|
|
2837
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142")
|
|
2838
|
-
)
|
|
2839
|
-
), c(
|
|
2840
|
-
S.from(
|
|
2841
|
-
r.privateAdd(
|
|
2842
|
-
e("0000000000000000000000000000000000000000000000000000000000000001"),
|
|
2843
|
-
e("0000000000000000000000000000000000000000000000000000000000000000")
|
|
2844
|
-
)
|
|
2845
|
-
).equals(
|
|
2846
|
-
e("0000000000000000000000000000000000000000000000000000000000000001")
|
|
2847
|
-
)
|
|
2848
|
-
), c(
|
|
2849
|
-
r.privateAdd(
|
|
2850
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),
|
|
2851
|
-
e("0000000000000000000000000000000000000000000000000000000000000003")
|
|
2852
|
-
) === null
|
|
2853
|
-
), c(
|
|
2854
|
-
S.from(
|
|
2855
|
-
r.privateAdd(
|
|
2856
|
-
e("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),
|
|
2857
|
-
e("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665")
|
|
2858
|
-
)
|
|
2859
|
-
).equals(
|
|
2860
|
-
e("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24")
|
|
2861
|
-
)
|
|
2862
|
-
), c(
|
|
2863
|
-
S.from(
|
|
2864
|
-
r.privateNegate(
|
|
2865
|
-
e("0000000000000000000000000000000000000000000000000000000000000001")
|
|
2866
|
-
)
|
|
2867
|
-
).equals(
|
|
2868
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")
|
|
2869
|
-
)
|
|
2870
|
-
), c(
|
|
2871
|
-
S.from(
|
|
2872
|
-
r.privateNegate(
|
|
2873
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")
|
|
2874
|
-
)
|
|
2875
|
-
).equals(
|
|
2876
|
-
e("0000000000000000000000000000000000000000000000000000000000000003")
|
|
2877
|
-
)
|
|
2878
|
-
), c(
|
|
2879
|
-
S.from(
|
|
2880
|
-
r.privateNegate(
|
|
2881
|
-
e("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")
|
|
2882
|
-
)
|
|
2883
|
-
).equals(
|
|
2884
|
-
e("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")
|
|
2885
|
-
)
|
|
2886
|
-
), c(
|
|
2887
|
-
S.from(
|
|
2888
|
-
r.pointCompress(
|
|
2889
|
-
e(
|
|
2890
|
-
"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
|
|
2891
|
-
),
|
|
2892
|
-
!0
|
|
2893
|
-
)
|
|
2894
|
-
).equals(
|
|
2895
|
-
e("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")
|
|
2896
|
-
)
|
|
2897
|
-
), c(
|
|
2898
|
-
S.from(
|
|
2899
|
-
r.pointCompress(
|
|
2900
|
-
e(
|
|
2901
|
-
"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
|
|
2902
|
-
),
|
|
2903
|
-
!1
|
|
2904
|
-
)
|
|
2905
|
-
).equals(
|
|
2906
|
-
e(
|
|
2907
|
-
"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
|
|
2908
|
-
)
|
|
2909
|
-
)
|
|
2910
|
-
), c(
|
|
2911
|
-
S.from(
|
|
2912
|
-
r.pointCompress(
|
|
2913
|
-
e("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
2914
|
-
!0
|
|
2915
|
-
)
|
|
2916
|
-
).equals(
|
|
2917
|
-
e("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")
|
|
2918
|
-
)
|
|
2919
|
-
), c(
|
|
2920
|
-
S.from(
|
|
2921
|
-
r.pointCompress(
|
|
2922
|
-
e("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
2923
|
-
!1
|
|
2924
|
-
)
|
|
2925
|
-
).equals(
|
|
2926
|
-
e(
|
|
2927
|
-
"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
|
|
2928
|
-
)
|
|
2929
|
-
)
|
|
2930
|
-
), c(
|
|
2931
|
-
S.from(
|
|
2932
|
-
r.pointFromScalar(
|
|
2933
|
-
e("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")
|
|
2934
|
-
)
|
|
2935
|
-
).equals(
|
|
2936
|
-
e("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99")
|
|
2937
|
-
)
|
|
2938
|
-
), c(
|
|
2939
|
-
r.xOnlyPointAddTweak(
|
|
2940
|
-
e("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
2941
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")
|
|
2942
|
-
) === null
|
|
2943
|
-
);
|
|
2944
|
-
let g = r.xOnlyPointAddTweak(
|
|
2945
|
-
e("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),
|
|
2946
|
-
e("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac")
|
|
2947
|
-
);
|
|
2948
|
-
c(
|
|
2949
|
-
S.from(g.xOnlyPubkey).equals(
|
|
2950
|
-
e("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf")
|
|
2951
|
-
) && g.parity === 1
|
|
2952
|
-
), g = r.xOnlyPointAddTweak(
|
|
2953
|
-
e("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),
|
|
2954
|
-
e("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")
|
|
2955
|
-
), c(
|
|
2956
|
-
S.from(g.xOnlyPubkey).equals(
|
|
2957
|
-
e("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c")
|
|
2958
|
-
) && g.parity === 0
|
|
2959
|
-
), c(
|
|
2960
|
-
S.from(
|
|
2961
|
-
r.sign(
|
|
2962
|
-
e("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),
|
|
2963
|
-
e("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")
|
|
2964
|
-
)
|
|
2965
|
-
).equals(
|
|
2966
|
-
e(
|
|
2967
|
-
"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"
|
|
2968
|
-
)
|
|
2969
|
-
)
|
|
2970
|
-
), c(
|
|
2971
|
-
r.verify(
|
|
2972
|
-
e("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),
|
|
2973
|
-
e("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
2974
|
-
e(
|
|
2975
|
-
"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"
|
|
2976
|
-
)
|
|
2977
|
-
)
|
|
2978
|
-
), r.signSchnorr && c(
|
|
2979
|
-
S.from(
|
|
2980
|
-
r.signSchnorr(
|
|
2981
|
-
e("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),
|
|
2982
|
-
e("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),
|
|
2983
|
-
e("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")
|
|
2984
|
-
)
|
|
2985
|
-
).equals(
|
|
2986
|
-
e(
|
|
2987
|
-
"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"
|
|
2988
|
-
)
|
|
2989
|
-
)
|
|
2990
|
-
), r.verifySchnorr && c(
|
|
2991
|
-
r.verifySchnorr(
|
|
2992
|
-
e("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),
|
|
2993
|
-
e("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),
|
|
2994
|
-
e(
|
|
2995
|
-
"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"
|
|
2996
|
-
)
|
|
2997
|
-
)
|
|
2998
|
-
);
|
|
2999
|
-
}
|
|
3000
|
-
he.testEcc = n;
|
|
3001
|
-
function c(r) {
|
|
3002
|
-
if (!r) throw new Error("ecc library invalid");
|
|
3003
|
-
}
|
|
3004
|
-
return he;
|
|
3005
|
-
}
|
|
3006
|
-
var Vr;
|
|
3007
|
-
function On() {
|
|
3008
|
-
if (Vr) return re;
|
|
3009
|
-
Vr = 1, Object.defineProperty(re, "__esModule", { value: !0 }), re.ECPairFactory = re.networks = void 0;
|
|
3010
|
-
const e = _n();
|
|
3011
|
-
re.networks = e;
|
|
3012
|
-
const n = Tn(), c = Pt(), r = Pn(), g = xn(), o = n.typeforce.maybe(
|
|
3013
|
-
n.typeforce.compile({
|
|
3014
|
-
compressed: n.maybe(n.Boolean),
|
|
3015
|
-
network: n.maybe(n.Network)
|
|
3016
|
-
})
|
|
3017
|
-
), i = (u) => u.length === 32 ? u : u.slice(1, 33);
|
|
3018
|
-
function t(u) {
|
|
3019
|
-
(0, g.testEcc)(u);
|
|
3020
|
-
function f(a) {
|
|
3021
|
-
return u.isPoint(a);
|
|
3022
|
-
}
|
|
3023
|
-
function d(a, l) {
|
|
3024
|
-
if (n.typeforce(n.Buffer256bit, a), !u.isPrivate(a))
|
|
3025
|
-
throw new TypeError("Private key not in range [1, n)");
|
|
3026
|
-
return n.typeforce(o, l), new s(a, void 0, l);
|
|
3027
|
-
}
|
|
3028
|
-
function v(a, l) {
|
|
3029
|
-
return n.typeforce(u.isPoint, a), n.typeforce(o, l), new s(void 0, a, l);
|
|
3030
|
-
}
|
|
3031
|
-
function p(a, l) {
|
|
3032
|
-
const E = r.decode(a), b = E.version;
|
|
3033
|
-
if (n.Array(l)) {
|
|
3034
|
-
if (l = l.filter((w) => b === w.wif).pop(), !l) throw new Error("Unknown network version");
|
|
3035
|
-
} else if (l = l || e.bitcoin, b !== l.wif) throw new Error("Invalid network version");
|
|
3036
|
-
return d(E.privateKey, {
|
|
3037
|
-
compressed: E.compressed,
|
|
3038
|
-
network: l
|
|
3039
|
-
});
|
|
3040
|
-
}
|
|
3041
|
-
function h(a) {
|
|
3042
|
-
n.typeforce(o, a), a === void 0 && (a = {});
|
|
3043
|
-
const l = a.rng || c;
|
|
3044
|
-
let E;
|
|
3045
|
-
do
|
|
3046
|
-
E = l(32), n.typeforce(n.Buffer256bit, E);
|
|
3047
|
-
while (!u.isPrivate(E));
|
|
3048
|
-
return d(E, a);
|
|
3049
|
-
}
|
|
3050
|
-
class s {
|
|
3051
|
-
__D;
|
|
3052
|
-
__Q;
|
|
3053
|
-
compressed;
|
|
3054
|
-
network;
|
|
3055
|
-
lowR;
|
|
3056
|
-
constructor(l, E, b) {
|
|
3057
|
-
this.__D = l, this.__Q = E, this.lowR = !1, b === void 0 && (b = {}), this.compressed = b.compressed === void 0 ? !0 : b.compressed, this.network = b.network || e.bitcoin, E !== void 0 && (this.__Q = S.from(u.pointCompress(E, this.compressed)));
|
|
3058
|
-
}
|
|
3059
|
-
get privateKey() {
|
|
3060
|
-
return this.__D;
|
|
3061
|
-
}
|
|
3062
|
-
get publicKey() {
|
|
3063
|
-
if (!this.__Q) {
|
|
3064
|
-
const l = u.pointFromScalar(this.__D, this.compressed);
|
|
3065
|
-
this.__Q = S.from(l);
|
|
3066
|
-
}
|
|
3067
|
-
return this.__Q;
|
|
3068
|
-
}
|
|
3069
|
-
toWIF() {
|
|
3070
|
-
if (!this.__D) throw new Error("Missing private key");
|
|
3071
|
-
return r.encode(this.network.wif, this.__D, this.compressed);
|
|
3072
|
-
}
|
|
3073
|
-
tweak(l) {
|
|
3074
|
-
return this.privateKey ? this.tweakFromPrivateKey(l) : this.tweakFromPublicKey(l);
|
|
3075
|
-
}
|
|
3076
|
-
sign(l, E) {
|
|
3077
|
-
if (!this.__D) throw new Error("Missing private key");
|
|
3078
|
-
if (E === void 0 && (E = this.lowR), E === !1)
|
|
3079
|
-
return S.from(u.sign(l, this.__D));
|
|
3080
|
-
{
|
|
3081
|
-
let b = u.sign(l, this.__D);
|
|
3082
|
-
const w = S.alloc(32, 0);
|
|
3083
|
-
let m = 0;
|
|
3084
|
-
for (; b[0] > 127; )
|
|
3085
|
-
m++, w.writeUIntLE(m, 0, 6), b = u.sign(l, this.__D, w);
|
|
3086
|
-
return S.from(b);
|
|
3087
|
-
}
|
|
3088
|
-
}
|
|
3089
|
-
signSchnorr(l) {
|
|
3090
|
-
if (!this.privateKey) throw new Error("Missing private key");
|
|
3091
|
-
if (!u.signSchnorr)
|
|
3092
|
-
throw new Error("signSchnorr not supported by ecc library");
|
|
3093
|
-
return S.from(u.signSchnorr(l, this.privateKey));
|
|
3094
|
-
}
|
|
3095
|
-
verify(l, E) {
|
|
3096
|
-
return u.verify(l, this.publicKey, E);
|
|
3097
|
-
}
|
|
3098
|
-
verifySchnorr(l, E) {
|
|
3099
|
-
if (!u.verifySchnorr)
|
|
3100
|
-
throw new Error("verifySchnorr not supported by ecc library");
|
|
3101
|
-
return u.verifySchnorr(l, this.publicKey.subarray(1, 33), E);
|
|
3102
|
-
}
|
|
3103
|
-
tweakFromPublicKey(l) {
|
|
3104
|
-
const E = i(this.publicKey), b = u.xOnlyPointAddTweak(E, l);
|
|
3105
|
-
if (!b || b.xOnlyPubkey === null)
|
|
3106
|
-
throw new Error("Cannot tweak public key!");
|
|
3107
|
-
const w = S.from([
|
|
3108
|
-
b.parity === 0 ? 2 : 3
|
|
3109
|
-
]);
|
|
3110
|
-
return v(
|
|
3111
|
-
S.concat([w, b.xOnlyPubkey]),
|
|
3112
|
-
{ network: this.network, compressed: this.compressed }
|
|
3113
|
-
);
|
|
3114
|
-
}
|
|
3115
|
-
tweakFromPrivateKey(l) {
|
|
3116
|
-
const b = this.publicKey[0] === 3 || this.publicKey[0] === 4 && (this.publicKey[64] & 1) === 1 ? u.privateNegate(this.privateKey) : this.privateKey, w = u.privateAdd(b, l);
|
|
3117
|
-
if (!w) throw new Error("Invalid tweaked private key!");
|
|
3118
|
-
return d(S.from(w), {
|
|
3119
|
-
network: this.network,
|
|
3120
|
-
compressed: this.compressed
|
|
3121
|
-
});
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
return {
|
|
3125
|
-
isPoint: f,
|
|
3126
|
-
fromPrivateKey: d,
|
|
3127
|
-
fromPublicKey: v,
|
|
3128
|
-
fromWIF: p,
|
|
3129
|
-
makeRandom: h
|
|
3130
|
-
};
|
|
3131
|
-
}
|
|
3132
|
-
return re.ECPairFactory = t, re;
|
|
3133
|
-
}
|
|
3134
|
-
var Xr;
|
|
3135
|
-
function Rn() {
|
|
3136
|
-
return Xr || (Xr = 1, (function(e) {
|
|
3137
|
-
Object.defineProperty(e, "__esModule", { value: !0 }), e.networks = e.ECPairFactory = e.default = void 0;
|
|
3138
|
-
var n = On();
|
|
3139
|
-
Object.defineProperty(e, "default", {
|
|
3140
|
-
enumerable: !0,
|
|
3141
|
-
get: function() {
|
|
3142
|
-
return n.ECPairFactory;
|
|
3143
|
-
}
|
|
3144
|
-
}), Object.defineProperty(e, "ECPairFactory", {
|
|
3145
|
-
enumerable: !0,
|
|
3146
|
-
get: function() {
|
|
3147
|
-
return n.ECPairFactory;
|
|
3148
|
-
}
|
|
3149
|
-
}), Object.defineProperty(e, "networks", {
|
|
3150
|
-
enumerable: !0,
|
|
3151
|
-
get: function() {
|
|
3152
|
-
return n.networks;
|
|
3153
|
-
}
|
|
3154
|
-
});
|
|
3155
|
-
})(Le)), Le;
|
|
3156
|
-
}
|
|
3157
|
-
var Xn = Rn();
|
|
3158
|
-
export {
|
|
3159
|
-
qn as a,
|
|
3160
|
-
Fn as b,
|
|
3161
|
-
Xt as c,
|
|
3162
|
-
Ln as d,
|
|
3163
|
-
Dn as e,
|
|
3164
|
-
Gn as f,
|
|
3165
|
-
nt as g,
|
|
3166
|
-
Mn as i,
|
|
3167
|
-
Wn as p,
|
|
3168
|
-
Vn as r,
|
|
3169
|
-
Xn as s,
|
|
3170
|
-
Hn as u,
|
|
3171
|
-
jn as v
|
|
3172
|
-
};
|