@gardenfi/core 0.2.0-beta.89 → 0.2.0-beta.90
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/dist/index.cjs +6 -6
- package/dist/index.js +184 -179
- package/dist/src/lib/garden/garden.types.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -700,17 +700,17 @@ class Ho extends Hi {
|
|
|
700
700
|
const { buffer: r, view: n, blockLen: i, isLE: a } = this;
|
|
701
701
|
let { pos: f } = this;
|
|
702
702
|
r[f++] = 128, this.buffer.subarray(f).fill(0), this.padOffset > i - f && (this.process(n, 0), f = 0);
|
|
703
|
-
for (let
|
|
704
|
-
r[
|
|
703
|
+
for (let g = f; g < i; g++)
|
|
704
|
+
r[g] = 0;
|
|
705
705
|
Mo(n, i - 8, BigInt(this.length * 8), a), this.process(n, 0);
|
|
706
706
|
const u = Dr(t), l = this.outputLen;
|
|
707
707
|
if (l % 4)
|
|
708
708
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
709
|
-
const b = l / 4,
|
|
710
|
-
if (b >
|
|
709
|
+
const b = l / 4, m = this.get();
|
|
710
|
+
if (b > m.length)
|
|
711
711
|
throw new Error("_sha2: outputLen bigger than state");
|
|
712
|
-
for (let
|
|
713
|
-
u.setUint32(4 *
|
|
712
|
+
for (let g = 0; g < b; g++)
|
|
713
|
+
u.setUint32(4 * g, m[g], a);
|
|
714
714
|
}
|
|
715
715
|
digest() {
|
|
716
716
|
const { buffer: t, outputLen: r } = this;
|
|
@@ -812,18 +812,18 @@ class Go extends Ho {
|
|
|
812
812
|
this.A = t | 0, this.B = r | 0, this.C = n | 0, this.D = i | 0, this.E = a | 0, this.F = f | 0, this.G = u | 0, this.H = l | 0;
|
|
813
813
|
}
|
|
814
814
|
process(t, r) {
|
|
815
|
-
for (let
|
|
816
|
-
Ye[
|
|
817
|
-
for (let
|
|
818
|
-
const v = Ye[
|
|
819
|
-
Ye[
|
|
815
|
+
for (let g = 0; g < 16; g++, r += 4)
|
|
816
|
+
Ye[g] = t.getUint32(r, !1);
|
|
817
|
+
for (let g = 16; g < 64; g++) {
|
|
818
|
+
const v = Ye[g - 15], I = Ye[g - 2], B = Le(v, 7) ^ Le(v, 18) ^ v >>> 3, P = Le(I, 17) ^ Le(I, 19) ^ I >>> 10;
|
|
819
|
+
Ye[g] = P + Ye[g - 7] + B + Ye[g - 16] | 0;
|
|
820
820
|
}
|
|
821
|
-
let { A: n, B: i, C: a, D: f, E: u, F: l, G: b, H:
|
|
822
|
-
for (let
|
|
823
|
-
const v = Le(u, 6) ^ Le(u, 11) ^ Le(u, 25), I =
|
|
824
|
-
|
|
821
|
+
let { A: n, B: i, C: a, D: f, E: u, F: l, G: b, H: m } = this;
|
|
822
|
+
for (let g = 0; g < 64; g++) {
|
|
823
|
+
const v = Le(u, 6) ^ Le(u, 11) ^ Le(u, 25), I = m + v + Do(u, l, b) + zo[g] + Ye[g] | 0, P = (Le(n, 2) ^ Le(n, 13) ^ Le(n, 22)) + $o(n, i, a) | 0;
|
|
824
|
+
m = b, b = l, l = u, u = f + I | 0, f = a, a = i, i = n, n = I + P | 0;
|
|
825
825
|
}
|
|
826
|
-
n = n + this.A | 0, i = i + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, u = u + this.E | 0, l = l + this.F | 0, b = b + this.G | 0,
|
|
826
|
+
n = n + this.A | 0, i = i + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, u = u + this.E | 0, l = l + this.F | 0, b = b + this.G | 0, m = m + this.H | 0, this.set(n, i, a, f, u, l, b, m);
|
|
827
827
|
}
|
|
828
828
|
roundClean() {
|
|
829
829
|
Ye.fill(0);
|
|
@@ -1031,14 +1031,14 @@ function da(e, t = 24) {
|
|
|
1031
1031
|
for (let f = 0; f < 10; f++)
|
|
1032
1032
|
r[f] = e[f] ^ e[f + 10] ^ e[f + 20] ^ e[f + 30] ^ e[f + 40];
|
|
1033
1033
|
for (let f = 0; f < 10; f += 2) {
|
|
1034
|
-
const u = (f + 8) % 10, l = (f + 2) % 10, b = r[l],
|
|
1034
|
+
const u = (f + 8) % 10, l = (f + 2) % 10, b = r[l], m = r[l + 1], g = Kn(b, m, 1) ^ r[u], v = Yn(b, m, 1) ^ r[u + 1];
|
|
1035
1035
|
for (let I = 0; I < 50; I += 10)
|
|
1036
|
-
e[f + I] ^=
|
|
1036
|
+
e[f + I] ^= g, e[f + I + 1] ^= v;
|
|
1037
1037
|
}
|
|
1038
1038
|
let i = e[2], a = e[3];
|
|
1039
1039
|
for (let f = 0; f < 24; f++) {
|
|
1040
|
-
const u = Ji[f], l = Kn(i, a, u), b = Yn(i, a, u),
|
|
1041
|
-
i = e[
|
|
1040
|
+
const u = Ji[f], l = Kn(i, a, u), b = Yn(i, a, u), m = Yi[f];
|
|
1041
|
+
i = e[m], a = e[m + 1], e[m] = l, e[m + 1] = b;
|
|
1042
1042
|
}
|
|
1043
1043
|
for (let f = 0; f < 50; f += 10) {
|
|
1044
1044
|
for (let u = 0; u < 10; u++)
|
|
@@ -1255,9 +1255,9 @@ function Aa(e, t) {
|
|
|
1255
1255
|
return r === "eip1559" ? Pa(e, t) : r === "eip2930" ? Ca(e, t) : r === "eip4844" ? Ta(e, t) : r === "eip7702" ? Ra(e, t) : ka(e, t);
|
|
1256
1256
|
}
|
|
1257
1257
|
function Ra(e, t) {
|
|
1258
|
-
const { authorizationList: r, chainId: n, gas: i, nonce: a, to: f, value: u, maxFeePerGas: l, maxPriorityFeePerGas: b, accessList:
|
|
1258
|
+
const { authorizationList: r, chainId: n, gas: i, nonce: a, to: f, value: u, maxFeePerGas: l, maxPriorityFeePerGas: b, accessList: m, data: g } = e;
|
|
1259
1259
|
va(e);
|
|
1260
|
-
const v = Ir(
|
|
1260
|
+
const v = Ir(m), I = Zo(r);
|
|
1261
1261
|
return Yt([
|
|
1262
1262
|
"0x04",
|
|
1263
1263
|
ft([
|
|
@@ -1268,7 +1268,7 @@ function Ra(e, t) {
|
|
|
1268
1268
|
i ? W(i) : "0x",
|
|
1269
1269
|
f ?? "0x",
|
|
1270
1270
|
u ? W(u) : "0x",
|
|
1271
|
-
|
|
1271
|
+
g ?? "0x",
|
|
1272
1272
|
v,
|
|
1273
1273
|
I,
|
|
1274
1274
|
...Jt(e, t)
|
|
@@ -1276,7 +1276,7 @@ function Ra(e, t) {
|
|
|
1276
1276
|
]);
|
|
1277
1277
|
}
|
|
1278
1278
|
function Ta(e, t) {
|
|
1279
|
-
const { chainId: r, gas: n, nonce: i, to: a, value: f, maxFeePerBlobGas: u, maxFeePerGas: l, maxPriorityFeePerGas: b, accessList:
|
|
1279
|
+
const { chainId: r, gas: n, nonce: i, to: a, value: f, maxFeePerBlobGas: u, maxFeePerGas: l, maxPriorityFeePerGas: b, accessList: m, data: g } = e;
|
|
1280
1280
|
Ea(e);
|
|
1281
1281
|
let v = e.blobVersionedHashes, I = e.sidecars;
|
|
1282
1282
|
if (e.blobs && (typeof v > "u" || typeof I > "u")) {
|
|
@@ -1291,7 +1291,7 @@ function Ta(e, t) {
|
|
|
1291
1291
|
I = Qo({ blobs: L, commitments: O, proofs: S });
|
|
1292
1292
|
}
|
|
1293
1293
|
}
|
|
1294
|
-
const B = Ir(
|
|
1294
|
+
const B = Ir(m), P = [
|
|
1295
1295
|
W(r),
|
|
1296
1296
|
i ? W(i) : "0x",
|
|
1297
1297
|
b ? W(b) : "0x",
|
|
@@ -1299,7 +1299,7 @@ function Ta(e, t) {
|
|
|
1299
1299
|
n ? W(n) : "0x",
|
|
1300
1300
|
a ?? "0x",
|
|
1301
1301
|
f ? W(f) : "0x",
|
|
1302
|
-
|
|
1302
|
+
g ?? "0x",
|
|
1303
1303
|
B,
|
|
1304
1304
|
u ? W(u) : "0x",
|
|
1305
1305
|
v ?? [],
|
|
@@ -1317,9 +1317,9 @@ function Ta(e, t) {
|
|
|
1317
1317
|
]);
|
|
1318
1318
|
}
|
|
1319
1319
|
function Pa(e, t) {
|
|
1320
|
-
const { chainId: r, gas: n, nonce: i, to: a, value: f, maxFeePerGas: u, maxPriorityFeePerGas: l, accessList: b, data:
|
|
1320
|
+
const { chainId: r, gas: n, nonce: i, to: a, value: f, maxFeePerGas: u, maxPriorityFeePerGas: l, accessList: b, data: m } = e;
|
|
1321
1321
|
Bn(e);
|
|
1322
|
-
const
|
|
1322
|
+
const g = Ir(b), v = [
|
|
1323
1323
|
W(r),
|
|
1324
1324
|
i ? W(i) : "0x",
|
|
1325
1325
|
l ? W(l) : "0x",
|
|
@@ -1327,8 +1327,8 @@ function Pa(e, t) {
|
|
|
1327
1327
|
n ? W(n) : "0x",
|
|
1328
1328
|
a ?? "0x",
|
|
1329
1329
|
f ? W(f) : "0x",
|
|
1330
|
-
|
|
1331
|
-
|
|
1330
|
+
m ?? "0x",
|
|
1331
|
+
g,
|
|
1332
1332
|
...Jt(e, t)
|
|
1333
1333
|
];
|
|
1334
1334
|
return Yt([
|
|
@@ -1339,7 +1339,7 @@ function Pa(e, t) {
|
|
|
1339
1339
|
function Ca(e, t) {
|
|
1340
1340
|
const { chainId: r, gas: n, data: i, nonce: a, to: f, value: u, accessList: l, gasPrice: b } = e;
|
|
1341
1341
|
Ba(e);
|
|
1342
|
-
const
|
|
1342
|
+
const m = Ir(l), g = [
|
|
1343
1343
|
W(r),
|
|
1344
1344
|
a ? W(a) : "0x",
|
|
1345
1345
|
b ? W(b) : "0x",
|
|
@@ -1347,12 +1347,12 @@ function Ca(e, t) {
|
|
|
1347
1347
|
f ?? "0x",
|
|
1348
1348
|
u ? W(u) : "0x",
|
|
1349
1349
|
i ?? "0x",
|
|
1350
|
-
|
|
1350
|
+
m,
|
|
1351
1351
|
...Jt(e, t)
|
|
1352
1352
|
];
|
|
1353
1353
|
return Yt([
|
|
1354
1354
|
"0x01",
|
|
1355
|
-
ft(
|
|
1355
|
+
ft(g)
|
|
1356
1356
|
]);
|
|
1357
1357
|
}
|
|
1358
1358
|
function ka(e, t) {
|
|
@@ -1367,7 +1367,7 @@ function ka(e, t) {
|
|
|
1367
1367
|
i ?? "0x"
|
|
1368
1368
|
];
|
|
1369
1369
|
if (t) {
|
|
1370
|
-
const
|
|
1370
|
+
const m = (() => {
|
|
1371
1371
|
if (t.v >= 35n)
|
|
1372
1372
|
return (t.v - 35n) / 2n > 0 ? t.v : 27n + (t.v === 35n ? 0n : 1n);
|
|
1373
1373
|
if (r > 0)
|
|
@@ -1376,11 +1376,11 @@ function ka(e, t) {
|
|
|
1376
1376
|
if (t.v !== I)
|
|
1377
1377
|
throw new Co({ v: t.v });
|
|
1378
1378
|
return I;
|
|
1379
|
-
})(),
|
|
1379
|
+
})(), g = dr(t.r), v = dr(t.s);
|
|
1380
1380
|
b = [
|
|
1381
1381
|
...b,
|
|
1382
|
-
W(
|
|
1383
|
-
|
|
1382
|
+
W(m),
|
|
1383
|
+
g === "0x00" ? "0x" : g,
|
|
1384
1384
|
v === "0x00" ? "0x" : v
|
|
1385
1385
|
];
|
|
1386
1386
|
} else r > 0 && (b = [
|
|
@@ -2255,13 +2255,13 @@ class rf {
|
|
|
2255
2255
|
address: cr(this.order.source_swap.asset),
|
|
2256
2256
|
abi: tf,
|
|
2257
2257
|
client: t
|
|
2258
|
-
}),
|
|
2258
|
+
}), m = await b.read.token(), g = await Xs(
|
|
2259
2259
|
Number(u),
|
|
2260
|
-
|
|
2260
|
+
m,
|
|
2261
2261
|
this.order.source_swap.asset,
|
|
2262
2262
|
t
|
|
2263
2263
|
);
|
|
2264
|
-
if (
|
|
2264
|
+
if (g.error) return N(g.error);
|
|
2265
2265
|
const v = await b.read.eip712Domain(), I = await t.signTypedData({
|
|
2266
2266
|
account: t.account,
|
|
2267
2267
|
domain: {
|
|
@@ -2433,12 +2433,12 @@ class mr {
|
|
|
2433
2433
|
if (this.utxoHashes && this.utxoHashes.length > 0)
|
|
2434
2434
|
for (const l of this.utxoHashes) {
|
|
2435
2435
|
const b = await a.getTransaction(l);
|
|
2436
|
-
for (let
|
|
2437
|
-
const
|
|
2438
|
-
|
|
2436
|
+
for (let m = 0; m < b.vout.length; m++) {
|
|
2437
|
+
const g = b.vout[m];
|
|
2438
|
+
g.scriptpubkey_address === i && f.push({
|
|
2439
2439
|
txid: b.txid,
|
|
2440
|
-
vout:
|
|
2441
|
-
value:
|
|
2440
|
+
vout: m,
|
|
2441
|
+
value: g.value,
|
|
2442
2442
|
status: { confirmed: !1 }
|
|
2443
2443
|
});
|
|
2444
2444
|
}
|
|
@@ -2482,16 +2482,16 @@ class mr {
|
|
|
2482
2482
|
async instantRefund(t, r) {
|
|
2483
2483
|
gt(t.length > 0, me.noCounterpartySigs);
|
|
2484
2484
|
const { tx: n, usedUtxos: i } = await this.buildRawTx(r);
|
|
2485
|
-
for (const
|
|
2486
|
-
if (!t.find((v) => v.utxo ===
|
|
2487
|
-
throw new Error(me.counterPartySigNotFound(
|
|
2485
|
+
for (const g of i)
|
|
2486
|
+
if (!t.find((v) => v.utxo === g.txid))
|
|
2487
|
+
throw new Error(me.counterPartySigNotFound(g.txid));
|
|
2488
2488
|
const a = this.getOutputScript(), f = fe.Transaction.SIGHASH_DEFAULT, u = this.leafHash(
|
|
2489
2489
|
2
|
|
2490
2490
|
/* INSTANT_REFUND */
|
|
2491
|
-
), l = i.map((
|
|
2492
|
-
for (let
|
|
2491
|
+
), l = i.map((g) => g.value), b = zr(a, i.length);
|
|
2492
|
+
for (let g = 0; g < n.ins.length; g++) {
|
|
2493
2493
|
const v = n.hashForWitnessV1(
|
|
2494
|
-
|
|
2494
|
+
g,
|
|
2495
2495
|
b,
|
|
2496
2496
|
l,
|
|
2497
2497
|
f,
|
|
@@ -2500,15 +2500,15 @@ class mr {
|
|
|
2500
2500
|
if (!ot.verifySchnorr(
|
|
2501
2501
|
v,
|
|
2502
2502
|
Buffer.from(this.redeemerPubkey, "hex"),
|
|
2503
|
-
Buffer.from(t[
|
|
2503
|
+
Buffer.from(t[g].sig, "hex")
|
|
2504
2504
|
))
|
|
2505
2505
|
throw new Error(
|
|
2506
|
-
me.invalidCounterpartySigForUTXO(t[
|
|
2506
|
+
me.invalidCounterpartySigForUTXO(t[g].utxo)
|
|
2507
2507
|
);
|
|
2508
|
-
const I = await this.signer.signSchnorr(v), B = Buffer.from(n.ins[
|
|
2508
|
+
const I = await this.signer.signSchnorr(v), B = Buffer.from(n.ins[g].hash).reverse().toString("hex"), P = t.find((T) => T.utxo === B);
|
|
2509
2509
|
if (!P)
|
|
2510
2510
|
throw new Error(me.counterPartySigNotFound(B));
|
|
2511
|
-
n.setWitness(
|
|
2511
|
+
n.setWitness(g, [
|
|
2512
2512
|
Buffer.from(P.sig, "hex"),
|
|
2513
2513
|
I,
|
|
2514
2514
|
this.instantRefundLeaf(),
|
|
@@ -2534,16 +2534,16 @@ class mr {
|
|
|
2534
2534
|
), f = this.leafHash(
|
|
2535
2535
|
1
|
|
2536
2536
|
/* REDEEM */
|
|
2537
|
-
), u = a.map((
|
|
2538
|
-
for (let
|
|
2537
|
+
), u = a.map((g) => g.value), l = zr(this.getOutputScript(), a.length), b = fe.Transaction.SIGHASH_DEFAULT;
|
|
2538
|
+
for (let g = 0; g < i.ins.length; g++) {
|
|
2539
2539
|
const v = i.hashForWitnessV1(
|
|
2540
|
-
|
|
2540
|
+
g,
|
|
2541
2541
|
l,
|
|
2542
2542
|
u,
|
|
2543
2543
|
b,
|
|
2544
2544
|
f
|
|
2545
2545
|
), I = await this.signer.signSchnorr(v);
|
|
2546
|
-
i.setWitness(
|
|
2546
|
+
i.setWitness(g, [
|
|
2547
2547
|
I,
|
|
2548
2548
|
Buffer.from(t, "hex"),
|
|
2549
2549
|
this.redeemLeaf(),
|
|
@@ -2568,14 +2568,14 @@ class mr {
|
|
|
2568
2568
|
const u = this.leafHash(
|
|
2569
2569
|
0
|
|
2570
2570
|
/* REFUND */
|
|
2571
|
-
), l = i.map((v) => v.value), b = zr(this.getOutputScript(), i.length),
|
|
2571
|
+
), l = i.map((v) => v.value), b = zr(this.getOutputScript(), i.length), m = fe.Transaction.SIGHASH_DEFAULT;
|
|
2572
2572
|
for (let v = 0; v < n.ins.length; v++) {
|
|
2573
2573
|
n.ins[v].sequence = this.expiry;
|
|
2574
2574
|
const I = n.hashForWitnessV1(
|
|
2575
2575
|
v,
|
|
2576
2576
|
b,
|
|
2577
2577
|
l,
|
|
2578
|
-
|
|
2578
|
+
m,
|
|
2579
2579
|
u
|
|
2580
2580
|
), B = await this.signer.signSchnorr(I);
|
|
2581
2581
|
n.setWitness(v, [
|
|
@@ -2771,16 +2771,21 @@ class Bl {
|
|
|
2771
2771
|
async swap(t) {
|
|
2772
2772
|
const r = await this.validateAndFillParams(t);
|
|
2773
2773
|
if (r.error) return N(r.error);
|
|
2774
|
-
const { sendAddress: n, receiveAddress: i, timelock: a } = r.val
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2774
|
+
const { sendAddress: n, receiveAddress: i, timelock: a } = r.val;
|
|
2775
|
+
let f = t.nonce;
|
|
2776
|
+
if (!f) {
|
|
2777
|
+
const P = await this.orderBook.getOrdersCount(this.evmAddress);
|
|
2778
|
+
if (P.error) return N(P.error);
|
|
2779
|
+
f = P.val + 1;
|
|
2780
|
+
}
|
|
2781
|
+
const u = this.secretManager.generateSecret(f);
|
|
2782
|
+
if (u.error) return N(u.error);
|
|
2783
|
+
const { strategyId: l, btcAddress: b } = t.additionalData, m = {
|
|
2784
|
+
strategy_id: l,
|
|
2785
|
+
...b && {
|
|
2786
|
+
bitcoin_optional_recipient: b
|
|
2782
2787
|
}
|
|
2783
|
-
},
|
|
2788
|
+
}, g = {
|
|
2784
2789
|
source_chain: t.fromAsset.chain,
|
|
2785
2790
|
destination_chain: t.toAsset.chain,
|
|
2786
2791
|
source_asset: t.fromAsset.atomicSwapAddress,
|
|
@@ -2790,17 +2795,17 @@ class Bl {
|
|
|
2790
2795
|
source_amount: t.sendAmount,
|
|
2791
2796
|
destination_amount: t.receiveAmount,
|
|
2792
2797
|
fee: "1",
|
|
2793
|
-
nonce:
|
|
2798
|
+
nonce: f.toString(),
|
|
2794
2799
|
timelock: a,
|
|
2795
|
-
secret_hash: it(
|
|
2800
|
+
secret_hash: it(u.val.secretHash),
|
|
2796
2801
|
min_destination_confirmations: t.minDestinationConfirmations ?? 0,
|
|
2797
2802
|
additional_data: m
|
|
2798
|
-
},
|
|
2803
|
+
}, v = await this.quote.getAttestedQuote(g);
|
|
2804
|
+
if (v.error) return N(v.error);
|
|
2805
|
+
const I = await this.orderBook.createOrder(v.val);
|
|
2799
2806
|
if (I.error) return N(I.error);
|
|
2800
|
-
const B = await this.
|
|
2801
|
-
|
|
2802
|
-
const P = await this.pollOrder(B.val);
|
|
2803
|
-
return P.error ? N(P.error) : ue(P.val);
|
|
2807
|
+
const B = await this.pollOrder(I.val);
|
|
2808
|
+
return B.error ? N(B.error) : ue(B.val);
|
|
2804
2809
|
}
|
|
2805
2810
|
async validateAndFillParams(t) {
|
|
2806
2811
|
if (t.fromAsset.chain === t.toAsset.chain && t.fromAsset.atomicSwapAddress === t.toAsset.atomicSwapAddress)
|
|
@@ -2992,13 +2997,13 @@ class Bl {
|
|
|
2992
2997
|
else if (r.destination_swap.redeem_tx_hash && !Number(r.destination_swap.redeem_block_number))
|
|
2993
2998
|
try {
|
|
2994
2999
|
const b = await (await t.getProvider()).getTransaction(r.destination_swap.redeem_tx_hash);
|
|
2995
|
-
let
|
|
2996
|
-
for (const
|
|
2997
|
-
if (
|
|
2998
|
-
|
|
3000
|
+
let m = !1;
|
|
3001
|
+
for (const g of b.vin)
|
|
3002
|
+
if (g.txid === a) {
|
|
3003
|
+
m = !0;
|
|
2999
3004
|
break;
|
|
3000
3005
|
}
|
|
3001
|
-
if (
|
|
3006
|
+
if (m) {
|
|
3002
3007
|
this.orderExecutorCache.set(
|
|
3003
3008
|
r,
|
|
3004
3009
|
le.Redeem,
|
|
@@ -3022,7 +3027,7 @@ class Bl {
|
|
|
3022
3027
|
}
|
|
3023
3028
|
this.emit("log", r.create_order.create_id, "executing btc redeem");
|
|
3024
3029
|
try {
|
|
3025
|
-
const
|
|
3030
|
+
const m = await (await mr.from(
|
|
3026
3031
|
t,
|
|
3027
3032
|
Number(r.destination_swap.amount),
|
|
3028
3033
|
r.create_order.secret_hash,
|
|
@@ -3038,7 +3043,7 @@ class Bl {
|
|
|
3038
3043
|
"log",
|
|
3039
3044
|
r.create_order.create_id,
|
|
3040
3045
|
"rbf: btc redeem success"
|
|
3041
|
-
) : this.emit("success", r, le.Redeem,
|
|
3046
|
+
) : this.emit("success", r, le.Redeem, m), this.orderExecutorCache.set(r, le.Redeem, m, a);
|
|
3042
3047
|
} catch (b) {
|
|
3043
3048
|
this.emit("error", r, "Failed btc redeem: " + b);
|
|
3044
3049
|
}
|
|
@@ -3106,8 +3111,8 @@ class Bl {
|
|
|
3106
3111
|
var i;
|
|
3107
3112
|
const r = await ((i = this.blockNumberFetcher) == null ? void 0 : i.fetchBlockNumbers()), n = [];
|
|
3108
3113
|
for (let a = 0; a < t.length; a++) {
|
|
3109
|
-
const f = t[a], u = f.source_swap.chain, l = f.destination_swap.chain, b = this.getWallet(u),
|
|
3110
|
-
if (b.error ||
|
|
3114
|
+
const f = t[a], u = f.source_swap.chain, l = f.destination_swap.chain, b = this.getWallet(u), m = this.getWallet(l);
|
|
3115
|
+
if (b.error || m.error || !b.val || !m.val) {
|
|
3111
3116
|
this.emit(
|
|
3112
3117
|
"error",
|
|
3113
3118
|
f,
|
|
@@ -3115,11 +3120,11 @@ class Bl {
|
|
|
3115
3120
|
);
|
|
3116
3121
|
continue;
|
|
3117
3122
|
}
|
|
3118
|
-
let
|
|
3119
|
-
if (!
|
|
3123
|
+
let g = r == null ? void 0 : r.val[u], v = r == null ? void 0 : r.val[l];
|
|
3124
|
+
if (!g || !v) {
|
|
3120
3125
|
const B = await this.fetchCurrentBlockNumbers(f, {
|
|
3121
3126
|
source: b.val,
|
|
3122
|
-
destination:
|
|
3127
|
+
destination: m.val
|
|
3123
3128
|
});
|
|
3124
3129
|
if (B.error) {
|
|
3125
3130
|
this.emit(
|
|
@@ -3129,11 +3134,11 @@ class Bl {
|
|
|
3129
3134
|
);
|
|
3130
3135
|
continue;
|
|
3131
3136
|
}
|
|
3132
|
-
|
|
3137
|
+
g = B.val.source, v = B.val.destination;
|
|
3133
3138
|
}
|
|
3134
3139
|
const I = Zi(
|
|
3135
3140
|
f,
|
|
3136
|
-
|
|
3141
|
+
g,
|
|
3137
3142
|
v
|
|
3138
3143
|
);
|
|
3139
3144
|
n.push({
|
|
@@ -3329,8 +3334,8 @@ function yf() {
|
|
|
3329
3334
|
return `${M.toJSON()} between [${S}, ${z}]`;
|
|
3330
3335
|
}, $;
|
|
3331
3336
|
}
|
|
3332
|
-
var
|
|
3333
|
-
function
|
|
3337
|
+
var m = Math.pow(2, 53) - 1;
|
|
3338
|
+
function g(S) {
|
|
3334
3339
|
return typeof S == "number" && isFinite(S);
|
|
3335
3340
|
}
|
|
3336
3341
|
function v(S) {
|
|
@@ -3343,7 +3348,7 @@ function yf() {
|
|
|
3343
3348
|
return (S | 0) === S;
|
|
3344
3349
|
}
|
|
3345
3350
|
function P(S) {
|
|
3346
|
-
return typeof S == "number" && S >= -
|
|
3351
|
+
return typeof S == "number" && S >= -m && S <= m && Math.floor(S) === S;
|
|
3347
3352
|
}
|
|
3348
3353
|
function T(S) {
|
|
3349
3354
|
return (S & 255) === S;
|
|
@@ -3355,13 +3360,13 @@ function yf() {
|
|
|
3355
3360
|
return S >>> 0 === S;
|
|
3356
3361
|
}
|
|
3357
3362
|
function L(S) {
|
|
3358
|
-
return typeof S == "number" && S >= 0 && S <=
|
|
3363
|
+
return typeof S == "number" && S >= 0 && S <= m && Math.floor(S) === S;
|
|
3359
3364
|
}
|
|
3360
3365
|
var k = {
|
|
3361
3366
|
ArrayN: a,
|
|
3362
3367
|
Buffer: r,
|
|
3363
3368
|
BufferN: f,
|
|
3364
|
-
Finite:
|
|
3369
|
+
Finite: g,
|
|
3365
3370
|
Hex: n,
|
|
3366
3371
|
HexN: u,
|
|
3367
3372
|
Int8: v,
|
|
@@ -3444,8 +3449,8 @@ var Xt = ss, he = Sn, Me = Xt.tfJSON, os = Xt.TfTypeError, as = Xt.TfPropertyTyp
|
|
|
3444
3449
|
var l = r[u], b = a[u];
|
|
3445
3450
|
we(l, b, f);
|
|
3446
3451
|
}
|
|
3447
|
-
} catch (
|
|
3448
|
-
throw Dt(
|
|
3452
|
+
} catch (m) {
|
|
3453
|
+
throw Dt(m, u);
|
|
3449
3454
|
}
|
|
3450
3455
|
if (f) {
|
|
3451
3456
|
for (u in a)
|
|
@@ -3618,10 +3623,10 @@ function If(e) {
|
|
|
3618
3623
|
var Rn = {};
|
|
3619
3624
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3620
3625
|
Rn.read = function(e, t, r, n, i) {
|
|
3621
|
-
var a, f, u = i * 8 - n - 1, l = (1 << u) - 1, b = l >> 1,
|
|
3622
|
-
for (
|
|
3626
|
+
var a, f, u = i * 8 - n - 1, l = (1 << u) - 1, b = l >> 1, m = -7, g = r ? i - 1 : 0, v = r ? -1 : 1, I = e[t + g];
|
|
3627
|
+
for (g += v, a = I & (1 << -m) - 1, I >>= -m, m += u; m > 0; a = a * 256 + e[t + g], g += v, m -= 8)
|
|
3623
3628
|
;
|
|
3624
|
-
for (f = a & (1 << -
|
|
3629
|
+
for (f = a & (1 << -m) - 1, a >>= -m, m += n; m > 0; f = f * 256 + e[t + g], g += v, m -= 8)
|
|
3625
3630
|
;
|
|
3626
3631
|
if (a === 0)
|
|
3627
3632
|
a = 1 - b;
|
|
@@ -3633,8 +3638,8 @@ Rn.read = function(e, t, r, n, i) {
|
|
|
3633
3638
|
return (I ? -1 : 1) * f * Math.pow(2, a - n);
|
|
3634
3639
|
};
|
|
3635
3640
|
Rn.write = function(e, t, r, n, i, a) {
|
|
3636
|
-
var f, u, l, b = a * 8 - i - 1,
|
|
3637
|
-
for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (u = isNaN(t) ? 1 : 0, f =
|
|
3641
|
+
var f, u, l, b = a * 8 - i - 1, m = (1 << b) - 1, g = m >> 1, v = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, I = n ? 0 : a - 1, B = n ? 1 : -1, P = t < 0 || t === 0 && 1 / t < 0 ? 1 : 0;
|
|
3642
|
+
for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (u = isNaN(t) ? 1 : 0, f = m) : (f = Math.floor(Math.log(t) / Math.LN2), t * (l = Math.pow(2, -f)) < 1 && (f--, l *= 2), f + g >= 1 ? t += v / l : t += v * Math.pow(2, 1 - g), t * l >= 2 && (f++, l /= 2), f + g >= m ? (u = 0, f = m) : f + g >= 1 ? (u = (t * l - 1) * Math.pow(2, i), f = f + g) : (u = t * Math.pow(2, g - 1) * Math.pow(2, i), f = 0)); i >= 8; e[r + I] = u & 255, I += B, u /= 256, i -= 8)
|
|
3638
3643
|
;
|
|
3639
3644
|
for (f = f << i | u, b += i; b > 0; e[r + I] = f & 255, I += B, f /= 256, b -= 8)
|
|
3640
3645
|
;
|
|
@@ -3688,7 +3693,7 @@ Rn.write = function(e, t, r, n, i, a) {
|
|
|
3688
3693
|
throw new TypeError(
|
|
3689
3694
|
'The "string" argument must be of type string. Received type number'
|
|
3690
3695
|
);
|
|
3691
|
-
return
|
|
3696
|
+
return g(c);
|
|
3692
3697
|
}
|
|
3693
3698
|
return l(c, s, o);
|
|
3694
3699
|
}
|
|
@@ -3728,19 +3733,19 @@ Rn.write = function(e, t, r, n, i, a) {
|
|
|
3728
3733
|
if (c < 0)
|
|
3729
3734
|
throw new RangeError('The value "' + c + '" is invalid for option "size"');
|
|
3730
3735
|
}
|
|
3731
|
-
function
|
|
3736
|
+
function m(c, s, o) {
|
|
3732
3737
|
return b(c), c <= 0 ? f(c) : s !== void 0 ? typeof o == "string" ? f(c).fill(s, o) : f(c).fill(s) : f(c);
|
|
3733
3738
|
}
|
|
3734
3739
|
u.alloc = function(c, s, o) {
|
|
3735
|
-
return
|
|
3740
|
+
return m(c, s, o);
|
|
3736
3741
|
};
|
|
3737
|
-
function
|
|
3742
|
+
function g(c) {
|
|
3738
3743
|
return b(c), f(c < 0 ? 0 : C(c) | 0);
|
|
3739
3744
|
}
|
|
3740
3745
|
u.allocUnsafe = function(c) {
|
|
3741
|
-
return
|
|
3746
|
+
return g(c);
|
|
3742
3747
|
}, u.allocUnsafeSlow = function(c) {
|
|
3743
|
-
return
|
|
3748
|
+
return g(c);
|
|
3744
3749
|
};
|
|
3745
3750
|
function v(c, s) {
|
|
3746
3751
|
if ((typeof s != "string" || s === "") && (s = "utf8"), !u.isEncoding(s))
|
|
@@ -4725,8 +4730,8 @@ K.prototype.emit = function(t) {
|
|
|
4725
4730
|
if (typeof l == "function")
|
|
4726
4731
|
ti(l, this, r);
|
|
4727
4732
|
else
|
|
4728
|
-
for (var b = l.length,
|
|
4729
|
-
ti(
|
|
4733
|
+
for (var b = l.length, m = bs(l, b), n = 0; n < b; ++n)
|
|
4734
|
+
ti(m[n], this, r);
|
|
4730
4735
|
return !0;
|
|
4731
4736
|
};
|
|
4732
4737
|
function ls(e, t, r, n) {
|
|
@@ -4935,7 +4940,7 @@ function $f() {
|
|
|
4935
4940
|
}
|
|
4936
4941
|
return (P === "string" ? String : Number)(B);
|
|
4937
4942
|
}
|
|
4938
|
-
var l = Pt, b = l.Buffer,
|
|
4943
|
+
var l = Pt, b = l.Buffer, m = Pn, g = m.inspect, v = g && g.custom || "inspect";
|
|
4939
4944
|
function I(B, P, T) {
|
|
4940
4945
|
b.prototype.copy.call(B, P, T);
|
|
4941
4946
|
}
|
|
@@ -5035,7 +5040,7 @@ function $f() {
|
|
|
5035
5040
|
}, {
|
|
5036
5041
|
key: v,
|
|
5037
5042
|
value: function(T, C) {
|
|
5038
|
-
return
|
|
5043
|
+
return g(this, t(t({}, C), {}, {
|
|
5039
5044
|
// Only inspect one level.
|
|
5040
5045
|
depth: 0,
|
|
5041
5046
|
// It should not recurse.
|
|
@@ -5203,12 +5208,12 @@ function vs() {
|
|
|
5203
5208
|
function u(w) {
|
|
5204
5209
|
return i.isBuffer(w) || w instanceof a;
|
|
5205
5210
|
}
|
|
5206
|
-
var l = _s, b = xs,
|
|
5211
|
+
var l = _s, b = xs, m = b.getHighWaterMark, g = ht.codes, v = g.ERR_INVALID_ARG_TYPE, I = g.ERR_METHOD_NOT_IMPLEMENTED, B = g.ERR_MULTIPLE_CALLBACK, P = g.ERR_STREAM_CANNOT_PIPE, T = g.ERR_STREAM_DESTROYED, C = g.ERR_STREAM_NULL_VALUES, F = g.ERR_STREAM_WRITE_AFTER_END, L = g.ERR_UNKNOWN_ENCODING, k = l.errorOrDestroy;
|
|
5207
5212
|
de(M, n);
|
|
5208
5213
|
function O() {
|
|
5209
5214
|
}
|
|
5210
5215
|
function S(w, _, R) {
|
|
5211
|
-
t = t || It(), w = w || {}, typeof R != "boolean" && (R = _ instanceof t), this.objectMode = !!w.objectMode, R && (this.objectMode = this.objectMode || !!w.writableObjectMode), this.highWaterMark =
|
|
5216
|
+
t = t || It(), w = w || {}, typeof R != "boolean" && (R = _ instanceof t), this.objectMode = !!w.objectMode, R && (this.objectMode = this.objectMode || !!w.writableObjectMode), this.highWaterMark = m(this, w, "writableHighWaterMark", R), this.finalCalled = !1, this.needDrain = !1, this.ending = !1, this.ended = !1, this.finished = !1, this.destroyed = !1;
|
|
5212
5217
|
var D = w.decodeStrings === !1;
|
|
5213
5218
|
this.decodeStrings = !D, this.defaultEncoding = w.defaultEncoding || "utf8", this.length = 0, this.writing = !1, this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(G) {
|
|
5214
5219
|
tt(_, G);
|
|
@@ -5413,9 +5418,9 @@ function It() {
|
|
|
5413
5418
|
if (ai) return Yr;
|
|
5414
5419
|
ai = 1;
|
|
5415
5420
|
var e = Object.keys || function(b) {
|
|
5416
|
-
var
|
|
5417
|
-
for (var
|
|
5418
|
-
return
|
|
5421
|
+
var m = [];
|
|
5422
|
+
for (var g in b) m.push(g);
|
|
5423
|
+
return m;
|
|
5419
5424
|
};
|
|
5420
5425
|
Yr = f;
|
|
5421
5426
|
var t = Bs(), r = vs();
|
|
@@ -5467,8 +5472,8 @@ function It() {
|
|
|
5467
5472
|
get: function() {
|
|
5468
5473
|
return this._readableState === void 0 || this._writableState === void 0 ? !1 : this._readableState.destroyed && this._writableState.destroyed;
|
|
5469
5474
|
},
|
|
5470
|
-
set: function(
|
|
5471
|
-
this._readableState === void 0 || this._writableState === void 0 || (this._readableState.destroyed =
|
|
5475
|
+
set: function(m) {
|
|
5476
|
+
this._readableState === void 0 || this._writableState === void 0 || (this._readableState.destroyed = m, this._writableState.destroyed = m);
|
|
5472
5477
|
}
|
|
5473
5478
|
}), Yr;
|
|
5474
5479
|
}
|
|
@@ -5653,9 +5658,9 @@ function Es(e, t, r) {
|
|
|
5653
5658
|
i = !1, f = !0, n || r.call(e);
|
|
5654
5659
|
}, l = e._readableState && e._readableState.endEmitted, b = function() {
|
|
5655
5660
|
n = !1, l = !0, i || r.call(e);
|
|
5656
|
-
},
|
|
5661
|
+
}, m = function(B) {
|
|
5657
5662
|
r.call(e, B);
|
|
5658
|
-
},
|
|
5663
|
+
}, g = function() {
|
|
5659
5664
|
var B;
|
|
5660
5665
|
if (n && !l)
|
|
5661
5666
|
return (!e._readableState || !e._readableState.ended) && (B = new ui()), r.call(e, B);
|
|
@@ -5664,8 +5669,8 @@ function Es(e, t, r) {
|
|
|
5664
5669
|
}, v = function() {
|
|
5665
5670
|
e.req.on("finish", u);
|
|
5666
5671
|
};
|
|
5667
|
-
return pu(e) ? (e.on("complete", u), e.on("abort",
|
|
5668
|
-
e.removeListener("complete", u), e.removeListener("abort",
|
|
5672
|
+
return pu(e) ? (e.on("complete", u), e.on("abort", g), e.req ? v() : e.on("request", v)) : i && !e._writableState && (e.on("end", a), e.on("close", a)), e.on("end", b), e.on("finish", u), t.error !== !1 && e.on("error", m), e.on("close", g), function() {
|
|
5673
|
+
e.removeListener("complete", u), e.removeListener("abort", g), e.removeListener("request", v), e.req && e.req.removeListener("finish", u), e.removeListener("end", a), e.removeListener("close", a), e.removeListener("finish", u), e.removeListener("end", b), e.removeListener("error", m), e.removeListener("close", g);
|
|
5669
5674
|
};
|
|
5670
5675
|
}
|
|
5671
5676
|
var kn = Es, Xr, ci;
|
|
@@ -5690,7 +5695,7 @@ function bu() {
|
|
|
5690
5695
|
}
|
|
5691
5696
|
return (k === "string" ? String : Number)(L);
|
|
5692
5697
|
}
|
|
5693
|
-
var i = kn, a = Symbol("lastResolve"), f = Symbol("lastReject"), u = Symbol("error"), l = Symbol("ended"), b = Symbol("lastPromise"),
|
|
5698
|
+
var i = kn, a = Symbol("lastResolve"), f = Symbol("lastReject"), u = Symbol("error"), l = Symbol("ended"), b = Symbol("lastPromise"), m = Symbol("handlePromise"), g = Symbol("stream");
|
|
5694
5699
|
function v(L, k) {
|
|
5695
5700
|
return {
|
|
5696
5701
|
value: L,
|
|
@@ -5700,7 +5705,7 @@ function bu() {
|
|
|
5700
5705
|
function I(L) {
|
|
5701
5706
|
var k = L[a];
|
|
5702
5707
|
if (k !== null) {
|
|
5703
|
-
var O = L[
|
|
5708
|
+
var O = L[g].read();
|
|
5704
5709
|
O !== null && (L[b] = null, L[a] = null, L[f] = null, k(v(O, !1)));
|
|
5705
5710
|
}
|
|
5706
5711
|
}
|
|
@@ -5714,14 +5719,14 @@ function bu() {
|
|
|
5714
5719
|
O(v(void 0, !0));
|
|
5715
5720
|
return;
|
|
5716
5721
|
}
|
|
5717
|
-
k[
|
|
5722
|
+
k[m](O, S);
|
|
5718
5723
|
}, S);
|
|
5719
5724
|
};
|
|
5720
5725
|
}
|
|
5721
5726
|
var T = Object.getPrototypeOf(function() {
|
|
5722
5727
|
}), C = Object.setPrototypeOf((e = {
|
|
5723
5728
|
get stream() {
|
|
5724
|
-
return this[
|
|
5729
|
+
return this[g];
|
|
5725
5730
|
},
|
|
5726
5731
|
next: function() {
|
|
5727
5732
|
var k = this, O = this[u];
|
|
@@ -5729,7 +5734,7 @@ function bu() {
|
|
|
5729
5734
|
return Promise.reject(O);
|
|
5730
5735
|
if (this[l])
|
|
5731
5736
|
return Promise.resolve(v(void 0, !0));
|
|
5732
|
-
if (this[
|
|
5737
|
+
if (this[g].destroyed)
|
|
5733
5738
|
return new Promise(function($, se) {
|
|
5734
5739
|
process.nextTick(function() {
|
|
5735
5740
|
k[u] ? se(k[u]) : $(v(void 0, !0));
|
|
@@ -5739,10 +5744,10 @@ function bu() {
|
|
|
5739
5744
|
if (S)
|
|
5740
5745
|
z = new Promise(P(S, this));
|
|
5741
5746
|
else {
|
|
5742
|
-
var M = this[
|
|
5747
|
+
var M = this[g].read();
|
|
5743
5748
|
if (M !== null)
|
|
5744
5749
|
return Promise.resolve(v(M, !1));
|
|
5745
|
-
z = new Promise(this[
|
|
5750
|
+
z = new Promise(this[m]);
|
|
5746
5751
|
}
|
|
5747
5752
|
return this[b] = z, z;
|
|
5748
5753
|
}
|
|
@@ -5751,7 +5756,7 @@ function bu() {
|
|
|
5751
5756
|
}), t(e, "return", function() {
|
|
5752
5757
|
var k = this;
|
|
5753
5758
|
return new Promise(function(O, S) {
|
|
5754
|
-
k[
|
|
5759
|
+
k[g].destroy(null, function(z) {
|
|
5755
5760
|
if (z) {
|
|
5756
5761
|
S(z);
|
|
5757
5762
|
return;
|
|
@@ -5760,7 +5765,7 @@ function bu() {
|
|
|
5760
5765
|
});
|
|
5761
5766
|
});
|
|
5762
5767
|
}), e), T), F = function(k) {
|
|
5763
|
-
var O, S = Object.create(C, (O = {}, t(O,
|
|
5768
|
+
var O, S = Object.create(C, (O = {}, t(O, g, {
|
|
5764
5769
|
value: k,
|
|
5765
5770
|
writable: !0
|
|
5766
5771
|
}), t(O, a, {
|
|
@@ -5775,9 +5780,9 @@ function bu() {
|
|
|
5775
5780
|
}), t(O, l, {
|
|
5776
5781
|
value: k._readableState.endEmitted,
|
|
5777
5782
|
writable: !0
|
|
5778
|
-
}), t(O,
|
|
5783
|
+
}), t(O, m, {
|
|
5779
5784
|
value: function(M, $) {
|
|
5780
|
-
var se = S[
|
|
5785
|
+
var se = S[g].read();
|
|
5781
5786
|
se ? (S[b] = null, S[a] = null, S[f] = null, M(v(se, !1))) : (S[a] = M, S[f] = $);
|
|
5782
5787
|
},
|
|
5783
5788
|
writable: !0
|
|
@@ -5819,9 +5824,9 @@ function Bs() {
|
|
|
5819
5824
|
var u = Pn, l;
|
|
5820
5825
|
u && u.debuglog ? l = u.debuglog("stream") : l = function() {
|
|
5821
5826
|
};
|
|
5822
|
-
var b = $f(),
|
|
5827
|
+
var b = $f(), m = _s, g = xs, v = g.getHighWaterMark, I = ht.codes, B = I.ERR_INVALID_ARG_TYPE, P = I.ERR_STREAM_PUSH_AFTER_EOF, T = I.ERR_METHOD_NOT_IMPLEMENTED, C = I.ERR_STREAM_UNSHIFT_AFTER_END_EVENT, F, L, k;
|
|
5823
5828
|
de($, r);
|
|
5824
|
-
var O =
|
|
5829
|
+
var O = m.errorOrDestroy, S = ["error", "close", "destroy", "pause", "resume"];
|
|
5825
5830
|
function z(d, p, A) {
|
|
5826
5831
|
if (typeof d.prependListener == "function") return d.prependListener(p, A);
|
|
5827
5832
|
!d._events || !d._events[p] ? d.on(p, A) : Array.isArray(d._events[p]) ? d._events[p].unshift(A) : d._events[p] = [A, d._events[p]];
|
|
@@ -5845,7 +5850,7 @@ function Bs() {
|
|
|
5845
5850
|
set: function(p) {
|
|
5846
5851
|
this._readableState && (this._readableState.destroyed = p);
|
|
5847
5852
|
}
|
|
5848
|
-
}), $.prototype.destroy =
|
|
5853
|
+
}), $.prototype.destroy = m.destroy, $.prototype._undestroy = m.undestroy, $.prototype._destroy = function(d, p) {
|
|
5849
5854
|
p(d);
|
|
5850
5855
|
}, $.prototype.push = function(d, p) {
|
|
5851
5856
|
var A = this._readableState, U;
|
|
@@ -6256,8 +6261,8 @@ function Cu() {
|
|
|
6256
6261
|
throw new Su("streams");
|
|
6257
6262
|
var i, a = t.map(function(f, u) {
|
|
6258
6263
|
var l = u < t.length - 1, b = u > 0;
|
|
6259
|
-
return Ru(f, l, b, function(
|
|
6260
|
-
i || (i =
|
|
6264
|
+
return Ru(f, l, b, function(m) {
|
|
6265
|
+
i || (i = m), m && a.forEach(bi), !l && (a.forEach(bi), n(i));
|
|
6261
6266
|
});
|
|
6262
6267
|
});
|
|
6263
6268
|
return t.reduce(Tu);
|
|
@@ -6733,12 +6738,12 @@ function Lr() {
|
|
|
6733
6738
|
Gu(Lr, ks);
|
|
6734
6739
|
Lr.prototype._update = function() {
|
|
6735
6740
|
for (var e = ju, t = 0; t < 16; ++t) e[t] = this._block.readInt32LE(t * 4);
|
|
6736
|
-
for (var r = this._a | 0, n = this._b | 0, i = this._c | 0, a = this._d | 0, f = this._e | 0, u = this._a | 0, l = this._b | 0, b = this._c | 0,
|
|
6741
|
+
for (var r = this._a | 0, n = this._b | 0, i = this._c | 0, a = this._d | 0, f = this._e | 0, u = this._a | 0, l = this._b | 0, b = this._c | 0, m = this._d | 0, g = this._e | 0, v = 0; v < 80; v += 1) {
|
|
6737
6742
|
var I, B;
|
|
6738
|
-
v < 16 ? (I = yi(r, n, i, a, f, e[$t[v]], jt[0], zt[v]), B = wi(u, l, b,
|
|
6743
|
+
v < 16 ? (I = yi(r, n, i, a, f, e[$t[v]], jt[0], zt[v]), B = wi(u, l, b, m, g, e[Ht[v]], Wt[0], Gt[v])) : v < 32 ? (I = gi(r, n, i, a, f, e[$t[v]], jt[1], zt[v]), B = _i(u, l, b, m, g, e[Ht[v]], Wt[1], Gt[v])) : v < 48 ? (I = mi(r, n, i, a, f, e[$t[v]], jt[2], zt[v]), B = mi(u, l, b, m, g, e[Ht[v]], Wt[2], Gt[v])) : v < 64 ? (I = _i(r, n, i, a, f, e[$t[v]], jt[3], zt[v]), B = gi(u, l, b, m, g, e[Ht[v]], Wt[3], Gt[v])) : (I = wi(r, n, i, a, f, e[$t[v]], jt[4], zt[v]), B = yi(u, l, b, m, g, e[Ht[v]], Wt[4], Gt[v])), r = f, f = a, a = lt(i, 10), i = n, n = I, u = g, g = m, m = lt(b, 10), b = l, l = B;
|
|
6739
6744
|
}
|
|
6740
|
-
var P = this._b + i +
|
|
6741
|
-
this._b = this._c + a +
|
|
6745
|
+
var P = this._b + i + m | 0;
|
|
6746
|
+
this._b = this._c + a + g | 0, this._c = this._d + f + u | 0, this._d = this._e + r + l | 0, this._e = this._a + n + b | 0, this._a = P;
|
|
6742
6747
|
};
|
|
6743
6748
|
Lr.prototype._digest = function() {
|
|
6744
6749
|
this._block[this._blockOffset++] = 128, this._blockOffset > 56 && (this._block.fill(0, this._blockOffset, 64), this._update(), this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], 60), this._update();
|
|
@@ -6819,8 +6824,8 @@ Zt.prototype._update = function(e) {
|
|
|
6819
6824
|
for (var t = this._w, r = this._a | 0, n = this._b | 0, i = this._c | 0, a = this._d | 0, f = this._e | 0, u = 0; u < 16; ++u) t[u] = e.readInt32BE(u * 4);
|
|
6820
6825
|
for (; u < 80; ++u) t[u] = t[u - 3] ^ t[u - 8] ^ t[u - 14] ^ t[u - 16];
|
|
6821
6826
|
for (var l = 0; l < 80; ++l) {
|
|
6822
|
-
var b = ~~(l / 20),
|
|
6823
|
-
f = a, a = i, i = Xu(n), n = r, r =
|
|
6827
|
+
var b = ~~(l / 20), m = Ju(r) + Qu(b, n, i, a) + f + t[l] + Ku[b] | 0;
|
|
6828
|
+
f = a, a = i, i = Xu(n), n = r, r = m;
|
|
6824
6829
|
}
|
|
6825
6830
|
this._a = r + this._a | 0, this._b = n + this._b | 0, this._c = i + this._c | 0, this._d = a + this._d | 0, this._e = f + this._e | 0;
|
|
6826
6831
|
};
|
|
@@ -6857,8 +6862,8 @@ er.prototype._update = function(e) {
|
|
|
6857
6862
|
for (var t = this._w, r = this._a | 0, n = this._b | 0, i = this._c | 0, a = this._d | 0, f = this._e | 0, u = 0; u < 16; ++u) t[u] = e.readInt32BE(u * 4);
|
|
6858
6863
|
for (; u < 80; ++u) t[u] = ic(t[u - 3] ^ t[u - 8] ^ t[u - 14] ^ t[u - 16]);
|
|
6859
6864
|
for (var l = 0; l < 80; ++l) {
|
|
6860
|
-
var b = ~~(l / 20),
|
|
6861
|
-
f = a, a = i, i = oc(n), n = r, r =
|
|
6865
|
+
var b = ~~(l / 20), m = sc(r) + ac(b, n, i, a) + f + t[l] + rc[b] | 0;
|
|
6866
|
+
f = a, a = i, i = oc(n), n = r, r = m;
|
|
6862
6867
|
}
|
|
6863
6868
|
this._a = r + this._a | 0, this._b = n + this._b | 0, this._c = i + this._c | 0, this._d = a + this._d | 0, this._e = f + this._e | 0;
|
|
6864
6869
|
};
|
|
@@ -6958,10 +6963,10 @@ function mc(e) {
|
|
|
6958
6963
|
return (e >>> 17 | e << 15) ^ (e >>> 19 | e << 13) ^ e >>> 10;
|
|
6959
6964
|
}
|
|
6960
6965
|
tr.prototype._update = function(e) {
|
|
6961
|
-
for (var t = this._w, r = this._a | 0, n = this._b | 0, i = this._c | 0, a = this._d | 0, f = this._e | 0, u = this._f | 0, l = this._g | 0, b = this._h | 0,
|
|
6962
|
-
for (;
|
|
6963
|
-
for (var
|
|
6964
|
-
var v = b + yc(f) + dc(f, u, l) + lc[
|
|
6966
|
+
for (var t = this._w, r = this._a | 0, n = this._b | 0, i = this._c | 0, a = this._d | 0, f = this._e | 0, u = this._f | 0, l = this._g | 0, b = this._h | 0, m = 0; m < 16; ++m) t[m] = e.readInt32BE(m * 4);
|
|
6967
|
+
for (; m < 64; ++m) t[m] = mc(t[m - 2]) + t[m - 7] + gc(t[m - 15]) + t[m - 16] | 0;
|
|
6968
|
+
for (var g = 0; g < 64; ++g) {
|
|
6969
|
+
var v = b + yc(f) + dc(f, u, l) + lc[g] + t[g] | 0, I = bc(r) + pc(r, n, i) | 0;
|
|
6965
6970
|
b = l, l = u, u = f, f = a + v | 0, a = i, i = n, n = r, r = v + I | 0;
|
|
6966
6971
|
}
|
|
6967
6972
|
this._a = r + this._a | 0, this._b = n + this._b | 0, this._c = i + this._c | 0, this._d = a + this._d | 0, this._e = f + this._e | 0, this._f = u + this._f | 0, this._g = l + this._g | 0, this._h = b + this._h | 0;
|
|
@@ -7179,7 +7184,7 @@ function ce(e, t) {
|
|
|
7179
7184
|
return e >>> 0 < t >>> 0 ? 1 : 0;
|
|
7180
7185
|
}
|
|
7181
7186
|
rr.prototype._update = function(e) {
|
|
7182
|
-
for (var t = this._w, r = this._ah | 0, n = this._bh | 0, i = this._ch | 0, a = this._dh | 0, f = this._eh | 0, u = this._fh | 0, l = this._gh | 0, b = this._hh | 0,
|
|
7187
|
+
for (var t = this._w, r = this._ah | 0, n = this._bh | 0, i = this._ch | 0, a = this._dh | 0, f = this._eh | 0, u = this._fh | 0, l = this._gh | 0, b = this._hh | 0, m = this._al | 0, g = this._bl | 0, v = this._cl | 0, I = this._dl | 0, B = this._el | 0, P = this._fl | 0, T = this._gl | 0, C = this._hl | 0, F = 0; F < 32; F += 2)
|
|
7183
7188
|
t[F] = e.readInt32BE(F * 4), t[F + 1] = e.readInt32BE(F * 4 + 4);
|
|
7184
7189
|
for (; F < 160; F += 2) {
|
|
7185
7190
|
var L = t[F - 30], k = t[F - 15 * 2 + 1], O = Rc(L, k), S = Tc(k, L);
|
|
@@ -7189,12 +7194,12 @@ rr.prototype._update = function(e) {
|
|
|
7189
7194
|
}
|
|
7190
7195
|
for (var Ee = 0; Ee < 160; Ee += 2) {
|
|
7191
7196
|
ve = t[Ee], ae = t[Ee + 1];
|
|
7192
|
-
var tt = Ei(r, n, i), Pe = Ei(
|
|
7197
|
+
var tt = Ei(r, n, i), Pe = Ei(m, g, v), Ge = Bi(r, m), Ce = Bi(m, r), je = Si(f, B), Q = Si(B, f), oe = xi[Ee], Be = xi[Ee + 1], We = vi(f, u, l), Ue = vi(B, P, T), w = C + Q | 0, _ = b + je + ce(w, C) | 0;
|
|
7193
7198
|
w = w + Ue | 0, _ = _ + We + ce(w, Ue) | 0, w = w + Be | 0, _ = _ + oe + ce(w, Be) | 0, w = w + ae | 0, _ = _ + ve + ce(w, ae) | 0;
|
|
7194
7199
|
var R = Ce + Pe | 0, D = Ge + tt + ce(R, Ce) | 0;
|
|
7195
|
-
b = l, C = T, l = u, T = P, u = f, P = B, B = I + w | 0, f = a + _ + ce(B, I) | 0, a = i, I = v, i = n, v =
|
|
7200
|
+
b = l, C = T, l = u, T = P, u = f, P = B, B = I + w | 0, f = a + _ + ce(B, I) | 0, a = i, I = v, i = n, v = g, n = r, g = m, m = w + R | 0, r = _ + D + ce(m, w) | 0;
|
|
7196
7201
|
}
|
|
7197
|
-
this._al = this._al +
|
|
7202
|
+
this._al = this._al + m | 0, this._bl = this._bl + g | 0, this._cl = this._cl + v | 0, this._dl = this._dl + I | 0, this._el = this._el + B | 0, this._fl = this._fl + P | 0, this._gl = this._gl + T | 0, this._hl = this._hl + C | 0, this._ah = this._ah + r + ce(this._al, m) | 0, this._bh = this._bh + n + ce(this._bl, g) | 0, this._ch = this._ch + i + ce(this._cl, v) | 0, this._dh = this._dh + a + ce(this._dl, I) | 0, this._eh = this._eh + f + ce(this._el, B) | 0, this._fh = this._fh + u + ce(this._fl, P) | 0, this._gh = this._gh + l + ce(this._gl, T) | 0, this._hh = this._hh + b + ce(this._hl, C) | 0;
|
|
7198
7203
|
};
|
|
7199
7204
|
rr.prototype._hash = function() {
|
|
7200
7205
|
var e = Ic.allocUnsafe(64);
|
|
@@ -7305,7 +7310,7 @@ function Vc(e) {
|
|
|
7305
7310
|
t[a] = n;
|
|
7306
7311
|
}
|
|
7307
7312
|
var f = e.length, u = e.charAt(0), l = Math.log(f) / Math.log(256), b = Math.log(256) / Math.log(f);
|
|
7308
|
-
function
|
|
7313
|
+
function m(I) {
|
|
7309
7314
|
if ((Array.isArray(I) || I instanceof Uint8Array) && (I = ur.from(I)), !ur.isBuffer(I))
|
|
7310
7315
|
throw new TypeError("Expected Buffer");
|
|
7311
7316
|
if (I.length === 0)
|
|
@@ -7325,7 +7330,7 @@ function Vc(e) {
|
|
|
7325
7330
|
M += e.charAt(L[z]);
|
|
7326
7331
|
return M;
|
|
7327
7332
|
}
|
|
7328
|
-
function
|
|
7333
|
+
function g(I) {
|
|
7329
7334
|
if (typeof I != "string")
|
|
7330
7335
|
throw new TypeError("Expected String");
|
|
7331
7336
|
if (I.length === 0)
|
|
@@ -7351,14 +7356,14 @@ function Vc(e) {
|
|
|
7351
7356
|
return z;
|
|
7352
7357
|
}
|
|
7353
7358
|
function v(I) {
|
|
7354
|
-
var B =
|
|
7359
|
+
var B = g(I);
|
|
7355
7360
|
if (B)
|
|
7356
7361
|
return B;
|
|
7357
7362
|
throw new Error("Non-base" + f + " character");
|
|
7358
7363
|
}
|
|
7359
7364
|
return {
|
|
7360
|
-
encode:
|
|
7361
|
-
decodeUnsafe:
|
|
7365
|
+
encode: m,
|
|
7366
|
+
decodeUnsafe: g,
|
|
7362
7367
|
decode: v
|
|
7363
7368
|
};
|
|
7364
7369
|
}
|
|
@@ -7655,10 +7660,10 @@ function cl(e) {
|
|
|
7655
7660
|
return _e.typeforce(e.isPoint, u), _e.typeforce(nn, l), new f(void 0, u, l);
|
|
7656
7661
|
}
|
|
7657
7662
|
function i(u, l) {
|
|
7658
|
-
const b = Ai.decode(u),
|
|
7663
|
+
const b = Ai.decode(u), m = b.version;
|
|
7659
7664
|
if (_e.Array(l)) {
|
|
7660
|
-
if (l = l.filter((
|
|
7661
|
-
} else if (l = l || pn.bitcoin,
|
|
7665
|
+
if (l = l.filter((g) => m === g.wif).pop(), !l) throw new Error("Unknown network version");
|
|
7666
|
+
} else if (l = l || pn.bitcoin, m !== l.wif) throw new Error("Invalid network version");
|
|
7662
7667
|
return r(b.privateKey, {
|
|
7663
7668
|
compressed: b.compressed,
|
|
7664
7669
|
network: l
|
|
@@ -7674,13 +7679,13 @@ function cl(e) {
|
|
|
7674
7679
|
return r(b, u);
|
|
7675
7680
|
}
|
|
7676
7681
|
class f {
|
|
7677
|
-
constructor(l, b,
|
|
7682
|
+
constructor(l, b, m) {
|
|
7678
7683
|
yt(this, "__D");
|
|
7679
7684
|
yt(this, "__Q");
|
|
7680
7685
|
yt(this, "compressed");
|
|
7681
7686
|
yt(this, "network");
|
|
7682
7687
|
yt(this, "lowR");
|
|
7683
|
-
this.__D = l, this.__Q = b, this.lowR = !1,
|
|
7688
|
+
this.__D = l, this.__Q = b, this.lowR = !1, m === void 0 && (m = {}), this.compressed = m.compressed === void 0 ? !0 : m.compressed, this.network = m.network || pn.bitcoin, b !== void 0 && (this.__Q = Buffer.from(e.pointCompress(b, this.compressed)));
|
|
7684
7689
|
}
|
|
7685
7690
|
get privateKey() {
|
|
7686
7691
|
return this.__D;
|
|
@@ -7704,12 +7709,12 @@ function cl(e) {
|
|
|
7704
7709
|
if (b === void 0 && (b = this.lowR), b === !1)
|
|
7705
7710
|
return Buffer.from(e.sign(l, this.__D));
|
|
7706
7711
|
{
|
|
7707
|
-
let
|
|
7708
|
-
const
|
|
7712
|
+
let m = e.sign(l, this.__D);
|
|
7713
|
+
const g = Buffer.alloc(32, 0);
|
|
7709
7714
|
let v = 0;
|
|
7710
|
-
for (;
|
|
7711
|
-
v++,
|
|
7712
|
-
return Buffer.from(
|
|
7715
|
+
for (; m[0] > 127; )
|
|
7716
|
+
v++, g.writeUIntLE(v, 0, 6), m = e.sign(l, this.__D, g);
|
|
7717
|
+
return Buffer.from(m);
|
|
7713
7718
|
}
|
|
7714
7719
|
}
|
|
7715
7720
|
signSchnorr(l) {
|
|
@@ -7727,21 +7732,21 @@ function cl(e) {
|
|
|
7727
7732
|
return e.verifySchnorr(l, this.publicKey.subarray(1, 33), b);
|
|
7728
7733
|
}
|
|
7729
7734
|
tweakFromPublicKey(l) {
|
|
7730
|
-
const b = ul(this.publicKey),
|
|
7731
|
-
if (!
|
|
7735
|
+
const b = ul(this.publicKey), m = e.xOnlyPointAddTweak(b, l);
|
|
7736
|
+
if (!m || m.xOnlyPubkey === null)
|
|
7732
7737
|
throw new Error("Cannot tweak public key!");
|
|
7733
|
-
const
|
|
7734
|
-
|
|
7738
|
+
const g = Buffer.from([
|
|
7739
|
+
m.parity === 0 ? 2 : 3
|
|
7735
7740
|
]);
|
|
7736
7741
|
return n(
|
|
7737
|
-
Buffer.concat([
|
|
7742
|
+
Buffer.concat([g, m.xOnlyPubkey]),
|
|
7738
7743
|
{ network: this.network, compressed: this.compressed }
|
|
7739
7744
|
);
|
|
7740
7745
|
}
|
|
7741
7746
|
tweakFromPrivateKey(l) {
|
|
7742
|
-
const
|
|
7743
|
-
if (!
|
|
7744
|
-
return r(Buffer.from(
|
|
7747
|
+
const m = this.publicKey[0] === 3 || this.publicKey[0] === 4 && (this.publicKey[64] & 1) === 1 ? e.privateNegate(this.privateKey) : this.privateKey, g = e.privateAdd(m, l);
|
|
7748
|
+
if (!g) throw new Error("Invalid tweaked private key!");
|
|
7749
|
+
return r(Buffer.from(g), {
|
|
7745
7750
|
network: this.network,
|
|
7746
7751
|
compressed: this.compressed
|
|
7747
7752
|
});
|