@babylonlabs-io/ts-sdk 0.15.2 → 0.15.3
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/{challengeAssert-CenzzhZU.js → challengeAssert-C5DQSUnp.js} +249 -265
- package/dist/challengeAssert-C5DQSUnp.js.map +1 -0
- package/dist/challengeAssert-D7SqsNpQ.cjs +2 -0
- package/dist/challengeAssert-D7SqsNpQ.cjs.map +1 -0
- package/dist/errors-BZc3Urez.cjs +2 -0
- package/dist/errors-BZc3Urez.cjs.map +1 -0
- package/dist/{errors-C5aW6wrA.js → errors-UqmtfBtv.js} +189 -188
- package/dist/errors-UqmtfBtv.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +2 -2
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.js +1 -1
- package/dist/tbv/core/primitives/psbt/__tests__/constants.d.ts +2 -13
- package/dist/tbv/core/primitives/psbt/__tests__/constants.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/scripts/payout.d.ts +7 -0
- package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +17 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/utils/transaction/createSplitTransaction.d.ts.map +1 -1
- package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +2 -2
- package/package.json +3 -3
- package/dist/challengeAssert-BpzES0KW.cjs +0 -2
- package/dist/challengeAssert-BpzES0KW.cjs.map +0 -1
- package/dist/challengeAssert-CenzzhZU.js.map +0 -1
- package/dist/errors-C5aW6wrA.js.map +0 -1
- package/dist/errors-DD3lnhb0.cjs +0 -2
- package/dist/errors-DD3lnhb0.cjs.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (e, t, n) =>
|
|
4
|
-
import * as
|
|
5
|
-
import { script as
|
|
1
|
+
var de = Object.defineProperty;
|
|
2
|
+
var fe = (e, t, n) => t in e ? de(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var p = (e, t, n) => fe(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import * as pe from "bitcoinjs-lib";
|
|
5
|
+
import { script as ge, Transaction as J, address as be, Psbt as bt } from "bitcoinjs-lib";
|
|
6
6
|
import { Buffer as S } from "buffer";
|
|
7
|
-
import { P as
|
|
8
|
-
import { createPublicClient as lt, http as ht, encodeFunctionData as Bt, zeroAddress as
|
|
7
|
+
import { P as ye, y as xe, D as Mt, M as Ht, B as we, T as me, H as Nt, G as yt, u as B, b as Pe, A as Te, E as ve, a as ke, d as He, e as Ee, f as Ie, s as U, q as Se, x as Et, h as It, i as St, r as Be } from "./challengeAssert-C5DQSUnp.js";
|
|
8
|
+
import { createPublicClient as lt, http as ht, encodeFunctionData as Bt, zeroAddress as Ae } from "viem";
|
|
9
9
|
import { deriveVaultId as At } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
10
|
-
function
|
|
10
|
+
function $e(e, t, n, s) {
|
|
11
11
|
if (!Number.isInteger(s) || s < 1)
|
|
12
12
|
throw new Error(
|
|
13
13
|
`Invalid numOutputs: expected a positive integer, got ${s}`
|
|
@@ -16,7 +16,7 @@ function Ae(e, t, n, s) {
|
|
|
16
16
|
throw new Error("Insufficient funds: no UTXOs available");
|
|
17
17
|
const o = e.filter((l) => {
|
|
18
18
|
const h = S.from(l.scriptPubKey, "hex");
|
|
19
|
-
return !!
|
|
19
|
+
return !!ge.decompile(h);
|
|
20
20
|
});
|
|
21
21
|
if (o.length === 0)
|
|
22
22
|
throw new Error(
|
|
@@ -26,8 +26,8 @@ function Ae(e, t, n, s) {
|
|
|
26
26
|
let a = 0n, c = 0n;
|
|
27
27
|
for (const l of r) {
|
|
28
28
|
i.push(l), a += BigInt(l.value);
|
|
29
|
-
const h = i.length *
|
|
30
|
-
if (c = BigInt(Math.ceil(d * n)) + BigInt(
|
|
29
|
+
const h = i.length * ye, u = s * Ht, d = h + u + me;
|
|
30
|
+
if (c = BigInt(Math.ceil(d * n)) + BigInt(xe(n)), a - t - c > Mt) {
|
|
31
31
|
const g = BigInt(
|
|
32
32
|
Math.ceil(Ht * n)
|
|
33
33
|
);
|
|
@@ -47,18 +47,18 @@ function Ae(e, t, n, s) {
|
|
|
47
47
|
`Insufficient funds: need ${t + c} sats (${t} pegin + ${c} fee), have ${a} sats`
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Yn(e) {
|
|
51
51
|
return e > Mt;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
53
|
+
function Qn() {
|
|
54
|
+
return we;
|
|
55
55
|
}
|
|
56
56
|
function dt(e) {
|
|
57
57
|
const t = e.startsWith("0x") ? e.slice(2) : e;
|
|
58
58
|
return `0x${J.fromHex(t).getId()}`;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
if (e.length === 0)
|
|
60
|
+
function ts(e, t, n) {
|
|
61
|
+
if (Nt(), e.length === 0)
|
|
62
62
|
throw new Error("No input UTXOs provided for split transaction");
|
|
63
63
|
if (t.length === 0)
|
|
64
64
|
throw new Error("No outputs specified for split transaction");
|
|
@@ -78,7 +78,7 @@ function Qn(e, t, n) {
|
|
|
78
78
|
const l = t[c];
|
|
79
79
|
let h;
|
|
80
80
|
try {
|
|
81
|
-
h =
|
|
81
|
+
h = be.toOutputScript(l.address, s);
|
|
82
82
|
} catch (u) {
|
|
83
83
|
throw new Error(
|
|
84
84
|
`Failed to decode address "${l.address}": ${u instanceof Error ? u.message : String(u)}`
|
|
@@ -101,7 +101,7 @@ function Qn(e, t, n) {
|
|
|
101
101
|
outputs: r
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function es(e, t, n) {
|
|
105
105
|
const s = J.fromHex(e), o = new bt();
|
|
106
106
|
if (o.setVersion(s.version), o.setLocktime(s.locktime), !S.isBuffer(n) || n.length !== 32)
|
|
107
107
|
throw new Error(
|
|
@@ -146,7 +146,7 @@ function ts(e, t, n) {
|
|
|
146
146
|
return o.toHex();
|
|
147
147
|
}
|
|
148
148
|
var rt = /* @__PURE__ */ ((e) => (e.P2PKH = "P2PKH", e.P2SH = "P2SH", e.P2WPKH = "P2WPKH", e.P2WSH = "P2WSH", e.P2TR = "P2TR", e.UNKNOWN = "UNKNOWN", e))(rt || {});
|
|
149
|
-
function
|
|
149
|
+
function Ue(e) {
|
|
150
150
|
const t = e.length;
|
|
151
151
|
return t === 25 && e[0] === 118 && // OP_DUP
|
|
152
152
|
e[1] === 169 && // OP_HASH160
|
|
@@ -159,8 +159,8 @@ function $e(e) {
|
|
|
159
159
|
e[1] === 32 ? "P2WSH" : t === 34 && e[0] === 81 && // OP_1
|
|
160
160
|
e[1] === 32 ? "P2TR" : "UNKNOWN";
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
const n = S.from(e.scriptPubKey, "hex"), s =
|
|
162
|
+
function Fe(e, t) {
|
|
163
|
+
const n = S.from(e.scriptPubKey, "hex"), s = Ue(n);
|
|
164
164
|
switch (s) {
|
|
165
165
|
case rt.P2WPKH:
|
|
166
166
|
return {
|
|
@@ -210,17 +210,17 @@ function xt(e, t) {
|
|
|
210
210
|
}))
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
-
const
|
|
214
|
-
function
|
|
215
|
-
return Number.isInteger(e) && e > 0 && e <=
|
|
213
|
+
const Ce = 21e6 * 1e8, Xt = 1e4;
|
|
214
|
+
function qt(e) {
|
|
215
|
+
return Number.isInteger(e) && e > 0 && e <= Ce;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
return Number.isInteger(e) && e > 0 && e <=
|
|
217
|
+
function Oe(e) {
|
|
218
|
+
return Number.isInteger(e) && e > 0 && e <= Xt;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function Gt(e, t) {
|
|
221
221
|
return !Number.isInteger(e) || e < 0 ? !1 : t === void 0 || e < t;
|
|
222
222
|
}
|
|
223
|
-
const
|
|
223
|
+
const Le = {
|
|
224
224
|
mainnet: "https://mempool.space/api",
|
|
225
225
|
testnet: "https://mempool.space/testnet/api",
|
|
226
226
|
signet: "https://mempool.space/signet/api"
|
|
@@ -240,7 +240,7 @@ async function at(e, t) {
|
|
|
240
240
|
throw n instanceof Error ? new Error(`Failed to fetch from mempool API: ${n.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
async function
|
|
243
|
+
async function _e(e, t) {
|
|
244
244
|
try {
|
|
245
245
|
const n = await fetch(`${t}/tx`, {
|
|
246
246
|
method: "POST",
|
|
@@ -266,10 +266,10 @@ async function Le(e, t) {
|
|
|
266
266
|
throw n instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${n.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
async function
|
|
269
|
+
async function Re(e, t) {
|
|
270
270
|
return at(`${t}/tx/${e}`);
|
|
271
271
|
}
|
|
272
|
-
async function
|
|
272
|
+
async function ns(e, t) {
|
|
273
273
|
try {
|
|
274
274
|
const n = await fetch(`${t}/tx/${e}/hex`);
|
|
275
275
|
if (!n.ok) {
|
|
@@ -283,14 +283,14 @@ async function es(e, t) {
|
|
|
283
283
|
throw n instanceof Error ? new Error(`Failed to get transaction hex for ${e}: ${n.message}`) : new Error(`Failed to get transaction hex for ${e}: Unknown error`);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
async function
|
|
287
|
-
const s = await
|
|
288
|
-
if (!
|
|
286
|
+
async function We(e, t, n) {
|
|
287
|
+
const s = await Re(e, n);
|
|
288
|
+
if (!Gt(t, s.vout.length))
|
|
289
289
|
throw new Error(
|
|
290
290
|
`Invalid vout ${t} for transaction ${e} (has ${s.vout.length} outputs)`
|
|
291
291
|
);
|
|
292
292
|
const o = s.vout[t];
|
|
293
|
-
if (!
|
|
293
|
+
if (!qt(o.value))
|
|
294
294
|
throw new Error(`Invalid UTXO value ${o.value} for ${e}:${t}`);
|
|
295
295
|
return {
|
|
296
296
|
txid: e,
|
|
@@ -299,7 +299,7 @@ async function Re(e, t, n) {
|
|
|
299
299
|
scriptPubKey: o.scriptpubkey
|
|
300
300
|
};
|
|
301
301
|
}
|
|
302
|
-
async function
|
|
302
|
+
async function ss(e, t) {
|
|
303
303
|
try {
|
|
304
304
|
const n = await at(`${t}/address/${e}/utxo`), s = await at(`${t}/v1/validate-address/${e}`);
|
|
305
305
|
if (!s.isvalid)
|
|
@@ -307,9 +307,9 @@ async function ns(e, t) {
|
|
|
307
307
|
`Invalid Bitcoin address: ${e}. Mempool API validation failed.`
|
|
308
308
|
);
|
|
309
309
|
for (const r of n) {
|
|
310
|
-
if (!
|
|
310
|
+
if (!Gt(r.vout))
|
|
311
311
|
throw new Error(`Invalid vout ${r.vout} for ${r.txid}`);
|
|
312
|
-
if (!
|
|
312
|
+
if (!qt(r.value))
|
|
313
313
|
throw new Error(
|
|
314
314
|
`Invalid UTXO value ${r.value} for ${r.txid}:${r.vout}`
|
|
315
315
|
);
|
|
@@ -329,13 +329,13 @@ async function ns(e, t) {
|
|
|
329
329
|
);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
function
|
|
333
|
-
return
|
|
332
|
+
function os(e) {
|
|
333
|
+
return Le[e];
|
|
334
334
|
}
|
|
335
|
-
async function
|
|
335
|
+
async function rs(e, t) {
|
|
336
336
|
return at(`${t}/address/${e}/txs`);
|
|
337
337
|
}
|
|
338
|
-
async function
|
|
338
|
+
async function is(e) {
|
|
339
339
|
const t = await fetch(`${e}/v1/fees/recommended`);
|
|
340
340
|
if (!t.ok)
|
|
341
341
|
throw new Error(
|
|
@@ -349,9 +349,9 @@ async function rs(e) {
|
|
|
349
349
|
"minimumFee"
|
|
350
350
|
];
|
|
351
351
|
for (const o of s)
|
|
352
|
-
if (!
|
|
352
|
+
if (!Oe(n[o]))
|
|
353
353
|
throw new Error(
|
|
354
|
-
`Invalid fee rate ${o}=${n[o]} from mempool API: expected a positive number ≤ ${
|
|
354
|
+
`Invalid fee rate ${o}=${n[o]} from mempool API: expected a positive number ≤ ${Xt}`
|
|
355
355
|
);
|
|
356
356
|
if (n.minimumFee > n.economyFee || n.economyFee > n.hourFee || n.hourFee > n.halfHourFee || n.halfHourFee > n.fastestFee)
|
|
357
357
|
throw new Error(
|
|
@@ -701,14 +701,14 @@ function mt(e) {
|
|
|
701
701
|
if (i)
|
|
702
702
|
return i[1];
|
|
703
703
|
}
|
|
704
|
-
function
|
|
704
|
+
function as(e) {
|
|
705
705
|
const t = mt(e);
|
|
706
706
|
if (t) {
|
|
707
707
|
const n = t.substring(0, 10);
|
|
708
708
|
return q[t] ?? q[n];
|
|
709
709
|
}
|
|
710
710
|
}
|
|
711
|
-
function
|
|
711
|
+
function cs(e) {
|
|
712
712
|
const t = mt(e);
|
|
713
713
|
if (t === void 0) return !1;
|
|
714
714
|
const n = t.substring(0, 10);
|
|
@@ -736,18 +736,18 @@ function M(e) {
|
|
|
736
736
|
}
|
|
737
737
|
throw e instanceof Error ? (console.error("[Contract Error] Unhandled error:", e.message), e) : new Error(`Contract call failed: ${String(e)}`);
|
|
738
738
|
}
|
|
739
|
-
const
|
|
740
|
-
function
|
|
739
|
+
const Ve = 0;
|
|
740
|
+
function Ke(e, t, n, s) {
|
|
741
741
|
const o = n == null ? void 0 : n[`${e}:${t}`];
|
|
742
742
|
return o ? Promise.resolve({
|
|
743
743
|
txid: e,
|
|
744
744
|
vout: t,
|
|
745
745
|
value: o.value,
|
|
746
746
|
scriptPubKey: o.scriptPubKey
|
|
747
|
-
}) :
|
|
747
|
+
}) : We(e, t, s);
|
|
748
748
|
}
|
|
749
749
|
const $t = 12e4;
|
|
750
|
-
class
|
|
750
|
+
class us {
|
|
751
751
|
/**
|
|
752
752
|
* Creates a new PeginManager instance.
|
|
753
753
|
*
|
|
@@ -798,12 +798,12 @@ class cs {
|
|
|
798
798
|
councilQuorum: t.councilQuorum,
|
|
799
799
|
councilSize: t.councilSize,
|
|
800
800
|
network: this.config.btcNetwork
|
|
801
|
-
}, l = await
|
|
801
|
+
}, l = await Pe(c), h = $e(
|
|
802
802
|
[...t.availableUTXOs],
|
|
803
803
|
l.totalOutputValue,
|
|
804
804
|
t.mempoolFeeRate,
|
|
805
|
-
|
|
806
|
-
), u = yt(this.config.btcNetwork), d =
|
|
805
|
+
Te(l.htlcValues.length)
|
|
806
|
+
), u = yt(this.config.btcNetwork), d = ve({
|
|
807
807
|
unfundedTxHex: l.psbtHex,
|
|
808
808
|
selectedUTXOs: h.selectedUTXOs,
|
|
809
809
|
changeAddress: t.changeAddress,
|
|
@@ -811,12 +811,12 @@ class cs {
|
|
|
811
811
|
network: u
|
|
812
812
|
}), y = B(dt(d)), g = [], x = [], P = [];
|
|
813
813
|
for (let f = 0; f < t.hashlocks.length; f++) {
|
|
814
|
-
const w = await
|
|
814
|
+
const w = await ke({
|
|
815
815
|
prePeginParams: c,
|
|
816
816
|
timelockPegin: t.timelockPegin,
|
|
817
817
|
fundedPrePeginTxHex: d,
|
|
818
818
|
htlcVout: f
|
|
819
|
-
}), v = await
|
|
819
|
+
}), v = await He({
|
|
820
820
|
peginTxHex: w.txHex,
|
|
821
821
|
fundedPrePeginTxHex: d,
|
|
822
822
|
depositorPubkey: s,
|
|
@@ -836,10 +836,10 @@ class cs {
|
|
|
836
836
|
P
|
|
837
837
|
), b = [];
|
|
838
838
|
for (let f = 0; f < m.length; f++) {
|
|
839
|
-
const w =
|
|
839
|
+
const w = Ee(
|
|
840
840
|
m[f],
|
|
841
841
|
s
|
|
842
|
-
), v =
|
|
842
|
+
), v = Ie(m[f]);
|
|
843
843
|
b.push({
|
|
844
844
|
htlcVout: f,
|
|
845
845
|
htlcValue: l.htlcValues[f],
|
|
@@ -921,7 +921,7 @@ class cs {
|
|
|
921
921
|
);
|
|
922
922
|
const l = this.config.mempoolApiUrl, h = r.ins.map((b) => {
|
|
923
923
|
const f = S.from(b.hash).reverse().toString("hex"), w = b.index;
|
|
924
|
-
return
|
|
924
|
+
return Ke(f, w, t.localPrevouts, l).then(
|
|
925
925
|
(v) => ({ input: b, utxoData: v, txid: f, vout: w })
|
|
926
926
|
);
|
|
927
927
|
}), u = await Promise.all(h), d = u.reduce(
|
|
@@ -936,7 +936,7 @@ class cs {
|
|
|
936
936
|
`UTXO value mismatch: total input value (${d} sat) is less than total output value (${y} sat). This may indicate the mempool API returned manipulated UTXO data.`
|
|
937
937
|
);
|
|
938
938
|
for (const { input: b, utxoData: f, txid: w, vout: v } of u) {
|
|
939
|
-
const T =
|
|
939
|
+
const T = Fe(
|
|
940
940
|
{
|
|
941
941
|
value: f.value,
|
|
942
942
|
scriptPubKey: f.scriptPubKey
|
|
@@ -967,7 +967,7 @@ class cs {
|
|
|
967
967
|
);
|
|
968
968
|
}
|
|
969
969
|
const P = x.extractTransaction().toHex();
|
|
970
|
-
return await
|
|
970
|
+
return await _e(P, l);
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
973
973
|
* Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
|
|
@@ -1154,7 +1154,7 @@ class cs {
|
|
|
1154
1154
|
),
|
|
1155
1155
|
hashlock: b.hashlock,
|
|
1156
1156
|
htlcVout: b.htlcVout,
|
|
1157
|
-
referralCode:
|
|
1157
|
+
referralCode: Ve,
|
|
1158
1158
|
depositorPayoutBtcAddress: c[f],
|
|
1159
1159
|
depositorWotsPkHash: b.depositorWotsPkHash
|
|
1160
1160
|
})), g = Bt({
|
|
@@ -1216,7 +1216,7 @@ class cs {
|
|
|
1216
1216
|
abi: j,
|
|
1217
1217
|
functionName: "getBTCVault",
|
|
1218
1218
|
args: [t]
|
|
1219
|
-
})).depositor !==
|
|
1219
|
+
})).depositor !== Ae;
|
|
1220
1220
|
} catch {
|
|
1221
1221
|
return !1;
|
|
1222
1222
|
}
|
|
@@ -1229,13 +1229,14 @@ class cs {
|
|
|
1229
1229
|
* wallet's public key to guard against a compromised wallet provider.
|
|
1230
1230
|
*/
|
|
1231
1231
|
async resolvePayoutScriptPubKey(t) {
|
|
1232
|
+
Nt();
|
|
1232
1233
|
let n;
|
|
1233
1234
|
if (t)
|
|
1234
1235
|
n = t;
|
|
1235
1236
|
else {
|
|
1236
1237
|
n = await this.config.btcWallet.getAddress();
|
|
1237
1238
|
const o = await this.config.btcWallet.getPublicKeyHex();
|
|
1238
|
-
if (!
|
|
1239
|
+
if (!Se(
|
|
1239
1240
|
n,
|
|
1240
1241
|
o,
|
|
1241
1242
|
this.config.btcNetwork
|
|
@@ -1246,7 +1247,7 @@ class cs {
|
|
|
1246
1247
|
}
|
|
1247
1248
|
const s = yt(this.config.btcNetwork);
|
|
1248
1249
|
try {
|
|
1249
|
-
return `0x${
|
|
1250
|
+
return `0x${pe.address.toOutputScript(n, s).toString("hex")}`;
|
|
1250
1251
|
} catch {
|
|
1251
1252
|
throw new Error(
|
|
1252
1253
|
`Invalid BTC payout address: "${n}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
|
|
@@ -1285,7 +1286,7 @@ class cs {
|
|
|
1285
1286
|
return this.config.vaultContracts.btcVaultRegistry;
|
|
1286
1287
|
}
|
|
1287
1288
|
}
|
|
1288
|
-
class
|
|
1289
|
+
class ls {
|
|
1289
1290
|
/**
|
|
1290
1291
|
* Creates a new PayoutManager instance.
|
|
1291
1292
|
*
|
|
@@ -1434,7 +1435,7 @@ class us {
|
|
|
1434
1435
|
* @throws Error if the largest output does not pay to the registered address
|
|
1435
1436
|
*/
|
|
1436
1437
|
validatePayoutOutputs(t, n) {
|
|
1437
|
-
if (!
|
|
1438
|
+
if (!Be(n))
|
|
1438
1439
|
throw new Error(
|
|
1439
1440
|
"Invalid registeredPayoutScriptPubKey: not valid hex"
|
|
1440
1441
|
);
|
|
@@ -1452,7 +1453,7 @@ class us {
|
|
|
1452
1453
|
);
|
|
1453
1454
|
}
|
|
1454
1455
|
}
|
|
1455
|
-
function
|
|
1456
|
+
function De(e) {
|
|
1456
1457
|
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
1457
1458
|
}
|
|
1458
1459
|
function V(e, t = "") {
|
|
@@ -1462,14 +1463,14 @@ function V(e, t = "") {
|
|
|
1462
1463
|
}
|
|
1463
1464
|
}
|
|
1464
1465
|
function K(e, t, n = "") {
|
|
1465
|
-
const s =
|
|
1466
|
+
const s = De(e), o = e == null ? void 0 : e.length, r = t !== void 0;
|
|
1466
1467
|
if (!s || r && o !== t) {
|
|
1467
1468
|
const i = n && `"${n}" `, a = r ? ` of length ${t}` : "", c = s ? `length=${o}` : `type=${typeof e}`;
|
|
1468
1469
|
throw new Error(i + "expected Uint8Array" + a + ", got " + c);
|
|
1469
1470
|
}
|
|
1470
1471
|
return e;
|
|
1471
1472
|
}
|
|
1472
|
-
function
|
|
1473
|
+
function jt(e) {
|
|
1473
1474
|
if (typeof e != "function" || typeof e.create != "function")
|
|
1474
1475
|
throw new Error("Hash must wrapped by utils.createHasher");
|
|
1475
1476
|
V(e.outputLen), V(e.blockLen);
|
|
@@ -1480,13 +1481,13 @@ function G(e, t = !0) {
|
|
|
1480
1481
|
if (t && e.finished)
|
|
1481
1482
|
throw new Error("Hash#digest() has already been called");
|
|
1482
1483
|
}
|
|
1483
|
-
function
|
|
1484
|
+
function zt(e, t) {
|
|
1484
1485
|
K(e, void 0, "digestInto() output");
|
|
1485
1486
|
const n = t.outputLen;
|
|
1486
1487
|
if (e.length < n)
|
|
1487
1488
|
throw new Error('"digestInto() output" expected to be of length >=' + n);
|
|
1488
1489
|
}
|
|
1489
|
-
function
|
|
1490
|
+
function Me(e) {
|
|
1490
1491
|
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
1491
1492
|
}
|
|
1492
1493
|
function A(...e) {
|
|
@@ -1502,25 +1503,25 @@ function $(e, t) {
|
|
|
1502
1503
|
function Y(e, t) {
|
|
1503
1504
|
return e << t | e >>> 32 - t >>> 0;
|
|
1504
1505
|
}
|
|
1505
|
-
const
|
|
1506
|
-
function
|
|
1506
|
+
const Ne = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1507
|
+
function Xe(e) {
|
|
1507
1508
|
return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
|
|
1508
1509
|
}
|
|
1509
|
-
function
|
|
1510
|
+
function qe(e) {
|
|
1510
1511
|
for (let t = 0; t < e.length; t++)
|
|
1511
|
-
e[t] =
|
|
1512
|
+
e[t] = Xe(e[t]);
|
|
1512
1513
|
return e;
|
|
1513
1514
|
}
|
|
1514
|
-
const Ut =
|
|
1515
|
-
function
|
|
1515
|
+
const Ut = Ne ? (e) => e : qe;
|
|
1516
|
+
function Ge(e) {
|
|
1516
1517
|
if (typeof e != "string")
|
|
1517
1518
|
throw new Error("string expected");
|
|
1518
1519
|
return new Uint8Array(new TextEncoder().encode(e));
|
|
1519
1520
|
}
|
|
1520
1521
|
function Ft(e, t = "") {
|
|
1521
|
-
return typeof e == "string" ?
|
|
1522
|
+
return typeof e == "string" ? Ge(e) : K(e, void 0, t);
|
|
1522
1523
|
}
|
|
1523
|
-
function
|
|
1524
|
+
function je(e, t) {
|
|
1524
1525
|
if (t !== void 0 && {}.toString.call(t) !== "[object Object]")
|
|
1525
1526
|
throw new Error("options must be object or undefined");
|
|
1526
1527
|
return Object.assign(e, t);
|
|
@@ -1529,10 +1530,10 @@ function ct(e, t = {}) {
|
|
|
1529
1530
|
const n = (o, r) => e(r).update(o).digest(), s = e(void 0);
|
|
1530
1531
|
return n.outputLen = s.outputLen, n.blockLen = s.blockLen, n.create = (o) => e(o), Object.assign(n, t), Object.freeze(n);
|
|
1531
1532
|
}
|
|
1532
|
-
const
|
|
1533
|
+
const Zt = (e) => ({
|
|
1533
1534
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, e])
|
|
1534
1535
|
});
|
|
1535
|
-
class
|
|
1536
|
+
class Jt {
|
|
1536
1537
|
constructor(t, n) {
|
|
1537
1538
|
p(this, "oHash");
|
|
1538
1539
|
p(this, "iHash");
|
|
@@ -1540,7 +1541,7 @@ class Zt {
|
|
|
1540
1541
|
p(this, "outputLen");
|
|
1541
1542
|
p(this, "finished", !1);
|
|
1542
1543
|
p(this, "destroyed", !1);
|
|
1543
|
-
if (
|
|
1544
|
+
if (jt(t), K(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
1544
1545
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
1545
1546
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
1546
1547
|
const s = this.blockLen, o = new Uint8Array(s);
|
|
@@ -1574,12 +1575,12 @@ class Zt {
|
|
|
1574
1575
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
1575
1576
|
}
|
|
1576
1577
|
}
|
|
1577
|
-
const Pt = (e, t, n) => new
|
|
1578
|
-
Pt.create = (e, t) => new
|
|
1579
|
-
function
|
|
1578
|
+
const Pt = (e, t, n) => new Jt(e, t).update(n).digest();
|
|
1579
|
+
Pt.create = (e, t) => new Jt(e, t);
|
|
1580
|
+
function ze(e, t, n) {
|
|
1580
1581
|
return e & t ^ ~e & n;
|
|
1581
1582
|
}
|
|
1582
|
-
function
|
|
1583
|
+
function Ze(e, t, n) {
|
|
1583
1584
|
return e & t ^ e & n ^ t & n;
|
|
1584
1585
|
}
|
|
1585
1586
|
class Tt {
|
|
@@ -1613,7 +1614,7 @@ class Tt {
|
|
|
1613
1614
|
return this.length += t.length, this.roundClean(), this;
|
|
1614
1615
|
}
|
|
1615
1616
|
digestInto(t) {
|
|
1616
|
-
G(this),
|
|
1617
|
+
G(this), zt(t, this), this.finished = !0;
|
|
1617
1618
|
const { buffer: n, view: s, blockLen: o, isLE: r } = this;
|
|
1618
1619
|
let { pos: i } = this;
|
|
1619
1620
|
n[i++] = 128, A(this.buffer.subarray(i)), this.padOffset > o - i && (this.process(s, 0), i = 0);
|
|
@@ -1670,7 +1671,7 @@ const L = /* @__PURE__ */ Uint32Array.from([
|
|
|
1670
1671
|
4215389547,
|
|
1671
1672
|
1541459225,
|
|
1672
1673
|
327033209
|
|
1673
|
-
]),
|
|
1674
|
+
]), Je = /* @__PURE__ */ Uint8Array.from([
|
|
1674
1675
|
7,
|
|
1675
1676
|
4,
|
|
1676
1677
|
13,
|
|
@@ -1687,25 +1688,25 @@ const L = /* @__PURE__ */ Uint32Array.from([
|
|
|
1687
1688
|
14,
|
|
1688
1689
|
11,
|
|
1689
1690
|
8
|
|
1690
|
-
]),
|
|
1691
|
-
const n = [[
|
|
1691
|
+
]), Yt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), Ye = Yt.map((e) => (9 * e + 5) % 16), Qt = /* @__PURE__ */ (() => {
|
|
1692
|
+
const n = [[Yt], [Ye]];
|
|
1692
1693
|
for (let s = 0; s < 4; s++)
|
|
1693
1694
|
for (let o of n)
|
|
1694
|
-
o.push(o[s].map((r) =>
|
|
1695
|
+
o.push(o[s].map((r) => Je[r]));
|
|
1695
1696
|
return n;
|
|
1696
|
-
})(),
|
|
1697
|
+
})(), te = Qt[0], ee = Qt[1], ne = /* @__PURE__ */ [
|
|
1697
1698
|
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
1698
1699
|
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
1699
1700
|
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
1700
1701
|
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
1701
1702
|
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
|
|
1702
|
-
].map((e) => Uint8Array.from(e)),
|
|
1703
|
+
].map((e) => Uint8Array.from(e)), Qe = /* @__PURE__ */ te.map((e, t) => e.map((n) => ne[t][n])), tn = /* @__PURE__ */ ee.map((e, t) => e.map((n) => ne[t][n])), en = /* @__PURE__ */ Uint32Array.from([
|
|
1703
1704
|
0,
|
|
1704
1705
|
1518500249,
|
|
1705
1706
|
1859775393,
|
|
1706
1707
|
2400959708,
|
|
1707
1708
|
2840853838
|
|
1708
|
-
]),
|
|
1709
|
+
]), nn = /* @__PURE__ */ Uint32Array.from([
|
|
1709
1710
|
1352829926,
|
|
1710
1711
|
1548603684,
|
|
1711
1712
|
1836072691,
|
|
@@ -1716,7 +1717,7 @@ function Ct(e, t, n, s) {
|
|
|
1716
1717
|
return e === 0 ? t ^ n ^ s : e === 1 ? t & n | ~t & s : e === 2 ? (t | ~n) ^ s : e === 3 ? t & s | n & ~s : t ^ (n | ~s);
|
|
1717
1718
|
}
|
|
1718
1719
|
const Q = /* @__PURE__ */ new Uint32Array(16);
|
|
1719
|
-
class
|
|
1720
|
+
class sn extends Tt {
|
|
1720
1721
|
constructor() {
|
|
1721
1722
|
super(64, 20, 8, !0);
|
|
1722
1723
|
p(this, "h0", 1732584193);
|
|
@@ -1737,7 +1738,7 @@ class nn extends Tt {
|
|
|
1737
1738
|
Q[g] = n.getUint32(s, !0);
|
|
1738
1739
|
let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, c = this.h2 | 0, l = c, h = this.h3 | 0, u = h, d = this.h4 | 0, y = d;
|
|
1739
1740
|
for (let g = 0; g < 5; g++) {
|
|
1740
|
-
const x = 4 - g, P =
|
|
1741
|
+
const x = 4 - g, P = en[g], m = nn[g], b = te[g], f = ee[g], w = Qe[g], v = tn[g];
|
|
1741
1742
|
for (let T = 0; T < 16; T++) {
|
|
1742
1743
|
const H = Y(o + Ct(g, i, c, h) + Q[b[T]] + P, w[T]) + d | 0;
|
|
1743
1744
|
o = d, d = h, h = Y(c, 10) | 0, c = i, i = H;
|
|
@@ -1756,25 +1757,25 @@ class nn extends Tt {
|
|
|
1756
1757
|
this.destroyed = !0, A(this.buffer), this.set(0, 0, 0, 0, 0);
|
|
1757
1758
|
}
|
|
1758
1759
|
}
|
|
1759
|
-
const
|
|
1760
|
-
function
|
|
1760
|
+
const on = /* @__PURE__ */ ct(() => new sn()), tt = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ot = /* @__PURE__ */ BigInt(32);
|
|
1761
|
+
function rn(e, t = !1) {
|
|
1761
1762
|
return t ? { h: Number(e & tt), l: Number(e >> Ot & tt) } : { h: Number(e >> Ot & tt) | 0, l: Number(e & tt) | 0 };
|
|
1762
1763
|
}
|
|
1763
|
-
function
|
|
1764
|
+
function se(e, t = !1) {
|
|
1764
1765
|
const n = e.length;
|
|
1765
1766
|
let s = new Uint32Array(n), o = new Uint32Array(n);
|
|
1766
1767
|
for (let r = 0; r < n; r++) {
|
|
1767
|
-
const { h: i, l: a } =
|
|
1768
|
+
const { h: i, l: a } = rn(e[r], t);
|
|
1768
1769
|
[s[r], o[r]] = [i, a];
|
|
1769
1770
|
}
|
|
1770
1771
|
return [s, o];
|
|
1771
1772
|
}
|
|
1772
|
-
const Lt = (e, t, n) => e >>> n, _t = (e, t, n) => e << 32 - n | t >>> n, N = (e, t, n) => e >>> n | t << 32 - n, X = (e, t, n) => e << 32 - n | t >>> n, et = (e, t, n) => e << 64 - n | t >>> n - 32, nt = (e, t, n) => e >>> n - 32 | t << 64 - n,
|
|
1773
|
+
const Lt = (e, t, n) => e >>> n, _t = (e, t, n) => e << 32 - n | t >>> n, N = (e, t, n) => e >>> n | t << 32 - n, X = (e, t, n) => e << 32 - n | t >>> n, et = (e, t, n) => e << 64 - n | t >>> n - 32, nt = (e, t, n) => e >>> n - 32 | t << 64 - n, an = (e, t, n) => e << n | t >>> 32 - n, cn = (e, t, n) => t << n | e >>> 32 - n, un = (e, t, n) => t << n - 32 | e >>> 64 - n, ln = (e, t, n) => e << n - 32 | t >>> 64 - n;
|
|
1773
1774
|
function F(e, t, n, s) {
|
|
1774
1775
|
const o = (t >>> 0) + (s >>> 0);
|
|
1775
1776
|
return { h: e + n + (o / 2 ** 32 | 0) | 0, l: o | 0 };
|
|
1776
1777
|
}
|
|
1777
|
-
const
|
|
1778
|
+
const hn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), dn = (e, t, n, s) => t + n + s + (e / 2 ** 32 | 0) | 0, fn = (e, t, n, s) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0), pn = (e, t, n, s, o) => t + n + s + o + (e / 2 ** 32 | 0) | 0, gn = (e, t, n, s, o) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0) + (o >>> 0), bn = (e, t, n, s, o, r) => t + n + s + o + r + (e / 2 ** 32 | 0) | 0, yn = /* @__PURE__ */ Uint32Array.from([
|
|
1778
1779
|
1116352408,
|
|
1779
1780
|
1899447441,
|
|
1780
1781
|
3049323471,
|
|
@@ -1840,7 +1841,7 @@ const ln = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), hn = (e, t, n, s) =>
|
|
|
1840
1841
|
3204031479,
|
|
1841
1842
|
3329325298
|
|
1842
1843
|
]), _ = /* @__PURE__ */ new Uint32Array(64);
|
|
1843
|
-
class
|
|
1844
|
+
class xn extends Tt {
|
|
1844
1845
|
constructor(t) {
|
|
1845
1846
|
super(64, t, 8, !1);
|
|
1846
1847
|
}
|
|
@@ -1861,7 +1862,7 @@ class yn extends Tt {
|
|
|
1861
1862
|
}
|
|
1862
1863
|
let { A: s, B: o, C: r, D: i, E: a, F: c, G: l, H: h } = this;
|
|
1863
1864
|
for (let u = 0; u < 64; u++) {
|
|
1864
|
-
const d = $(a, 6) ^ $(a, 11) ^ $(a, 25), y = h + d +
|
|
1865
|
+
const d = $(a, 6) ^ $(a, 11) ^ $(a, 25), y = h + d + ze(a, c, l) + yn[u] + _[u] | 0, x = ($(s, 2) ^ $(s, 13) ^ $(s, 22)) + Ze(s, o, r) | 0;
|
|
1865
1866
|
h = l, l = c, c = a, a = i + y | 0, i = r, r = o, o = s, s = y + x | 0;
|
|
1866
1867
|
}
|
|
1867
1868
|
s = s + this.A | 0, o = o + this.B | 0, r = r + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, h = h + this.H | 0, this.set(s, o, r, i, a, c, l, h);
|
|
@@ -1873,7 +1874,7 @@ class yn extends Tt {
|
|
|
1873
1874
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), A(this.buffer);
|
|
1874
1875
|
}
|
|
1875
1876
|
}
|
|
1876
|
-
class
|
|
1877
|
+
class wn extends xn {
|
|
1877
1878
|
constructor() {
|
|
1878
1879
|
super(32);
|
|
1879
1880
|
// We cannot use array here since array allows indexing by variable
|
|
@@ -1888,7 +1889,7 @@ class xn extends yn {
|
|
|
1888
1889
|
p(this, "H", L[7] | 0);
|
|
1889
1890
|
}
|
|
1890
1891
|
}
|
|
1891
|
-
const
|
|
1892
|
+
const oe = se([
|
|
1892
1893
|
"0x428a2f98d728ae22",
|
|
1893
1894
|
"0x7137449123ef65cd",
|
|
1894
1895
|
"0xb5c0fbcfec4d3b2f",
|
|
@@ -1969,8 +1970,8 @@ const se = ne([
|
|
|
1969
1970
|
"0x597f299cfc657e2a",
|
|
1970
1971
|
"0x5fcb6fab3ad6faec",
|
|
1971
1972
|
"0x6c44198c4a475817"
|
|
1972
|
-
].map((e) => BigInt(e))),
|
|
1973
|
-
class
|
|
1973
|
+
].map((e) => BigInt(e))), mn = oe[0], Pn = oe[1], R = /* @__PURE__ */ new Uint32Array(80), W = /* @__PURE__ */ new Uint32Array(80);
|
|
1974
|
+
class Tn extends Tt {
|
|
1974
1975
|
constructor(t) {
|
|
1975
1976
|
super(128, t, 16, !1);
|
|
1976
1977
|
}
|
|
@@ -1987,15 +1988,15 @@ class Pn extends Tt {
|
|
|
1987
1988
|
for (let f = 0; f < 16; f++, n += 4)
|
|
1988
1989
|
R[f] = t.getUint32(n), W[f] = t.getUint32(n += 4);
|
|
1989
1990
|
for (let f = 16; f < 80; f++) {
|
|
1990
|
-
const w = R[f - 15] | 0, v = W[f - 15] | 0, T = N(w, v, 1) ^ N(w, v, 8) ^ Lt(w, v, 7), H = X(w, v, 1) ^ X(w, v, 8) ^ _t(w, v, 7), E = R[f - 2] | 0, I = W[f - 2] | 0, C = N(E, I, 19) ^ et(E, I, 61) ^ Lt(E, I, 6), D = X(E, I, 19) ^ nt(E, I, 61) ^ _t(E, I, 6), O =
|
|
1991
|
+
const w = R[f - 15] | 0, v = W[f - 15] | 0, T = N(w, v, 1) ^ N(w, v, 8) ^ Lt(w, v, 7), H = X(w, v, 1) ^ X(w, v, 8) ^ _t(w, v, 7), E = R[f - 2] | 0, I = W[f - 2] | 0, C = N(E, I, 19) ^ et(E, I, 61) ^ Lt(E, I, 6), D = X(E, I, 19) ^ nt(E, I, 61) ^ _t(E, I, 6), O = fn(H, D, W[f - 7], W[f - 16]), ut = pn(O, T, C, R[f - 7], R[f - 16]);
|
|
1991
1992
|
R[f] = ut | 0, W[f] = O | 0;
|
|
1992
1993
|
}
|
|
1993
1994
|
let { Ah: s, Al: o, Bh: r, Bl: i, Ch: a, Cl: c, Dh: l, Dl: h, Eh: u, El: d, Fh: y, Fl: g, Gh: x, Gl: P, Hh: m, Hl: b } = this;
|
|
1994
1995
|
for (let f = 0; f < 80; f++) {
|
|
1995
|
-
const w = N(u, d, 14) ^ N(u, d, 18) ^ et(u, d, 41), v = X(u, d, 14) ^ X(u, d, 18) ^ nt(u, d, 41), T = u & y ^ ~u & x, H = d & g ^ ~d & P, E =
|
|
1996
|
+
const w = N(u, d, 14) ^ N(u, d, 18) ^ et(u, d, 41), v = X(u, d, 14) ^ X(u, d, 18) ^ nt(u, d, 41), T = u & y ^ ~u & x, H = d & g ^ ~d & P, E = gn(b, v, H, Pn[f], W[f]), I = bn(E, m, w, T, mn[f], R[f]), C = E | 0, D = N(s, o, 28) ^ et(s, o, 34) ^ et(s, o, 39), O = X(s, o, 28) ^ nt(s, o, 34) ^ nt(s, o, 39), ut = s & r ^ s & a ^ r & a, he = o & i ^ o & c ^ i & c;
|
|
1996
1997
|
m = x | 0, b = P | 0, x = y | 0, P = g | 0, y = u | 0, g = d | 0, { h: u, l: d } = F(l | 0, h | 0, I | 0, C | 0), l = a | 0, h = c | 0, a = r | 0, c = i | 0, r = s | 0, i = o | 0;
|
|
1997
|
-
const kt =
|
|
1998
|
-
s =
|
|
1998
|
+
const kt = hn(C, O, he);
|
|
1999
|
+
s = dn(kt, I, D, ut), o = kt | 0;
|
|
1999
2000
|
}
|
|
2000
2001
|
({ h: s, l: o } = F(this.Ah | 0, this.Al | 0, s | 0, o | 0)), { h: r, l: i } = F(this.Bh | 0, this.Bl | 0, r | 0, i | 0), { h: a, l: c } = F(this.Ch | 0, this.Cl | 0, a | 0, c | 0), { h: l, l: h } = F(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: u, l: d } = F(this.Eh | 0, this.El | 0, u | 0, d | 0), { h: y, l: g } = F(this.Fh | 0, this.Fl | 0, y | 0, g | 0), { h: x, l: P } = F(this.Gh | 0, this.Gl | 0, x | 0, P | 0), { h: m, l: b } = F(this.Hh | 0, this.Hl | 0, m | 0, b | 0), this.set(s, o, r, i, a, c, l, h, u, d, y, g, x, P, m, b);
|
|
2001
2002
|
}
|
|
@@ -2006,7 +2007,7 @@ class Pn extends Tt {
|
|
|
2006
2007
|
A(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2007
2008
|
}
|
|
2008
2009
|
}
|
|
2009
|
-
class
|
|
2010
|
+
class vn extends Tn {
|
|
2010
2011
|
constructor() {
|
|
2011
2012
|
super(64);
|
|
2012
2013
|
p(this, "Ah", k[0] | 0);
|
|
@@ -2027,22 +2028,22 @@ class Tn extends Pn {
|
|
|
2027
2028
|
p(this, "Hl", k[15] | 0);
|
|
2028
2029
|
}
|
|
2029
2030
|
}
|
|
2030
|
-
const
|
|
2031
|
-
() => new
|
|
2032
|
-
/* @__PURE__ */
|
|
2033
|
-
),
|
|
2034
|
-
() => new
|
|
2035
|
-
/* @__PURE__ */
|
|
2036
|
-
),
|
|
2031
|
+
const kn = /* @__PURE__ */ ct(
|
|
2032
|
+
() => new wn(),
|
|
2033
|
+
/* @__PURE__ */ Zt(1)
|
|
2034
|
+
), re = /* @__PURE__ */ ct(
|
|
2035
|
+
() => new vn(),
|
|
2036
|
+
/* @__PURE__ */ Zt(3)
|
|
2037
|
+
), Hn = BigInt(0), z = BigInt(1), En = BigInt(2), In = BigInt(7), Sn = BigInt(256), Bn = BigInt(113), ie = [], ae = [], ce = [];
|
|
2037
2038
|
for (let e = 0, t = z, n = 1, s = 0; e < 24; e++) {
|
|
2038
|
-
[n, s] = [s, (2 * n + 3 * s) % 5],
|
|
2039
|
-
let o =
|
|
2039
|
+
[n, s] = [s, (2 * n + 3 * s) % 5], ie.push(2 * (5 * s + n)), ae.push((e + 1) * (e + 2) / 2 % 64);
|
|
2040
|
+
let o = Hn;
|
|
2040
2041
|
for (let r = 0; r < 7; r++)
|
|
2041
|
-
t = (t << z ^ (t >>
|
|
2042
|
-
|
|
2042
|
+
t = (t << z ^ (t >> In) * Bn) % Sn, t & En && (o ^= z << (z << BigInt(r)) - z);
|
|
2043
|
+
ce.push(o);
|
|
2043
2044
|
}
|
|
2044
|
-
const
|
|
2045
|
-
function
|
|
2045
|
+
const ue = se(ce, !0), An = ue[0], $n = ue[1], Rt = (e, t, n) => n > 32 ? un(e, t, n) : an(e, t, n), Wt = (e, t, n) => n > 32 ? ln(e, t, n) : cn(e, t, n);
|
|
2046
|
+
function Un(e, t = 24) {
|
|
2046
2047
|
const n = new Uint32Array(10);
|
|
2047
2048
|
for (let s = 24 - t; s < 24; s++) {
|
|
2048
2049
|
for (let i = 0; i < 10; i++)
|
|
@@ -2054,7 +2055,7 @@ function $n(e, t = 24) {
|
|
|
2054
2055
|
}
|
|
2055
2056
|
let o = e[2], r = e[3];
|
|
2056
2057
|
for (let i = 0; i < 24; i++) {
|
|
2057
|
-
const a =
|
|
2058
|
+
const a = ae[i], c = Rt(o, r, a), l = Wt(o, r, a), h = ie[i];
|
|
2058
2059
|
o = e[h], r = e[h + 1], e[h] = c, e[h + 1] = l;
|
|
2059
2060
|
}
|
|
2060
2061
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -2063,7 +2064,7 @@ function $n(e, t = 24) {
|
|
|
2063
2064
|
for (let a = 0; a < 10; a++)
|
|
2064
2065
|
e[i + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
|
|
2065
2066
|
}
|
|
2066
|
-
e[0] ^=
|
|
2067
|
+
e[0] ^= An[s], e[1] ^= $n[s];
|
|
2067
2068
|
}
|
|
2068
2069
|
A(n);
|
|
2069
2070
|
}
|
|
@@ -2083,13 +2084,13 @@ class vt {
|
|
|
2083
2084
|
p(this, "rounds");
|
|
2084
2085
|
if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = o, this.rounds = r, V(s, "outputLen"), !(0 < t && t < 200))
|
|
2085
2086
|
throw new Error("only keccak-f1600 function is supported");
|
|
2086
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
2087
|
+
this.state = new Uint8Array(200), this.state32 = Me(this.state);
|
|
2087
2088
|
}
|
|
2088
2089
|
clone() {
|
|
2089
2090
|
return this._cloneInto();
|
|
2090
2091
|
}
|
|
2091
2092
|
keccak() {
|
|
2092
|
-
Ut(this.state32),
|
|
2093
|
+
Ut(this.state32), Un(this.state32, this.rounds), Ut(this.state32), this.posOut = 0, this.pos = 0;
|
|
2093
2094
|
}
|
|
2094
2095
|
update(t) {
|
|
2095
2096
|
G(this), K(t);
|
|
@@ -2128,7 +2129,7 @@ class vt {
|
|
|
2128
2129
|
return V(t), this.xofInto(new Uint8Array(t));
|
|
2129
2130
|
}
|
|
2130
2131
|
digestInto(t) {
|
|
2131
|
-
if (
|
|
2132
|
+
if (zt(t, this), this.finished)
|
|
2132
2133
|
throw new Error("digest() was already called");
|
|
2133
2134
|
return this.writeInto(t), this.destroy(), t;
|
|
2134
2135
|
}
|
|
@@ -2143,20 +2144,20 @@ class vt {
|
|
|
2143
2144
|
return t || (t = new vt(n, s, o, i, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = s, t.outputLen = o, t.enableXOF = i, t.destroyed = this.destroyed, t;
|
|
2144
2145
|
}
|
|
2145
2146
|
}
|
|
2146
|
-
const
|
|
2147
|
-
function
|
|
2148
|
-
|
|
2149
|
-
const o =
|
|
2147
|
+
const Fn = (e, t, n, s = {}) => ct(() => new vt(t, e, n), s), Cn = /* @__PURE__ */ Fn(1, 136, 32);
|
|
2148
|
+
function On(e, t, n, s) {
|
|
2149
|
+
jt(e);
|
|
2150
|
+
const o = je({ dkLen: 32, asyncTick: 10 }, s), { c: r, dkLen: i, asyncTick: a } = o;
|
|
2150
2151
|
if (V(r, "c"), V(i, "dkLen"), V(a, "asyncTick"), r < 1)
|
|
2151
2152
|
throw new Error("iterations (c) must be >= 1");
|
|
2152
2153
|
const c = Ft(t, "password"), l = Ft(n, "salt"), h = new Uint8Array(i), u = Pt.create(e, c), d = u._cloneInto().update(l);
|
|
2153
2154
|
return { c: r, dkLen: i, asyncTick: a, DK: h, PRF: u, PRFSalt: d };
|
|
2154
2155
|
}
|
|
2155
|
-
function
|
|
2156
|
+
function Ln(e, t, n, s, o) {
|
|
2156
2157
|
return e.destroy(), t.destroy(), s && s.destroy(), A(o), n;
|
|
2157
2158
|
}
|
|
2158
|
-
function
|
|
2159
|
-
const { c: o, dkLen: r, DK: i, PRF: a, PRFSalt: c } =
|
|
2159
|
+
function _n(e, t, n, s) {
|
|
2160
|
+
const { c: o, dkLen: r, DK: i, PRF: a, PRFSalt: c } = On(e, t, n, s);
|
|
2160
2161
|
let l;
|
|
2161
2162
|
const h = new Uint8Array(4), u = it(h), d = new Uint8Array(a.outputLen);
|
|
2162
2163
|
for (let y = 1, g = 0; g < r; y++, g += a.outputLen) {
|
|
@@ -2168,24 +2169,24 @@ function Ln(e, t, n, s) {
|
|
|
2168
2169
|
x[m] ^= d[m];
|
|
2169
2170
|
}
|
|
2170
2171
|
}
|
|
2171
|
-
return
|
|
2172
|
+
return Ln(a, c, i, l, d);
|
|
2172
2173
|
}
|
|
2173
|
-
function
|
|
2174
|
+
function le(e) {
|
|
2174
2175
|
if (typeof e != "string")
|
|
2175
2176
|
throw new TypeError("invalid mnemonic type: " + typeof e);
|
|
2176
2177
|
return e.normalize("NFKD");
|
|
2177
2178
|
}
|
|
2178
|
-
function
|
|
2179
|
-
const t =
|
|
2179
|
+
function Rn(e) {
|
|
2180
|
+
const t = le(e), n = t.split(" ");
|
|
2180
2181
|
if (![12, 15, 18, 21, 24].includes(n.length))
|
|
2181
2182
|
throw new Error("Invalid mnemonic");
|
|
2182
2183
|
return { nfkd: t, words: n };
|
|
2183
2184
|
}
|
|
2184
|
-
const
|
|
2185
|
-
function
|
|
2186
|
-
return
|
|
2185
|
+
const Wn = (e) => le("mnemonic" + e);
|
|
2186
|
+
function Vn(e, t = "") {
|
|
2187
|
+
return _n(re, Rn(e).nfkd, Wn(t), { c: 2048, dkLen: 64 });
|
|
2187
2188
|
}
|
|
2188
|
-
const
|
|
2189
|
+
const Kn = 508, Vt = 16, st = 32, ot = 64, Kt = 5, Dn = 4;
|
|
2189
2190
|
function Z(...e) {
|
|
2190
2191
|
const t = e.reduce((o, r) => o + r.length, 0), n = new Uint8Array(t);
|
|
2191
2192
|
let s = 0;
|
|
@@ -2197,21 +2198,21 @@ function ft(e) {
|
|
|
2197
2198
|
return new TextEncoder().encode(e);
|
|
2198
2199
|
}
|
|
2199
2200
|
function pt(e) {
|
|
2200
|
-
const t = new Uint8Array(
|
|
2201
|
+
const t = new Uint8Array(Dn);
|
|
2201
2202
|
return new DataView(t.buffer).setUint32(0, e.length, !1), Z(t, e);
|
|
2202
2203
|
}
|
|
2203
2204
|
function gt(e, t) {
|
|
2204
|
-
return Pt(
|
|
2205
|
+
return Pt(re, e, t);
|
|
2205
2206
|
}
|
|
2206
2207
|
function Dt(e) {
|
|
2207
|
-
return
|
|
2208
|
+
return on(kn(e));
|
|
2208
2209
|
}
|
|
2209
2210
|
const wt = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
2210
|
-
function
|
|
2211
|
-
const t =
|
|
2211
|
+
function Mn(e) {
|
|
2212
|
+
const t = Vn(e), n = new Uint8Array(t);
|
|
2212
2213
|
return t.fill(0), n;
|
|
2213
2214
|
}
|
|
2214
|
-
async function
|
|
2215
|
+
async function Nn(e, t, n, s) {
|
|
2215
2216
|
if (e.length !== ot)
|
|
2216
2217
|
throw new Error(
|
|
2217
2218
|
`WOTS seed must be ${ot} bytes, got ${e.length}`
|
|
@@ -2232,7 +2233,7 @@ async function Mn(e, t, n, s) {
|
|
|
2232
2233
|
const d = [], y = [], g = [], x = [];
|
|
2233
2234
|
let P = !1;
|
|
2234
2235
|
try {
|
|
2235
|
-
for (let m = 0; m <
|
|
2236
|
+
for (let m = 0; m < Kn; m++) {
|
|
2236
2237
|
const b = new Uint8Array(Kt);
|
|
2237
2238
|
b[0] = 0, new DataView(b.buffer).setUint32(1, m, !1);
|
|
2238
2239
|
const f = new Uint8Array(Kt);
|
|
@@ -2257,13 +2258,13 @@ async function Mn(e, t, n, s) {
|
|
|
2257
2258
|
a.fill(0);
|
|
2258
2259
|
}
|
|
2259
2260
|
}
|
|
2260
|
-
function
|
|
2261
|
+
function hs(e) {
|
|
2261
2262
|
return {
|
|
2262
2263
|
false_list: e.falseHashes.map(wt),
|
|
2263
2264
|
true_list: e.trueHashes.map(wt)
|
|
2264
2265
|
};
|
|
2265
2266
|
}
|
|
2266
|
-
function
|
|
2267
|
+
function Xn(e) {
|
|
2267
2268
|
if (e.falseHashes.length === 0 || e.trueHashes.length === 0)
|
|
2268
2269
|
throw new Error(
|
|
2269
2270
|
"computeWotsPkHash: keypair hash arrays must not be empty"
|
|
@@ -2274,20 +2275,20 @@ function Nn(e) {
|
|
|
2274
2275
|
s.set(i, o), o += t;
|
|
2275
2276
|
for (const i of e.trueHashes)
|
|
2276
2277
|
s.set(i, o), o += t;
|
|
2277
|
-
const r =
|
|
2278
|
+
const r = Cn(s);
|
|
2278
2279
|
return `0x${wt(r)}`;
|
|
2279
2280
|
}
|
|
2280
|
-
async function
|
|
2281
|
-
const o =
|
|
2281
|
+
async function ds(e, t, n, s) {
|
|
2282
|
+
const o = Mn(e);
|
|
2282
2283
|
try {
|
|
2283
|
-
const r = await
|
|
2284
|
+
const r = await Nn(
|
|
2284
2285
|
o,
|
|
2285
2286
|
t,
|
|
2286
2287
|
n,
|
|
2287
2288
|
s
|
|
2288
2289
|
);
|
|
2289
2290
|
try {
|
|
2290
|
-
return
|
|
2291
|
+
return Xn(r);
|
|
2291
2292
|
} finally {
|
|
2292
2293
|
for (const i of r.falsePreimages) i.fill(0);
|
|
2293
2294
|
for (const i of r.truePreimages) i.fill(0);
|
|
@@ -2296,43 +2297,43 @@ async function hs(e, t, n, s) {
|
|
|
2296
2297
|
o.fill(0);
|
|
2297
2298
|
}
|
|
2298
2299
|
}
|
|
2299
|
-
function
|
|
2300
|
+
function fs(e) {
|
|
2300
2301
|
const t = (e instanceof Error ? e.message : typeof e == "string" ? e : "").toLowerCase();
|
|
2301
2302
|
return t.includes("wots") && t.includes("hash") && t.includes("does not match");
|
|
2302
2303
|
}
|
|
2303
2304
|
export {
|
|
2304
|
-
|
|
2305
|
+
Xn as A,
|
|
2305
2306
|
rt as B,
|
|
2306
2307
|
q as C,
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2308
|
+
ds as D,
|
|
2309
|
+
fs as E,
|
|
2310
|
+
Le as M,
|
|
2311
|
+
us as P,
|
|
2312
|
+
Yn as a,
|
|
2313
|
+
ts as b,
|
|
2313
2314
|
dt as c,
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2315
|
+
es as d,
|
|
2316
|
+
Ue as e,
|
|
2317
|
+
Fe as f,
|
|
2318
|
+
Qn as g,
|
|
2318
2319
|
xt as h,
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2320
|
+
ls as i,
|
|
2321
|
+
rs as j,
|
|
2322
|
+
ss as k,
|
|
2323
|
+
os as l,
|
|
2324
|
+
is as m,
|
|
2325
|
+
ns as n,
|
|
2326
|
+
Re as o,
|
|
2327
|
+
We as p,
|
|
2328
|
+
_e as q,
|
|
2328
2329
|
j as r,
|
|
2329
|
-
|
|
2330
|
+
$e as s,
|
|
2330
2331
|
mt as t,
|
|
2331
|
-
|
|
2332
|
-
|
|
2332
|
+
as as u,
|
|
2333
|
+
cs as v,
|
|
2333
2334
|
M as w,
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2335
|
+
Mn as x,
|
|
2336
|
+
Nn as y,
|
|
2337
|
+
hs as z
|
|
2337
2338
|
};
|
|
2338
|
-
//# sourceMappingURL=errors-
|
|
2339
|
+
//# sourceMappingURL=errors-UqmtfBtv.js.map
|