@btc-vision/transaction 1.8.7 → 1.8.9
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/btc-vision-bitcoin.js +705 -703
- package/browser/index.js +116 -108
- package/browser/noble-curves.js +4 -4
- package/browser/noble-hashes.js +88 -88
- package/browser/rolldown-runtime.js +26 -19
- package/browser/src/epoch/validator/EpochValidator.d.ts +28 -6
- package/browser/vendors.js +3065 -3027
- package/build/epoch/validator/EpochValidator.d.ts +28 -6
- package/build/epoch/validator/EpochValidator.js +44 -10
- package/build/transaction/builders/TransactionBuilder.js +18 -2
- package/package.json +1 -1
- package/src/epoch/validator/EpochValidator.ts +67 -6
- package/src/transaction/builders/TransactionBuilder.ts +19 -2
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -156,10 +156,10 @@ var kt = {
|
|
|
156
156
|
scriptHash: 196,
|
|
157
157
|
wif: 239
|
|
158
158
|
}
|
|
159
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
159
|
+
}, Symbol.toStringTag, { value: "Module" })), ge = {}, mi;
|
|
160
160
|
function Ia() {
|
|
161
|
-
if (mi) return
|
|
162
|
-
mi = 1, Object.defineProperty(
|
|
161
|
+
if (mi) return ge;
|
|
162
|
+
mi = 1, Object.defineProperty(ge, "__esModule", { value: !0 }), ge.bech32m = ge.bech32 = void 0;
|
|
163
163
|
const e = "qpzry9x8gf2tvdw0s3jn54khce6mua7l", t = {};
|
|
164
164
|
for (let p = 0; p < 32; p++) {
|
|
165
165
|
const u = e.charAt(p);
|
|
@@ -184,13 +184,13 @@ function Ia() {
|
|
|
184
184
|
return u;
|
|
185
185
|
}
|
|
186
186
|
function i(p, u, d, w) {
|
|
187
|
-
let
|
|
187
|
+
let g = 0, m = 0;
|
|
188
188
|
const v = (1 << d) - 1, I = [];
|
|
189
|
-
for (let P = 0; P < p.length; ++P) for (
|
|
190
|
-
if (w) m > 0 && I.push(
|
|
189
|
+
for (let P = 0; P < p.length; ++P) for (g = g << u | p[P], m += u; m >= d; ) m -= d, I.push(g >> m & v);
|
|
190
|
+
if (w) m > 0 && I.push(g << d - m & v);
|
|
191
191
|
else {
|
|
192
192
|
if (m >= u) return "Excess padding";
|
|
193
|
-
if (
|
|
193
|
+
if (g << d - m & v) return "Non-zero padding";
|
|
194
194
|
}
|
|
195
195
|
return I;
|
|
196
196
|
}
|
|
@@ -239,20 +239,20 @@ function Ia() {
|
|
|
239
239
|
if (_ === 0) return "Missing prefix for " + v;
|
|
240
240
|
const O = v.slice(0, _), z = v.slice(_ + 1);
|
|
241
241
|
if (z.length < 6) return "Data too short";
|
|
242
|
-
let
|
|
243
|
-
if (typeof
|
|
244
|
-
const
|
|
245
|
-
for (let
|
|
246
|
-
const q = z.charAt(
|
|
242
|
+
let M = n(O);
|
|
243
|
+
if (typeof M == "string") return M;
|
|
244
|
+
const Z = [];
|
|
245
|
+
for (let Q = 0; Q < z.length; ++Q) {
|
|
246
|
+
const q = z.charAt(Q), Vt = t[q];
|
|
247
247
|
if (Vt === void 0) return "Unknown character " + q;
|
|
248
|
-
|
|
248
|
+
M = r(M) ^ Vt, !(Q + 6 >= z.length) && Z.push(Vt);
|
|
249
249
|
}
|
|
250
|
-
return
|
|
250
|
+
return M !== u ? "Invalid checksum for " + v : {
|
|
251
251
|
prefix: O,
|
|
252
|
-
words:
|
|
252
|
+
words: Z
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function g(v, I) {
|
|
256
256
|
const P = w(v, I);
|
|
257
257
|
if (typeof P == "object") return P;
|
|
258
258
|
}
|
|
@@ -262,7 +262,7 @@ function Ia() {
|
|
|
262
262
|
throw new Error(P);
|
|
263
263
|
}
|
|
264
264
|
return {
|
|
265
|
-
decodeUnsafe:
|
|
265
|
+
decodeUnsafe: g,
|
|
266
266
|
decode: m,
|
|
267
267
|
encode: d,
|
|
268
268
|
toWords: o,
|
|
@@ -270,19 +270,19 @@ function Ia() {
|
|
|
270
270
|
fromWords: f
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
|
-
return
|
|
273
|
+
return ge.bech32 = l("bech32"), ge.bech32m = l("bech32m"), ge;
|
|
274
274
|
}
|
|
275
|
-
var
|
|
275
|
+
var et = Ia();
|
|
276
276
|
function cr(e) {
|
|
277
277
|
let t, r;
|
|
278
278
|
try {
|
|
279
|
-
t =
|
|
279
|
+
t = et.bech32.decode(e);
|
|
280
280
|
} catch {
|
|
281
281
|
}
|
|
282
282
|
if (t) {
|
|
283
283
|
if (r = t.words[0], r !== 0) throw new TypeError(e + " uses wrong encoding");
|
|
284
|
-
} else if (t =
|
|
285
|
-
const n =
|
|
284
|
+
} else if (t = et.bech32m.decode(e), r = t.words[0], r === 0) throw new TypeError(e + " uses wrong encoding");
|
|
285
|
+
const n = et.bech32.fromWords(t.words.slice(1));
|
|
286
286
|
return {
|
|
287
287
|
version: r,
|
|
288
288
|
prefix: t.prefix,
|
|
@@ -351,7 +351,7 @@ function xa(e) {
|
|
|
351
351
|
function Ts(e) {
|
|
352
352
|
typeof e == "number" ? xa(e) : Pa(e);
|
|
353
353
|
}
|
|
354
|
-
function
|
|
354
|
+
function ye(e, t, r) {
|
|
355
355
|
Ts(e), r === void 0 && (r = 0), t === void 0 && (t = new Uint8Array(Ct(e)));
|
|
356
356
|
let n = 0;
|
|
357
357
|
return e < 253 ? (t.set([Number(e)], r), n = 1) : e <= 65535 ? (t.set([253], r), Aa(t, r + 1, Number(e), "LE"), n = 3) : e <= 4294967295 ? (t.set([254], r), Sa(t, r + 1, Number(e), "LE"), n = 5) : (t.set([255], r), Ta(t, r + 1, BigInt(e), "LE"), n = 9), {
|
|
@@ -397,7 +397,7 @@ function Ct(e) {
|
|
|
397
397
|
var Kl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
398
398
|
__proto__: null,
|
|
399
399
|
decode: We,
|
|
400
|
-
encode:
|
|
400
|
+
encode: ye,
|
|
401
401
|
encodingLength: Ct
|
|
402
402
|
}, Symbol.toStringTag, { value: "Module" })), Ba = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), Ei = (() => {
|
|
403
403
|
const e = new Array(128).fill(-1);
|
|
@@ -901,13 +901,13 @@ var Wn = class {
|
|
|
901
901
|
process(e, t) {
|
|
902
902
|
for (let u = 0; u < 16; u++, t += 4) oe[u] = e.getUint32(t, !1);
|
|
903
903
|
for (let u = 16; u < 64; u++) {
|
|
904
|
-
const d = oe[u - 15], w = oe[u - 2],
|
|
905
|
-
oe[u] =
|
|
904
|
+
const d = oe[u - 15], w = oe[u - 2], g = Wt(d, 7) ^ Wt(d, 18) ^ d >>> 3, m = Wt(w, 17) ^ Wt(w, 19) ^ w >>> 10;
|
|
905
|
+
oe[u] = m + oe[u - 7] + g + oe[u - 16] | 0;
|
|
906
906
|
}
|
|
907
907
|
let { A: r, B: n, C: i, D: o, E: a, F: f, G: l, H: p } = this;
|
|
908
908
|
for (let u = 0; u < 64; u++) {
|
|
909
|
-
const d = Wt(a, 6) ^ Wt(a, 11) ^ Wt(a, 25), w = p + d + Os(a, f, l) + Ca[u] + oe[u] | 0,
|
|
910
|
-
p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w +
|
|
909
|
+
const d = Wt(a, 6) ^ Wt(a, 11) ^ Wt(a, 25), w = p + d + Os(a, f, l) + Ca[u] + oe[u] | 0, g = (Wt(r, 2) ^ Wt(r, 13) ^ Wt(r, 22)) + Ps(r, n, i) | 0;
|
|
910
|
+
p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w + g | 0;
|
|
911
911
|
}
|
|
912
912
|
r = r + this.A | 0, n = n + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, p = p + this.H | 0, this.set(r, n, i, o, a, f, l, p);
|
|
913
913
|
}
|
|
@@ -932,7 +932,7 @@ var Wn = class {
|
|
|
932
932
|
}, Ke = /* @__PURE__ */ Fn(() => new $a(), /* @__PURE__ */ La(1));
|
|
933
933
|
function Ka(e) {
|
|
934
934
|
if (e.length >= 255) throw new TypeError("Alphabet too long");
|
|
935
|
-
const t = new Uint8Array(256);
|
|
935
|
+
const t = /* @__PURE__ */ new Uint8Array(256);
|
|
936
936
|
for (let p = 0; p < t.length; p++) t[p] = 255;
|
|
937
937
|
for (let p = 0; p < e.length; p++) {
|
|
938
938
|
const u = e.charAt(p), d = u.charCodeAt(0);
|
|
@@ -944,10 +944,10 @@ function Ka(e) {
|
|
|
944
944
|
if (p instanceof Uint8Array || (ArrayBuffer.isView(p) ? p = new Uint8Array(p.buffer, p.byteOffset, p.byteLength) : Array.isArray(p) && (p = Uint8Array.from(p))), !(p instanceof Uint8Array)) throw new TypeError("Expected Uint8Array");
|
|
945
945
|
if (p.length === 0) return "";
|
|
946
946
|
let u = 0, d = 0, w = 0;
|
|
947
|
-
const
|
|
948
|
-
for (; w !==
|
|
949
|
-
const m = (
|
|
950
|
-
for (; w !==
|
|
947
|
+
const g = p.length;
|
|
948
|
+
for (; w !== g && p[w] === 0; ) w++, u++;
|
|
949
|
+
const m = (g - w) * o + 1 >>> 0, v = new Uint8Array(m);
|
|
950
|
+
for (; w !== g; ) {
|
|
951
951
|
let S = p[w], _ = 0;
|
|
952
952
|
for (let O = m - 1; (S !== 0 || _ < d) && O !== -1; O--, _++) S += 256 * v[O] >>> 0, v[O] = S % r >>> 0, S = S / r >>> 0;
|
|
953
953
|
if (S !== 0) throw new Error("Non-zero carry");
|
|
@@ -961,25 +961,25 @@ function Ka(e) {
|
|
|
961
961
|
}
|
|
962
962
|
function f(p) {
|
|
963
963
|
if (typeof p != "string") throw new TypeError("Expected String");
|
|
964
|
-
if (p.length === 0) return new Uint8Array();
|
|
964
|
+
if (p.length === 0) return /* @__PURE__ */ new Uint8Array();
|
|
965
965
|
let u = 0, d = 0, w = 0;
|
|
966
966
|
for (; p[u] === n; ) d++, u++;
|
|
967
|
-
const
|
|
967
|
+
const g = (p.length - u) * i + 1 >>> 0, m = new Uint8Array(g);
|
|
968
968
|
for (; u < p.length; ) {
|
|
969
969
|
const S = p.charCodeAt(u);
|
|
970
970
|
if (S > 255) return;
|
|
971
971
|
let _ = t[S];
|
|
972
972
|
if (_ === 255) return;
|
|
973
973
|
let O = 0;
|
|
974
|
-
for (let z =
|
|
974
|
+
for (let z = g - 1; (_ !== 0 || O < w) && z !== -1; z--, O++) _ += r * m[z] >>> 0, m[z] = _ % 256 >>> 0, _ = _ / 256 >>> 0;
|
|
975
975
|
if (_ !== 0) throw new Error("Non-zero carry");
|
|
976
976
|
w = O, u++;
|
|
977
977
|
}
|
|
978
|
-
let v =
|
|
979
|
-
for (; v !==
|
|
980
|
-
const I = new Uint8Array(d + (
|
|
978
|
+
let v = g - w;
|
|
979
|
+
for (; v !== g && m[v] === 0; ) v++;
|
|
980
|
+
const I = new Uint8Array(d + (g - v));
|
|
981
981
|
let P = d;
|
|
982
|
-
for (; v !==
|
|
982
|
+
for (; v !== g; ) I[P++] = m[v++];
|
|
983
983
|
return I;
|
|
984
984
|
}
|
|
985
985
|
function l(p) {
|
|
@@ -1304,21 +1304,21 @@ function eh(e) {
|
|
|
1304
1304
|
}
|
|
1305
1305
|
var qn = {};
|
|
1306
1306
|
qn.read = function(e, t, r, n, i) {
|
|
1307
|
-
var o, a, f = i * 8 - n - 1, l = (1 << f) - 1, p = l >> 1, u = -7, d = r ? i - 1 : 0, w = r ? -1 : 1,
|
|
1308
|
-
for (d += w, o =
|
|
1307
|
+
var o, a, f = i * 8 - n - 1, l = (1 << f) - 1, p = l >> 1, u = -7, d = r ? i - 1 : 0, w = r ? -1 : 1, g = e[t + d];
|
|
1308
|
+
for (d += w, o = g & (1 << -u) - 1, g >>= -u, u += f; u > 0; o = o * 256 + e[t + d], d += w, u -= 8) ;
|
|
1309
1309
|
for (a = o & (1 << -u) - 1, o >>= -u, u += n; u > 0; a = a * 256 + e[t + d], d += w, u -= 8) ;
|
|
1310
1310
|
if (o === 0) o = 1 - p;
|
|
1311
1311
|
else {
|
|
1312
|
-
if (o === l) return a ? NaN : (
|
|
1312
|
+
if (o === l) return a ? NaN : (g ? -1 : 1) * (1 / 0);
|
|
1313
1313
|
a = a + Math.pow(2, n), o = o - p;
|
|
1314
1314
|
}
|
|
1315
|
-
return (
|
|
1315
|
+
return (g ? -1 : 1) * a * Math.pow(2, o - n);
|
|
1316
1316
|
};
|
|
1317
1317
|
qn.write = function(e, t, r, n, i, o) {
|
|
1318
|
-
var a, f, l, p = o * 8 - i - 1, u = (1 << p) - 1, d = u >> 1, w = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
|
|
1319
|
-
for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (f = isNaN(t) ? 1 : 0, a = u) : (a = Math.floor(Math.log(t) / Math.LN2), t * (l = Math.pow(2, -a)) < 1 && (a--, l *= 2), a + d >= 1 ? t += w / l : t += w * Math.pow(2, 1 - d), t * l >= 2 && (a++, l /= 2), a + d >= u ? (f = 0, a = u) : a + d >= 1 ? (f = (t * l - 1) * Math.pow(2, i), a = a + d) : (f = t * Math.pow(2, d - 1) * Math.pow(2, i), a = 0)); i >= 8; e[r +
|
|
1320
|
-
for (a = a << i | f, p += i; p > 0; e[r +
|
|
1321
|
-
e[r +
|
|
1318
|
+
var a, f, l, p = o * 8 - i - 1, u = (1 << p) - 1, d = u >> 1, w = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, g = n ? 0 : o - 1, m = n ? 1 : -1, v = t < 0 || t === 0 && 1 / t < 0 ? 1 : 0;
|
|
1319
|
+
for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (f = isNaN(t) ? 1 : 0, a = u) : (a = Math.floor(Math.log(t) / Math.LN2), t * (l = Math.pow(2, -a)) < 1 && (a--, l *= 2), a + d >= 1 ? t += w / l : t += w * Math.pow(2, 1 - d), t * l >= 2 && (a++, l /= 2), a + d >= u ? (f = 0, a = u) : a + d >= 1 ? (f = (t * l - 1) * Math.pow(2, i), a = a + d) : (f = t * Math.pow(2, d - 1) * Math.pow(2, i), a = 0)); i >= 8; e[r + g] = f & 255, g += m, f /= 256, i -= 8) ;
|
|
1320
|
+
for (a = a << i | f, p += i; p > 0; e[r + g] = a & 255, g += m, a /= 256, p -= 8) ;
|
|
1321
|
+
e[r + g - m] |= v * 128;
|
|
1322
1322
|
};
|
|
1323
1323
|
(function(e) {
|
|
1324
1324
|
const t = Zr, r = qn, n = typeof Symbol == "function" && typeof Symbol.for == "function" ? /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom") : null;
|
|
@@ -1367,10 +1367,10 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1367
1367
|
if (s == null) throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof s);
|
|
1368
1368
|
if (Ft(s, a) || s && Ft(s.buffer, a) || typeof f < "u" && (Ft(s, f) || s && Ft(s.buffer, f))) return S(s, h, c);
|
|
1369
1369
|
if (typeof s == "number") throw new TypeError('The "value" argument must not be of type number. Received type number');
|
|
1370
|
-
const
|
|
1371
|
-
if (
|
|
1372
|
-
const
|
|
1373
|
-
if (
|
|
1370
|
+
const y = s.valueOf && s.valueOf();
|
|
1371
|
+
if (y != null && y !== s) return u.from(y, h, c);
|
|
1372
|
+
const b = _(s);
|
|
1373
|
+
if (b) return b;
|
|
1374
1374
|
if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof s[Symbol.toPrimitive] == "function") return u.from(s[Symbol.toPrimitive]("string"), h, c);
|
|
1375
1375
|
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof s);
|
|
1376
1376
|
}
|
|
@@ -1381,11 +1381,11 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1381
1381
|
if (typeof s != "number") throw new TypeError('"size" argument must be of type number');
|
|
1382
1382
|
if (s < 0) throw new RangeError('The value "' + s + '" is invalid for option "size"');
|
|
1383
1383
|
}
|
|
1384
|
-
function
|
|
1384
|
+
function g(s, h, c) {
|
|
1385
1385
|
return w(s), s <= 0 ? p(s) : h !== void 0 ? typeof c == "string" ? p(s).fill(h, c) : p(s).fill(h) : p(s);
|
|
1386
1386
|
}
|
|
1387
1387
|
u.alloc = function(s, h, c) {
|
|
1388
|
-
return
|
|
1388
|
+
return g(s, h, c);
|
|
1389
1389
|
};
|
|
1390
1390
|
function m(s) {
|
|
1391
1391
|
return w(s), p(s < 0 ? 0 : O(s) | 0);
|
|
@@ -1397,14 +1397,14 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1397
1397
|
};
|
|
1398
1398
|
function v(s, h) {
|
|
1399
1399
|
if ((typeof h != "string" || h === "") && (h = "utf8"), !u.isEncoding(h)) throw new TypeError("Unknown encoding: " + h);
|
|
1400
|
-
const c =
|
|
1401
|
-
let
|
|
1402
|
-
const
|
|
1403
|
-
return
|
|
1400
|
+
const c = M(s, h) | 0;
|
|
1401
|
+
let y = p(c);
|
|
1402
|
+
const b = y.write(s, h);
|
|
1403
|
+
return b !== c && (y = y.slice(0, b)), y;
|
|
1404
1404
|
}
|
|
1405
1405
|
function I(s) {
|
|
1406
1406
|
const h = s.length < 0 ? 0 : O(s.length) | 0, c = p(h);
|
|
1407
|
-
for (let
|
|
1407
|
+
for (let y = 0; y < h; y += 1) c[y] = s[y] & 255;
|
|
1408
1408
|
return c;
|
|
1409
1409
|
}
|
|
1410
1410
|
function P(s) {
|
|
@@ -1417,8 +1417,8 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1417
1417
|
function S(s, h, c) {
|
|
1418
1418
|
if (h < 0 || s.byteLength < h) throw new RangeError('"offset" is outside of buffer bounds');
|
|
1419
1419
|
if (s.byteLength < h + (c || 0)) throw new RangeError('"length" is outside of buffer bounds');
|
|
1420
|
-
let
|
|
1421
|
-
return h === void 0 && c === void 0 ?
|
|
1420
|
+
let y;
|
|
1421
|
+
return h === void 0 && c === void 0 ? y = new o(s) : c === void 0 ? y = new o(s, h) : y = new o(s, h, c), Object.setPrototypeOf(y, u.prototype), y;
|
|
1422
1422
|
}
|
|
1423
1423
|
function _(s) {
|
|
1424
1424
|
if (u.isBuffer(s)) {
|
|
@@ -1440,12 +1440,12 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1440
1440
|
}, u.compare = function(s, h) {
|
|
1441
1441
|
if (Ft(s, o) && (s = u.from(s, s.offset, s.byteLength)), Ft(h, o) && (h = u.from(h, h.offset, h.byteLength)), !u.isBuffer(s) || !u.isBuffer(h)) throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
|
|
1442
1442
|
if (s === h) return 0;
|
|
1443
|
-
let c = s.length,
|
|
1444
|
-
for (let
|
|
1445
|
-
c = s[
|
|
1443
|
+
let c = s.length, y = h.length;
|
|
1444
|
+
for (let b = 0, E = Math.min(c, y); b < E; ++b) if (s[b] !== h[b]) {
|
|
1445
|
+
c = s[b], y = h[b];
|
|
1446
1446
|
break;
|
|
1447
1447
|
}
|
|
1448
|
-
return c <
|
|
1448
|
+
return c < y ? -1 : y < c ? 1 : 0;
|
|
1449
1449
|
}, u.isEncoding = function(s) {
|
|
1450
1450
|
switch (String(s).toLowerCase()) {
|
|
1451
1451
|
case "hex":
|
|
@@ -1468,24 +1468,24 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1468
1468
|
if (s.length === 0) return u.alloc(0);
|
|
1469
1469
|
let c;
|
|
1470
1470
|
if (h === void 0) for (h = 0, c = 0; c < s.length; ++c) h += s[c].length;
|
|
1471
|
-
const
|
|
1472
|
-
let
|
|
1471
|
+
const y = u.allocUnsafe(h);
|
|
1472
|
+
let b = 0;
|
|
1473
1473
|
for (c = 0; c < s.length; ++c) {
|
|
1474
1474
|
let E = s[c];
|
|
1475
|
-
if (Ft(E, o))
|
|
1476
|
-
else if (u.isBuffer(E)) E.copy(
|
|
1475
|
+
if (Ft(E, o)) b + E.length > y.length ? (u.isBuffer(E) || (E = u.from(E)), E.copy(y, b)) : o.prototype.set.call(y, E, b);
|
|
1476
|
+
else if (u.isBuffer(E)) E.copy(y, b);
|
|
1477
1477
|
else throw new TypeError('"list" argument must be an Array of Buffers');
|
|
1478
|
-
|
|
1478
|
+
b += E.length;
|
|
1479
1479
|
}
|
|
1480
|
-
return
|
|
1480
|
+
return y;
|
|
1481
1481
|
};
|
|
1482
|
-
function
|
|
1482
|
+
function M(s, h) {
|
|
1483
1483
|
if (u.isBuffer(s)) return s.length;
|
|
1484
1484
|
if (a.isView(s) || Ft(s, a)) return s.byteLength;
|
|
1485
1485
|
if (typeof s != "string") throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof s);
|
|
1486
|
-
const c = s.length,
|
|
1487
|
-
if (!
|
|
1488
|
-
let
|
|
1486
|
+
const c = s.length, y = arguments.length > 2 && arguments[2] === !0;
|
|
1487
|
+
if (!y && c === 0) return 0;
|
|
1488
|
+
let b = !1;
|
|
1489
1489
|
for (; ; ) switch (h) {
|
|
1490
1490
|
case "ascii":
|
|
1491
1491
|
case "latin1":
|
|
@@ -1504,13 +1504,13 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1504
1504
|
case "base64":
|
|
1505
1505
|
return bi(s).length;
|
|
1506
1506
|
default:
|
|
1507
|
-
if (
|
|
1508
|
-
h = ("" + h).toLowerCase(),
|
|
1507
|
+
if (b) return y ? -1 : hn(s).length;
|
|
1508
|
+
h = ("" + h).toLowerCase(), b = !0;
|
|
1509
1509
|
}
|
|
1510
1510
|
}
|
|
1511
|
-
u.byteLength =
|
|
1512
|
-
function
|
|
1513
|
-
let
|
|
1511
|
+
u.byteLength = M;
|
|
1512
|
+
function Z(s, h, c) {
|
|
1513
|
+
let y = !1;
|
|
1514
1514
|
if ((h === void 0 || h < 0) && (h = 0), h > this.length || ((c === void 0 || c > this.length) && (c = this.length), c <= 0) || (c >>>= 0, h >>>= 0, c <= h)) return "";
|
|
1515
1515
|
for (s || (s = "utf8"); ; ) switch (s) {
|
|
1516
1516
|
case "hex":
|
|
@@ -1522,7 +1522,7 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1522
1522
|
return L(this, h, c);
|
|
1523
1523
|
case "latin1":
|
|
1524
1524
|
case "binary":
|
|
1525
|
-
return
|
|
1525
|
+
return D(this, h, c);
|
|
1526
1526
|
case "base64":
|
|
1527
1527
|
return B(this, h, c);
|
|
1528
1528
|
case "ucs2":
|
|
@@ -1531,33 +1531,33 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1531
1531
|
case "utf-16le":
|
|
1532
1532
|
return ct(this, h, c);
|
|
1533
1533
|
default:
|
|
1534
|
-
if (
|
|
1535
|
-
s = (s + "").toLowerCase(),
|
|
1534
|
+
if (y) throw new TypeError("Unknown encoding: " + s);
|
|
1535
|
+
s = (s + "").toLowerCase(), y = !0;
|
|
1536
1536
|
}
|
|
1537
1537
|
}
|
|
1538
1538
|
u.prototype._isBuffer = !0;
|
|
1539
|
-
function
|
|
1540
|
-
const
|
|
1541
|
-
s[h] = s[c], s[c] =
|
|
1539
|
+
function Q(s, h, c) {
|
|
1540
|
+
const y = s[h];
|
|
1541
|
+
s[h] = s[c], s[c] = y;
|
|
1542
1542
|
}
|
|
1543
1543
|
u.prototype.swap16 = function() {
|
|
1544
1544
|
const s = this.length;
|
|
1545
1545
|
if (s % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
1546
|
-
for (let h = 0; h < s; h += 2)
|
|
1546
|
+
for (let h = 0; h < s; h += 2) Q(this, h, h + 1);
|
|
1547
1547
|
return this;
|
|
1548
1548
|
}, u.prototype.swap32 = function() {
|
|
1549
1549
|
const s = this.length;
|
|
1550
1550
|
if (s % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
1551
|
-
for (let h = 0; h < s; h += 4)
|
|
1551
|
+
for (let h = 0; h < s; h += 4) Q(this, h, h + 3), Q(this, h + 1, h + 2);
|
|
1552
1552
|
return this;
|
|
1553
1553
|
}, u.prototype.swap64 = function() {
|
|
1554
1554
|
const s = this.length;
|
|
1555
1555
|
if (s % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
1556
|
-
for (let h = 0; h < s; h += 8)
|
|
1556
|
+
for (let h = 0; h < s; h += 8) Q(this, h, h + 7), Q(this, h + 1, h + 6), Q(this, h + 2, h + 5), Q(this, h + 3, h + 4);
|
|
1557
1557
|
return this;
|
|
1558
1558
|
}, u.prototype.toString = function() {
|
|
1559
1559
|
const s = this.length;
|
|
1560
|
-
return s === 0 ? "" : arguments.length === 0 ? V(this, 0, s) :
|
|
1560
|
+
return s === 0 ? "" : arguments.length === 0 ? V(this, 0, s) : Z.apply(this, arguments);
|
|
1561
1561
|
}, u.prototype.toLocaleString = u.prototype.toString, u.prototype.equals = function(s) {
|
|
1562
1562
|
if (!u.isBuffer(s)) throw new TypeError("Argument must be a Buffer");
|
|
1563
1563
|
return this === s ? !0 : u.compare(this, s) === 0;
|
|
@@ -1565,54 +1565,54 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1565
1565
|
let s = "";
|
|
1566
1566
|
const h = e.INSPECT_MAX_BYTES;
|
|
1567
1567
|
return s = this.toString("hex", 0, h).replace(/(.{2})/g, "$1 ").trim(), this.length > h && (s += " ... "), "<Buffer " + s + ">";
|
|
1568
|
-
}, n && (u.prototype[n] = u.prototype.inspect), u.prototype.compare = function(s, h, c,
|
|
1568
|
+
}, n && (u.prototype[n] = u.prototype.inspect), u.prototype.compare = function(s, h, c, y, b) {
|
|
1569
1569
|
if (Ft(s, o) && (s = u.from(s, s.offset, s.byteLength)), !u.isBuffer(s)) throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof s);
|
|
1570
|
-
if (h === void 0 && (h = 0), c === void 0 && (c = s ? s.length : 0),
|
|
1571
|
-
if (
|
|
1572
|
-
if (
|
|
1570
|
+
if (h === void 0 && (h = 0), c === void 0 && (c = s ? s.length : 0), y === void 0 && (y = 0), b === void 0 && (b = this.length), h < 0 || c > s.length || y < 0 || b > this.length) throw new RangeError("out of range index");
|
|
1571
|
+
if (y >= b && h >= c) return 0;
|
|
1572
|
+
if (y >= b) return -1;
|
|
1573
1573
|
if (h >= c) return 1;
|
|
1574
|
-
if (h >>>= 0, c >>>= 0,
|
|
1575
|
-
let E =
|
|
1576
|
-
const
|
|
1577
|
-
for (let
|
|
1578
|
-
E = bt[
|
|
1574
|
+
if (h >>>= 0, c >>>= 0, y >>>= 0, b >>>= 0, this === s) return 0;
|
|
1575
|
+
let E = b - y, k = c - h;
|
|
1576
|
+
const ot = Math.min(E, k), bt = this.slice(y, b), at = s.slice(h, c);
|
|
1577
|
+
for (let nt = 0; nt < ot; ++nt) if (bt[nt] !== at[nt]) {
|
|
1578
|
+
E = bt[nt], k = at[nt];
|
|
1579
1579
|
break;
|
|
1580
1580
|
}
|
|
1581
1581
|
return E < k ? -1 : k < E ? 1 : 0;
|
|
1582
1582
|
};
|
|
1583
|
-
function q(s, h, c,
|
|
1583
|
+
function q(s, h, c, y, b) {
|
|
1584
1584
|
if (s.length === 0) return -1;
|
|
1585
|
-
if (typeof c == "string" ? (
|
|
1586
|
-
if (
|
|
1585
|
+
if (typeof c == "string" ? (y = c, c = 0) : c > 2147483647 ? c = 2147483647 : c < -2147483648 && (c = -2147483648), c = +c, un(c) && (c = b ? 0 : s.length - 1), c < 0 && (c = s.length + c), c >= s.length) {
|
|
1586
|
+
if (b) return -1;
|
|
1587
1587
|
c = s.length - 1;
|
|
1588
|
-
} else if (c < 0) if (
|
|
1588
|
+
} else if (c < 0) if (b) c = 0;
|
|
1589
1589
|
else return -1;
|
|
1590
|
-
if (typeof h == "string" && (h = u.from(h,
|
|
1591
|
-
if (typeof h == "number") return h = h & 255, typeof o.prototype.indexOf == "function" ?
|
|
1590
|
+
if (typeof h == "string" && (h = u.from(h, y)), u.isBuffer(h)) return h.length === 0 ? -1 : Vt(s, h, c, y, b);
|
|
1591
|
+
if (typeof h == "number") return h = h & 255, typeof o.prototype.indexOf == "function" ? b ? o.prototype.indexOf.call(s, h, c) : o.prototype.lastIndexOf.call(s, h, c) : Vt(s, [h], c, y, b);
|
|
1592
1592
|
throw new TypeError("val must be string, number or Buffer");
|
|
1593
1593
|
}
|
|
1594
|
-
function Vt(s, h, c,
|
|
1595
|
-
let E = 1, k = s.length,
|
|
1596
|
-
if (
|
|
1594
|
+
function Vt(s, h, c, y, b) {
|
|
1595
|
+
let E = 1, k = s.length, ot = h.length;
|
|
1596
|
+
if (y !== void 0 && (y = String(y).toLowerCase(), y === "ucs2" || y === "ucs-2" || y === "utf16le" || y === "utf-16le")) {
|
|
1597
1597
|
if (s.length < 2 || h.length < 2) return -1;
|
|
1598
|
-
E = 2, k /= 2,
|
|
1599
|
-
}
|
|
1600
|
-
function bt(
|
|
1601
|
-
return E === 1 ?
|
|
1602
|
-
}
|
|
1603
|
-
let
|
|
1604
|
-
if (
|
|
1605
|
-
let
|
|
1606
|
-
for (
|
|
1607
|
-
if (
|
|
1608
|
-
} else
|
|
1609
|
-
} else for (c +
|
|
1610
|
-
let
|
|
1611
|
-
for (let pt = 0; pt <
|
|
1612
|
-
|
|
1598
|
+
E = 2, k /= 2, ot /= 2, c /= 2;
|
|
1599
|
+
}
|
|
1600
|
+
function bt(nt, pt) {
|
|
1601
|
+
return E === 1 ? nt[pt] : nt.readUInt16BE(pt * E);
|
|
1602
|
+
}
|
|
1603
|
+
let at;
|
|
1604
|
+
if (b) {
|
|
1605
|
+
let nt = -1;
|
|
1606
|
+
for (at = c; at < k; at++) if (bt(s, at) === bt(h, nt === -1 ? 0 : at - nt)) {
|
|
1607
|
+
if (nt === -1 && (nt = at), at - nt + 1 === ot) return nt * E;
|
|
1608
|
+
} else nt !== -1 && (at -= at - nt), nt = -1;
|
|
1609
|
+
} else for (c + ot > k && (c = k - ot), at = c; at >= 0; at--) {
|
|
1610
|
+
let nt = !0;
|
|
1611
|
+
for (let pt = 0; pt < ot; pt++) if (bt(s, at + pt) !== bt(h, pt)) {
|
|
1612
|
+
nt = !1;
|
|
1613
1613
|
break;
|
|
1614
1614
|
}
|
|
1615
|
-
if (
|
|
1615
|
+
if (nt) return at;
|
|
1616
1616
|
}
|
|
1617
1617
|
return -1;
|
|
1618
1618
|
}
|
|
@@ -1623,42 +1623,42 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1623
1623
|
}, u.prototype.lastIndexOf = function(s, h, c) {
|
|
1624
1624
|
return q(this, s, h, c, !1);
|
|
1625
1625
|
};
|
|
1626
|
-
function Qt(s, h, c,
|
|
1626
|
+
function Qt(s, h, c, y) {
|
|
1627
1627
|
c = Number(c) || 0;
|
|
1628
|
-
const
|
|
1629
|
-
|
|
1628
|
+
const b = s.length - c;
|
|
1629
|
+
y ? (y = Number(y), y > b && (y = b)) : y = b;
|
|
1630
1630
|
const E = h.length;
|
|
1631
|
-
|
|
1631
|
+
y > E / 2 && (y = E / 2);
|
|
1632
1632
|
let k;
|
|
1633
|
-
for (k = 0; k <
|
|
1634
|
-
const
|
|
1635
|
-
if (un(
|
|
1636
|
-
s[c + k] =
|
|
1633
|
+
for (k = 0; k < y; ++k) {
|
|
1634
|
+
const ot = parseInt(h.substr(k * 2, 2), 16);
|
|
1635
|
+
if (un(ot)) return k;
|
|
1636
|
+
s[c + k] = ot;
|
|
1637
1637
|
}
|
|
1638
1638
|
return k;
|
|
1639
1639
|
}
|
|
1640
|
-
function Y(s, h, c,
|
|
1641
|
-
return br(hn(h, s.length - c), s, c,
|
|
1640
|
+
function Y(s, h, c, y) {
|
|
1641
|
+
return br(hn(h, s.length - c), s, c, y);
|
|
1642
1642
|
}
|
|
1643
|
-
function U(s, h, c,
|
|
1644
|
-
return br(
|
|
1643
|
+
function U(s, h, c, y) {
|
|
1644
|
+
return br(ga(h), s, c, y);
|
|
1645
1645
|
}
|
|
1646
|
-
function T(s, h, c,
|
|
1647
|
-
return br(bi(h), s, c,
|
|
1646
|
+
function T(s, h, c, y) {
|
|
1647
|
+
return br(bi(h), s, c, y);
|
|
1648
1648
|
}
|
|
1649
|
-
function A(s, h, c,
|
|
1650
|
-
return br(ba(h, s.length - c), s, c,
|
|
1649
|
+
function A(s, h, c, y) {
|
|
1650
|
+
return br(ba(h, s.length - c), s, c, y);
|
|
1651
1651
|
}
|
|
1652
|
-
u.prototype.write = function(s, h, c,
|
|
1653
|
-
if (h === void 0)
|
|
1654
|
-
else if (c === void 0 && typeof h == "string")
|
|
1655
|
-
else if (isFinite(h)) h = h >>> 0, isFinite(c) ? (c = c >>> 0,
|
|
1652
|
+
u.prototype.write = function(s, h, c, y) {
|
|
1653
|
+
if (h === void 0) y = "utf8", c = this.length, h = 0;
|
|
1654
|
+
else if (c === void 0 && typeof h == "string") y = h, c = this.length, h = 0;
|
|
1655
|
+
else if (isFinite(h)) h = h >>> 0, isFinite(c) ? (c = c >>> 0, y === void 0 && (y = "utf8")) : (y = c, c = void 0);
|
|
1656
1656
|
else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
|
|
1657
|
-
const
|
|
1658
|
-
if ((c === void 0 || c >
|
|
1659
|
-
|
|
1657
|
+
const b = this.length - h;
|
|
1658
|
+
if ((c === void 0 || c > b) && (c = b), s.length > 0 && (c < 0 || h < 0) || h > this.length) throw new RangeError("Attempt to write outside buffer bounds");
|
|
1659
|
+
y || (y = "utf8");
|
|
1660
1660
|
let E = !1;
|
|
1661
|
-
for (; ; ) switch (
|
|
1661
|
+
for (; ; ) switch (y) {
|
|
1662
1662
|
case "hex":
|
|
1663
1663
|
return Qt(this, s, h, c);
|
|
1664
1664
|
case "utf8":
|
|
@@ -1676,8 +1676,8 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1676
1676
|
case "utf-16le":
|
|
1677
1677
|
return A(this, s, h, c);
|
|
1678
1678
|
default:
|
|
1679
|
-
if (E) throw new TypeError("Unknown encoding: " +
|
|
1680
|
-
|
|
1679
|
+
if (E) throw new TypeError("Unknown encoding: " + y);
|
|
1680
|
+
y = ("" + y).toLowerCase(), E = !0;
|
|
1681
1681
|
}
|
|
1682
1682
|
}, u.prototype.toJSON = function() {
|
|
1683
1683
|
return {
|
|
@@ -1690,69 +1690,69 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1690
1690
|
}
|
|
1691
1691
|
function V(s, h, c) {
|
|
1692
1692
|
c = Math.min(s.length, c);
|
|
1693
|
-
const
|
|
1694
|
-
let
|
|
1695
|
-
for (;
|
|
1696
|
-
const E = s[
|
|
1697
|
-
let k = null,
|
|
1698
|
-
if (
|
|
1699
|
-
let bt,
|
|
1700
|
-
switch (
|
|
1693
|
+
const y = [];
|
|
1694
|
+
let b = h;
|
|
1695
|
+
for (; b < c; ) {
|
|
1696
|
+
const E = s[b];
|
|
1697
|
+
let k = null, ot = E > 239 ? 4 : E > 223 ? 3 : E > 191 ? 2 : 1;
|
|
1698
|
+
if (b + ot <= c) {
|
|
1699
|
+
let bt, at, nt, pt;
|
|
1700
|
+
switch (ot) {
|
|
1701
1701
|
case 1:
|
|
1702
1702
|
E < 128 && (k = E);
|
|
1703
1703
|
break;
|
|
1704
1704
|
case 2:
|
|
1705
|
-
bt = s[
|
|
1705
|
+
bt = s[b + 1], (bt & 192) === 128 && (pt = (E & 31) << 6 | bt & 63, pt > 127 && (k = pt));
|
|
1706
1706
|
break;
|
|
1707
1707
|
case 3:
|
|
1708
|
-
bt = s[
|
|
1708
|
+
bt = s[b + 1], at = s[b + 2], (bt & 192) === 128 && (at & 192) === 128 && (pt = (E & 15) << 12 | (bt & 63) << 6 | at & 63, pt > 2047 && (pt < 55296 || pt > 57343) && (k = pt));
|
|
1709
1709
|
break;
|
|
1710
1710
|
case 4:
|
|
1711
|
-
bt = s[
|
|
1711
|
+
bt = s[b + 1], at = s[b + 2], nt = s[b + 3], (bt & 192) === 128 && (at & 192) === 128 && (nt & 192) === 128 && (pt = (E & 15) << 18 | (bt & 63) << 12 | (at & 63) << 6 | nt & 63, pt > 65535 && pt < 1114112 && (k = pt));
|
|
1712
1712
|
}
|
|
1713
1713
|
}
|
|
1714
|
-
k === null ? (k = 65533,
|
|
1714
|
+
k === null ? (k = 65533, ot = 1) : k > 65535 && (k -= 65536, y.push(k >>> 10 & 1023 | 55296), k = 56320 | k & 1023), y.push(k), b += ot;
|
|
1715
1715
|
}
|
|
1716
|
-
return C(
|
|
1716
|
+
return C(y);
|
|
1717
1717
|
}
|
|
1718
1718
|
const $ = 4096;
|
|
1719
1719
|
function C(s) {
|
|
1720
1720
|
const h = s.length;
|
|
1721
1721
|
if (h <= $) return String.fromCharCode.apply(String, s);
|
|
1722
|
-
let c = "",
|
|
1723
|
-
for (;
|
|
1722
|
+
let c = "", y = 0;
|
|
1723
|
+
for (; y < h; ) c += String.fromCharCode.apply(String, s.slice(y, y += $));
|
|
1724
1724
|
return c;
|
|
1725
1725
|
}
|
|
1726
1726
|
function L(s, h, c) {
|
|
1727
|
-
let
|
|
1727
|
+
let y = "";
|
|
1728
1728
|
c = Math.min(s.length, c);
|
|
1729
|
-
for (let
|
|
1730
|
-
return
|
|
1729
|
+
for (let b = h; b < c; ++b) y += String.fromCharCode(s[b] & 127);
|
|
1730
|
+
return y;
|
|
1731
1731
|
}
|
|
1732
|
-
function
|
|
1733
|
-
let
|
|
1732
|
+
function D(s, h, c) {
|
|
1733
|
+
let y = "";
|
|
1734
1734
|
c = Math.min(s.length, c);
|
|
1735
|
-
for (let
|
|
1736
|
-
return
|
|
1735
|
+
for (let b = h; b < c; ++b) y += String.fromCharCode(s[b]);
|
|
1736
|
+
return y;
|
|
1737
1737
|
}
|
|
1738
1738
|
function F(s, h, c) {
|
|
1739
|
-
const
|
|
1740
|
-
(!h || h < 0) && (h = 0), (!c || c < 0 || c >
|
|
1741
|
-
let
|
|
1742
|
-
for (let E = h; E < c; ++E)
|
|
1743
|
-
return
|
|
1739
|
+
const y = s.length;
|
|
1740
|
+
(!h || h < 0) && (h = 0), (!c || c < 0 || c > y) && (c = y);
|
|
1741
|
+
let b = "";
|
|
1742
|
+
for (let E = h; E < c; ++E) b += ma[s[E]];
|
|
1743
|
+
return b;
|
|
1744
1744
|
}
|
|
1745
1745
|
function ct(s, h, c) {
|
|
1746
|
-
const
|
|
1747
|
-
let
|
|
1748
|
-
for (let E = 0; E <
|
|
1749
|
-
return
|
|
1746
|
+
const y = s.slice(h, c);
|
|
1747
|
+
let b = "";
|
|
1748
|
+
for (let E = 0; E < y.length - 1; E += 2) b += String.fromCharCode(y[E] + y[E + 1] * 256);
|
|
1749
|
+
return b;
|
|
1750
1750
|
}
|
|
1751
1751
|
u.prototype.slice = function(s, h) {
|
|
1752
1752
|
const c = this.length;
|
|
1753
1753
|
s = ~~s, h = h === void 0 ? c : ~~h, s < 0 ? (s += c, s < 0 && (s = 0)) : s > c && (s = c), h < 0 ? (h += c, h < 0 && (h = 0)) : h > c && (h = c), h < s && (h = s);
|
|
1754
|
-
const
|
|
1755
|
-
return Object.setPrototypeOf(
|
|
1754
|
+
const y = this.subarray(s, h);
|
|
1755
|
+
return Object.setPrototypeOf(y, u.prototype), y;
|
|
1756
1756
|
};
|
|
1757
1757
|
function W(s, h, c) {
|
|
1758
1758
|
if (s % 1 !== 0 || s < 0) throw new RangeError("offset is not uint");
|
|
@@ -1760,14 +1760,14 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1760
1760
|
}
|
|
1761
1761
|
u.prototype.readUintLE = u.prototype.readUIntLE = function(s, h, c) {
|
|
1762
1762
|
s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
|
|
1763
|
-
let
|
|
1764
|
-
for (; ++E < h && (
|
|
1765
|
-
return
|
|
1763
|
+
let y = this[s], b = 1, E = 0;
|
|
1764
|
+
for (; ++E < h && (b *= 256); ) y += this[s + E] * b;
|
|
1765
|
+
return y;
|
|
1766
1766
|
}, u.prototype.readUintBE = u.prototype.readUIntBE = function(s, h, c) {
|
|
1767
1767
|
s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
|
|
1768
|
-
let
|
|
1769
|
-
for (; h > 0 && (
|
|
1770
|
-
return
|
|
1768
|
+
let y = this[s + --h], b = 1;
|
|
1769
|
+
for (; h > 0 && (b *= 256); ) y += this[s + --h] * b;
|
|
1770
|
+
return y;
|
|
1771
1771
|
}, u.prototype.readUint8 = u.prototype.readUInt8 = function(s, h) {
|
|
1772
1772
|
return s = s >>> 0, h || W(s, 1, this.length), this[s];
|
|
1773
1773
|
}, u.prototype.readUint16LE = u.prototype.readUInt16LE = function(s, h) {
|
|
@@ -1782,24 +1782,24 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1782
1782
|
s = s >>> 0, _e(s, "offset");
|
|
1783
1783
|
const h = this[s], c = this[s + 7];
|
|
1784
1784
|
(h === void 0 || c === void 0) && ze(s, this.length - 8);
|
|
1785
|
-
const
|
|
1786
|
-
return BigInt(
|
|
1785
|
+
const y = h + this[++s] * 2 ** 8 + this[++s] * 2 ** 16 + this[++s] * 2 ** 24, b = this[++s] + this[++s] * 2 ** 8 + this[++s] * 2 ** 16 + c * 2 ** 24;
|
|
1786
|
+
return BigInt(y) + (BigInt(b) << BigInt(32));
|
|
1787
1787
|
}), u.prototype.readBigUInt64BE = ie(function(s) {
|
|
1788
1788
|
s = s >>> 0, _e(s, "offset");
|
|
1789
1789
|
const h = this[s], c = this[s + 7];
|
|
1790
1790
|
(h === void 0 || c === void 0) && ze(s, this.length - 8);
|
|
1791
|
-
const
|
|
1792
|
-
return (BigInt(
|
|
1791
|
+
const y = h * 2 ** 24 + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + this[++s], b = this[++s] * 2 ** 24 + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + c;
|
|
1792
|
+
return (BigInt(y) << BigInt(32)) + BigInt(b);
|
|
1793
1793
|
}), u.prototype.readIntLE = function(s, h, c) {
|
|
1794
1794
|
s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
|
|
1795
|
-
let
|
|
1796
|
-
for (; ++E < h && (
|
|
1797
|
-
return
|
|
1795
|
+
let y = this[s], b = 1, E = 0;
|
|
1796
|
+
for (; ++E < h && (b *= 256); ) y += this[s + E] * b;
|
|
1797
|
+
return b *= 128, y >= b && (y -= Math.pow(2, 8 * h)), y;
|
|
1798
1798
|
}, u.prototype.readIntBE = function(s, h, c) {
|
|
1799
1799
|
s = s >>> 0, h = h >>> 0, c || W(s, h, this.length);
|
|
1800
|
-
let
|
|
1801
|
-
for (;
|
|
1802
|
-
return
|
|
1800
|
+
let y = h, b = 1, E = this[s + --y];
|
|
1801
|
+
for (; y > 0 && (b *= 256); ) E += this[s + --y] * b;
|
|
1802
|
+
return b *= 128, E >= b && (E -= Math.pow(2, 8 * h)), E;
|
|
1803
1803
|
}, u.prototype.readInt8 = function(s, h) {
|
|
1804
1804
|
return s = s >>> 0, h || W(s, 1, this.length), this[s] & 128 ? (255 - this[s] + 1) * -1 : this[s];
|
|
1805
1805
|
}, u.prototype.readInt16LE = function(s, h) {
|
|
@@ -1818,14 +1818,14 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1818
1818
|
s = s >>> 0, _e(s, "offset");
|
|
1819
1819
|
const h = this[s], c = this[s + 7];
|
|
1820
1820
|
(h === void 0 || c === void 0) && ze(s, this.length - 8);
|
|
1821
|
-
const
|
|
1822
|
-
return (BigInt(
|
|
1821
|
+
const y = this[s + 4] + this[s + 5] * 2 ** 8 + this[s + 6] * 2 ** 16 + (c << 24);
|
|
1822
|
+
return (BigInt(y) << BigInt(32)) + BigInt(h + this[++s] * 2 ** 8 + this[++s] * 2 ** 16 + this[++s] * 2 ** 24);
|
|
1823
1823
|
}), u.prototype.readBigInt64BE = ie(function(s) {
|
|
1824
1824
|
s = s >>> 0, _e(s, "offset");
|
|
1825
1825
|
const h = this[s], c = this[s + 7];
|
|
1826
1826
|
(h === void 0 || c === void 0) && ze(s, this.length - 8);
|
|
1827
|
-
const
|
|
1828
|
-
return (BigInt(
|
|
1827
|
+
const y = (h << 24) + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + this[++s];
|
|
1828
|
+
return (BigInt(y) << BigInt(32)) + BigInt(this[++s] * 2 ** 24 + this[++s] * 2 ** 16 + this[++s] * 2 ** 8 + c);
|
|
1829
1829
|
}), u.prototype.readFloatLE = function(s, h) {
|
|
1830
1830
|
return s = s >>> 0, h || W(s, 4, this.length), r.read(this, s, !0, 23, 4);
|
|
1831
1831
|
}, u.prototype.readFloatBE = function(s, h) {
|
|
@@ -1835,26 +1835,26 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1835
1835
|
}, u.prototype.readDoubleBE = function(s, h) {
|
|
1836
1836
|
return s = s >>> 0, h || W(s, 8, this.length), r.read(this, s, !1, 52, 8);
|
|
1837
1837
|
};
|
|
1838
|
-
function K(s, h, c,
|
|
1838
|
+
function K(s, h, c, y, b, E) {
|
|
1839
1839
|
if (!u.isBuffer(s)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1840
|
-
if (h >
|
|
1841
|
-
if (c +
|
|
1840
|
+
if (h > b || h < E) throw new RangeError('"value" argument is out of bounds');
|
|
1841
|
+
if (c + y > s.length) throw new RangeError("Index out of range");
|
|
1842
1842
|
}
|
|
1843
|
-
u.prototype.writeUintLE = u.prototype.writeUIntLE = function(s, h, c,
|
|
1844
|
-
if (s = +s, h = h >>> 0, c = c >>> 0, !
|
|
1843
|
+
u.prototype.writeUintLE = u.prototype.writeUIntLE = function(s, h, c, y) {
|
|
1844
|
+
if (s = +s, h = h >>> 0, c = c >>> 0, !y) {
|
|
1845
1845
|
const k = Math.pow(2, 8 * c) - 1;
|
|
1846
1846
|
K(this, s, h, c, k, 0);
|
|
1847
1847
|
}
|
|
1848
|
-
let
|
|
1849
|
-
for (this[h] = s & 255; ++E < c && (
|
|
1848
|
+
let b = 1, E = 0;
|
|
1849
|
+
for (this[h] = s & 255; ++E < c && (b *= 256); ) this[h + E] = s / b & 255;
|
|
1850
1850
|
return h + c;
|
|
1851
|
-
}, u.prototype.writeUintBE = u.prototype.writeUIntBE = function(s, h, c,
|
|
1852
|
-
if (s = +s, h = h >>> 0, c = c >>> 0, !
|
|
1851
|
+
}, u.prototype.writeUintBE = u.prototype.writeUIntBE = function(s, h, c, y) {
|
|
1852
|
+
if (s = +s, h = h >>> 0, c = c >>> 0, !y) {
|
|
1853
1853
|
const k = Math.pow(2, 8 * c) - 1;
|
|
1854
1854
|
K(this, s, h, c, k, 0);
|
|
1855
1855
|
}
|
|
1856
|
-
let
|
|
1857
|
-
for (this[h +
|
|
1856
|
+
let b = c - 1, E = 1;
|
|
1857
|
+
for (this[h + b] = s & 255; --b >= 0 && (E *= 256); ) this[h + b] = s / E & 255;
|
|
1858
1858
|
return h + c;
|
|
1859
1859
|
}, u.prototype.writeUint8 = u.prototype.writeUInt8 = function(s, h, c) {
|
|
1860
1860
|
return s = +s, h = h >>> 0, c || K(this, s, h, 1, 255, 0), this[h] = s & 255, h + 1;
|
|
@@ -1867,39 +1867,39 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1867
1867
|
}, u.prototype.writeUint32BE = u.prototype.writeUInt32BE = function(s, h, c) {
|
|
1868
1868
|
return s = +s, h = h >>> 0, c || K(this, s, h, 4, 4294967295, 0), this[h] = s >>> 24, this[h + 1] = s >>> 16, this[h + 2] = s >>> 8, this[h + 3] = s & 255, h + 4;
|
|
1869
1869
|
};
|
|
1870
|
-
function
|
|
1871
|
-
|
|
1870
|
+
function it(s, h, c, y, b) {
|
|
1871
|
+
gi(h, y, b, s, c, 7);
|
|
1872
1872
|
let E = Number(h & BigInt(4294967295));
|
|
1873
1873
|
s[c++] = E, E = E >> 8, s[c++] = E, E = E >> 8, s[c++] = E, E = E >> 8, s[c++] = E;
|
|
1874
1874
|
let k = Number(h >> BigInt(32) & BigInt(4294967295));
|
|
1875
1875
|
return s[c++] = k, k = k >> 8, s[c++] = k, k = k >> 8, s[c++] = k, k = k >> 8, s[c++] = k, c;
|
|
1876
1876
|
}
|
|
1877
|
-
function lt(s, h, c,
|
|
1878
|
-
|
|
1877
|
+
function lt(s, h, c, y, b) {
|
|
1878
|
+
gi(h, y, b, s, c, 7);
|
|
1879
1879
|
let E = Number(h & BigInt(4294967295));
|
|
1880
1880
|
s[c + 7] = E, E = E >> 8, s[c + 6] = E, E = E >> 8, s[c + 5] = E, E = E >> 8, s[c + 4] = E;
|
|
1881
1881
|
let k = Number(h >> BigInt(32) & BigInt(4294967295));
|
|
1882
1882
|
return s[c + 3] = k, k = k >> 8, s[c + 2] = k, k = k >> 8, s[c + 1] = k, k = k >> 8, s[c] = k, c + 8;
|
|
1883
1883
|
}
|
|
1884
1884
|
u.prototype.writeBigUInt64LE = ie(function(s, h = 0) {
|
|
1885
|
-
return
|
|
1885
|
+
return it(this, s, h, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1886
1886
|
}), u.prototype.writeBigUInt64BE = ie(function(s, h = 0) {
|
|
1887
1887
|
return lt(this, s, h, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1888
|
-
}), u.prototype.writeIntLE = function(s, h, c,
|
|
1889
|
-
if (s = +s, h = h >>> 0, !
|
|
1890
|
-
const
|
|
1891
|
-
K(this, s, h, c,
|
|
1888
|
+
}), u.prototype.writeIntLE = function(s, h, c, y) {
|
|
1889
|
+
if (s = +s, h = h >>> 0, !y) {
|
|
1890
|
+
const ot = Math.pow(2, 8 * c - 1);
|
|
1891
|
+
K(this, s, h, c, ot - 1, -ot);
|
|
1892
1892
|
}
|
|
1893
|
-
let
|
|
1894
|
-
for (this[h] = s & 255; ++
|
|
1893
|
+
let b = 0, E = 1, k = 0;
|
|
1894
|
+
for (this[h] = s & 255; ++b < c && (E *= 256); ) s < 0 && k === 0 && this[h + b - 1] !== 0 && (k = 1), this[h + b] = (s / E >> 0) - k & 255;
|
|
1895
1895
|
return h + c;
|
|
1896
|
-
}, u.prototype.writeIntBE = function(s, h, c,
|
|
1897
|
-
if (s = +s, h = h >>> 0, !
|
|
1898
|
-
const
|
|
1899
|
-
K(this, s, h, c,
|
|
1896
|
+
}, u.prototype.writeIntBE = function(s, h, c, y) {
|
|
1897
|
+
if (s = +s, h = h >>> 0, !y) {
|
|
1898
|
+
const ot = Math.pow(2, 8 * c - 1);
|
|
1899
|
+
K(this, s, h, c, ot - 1, -ot);
|
|
1900
1900
|
}
|
|
1901
|
-
let
|
|
1902
|
-
for (this[h +
|
|
1901
|
+
let b = c - 1, E = 1, k = 0;
|
|
1902
|
+
for (this[h + b] = s & 255; --b >= 0 && (E *= 256); ) s < 0 && k === 0 && this[h + b + 1] !== 0 && (k = 1), this[h + b] = (s / E >> 0) - k & 255;
|
|
1903
1903
|
return h + c;
|
|
1904
1904
|
}, u.prototype.writeInt8 = function(s, h, c) {
|
|
1905
1905
|
return s = +s, h = h >>> 0, c || K(this, s, h, 1, 127, -128), s < 0 && (s = 255 + s + 1), this[h] = s & 255, h + 1;
|
|
@@ -1912,56 +1912,56 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1912
1912
|
}, u.prototype.writeInt32BE = function(s, h, c) {
|
|
1913
1913
|
return s = +s, h = h >>> 0, c || K(this, s, h, 4, 2147483647, -2147483648), s < 0 && (s = 4294967295 + s + 1), this[h] = s >>> 24, this[h + 1] = s >>> 16, this[h + 2] = s >>> 8, this[h + 3] = s & 255, h + 4;
|
|
1914
1914
|
}, u.prototype.writeBigInt64LE = ie(function(s, h = 0) {
|
|
1915
|
-
return
|
|
1915
|
+
return it(this, s, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1916
1916
|
}), u.prototype.writeBigInt64BE = ie(function(s, h = 0) {
|
|
1917
1917
|
return lt(this, s, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1918
1918
|
});
|
|
1919
|
-
function _t(s, h, c,
|
|
1920
|
-
if (c +
|
|
1919
|
+
function _t(s, h, c, y, b, E) {
|
|
1920
|
+
if (c + y > s.length) throw new RangeError("Index out of range");
|
|
1921
1921
|
if (c < 0) throw new RangeError("Index out of range");
|
|
1922
1922
|
}
|
|
1923
|
-
function
|
|
1924
|
-
return h = +h, c = c >>> 0,
|
|
1923
|
+
function st(s, h, c, y, b) {
|
|
1924
|
+
return h = +h, c = c >>> 0, b || _t(s, h, c, 4), r.write(s, h, c, y, 23, 4), c + 4;
|
|
1925
1925
|
}
|
|
1926
1926
|
u.prototype.writeFloatLE = function(s, h, c) {
|
|
1927
|
-
return
|
|
1927
|
+
return st(this, s, h, !0, c);
|
|
1928
1928
|
}, u.prototype.writeFloatBE = function(s, h, c) {
|
|
1929
|
-
return
|
|
1929
|
+
return st(this, s, h, !1, c);
|
|
1930
1930
|
};
|
|
1931
|
-
function
|
|
1932
|
-
return h = +h, c = c >>> 0,
|
|
1931
|
+
function gt(s, h, c, y, b) {
|
|
1932
|
+
return h = +h, c = c >>> 0, b || _t(s, h, c, 8), r.write(s, h, c, y, 52, 8), c + 8;
|
|
1933
1933
|
}
|
|
1934
1934
|
u.prototype.writeDoubleLE = function(s, h, c) {
|
|
1935
|
-
return
|
|
1935
|
+
return gt(this, s, h, !0, c);
|
|
1936
1936
|
}, u.prototype.writeDoubleBE = function(s, h, c) {
|
|
1937
|
-
return
|
|
1938
|
-
}, u.prototype.copy = function(s, h, c,
|
|
1937
|
+
return gt(this, s, h, !1, c);
|
|
1938
|
+
}, u.prototype.copy = function(s, h, c, y) {
|
|
1939
1939
|
if (!u.isBuffer(s)) throw new TypeError("argument should be a Buffer");
|
|
1940
|
-
if (c || (c = 0), !
|
|
1940
|
+
if (c || (c = 0), !y && y !== 0 && (y = this.length), h >= s.length && (h = s.length), h || (h = 0), y > 0 && y < c && (y = c), y === c || s.length === 0 || this.length === 0) return 0;
|
|
1941
1941
|
if (h < 0) throw new RangeError("targetStart out of bounds");
|
|
1942
1942
|
if (c < 0 || c >= this.length) throw new RangeError("Index out of range");
|
|
1943
|
-
if (
|
|
1944
|
-
|
|
1945
|
-
const
|
|
1946
|
-
return this === s && typeof o.prototype.copyWithin == "function" ? this.copyWithin(h, c,
|
|
1947
|
-
}, u.prototype.fill = function(s, h, c,
|
|
1943
|
+
if (y < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1944
|
+
y > this.length && (y = this.length), s.length - h < y - c && (y = s.length - h + c);
|
|
1945
|
+
const b = y - c;
|
|
1946
|
+
return this === s && typeof o.prototype.copyWithin == "function" ? this.copyWithin(h, c, y) : o.prototype.set.call(s, this.subarray(c, y), h), b;
|
|
1947
|
+
}, u.prototype.fill = function(s, h, c, y) {
|
|
1948
1948
|
if (typeof s == "string") {
|
|
1949
|
-
if (typeof h == "string" ? (
|
|
1950
|
-
if (typeof
|
|
1949
|
+
if (typeof h == "string" ? (y = h, h = 0, c = this.length) : typeof c == "string" && (y = c, c = this.length), y !== void 0 && typeof y != "string") throw new TypeError("encoding must be a string");
|
|
1950
|
+
if (typeof y == "string" && !u.isEncoding(y)) throw new TypeError("Unknown encoding: " + y);
|
|
1951
1951
|
if (s.length === 1) {
|
|
1952
1952
|
const E = s.charCodeAt(0);
|
|
1953
|
-
(
|
|
1953
|
+
(y === "utf8" && E < 128 || y === "latin1") && (s = E);
|
|
1954
1954
|
}
|
|
1955
1955
|
} else typeof s == "number" ? s = s & 255 : typeof s == "boolean" && (s = Number(s));
|
|
1956
1956
|
if (h < 0 || this.length < h || this.length < c) throw new RangeError("Out of range index");
|
|
1957
1957
|
if (c <= h) return this;
|
|
1958
1958
|
h = h >>> 0, c = c === void 0 ? this.length : c >>> 0, s || (s = 0);
|
|
1959
|
-
let
|
|
1960
|
-
if (typeof s == "number") for (
|
|
1959
|
+
let b;
|
|
1960
|
+
if (typeof s == "number") for (b = h; b < c; ++b) this[b] = s;
|
|
1961
1961
|
else {
|
|
1962
|
-
const E = u.isBuffer(s) ? s : u.from(s,
|
|
1962
|
+
const E = u.isBuffer(s) ? s : u.from(s, y), k = E.length;
|
|
1963
1963
|
if (k === 0) throw new TypeError('The value "' + s + '" is invalid for argument "value"');
|
|
1964
|
-
for (
|
|
1964
|
+
for (b = 0; b < c - h; ++b) this[b + h] = E[b % k];
|
|
1965
1965
|
}
|
|
1966
1966
|
return this;
|
|
1967
1967
|
};
|
|
@@ -1978,11 +1978,11 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1978
1978
|
get code() {
|
|
1979
1979
|
return s;
|
|
1980
1980
|
}
|
|
1981
|
-
set code(
|
|
1981
|
+
set code(y) {
|
|
1982
1982
|
Object.defineProperty(this, "code", {
|
|
1983
1983
|
configurable: !0,
|
|
1984
1984
|
enumerable: !0,
|
|
1985
|
-
value:
|
|
1985
|
+
value: y,
|
|
1986
1986
|
writable: !0
|
|
1987
1987
|
});
|
|
1988
1988
|
}
|
|
@@ -1996,25 +1996,25 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
1996
1996
|
}, RangeError), Be("ERR_INVALID_ARG_TYPE", function(s, h) {
|
|
1997
1997
|
return `The "${s}" argument must be of type number. Received type ${typeof h}`;
|
|
1998
1998
|
}, TypeError), Be("ERR_OUT_OF_RANGE", function(s, h, c) {
|
|
1999
|
-
let
|
|
2000
|
-
return Number.isInteger(c) && Math.abs(c) > 2 ** 32 ?
|
|
1999
|
+
let y = `The value of "${s}" is out of range.`, b = c;
|
|
2000
|
+
return Number.isInteger(c) && Math.abs(c) > 2 ** 32 ? b = je(String(c)) : typeof c == "bigint" && (b = String(c), (c > BigInt(2) ** BigInt(32) || c < -(BigInt(2) ** BigInt(32))) && (b = je(b)), b += "n"), y += ` It must be ${h}. Received ${b}`, y;
|
|
2001
2001
|
}, RangeError);
|
|
2002
2002
|
function je(s) {
|
|
2003
2003
|
let h = "", c = s.length;
|
|
2004
|
-
const
|
|
2005
|
-
for (; c >=
|
|
2004
|
+
const y = s[0] === "-" ? 1 : 0;
|
|
2005
|
+
for (; c >= y + 4; c -= 3) h = `_${s.slice(c - 3, c)}${h}`;
|
|
2006
2006
|
return `${s.slice(0, c)}${h}`;
|
|
2007
2007
|
}
|
|
2008
2008
|
function da(s, h, c) {
|
|
2009
2009
|
_e(h, "offset"), (s[h] === void 0 || s[h + c] === void 0) && ze(h, s.length - (c + 1));
|
|
2010
2010
|
}
|
|
2011
|
-
function
|
|
2011
|
+
function gi(s, h, c, y, b, E) {
|
|
2012
2012
|
if (s > c || s < h) {
|
|
2013
2013
|
const k = typeof h == "bigint" ? "n" : "";
|
|
2014
|
-
let
|
|
2015
|
-
throw h === 0 || h === BigInt(0) ?
|
|
2014
|
+
let ot;
|
|
2015
|
+
throw h === 0 || h === BigInt(0) ? ot = `>= 0${k} and < 2${k} ** ${(E + 1) * 8}${k}` : ot = `>= -(2${k} ** ${(E + 1) * 8 - 1}${k}) and < 2 ** ${(E + 1) * 8 - 1}${k}`, new $t.ERR_OUT_OF_RANGE("value", ot, s);
|
|
2016
2016
|
}
|
|
2017
|
-
da(
|
|
2017
|
+
da(y, b, E);
|
|
2018
2018
|
}
|
|
2019
2019
|
function _e(s, h) {
|
|
2020
2020
|
if (typeof s != "number") throw new $t.ERR_INVALID_ARG_TYPE(h, "number", s);
|
|
@@ -2023,7 +2023,7 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
2023
2023
|
throw Math.floor(s) !== s ? (_e(s, c), new $t.ERR_OUT_OF_RANGE("offset", "an integer", s)) : h < 0 ? new $t.ERR_BUFFER_OUT_OF_BOUNDS() : new $t.ERR_OUT_OF_RANGE("offset", `>= 0 and <= ${h}`, s);
|
|
2024
2024
|
}
|
|
2025
2025
|
const wa = /[^+/0-9A-Za-z-_]/g;
|
|
2026
|
-
function
|
|
2026
|
+
function ya(s) {
|
|
2027
2027
|
if (s = s.split("=")[0], s = s.trim().replace(wa, ""), s.length < 2) return "";
|
|
2028
2028
|
for (; s.length % 4 !== 0; ) s = s + "=";
|
|
2029
2029
|
return s;
|
|
@@ -2031,29 +2031,29 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
2031
2031
|
function hn(s, h) {
|
|
2032
2032
|
h = h || 1 / 0;
|
|
2033
2033
|
let c;
|
|
2034
|
-
const
|
|
2035
|
-
let
|
|
2034
|
+
const y = s.length;
|
|
2035
|
+
let b = null;
|
|
2036
2036
|
const E = [];
|
|
2037
|
-
for (let k = 0; k <
|
|
2037
|
+
for (let k = 0; k < y; ++k) {
|
|
2038
2038
|
if (c = s.charCodeAt(k), c > 55295 && c < 57344) {
|
|
2039
|
-
if (!
|
|
2039
|
+
if (!b) {
|
|
2040
2040
|
if (c > 56319) {
|
|
2041
2041
|
(h -= 3) > -1 && E.push(239, 191, 189);
|
|
2042
2042
|
continue;
|
|
2043
|
-
} else if (k + 1 ===
|
|
2043
|
+
} else if (k + 1 === y) {
|
|
2044
2044
|
(h -= 3) > -1 && E.push(239, 191, 189);
|
|
2045
2045
|
continue;
|
|
2046
2046
|
}
|
|
2047
|
-
|
|
2047
|
+
b = c;
|
|
2048
2048
|
continue;
|
|
2049
2049
|
}
|
|
2050
2050
|
if (c < 56320) {
|
|
2051
|
-
(h -= 3) > -1 && E.push(239, 191, 189),
|
|
2051
|
+
(h -= 3) > -1 && E.push(239, 191, 189), b = c;
|
|
2052
2052
|
continue;
|
|
2053
2053
|
}
|
|
2054
|
-
c = (
|
|
2055
|
-
} else
|
|
2056
|
-
if (
|
|
2054
|
+
c = (b - 55296 << 10 | c - 56320) + 65536;
|
|
2055
|
+
} else b && (h -= 3) > -1 && E.push(239, 191, 189);
|
|
2056
|
+
if (b = null, c < 128) {
|
|
2057
2057
|
if ((h -= 1) < 0) break;
|
|
2058
2058
|
E.push(c);
|
|
2059
2059
|
} else if (c < 2048) {
|
|
@@ -2069,24 +2069,24 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
2069
2069
|
}
|
|
2070
2070
|
return E;
|
|
2071
2071
|
}
|
|
2072
|
-
function
|
|
2072
|
+
function ga(s) {
|
|
2073
2073
|
const h = [];
|
|
2074
2074
|
for (let c = 0; c < s.length; ++c) h.push(s.charCodeAt(c) & 255);
|
|
2075
2075
|
return h;
|
|
2076
2076
|
}
|
|
2077
2077
|
function ba(s, h) {
|
|
2078
|
-
let c,
|
|
2078
|
+
let c, y, b;
|
|
2079
2079
|
const E = [];
|
|
2080
|
-
for (let k = 0; k < s.length && !((h -= 2) < 0); ++k) c = s.charCodeAt(k),
|
|
2080
|
+
for (let k = 0; k < s.length && !((h -= 2) < 0); ++k) c = s.charCodeAt(k), y = c >> 8, b = c % 256, E.push(b), E.push(y);
|
|
2081
2081
|
return E;
|
|
2082
2082
|
}
|
|
2083
2083
|
function bi(s) {
|
|
2084
|
-
return t.toByteArray(
|
|
2084
|
+
return t.toByteArray(ya(s));
|
|
2085
2085
|
}
|
|
2086
|
-
function br(s, h, c,
|
|
2087
|
-
let
|
|
2088
|
-
for (
|
|
2089
|
-
return
|
|
2086
|
+
function br(s, h, c, y) {
|
|
2087
|
+
let b;
|
|
2088
|
+
for (b = 0; b < y && !(b + c >= h.length || b >= s.length); ++b) h[b + c] = s[b];
|
|
2089
|
+
return b;
|
|
2090
2090
|
}
|
|
2091
2091
|
function Ft(s, h) {
|
|
2092
2092
|
return s instanceof h || s != null && s.constructor != null && s.constructor.name != null && s.constructor.name === h.name;
|
|
@@ -2097,8 +2097,8 @@ qn.write = function(e, t, r, n, i, o) {
|
|
|
2097
2097
|
const ma = (function() {
|
|
2098
2098
|
const s = "0123456789abcdef", h = new Array(256);
|
|
2099
2099
|
for (let c = 0; c < 16; ++c) {
|
|
2100
|
-
const
|
|
2101
|
-
for (let
|
|
2100
|
+
const y = c * 16;
|
|
2101
|
+
for (let b = 0; b < 16; ++b) h[y + b] = s[c] + s[b];
|
|
2102
2102
|
}
|
|
2103
2103
|
return h;
|
|
2104
2104
|
})();
|
|
@@ -2236,11 +2236,11 @@ var wh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2236
2236
|
encode: dh,
|
|
2237
2237
|
isDefinedHashType: Qr
|
|
2238
2238
|
}, Symbol.toStringTag, { value: "Module" })), Vs = j.OP_RESERVED;
|
|
2239
|
-
function
|
|
2239
|
+
function yh(e) {
|
|
2240
2240
|
return oh(e) && (e === j.OP_0 || e >= j.OP_1 && e <= j.OP_16 || e === j.OP_1NEGATE);
|
|
2241
2241
|
}
|
|
2242
2242
|
function $s(e) {
|
|
2243
|
-
return e instanceof Uint8Array ? !0 :
|
|
2243
|
+
return e instanceof Uint8Array ? !0 : yh(e);
|
|
2244
2244
|
}
|
|
2245
2245
|
function Jr(e) {
|
|
2246
2246
|
return Yn(e) && e.every($s);
|
|
@@ -2258,13 +2258,13 @@ function Rr(e) {
|
|
|
2258
2258
|
function Zn(e) {
|
|
2259
2259
|
return e instanceof Uint8Array;
|
|
2260
2260
|
}
|
|
2261
|
-
function
|
|
2261
|
+
function gh(e) {
|
|
2262
2262
|
return Yn(e);
|
|
2263
2263
|
}
|
|
2264
2264
|
function Nr(e) {
|
|
2265
2265
|
return e instanceof Uint8Array;
|
|
2266
2266
|
}
|
|
2267
|
-
function
|
|
2267
|
+
function yt(e) {
|
|
2268
2268
|
if (Zn(e)) return e;
|
|
2269
2269
|
if (!Yn(e)) throw new TypeError("Expected an array");
|
|
2270
2270
|
const t = e.reduce((i, o) => Nr(o) ? o.length === 1 && Rr(o) !== void 0 ? i + 1 : i + Bs(o.length) + o.length : i + 1, 0), r = new Uint8Array(t);
|
|
@@ -2281,8 +2281,8 @@ function gt(e) {
|
|
|
2281
2281
|
}), n !== r.length) throw new Error("Could not decode chunks");
|
|
2282
2282
|
return r;
|
|
2283
2283
|
}
|
|
2284
|
-
function
|
|
2285
|
-
if (
|
|
2284
|
+
function rt(e) {
|
|
2285
|
+
if (gh(e)) return e;
|
|
2286
2286
|
if (!(e instanceof Uint8Array)) throw new TypeError("Expected a Uint8Array");
|
|
2287
2287
|
const t = [];
|
|
2288
2288
|
let r = 0;
|
|
@@ -2302,7 +2302,7 @@ function et(e) {
|
|
|
2302
2302
|
function Ks(e) {
|
|
2303
2303
|
let t;
|
|
2304
2304
|
if (Zn(e)) {
|
|
2305
|
-
const r =
|
|
2305
|
+
const r = rt(e);
|
|
2306
2306
|
if (!r) throw new Error("Could not convert invalid chunks to ASM");
|
|
2307
2307
|
t = r;
|
|
2308
2308
|
} else t = e;
|
|
@@ -2317,14 +2317,14 @@ function Ks(e) {
|
|
|
2317
2317
|
}
|
|
2318
2318
|
function bh(e) {
|
|
2319
2319
|
if (typeof e != "string") throw new TypeError("Expected a string");
|
|
2320
|
-
return
|
|
2320
|
+
return yt(e.split(" ").map((t) => {
|
|
2321
2321
|
if (j[t] !== void 0) return j[t];
|
|
2322
2322
|
if (!hh(t)) throw new TypeError("Expected hex string");
|
|
2323
2323
|
return Mt(t);
|
|
2324
2324
|
}));
|
|
2325
2325
|
}
|
|
2326
2326
|
function Ds(e) {
|
|
2327
|
-
const t = Zn(e) ?
|
|
2327
|
+
const t = Zn(e) ? rt(e) : e;
|
|
2328
2328
|
if (!t || !Jr(t)) throw new TypeError("Expected push-only script");
|
|
2329
2329
|
return t.map((r) => Nr(r) ? r : r === j.OP_0 ? Et(0) : Ns(r - Vs));
|
|
2330
2330
|
}
|
|
@@ -2336,9 +2336,9 @@ function xe(e) {
|
|
|
2336
2336
|
}
|
|
2337
2337
|
var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2338
2338
|
__proto__: null,
|
|
2339
|
-
compile:
|
|
2339
|
+
compile: yt,
|
|
2340
2340
|
countNonPushOnlyOPs: Xn,
|
|
2341
|
-
decompile:
|
|
2341
|
+
decompile: rt,
|
|
2342
2342
|
fromASM: bh,
|
|
2343
2343
|
isCanonicalPubKey: Ms,
|
|
2344
2344
|
isCanonicalScriptSignature: xe,
|
|
@@ -2378,8 +2378,8 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
2378
2378
|
#l = !1;
|
|
2379
2379
|
#d = !1;
|
|
2380
2380
|
#w = !1;
|
|
2381
|
-
#
|
|
2382
|
-
#
|
|
2381
|
+
#y = !1;
|
|
2382
|
+
#g;
|
|
2383
2383
|
#m = !1;
|
|
2384
2384
|
constructor(t, r) {
|
|
2385
2385
|
this.#t = t.network ?? kt, this.#a = {
|
|
@@ -2406,7 +2406,7 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
2406
2406
|
return this.#w || (this.#u = this.#A(), this.#w = !0), this.#u;
|
|
2407
2407
|
}
|
|
2408
2408
|
get output() {
|
|
2409
|
-
return this.#
|
|
2409
|
+
return this.#y || (this.#c = this.#T(), this.#y = !0), this.#c;
|
|
2410
2410
|
}
|
|
2411
2411
|
static fromProgram(t, r) {
|
|
2412
2412
|
return new Qe({
|
|
@@ -2448,7 +2448,7 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
2448
2448
|
if (!this.#m) {
|
|
2449
2449
|
if (this.#e) {
|
|
2450
2450
|
const t = cr(this.#e);
|
|
2451
|
-
t && (this.#
|
|
2451
|
+
t && (this.#g = {
|
|
2452
2452
|
version: t.version,
|
|
2453
2453
|
prefix: t.prefix,
|
|
2454
2454
|
data: t.data
|
|
@@ -2456,7 +2456,7 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
2456
2456
|
}
|
|
2457
2457
|
this.#m = !0;
|
|
2458
2458
|
}
|
|
2459
|
-
return this.#
|
|
2459
|
+
return this.#g;
|
|
2460
2460
|
}
|
|
2461
2461
|
#v() {
|
|
2462
2462
|
if (typeof this.#r < "u" && typeof this.#n < "u") {
|
|
@@ -2470,8 +2470,8 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
2470
2470
|
const t = this.program;
|
|
2471
2471
|
if (!t) return;
|
|
2472
2472
|
if (!this.#t.bech32Opnet) throw new TypeError("Network does not support opnet");
|
|
2473
|
-
const r =
|
|
2474
|
-
return r.unshift(Pi),
|
|
2473
|
+
const r = et.bech32m.toWords(t);
|
|
2474
|
+
return r.unshift(Pi), et.bech32m.encode(this.#t.bech32Opnet, r);
|
|
2475
2475
|
}
|
|
2476
2476
|
#b() {
|
|
2477
2477
|
if (this.#s) return this.#s;
|
|
@@ -2501,7 +2501,7 @@ var mh = sh, Ae = wh, Eh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
2501
2501
|
#T() {
|
|
2502
2502
|
if (this.#i) return this.#i;
|
|
2503
2503
|
const t = this.program;
|
|
2504
|
-
if (t) return
|
|
2504
|
+
if (t) return yt([Oi.OP_16, t]);
|
|
2505
2505
|
}
|
|
2506
2506
|
#k() {
|
|
2507
2507
|
let t = Et(0);
|
|
@@ -2744,13 +2744,13 @@ var Er = /* @__PURE__ */ new Uint32Array(16), Ph = class extends Wn {
|
|
|
2744
2744
|
for (let w = 0; w < 16; w++, t += 4) Er[w] = e.getUint32(t, !0);
|
|
2745
2745
|
let r = this.h0 | 0, n = r, i = this.h1 | 0, o = i, a = this.h2 | 0, f = a, l = this.h3 | 0, p = l, u = this.h4 | 0, d = u;
|
|
2746
2746
|
for (let w = 0; w < 5; w++) {
|
|
2747
|
-
const
|
|
2747
|
+
const g = 4 - w, m = Uh[w], v = Oh[w], I = js[w], P = zs[w], S = Th[w], _ = kh[w];
|
|
2748
2748
|
for (let O = 0; O < 16; O++) {
|
|
2749
2749
|
const z = Ee(r + _i(w, i, a, l) + Er[I[O]] + m, S[O]) + u | 0;
|
|
2750
2750
|
r = u, u = l, l = Ee(a, 10) | 0, a = i, i = z;
|
|
2751
2751
|
}
|
|
2752
2752
|
for (let O = 0; O < 16; O++) {
|
|
2753
|
-
const z = Ee(n + _i(
|
|
2753
|
+
const z = Ee(n + _i(g, o, f, p) + Er[P[O]] + v, _[O]) + d | 0;
|
|
2754
2754
|
n = d, d = p, p = Ee(f, 10) | 0, f = o, o = z;
|
|
2755
2755
|
}
|
|
2756
2756
|
}
|
|
@@ -3518,11 +3518,11 @@ var Rh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3518
3518
|
add(t) {
|
|
3519
3519
|
const { X: r, Y: n, Z: i } = this, { X: o, Y: a, Z: f } = pn(t), l = 0n, p = Qs;
|
|
3520
3520
|
let u = 0n, d = 0n, w = 0n;
|
|
3521
|
-
const
|
|
3521
|
+
const g = N(p * 3n);
|
|
3522
3522
|
let m = N(r * o), v = N(n * a), I = N(i * f), P = N(r + n), S = N(o + a);
|
|
3523
3523
|
P = N(P * S), S = N(m + v), P = N(P - S), S = N(r + i);
|
|
3524
3524
|
let _ = N(o + f);
|
|
3525
|
-
return S = N(S * _), _ = N(m + I), S = N(S - _), _ = N(n + i), u = N(a + f), _ = N(_ * u), u = N(v + I), _ = N(_ - u), w = N(l * S), u = N(
|
|
3525
|
+
return S = N(S * _), _ = N(m + I), S = N(S - _), _ = N(n + i), u = N(a + f), _ = N(_ * u), u = N(v + I), _ = N(_ - u), w = N(l * S), u = N(g * I), w = N(u + w), u = N(v - w), w = N(v + w), d = N(u * w), v = N(m + m), v = N(v + m), I = N(l * I), S = N(g * S), v = N(v + I), I = N(m - I), I = N(l * I), S = N(S + I), m = N(v * S), d = N(d + m), m = N(_ * S), u = N(P * u), u = N(u - m), m = N(P * v), w = N(_ * w), w = N(w + m), new be(u, d, w);
|
|
3526
3526
|
}
|
|
3527
3527
|
subtract(t) {
|
|
3528
3528
|
return this.add(pn(t).negate());
|
|
@@ -3587,8 +3587,8 @@ var jh = (e) => Hr("0x" + (ro(e) || "0")), Ci = (e, t, r) => jh(e.subarray(t, r)
|
|
|
3587
3587
|
for (let l = 0; l < oo; l++) {
|
|
3588
3588
|
let p = Number(e & a);
|
|
3589
3589
|
e >>= f, p > xn && (p -= o, e += 1n);
|
|
3590
|
-
const u = l * xn, d = u, w = u + Math.abs(p) - 1,
|
|
3591
|
-
p === 0 ? n = n.add(Ki(
|
|
3590
|
+
const u = l * xn, d = u, w = u + Math.abs(p) - 1, g = l % 2 !== 0, m = p < 0;
|
|
3591
|
+
p === 0 ? n = n.add(Ki(g, t[d])) : r = r.add(Ki(m, t[w]));
|
|
3592
3592
|
}
|
|
3593
3593
|
return e !== 0n && xt("invalid wnaf"), {
|
|
3594
3594
|
p: r,
|
|
@@ -3647,8 +3647,8 @@ var he = j, ao = class Je {
|
|
|
3647
3647
|
#l;
|
|
3648
3648
|
#d;
|
|
3649
3649
|
#w;
|
|
3650
|
-
#
|
|
3651
|
-
#
|
|
3650
|
+
#y;
|
|
3651
|
+
#g = !1;
|
|
3652
3652
|
#m = !1;
|
|
3653
3653
|
#E = !1;
|
|
3654
3654
|
#v = !1;
|
|
@@ -3672,7 +3672,7 @@ var he = j, ao = class Je {
|
|
|
3672
3672
|
return this.#t;
|
|
3673
3673
|
}
|
|
3674
3674
|
get address() {
|
|
3675
|
-
return this.#
|
|
3675
|
+
return this.#g || (this.#u = this.#x(), this.#g = !0), this.#u;
|
|
3676
3676
|
}
|
|
3677
3677
|
get hash() {
|
|
3678
3678
|
return this.#m || (this.#c = this.#B(), this.#m = !0), this.#c;
|
|
@@ -3690,7 +3690,7 @@ var he = j, ao = class Je {
|
|
|
3690
3690
|
return this.#b || (this.#w = this.#H(), this.#b = !0), this.#w;
|
|
3691
3691
|
}
|
|
3692
3692
|
get witness() {
|
|
3693
|
-
return this.#S || (this.#
|
|
3693
|
+
return this.#S || (this.#y = this.#L(), this.#S = !0), this.#y;
|
|
3694
3694
|
}
|
|
3695
3695
|
static fromPubkey(t, r) {
|
|
3696
3696
|
return new Je({
|
|
@@ -3743,7 +3743,7 @@ var he = j, ao = class Je {
|
|
|
3743
3743
|
return this.#A;
|
|
3744
3744
|
}
|
|
3745
3745
|
#O() {
|
|
3746
|
-
return this.#P || (this.#o && (this.#k =
|
|
3746
|
+
return this.#P || (this.#o && (this.#k = rt(this.#o) ?? void 0), this.#P = !0), this.#k;
|
|
3747
3747
|
}
|
|
3748
3748
|
#x() {
|
|
3749
3749
|
if (this.#e) return this.#e;
|
|
@@ -3776,7 +3776,7 @@ var he = j, ao = class Je {
|
|
|
3776
3776
|
#N() {
|
|
3777
3777
|
if (this.#i) return this.#i;
|
|
3778
3778
|
const t = this.hash;
|
|
3779
|
-
if (t) return
|
|
3779
|
+
if (t) return yt([
|
|
3780
3780
|
he.OP_DUP,
|
|
3781
3781
|
he.OP_HASH160,
|
|
3782
3782
|
t,
|
|
@@ -3792,13 +3792,13 @@ var he = j, ao = class Je {
|
|
|
3792
3792
|
const r = Bn(this.#r);
|
|
3793
3793
|
r && (this.#f ? t = r.uncompressed : t = r.hybrid);
|
|
3794
3794
|
}
|
|
3795
|
-
return
|
|
3795
|
+
return yt([this.#n, t]);
|
|
3796
3796
|
}
|
|
3797
3797
|
#L() {
|
|
3798
3798
|
if (this.input) return [];
|
|
3799
3799
|
}
|
|
3800
3800
|
#C() {
|
|
3801
|
-
let t = new Uint8Array(0);
|
|
3801
|
+
let t = /* @__PURE__ */ new Uint8Array(0);
|
|
3802
3802
|
if (this.#e) {
|
|
3803
3803
|
const r = this.#U();
|
|
3804
3804
|
if (!r) throw new TypeError("Invalid address");
|
|
@@ -3878,8 +3878,8 @@ var Ye = j, ho = class tr {
|
|
|
3878
3878
|
#l;
|
|
3879
3879
|
#d = !1;
|
|
3880
3880
|
#w = !1;
|
|
3881
|
-
#g = !1;
|
|
3882
3881
|
#y = !1;
|
|
3882
|
+
#g = !1;
|
|
3883
3883
|
#m = !1;
|
|
3884
3884
|
#E = !1;
|
|
3885
3885
|
#v;
|
|
@@ -3909,10 +3909,10 @@ var Ye = j, ho = class tr {
|
|
|
3909
3909
|
return this.#w || (this.#f = this.#x(), this.#w = !0), this.#f;
|
|
3910
3910
|
}
|
|
3911
3911
|
get output() {
|
|
3912
|
-
return this.#
|
|
3912
|
+
return this.#y || (this.#u = this.#B(), this.#y = !0), this.#u;
|
|
3913
3913
|
}
|
|
3914
3914
|
get input() {
|
|
3915
|
-
return this.#
|
|
3915
|
+
return this.#g || (this.#c = this.#_(), this.#g = !0), this.#c;
|
|
3916
3916
|
}
|
|
3917
3917
|
get redeem() {
|
|
3918
3918
|
return this.#m || (this.#p = this.#R(), this.#m = !0), this.#p;
|
|
@@ -3970,7 +3970,7 @@ var Ye = j, ho = class tr {
|
|
|
3970
3970
|
return this.#v;
|
|
3971
3971
|
}
|
|
3972
3972
|
#P() {
|
|
3973
|
-
return this.#S || (this.#n && (this.#b =
|
|
3973
|
+
return this.#S || (this.#n && (this.#b = rt(this.#n) ?? void 0), this.#S = !0), this.#b;
|
|
3974
3974
|
}
|
|
3975
3975
|
#U() {
|
|
3976
3976
|
if (!this.#T) {
|
|
@@ -3979,8 +3979,8 @@ var Ye = j, ho = class tr {
|
|
|
3979
3979
|
const r = t[t.length - 1];
|
|
3980
3980
|
this.#A = {
|
|
3981
3981
|
network: this.#t,
|
|
3982
|
-
output: r === Ye.OP_FALSE ? new Uint8Array(0) : r,
|
|
3983
|
-
input:
|
|
3982
|
+
output: r === Ye.OP_FALSE ? /* @__PURE__ */ new Uint8Array(0) : r,
|
|
3983
|
+
input: yt(t.slice(0, -1)),
|
|
3984
3984
|
witness: this.#o || []
|
|
3985
3985
|
};
|
|
3986
3986
|
}
|
|
@@ -4005,7 +4005,7 @@ var Ye = j, ho = class tr {
|
|
|
4005
4005
|
#B() {
|
|
4006
4006
|
if (this.#r) return this.#r;
|
|
4007
4007
|
const t = this.hash;
|
|
4008
|
-
if (t) return
|
|
4008
|
+
if (t) return yt([
|
|
4009
4009
|
Ye.OP_HASH160,
|
|
4010
4010
|
t,
|
|
4011
4011
|
Ye.OP_EQUAL
|
|
@@ -4014,7 +4014,7 @@ var Ye = j, ho = class tr {
|
|
|
4014
4014
|
#_() {
|
|
4015
4015
|
if (this.#n) return this.#n;
|
|
4016
4016
|
const t = this.#i;
|
|
4017
|
-
if (!(!t || !t.input || !t.output)) return
|
|
4017
|
+
if (!(!t || !t.input || !t.output)) return yt([].concat(rt(t.input), t.output));
|
|
4018
4018
|
}
|
|
4019
4019
|
#R() {
|
|
4020
4020
|
if (this.#i) return this.#i;
|
|
@@ -4028,7 +4028,7 @@ var Ye = j, ho = class tr {
|
|
|
4028
4028
|
}
|
|
4029
4029
|
#H(t) {
|
|
4030
4030
|
if (t.output) {
|
|
4031
|
-
const r =
|
|
4031
|
+
const r = rt(t.output);
|
|
4032
4032
|
if (!r || r.length < 1) throw new TypeError("Redeem.output too short");
|
|
4033
4033
|
if (t.output.byteLength > 520) throw new TypeError("Redeem.output unspendable if larger than 520 bytes");
|
|
4034
4034
|
if (Xn(r) > 201) throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
|
|
@@ -4037,12 +4037,12 @@ var Ye = j, ho = class tr {
|
|
|
4037
4037
|
const r = t.input.length > 0, n = t.witness && t.witness.length > 0;
|
|
4038
4038
|
if (!r && !n) throw new TypeError("Empty input");
|
|
4039
4039
|
if (r && n) throw new TypeError("Input and witness provided");
|
|
4040
|
-
if (r && !Jr(
|
|
4040
|
+
if (r && !Jr(rt(t.input)))
|
|
4041
4041
|
throw new TypeError("Non push-only scriptSig");
|
|
4042
4042
|
}
|
|
4043
4043
|
}
|
|
4044
4044
|
#L() {
|
|
4045
|
-
let t = new Uint8Array(0);
|
|
4045
|
+
let t = /* @__PURE__ */ new Uint8Array(0);
|
|
4046
4046
|
if (this.#e) {
|
|
4047
4047
|
const r = this.#k();
|
|
4048
4048
|
if (!r) throw new TypeError("Invalid address");
|
|
@@ -4388,13 +4388,13 @@ var nu = class {
|
|
|
4388
4388
|
process(e, t) {
|
|
4389
4389
|
for (let u = 0; u < 16; u++, t += 4) fe[u] = e.getUint32(t, !1);
|
|
4390
4390
|
for (let u = 16; u < 64; u++) {
|
|
4391
|
-
const d = fe[u - 15], w = fe[u - 2],
|
|
4392
|
-
fe[u] =
|
|
4391
|
+
const d = fe[u - 15], w = fe[u - 2], g = Gt(d, 7) ^ Gt(d, 18) ^ d >>> 3, m = Gt(w, 17) ^ Gt(w, 19) ^ w >>> 10;
|
|
4392
|
+
fe[u] = m + fe[u - 7] + g + fe[u - 16] | 0;
|
|
4393
4393
|
}
|
|
4394
4394
|
let { A: r, B: n, C: i, D: o, E: a, F: f, G: l, H: p } = this;
|
|
4395
4395
|
for (let u = 0; u < 64; u++) {
|
|
4396
|
-
const d = Gt(a, 6) ^ Gt(a, 11) ^ Gt(a, 25), w = p + d + eu(a, f, l) + iu[u] + fe[u] | 0,
|
|
4397
|
-
p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w +
|
|
4396
|
+
const d = Gt(a, 6) ^ Gt(a, 11) ^ Gt(a, 25), w = p + d + eu(a, f, l) + iu[u] + fe[u] | 0, g = (Gt(r, 2) ^ Gt(r, 13) ^ Gt(r, 22)) + ru(r, n, i) | 0;
|
|
4397
|
+
p = l, l = f, f = a, a = o + w | 0, o = i, i = n, n = r, r = w + g | 0;
|
|
4398
4398
|
}
|
|
4399
4399
|
r = r + this.A | 0, n = n + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, p = p + this.H | 0, this.set(r, n, i, o, a, f, l, p);
|
|
4400
4400
|
}
|
|
@@ -4419,7 +4419,7 @@ var nu = class {
|
|
|
4419
4419
|
}, au = /* @__PURE__ */ Jh(() => new ou(), /* @__PURE__ */ tu(1));
|
|
4420
4420
|
function hu(e) {
|
|
4421
4421
|
if (e.length >= 255) throw new TypeError("Alphabet too long");
|
|
4422
|
-
const t = new Uint8Array(256);
|
|
4422
|
+
const t = /* @__PURE__ */ new Uint8Array(256);
|
|
4423
4423
|
for (let p = 0; p < t.length; p++) t[p] = 255;
|
|
4424
4424
|
for (let p = 0; p < e.length; p++) {
|
|
4425
4425
|
const u = e.charAt(p), d = u.charCodeAt(0);
|
|
@@ -4431,10 +4431,10 @@ function hu(e) {
|
|
|
4431
4431
|
if (p instanceof Uint8Array || (ArrayBuffer.isView(p) ? p = new Uint8Array(p.buffer, p.byteOffset, p.byteLength) : Array.isArray(p) && (p = Uint8Array.from(p))), !(p instanceof Uint8Array)) throw new TypeError("Expected Uint8Array");
|
|
4432
4432
|
if (p.length === 0) return "";
|
|
4433
4433
|
let u = 0, d = 0, w = 0;
|
|
4434
|
-
const
|
|
4435
|
-
for (; w !==
|
|
4436
|
-
const m = (
|
|
4437
|
-
for (; w !==
|
|
4434
|
+
const g = p.length;
|
|
4435
|
+
for (; w !== g && p[w] === 0; ) w++, u++;
|
|
4436
|
+
const m = (g - w) * o + 1 >>> 0, v = new Uint8Array(m);
|
|
4437
|
+
for (; w !== g; ) {
|
|
4438
4438
|
let S = p[w], _ = 0;
|
|
4439
4439
|
for (let O = m - 1; (S !== 0 || _ < d) && O !== -1; O--, _++) S += 256 * v[O] >>> 0, v[O] = S % r >>> 0, S = S / r >>> 0;
|
|
4440
4440
|
if (S !== 0) throw new Error("Non-zero carry");
|
|
@@ -4448,25 +4448,25 @@ function hu(e) {
|
|
|
4448
4448
|
}
|
|
4449
4449
|
function f(p) {
|
|
4450
4450
|
if (typeof p != "string") throw new TypeError("Expected String");
|
|
4451
|
-
if (p.length === 0) return new Uint8Array();
|
|
4451
|
+
if (p.length === 0) return /* @__PURE__ */ new Uint8Array();
|
|
4452
4452
|
let u = 0, d = 0, w = 0;
|
|
4453
4453
|
for (; p[u] === n; ) d++, u++;
|
|
4454
|
-
const
|
|
4454
|
+
const g = (p.length - u) * i + 1 >>> 0, m = new Uint8Array(g);
|
|
4455
4455
|
for (; u < p.length; ) {
|
|
4456
4456
|
const S = p.charCodeAt(u);
|
|
4457
4457
|
if (S > 255) return;
|
|
4458
4458
|
let _ = t[S];
|
|
4459
4459
|
if (_ === 255) return;
|
|
4460
4460
|
let O = 0;
|
|
4461
|
-
for (let z =
|
|
4461
|
+
for (let z = g - 1; (_ !== 0 || O < w) && z !== -1; z--, O++) _ += r * m[z] >>> 0, m[z] = _ % 256 >>> 0, _ = _ / 256 >>> 0;
|
|
4462
4462
|
if (_ !== 0) throw new Error("Non-zero carry");
|
|
4463
4463
|
w = O, u++;
|
|
4464
4464
|
}
|
|
4465
|
-
let v =
|
|
4466
|
-
for (; v !==
|
|
4467
|
-
const I = new Uint8Array(d + (
|
|
4465
|
+
let v = g - w;
|
|
4466
|
+
for (; v !== g && m[v] === 0; ) v++;
|
|
4467
|
+
const I = new Uint8Array(d + (g - v));
|
|
4468
4468
|
let P = d;
|
|
4469
|
-
for (; v !==
|
|
4469
|
+
for (; v !== g; ) I[P++] = m[v++];
|
|
4470
4470
|
return I;
|
|
4471
4471
|
}
|
|
4472
4472
|
function l(p) {
|
|
@@ -4515,7 +4515,7 @@ function ri(e, t) {
|
|
|
4515
4515
|
if (r.length !== t) throw new Error("number too large");
|
|
4516
4516
|
return r;
|
|
4517
4517
|
}
|
|
4518
|
-
function
|
|
4518
|
+
function yo(e, t) {
|
|
4519
4519
|
return ri(e, t).reverse();
|
|
4520
4520
|
}
|
|
4521
4521
|
function uu(e) {
|
|
@@ -4540,7 +4540,7 @@ function pu(e, t, r) {
|
|
|
4540
4540
|
let l = n(e), p = n(e), u = 0;
|
|
4541
4541
|
const d = () => {
|
|
4542
4542
|
l.fill(1), p.fill(0), u = 0;
|
|
4543
|
-
}, w = (...v) => r(p, we(l, ...v)),
|
|
4543
|
+
}, w = (...v) => r(p, we(l, ...v)), g = (v = i) => {
|
|
4544
4544
|
p = w(o, v), l = w(), v.length !== 0 && (p = w(a, v), l = w());
|
|
4545
4545
|
}, m = () => {
|
|
4546
4546
|
if (u++ >= f) throw new Error("drbg: tried max amount of iterations");
|
|
@@ -4554,9 +4554,9 @@ function pu(e, t, r) {
|
|
|
4554
4554
|
return we(...I);
|
|
4555
4555
|
};
|
|
4556
4556
|
return (v, I) => {
|
|
4557
|
-
d(),
|
|
4557
|
+
d(), g(v);
|
|
4558
4558
|
let P;
|
|
4559
|
-
for (; !(P = I(m())); )
|
|
4559
|
+
for (; !(P = I(m())); ) g();
|
|
4560
4560
|
return d(), P;
|
|
4561
4561
|
};
|
|
4562
4562
|
}
|
|
@@ -4580,7 +4580,7 @@ function Wi(e) {
|
|
|
4580
4580
|
return t.set(r, o), o;
|
|
4581
4581
|
};
|
|
4582
4582
|
}
|
|
4583
|
-
var Ot = /* @__PURE__ */ BigInt(0), Tt = /* @__PURE__ */ BigInt(1), ve = /* @__PURE__ */ BigInt(2),
|
|
4583
|
+
var Ot = /* @__PURE__ */ BigInt(0), Tt = /* @__PURE__ */ BigInt(1), ve = /* @__PURE__ */ BigInt(2), go = /* @__PURE__ */ BigInt(3), bo = /* @__PURE__ */ BigInt(4), mo = /* @__PURE__ */ BigInt(5), du = /* @__PURE__ */ BigInt(7), Eo = /* @__PURE__ */ BigInt(8), wu = /* @__PURE__ */ BigInt(9), vo = /* @__PURE__ */ BigInt(16);
|
|
4584
4584
|
function Dt(e, t) {
|
|
4585
4585
|
const r = e % t;
|
|
4586
4586
|
return r >= Ot ? r : t + r;
|
|
@@ -4608,22 +4608,22 @@ function Io(e, t) {
|
|
|
4608
4608
|
const r = (e.ORDER + Tt) / bo, n = e.pow(t, r);
|
|
4609
4609
|
return si(e, n, t), n;
|
|
4610
4610
|
}
|
|
4611
|
-
function
|
|
4611
|
+
function yu(e, t) {
|
|
4612
4612
|
const r = (e.ORDER - mo) / Eo, n = e.mul(t, ve), i = e.pow(n, r), o = e.mul(t, i), a = e.mul(e.mul(o, ve), i), f = e.mul(o, e.sub(a, e.ONE));
|
|
4613
4613
|
return si(e, f, t), f;
|
|
4614
4614
|
}
|
|
4615
|
-
function
|
|
4615
|
+
function gu(e) {
|
|
4616
4616
|
const t = nn(e), r = Ao(e), n = r(t, t.neg(t.ONE)), i = r(t, n), o = r(t, t.neg(n)), a = (e + du) / vo;
|
|
4617
4617
|
return (f, l) => {
|
|
4618
4618
|
let p = f.pow(l, a), u = f.mul(p, n);
|
|
4619
|
-
const d = f.mul(p, i), w = f.mul(p, o),
|
|
4620
|
-
p = f.cmov(p, u,
|
|
4619
|
+
const d = f.mul(p, i), w = f.mul(p, o), g = f.eql(f.sqr(u), l), m = f.eql(f.sqr(d), l);
|
|
4620
|
+
p = f.cmov(p, u, g), u = f.cmov(w, d, m);
|
|
4621
4621
|
const v = f.eql(f.sqr(u), l), I = f.cmov(p, u, v);
|
|
4622
4622
|
return si(f, I, l), I;
|
|
4623
4623
|
};
|
|
4624
4624
|
}
|
|
4625
4625
|
function Ao(e) {
|
|
4626
|
-
if (e <
|
|
4626
|
+
if (e < go) throw new Error("sqrt is not defined for small field");
|
|
4627
4627
|
let t = e - Tt, r = 0;
|
|
4628
4628
|
for (; t % ve === Ot; ) t /= ve, r++;
|
|
4629
4629
|
let n = ve;
|
|
@@ -4638,16 +4638,16 @@ function Ao(e) {
|
|
|
4638
4638
|
let p = r, u = f.mul(f.ONE, o), d = f.pow(l, t), w = f.pow(l, a);
|
|
4639
4639
|
for (; !f.eql(d, f.ONE); ) {
|
|
4640
4640
|
if (f.is0(d)) return f.ZERO;
|
|
4641
|
-
let
|
|
4642
|
-
for (; !f.eql(m, f.ONE); ) if (
|
|
4643
|
-
const v = Tt << BigInt(p -
|
|
4644
|
-
p =
|
|
4641
|
+
let g = 1, m = f.sqr(d);
|
|
4642
|
+
for (; !f.eql(m, f.ONE); ) if (g++, m = f.sqr(m), g === p) throw new Error("Cannot find square root");
|
|
4643
|
+
const v = Tt << BigInt(p - g - 1), I = f.pow(u, v);
|
|
4644
|
+
p = g, u = f.sqr(I), d = f.mul(d, u), w = f.mul(w, I);
|
|
4645
4645
|
}
|
|
4646
4646
|
return w;
|
|
4647
4647
|
};
|
|
4648
4648
|
}
|
|
4649
4649
|
function bu(e) {
|
|
4650
|
-
return e % bo ===
|
|
4650
|
+
return e % bo === go ? Io : e % Eo === mo ? yu : e % vo === wu ? gu(e) : Ao(e);
|
|
4651
4651
|
}
|
|
4652
4652
|
var mu = [
|
|
4653
4653
|
"create",
|
|
@@ -4777,7 +4777,7 @@ var Au = class {
|
|
|
4777
4777
|
return this._sqrt || (this._sqrt = bu(this.ORDER)), this._sqrt(this, e);
|
|
4778
4778
|
}
|
|
4779
4779
|
toBytes(e) {
|
|
4780
|
-
return this.isLE ?
|
|
4780
|
+
return this.isLE ? yo(e, this.BYTES) : ri(e, this.BYTES);
|
|
4781
4781
|
}
|
|
4782
4782
|
fromBytes(e, t = !1) {
|
|
4783
4783
|
ut(e);
|
|
@@ -4816,7 +4816,7 @@ function Su(e, t, r = !1) {
|
|
|
4816
4816
|
const n = e.length, i = To(t), o = ko(t);
|
|
4817
4817
|
if (n < 16 || n < o || n > 1024) throw new Error("expected " + o + "-1024 bytes of input, got " + n);
|
|
4818
4818
|
const a = Dt(r ? wo(e) : rn(e), t - Tt) + Tt;
|
|
4819
|
-
return r ?
|
|
4819
|
+
return r ? yo(a, i) : ri(a, i);
|
|
4820
4820
|
}
|
|
4821
4821
|
var Me = /* @__PURE__ */ BigInt(0), Ie = /* @__PURE__ */ BigInt(1);
|
|
4822
4822
|
function Dr(e, t) {
|
|
@@ -4845,18 +4845,18 @@ function qi(e, t, r) {
|
|
|
4845
4845
|
const { windowSize: n, mask: i, maxNumber: o, shiftBy: a } = r;
|
|
4846
4846
|
let f = Number(e & i), l = e >> a;
|
|
4847
4847
|
f > n && (f -= o, l += Ie);
|
|
4848
|
-
const p = t * n, u = p + Math.abs(f) - 1, d = f === 0, w = f < 0,
|
|
4848
|
+
const p = t * n, u = p + Math.abs(f) - 1, d = f === 0, w = f < 0, g = t % 2 !== 0;
|
|
4849
4849
|
return {
|
|
4850
4850
|
nextN: l,
|
|
4851
4851
|
offset: u,
|
|
4852
4852
|
isZero: d,
|
|
4853
4853
|
isNeg: w,
|
|
4854
|
-
isNegF:
|
|
4854
|
+
isNegF: g,
|
|
4855
4855
|
offsetF: p
|
|
4856
4856
|
};
|
|
4857
4857
|
}
|
|
4858
|
-
var
|
|
4859
|
-
function
|
|
4858
|
+
var yn = /* @__PURE__ */ new WeakMap(), Oo = /* @__PURE__ */ new WeakMap();
|
|
4859
|
+
function gn(e) {
|
|
4860
4860
|
return Oo.get(e) || 1;
|
|
4861
4861
|
}
|
|
4862
4862
|
function Yi(e) {
|
|
@@ -4910,22 +4910,22 @@ var Tu = class {
|
|
|
4910
4910
|
return Yi(r), n;
|
|
4911
4911
|
}
|
|
4912
4912
|
getPrecomputes(e, t, r) {
|
|
4913
|
-
let n =
|
|
4914
|
-
return n || (n = this.precomputeWindow(t, e), e !== 1 && (typeof r == "function" && (n = r(n)),
|
|
4913
|
+
let n = yn.get(t);
|
|
4914
|
+
return n || (n = this.precomputeWindow(t, e), e !== 1 && (typeof r == "function" && (n = r(n)), yn.set(t, n))), n;
|
|
4915
4915
|
}
|
|
4916
4916
|
cached(e, t, r) {
|
|
4917
|
-
const n =
|
|
4917
|
+
const n = gn(e);
|
|
4918
4918
|
return this.wNAF(n, this.getPrecomputes(n, e, r), t);
|
|
4919
4919
|
}
|
|
4920
4920
|
unsafe(e, t, r, n) {
|
|
4921
|
-
const i =
|
|
4921
|
+
const i = gn(e);
|
|
4922
4922
|
return i === 1 ? this._unsafeLadder(e, t, n) : this.wNAFUnsafe(i, this.getPrecomputes(i, e, r), t, n);
|
|
4923
4923
|
}
|
|
4924
4924
|
createCache(e, t) {
|
|
4925
|
-
Uo(t, this.bits), Oo.set(e, t),
|
|
4925
|
+
Uo(t, this.bits), Oo.set(e, t), yn.delete(e);
|
|
4926
4926
|
}
|
|
4927
4927
|
hasCache(e) {
|
|
4928
|
-
return
|
|
4928
|
+
return gn(e) !== 1;
|
|
4929
4929
|
}
|
|
4930
4930
|
};
|
|
4931
4931
|
function ku(e, t, r, n) {
|
|
@@ -5020,8 +5020,8 @@ function Pu(e, t, r) {
|
|
|
5020
5020
|
let p = e - f * n - l * o, u = -f * i - l * a;
|
|
5021
5021
|
const d = p < re, w = u < re;
|
|
5022
5022
|
d && (p = -p), w && (u = -u);
|
|
5023
|
-
const
|
|
5024
|
-
if (p < re || p >=
|
|
5023
|
+
const g = ni(Math.ceil(lu(r) / 2)) + Ve;
|
|
5024
|
+
if (p < re || p >= g || u < re || u >= g) throw new Error("splitScalar (endomorphism): failed, k=" + e);
|
|
5025
5025
|
return {
|
|
5026
5026
|
k1neg: d,
|
|
5027
5027
|
k1: p,
|
|
@@ -5151,8 +5151,8 @@ function _u(e, t = {}) {
|
|
|
5151
5151
|
throw new Error("bad point: is not on curve, sqrt error" + ct);
|
|
5152
5152
|
}
|
|
5153
5153
|
u();
|
|
5154
|
-
const
|
|
5155
|
-
return (B & 1) === 1 !==
|
|
5154
|
+
const D = n.isOdd(L);
|
|
5155
|
+
return (B & 1) === 1 !== D && (L = n.neg(L)), {
|
|
5156
5156
|
x: $,
|
|
5157
5157
|
y: L
|
|
5158
5158
|
};
|
|
@@ -5165,7 +5165,7 @@ function _u(e, t = {}) {
|
|
|
5165
5165
|
};
|
|
5166
5166
|
} else throw new Error(`bad point: got length ${A}, expected compressed=${U} or uncompressed=${T}`);
|
|
5167
5167
|
}
|
|
5168
|
-
const
|
|
5168
|
+
const g = t.toBytes || d, m = t.fromBytes || w;
|
|
5169
5169
|
function v(Y) {
|
|
5170
5170
|
const U = n.sqr(Y), T = n.mul(U, Y);
|
|
5171
5171
|
return n.add(n.add(T, n.mul(Y, o.a)), o.b);
|
|
@@ -5188,7 +5188,7 @@ function _u(e, t = {}) {
|
|
|
5188
5188
|
if (!l || !l.basises) throw new Error("no endo");
|
|
5189
5189
|
return Pu(Y, l.basises, i.ORDER);
|
|
5190
5190
|
}
|
|
5191
|
-
const
|
|
5191
|
+
const M = Wi((Y, U) => {
|
|
5192
5192
|
const { X: T, Y: A, Z: B } = Y;
|
|
5193
5193
|
if (n.eql(B, n.ONE)) return {
|
|
5194
5194
|
x: T,
|
|
@@ -5206,7 +5206,7 @@ function _u(e, t = {}) {
|
|
|
5206
5206
|
x: $,
|
|
5207
5207
|
y: C
|
|
5208
5208
|
};
|
|
5209
|
-
}),
|
|
5209
|
+
}), Z = Wi((Y) => {
|
|
5210
5210
|
if (Y.is0()) {
|
|
5211
5211
|
if (t.allowInfinityPoint && !n.is0(Y.Y)) return;
|
|
5212
5212
|
throw new Error("bad point: ZERO");
|
|
@@ -5217,7 +5217,7 @@ function _u(e, t = {}) {
|
|
|
5217
5217
|
if (!Y.isTorsionFree()) throw new Error("bad point: not in prime-order subgroup");
|
|
5218
5218
|
return !0;
|
|
5219
5219
|
});
|
|
5220
|
-
function
|
|
5220
|
+
function Q(Y, U, T, A, B) {
|
|
5221
5221
|
return T = new q(n.mul(T.X, Y), T.Y, T.Z), U = Dr(A, U), T = Dr(B, T), U.add(T);
|
|
5222
5222
|
}
|
|
5223
5223
|
class q {
|
|
@@ -5257,7 +5257,7 @@ function _u(e, t = {}) {
|
|
|
5257
5257
|
return Qt.createCache(this, U), T || this.multiply(Ar), this;
|
|
5258
5258
|
}
|
|
5259
5259
|
assertValidity() {
|
|
5260
|
-
|
|
5260
|
+
Z(this);
|
|
5261
5261
|
}
|
|
5262
5262
|
hasEvenY() {
|
|
5263
5263
|
const { y: U } = this.toAffine();
|
|
@@ -5266,26 +5266,26 @@ function _u(e, t = {}) {
|
|
|
5266
5266
|
}
|
|
5267
5267
|
equals(U) {
|
|
5268
5268
|
O(U);
|
|
5269
|
-
const { X: T, Y: A, Z: B } = this, { X: V, Y: $, Z: C } = U, L = n.eql(n.mul(T, C), n.mul(V, B)),
|
|
5270
|
-
return L &&
|
|
5269
|
+
const { X: T, Y: A, Z: B } = this, { X: V, Y: $, Z: C } = U, L = n.eql(n.mul(T, C), n.mul(V, B)), D = n.eql(n.mul(A, C), n.mul($, B));
|
|
5270
|
+
return L && D;
|
|
5271
5271
|
}
|
|
5272
5272
|
negate() {
|
|
5273
5273
|
return new q(this.X, n.neg(this.Y), this.Z);
|
|
5274
5274
|
}
|
|
5275
5275
|
double() {
|
|
5276
5276
|
const { a: U, b: T } = o, A = n.mul(T, Ar), { X: B, Y: V, Z: $ } = this;
|
|
5277
|
-
let C = n.ZERO, L = n.ZERO,
|
|
5278
|
-
return K = n.add(K, K),
|
|
5277
|
+
let C = n.ZERO, L = n.ZERO, D = n.ZERO, F = n.mul(B, B), ct = n.mul(V, V), W = n.mul($, $), K = n.mul(B, V);
|
|
5278
|
+
return K = n.add(K, K), D = n.mul(B, $), D = n.add(D, D), C = n.mul(U, D), L = n.mul(A, W), L = n.add(C, L), C = n.sub(ct, L), L = n.add(ct, L), L = n.mul(C, L), C = n.mul(K, C), D = n.mul(A, D), W = n.mul(U, W), K = n.sub(F, W), K = n.mul(U, K), K = n.add(K, D), D = n.add(F, F), F = n.add(D, F), F = n.add(F, W), F = n.mul(F, K), L = n.add(L, F), W = n.mul(V, $), W = n.add(W, W), F = n.mul(W, K), C = n.sub(C, F), D = n.mul(W, ct), D = n.add(D, D), D = n.add(D, D), new q(C, L, D);
|
|
5279
5279
|
}
|
|
5280
5280
|
add(U) {
|
|
5281
5281
|
O(U);
|
|
5282
5282
|
const { X: T, Y: A, Z: B } = this, { X: V, Y: $, Z: C } = U;
|
|
5283
|
-
let L = n.ZERO,
|
|
5283
|
+
let L = n.ZERO, D = n.ZERO, F = n.ZERO;
|
|
5284
5284
|
const ct = o.a, W = n.mul(o.b, Ar);
|
|
5285
|
-
let K = n.mul(T, V),
|
|
5286
|
-
_t = n.mul(_t,
|
|
5287
|
-
let
|
|
5288
|
-
return
|
|
5285
|
+
let K = n.mul(T, V), it = n.mul(A, $), lt = n.mul(B, C), _t = n.add(T, A), st = n.add(V, $);
|
|
5286
|
+
_t = n.mul(_t, st), st = n.add(K, it), _t = n.sub(_t, st), st = n.add(T, B);
|
|
5287
|
+
let gt = n.add(V, C);
|
|
5288
|
+
return st = n.mul(st, gt), gt = n.add(K, lt), st = n.sub(st, gt), gt = n.add(A, B), L = n.add($, C), gt = n.mul(gt, L), L = n.add(it, lt), gt = n.sub(gt, L), F = n.mul(ct, st), L = n.mul(W, lt), F = n.add(L, F), L = n.sub(it, F), F = n.add(it, F), D = n.mul(L, F), it = n.add(K, K), it = n.add(it, K), lt = n.mul(ct, lt), st = n.mul(W, st), it = n.add(it, lt), lt = n.sub(K, lt), lt = n.mul(ct, lt), st = n.add(st, lt), K = n.mul(it, st), D = n.add(D, K), K = n.mul(gt, st), L = n.mul(_t, L), L = n.sub(L, K), K = n.mul(_t, it), F = n.mul(gt, F), F = n.add(F, K), new q(L, D, F);
|
|
5289
5289
|
}
|
|
5290
5290
|
subtract(U) {
|
|
5291
5291
|
return this.add(U.negate());
|
|
@@ -5299,8 +5299,8 @@ function _u(e, t = {}) {
|
|
|
5299
5299
|
let A, B;
|
|
5300
5300
|
const V = ($) => Qt.cached(this, $, (C) => zi(q, C));
|
|
5301
5301
|
if (T) {
|
|
5302
|
-
const { k1neg: $, k1: C, k2neg: L, k2:
|
|
5303
|
-
B = ct.add(K), A =
|
|
5302
|
+
const { k1neg: $, k1: C, k2neg: L, k2: D } = z(U), { p: F, f: ct } = V(C), { p: W, f: K } = V(D);
|
|
5303
|
+
B = ct.add(K), A = Q(T.beta, F, W, $, L);
|
|
5304
5304
|
} else {
|
|
5305
5305
|
const { p: $, f: C } = V(U);
|
|
5306
5306
|
A = $, B = C;
|
|
@@ -5314,12 +5314,12 @@ function _u(e, t = {}) {
|
|
|
5314
5314
|
if (U === Ve) return A;
|
|
5315
5315
|
if (Qt.hasCache(this)) return this.multiply(U);
|
|
5316
5316
|
if (T) {
|
|
5317
|
-
const { k1neg: B, k1: V, k2neg: $, k2: C } = z(U), { p1: L, p2:
|
|
5318
|
-
return
|
|
5317
|
+
const { k1neg: B, k1: V, k2neg: $, k2: C } = z(U), { p1: L, p2: D } = ku(q, A, V, C);
|
|
5318
|
+
return Q(T.beta, L, D, B, $);
|
|
5319
5319
|
} else return Qt.unsafe(A, U);
|
|
5320
5320
|
}
|
|
5321
5321
|
toAffine(U) {
|
|
5322
|
-
return
|
|
5322
|
+
return M(this, U);
|
|
5323
5323
|
}
|
|
5324
5324
|
isTorsionFree() {
|
|
5325
5325
|
const { isTorsionFree: U } = t;
|
|
@@ -5333,7 +5333,7 @@ function _u(e, t = {}) {
|
|
|
5333
5333
|
return this.multiplyUnsafe(a).is0();
|
|
5334
5334
|
}
|
|
5335
5335
|
toBytes(U = !0) {
|
|
5336
|
-
return Kr(U, "isCompressed"), this.assertValidity(),
|
|
5336
|
+
return Kr(U, "isCompressed"), this.assertValidity(), g(q, this, U);
|
|
5337
5337
|
}
|
|
5338
5338
|
toHex(U = !0) {
|
|
5339
5339
|
return en(this.toBytes(U));
|
|
@@ -5359,39 +5359,39 @@ function Ro(e, t) {
|
|
|
5359
5359
|
}
|
|
5360
5360
|
function Ru(e, t = {}) {
|
|
5361
5361
|
const { Fn: r } = e, n = t.randomBytes || co, i = Object.assign(Ro(e.Fp, r), { seed: ko(r.ORDER) });
|
|
5362
|
-
function o(
|
|
5362
|
+
function o(g) {
|
|
5363
5363
|
try {
|
|
5364
|
-
const m = r.fromBytes(
|
|
5364
|
+
const m = r.fromBytes(g);
|
|
5365
5365
|
return r.isValidNot0(m);
|
|
5366
5366
|
} catch {
|
|
5367
5367
|
return !1;
|
|
5368
5368
|
}
|
|
5369
5369
|
}
|
|
5370
|
-
function a(
|
|
5370
|
+
function a(g, m) {
|
|
5371
5371
|
const { publicKey: v, publicKeyUncompressed: I } = i;
|
|
5372
5372
|
try {
|
|
5373
|
-
const P =
|
|
5374
|
-
return m === !0 && P !== v || m === !1 && P !== I ? !1 : !!e.fromBytes(
|
|
5373
|
+
const P = g.length;
|
|
5374
|
+
return m === !0 && P !== v || m === !1 && P !== I ? !1 : !!e.fromBytes(g);
|
|
5375
5375
|
} catch {
|
|
5376
5376
|
return !1;
|
|
5377
5377
|
}
|
|
5378
5378
|
}
|
|
5379
|
-
function f(
|
|
5380
|
-
return Su(ut(
|
|
5379
|
+
function f(g = n(i.seed)) {
|
|
5380
|
+
return Su(ut(g, i.seed, "seed"), r.ORDER);
|
|
5381
5381
|
}
|
|
5382
|
-
function l(
|
|
5383
|
-
return e.BASE.multiply(r.fromBytes(
|
|
5382
|
+
function l(g, m = !0) {
|
|
5383
|
+
return e.BASE.multiply(r.fromBytes(g)).toBytes(m);
|
|
5384
5384
|
}
|
|
5385
|
-
function p(
|
|
5385
|
+
function p(g) {
|
|
5386
5386
|
const { secretKey: m, publicKey: v, publicKeyUncompressed: I } = i;
|
|
5387
|
-
if (!ti(
|
|
5388
|
-
const P = ut(
|
|
5387
|
+
if (!ti(g) || "_lengths" in r && r._lengths || m === v) return;
|
|
5388
|
+
const P = ut(g, void 0, "key").length;
|
|
5389
5389
|
return P === v || P === I;
|
|
5390
5390
|
}
|
|
5391
|
-
function u(
|
|
5392
|
-
if (p(
|
|
5391
|
+
function u(g, m, v = !0) {
|
|
5392
|
+
if (p(g) === !0) throw new Error("first arg must be private key");
|
|
5393
5393
|
if (p(m) === !1) throw new Error("second arg must be public key");
|
|
5394
|
-
const I = r.fromBytes(
|
|
5394
|
+
const I = r.fromBytes(g);
|
|
5395
5395
|
return e.fromBytes(m).multiply(I).toBytes(v);
|
|
5396
5396
|
}
|
|
5397
5397
|
const d = {
|
|
@@ -5416,7 +5416,7 @@ function Nu(e, t, r = {}) {
|
|
|
5416
5416
|
bits2int: "function",
|
|
5417
5417
|
bits2int_modN: "function"
|
|
5418
5418
|
}), r = Object.assign({}, r);
|
|
5419
|
-
const n = r.randomBytes || co, i = r.hmac || ((T, A) => xo(t, T, A)), { Fp: o, Fn: a } = e, { ORDER: f, BITS: l } = a, { keygen: p, getPublicKey: u, getSharedSecret: d, utils: w, lengths:
|
|
5419
|
+
const n = r.randomBytes || co, i = r.hmac || ((T, A) => xo(t, T, A)), { Fp: o, Fn: a } = e, { ORDER: f, BITS: l } = a, { keygen: p, getPublicKey: u, getSharedSecret: d, utils: w, lengths: g } = Ru(e, r), m = {
|
|
5420
5420
|
prehash: !0,
|
|
5421
5421
|
lowS: typeof r.lowS == "boolean" ? r.lowS : !0,
|
|
5422
5422
|
format: "compact",
|
|
@@ -5434,7 +5434,7 @@ function Nu(e, t, r = {}) {
|
|
|
5434
5434
|
}
|
|
5435
5435
|
function _(T, A) {
|
|
5436
5436
|
Rn(A);
|
|
5437
|
-
const B =
|
|
5437
|
+
const B = g.signature;
|
|
5438
5438
|
return ut(T, A === "compact" ? B : A === "recovered" ? B + 1 : void 0);
|
|
5439
5439
|
}
|
|
5440
5440
|
class O {
|
|
@@ -5457,11 +5457,11 @@ function Nu(e, t, r = {}) {
|
|
|
5457
5457
|
_(A, B);
|
|
5458
5458
|
let V;
|
|
5459
5459
|
if (B === "der") {
|
|
5460
|
-
const { r:
|
|
5461
|
-
return new O(
|
|
5460
|
+
const { r: D, s: F } = de.toSig(ut(A));
|
|
5461
|
+
return new O(D, F);
|
|
5462
5462
|
}
|
|
5463
5463
|
B === "recovered" && (V = A[0], B = "compact", A = A.subarray(1));
|
|
5464
|
-
const $ =
|
|
5464
|
+
const $ = g.signature / 2, C = A.subarray(0, $), L = A.subarray($, $ * 2);
|
|
5465
5465
|
return new O(a.fromBytes(C), a.fromBytes(L), V);
|
|
5466
5466
|
}
|
|
5467
5467
|
static fromHex(A, B) {
|
|
@@ -5478,9 +5478,9 @@ function Nu(e, t, r = {}) {
|
|
|
5478
5478
|
recoverPublicKey(A) {
|
|
5479
5479
|
const { r: B, s: V } = this, $ = this.assertRecovery(), C = $ === 2 || $ === 3 ? B + f : B;
|
|
5480
5480
|
if (!o.isValid(C)) throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
5481
|
-
const L = o.toBytes(C),
|
|
5482
|
-
if (
|
|
5483
|
-
return
|
|
5481
|
+
const L = o.toBytes(C), D = e.fromBytes(we(_o(($ & 1) === 0), L)), F = a.inv(C), ct = M(ut(A, void 0, "msgHash")), W = a.create(-ct * F), K = a.create(V * F), it = e.BASE.multiplyUnsafe(W).add(D.multiplyUnsafe(K));
|
|
5482
|
+
if (it.is0()) throw new Error("invalid recovery: point at infinify");
|
|
5483
|
+
return it.assertValidity(), it;
|
|
5484
5484
|
}
|
|
5485
5485
|
hasHighS() {
|
|
5486
5486
|
return I(this.s);
|
|
@@ -5498,11 +5498,11 @@ function Nu(e, t, r = {}) {
|
|
|
5498
5498
|
if (T.length > 8192) throw new Error("input is too large");
|
|
5499
5499
|
const A = rn(T), B = T.length * 8 - l;
|
|
5500
5500
|
return B > 0 ? A >> BigInt(B) : A;
|
|
5501
|
-
},
|
|
5501
|
+
}, M = r.bits2int_modN || function(T) {
|
|
5502
5502
|
return a.create(z(T));
|
|
5503
|
-
},
|
|
5504
|
-
function
|
|
5505
|
-
return cu("num < 2^" + l, T, re,
|
|
5503
|
+
}, Z = ni(l);
|
|
5504
|
+
function Q(T) {
|
|
5505
|
+
return cu("num < 2^" + l, T, re, Z), a.toBytes(T);
|
|
5506
5506
|
}
|
|
5507
5507
|
function q(T, A) {
|
|
5508
5508
|
return ut(T, void 0, "message"), A ? ut(t(T), void 0, "prehashed message") : T;
|
|
@@ -5510,23 +5510,23 @@ function Nu(e, t, r = {}) {
|
|
|
5510
5510
|
function Vt(T, A, B) {
|
|
5511
5511
|
const { lowS: V, prehash: $, extraEntropy: C } = bn(B, m);
|
|
5512
5512
|
T = q(T, $);
|
|
5513
|
-
const L =
|
|
5514
|
-
if (!a.isValidNot0(
|
|
5515
|
-
const F = [
|
|
5513
|
+
const L = M(T), D = a.fromBytes(A);
|
|
5514
|
+
if (!a.isValidNot0(D)) throw new Error("invalid private key");
|
|
5515
|
+
const F = [Q(D), Q(L)];
|
|
5516
5516
|
if (C != null && C !== !1) {
|
|
5517
|
-
const
|
|
5518
|
-
F.push(ut(
|
|
5517
|
+
const it = C === !0 ? n(g.secretKey) : C;
|
|
5518
|
+
F.push(ut(it, void 0, "extraEntropy"));
|
|
5519
5519
|
}
|
|
5520
5520
|
const ct = we(...F), W = L;
|
|
5521
|
-
function K(
|
|
5522
|
-
const lt = z(
|
|
5521
|
+
function K(it) {
|
|
5522
|
+
const lt = z(it);
|
|
5523
5523
|
if (!a.isValidNot0(lt)) return;
|
|
5524
|
-
const _t = a.inv(lt),
|
|
5525
|
-
if (
|
|
5526
|
-
const $t = a.create(_t * a.create(W +
|
|
5524
|
+
const _t = a.inv(lt), st = e.BASE.multiply(lt).toAffine(), gt = a.create(st.x);
|
|
5525
|
+
if (gt === re) return;
|
|
5526
|
+
const $t = a.create(_t * a.create(W + gt * D));
|
|
5527
5527
|
if ($t === re) return;
|
|
5528
|
-
let Be = (
|
|
5529
|
-
return V && I($t) && (je = a.neg($t), Be ^= 1), new O(
|
|
5528
|
+
let Be = (st.x === gt ? 0 : 2) | Number(st.y & Ve), je = $t;
|
|
5529
|
+
return V && I($t) && (je = a.neg($t), Be ^= 1), new O(gt, je, v ? void 0 : Be);
|
|
5530
5530
|
}
|
|
5531
5531
|
return {
|
|
5532
5532
|
seed: ct,
|
|
@@ -5540,15 +5540,15 @@ function Nu(e, t, r = {}) {
|
|
|
5540
5540
|
function Y(T, A, B, V = {}) {
|
|
5541
5541
|
const { lowS: $, prehash: C, format: L } = bn(V, m);
|
|
5542
5542
|
if (B = ut(B, void 0, "publicKey"), A = q(A, C), !ti(T)) {
|
|
5543
|
-
const
|
|
5544
|
-
throw new Error("verify expects Uint8Array signature" +
|
|
5543
|
+
const D = T instanceof O ? ", use sig.toBytes()" : "";
|
|
5544
|
+
throw new Error("verify expects Uint8Array signature" + D);
|
|
5545
5545
|
}
|
|
5546
5546
|
_(T, L);
|
|
5547
5547
|
try {
|
|
5548
|
-
const
|
|
5549
|
-
if ($ &&
|
|
5550
|
-
const { r: ct, s: W } =
|
|
5551
|
-
return
|
|
5548
|
+
const D = O.fromBytes(T, L), F = e.fromBytes(B);
|
|
5549
|
+
if ($ && D.hasHighS()) return !1;
|
|
5550
|
+
const { r: ct, s: W } = D, K = M(A), it = a.inv(W), lt = a.create(K * it), _t = a.create(ct * it), st = e.BASE.multiplyUnsafe(lt).add(F.multiplyUnsafe(_t));
|
|
5551
|
+
return st.is0() ? !1 : a.create(st.x) === ct;
|
|
5552
5552
|
} catch {
|
|
5553
5553
|
return !1;
|
|
5554
5554
|
}
|
|
@@ -5562,7 +5562,7 @@ function Nu(e, t, r = {}) {
|
|
|
5562
5562
|
getPublicKey: u,
|
|
5563
5563
|
getSharedSecret: d,
|
|
5564
5564
|
utils: w,
|
|
5565
|
-
lengths:
|
|
5565
|
+
lengths: g,
|
|
5566
5566
|
Point: e,
|
|
5567
5567
|
sign: Qt,
|
|
5568
5568
|
verify: Y,
|
|
@@ -5584,7 +5584,7 @@ var oi = {
|
|
|
5584
5584
|
basises: [[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")], [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]
|
|
5585
5585
|
}, Qi = /* @__PURE__ */ BigInt(2);
|
|
5586
5586
|
function Lu(e) {
|
|
5587
|
-
const t = oi.p, r = BigInt(3), n = BigInt(6), i = BigInt(11), o = BigInt(22), a = BigInt(23), f = BigInt(44), l = BigInt(88), p = e * e * e % t, u = p * p * e % t, d = Rt(Rt(Rt(u, r, t) * u % t, r, t) * u % t, Qi, t) * p % t, w = Rt(d, i, t) * d % t,
|
|
5587
|
+
const t = oi.p, r = BigInt(3), n = BigInt(6), i = BigInt(11), o = BigInt(22), a = BigInt(23), f = BigInt(44), l = BigInt(88), p = e * e * e % t, u = p * p * e % t, d = Rt(Rt(Rt(u, r, t) * u % t, r, t) * u % t, Qi, t) * p % t, w = Rt(d, i, t) * d % t, g = Rt(w, o, t) * w % t, m = Rt(g, f, t) * g % t, v = Rt(Rt(Rt(Rt(Rt(Rt(m, l, t) * m % t, f, t) * g % t, r, t) * u % t, a, t) * w % t, n, t) * p % t, Qi, t);
|
|
5588
5588
|
if (!Nn.eql(Nn.sqr(v), e)) throw new Error("Cannot find square root");
|
|
5589
5589
|
return v;
|
|
5590
5590
|
}
|
|
@@ -5596,21 +5596,21 @@ var Nn = nn(oi.p, { sqrt: Lu });
|
|
|
5596
5596
|
function H(e) {
|
|
5597
5597
|
return Xh(e);
|
|
5598
5598
|
}
|
|
5599
|
-
function
|
|
5599
|
+
function X(e, t) {
|
|
5600
5600
|
if (!e) throw new Error(`verifyCryptoBackend: ${t}`);
|
|
5601
5601
|
}
|
|
5602
5602
|
function Cu(e) {
|
|
5603
|
-
|
|
5603
|
+
X(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isPoint should accept generator point"), X(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005")), "isPoint should reject invalid point"), X(e.isXOnlyPoint(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isXOnlyPoint should accept generator x-coordinate"), X(!e.isXOnlyPoint(H("0000000000000000000000000000000000000000000000000000000000000005")), "isXOnlyPoint should reject x-coordinate not on curve"), X(!e.isXOnlyPoint(H("0000000000000000000000000000000000000000000000000000000000000000")), "isXOnlyPoint should reject zero"), X(!e.isXOnlyPoint(H("79be667ef9dcbbac55a06295ce870b07")), "isXOnlyPoint should reject wrong length"), X(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "isPrivate should accept valid scalar"), X(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")), "isPrivate should accept n-1"), X(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000")), "isPrivate should reject zero"), X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141")), "isPrivate should reject n"), X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142")), "isPrivate should reject n+1");
|
|
5604
5604
|
const t = e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"), H("0000000000000000000000000000000000000000000000000000000000000000"));
|
|
5605
|
-
|
|
5605
|
+
X(t !== null && Ut(t, H("0000000000000000000000000000000000000000000000000000000000000001")), "privateAdd: 1 + 0 should equal 1"), X(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"), H("0000000000000000000000000000000000000000000000000000000000000003")) === null, "privateAdd: (n-3) + 3 should return null (result is zero mod n)");
|
|
5606
5606
|
const r = e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"), H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"));
|
|
5607
|
-
|
|
5607
|
+
X(r !== null && Ut(r, H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24")), "privateAdd: known vector failed"), X(Ut(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001")), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")), "privateNegate(1) should equal n-1"), X(Ut(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")), H("0000000000000000000000000000000000000000000000000000000000000003")), "privateNegate(n-3) should equal 3"), X(Ut(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")), H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")), "privateNegate known vector failed"), X(Ut(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"), !0), H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "pointCompress uncompressed->compressed failed"), X(Ut(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"), !1), H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")), "pointCompress uncompressed->uncompressed failed"), X(Ut(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), !0), H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")), "pointCompress compressed->compressed failed"), X(Ut(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), !1), H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")), "pointCompress compressed->uncompressed failed");
|
|
5608
5608
|
const n = e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"));
|
|
5609
|
-
|
|
5609
|
+
X(n !== null && Ut(n, H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99")), "pointFromScalar known vector failed"), X(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")) === null, "xOnlyPointAddTweak should return null for infinity result");
|
|
5610
5610
|
let i = e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"), H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));
|
|
5611
|
-
|
|
5611
|
+
X(i !== null && Ut(i.xOnlyPubkey, H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf")) && i.parity === 1, "xOnlyPointAddTweak parity=1 case failed"), i = e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"), H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")), X(i !== null && Ut(i.xOnlyPubkey, H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c")) && i.parity === 0, "xOnlyPointAddTweak parity=0 case failed");
|
|
5612
5612
|
const o = e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"), H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"));
|
|
5613
|
-
|
|
5613
|
+
X(Ut(o, H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5")), "sign known vector failed"), X(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"), H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), o), "verify known vector failed"), e.signSchnorr && X(Ut(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"), H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"), H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")), H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")), "signSchnorr known vector failed"), e.verifySchnorr && X(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"), H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"), H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")), "verifySchnorr known vector failed");
|
|
5614
5614
|
}
|
|
5615
5615
|
var Hn = class Kt {
|
|
5616
5616
|
static #t;
|
|
@@ -5705,7 +5705,7 @@ function Fe(e, t) {
|
|
|
5705
5705
|
}
|
|
5706
5706
|
function Du(e) {
|
|
5707
5707
|
const t = Et(Ct(e.length));
|
|
5708
|
-
return
|
|
5708
|
+
return ye(e.length, t), Bt([t, e]);
|
|
5709
5709
|
}
|
|
5710
5710
|
var Ji = j, ts = 2, Mu = 80, No = class rr {
|
|
5711
5711
|
static NAME = ft.P2MR;
|
|
@@ -5725,8 +5725,8 @@ var Ji = j, ts = 2, Mu = 80, No = class rr {
|
|
|
5725
5725
|
#l;
|
|
5726
5726
|
#d;
|
|
5727
5727
|
#w = !1;
|
|
5728
|
-
#g = !1;
|
|
5729
5728
|
#y = !1;
|
|
5729
|
+
#g = !1;
|
|
5730
5730
|
#m = !1;
|
|
5731
5731
|
#E = !1;
|
|
5732
5732
|
#v = !1;
|
|
@@ -5752,10 +5752,10 @@ var Ji = j, ts = 2, Mu = 80, No = class rr {
|
|
|
5752
5752
|
return this.#w || (this.#f = this.#x(), this.#w = !0), this.#f;
|
|
5753
5753
|
}
|
|
5754
5754
|
get hash() {
|
|
5755
|
-
return this.#
|
|
5755
|
+
return this.#y || (this.#u = this.#B(), this.#y = !0), this.#u;
|
|
5756
5756
|
}
|
|
5757
5757
|
get output() {
|
|
5758
|
-
return this.#
|
|
5758
|
+
return this.#g || (this.#c = this.#_(), this.#g = !0), this.#c;
|
|
5759
5759
|
}
|
|
5760
5760
|
get redeem() {
|
|
5761
5761
|
return this.#m || (this.#p = this.#R(), this.#m = !0), this.#p;
|
|
@@ -5834,8 +5834,8 @@ var Ji = j, ts = 2, Mu = 80, No = class rr {
|
|
|
5834
5834
|
if (this.#e) return this.#e;
|
|
5835
5835
|
const t = this.hash;
|
|
5836
5836
|
if (!t) return;
|
|
5837
|
-
const r =
|
|
5838
|
-
return r.unshift(ts),
|
|
5837
|
+
const r = et.bech32m.toWords(t);
|
|
5838
|
+
return r.unshift(ts), et.bech32m.encode(this.#t.bech32, r);
|
|
5839
5839
|
}
|
|
5840
5840
|
#B() {
|
|
5841
5841
|
if (this.#s) return this.#s;
|
|
@@ -5855,7 +5855,7 @@ var Ji = j, ts = 2, Mu = 80, No = class rr {
|
|
|
5855
5855
|
#_() {
|
|
5856
5856
|
if (this.#n) return this.#n;
|
|
5857
5857
|
const t = this.hash;
|
|
5858
|
-
if (t) return
|
|
5858
|
+
if (t) return yt([Ji.OP_2, t]);
|
|
5859
5859
|
}
|
|
5860
5860
|
#R() {
|
|
5861
5861
|
if (this.#o) return this.#o;
|
|
@@ -5885,7 +5885,7 @@ var Ji = j, ts = 2, Mu = 80, No = class rr {
|
|
|
5885
5885
|
}
|
|
5886
5886
|
}
|
|
5887
5887
|
#L() {
|
|
5888
|
-
let t = new Uint8Array(0);
|
|
5888
|
+
let t = /* @__PURE__ */ new Uint8Array(0);
|
|
5889
5889
|
if (this.#e) {
|
|
5890
5890
|
const i = this.#P();
|
|
5891
5891
|
if (!i) throw new TypeError("Invalid address");
|
|
@@ -5914,7 +5914,7 @@ var Ji = j, ts = 2, Mu = 80, No = class rr {
|
|
|
5914
5914
|
if (this.#o && this.redeem) {
|
|
5915
5915
|
if (this.#o.redeemVersion && this.#o.redeemVersion !== this.redeem.redeemVersion) throw new TypeError("Redeem.redeemVersion and witness mismatch");
|
|
5916
5916
|
if (this.#o.output) {
|
|
5917
|
-
const i =
|
|
5917
|
+
const i = rt(this.#o.output);
|
|
5918
5918
|
if (!i || i.length === 0) throw new TypeError("Redeem.output is invalid");
|
|
5919
5919
|
if (this.redeem.output && !x(this.#o.output, this.redeem.output)) throw new TypeError("Redeem.output and witness mismatch");
|
|
5920
5920
|
}
|
|
@@ -5969,8 +5969,8 @@ var es = j, rs = 1, Fu = 80, Ho = class nr {
|
|
|
5969
5969
|
#l;
|
|
5970
5970
|
#d;
|
|
5971
5971
|
#w;
|
|
5972
|
-
#g;
|
|
5973
5972
|
#y;
|
|
5973
|
+
#g;
|
|
5974
5974
|
#m;
|
|
5975
5975
|
#E;
|
|
5976
5976
|
#v;
|
|
@@ -6014,10 +6014,10 @@ var es = j, rs = 1, Fu = 80, Ho = class nr {
|
|
|
6014
6014
|
return this.#A || (this.#w = this.#M(), this.#A = !0), this.#w;
|
|
6015
6015
|
}
|
|
6016
6016
|
get signature() {
|
|
6017
|
-
return this.#T || (this.#
|
|
6017
|
+
return this.#T || (this.#y = this.#F(), this.#T = !0), this.#y;
|
|
6018
6018
|
}
|
|
6019
6019
|
get output() {
|
|
6020
|
-
return this.#k || (this.#
|
|
6020
|
+
return this.#k || (this.#g = this.#W(), this.#k = !0), this.#g;
|
|
6021
6021
|
}
|
|
6022
6022
|
get redeem() {
|
|
6023
6023
|
return this.#P || (this.#m = this.#G(), this.#P = !0), this.#m;
|
|
@@ -6101,8 +6101,8 @@ var es = j, rs = 1, Fu = 80, Ho = class nr {
|
|
|
6101
6101
|
if (this.#e) return this.#e;
|
|
6102
6102
|
const t = this.pubkey;
|
|
6103
6103
|
if (!t) return;
|
|
6104
|
-
const r =
|
|
6105
|
-
return r.unshift(rs),
|
|
6104
|
+
const r = et.bech32m.toWords(t);
|
|
6105
|
+
return r.unshift(rs), et.bech32m.encode(this.#t.bech32, r);
|
|
6106
6106
|
}
|
|
6107
6107
|
#K() {
|
|
6108
6108
|
if (this.#s) return this.#s;
|
|
@@ -6142,7 +6142,7 @@ var es = j, rs = 1, Fu = 80, Ho = class nr {
|
|
|
6142
6142
|
#W() {
|
|
6143
6143
|
if (this.#h) return this.#h;
|
|
6144
6144
|
const t = this.pubkey;
|
|
6145
|
-
if (t) return
|
|
6145
|
+
if (t) return yt([es.OP_1, t]);
|
|
6146
6146
|
}
|
|
6147
6147
|
#G() {
|
|
6148
6148
|
if (this.#u) return this.#u;
|
|
@@ -6179,7 +6179,7 @@ var es = j, rs = 1, Fu = 80, Ho = class nr {
|
|
|
6179
6179
|
if (this.#o) return [this.#o];
|
|
6180
6180
|
}
|
|
6181
6181
|
#q() {
|
|
6182
|
-
let t = new Uint8Array(0);
|
|
6182
|
+
let t = /* @__PURE__ */ new Uint8Array(0);
|
|
6183
6183
|
if (this.#e) {
|
|
6184
6184
|
const i = this.#L();
|
|
6185
6185
|
if (!i) throw new TypeError("Invalid address");
|
|
@@ -6214,7 +6214,7 @@ var es = j, rs = 1, Fu = 80, Ho = class nr {
|
|
|
6214
6214
|
if (this.#u && this.redeem) {
|
|
6215
6215
|
if (this.#u.redeemVersion && this.#u.redeemVersion !== this.redeem.redeemVersion) throw new TypeError("Redeem.redeemVersion and witness mismatch");
|
|
6216
6216
|
if (this.#u.output) {
|
|
6217
|
-
const i =
|
|
6217
|
+
const i = rt(this.#u.output);
|
|
6218
6218
|
if (!i || i.length === 0) throw new TypeError("Redeem.output is invalid");
|
|
6219
6219
|
if (this.redeem.output && !x(this.#u.output, this.redeem.output)) throw new TypeError("Redeem.output and witness mismatch");
|
|
6220
6220
|
}
|
|
@@ -6259,7 +6259,7 @@ function wr(e, t) {
|
|
|
6259
6259
|
}, t);
|
|
6260
6260
|
return Object.assign(r.toPayment(), e);
|
|
6261
6261
|
}
|
|
6262
|
-
var ns = j, Wu = new Uint8Array(0), Lo = class ir {
|
|
6262
|
+
var ns = j, Wu = /* @__PURE__ */ new Uint8Array(0), Lo = class ir {
|
|
6263
6263
|
static NAME = ft.P2WPKH;
|
|
6264
6264
|
#t;
|
|
6265
6265
|
#a;
|
|
@@ -6277,8 +6277,8 @@ var ns = j, Wu = new Uint8Array(0), Lo = class ir {
|
|
|
6277
6277
|
#l;
|
|
6278
6278
|
#d;
|
|
6279
6279
|
#w = !1;
|
|
6280
|
-
#g = !1;
|
|
6281
6280
|
#y = !1;
|
|
6281
|
+
#g = !1;
|
|
6282
6282
|
#m = !1;
|
|
6283
6283
|
#E = !1;
|
|
6284
6284
|
#v = !1;
|
|
@@ -6301,10 +6301,10 @@ var ns = j, Wu = new Uint8Array(0), Lo = class ir {
|
|
|
6301
6301
|
return this.#w || (this.#h = this.#T(), this.#w = !0), this.#h;
|
|
6302
6302
|
}
|
|
6303
6303
|
get hash() {
|
|
6304
|
-
return this.#
|
|
6304
|
+
return this.#y || (this.#f = this.#k(), this.#y = !0), this.#f;
|
|
6305
6305
|
}
|
|
6306
6306
|
get pubkey() {
|
|
6307
|
-
return this.#
|
|
6307
|
+
return this.#g || (this.#u = this.#P(), this.#g = !0), this.#u;
|
|
6308
6308
|
}
|
|
6309
6309
|
get signature() {
|
|
6310
6310
|
return this.#m || (this.#c = this.#U(), this.#m = !0), this.#c;
|
|
@@ -6358,7 +6358,7 @@ var ns = j, Wu = new Uint8Array(0), Lo = class ir {
|
|
|
6358
6358
|
#A() {
|
|
6359
6359
|
if (!this.#S) {
|
|
6360
6360
|
if (this.#e) {
|
|
6361
|
-
const t =
|
|
6361
|
+
const t = et.bech32.decode(this.#e), r = t.words.shift(), n = et.bech32.fromWords(t.words);
|
|
6362
6362
|
this.#b = {
|
|
6363
6363
|
version: r ?? 0,
|
|
6364
6364
|
prefix: t.prefix,
|
|
@@ -6373,8 +6373,8 @@ var ns = j, Wu = new Uint8Array(0), Lo = class ir {
|
|
|
6373
6373
|
if (this.#e) return this.#e;
|
|
6374
6374
|
const t = this.hash;
|
|
6375
6375
|
if (!t) return;
|
|
6376
|
-
const r =
|
|
6377
|
-
return r.unshift(0),
|
|
6376
|
+
const r = et.bech32.toWords(t);
|
|
6377
|
+
return r.unshift(0), et.bech32.encode(this.#t.bech32, r);
|
|
6378
6378
|
}
|
|
6379
6379
|
#k() {
|
|
6380
6380
|
if (this.#s) return this.#s;
|
|
@@ -6394,7 +6394,7 @@ var ns = j, Wu = new Uint8Array(0), Lo = class ir {
|
|
|
6394
6394
|
#O() {
|
|
6395
6395
|
if (this.#i) return this.#i;
|
|
6396
6396
|
const t = this.hash;
|
|
6397
|
-
if (t) return
|
|
6397
|
+
if (t) return yt([ns.OP_0, t]);
|
|
6398
6398
|
}
|
|
6399
6399
|
#x() {
|
|
6400
6400
|
if (this.witness) return Wu;
|
|
@@ -6404,7 +6404,7 @@ var ns = j, Wu = new Uint8Array(0), Lo = class ir {
|
|
|
6404
6404
|
if (!(!this.#r || !this.#n)) return [this.#n, this.#r];
|
|
6405
6405
|
}
|
|
6406
6406
|
#_() {
|
|
6407
|
-
let t = new Uint8Array(0);
|
|
6407
|
+
let t = /* @__PURE__ */ new Uint8Array(0);
|
|
6408
6408
|
if (this.#e) {
|
|
6409
6409
|
const r = this.#A();
|
|
6410
6410
|
if (!r) throw new TypeError("Invalid address");
|
|
@@ -6452,7 +6452,7 @@ function sn(e, t) {
|
|
|
6452
6452
|
}, t);
|
|
6453
6453
|
return Object.assign(r.toPayment(), e);
|
|
6454
6454
|
}
|
|
6455
|
-
var is = j, mn = new Uint8Array(0);
|
|
6455
|
+
var is = j, mn = /* @__PURE__ */ new Uint8Array(0);
|
|
6456
6456
|
function Sr(e) {
|
|
6457
6457
|
return !!(e instanceof Uint8Array && e.length === 65 && e[0] === 4 && ke(e));
|
|
6458
6458
|
}
|
|
@@ -6474,8 +6474,8 @@ var Co = class sr {
|
|
|
6474
6474
|
#l = !1;
|
|
6475
6475
|
#d = !1;
|
|
6476
6476
|
#w = !1;
|
|
6477
|
-
#g = !1;
|
|
6478
6477
|
#y = !1;
|
|
6478
|
+
#g = !1;
|
|
6479
6479
|
#m = !1;
|
|
6480
6480
|
#E;
|
|
6481
6481
|
#v = !1;
|
|
@@ -6505,10 +6505,10 @@ var Co = class sr {
|
|
|
6505
6505
|
return this.#w || (this.#f = this.#P(), this.#w = !0), this.#f;
|
|
6506
6506
|
}
|
|
6507
6507
|
get input() {
|
|
6508
|
-
return this.#
|
|
6508
|
+
return this.#y || (this.#u = this.#U(), this.#y = !0), this.#u;
|
|
6509
6509
|
}
|
|
6510
6510
|
get redeem() {
|
|
6511
|
-
return this.#
|
|
6511
|
+
return this.#g || (this.#c = this.#O(), this.#g = !0), this.#c;
|
|
6512
6512
|
}
|
|
6513
6513
|
get witness() {
|
|
6514
6514
|
return this.#m || (this.#p = this.#x(), this.#m = !0), this.#p;
|
|
@@ -6553,7 +6553,7 @@ var Co = class sr {
|
|
|
6553
6553
|
#S() {
|
|
6554
6554
|
if (!this.#v) {
|
|
6555
6555
|
if (this.#e) {
|
|
6556
|
-
const t =
|
|
6556
|
+
const t = et.bech32.decode(this.#e), r = t.words.shift(), n = et.bech32.fromWords(t.words);
|
|
6557
6557
|
this.#E = {
|
|
6558
6558
|
version: r ?? 0,
|
|
6559
6559
|
prefix: t.prefix,
|
|
@@ -6565,14 +6565,14 @@ var Co = class sr {
|
|
|
6565
6565
|
return this.#E;
|
|
6566
6566
|
}
|
|
6567
6567
|
#A() {
|
|
6568
|
-
return this.#b || (this.#n?.input && (this.#I =
|
|
6568
|
+
return this.#b || (this.#n?.input && (this.#I = rt(this.#n.input) ?? void 0), this.#b = !0), this.#I;
|
|
6569
6569
|
}
|
|
6570
6570
|
#T() {
|
|
6571
6571
|
if (this.#e) return this.#e;
|
|
6572
6572
|
const t = this.hash;
|
|
6573
6573
|
if (!t) return;
|
|
6574
|
-
const r =
|
|
6575
|
-
return r.unshift(0),
|
|
6574
|
+
const r = et.bech32.toWords(t);
|
|
6575
|
+
return r.unshift(0), et.bech32.encode(this.#t.bech32, r);
|
|
6576
6576
|
}
|
|
6577
6577
|
#k() {
|
|
6578
6578
|
if (this.#s) return this.#s;
|
|
@@ -6584,7 +6584,7 @@ var Co = class sr {
|
|
|
6584
6584
|
#P() {
|
|
6585
6585
|
if (this.#r) return this.#r;
|
|
6586
6586
|
const t = this.hash;
|
|
6587
|
-
if (t) return
|
|
6587
|
+
if (t) return yt([is.OP_0, t]);
|
|
6588
6588
|
}
|
|
6589
6589
|
#U() {
|
|
6590
6590
|
if (this.witness) return mn;
|
|
@@ -6605,14 +6605,14 @@ var Co = class sr {
|
|
|
6605
6605
|
const r = this.#A();
|
|
6606
6606
|
if (r) {
|
|
6607
6607
|
const n = Ds(r);
|
|
6608
|
-
return this.#c = Object.assign({ witness: n }, t, { input: mn }), this.#
|
|
6608
|
+
return this.#c = Object.assign({ witness: n }, t, { input: mn }), this.#g = !0, [].concat(n, t.output);
|
|
6609
6609
|
}
|
|
6610
6610
|
}
|
|
6611
6611
|
return !t.output || !t.witness ? void 0 : [].concat(t.witness, t.output);
|
|
6612
6612
|
}
|
|
6613
6613
|
}
|
|
6614
6614
|
#B() {
|
|
6615
|
-
let t = new Uint8Array(0);
|
|
6615
|
+
let t = /* @__PURE__ */ new Uint8Array(0);
|
|
6616
6616
|
if (this.#e) {
|
|
6617
6617
|
const r = this.#S();
|
|
6618
6618
|
if (!r) throw new TypeError("Invalid address");
|
|
@@ -6635,7 +6635,7 @@ var Co = class sr {
|
|
|
6635
6635
|
if (this.#n.network && this.#n.network !== this.#t) throw new TypeError("Network mismatch");
|
|
6636
6636
|
if (this.#n.input && this.#n.input.length > 0 && this.#n.witness && this.#n.witness.length > 0) throw new TypeError("Ambiguous witness source");
|
|
6637
6637
|
if (this.#n.output) {
|
|
6638
|
-
const n =
|
|
6638
|
+
const n = rt(this.#n.output);
|
|
6639
6639
|
if (!n || n.length < 1) throw new TypeError("Redeem.output is invalid");
|
|
6640
6640
|
if (this.#n.output.byteLength > 3600) throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");
|
|
6641
6641
|
if (Xn(n) > 201) throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");
|
|
@@ -6646,16 +6646,16 @@ var Co = class sr {
|
|
|
6646
6646
|
const r = this.#A();
|
|
6647
6647
|
if (this.#n.input && r && !Jr(r)) throw new TypeError("Non push-only scriptSig");
|
|
6648
6648
|
if (this.#i && this.#n.witness && !Ue(this.#i, this.#n.witness)) throw new TypeError("Witness and redeem.witness mismatch");
|
|
6649
|
-
if (this.#n.input && r?.some(Sr) || this.#n.output && (
|
|
6649
|
+
if (this.#n.input && r?.some(Sr) || this.#n.output && (rt(this.#n.output) || []).some(Sr)) throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey");
|
|
6650
6650
|
}
|
|
6651
6651
|
if (this.#i && this.#i.length > 0) {
|
|
6652
6652
|
const r = this.#i[this.#i.length - 1];
|
|
6653
6653
|
if (this.#n && this.#n.output && !x(this.#n.output, r)) throw new TypeError("Witness and redeem.output mismatch");
|
|
6654
|
-
if (this.#i.some(Sr) || (
|
|
6654
|
+
if (this.#i.some(Sr) || (rt(r) || []).some(Sr)) throw new TypeError("Witness contains uncompressed pubkey");
|
|
6655
6655
|
}
|
|
6656
6656
|
}
|
|
6657
6657
|
};
|
|
6658
|
-
function
|
|
6658
|
+
function yr(e, t) {
|
|
6659
6659
|
if (!e.address && !e.hash && !e.output && !e.redeem && !e.witness) throw new TypeError("Not enough data");
|
|
6660
6660
|
return new Co({
|
|
6661
6661
|
address: e.address,
|
|
@@ -6697,10 +6697,10 @@ var ss = j, Vo = class Br {
|
|
|
6697
6697
|
return this.#t;
|
|
6698
6698
|
}
|
|
6699
6699
|
get pubkey() {
|
|
6700
|
-
return this.#c || (this.#i = this.#
|
|
6700
|
+
return this.#c || (this.#i = this.#y(), this.#c = !0), this.#i;
|
|
6701
6701
|
}
|
|
6702
6702
|
get signature() {
|
|
6703
|
-
return this.#p || (this.#o = this.#
|
|
6703
|
+
return this.#p || (this.#o = this.#g(), this.#p = !0), this.#o;
|
|
6704
6704
|
}
|
|
6705
6705
|
get output() {
|
|
6706
6706
|
return this.#l || (this.#h = this.#m(), this.#l = !0), this.#h;
|
|
@@ -6741,26 +6741,26 @@ var ss = j, Vo = class Br {
|
|
|
6741
6741
|
witness: this.witness
|
|
6742
6742
|
};
|
|
6743
6743
|
}
|
|
6744
|
-
#
|
|
6744
|
+
#y() {
|
|
6745
6745
|
if (this.#e) return this.#e;
|
|
6746
6746
|
if (this.#r) return this.#r.subarray(1, -1);
|
|
6747
6747
|
}
|
|
6748
|
-
#
|
|
6748
|
+
#g() {
|
|
6749
6749
|
if (this.#s) return this.#s;
|
|
6750
6750
|
if (this.#n) {
|
|
6751
|
-
const t =
|
|
6751
|
+
const t = rt(this.#n);
|
|
6752
6752
|
if (t && t.length > 0) return t[0];
|
|
6753
6753
|
}
|
|
6754
6754
|
}
|
|
6755
6755
|
#m() {
|
|
6756
6756
|
if (this.#r) return this.#r;
|
|
6757
6757
|
const t = this.#e;
|
|
6758
|
-
if (t) return
|
|
6758
|
+
if (t) return yt([t, ss.OP_CHECKSIG]);
|
|
6759
6759
|
}
|
|
6760
6760
|
#E() {
|
|
6761
6761
|
if (this.#n) return this.#n;
|
|
6762
6762
|
const t = this.#s;
|
|
6763
|
-
if (t) return
|
|
6763
|
+
if (t) return yt([t]);
|
|
6764
6764
|
}
|
|
6765
6765
|
#v() {
|
|
6766
6766
|
if (this.input) return [];
|
|
@@ -6777,7 +6777,7 @@ var ss = j, Vo = class Br {
|
|
|
6777
6777
|
if (this.#n && t && !x(this.#n, t)) throw new TypeError("Signature mismatch");
|
|
6778
6778
|
}
|
|
6779
6779
|
if (this.#n) {
|
|
6780
|
-
const t =
|
|
6780
|
+
const t = rt(this.#n);
|
|
6781
6781
|
if (!t || t.length !== 1) throw new TypeError("Input is invalid");
|
|
6782
6782
|
const r = this.signature;
|
|
6783
6783
|
if (!r || !xe(r)) throw new TypeError("Input has invalid signature");
|
|
@@ -6813,8 +6813,8 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
|
|
|
6813
6813
|
#l;
|
|
6814
6814
|
#d;
|
|
6815
6815
|
#w = !1;
|
|
6816
|
-
#g = !1;
|
|
6817
6816
|
#y = !1;
|
|
6817
|
+
#g = !1;
|
|
6818
6818
|
#m = !1;
|
|
6819
6819
|
#E = !1;
|
|
6820
6820
|
#v = !1;
|
|
@@ -6838,10 +6838,10 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
|
|
|
6838
6838
|
return this.#w || (this.#h = this.#T(), this.#w = !0), this.#h;
|
|
6839
6839
|
}
|
|
6840
6840
|
get n() {
|
|
6841
|
-
return this.#
|
|
6841
|
+
return this.#y || (this.#f = this.#k(), this.#y = !0), this.#f;
|
|
6842
6842
|
}
|
|
6843
6843
|
get pubkeys() {
|
|
6844
|
-
return this.#
|
|
6844
|
+
return this.#g || (this.#u = this.#P(), this.#g = !0), this.#u;
|
|
6845
6845
|
}
|
|
6846
6846
|
get signatures() {
|
|
6847
6847
|
return this.#m || (this.#c = this.#U(), this.#m = !0), this.#c;
|
|
@@ -6890,7 +6890,7 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
|
|
|
6890
6890
|
};
|
|
6891
6891
|
}
|
|
6892
6892
|
#A(t) {
|
|
6893
|
-
this.#S || (this.#S = !0, this.#b =
|
|
6893
|
+
this.#S || (this.#S = !0, this.#b = rt(t) ?? [], this.#h = this.#b[0] - Tr, this.#f = this.#b[this.#b.length - 2] - Tr, this.#u = this.#b.slice(1, -2), this.#w = !0, this.#y = !0, this.#g = !0);
|
|
6894
6894
|
}
|
|
6895
6895
|
#T() {
|
|
6896
6896
|
if (this.#e !== void 0) return this.#e;
|
|
@@ -6908,16 +6908,16 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
|
|
|
6908
6908
|
}
|
|
6909
6909
|
#U() {
|
|
6910
6910
|
if (this.#n) return this.#n;
|
|
6911
|
-
if (this.#o) return
|
|
6911
|
+
if (this.#o) return rt(this.#o)?.slice(1);
|
|
6912
6912
|
}
|
|
6913
6913
|
#O() {
|
|
6914
6914
|
if (this.#i) return this.#i;
|
|
6915
6915
|
const t = this.#e, r = this.n, n = this.#r;
|
|
6916
|
-
if (!(t === void 0 || r === void 0 || !n)) return
|
|
6916
|
+
if (!(t === void 0 || r === void 0 || !n)) return yt([].concat(Tr + t, n, Tr + r, He.OP_CHECKMULTISIG));
|
|
6917
6917
|
}
|
|
6918
6918
|
#x() {
|
|
6919
6919
|
if (this.#o) return this.#o;
|
|
6920
|
-
if (this.#n) return
|
|
6920
|
+
if (this.#n) return yt([He.OP_0].concat(this.#n));
|
|
6921
6921
|
}
|
|
6922
6922
|
#B() {
|
|
6923
6923
|
if (this.input) return [];
|
|
@@ -6943,7 +6943,7 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
|
|
|
6943
6943
|
}
|
|
6944
6944
|
if (this.#r) {
|
|
6945
6945
|
if (this.#s !== void 0 && this.#s !== this.#r.length) throw new TypeError("Pubkey count mismatch");
|
|
6946
|
-
if (this.#f = this.#r.length, this.#
|
|
6946
|
+
if (this.#f = this.#r.length, this.#y = !0, this.#h !== void 0 && this.#f < this.#h) throw new TypeError("Pubkey count cannot be less than m");
|
|
6947
6947
|
}
|
|
6948
6948
|
if (this.#n) {
|
|
6949
6949
|
if (this.#h !== void 0 && this.#n.length < this.#h) throw new TypeError("Not enough signatures provided");
|
|
@@ -6958,7 +6958,7 @@ var He = j, Tr = He.OP_RESERVED, $o = class _r {
|
|
|
6958
6958
|
}
|
|
6959
6959
|
}
|
|
6960
6960
|
};
|
|
6961
|
-
function
|
|
6961
|
+
function gr(e, t) {
|
|
6962
6962
|
if (!e.input && !e.output && !(e.pubkeys && e.m !== void 0) && !e.signatures) throw new TypeError("Not enough data");
|
|
6963
6963
|
const r = new $o({
|
|
6964
6964
|
m: e.m,
|
|
@@ -6979,7 +6979,7 @@ function Gu(e) {
|
|
|
6979
6979
|
const t = e.length;
|
|
6980
6980
|
return Ct(t) + e.reduce((r, n) => r + Nt(n), 0);
|
|
6981
6981
|
}
|
|
6982
|
-
var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000000000000000000000000000000000"), as = Or(Mt("0000000000000000000000000000000000000000000000000000000000000001")), ju = 18446744073709551615n,
|
|
6982
|
+
var ce = /* @__PURE__ */ new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000000000000000000000000000000000"), as = Or(Mt("0000000000000000000000000000000000000000000000000000000000000001")), ju = 18446744073709551615n, tt = class J {
|
|
6983
6983
|
static DEFAULT_SEQUENCE = 4294967295;
|
|
6984
6984
|
static SIGHASH_DEFAULT = 0;
|
|
6985
6985
|
static SIGHASH_ALL = 1;
|
|
@@ -6998,18 +6998,18 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
6998
6998
|
ins = [];
|
|
6999
6999
|
outs = [];
|
|
7000
7000
|
static fromBuffer(t, r) {
|
|
7001
|
-
const n = new _a(t), i = new
|
|
7001
|
+
const n = new _a(t), i = new J();
|
|
7002
7002
|
i.version = n.readInt32LE();
|
|
7003
7003
|
const o = n.readUInt8(), a = n.readUInt8();
|
|
7004
7004
|
let f = !1;
|
|
7005
|
-
o ===
|
|
7005
|
+
o === J.ADVANCED_TRANSACTION_MARKER && a === J.ADVANCED_TRANSACTION_FLAG ? f = !0 : n.offset -= 2;
|
|
7006
7006
|
const l = n.readVarInt();
|
|
7007
7007
|
for (let u = 0; u < l; ++u) {
|
|
7008
|
-
const d = n.readBytes(32), w = n.readUInt32LE(),
|
|
7008
|
+
const d = n.readBytes(32), w = n.readUInt32LE(), g = n.readVarBytes(), m = n.readUInt32LE();
|
|
7009
7009
|
i.ins.push({
|
|
7010
7010
|
hash: d,
|
|
7011
7011
|
index: w,
|
|
7012
|
-
script:
|
|
7012
|
+
script: g,
|
|
7013
7013
|
sequence: m,
|
|
7014
7014
|
witness: os
|
|
7015
7015
|
});
|
|
@@ -7028,7 +7028,7 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7028
7028
|
return i;
|
|
7029
7029
|
}
|
|
7030
7030
|
static fromHex(t) {
|
|
7031
|
-
return
|
|
7031
|
+
return J.fromBuffer(Mt(t), !1);
|
|
7032
7032
|
}
|
|
7033
7033
|
static isCoinbaseHash(t) {
|
|
7034
7034
|
if (t.length !== 32) throw new TypeError("Expected 32-byte hash");
|
|
@@ -7037,13 +7037,13 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7037
7037
|
}
|
|
7038
7038
|
isCoinbase() {
|
|
7039
7039
|
const t = this.ins[0];
|
|
7040
|
-
return this.ins.length === 1 && t !== void 0 &&
|
|
7040
|
+
return this.ins.length === 1 && t !== void 0 && J.isCoinbaseHash(t.hash);
|
|
7041
7041
|
}
|
|
7042
7042
|
addInput(t, r, n, i) {
|
|
7043
7043
|
if (t.length !== 32) throw new TypeError("Expected 32-byte hash");
|
|
7044
7044
|
if (!Number.isInteger(r) || r < 0 || r > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for index");
|
|
7045
7045
|
if (n != null && (!Number.isInteger(n) || n < 0 || n > 4294967295)) throw new TypeError("Expected unsigned 32-bit integer for sequence");
|
|
7046
|
-
return n ??=
|
|
7046
|
+
return n ??= J.DEFAULT_SEQUENCE, this.ins.push({
|
|
7047
7047
|
hash: t,
|
|
7048
7048
|
index: r,
|
|
7049
7049
|
script: i || ce,
|
|
@@ -7074,7 +7074,7 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7074
7074
|
return (r ? 10 : 8) + Ct(this.ins.length) + Ct(this.outs.length) + this.ins.reduce((n, i) => n + 40 + Nt(i.script), 0) + this.outs.reduce((n, i) => n + 8 + Nt(i.script), 0) + (r ? this.ins.reduce((n, i) => n + Gu(i.witness), 0) : 0);
|
|
7075
7075
|
}
|
|
7076
7076
|
clone() {
|
|
7077
|
-
const t = new
|
|
7077
|
+
const t = new J();
|
|
7078
7078
|
return t.version = this.version, t.locktime = this.locktime, t.ins = this.ins.map((r) => ({
|
|
7079
7079
|
hash: r.hash,
|
|
7080
7080
|
index: r.index,
|
|
@@ -7091,13 +7091,13 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7091
7091
|
if (!(r instanceof Uint8Array)) throw new TypeError("Expected Uint8Array for prevOutScript");
|
|
7092
7092
|
if (!Number.isInteger(n)) throw new TypeError("Expected integer for hashType");
|
|
7093
7093
|
if (t >= this.ins.length) return as;
|
|
7094
|
-
const i =
|
|
7094
|
+
const i = rt(r);
|
|
7095
7095
|
if (!i) throw new Error("Could not decompile prevOutScript");
|
|
7096
|
-
const o =
|
|
7097
|
-
if ((n & 31) ===
|
|
7096
|
+
const o = yt(i.filter((l) => l !== j.OP_CODESEPARATOR)), a = this.clone();
|
|
7097
|
+
if ((n & 31) === J.SIGHASH_NONE) a.outs = [], a.ins.forEach((l, p) => {
|
|
7098
7098
|
p !== t && (l.sequence = 0);
|
|
7099
7099
|
});
|
|
7100
|
-
else if ((n & 31) ===
|
|
7100
|
+
else if ((n & 31) === J.SIGHASH_SINGLE) {
|
|
7101
7101
|
if (t >= this.outs.length) return as;
|
|
7102
7102
|
a.outs.length = t + 1;
|
|
7103
7103
|
for (let l = 0; l < t; l++) a.outs[l] = {
|
|
@@ -7108,7 +7108,7 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7108
7108
|
p !== t && (l.sequence = 0);
|
|
7109
7109
|
});
|
|
7110
7110
|
}
|
|
7111
|
-
n &
|
|
7111
|
+
n & J.SIGHASH_ANYONECANPAY ? (a.ins = [a.ins[t]], a.ins[0].script = o) : (a.ins.forEach((l) => {
|
|
7112
7112
|
l.script = ce;
|
|
7113
7113
|
}), a.ins[t].script = o);
|
|
7114
7114
|
const f = Et(a.byteLength(!1) + 4);
|
|
@@ -7116,40 +7116,40 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7116
7116
|
}
|
|
7117
7117
|
hashForWitnessV1(t, r, n, i, o, a, f) {
|
|
7118
7118
|
if (!Number.isInteger(t) || t < 0 || t > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for inIndex");
|
|
7119
|
-
if (!Array.isArray(r) || !r.every((
|
|
7120
|
-
if (!Array.isArray(n) || !n.every((
|
|
7119
|
+
if (!Array.isArray(r) || !r.every((M) => M instanceof Uint8Array)) throw new TypeError("Expected array of Uint8Array for prevOutScripts");
|
|
7120
|
+
if (!Array.isArray(n) || !n.every((M) => typeof M == "bigint")) throw new TypeError("Expected array of bigint for values");
|
|
7121
7121
|
if (!Number.isInteger(i) || i < 0 || i > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for hashType");
|
|
7122
7122
|
if (n.length !== this.ins.length || r.length !== this.ins.length) throw new Error("Must supply prevout script and value for all inputs");
|
|
7123
|
-
const l = i ===
|
|
7124
|
-
let w = ce,
|
|
7125
|
-
if (!p) if (f) w = f.hashPrevouts,
|
|
7123
|
+
const l = i === J.SIGHASH_DEFAULT ? J.SIGHASH_ALL : i & J.SIGHASH_OUTPUT_MASK, p = (i & J.SIGHASH_INPUT_MASK) === J.SIGHASH_ANYONECANPAY, u = l === J.SIGHASH_NONE, d = l === J.SIGHASH_SINGLE;
|
|
7124
|
+
let w = ce, g = ce, m = ce, v = ce, I = ce;
|
|
7125
|
+
if (!p) if (f) w = f.hashPrevouts, g = f.hashAmounts, m = f.hashScriptPubKeys, v = f.hashSequences;
|
|
7126
7126
|
else {
|
|
7127
|
-
let
|
|
7128
|
-
this.ins.forEach((
|
|
7129
|
-
|
|
7130
|
-
}), w = It(
|
|
7127
|
+
let M = new dt(36 * this.ins.length);
|
|
7128
|
+
this.ins.forEach((Z) => {
|
|
7129
|
+
M.writeBytes(Z.hash), M.writeUInt32LE(Z.index);
|
|
7130
|
+
}), w = It(M.finish()), M = new dt(8 * this.ins.length), n.forEach((Z) => M.writeUInt64LE(Z)), g = It(M.finish()), M = new dt(r.map(Nt).reduce((Z, Q) => Z + Q)), r.forEach((Z) => M.writeVarBytes(Z)), m = It(M.finish()), M = new dt(4 * this.ins.length), this.ins.forEach((Z) => M.writeUInt32LE(Z.sequence)), v = It(M.finish());
|
|
7131
7131
|
}
|
|
7132
7132
|
if (u || d) {
|
|
7133
7133
|
if (d && t < this.outs.length) {
|
|
7134
|
-
const
|
|
7135
|
-
|
|
7134
|
+
const M = this.outs[t], Z = new dt(8 + Nt(M.script));
|
|
7135
|
+
Z.writeUInt64LE(M.value), Z.writeVarBytes(M.script), I = It(Z.finish());
|
|
7136
7136
|
}
|
|
7137
7137
|
} else if (f) I = f.hashOutputs;
|
|
7138
7138
|
else {
|
|
7139
7139
|
if (!this.outs.length) throw new Error("Add outputs to the transaction before signing.");
|
|
7140
|
-
const
|
|
7141
|
-
this.outs.forEach((
|
|
7142
|
-
|
|
7143
|
-
}), I = It(
|
|
7140
|
+
const M = this.outs.map((Q) => 8 + Nt(Q.script)).reduce((Q, q) => Q + q), Z = new dt(M);
|
|
7141
|
+
this.outs.forEach((Q) => {
|
|
7142
|
+
Z.writeUInt64LE(Q.value), Z.writeVarBytes(Q.script);
|
|
7143
|
+
}), I = It(Z.finish());
|
|
7144
7144
|
}
|
|
7145
7145
|
const P = (o ? 2 : 0) + (a ? 1 : 0), S = new dt(174 - (p ? 49 : 0) - (u ? 32 : 0) + (a ? 32 : 0) + (o ? 37 : 0));
|
|
7146
|
-
if (S.writeUInt8(i), S.writeInt32LE(this.version), S.writeUInt32LE(this.locktime), S.writeBytes(w), S.writeBytes(
|
|
7147
|
-
const
|
|
7148
|
-
S.writeBytes(
|
|
7146
|
+
if (S.writeUInt8(i), S.writeInt32LE(this.version), S.writeUInt32LE(this.locktime), S.writeBytes(w), S.writeBytes(g), S.writeBytes(m), S.writeBytes(v), u || d || S.writeBytes(I), S.writeUInt8(P), p) {
|
|
7147
|
+
const M = this.ins[t];
|
|
7148
|
+
S.writeBytes(M.hash), S.writeUInt32LE(M.index), S.writeUInt64LE(n[t]), S.writeVarBytes(r[t]), S.writeUInt32LE(M.sequence);
|
|
7149
7149
|
} else S.writeUInt32LE(t);
|
|
7150
7150
|
if (a) {
|
|
7151
|
-
const
|
|
7152
|
-
|
|
7151
|
+
const M = new dt(Nt(a));
|
|
7152
|
+
M.writeVarBytes(a), S.writeBytes(It(M.finish()));
|
|
7153
7153
|
}
|
|
7154
7154
|
d && S.writeBytes(I), o && (S.writeBytes(o), S.writeUInt8(0), S.writeUInt32LE(4294967295));
|
|
7155
7155
|
const _ = new Uint8Array([0]), O = S.finish(), z = new Uint8Array(1 + O.length);
|
|
@@ -7188,14 +7188,14 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7188
7188
|
if (typeof n != "bigint") throw new TypeError("Expected bigint for value");
|
|
7189
7189
|
if (!Number.isInteger(i) || i < 0 || i > 4294967295) throw new TypeError("Expected unsigned 32-bit integer for hashType");
|
|
7190
7190
|
let o, a, f = kr, l = kr, p = kr;
|
|
7191
|
-
if (i &
|
|
7191
|
+
if (i & J.SIGHASH_ANYONECANPAY || (o = Et(36 * this.ins.length), a = new dt(o, 0), this.ins.forEach((d) => {
|
|
7192
7192
|
a.writeBytes(d.hash), a.writeUInt32LE(d.index);
|
|
7193
|
-
}), l = le(o)), !(i &
|
|
7193
|
+
}), l = le(o)), !(i & J.SIGHASH_ANYONECANPAY) && (i & 31) !== J.SIGHASH_SINGLE && (i & 31) !== J.SIGHASH_NONE && (o = Et(4 * this.ins.length), a = new dt(o, 0), this.ins.forEach((d) => {
|
|
7194
7194
|
a.writeUInt32LE(d.sequence);
|
|
7195
|
-
}), p = le(o)), (i & 31) !==
|
|
7195
|
+
}), p = le(o)), (i & 31) !== J.SIGHASH_SINGLE && (i & 31) !== J.SIGHASH_NONE) o = Et(this.outs.reduce((d, w) => d + 8 + Nt(w.script), 0)), a = new dt(o, 0), this.outs.forEach((d) => {
|
|
7196
7196
|
a.writeUInt64LE(d.value), a.writeVarBytes(d.script);
|
|
7197
7197
|
}), f = le(o);
|
|
7198
|
-
else if ((i & 31) ===
|
|
7198
|
+
else if ((i & 31) === J.SIGHASH_SINGLE && t < this.outs.length) {
|
|
7199
7199
|
const d = this.outs[t];
|
|
7200
7200
|
o = Et(8 + Nt(d.script)), a = new dt(o, 0), a.writeUInt64LE(d.value), a.writeVarBytes(d.script), f = le(o);
|
|
7201
7201
|
}
|
|
@@ -7204,7 +7204,7 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7204
7204
|
return a.writeInt32LE(this.version), a.writeBytes(l), a.writeBytes(p), a.writeBytes(u.hash), a.writeUInt32LE(u.index), a.writeVarBytes(r), a.writeUInt64LE(n), a.writeUInt32LE(u.sequence), a.writeBytes(f), a.writeUInt32LE(this.locktime), a.writeUInt32LE(i), Or(le(o));
|
|
7205
7205
|
}
|
|
7206
7206
|
getHash(t) {
|
|
7207
|
-
return t && this.isCoinbase() ? new Uint8Array(32) : le(this.#t(void 0, void 0, t));
|
|
7207
|
+
return t && this.isCoinbase() ? /* @__PURE__ */ new Uint8Array(32) : le(this.#t(void 0, void 0, t));
|
|
7208
7208
|
}
|
|
7209
7209
|
getId() {
|
|
7210
7210
|
return Yt(zn(this.getHash(!1)));
|
|
@@ -7230,7 +7230,7 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7230
7230
|
const i = new dt(t, r || 0);
|
|
7231
7231
|
i.writeInt32LE(this.version);
|
|
7232
7232
|
const o = n && this.hasWitnesses();
|
|
7233
|
-
return o && (i.writeUInt8(
|
|
7233
|
+
return o && (i.writeUInt8(J.ADVANCED_TRANSACTION_MARKER), i.writeUInt8(J.ADVANCED_TRANSACTION_FLAG)), i.writeVarInt(this.ins.length), this.ins.forEach((a) => {
|
|
7234
7234
|
i.writeBytes(a.hash), i.writeUInt32LE(a.index), i.writeVarBytes(a.script), i.writeUInt32LE(a.sequence);
|
|
7235
7235
|
}), i.writeVarInt(this.outs.length), this.outs.forEach((a) => {
|
|
7236
7236
|
i.writeUInt64LE(a.value), i.writeVarBytes(a.script);
|
|
@@ -7240,7 +7240,7 @@ var ce = new Uint8Array(0), os = [], kr = Mt("0000000000000000000000000000000000
|
|
|
7240
7240
|
}
|
|
7241
7241
|
}, zu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
7242
7242
|
__proto__: null,
|
|
7243
|
-
Transaction:
|
|
7243
|
+
Transaction: tt
|
|
7244
7244
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
7245
7245
|
function ne(e) {
|
|
7246
7246
|
return (t) => {
|
|
@@ -7251,7 +7251,7 @@ function ne(e) {
|
|
|
7251
7251
|
}
|
|
7252
7252
|
};
|
|
7253
7253
|
}
|
|
7254
|
-
var qu = ne(
|
|
7254
|
+
var qu = ne(gr), Yu = ne(hi), Xu = ne(pr), on = ne(sn), hs = ne(yr), Ko = ne(dr), ui = ne(wr), fi = ne(ai), Gl = ne(Qn), jl = (e) => e.length === 4 && e[0] === 81 && e[1] === 2 && e[2] === 78 && e[3] === 115;
|
|
7255
7255
|
function or(e) {
|
|
7256
7256
|
const t = [];
|
|
7257
7257
|
function r(a) {
|
|
@@ -7259,7 +7259,7 @@ function or(e) {
|
|
|
7259
7259
|
}
|
|
7260
7260
|
function n(a) {
|
|
7261
7261
|
const f = Et(Ct(a));
|
|
7262
|
-
|
|
7262
|
+
ye(a, f, 0), t.push(f);
|
|
7263
7263
|
}
|
|
7264
7264
|
function i(a) {
|
|
7265
7265
|
n(a.length), r(a);
|
|
@@ -7270,7 +7270,7 @@ function or(e) {
|
|
|
7270
7270
|
return o(e), Bt(t);
|
|
7271
7271
|
}
|
|
7272
7272
|
function Do(e, t) {
|
|
7273
|
-
const r =
|
|
7273
|
+
const r = rt(t);
|
|
7274
7274
|
if (r === null) throw new Error("Unknown script error");
|
|
7275
7275
|
const n = St(e), i = Ce(e), o = Bn(e), a = o?.hybrid ? St(o.hybrid) : void 0, f = o?.uncompressed ? St(o.uncompressed) : void 0;
|
|
7276
7276
|
return r.findIndex((l) => typeof l == "number" ? !1 : !!(vr(l, e) || vr(l, i) || x(l, n) || o && (vr(l, o.uncompressed) || vr(l, o.hybrid) || a && x(l, a) || f && x(l, f))));
|
|
@@ -7283,11 +7283,11 @@ function Zu(e, t) {
|
|
|
7283
7283
|
}
|
|
7284
7284
|
function Mo(e, t, r) {
|
|
7285
7285
|
const { hashType: n } = t(e), i = [];
|
|
7286
|
-
switch (n &
|
|
7287
|
-
case
|
|
7286
|
+
switch (n & tt.SIGHASH_ANYONECANPAY && i.push("addInput"), n & 31) {
|
|
7287
|
+
case tt.SIGHASH_ALL:
|
|
7288
7288
|
break;
|
|
7289
|
-
case
|
|
7290
|
-
case
|
|
7289
|
+
case tt.SIGHASH_SINGLE:
|
|
7290
|
+
case tt.SIGHASH_NONE:
|
|
7291
7291
|
i.push("addOutput"), i.push("setInputSequence");
|
|
7292
7292
|
break;
|
|
7293
7293
|
}
|
|
@@ -7303,7 +7303,7 @@ function Qu(e) {
|
|
|
7303
7303
|
return r.map((n) => new Uint8Array(n.signature));
|
|
7304
7304
|
}
|
|
7305
7305
|
function Ju(e) {
|
|
7306
|
-
const t = e.finalScriptSig ?
|
|
7306
|
+
const t = e.finalScriptSig ? rt(new Uint8Array(e.finalScriptSig)) || [] : [], r = e.finalScriptWitness ? rt(new Uint8Array(e.finalScriptWitness)) || [] : [];
|
|
7307
7307
|
return t.concat(r).filter((n) => n instanceof Uint8Array && xe(n)).map((n) => ({ signature: n }));
|
|
7308
7308
|
}
|
|
7309
7309
|
function us(e, t, r) {
|
|
@@ -7315,7 +7315,7 @@ function us(e, t, r) {
|
|
|
7315
7315
|
}
|
|
7316
7316
|
}
|
|
7317
7317
|
function Le(e, t) {
|
|
7318
|
-
return Bt([e, t ? new Uint8Array([t]) : new Uint8Array(0)]);
|
|
7318
|
+
return Bt([e, t ? new Uint8Array([t]) : /* @__PURE__ */ new Uint8Array(0)]);
|
|
7319
7319
|
}
|
|
7320
7320
|
function Lt(e) {
|
|
7321
7321
|
return e && !!(e.tapInternalKey || e.tapMerkleRoot || e.tapLeafScript && e.tapLeafScript.length || e.tapBip32Derivation && e.tapBip32Derivation.length || e.witnessUtxo && (ui(new Uint8Array(e.witnessUtxo.script)) || fi(new Uint8Array(e.witnessUtxo.script))));
|
|
@@ -7361,7 +7361,7 @@ function nf(e, t) {
|
|
|
7361
7361
|
function sf(e) {
|
|
7362
7362
|
return {
|
|
7363
7363
|
signature: e.subarray(0, 64),
|
|
7364
|
-
hashType: e.subarray(64)[0] ||
|
|
7364
|
+
hashType: e.subarray(64)[0] || tt.SIGHASH_DEFAULT
|
|
7365
7365
|
};
|
|
7366
7366
|
}
|
|
7367
7367
|
function of(e) {
|
|
@@ -7453,10 +7453,10 @@ var Fo = {
|
|
|
7453
7453
|
ECDSA: 0,
|
|
7454
7454
|
Schnorr: 1
|
|
7455
7455
|
};
|
|
7456
|
-
function
|
|
7456
|
+
function yf(e) {
|
|
7457
7457
|
return e.type === "batchResult";
|
|
7458
7458
|
}
|
|
7459
|
-
function
|
|
7459
|
+
function gf(e) {
|
|
7460
7460
|
return e.type === "ready";
|
|
7461
7461
|
}
|
|
7462
7462
|
var At = {
|
|
@@ -7852,19 +7852,19 @@ var If = {
|
|
|
7852
7852
|
const d = f[u];
|
|
7853
7853
|
if (d.status === "fulfilled") {
|
|
7854
7854
|
const w = d.value;
|
|
7855
|
-
for (const
|
|
7855
|
+
for (const g of w.results) l.set(g.inputIndex, {
|
|
7856
7856
|
type: "result",
|
|
7857
|
-
taskId:
|
|
7858
|
-
signature:
|
|
7859
|
-
inputIndex:
|
|
7860
|
-
publicKey:
|
|
7861
|
-
signatureType:
|
|
7862
|
-
leafHash:
|
|
7857
|
+
taskId: g.taskId,
|
|
7858
|
+
signature: g.signature,
|
|
7859
|
+
inputIndex: g.inputIndex,
|
|
7860
|
+
publicKey: g.publicKey,
|
|
7861
|
+
signatureType: g.signatureType,
|
|
7862
|
+
leafHash: g.leafHash
|
|
7863
7863
|
});
|
|
7864
|
-
for (const
|
|
7864
|
+
for (const g of w.errors) p.set(g.inputIndex, g.error);
|
|
7865
7865
|
} else {
|
|
7866
|
-
const w = d.reason?.message ?? "Batch signing failed",
|
|
7867
|
-
for (const m of
|
|
7866
|
+
const w = d.reason?.message ?? "Batch signing failed", g = o[u];
|
|
7867
|
+
for (const m of g) p.set(m.inputIndex, w);
|
|
7868
7868
|
}
|
|
7869
7869
|
}
|
|
7870
7870
|
return this.#n || await this.#w(), {
|
|
@@ -7902,7 +7902,7 @@ var If = {
|
|
|
7902
7902
|
const a = setTimeout(() => {
|
|
7903
7903
|
o(/* @__PURE__ */ new Error(`Worker ${t} initialization timeout`));
|
|
7904
7904
|
}, 1e4), f = (l) => {
|
|
7905
|
-
|
|
7905
|
+
gf(l.data) && (clearTimeout(a), r.removeEventListener("message", f), n.state = At.Idle, i());
|
|
7906
7906
|
};
|
|
7907
7907
|
r.addEventListener("message", f), r.addEventListener("error", (l) => {
|
|
7908
7908
|
clearTimeout(a), o(/* @__PURE__ */ new Error(`Worker ${t} error: ${l.message}`));
|
|
@@ -7920,33 +7920,33 @@ var If = {
|
|
|
7920
7920
|
};
|
|
7921
7921
|
const o = this.#e[i] ?? await this.#p(), a = `batch-${this.#o++}`;
|
|
7922
7922
|
return new Promise((f, l) => {
|
|
7923
|
-
const p = {
|
|
7923
|
+
const p = setTimeout(() => {
|
|
7924
|
+
this.#s.delete(a), o.state = At.Idle, o.currentTaskId = null, o.taskStartTime = null, this.#d(o).catch(() => {
|
|
7925
|
+
}), this.#u().catch(() => {
|
|
7926
|
+
}), l(/* @__PURE__ */ new Error(`Batch signing timeout for ${t.length} tasks`));
|
|
7927
|
+
}, this.#a.maxKeyHoldTimeMs), u = {
|
|
7924
7928
|
batchId: a,
|
|
7925
7929
|
resolve: f,
|
|
7926
7930
|
reject: l,
|
|
7927
|
-
timeoutId:
|
|
7928
|
-
this.#s.delete(a), o.state = At.Idle, o.currentTaskId = null, o.taskStartTime = null, this.#d(o).catch(() => {
|
|
7929
|
-
}), this.#u().catch(() => {
|
|
7930
|
-
}), l(/* @__PURE__ */ new Error(`Batch signing timeout for ${t.length} tasks`));
|
|
7931
|
-
}, this.#a.maxKeyHoldTimeMs)
|
|
7931
|
+
timeoutId: p
|
|
7932
7932
|
};
|
|
7933
|
-
this.#s.set(a,
|
|
7934
|
-
const
|
|
7933
|
+
this.#s.set(a, u), o.state = At.Busy, o.currentTaskId = a, o.taskStartTime = Date.now();
|
|
7934
|
+
const d = t.map((g) => ({
|
|
7935
|
+
taskId: g.taskId,
|
|
7936
|
+
hash: g.hash,
|
|
7937
|
+
publicKey: n,
|
|
7938
|
+
signatureType: g.signatureType,
|
|
7939
|
+
lowR: g.lowR,
|
|
7940
|
+
inputIndex: g.inputIndex,
|
|
7941
|
+
sighashType: g.sighashType,
|
|
7942
|
+
leafHash: g.leafHash
|
|
7943
|
+
})), w = {
|
|
7935
7944
|
type: "signBatch",
|
|
7936
7945
|
batchId: a,
|
|
7937
|
-
tasks:
|
|
7938
|
-
taskId: d.taskId,
|
|
7939
|
-
hash: d.hash,
|
|
7940
|
-
publicKey: n,
|
|
7941
|
-
signatureType: d.signatureType,
|
|
7942
|
-
lowR: d.lowR,
|
|
7943
|
-
inputIndex: d.inputIndex,
|
|
7944
|
-
sighashType: d.sighashType,
|
|
7945
|
-
leafHash: d.leafHash
|
|
7946
|
-
})),
|
|
7946
|
+
tasks: d,
|
|
7947
7947
|
privateKey: r
|
|
7948
7948
|
};
|
|
7949
|
-
o.worker.postMessage(
|
|
7949
|
+
o.worker.postMessage(w);
|
|
7950
7950
|
});
|
|
7951
7951
|
}
|
|
7952
7952
|
async #p() {
|
|
@@ -7959,7 +7959,7 @@ var If = {
|
|
|
7959
7959
|
});
|
|
7960
7960
|
}
|
|
7961
7961
|
#l(t, r) {
|
|
7962
|
-
if (
|
|
7962
|
+
if (yf(r)) {
|
|
7963
7963
|
const n = this.#s.get(r.batchId);
|
|
7964
7964
|
n && (clearTimeout(n.timeoutId), this.#s.delete(r.batchId), t.state = At.Idle, t.currentTaskId = null, t.taskStartTime = null, n.resolve(r));
|
|
7965
7965
|
}
|
|
@@ -8005,7 +8005,7 @@ function Af(e, t, r, n, i) {
|
|
|
8005
8005
|
inputIndex: t,
|
|
8006
8006
|
hash: f,
|
|
8007
8007
|
signatureType: Fo.Schnorr,
|
|
8008
|
-
sighashType: r.sighashType ??
|
|
8008
|
+
sighashType: r.sighashType ?? tt.SIGHASH_DEFAULT,
|
|
8009
8009
|
leafHash: l
|
|
8010
8010
|
});
|
|
8011
8011
|
} catch {
|
|
@@ -8014,8 +8014,8 @@ function Af(e, t, r, n, i) {
|
|
|
8014
8014
|
}
|
|
8015
8015
|
function Sf(e, t, r, n, i) {
|
|
8016
8016
|
try {
|
|
8017
|
-
const o = r.sighashType ??
|
|
8018
|
-
return (i.sighashTypes ?? [
|
|
8017
|
+
const o = r.sighashType ?? tt.SIGHASH_ALL;
|
|
8018
|
+
return (i.sighashTypes ?? [tt.SIGHASH_ALL]).includes(o), null;
|
|
8019
8019
|
} catch {
|
|
8020
8020
|
return null;
|
|
8021
8021
|
}
|
|
@@ -8036,7 +8036,7 @@ function Yl(e, t, r) {
|
|
|
8036
8036
|
e.data.updateInput(i, { tapKeySig: f });
|
|
8037
8037
|
}
|
|
8038
8038
|
else {
|
|
8039
|
-
const f = Ae.encode(o.signature, a.sighashType ??
|
|
8039
|
+
const f = Ae.encode(o.signature, a.sighashType ?? tt.SIGHASH_ALL), l = [{
|
|
8040
8040
|
pubkey: Uint8Array.from(n),
|
|
8041
8041
|
signature: f
|
|
8042
8042
|
}];
|
|
@@ -8076,8 +8076,8 @@ function Go(e, t) {
|
|
|
8076
8076
|
if (f.length < 2 || f.length > 40) throw new TypeError("Invalid program length for segwit address");
|
|
8077
8077
|
const l = r === j.OP_0 ? 0 : r !== void 0 && r >= j.OP_1 && r <= j.OP_16 ? r - (j.OP_1 - 1) : -1;
|
|
8078
8078
|
if (l < 15 || l > 16) throw new TypeError(`Invalid segwit version ${l}`);
|
|
8079
|
-
const p = [l, ...
|
|
8080
|
-
return
|
|
8079
|
+
const p = [l, ...et.bech32m.toWords(f)];
|
|
8080
|
+
return et.bech32m.encode(t.bech32Opnet, p);
|
|
8081
8081
|
}
|
|
8082
8082
|
function jo(e, t) {
|
|
8083
8083
|
const r = e.subarray(2);
|
|
@@ -8105,8 +8105,8 @@ function Vn(e, t) {
|
|
|
8105
8105
|
return r[0] = t, r.set(e, 1), Gn(r);
|
|
8106
8106
|
}
|
|
8107
8107
|
function Wr(e, t, r, n) {
|
|
8108
|
-
const i =
|
|
8109
|
-
return i.unshift(t), t === 16 && n ?
|
|
8108
|
+
const i = et.bech32.toWords(e);
|
|
8109
|
+
return i.unshift(t), t === 16 && n ? et.bech32m.encode(n, i) : t === 0 ? et.bech32.encode(r, i) : et.bech32m.encode(r, i);
|
|
8110
8110
|
}
|
|
8111
8111
|
function qo(e, t) {
|
|
8112
8112
|
t = t || kt;
|
|
@@ -8116,12 +8116,12 @@ function qo(e, t) {
|
|
|
8116
8116
|
if (r === 22 && e[0] === 0 && e[1] === 20) return Wr(e.subarray(2, 22), 0, t.bech32);
|
|
8117
8117
|
if (r === 34 && e[0] === 0 && e[1] === 32) return Wr(e.subarray(2, 34), 0, t.bech32);
|
|
8118
8118
|
if (r === 34 && e[0] === 81 && e[1] === 32) {
|
|
8119
|
-
const n =
|
|
8120
|
-
return n.unshift(1),
|
|
8119
|
+
const n = et.bech32m.toWords(e.subarray(2, 34));
|
|
8120
|
+
return n.unshift(1), et.bech32m.encode(t.bech32, n);
|
|
8121
8121
|
}
|
|
8122
8122
|
if (r === 34 && e[0] === 82 && e[1] === 32) {
|
|
8123
|
-
const n =
|
|
8124
|
-
return n.unshift(2),
|
|
8123
|
+
const n = et.bech32m.toWords(e.subarray(2, 34));
|
|
8124
|
+
return n.unshift(2), et.bech32m.encode(t.bech32, n);
|
|
8125
8125
|
}
|
|
8126
8126
|
try {
|
|
8127
8127
|
return Go(e, t);
|
|
@@ -8153,7 +8153,7 @@ function Yo(e, t) {
|
|
|
8153
8153
|
if (o.prefix !== r.bech32 && r.bech32Opnet && o.prefix !== r.bech32Opnet) throw new Error(e + " has an invalid prefix");
|
|
8154
8154
|
if (o.version === 0) {
|
|
8155
8155
|
if (o.data.length === 20) return sn({ hash: lh(o.data) }).output;
|
|
8156
|
-
if (o.data.length === 32) return
|
|
8156
|
+
if (o.data.length === 32) return yr({ hash: Si(o.data) }).output;
|
|
8157
8157
|
} else if (o.version === 1) {
|
|
8158
8158
|
if (o.data.length === 32) return wr({ pubkey: o.data }).output;
|
|
8159
8159
|
} else {
|
|
@@ -8164,7 +8164,7 @@ function Yo(e, t) {
|
|
|
8164
8164
|
program: o.data,
|
|
8165
8165
|
network: r
|
|
8166
8166
|
}).output;
|
|
8167
|
-
} else if (o.version >= 2 && o.version <= 15 && o.data.length >= 2 && o.data.length <= 40) return o.version !== 16 && n && n(kf),
|
|
8167
|
+
} else if (o.version >= 2 && o.version <= 15 && o.data.length >= 2 && o.data.length <= 40) return o.version !== 16 && n && n(kf), yt([o.version + 80, o.data]);
|
|
8168
8168
|
}
|
|
8169
8169
|
}
|
|
8170
8170
|
}
|
|
@@ -8238,15 +8238,15 @@ var Uf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
8238
8238
|
}
|
|
8239
8239
|
#h() {
|
|
8240
8240
|
if (this.#e) return this.#e;
|
|
8241
|
-
if (this.#s) return
|
|
8241
|
+
if (this.#s) return rt(this.#s)?.slice(1);
|
|
8242
8242
|
}
|
|
8243
8243
|
#f() {
|
|
8244
8244
|
if (this.#s) return this.#s;
|
|
8245
|
-
if (this.#e) return
|
|
8245
|
+
if (this.#e) return yt([ls.OP_RETURN].concat(this.#e));
|
|
8246
8246
|
}
|
|
8247
8247
|
#u() {
|
|
8248
8248
|
if (this.#s) {
|
|
8249
|
-
const t =
|
|
8249
|
+
const t = rt(this.#s);
|
|
8250
8250
|
if (!t) throw new TypeError("Output is invalid");
|
|
8251
8251
|
if (t[0] !== ls.OP_RETURN) throw new TypeError("Output is invalid");
|
|
8252
8252
|
if (!t.slice(1).every((r) => r instanceof Uint8Array)) throw new TypeError("Output is invalid");
|
|
@@ -8281,22 +8281,21 @@ var Pf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
8281
8281
|
findScriptPath: Pe,
|
|
8282
8282
|
p2data: Of,
|
|
8283
8283
|
p2mr: ai,
|
|
8284
|
-
p2ms:
|
|
8284
|
+
p2ms: gr,
|
|
8285
8285
|
p2op: Qn,
|
|
8286
8286
|
p2pk: hi,
|
|
8287
8287
|
p2pkh: pr,
|
|
8288
8288
|
p2sh: dr,
|
|
8289
8289
|
p2tr: wr,
|
|
8290
8290
|
p2wpkh: sn,
|
|
8291
|
-
p2wsh:
|
|
8291
|
+
p2wsh: yr,
|
|
8292
8292
|
rootHashFromPath: Mr,
|
|
8293
8293
|
rootHashFromPathP2MR: hr,
|
|
8294
8294
|
tapBranchHash: Fe,
|
|
8295
8295
|
tapleafHash: Pt,
|
|
8296
8296
|
toHashTree: ur,
|
|
8297
8297
|
tweakKey: er
|
|
8298
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
8299
|
-
var Xl = Mt("6a24aa21a9ed"), qt;
|
|
8298
|
+
}, Symbol.toStringTag, { value: "Module" })), Xl = Mt("6a24aa21a9ed"), qt;
|
|
8300
8299
|
(function(e) {
|
|
8301
8300
|
e[e.UNSIGNED_TX = 0] = "UNSIGNED_TX", e[e.GLOBAL_XPUB = 1] = "GLOBAL_XPUB";
|
|
8302
8301
|
})(qt || (qt = {}));
|
|
@@ -8325,7 +8324,7 @@ function Xt(e) {
|
|
|
8325
8324
|
return r;
|
|
8326
8325
|
}
|
|
8327
8326
|
function G(e) {
|
|
8328
|
-
const t = e || new Uint8Array();
|
|
8327
|
+
const t = e || /* @__PURE__ */ new Uint8Array();
|
|
8329
8328
|
return t.length > 512 ? Rf(t) : _f(t);
|
|
8330
8329
|
}
|
|
8331
8330
|
function _f(e) {
|
|
@@ -8550,22 +8549,22 @@ function wc(e) {
|
|
|
8550
8549
|
2,
|
|
8551
8550
|
3,
|
|
8552
8551
|
4
|
|
8553
|
-
].includes(e.pubkey[0]) &&
|
|
8552
|
+
].includes(e.pubkey[0]) && yc(e.signature);
|
|
8554
8553
|
}
|
|
8555
|
-
function
|
|
8554
|
+
function yc(e) {
|
|
8556
8555
|
if (!(e instanceof Uint8Array) || e.length < 9 || e[0] !== 48 || e.length !== e[1] + 3 || e[2] !== 2) return !1;
|
|
8557
8556
|
const t = e[3];
|
|
8558
8557
|
if (t > 33 || t < 1 || e[3 + t + 1] !== 2) return !1;
|
|
8559
8558
|
const r = e[3 + t + 2];
|
|
8560
8559
|
return !(r > 33 || r < 1 || e.length !== 3 + t + 2 + r + 2);
|
|
8561
8560
|
}
|
|
8562
|
-
function
|
|
8561
|
+
function gc(e, t, r) {
|
|
8563
8562
|
const n = G(t.pubkey);
|
|
8564
8563
|
return r.has(n) ? !1 : (r.add(n), e.filter((i) => Zt(i.pubkey, t.pubkey) === 0).length === 0);
|
|
8565
8564
|
}
|
|
8566
8565
|
var bc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8567
8566
|
__proto__: null,
|
|
8568
|
-
canAddToArray:
|
|
8567
|
+
canAddToArray: gc,
|
|
8569
8568
|
check: wc,
|
|
8570
8569
|
decode: lc,
|
|
8571
8570
|
encode: pc,
|
|
@@ -8601,7 +8600,7 @@ function Tc(e) {
|
|
|
8601
8600
|
return Number(an(e.value, 0, "LE"));
|
|
8602
8601
|
}
|
|
8603
8602
|
function kc(e) {
|
|
8604
|
-
const t = Uint8Array.from([R.SIGHASH_TYPE]), r = new Uint8Array(4);
|
|
8603
|
+
const t = Uint8Array.from([R.SIGHASH_TYPE]), r = /* @__PURE__ */ new Uint8Array(4);
|
|
8605
8604
|
return ci(r, 0, e, "LE"), {
|
|
8606
8605
|
key: t,
|
|
8607
8606
|
value: r
|
|
@@ -8760,7 +8759,7 @@ function Jc(e) {
|
|
|
8760
8759
|
}
|
|
8761
8760
|
function tl(e) {
|
|
8762
8761
|
const { script: t, value: r } = e, n = Ct(t.length), i = new Uint8Array(8 + n + t.length);
|
|
8763
|
-
return Cf(i, 0, BigInt(r), "LE"),
|
|
8762
|
+
return Cf(i, 0, BigInt(r), "LE"), ye(t.length, i, 8), i.set(t, 8 + n), {
|
|
8764
8763
|
key: Uint8Array.from([R.WITNESS_UTXO]),
|
|
8765
8764
|
value: i
|
|
8766
8765
|
};
|
|
@@ -8799,7 +8798,7 @@ function ol(e) {
|
|
|
8799
8798
|
key: Uint8Array.from([ht.TAP_TREE]),
|
|
8800
8799
|
value: Xt([].concat(...e.leaves.map((t) => [
|
|
8801
8800
|
Uint8Array.of(t.depth, t.leafVersion),
|
|
8802
|
-
|
|
8801
|
+
ye(BigInt(t.script.length)).buffer,
|
|
8803
8802
|
t.script
|
|
8804
8803
|
])))
|
|
8805
8804
|
};
|
|
@@ -8831,8 +8830,8 @@ function li(e, t = ll) {
|
|
|
8831
8830
|
path: "m"
|
|
8832
8831
|
};
|
|
8833
8832
|
for (const u of cl(f.value.length / 4 - 1)) {
|
|
8834
|
-
const d = an(f.value, u * 4 + 4, "LE"), w = !!(d & 2147483648),
|
|
8835
|
-
p.path += "/" +
|
|
8833
|
+
const d = an(f.value, u * 4 + 4, "LE"), w = !!(d & 2147483648), g = d & 2147483647;
|
|
8834
|
+
p.path += "/" + g.toString(10) + (w ? "'" : "");
|
|
8836
8835
|
}
|
|
8837
8836
|
return p;
|
|
8838
8837
|
}
|
|
@@ -8841,9 +8840,9 @@ function li(e, t = ll) {
|
|
|
8841
8840
|
u.set(f.masterFingerprint, 0);
|
|
8842
8841
|
let d = 4;
|
|
8843
8842
|
return p.slice(1).forEach((w) => {
|
|
8844
|
-
const
|
|
8845
|
-
let m = 2147483647 & parseInt(
|
|
8846
|
-
|
|
8843
|
+
const g = w.slice(-1) === "'";
|
|
8844
|
+
let m = 2147483647 & parseInt(g ? w.slice(0, -1) : w, 10);
|
|
8845
|
+
g && (m += 2147483648), ci(u, d, m, "LE"), d += 4;
|
|
8847
8846
|
}), {
|
|
8848
8847
|
key: l,
|
|
8849
8848
|
value: u
|
|
@@ -8919,7 +8918,7 @@ function ra(e) {
|
|
|
8919
8918
|
}
|
|
8920
8919
|
function n(a) {
|
|
8921
8920
|
const f = t.encode(a), l = Ct(a.leafHashes.length), p = new Uint8Array(l);
|
|
8922
|
-
|
|
8921
|
+
ye(a.leafHashes.length, p);
|
|
8923
8922
|
const u = Xt([
|
|
8924
8923
|
p,
|
|
8925
8924
|
...a.leafHashes,
|
|
@@ -9037,9 +9036,9 @@ function ds(e) {
|
|
|
9037
9036
|
}
|
|
9038
9037
|
function wl(e) {
|
|
9039
9038
|
const t = e.key.length, r = e.value.length, n = Ct(t), i = Ct(r), o = new Uint8Array(n + t + i + r);
|
|
9040
|
-
return
|
|
9039
|
+
return ye(t, o, 0), o.set(e.key, n), ye(r, o, n + t), o.set(e.value, n + t + i), o;
|
|
9041
9040
|
}
|
|
9042
|
-
function
|
|
9041
|
+
function yl(e, t) {
|
|
9043
9042
|
let r = 0;
|
|
9044
9043
|
function n() {
|
|
9045
9044
|
const { numberValue: I, bytes: P } = We(e, r);
|
|
@@ -9076,7 +9075,7 @@ function gl(e, t) {
|
|
|
9076
9075
|
}
|
|
9077
9076
|
const u = l.filter((I) => I.key[0] === qt.UNSIGNED_TX);
|
|
9078
9077
|
if (u.length !== 1) throw new Error("Format Error: Only one UNSIGNED_TX allowed");
|
|
9079
|
-
const d = t(u[0].value), { inputCount: w, outputCount:
|
|
9078
|
+
const d = t(u[0].value), { inputCount: w, outputCount: g } = d.getInputOutputCounts(), m = [], v = [];
|
|
9080
9079
|
for (const I of qr(w)) {
|
|
9081
9080
|
const P = {}, S = [];
|
|
9082
9081
|
for (; !f(); ) {
|
|
@@ -9086,7 +9085,7 @@ function gl(e, t) {
|
|
|
9086
9085
|
}
|
|
9087
9086
|
m.push(S);
|
|
9088
9087
|
}
|
|
9089
|
-
for (const I of qr(
|
|
9088
|
+
for (const I of qr(g)) {
|
|
9090
9089
|
const P = {}, S = [];
|
|
9091
9090
|
for (; !f(); ) {
|
|
9092
9091
|
const _ = a(), O = G(_.key);
|
|
@@ -9214,12 +9213,12 @@ function sa(e, { globalMapKeyVals: t, inputKeyVals: r, outputKeyVals: n }) {
|
|
|
9214
9213
|
outputs: p
|
|
9215
9214
|
};
|
|
9216
9215
|
}
|
|
9217
|
-
function
|
|
9216
|
+
function gl({ globalMap: e, inputs: t, outputs: r }) {
|
|
9218
9217
|
const { globalKeyVals: n, inputKeyVals: i, outputKeyVals: o } = Kn({
|
|
9219
9218
|
globalMap: e,
|
|
9220
9219
|
inputs: t,
|
|
9221
9220
|
outputs: r
|
|
9222
|
-
}), a = ds(n), f = (d) => d.length === 0 ? [Uint8Array.from([0])] : d.map(ds), l = f(i), p = f(o), u = new Uint8Array(5);
|
|
9221
|
+
}), a = ds(n), f = (d) => d.length === 0 ? [Uint8Array.from([0])] : d.map(ds), l = f(i), p = f(o), u = /* @__PURE__ */ new Uint8Array(5);
|
|
9223
9222
|
return u.set([
|
|
9224
9223
|
112,
|
|
9225
9224
|
115,
|
|
@@ -9313,7 +9312,7 @@ function El(e, t) {
|
|
|
9313
9312
|
}
|
|
9314
9313
|
if (r === !1) throw new Error(`Input #${e} has too much or too little data to clean`);
|
|
9315
9314
|
}
|
|
9316
|
-
function
|
|
9315
|
+
function ys(e, t, r, n) {
|
|
9317
9316
|
throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`);
|
|
9318
9317
|
}
|
|
9319
9318
|
function wi(e) {
|
|
@@ -9322,12 +9321,12 @@ function wi(e) {
|
|
|
9322
9321
|
const i = t[n], { canAdd: o, canAddToArray: a, check: f, expected: l } = dl[e + "s"][n] || {}, p = !!a;
|
|
9323
9322
|
if (f) if (p) {
|
|
9324
9323
|
if (!Array.isArray(i) || r[n] && !Array.isArray(r[n])) throw new Error(`Key type ${n} must be an array`);
|
|
9325
|
-
i.every(f) ||
|
|
9324
|
+
i.every(f) || ys(e, n, l, i);
|
|
9326
9325
|
const u = r[n] || [], d = /* @__PURE__ */ new Set();
|
|
9327
9326
|
if (!i.every((w) => a(u, w, d))) throw new Error("Can not add duplicate data to array");
|
|
9328
9327
|
r[n] = u.concat(i);
|
|
9329
9328
|
} else {
|
|
9330
|
-
if (f(i) ||
|
|
9329
|
+
if (f(i) || ys(e, n, l, i), !o(r, i)) throw new Error(`Can not add duplicate data to ${e}`);
|
|
9331
9330
|
r[n] = i;
|
|
9332
9331
|
}
|
|
9333
9332
|
}
|
|
@@ -9335,12 +9334,14 @@ function wi(e) {
|
|
|
9335
9334
|
}
|
|
9336
9335
|
var vl = wi("global"), oa = wi("input"), aa = wi("output");
|
|
9337
9336
|
function Il(e, t) {
|
|
9338
|
-
|
|
9337
|
+
const r = mt(e, e.length - 1);
|
|
9338
|
+
oa(t, r);
|
|
9339
9339
|
}
|
|
9340
9340
|
function Al(e, t) {
|
|
9341
|
-
|
|
9341
|
+
const r = fr(e, e.length - 1);
|
|
9342
|
+
aa(t, r);
|
|
9342
9343
|
}
|
|
9343
|
-
var
|
|
9344
|
+
var gs = class {
|
|
9344
9345
|
constructor(e) {
|
|
9345
9346
|
this.inputs = [], this.outputs = [], this.globalMap = { unsignedTx: e };
|
|
9346
9347
|
}
|
|
@@ -9353,7 +9354,7 @@ var ys = class {
|
|
|
9353
9354
|
return this.fromBuffer(r, t);
|
|
9354
9355
|
}
|
|
9355
9356
|
static fromBuffer(e, t) {
|
|
9356
|
-
const r =
|
|
9357
|
+
const r = yl(e, t), n = new this(r.globalMap.unsignedTx);
|
|
9357
9358
|
return Object.assign(n, r), n;
|
|
9358
9359
|
}
|
|
9359
9360
|
toBase64() {
|
|
@@ -9363,16 +9364,18 @@ var ys = class {
|
|
|
9363
9364
|
return G(this.toBuffer());
|
|
9364
9365
|
}
|
|
9365
9366
|
toBuffer() {
|
|
9366
|
-
return
|
|
9367
|
+
return gl(this);
|
|
9367
9368
|
}
|
|
9368
9369
|
updateGlobal(e) {
|
|
9369
9370
|
return vl(e, this.globalMap), this;
|
|
9370
9371
|
}
|
|
9371
9372
|
updateInput(e, t) {
|
|
9372
|
-
|
|
9373
|
+
const r = mt(this.inputs, e);
|
|
9374
|
+
return oa(t, r), this;
|
|
9373
9375
|
}
|
|
9374
9376
|
updateOutput(e, t) {
|
|
9375
|
-
|
|
9377
|
+
const r = fr(this.outputs, e);
|
|
9378
|
+
return aa(t, r), this;
|
|
9376
9379
|
}
|
|
9377
9380
|
addUnknownKeyValToGlobal(e) {
|
|
9378
9381
|
return Sn(e, this.globalMap.unknownKeyVals, Tn(qt)), this.globalMap.unknownKeyVals || (this.globalMap.unknownKeyVals = []), this.globalMap.unknownKeyVals.push(e), this;
|
|
@@ -9461,7 +9464,7 @@ function fa(e, t) {
|
|
|
9461
9464
|
if (!x(n, a)) throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`);
|
|
9462
9465
|
};
|
|
9463
9466
|
}
|
|
9464
|
-
var bs = fa(dr, "Redeem script"), ms = fa(
|
|
9467
|
+
var bs = fa(dr, "Redeem script"), ms = fa(yr, "Witness script");
|
|
9465
9468
|
function Es(e) {
|
|
9466
9469
|
let t = 0;
|
|
9467
9470
|
function r(a) {
|
|
@@ -9482,15 +9485,15 @@ function Es(e) {
|
|
|
9482
9485
|
return o();
|
|
9483
9486
|
}
|
|
9484
9487
|
function Ul(e) {
|
|
9485
|
-
let t = e &
|
|
9488
|
+
let t = e & tt.SIGHASH_ANYONECANPAY ? "SIGHASH_ANYONECANPAY | " : "";
|
|
9486
9489
|
switch (e & 31) {
|
|
9487
|
-
case
|
|
9490
|
+
case tt.SIGHASH_ALL:
|
|
9488
9491
|
t += "SIGHASH_ALL";
|
|
9489
9492
|
break;
|
|
9490
|
-
case
|
|
9493
|
+
case tt.SIGHASH_SINGLE:
|
|
9491
9494
|
t += "SIGHASH_SINGLE";
|
|
9492
9495
|
break;
|
|
9493
|
-
case
|
|
9496
|
+
case tt.SIGHASH_NONE:
|
|
9494
9497
|
t += "SIGHASH_NONE";
|
|
9495
9498
|
break;
|
|
9496
9499
|
}
|
|
@@ -9509,7 +9512,7 @@ function vs(e) {
|
|
|
9509
9512
|
function Pl(e) {
|
|
9510
9513
|
return xe(e);
|
|
9511
9514
|
}
|
|
9512
|
-
function
|
|
9515
|
+
function yi(e) {
|
|
9513
9516
|
return on(e) ? "witnesspubkeyhash" : Xu(e) ? "pubkeyhash" : qu(e) ? "multisig" : Yu(e) ? "pubkey" : "nonstandard";
|
|
9514
9517
|
}
|
|
9515
9518
|
function Ze(e) {
|
|
@@ -9617,24 +9620,24 @@ var xl = class {
|
|
|
9617
9620
|
}
|
|
9618
9621
|
redeemFromFinalScriptSig(e) {
|
|
9619
9622
|
if (!e) return;
|
|
9620
|
-
const t =
|
|
9623
|
+
const t = rt(e);
|
|
9621
9624
|
if (!t) return;
|
|
9622
9625
|
const r = t[t.length - 1];
|
|
9623
|
-
if (!(!(r instanceof Uint8Array) || vs(r) || Pl(r) || !
|
|
9626
|
+
if (!(!(r instanceof Uint8Array) || vs(r) || Pl(r) || !rt(r))) return r;
|
|
9624
9627
|
}
|
|
9625
9628
|
redeemFromFinalWitnessScript(e) {
|
|
9626
9629
|
if (!e) return;
|
|
9627
9630
|
const t = Es(e), r = t[t.length - 1];
|
|
9628
|
-
if (!(!r || vs(r) || !
|
|
9631
|
+
if (!(!r || vs(r) || !rt(r))) return r;
|
|
9629
9632
|
}
|
|
9630
9633
|
finalizeAndComputeAmounts(e, t, r, n, i) {
|
|
9631
9634
|
let o = 0n;
|
|
9632
9635
|
e.forEach((d, w) => {
|
|
9633
|
-
const
|
|
9634
|
-
if (r && d.finalScriptSig && (
|
|
9636
|
+
const g = t.ins[w];
|
|
9637
|
+
if (r && d.finalScriptSig && (g.script = d.finalScriptSig), r && d.finalScriptWitness && (g.witness = Es(d.finalScriptWitness)), d.witnessUtxo) o += d.witnessUtxo.value;
|
|
9635
9638
|
else if (d.nonWitnessUtxo) {
|
|
9636
9639
|
if (!i) throw new Error("txFromBuffer is required for nonWitnessUtxo inputs");
|
|
9637
|
-
const m = this.getNonWitnessUtxoTx(d, w, i), v =
|
|
9640
|
+
const m = this.getNonWitnessUtxoTx(d, w, i), v = g.index, I = m.outs[v];
|
|
9638
9641
|
o += I.value;
|
|
9639
9642
|
}
|
|
9640
9643
|
});
|
|
@@ -9679,12 +9682,12 @@ var xl = class {
|
|
|
9679
9682
|
};
|
|
9680
9683
|
}
|
|
9681
9684
|
getHashForSig(e, t, r, n) {
|
|
9682
|
-
const i = this.#t.tx, o = t.sighashType ||
|
|
9685
|
+
const i = this.#t.tx, o = t.sighashType || tt.SIGHASH_ALL;
|
|
9683
9686
|
Is(o, n);
|
|
9684
9687
|
let a, f;
|
|
9685
9688
|
if (t.nonWitnessUtxo) {
|
|
9686
|
-
const d = this.#t.getNonWitnessUtxoTx(t, e, this.#a), w = i.ins[e],
|
|
9687
|
-
if (!x(
|
|
9689
|
+
const d = this.#t.getNonWitnessUtxoTx(t, e, this.#a), w = i.ins[e], g = w.hash;
|
|
9690
|
+
if (!x(g, d.getHash())) throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);
|
|
9688
9691
|
const m = w.index;
|
|
9689
9692
|
f = d.outs[m];
|
|
9690
9693
|
} else if (t.witnessUtxo) f = {
|
|
@@ -9712,17 +9715,17 @@ PROCEED WITH CAUTION!
|
|
|
9712
9715
|
};
|
|
9713
9716
|
}
|
|
9714
9717
|
getTaprootHashesForSig(e, t, r, n, i, o) {
|
|
9715
|
-
const a = this.#t.tx, f = t.sighashType ||
|
|
9718
|
+
const a = this.#t.tx, f = t.sighashType || tt.SIGHASH_DEFAULT;
|
|
9716
9719
|
if (Is(f, o), !this.#t.prevOuts) {
|
|
9717
|
-
const
|
|
9718
|
-
this.#t.prevOuts =
|
|
9720
|
+
const g = r.map((m, v) => this.#t.getScriptAndAmountFromUtxo(v, m, this.#a));
|
|
9721
|
+
this.#t.prevOuts = g, this.#t.signingScripts = g.map((m) => m.script), this.#t.values = g.map((m) => m.value);
|
|
9719
9722
|
}
|
|
9720
9723
|
const l = this.#t.signingScripts, p = this.#t.values;
|
|
9721
9724
|
this.#t.taprootHashCache || (this.#t.taprootHashCache = a.getTaprootHashCache(l, p));
|
|
9722
9725
|
const u = this.#t.taprootHashCache, d = [];
|
|
9723
9726
|
if (t.tapInternalKey && !i) {
|
|
9724
|
-
const
|
|
9725
|
-
if (x(Ce(n),
|
|
9727
|
+
const g = this.#t.getPrevoutTaprootKey(e, t, this.#a) || /* @__PURE__ */ new Uint8Array(0);
|
|
9728
|
+
if (x(Ce(n), g)) {
|
|
9726
9729
|
const m = a.hashForWitnessV1(e, l, p, f, void 0, void 0, u);
|
|
9727
9730
|
d.push({
|
|
9728
9731
|
pubkey: n,
|
|
@@ -9730,16 +9733,16 @@ PROCEED WITH CAUTION!
|
|
|
9730
9733
|
});
|
|
9731
9734
|
}
|
|
9732
9735
|
}
|
|
9733
|
-
const w = (t.tapLeafScript || []).filter((
|
|
9736
|
+
const w = (t.tapLeafScript || []).filter((g) => Fr(n, g.script)).map((g) => {
|
|
9734
9737
|
const m = Pt({
|
|
9735
|
-
output:
|
|
9736
|
-
version:
|
|
9738
|
+
output: g.script,
|
|
9739
|
+
version: g.leafVersion
|
|
9737
9740
|
});
|
|
9738
|
-
return Object.assign({ hash: m },
|
|
9739
|
-
}).filter((
|
|
9741
|
+
return Object.assign({ hash: m }, g);
|
|
9742
|
+
}).filter((g) => !i || x(i, g.hash)).map((g) => ({
|
|
9740
9743
|
pubkey: n,
|
|
9741
|
-
hash: a.hashForWitnessV1(e, l, p, f,
|
|
9742
|
-
leafHash:
|
|
9744
|
+
hash: a.hashForWitnessV1(e, l, p, f, g.hash, void 0, u),
|
|
9745
|
+
leafHash: g.hash
|
|
9743
9746
|
}));
|
|
9744
9747
|
return d.concat(w);
|
|
9745
9748
|
}
|
|
@@ -9793,7 +9796,7 @@ var _l = class {
|
|
|
9793
9796
|
this.#t = e, this.#a = t;
|
|
9794
9797
|
}
|
|
9795
9798
|
getFinalScripts(e, t, r, n, i, o, a = !0, f) {
|
|
9796
|
-
const l =
|
|
9799
|
+
const l = yi(r);
|
|
9797
9800
|
if (!la(t, r, l) && a) throw new Error(`Can not finalize input #${e}`);
|
|
9798
9801
|
if (!t.partialSig) throw new Error("Input missing partial signatures");
|
|
9799
9802
|
return ca(r, l, t.partialSig, n, i, o, f);
|
|
@@ -9803,14 +9806,14 @@ var _l = class {
|
|
|
9803
9806
|
}
|
|
9804
9807
|
};
|
|
9805
9808
|
function Rl(e, t, r, n, i, o, a = !0, f) {
|
|
9806
|
-
const l =
|
|
9809
|
+
const l = yi(r);
|
|
9807
9810
|
if (!la(t, r, l) && a) throw new Error(`Can not finalize input #${e}`);
|
|
9808
9811
|
if (!t.partialSig) throw new Error("Input missing partial signatures");
|
|
9809
9812
|
return ca(r, l, t.partialSig, n, i, o, f);
|
|
9810
9813
|
}
|
|
9811
9814
|
function ca(e, t, r, n, i, o, a) {
|
|
9812
9815
|
let f, l;
|
|
9813
|
-
const p = Nl(e, t, r), u = o ?
|
|
9816
|
+
const p = Nl(e, t, r), u = o ? yr({ redeem: p }) : null, d = i ? dr({ redeem: u || p }) : null;
|
|
9814
9817
|
return n ? (u && u.witness ? l = or(u.witness) : p && p.witness ? l = or(p.witness) : l = or(a ?? [new Uint8Array([0])]), d && (f = d?.input)) : d ? f = d?.input : p ? f = p.input : f = Array.isArray(a) && a[0] ? a[0] : new Uint8Array([1]), {
|
|
9815
9818
|
finalScriptSig: f,
|
|
9816
9819
|
finalScriptWitness: l
|
|
@@ -9823,7 +9826,7 @@ function la(e, t, r) {
|
|
|
9823
9826
|
case "witnesspubkeyhash":
|
|
9824
9827
|
return As(1, e.partialSig);
|
|
9825
9828
|
case "multisig": {
|
|
9826
|
-
const n =
|
|
9829
|
+
const n = gr({ output: t });
|
|
9827
9830
|
if (n.m === void 0) throw new Error("Cannot determine m for multisig");
|
|
9828
9831
|
return As(n.m, e.partialSig, n.pubkeys);
|
|
9829
9832
|
}
|
|
@@ -9846,7 +9849,7 @@ function Nl(e, t, r) {
|
|
|
9846
9849
|
const n = e;
|
|
9847
9850
|
switch (t) {
|
|
9848
9851
|
case "multisig":
|
|
9849
|
-
return
|
|
9852
|
+
return gr({
|
|
9850
9853
|
output: n,
|
|
9851
9854
|
signatures: Hl(e, r)
|
|
9852
9855
|
});
|
|
@@ -9878,7 +9881,7 @@ function Nl(e, t, r) {
|
|
|
9878
9881
|
}
|
|
9879
9882
|
}
|
|
9880
9883
|
function Hl(e, t) {
|
|
9881
|
-
const r =
|
|
9884
|
+
const r = gr({ output: e });
|
|
9882
9885
|
if (!r.pubkeys) throw new Error("Cannot extract pubkeys from multisig script");
|
|
9883
9886
|
const n = [];
|
|
9884
9887
|
for (const i of r.pubkeys) {
|
|
@@ -9901,7 +9904,7 @@ var Ll = new Uint8Array([
|
|
|
9901
9904
|
]), pa = class {
|
|
9902
9905
|
tx;
|
|
9903
9906
|
constructor(e = Ll) {
|
|
9904
|
-
this.tx =
|
|
9907
|
+
this.tx = tt.fromBuffer(e), Sl(this.tx), Object.defineProperty(this, "tx", {
|
|
9905
9908
|
enumerable: !1,
|
|
9906
9909
|
writable: !0
|
|
9907
9910
|
});
|
|
@@ -9929,13 +9932,13 @@ var Ll = new Uint8Array([
|
|
|
9929
9932
|
maximumFeeRate: 5e3
|
|
9930
9933
|
};
|
|
9931
9934
|
function jt(e) {
|
|
9932
|
-
return
|
|
9935
|
+
return tt.fromBuffer(e);
|
|
9933
9936
|
}
|
|
9934
9937
|
function $l(e, t, r, n, i, o, a = !0, f) {
|
|
9935
9938
|
return Rl(e, t, r, n, i, o, a, f);
|
|
9936
9939
|
}
|
|
9937
9940
|
var Zl = class Mn {
|
|
9938
|
-
constructor(t = {}, r = new
|
|
9941
|
+
constructor(t = {}, r = new gs(new pa())) {
|
|
9939
9942
|
this.data = r, this.#s = Object.assign({}, Vl, t);
|
|
9940
9943
|
const n = this.data.globalMap.unsignedTx.tx;
|
|
9941
9944
|
this.#t = new xl(n), t.version === 3 ? this.setVersionTRUC() : this.data.inputs.length === 0 && this.setVersion(2);
|
|
@@ -9995,8 +9998,8 @@ var Zl = class Mn {
|
|
|
9995
9998
|
return this.fromBuffer(n, r);
|
|
9996
9999
|
}
|
|
9997
10000
|
static fromBuffer(t, r = {}) {
|
|
9998
|
-
const n =
|
|
9999
|
-
return Tl(
|
|
10001
|
+
const n = gs.fromBuffer(t, Cl), i = new Mn(r, n);
|
|
10002
|
+
return Tl(i.#t.tx, i.#t), i.#t.hasSignatures = i.data.inputs.some((o) => o.partialSig?.length || o.tapKeySig || o.tapScriptSig?.length || o.finalScriptSig || o.finalScriptWitness), i;
|
|
10000
10003
|
}
|
|
10001
10004
|
combine(...t) {
|
|
10002
10005
|
return this.data.combine(...t.map((r) => r.data)), this;
|
|
@@ -10015,7 +10018,7 @@ var Zl = class Mn {
|
|
|
10015
10018
|
return Ur(t), Xe(this.data.inputs, "setVersion", this.#t.hasSignatures), this.#t.tx.version = t, this.#t.invalidate("outputs"), this;
|
|
10016
10019
|
}
|
|
10017
10020
|
setVersionTRUC() {
|
|
10018
|
-
return this.setVersion(
|
|
10021
|
+
return this.setVersion(tt.TRUC_VERSION);
|
|
10019
10022
|
}
|
|
10020
10023
|
setLocktime(t) {
|
|
10021
10024
|
return Ur(t), Xe(this.data.inputs, "setLocktime", this.#t.hasSignatures), this.#t.tx.locktime = t, this.#t.invalidate("outputs"), this;
|
|
@@ -10081,7 +10084,7 @@ var Zl = class Mn {
|
|
|
10081
10084
|
}
|
|
10082
10085
|
getInputType(t) {
|
|
10083
10086
|
const r = mt(this.data.inputs, t), n = Xr(this.#t.getScriptFromUtxo(t, r, jt), t, "input", r.redeemScript || this.#t.redeemFromFinalScriptSig(r.finalScriptSig), r.witnessScript || this.#t.redeemFromFinalWitnessScript(r.finalScriptWitness));
|
|
10084
|
-
return (n.type === "raw" ? "" : n.type + "-") +
|
|
10087
|
+
return (n.type === "raw" ? "" : n.type + "-") + yi(n.meaningfulScript);
|
|
10085
10088
|
}
|
|
10086
10089
|
inputHasPubkey(t, r) {
|
|
10087
10090
|
const n = mt(this.data.inputs, t);
|
|
@@ -10106,7 +10109,7 @@ var Zl = class Mn {
|
|
|
10106
10109
|
const i = this.data.inputs[t];
|
|
10107
10110
|
return Lt(i) ? this.#f(t, r, n) : this.#h(t, r, n);
|
|
10108
10111
|
}
|
|
10109
|
-
signAllInputsHD(t, r = [
|
|
10112
|
+
signAllInputsHD(t, r = [tt.SIGHASH_ALL]) {
|
|
10110
10113
|
if (!t || !t.publicKey || !t.fingerprint) throw new Error("Need HDSigner to sign input");
|
|
10111
10114
|
const n = [];
|
|
10112
10115
|
for (const i of Ze(this.data.inputs.length)) try {
|
|
@@ -10117,7 +10120,7 @@ var Zl = class Mn {
|
|
|
10117
10120
|
if (n.every((i) => !i)) throw new Error("No inputs were signed");
|
|
10118
10121
|
return this;
|
|
10119
10122
|
}
|
|
10120
|
-
async signAllInputsHDAsync(t, r = [
|
|
10123
|
+
async signAllInputsHDAsync(t, r = [tt.SIGHASH_ALL]) {
|
|
10121
10124
|
if (!t || !t.publicKey || !t.fingerprint) throw new Error("Need HDSigner to sign input");
|
|
10122
10125
|
const n = [], i = [];
|
|
10123
10126
|
for (const o of Ze(this.data.inputs.length)) i.push(this.signInputHDAsync(o, t, r).then(() => {
|
|
@@ -10127,11 +10130,11 @@ var Zl = class Mn {
|
|
|
10127
10130
|
}));
|
|
10128
10131
|
if (await Promise.all(i), n.every((o) => !o)) throw new Error("No inputs were signed");
|
|
10129
10132
|
}
|
|
10130
|
-
signInputHD(t, r, n = [
|
|
10133
|
+
signInputHD(t, r, n = [tt.SIGHASH_ALL]) {
|
|
10131
10134
|
if (!r || !r.publicKey || !r.fingerprint) throw new Error("Need HDSigner to sign input");
|
|
10132
10135
|
return this.#r.getSignersFromHD(t, this.data.inputs, r).forEach((i) => this.signInput(t, i, n)), this;
|
|
10133
10136
|
}
|
|
10134
|
-
async signInputHDAsync(t, r, n = [
|
|
10137
|
+
async signInputHDAsync(t, r, n = [tt.SIGHASH_ALL]) {
|
|
10135
10138
|
if (!r || !r.publicKey || !r.fingerprint) throw new Error("Need HDSigner to sign input");
|
|
10136
10139
|
const i = this.#r.getSignersFromHD(t, this.data.inputs, r).map((o) => this.signInputAsync(t, o, n));
|
|
10137
10140
|
await Promise.all(i);
|
|
@@ -10257,11 +10260,11 @@ var Zl = class Mn {
|
|
|
10257
10260
|
const f = [];
|
|
10258
10261
|
let l, p, u;
|
|
10259
10262
|
for (const d of a) {
|
|
10260
|
-
const w = d.signature,
|
|
10263
|
+
const w = d.signature, g = d.pubkey, m = Ae.decode(w), { hash: v, script: I } = u !== m.hashType || !l || !p ? this.#r.getHashForSig(t, Object.assign({}, i, { sighashType: m.hashType }), !0) : {
|
|
10261
10264
|
hash: l,
|
|
10262
10265
|
script: p
|
|
10263
10266
|
};
|
|
10264
|
-
u = m.hashType, l = v, p = I, ua(
|
|
10267
|
+
u = m.hashType, l = v, p = I, ua(g, I, "verify"), f.push(r(g, v, m.signature));
|
|
10265
10268
|
}
|
|
10266
10269
|
return f.every((d) => d);
|
|
10267
10270
|
}
|
|
@@ -10278,22 +10281,22 @@ var Zl = class Mn {
|
|
|
10278
10281
|
u++;
|
|
10279
10282
|
}
|
|
10280
10283
|
if (a) for (const d of a) {
|
|
10281
|
-
const w = d.pubkey,
|
|
10282
|
-
if (
|
|
10283
|
-
if (!r(w,
|
|
10284
|
+
const w = d.pubkey, g = l.find((m) => x(w, m.pubkey));
|
|
10285
|
+
if (g) {
|
|
10286
|
+
if (!r(w, g.hash, this.#r.trimTaprootSig(d.signature))) return !1;
|
|
10284
10287
|
u++;
|
|
10285
10288
|
}
|
|
10286
10289
|
}
|
|
10287
10290
|
return u > 0;
|
|
10288
10291
|
}
|
|
10289
|
-
#u(t, r, n = [
|
|
10292
|
+
#u(t, r, n = [tt.SIGHASH_ALL]) {
|
|
10290
10293
|
const i = r.publicKey instanceof Uint8Array ? r.publicKey : new Uint8Array(r.publicKey), { hash: o, sighashType: a } = this.#r.getHashAndSighashType(this.data.inputs, t, i, n), f = r.sign(o), l = [{
|
|
10291
10294
|
pubkey: i,
|
|
10292
10295
|
signature: Ae.encode(f instanceof Uint8Array ? f : new Uint8Array(f), a)
|
|
10293
10296
|
}];
|
|
10294
10297
|
return this.data.updateInput(t, { partialSig: l }), this.#t.hasSignatures = !0, this;
|
|
10295
10298
|
}
|
|
10296
|
-
#c(t, r, n, i, o = [
|
|
10299
|
+
#c(t, r, n, i, o = [tt.SIGHASH_DEFAULT]) {
|
|
10297
10300
|
const a = n.publicKey instanceof Uint8Array ? n.publicKey : new Uint8Array(n.publicKey);
|
|
10298
10301
|
if (!("signSchnorr" in n) || typeof n.signSchnorr != "function") throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);
|
|
10299
10302
|
const f = this.checkTaprootHashesForSig(t, r, n, i, o), l = n.signSchnorr.bind(n), p = f.filter((d) => !d.leafHash).map((d) => Le(l(d.hash), r.sighashType))[0], u = f.filter((d) => !!d.leafHash).map((d) => ({
|
|
@@ -10303,14 +10306,14 @@ var Zl = class Mn {
|
|
|
10303
10306
|
}));
|
|
10304
10307
|
return p && (this.data.updateInput(t, { tapKeySig: p }), this.#t.hasSignatures = !0), u.length && (this.data.updateInput(t, { tapScriptSig: u }), this.#t.hasSignatures = !0), this;
|
|
10305
10308
|
}
|
|
10306
|
-
async #p(t, r, n = [
|
|
10309
|
+
async #p(t, r, n = [tt.SIGHASH_ALL]) {
|
|
10307
10310
|
const i = r.publicKey instanceof Uint8Array ? r.publicKey : new Uint8Array(r.publicKey), { hash: o, sighashType: a } = this.#r.getHashAndSighashType(this.data.inputs, t, i, n), f = await r.sign(o), l = f instanceof Uint8Array ? f : new Uint8Array(f), p = [{
|
|
10308
10311
|
pubkey: i,
|
|
10309
10312
|
signature: Ae.encode(l, a)
|
|
10310
10313
|
}];
|
|
10311
10314
|
this.data.updateInput(t, { partialSig: p }), this.#t.hasSignatures = !0;
|
|
10312
10315
|
}
|
|
10313
|
-
async #l(t, r, n, i, o = [
|
|
10316
|
+
async #l(t, r, n, i, o = [tt.SIGHASH_DEFAULT]) {
|
|
10314
10317
|
const a = n.publicKey instanceof Uint8Array ? n.publicKey : new Uint8Array(n.publicKey);
|
|
10315
10318
|
if (!("signSchnorr" in n) || typeof n.signSchnorr != "function") throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);
|
|
10316
10319
|
const f = this.checkTaprootHashesForSig(t, r, n, i, o), l = n.signSchnorr.bind(n), p = f.find((d) => !d.leafHash);
|
|
@@ -10321,18 +10324,17 @@ var Zl = class Mn {
|
|
|
10321
10324
|
const u = f.filter((d) => !!d.leafHash);
|
|
10322
10325
|
if (u.length) {
|
|
10323
10326
|
const d = await Promise.all(u.map(async (w) => {
|
|
10324
|
-
const
|
|
10327
|
+
const g = await l(w.hash);
|
|
10325
10328
|
return {
|
|
10326
10329
|
pubkey: Ce(a),
|
|
10327
|
-
signature: Le(
|
|
10330
|
+
signature: Le(g, r.sighashType),
|
|
10328
10331
|
leafHash: w.leafHash
|
|
10329
10332
|
};
|
|
10330
10333
|
}));
|
|
10331
10334
|
this.data.updateInput(t, { tapScriptSig: d }), this.#t.hasSignatures = !0;
|
|
10332
10335
|
}
|
|
10333
10336
|
}
|
|
10334
|
-
}
|
|
10335
|
-
var Ql = {
|
|
10337
|
+
}, Ql = {
|
|
10336
10338
|
networks: va,
|
|
10337
10339
|
address: Uf,
|
|
10338
10340
|
payments: Pf,
|
|
@@ -10366,7 +10368,7 @@ export {
|
|
|
10366
10368
|
Kl as g,
|
|
10367
10369
|
zl as h,
|
|
10368
10370
|
Uf as i,
|
|
10369
|
-
|
|
10371
|
+
tt as j,
|
|
10370
10372
|
Mt as k,
|
|
10371
10373
|
Yu as l,
|
|
10372
10374
|
De as m,
|