@babylonlabs-io/ts-sdk 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -12
- package/dist/bitcoin-CNnPFU6Y.cjs +2 -0
- package/dist/bitcoin-CNnPFU6Y.cjs.map +1 -0
- package/dist/{constants-Q7v2O7Ps.js → bitcoin-nOOgeRyl.js} +64 -76
- package/dist/bitcoin-nOOgeRyl.js.map +1 -0
- package/dist/buildAndBroadcastRefund-DWEQvj9T.cjs +2 -0
- package/dist/buildAndBroadcastRefund-DWEQvj9T.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-DnTQkCgG.js +1331 -0
- package/dist/buildAndBroadcastRefund-DnTQkCgG.js.map +1 -0
- package/dist/challengeAssert-D1lpvuMv.js +283 -0
- package/dist/challengeAssert-D1lpvuMv.js.map +1 -0
- package/dist/challengeAssert-nYlgeAI8.cjs +2 -0
- package/dist/challengeAssert-nYlgeAI8.cjs.map +1 -0
- package/dist/errors-BZON3Wmn.cjs +2 -0
- package/dist/errors-BZON3Wmn.cjs.map +1 -0
- package/dist/{errors-aMocmFr-.js → errors-CHY4WNi-.js} +98 -97
- package/dist/errors-CHY4WNi-.js.map +1 -0
- package/dist/fundPeginTransaction-BLYXxLBv.js +70 -0
- package/dist/fundPeginTransaction-BLYXxLBv.js.map +1 -0
- package/dist/fundPeginTransaction-DxNOeyNI.cjs +2 -0
- package/dist/fundPeginTransaction-DxNOeyNI.cjs.map +1 -0
- package/dist/index-BpXpESWu.cjs +2 -0
- package/dist/index-BpXpESWu.cjs.map +1 -0
- package/dist/{index-BvFLf3vm.js → index-CFwoGJNQ.js} +146 -518
- package/dist/index-CFwoGJNQ.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +133 -109
- package/dist/payout-DzGsAnhf.js +261 -0
- package/dist/payout-DzGsAnhf.js.map +1 -0
- package/dist/payout-RFIh7GLN.cjs +2 -0
- package/dist/payout-RFIh7GLN.cjs.map +1 -0
- package/dist/psbtInputFields-C-zYR1z7.cjs +2 -0
- package/dist/psbtInputFields-C-zYR1z7.cjs.map +1 -0
- package/dist/psbtInputFields-Dx41_IoI.js +229 -0
- package/dist/psbtInputFields-Dx41_IoI.js.map +1 -0
- package/dist/signing-DeWVBl7m.js +64 -0
- package/dist/signing-DeWVBl7m.js.map +1 -0
- package/dist/signing-cl-lowxV.cjs +2 -0
- package/dist/signing-cl-lowxV.cjs.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +2 -2
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +3 -1
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +130 -106
- package/dist/tbv/core/managers/PeginManager.d.ts +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +3 -2
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +24 -23
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/index.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +2 -3
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +4 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/index.d.ts +1 -1
- package/dist/tbv/core/primitives/utils/index.d.ts.map +1 -1
- package/dist/tbv/core/services/activation/__tests__/activateVault.test.d.ts +2 -0
- package/dist/tbv/core/services/activation/__tests__/activateVault.test.d.ts.map +1 -0
- package/dist/tbv/core/services/activation/activateVault.d.ts +77 -0
- package/dist/tbv/core/services/activation/activateVault.d.ts.map +1 -0
- package/dist/tbv/core/services/activation/index.d.ts +7 -0
- package/dist/tbv/core/services/activation/index.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/__tests__/peginState.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/peginState.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/__tests__/validation.test.d.ts +5 -0
- package/dist/tbv/core/services/deposit/__tests__/validation.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +4 -0
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/peginState.d.ts +93 -0
- package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/validation.d.ts +114 -0
- package/dist/tbv/core/services/deposit/validation.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.d.ts +3 -0
- package/dist/tbv/core/services/index.d.ts.map +1 -1
- package/dist/tbv/core/services/index.js +25 -7
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/services/pegout/__tests__/state.test.d.ts +2 -0
- package/dist/tbv/core/services/pegout/__tests__/state.test.d.ts.map +1 -0
- package/dist/tbv/core/services/pegout/index.d.ts +2 -0
- package/dist/tbv/core/services/pegout/index.d.ts.map +1 -0
- package/dist/tbv/core/services/pegout/state.d.ts +30 -0
- package/dist/tbv/core/services/pegout/state.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/__tests__/buildAndBroadcastRefund.test.d.ts +2 -0
- package/dist/tbv/core/services/refund/__tests__/buildAndBroadcastRefund.test.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts +103 -0
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/errors.d.ts +13 -0
- package/dist/tbv/core/services/refund/errors.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/index.d.ts +8 -0
- package/dist/tbv/core/services/refund/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +30 -24
- package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts +1 -1
- package/dist/tbv/core/utils/utxo/__tests__/availability.test.d.ts +3 -0
- package/dist/tbv/core/utils/utxo/__tests__/availability.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts +3 -0
- package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/availability.d.ts +62 -0
- package/dist/tbv/core/utils/utxo/availability.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/index.d.ts +2 -0
- package/dist/tbv/core/utils/utxo/index.d.ts.map +1 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts +65 -0
- package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -0
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +130 -106
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.d.ts +3 -3
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +145 -169
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/tbv/integrations/aave/utils/healthFactor.d.ts +0 -30
- package/dist/tbv/integrations/aave/utils/healthFactor.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/utils/index.d.ts +2 -2
- package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -1
- package/dist/types-B-p4dhEH.cjs +2 -0
- package/dist/types-B-p4dhEH.cjs.map +1 -0
- package/dist/types-DWjaqVfP.js +608 -0
- package/dist/types-DWjaqVfP.js.map +1 -0
- package/package.json +5 -1
- package/dist/challengeAssert-D_k_ADgP.cjs +0 -2
- package/dist/challengeAssert-D_k_ADgP.cjs.map +0 -1
- package/dist/challengeAssert-k5_LWUtO.js +0 -362
- package/dist/challengeAssert-k5_LWUtO.js.map +0 -1
- package/dist/constants-EiyZkXce.cjs +0 -2
- package/dist/constants-EiyZkXce.cjs.map +0 -1
- package/dist/constants-Q7v2O7Ps.js.map +0 -1
- package/dist/errors-DVNYib5y.cjs +0 -2
- package/dist/errors-DVNYib5y.cjs.map +0 -1
- package/dist/errors-aMocmFr-.js.map +0 -1
- package/dist/fundPeginTransaction-DpwnDslW.js +0 -50
- package/dist/fundPeginTransaction-DpwnDslW.js.map +0 -1
- package/dist/fundPeginTransaction-EbrZzlrh.cjs +0 -2
- package/dist/fundPeginTransaction-EbrZzlrh.cjs.map +0 -1
- package/dist/index-BX-V3C9t.js +0 -995
- package/dist/index-BX-V3C9t.js.map +0 -1
- package/dist/index-BgnxXV5G.cjs +0 -2
- package/dist/index-BgnxXV5G.cjs.map +0 -1
- package/dist/index-BvFLf3vm.js.map +0 -1
- package/dist/index-DpKhuCta.cjs +0 -2
- package/dist/index-DpKhuCta.cjs.map +0 -1
- package/dist/payout-Ce9vSs9e.js +0 -164
- package/dist/payout-Ce9vSs9e.js.map +0 -1
- package/dist/payout-CfsDnjKI.cjs +0 -2
- package/dist/payout-CfsDnjKI.cjs.map +0 -1
- package/dist/psbtInputFields-C0nKn_GD.cjs +0 -2
- package/dist/psbtInputFields-C0nKn_GD.cjs.map +0 -1
- package/dist/psbtInputFields-DO0ELwiv.js +0 -116
- package/dist/psbtInputFields-DO0ELwiv.js.map +0 -1
- package/dist/signing-Deg5lCoC.cjs +0 -2
- package/dist/signing-Deg5lCoC.cjs.map +0 -1
- package/dist/signing-Drwr3bXB.js +0 -16
- package/dist/signing-Drwr3bXB.js.map +0 -1
- package/dist/types-D1rYwwCu.js +0 -235
- package/dist/types-D1rYwwCu.js.map +0 -1
- package/dist/types-DEWiqXYp.cjs +0 -2
- package/dist/types-DEWiqXYp.cjs.map +0 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
var qt = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var x = (e, t, n) =>
|
|
4
|
-
import * as
|
|
2
|
+
var Gt = (e, t, n) => t in e ? qt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var x = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import * as zt from "bitcoinjs-lib";
|
|
5
5
|
import { Transaction as Zt, Psbt as mt } from "bitcoinjs-lib";
|
|
6
6
|
import { Buffer as q } from "buffer";
|
|
7
|
-
import { createPublicClient as
|
|
8
|
-
import { c as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { b as
|
|
13
|
-
import {
|
|
14
|
-
import { f as he } from "./
|
|
15
|
-
import {
|
|
7
|
+
import { createPublicClient as G, http as z, encodeFunctionData as yt, zeroAddress as Jt } from "viem";
|
|
8
|
+
import { c as Yt } from "./signing-DeWVBl7m.js";
|
|
9
|
+
import { deriveVaultId as wt } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
10
|
+
import { b as Qt, a as te, d as ee, e as ne, f as se } from "./challengeAssert-D1lpvuMv.js";
|
|
11
|
+
import { s as E, g as bt, e as H, i as oe } from "./bitcoin-nOOgeRyl.js";
|
|
12
|
+
import { b as re, f as Z, i as ie } from "./psbtInputFields-Dx41_IoI.js";
|
|
13
|
+
import { p as ae, f as ce } from "./fundPeginTransaction-BLYXxLBv.js";
|
|
14
|
+
import { p as le, f as he } from "./index-CFwoGJNQ.js";
|
|
15
|
+
import { B as $ } from "./types-DWjaqVfP.js";
|
|
16
|
+
import { n as St, o as K, q as S, r as M, t as Bt, H as ue, u as U, x as fe, y as L, z as de, A as xt, D as ge, E as pe, F as me, G as ye, I as we, J as be, K as xe, L as Pt, M as ut, N as Ct } from "./buildAndBroadcastRefund-DnTQkCgG.js";
|
|
16
17
|
const B = {
|
|
17
18
|
// VaultAlreadyExists()
|
|
18
19
|
"0x04aabf33": "Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.",
|
|
@@ -62,14 +63,14 @@ function ft(e) {
|
|
|
62
63
|
if (i)
|
|
63
64
|
return i[1];
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function wn(e) {
|
|
66
67
|
const t = ft(e);
|
|
67
68
|
if (t) {
|
|
68
69
|
const n = t.substring(0, 10);
|
|
69
70
|
return B[t] ?? B[n];
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function bn(e) {
|
|
73
74
|
const t = ft(e);
|
|
74
75
|
if (t === void 0) return !1;
|
|
75
76
|
const n = t.substring(0, 10);
|
|
@@ -105,10 +106,10 @@ function ke(e, t, n, s) {
|
|
|
105
106
|
vout: t,
|
|
106
107
|
value: o.value,
|
|
107
108
|
scriptPubKey: o.scriptPubKey
|
|
108
|
-
}) :
|
|
109
|
+
}) : he(e, t, s);
|
|
109
110
|
}
|
|
110
111
|
const kt = 12e4;
|
|
111
|
-
class
|
|
112
|
+
class xn {
|
|
112
113
|
/**
|
|
113
114
|
* Creates a new PeginManager instance.
|
|
114
115
|
*
|
|
@@ -127,7 +128,7 @@ class bn {
|
|
|
127
128
|
* 2. Build unfunded Pre-PegIn transaction (HTLC output) using primitives
|
|
128
129
|
* 3. Select UTXOs to cover the HTLC value
|
|
129
130
|
* 4. Fund the Pre-PegIn transaction
|
|
130
|
-
* 5. Derive the PegIn transaction from the funded Pre-PegIn
|
|
131
|
+
* 5. Derive the PegIn transaction from the funded Pre-PegIn tx
|
|
131
132
|
* 6. Build PSBT for signing the PegIn input (HTLC leaf 0)
|
|
132
133
|
* 7. Sign via BTC wallet and extract depositor signature
|
|
133
134
|
*
|
|
@@ -159,12 +160,12 @@ class bn {
|
|
|
159
160
|
councilQuorum: t.councilQuorum,
|
|
160
161
|
councilSize: t.councilSize,
|
|
161
162
|
network: this.config.btcNetwork
|
|
162
|
-
}, u = await
|
|
163
|
+
}, u = await Qt(d), h = re(
|
|
163
164
|
[...t.availableUTXOs],
|
|
164
165
|
u.totalOutputValue,
|
|
165
166
|
t.mempoolFeeRate,
|
|
166
|
-
|
|
167
|
-
), m =
|
|
167
|
+
ae(u.htlcValues.length)
|
|
168
|
+
), m = bt(this.config.btcNetwork), l = ce({
|
|
168
169
|
unfundedTxHex: u.psbtHex,
|
|
169
170
|
selectedUTXOs: h.selectedUTXOs,
|
|
170
171
|
changeAddress: t.changeAddress,
|
|
@@ -172,12 +173,12 @@ class bn {
|
|
|
172
173
|
network: m
|
|
173
174
|
}), y = E(Z(l)), p = [], w = [], P = [];
|
|
174
175
|
for (let g = 0; g < t.hashlocks.length; g++) {
|
|
175
|
-
const b = await
|
|
176
|
+
const b = await te({
|
|
176
177
|
prePeginParams: d,
|
|
177
178
|
timelockPegin: t.timelockPegin,
|
|
178
179
|
fundedPrePeginTxHex: l,
|
|
179
180
|
htlcVout: g
|
|
180
|
-
}), T = await
|
|
181
|
+
}), T = await ee({
|
|
181
182
|
peginTxHex: b.txHex,
|
|
182
183
|
fundedPrePeginTxHex: l,
|
|
183
184
|
depositorPubkey: s,
|
|
@@ -189,7 +190,7 @@ class bn {
|
|
|
189
190
|
network: this.config.btcNetwork
|
|
190
191
|
});
|
|
191
192
|
p.push(b), w.push(T.psbtHex), P.push(
|
|
192
|
-
|
|
193
|
+
Yt(n, 1)
|
|
193
194
|
);
|
|
194
195
|
}
|
|
195
196
|
const f = await this.signPsbtsWithFallback(
|
|
@@ -197,10 +198,10 @@ class bn {
|
|
|
197
198
|
P
|
|
198
199
|
), c = [];
|
|
199
200
|
for (let g = 0; g < f.length; g++) {
|
|
200
|
-
const b =
|
|
201
|
+
const b = ne(
|
|
201
202
|
f[g],
|
|
202
203
|
s
|
|
203
|
-
), T =
|
|
204
|
+
), T = se(f[g]);
|
|
204
205
|
c.push({
|
|
205
206
|
htlcVout: g,
|
|
206
207
|
htlcValue: u.htlcValues[g],
|
|
@@ -297,7 +298,7 @@ class bn {
|
|
|
297
298
|
`UTXO value mismatch: total input value (${l} sat) is less than total output value (${y} sat). This may indicate the mempool API returned manipulated UTXO data.`
|
|
298
299
|
);
|
|
299
300
|
for (const { input: c, utxoData: g, txid: b, vout: T } of m) {
|
|
300
|
-
const k =
|
|
301
|
+
const k = ie(
|
|
301
302
|
{
|
|
302
303
|
value: g.value,
|
|
303
304
|
scriptPubKey: g.scriptPubKey
|
|
@@ -328,7 +329,7 @@ class bn {
|
|
|
328
329
|
);
|
|
329
330
|
}
|
|
330
331
|
const P = w.extractTransaction().toHex();
|
|
331
|
-
return await
|
|
332
|
+
return await le(P, u);
|
|
332
333
|
}
|
|
333
334
|
/**
|
|
334
335
|
* Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
|
|
@@ -369,7 +370,7 @@ class bn {
|
|
|
369
370
|
d && await d();
|
|
370
371
|
const p = H(n), w = H(s), P = H(o), f = await this.resolvePayoutScriptPubKey(
|
|
371
372
|
u
|
|
372
|
-
), c = Z(P), g = await
|
|
373
|
+
), c = Z(P), g = await wt(
|
|
373
374
|
E(c),
|
|
374
375
|
E(l)
|
|
375
376
|
), b = H(g);
|
|
@@ -377,9 +378,9 @@ class bn {
|
|
|
377
378
|
throw new Error(
|
|
378
379
|
`Vault already exists (ID: ${b}, peginTxHash: ${c}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
|
|
379
380
|
);
|
|
380
|
-
const k =
|
|
381
|
+
const k = G({
|
|
381
382
|
chain: this.config.ethChain,
|
|
382
|
-
transport:
|
|
383
|
+
transport: z()
|
|
383
384
|
});
|
|
384
385
|
let v;
|
|
385
386
|
try {
|
|
@@ -418,12 +419,12 @@ class bn {
|
|
|
418
419
|
value: v,
|
|
419
420
|
account: this.config.ethWallet.account.address
|
|
420
421
|
});
|
|
421
|
-
} catch (
|
|
422
|
-
_(
|
|
422
|
+
} catch (j) {
|
|
423
|
+
_(j);
|
|
423
424
|
}
|
|
424
|
-
let
|
|
425
|
+
let X;
|
|
425
426
|
try {
|
|
426
|
-
|
|
427
|
+
X = await this.config.ethWallet.sendTransaction({
|
|
427
428
|
to: this.config.vaultContracts.btcVaultRegistry,
|
|
428
429
|
data: C,
|
|
429
430
|
value: v,
|
|
@@ -431,16 +432,16 @@ class bn {
|
|
|
431
432
|
chain: this.config.ethChain,
|
|
432
433
|
gas: A
|
|
433
434
|
});
|
|
434
|
-
} catch (
|
|
435
|
-
_(
|
|
435
|
+
} catch (j) {
|
|
436
|
+
_(j);
|
|
436
437
|
}
|
|
437
438
|
const pt = await k.waitForTransactionReceipt({
|
|
438
|
-
hash:
|
|
439
|
+
hash: X,
|
|
439
440
|
timeout: kt
|
|
440
441
|
});
|
|
441
442
|
return pt.status === "reverted" && _(
|
|
442
443
|
new Error(
|
|
443
|
-
`Transaction reverted. Hash: ${
|
|
444
|
+
`Transaction reverted. Hash: ${X}. Check the transaction on block explorer for details.`
|
|
444
445
|
)
|
|
445
446
|
), {
|
|
446
447
|
ethTxHash: pt.transactionHash,
|
|
@@ -479,7 +480,7 @@ class bn {
|
|
|
479
480
|
for (const c of s) {
|
|
480
481
|
const g = H(
|
|
481
482
|
c.depositorSignedPeginTx
|
|
482
|
-
), b = Z(g), T = await
|
|
483
|
+
), b = Z(g), T = await wt(
|
|
483
484
|
E(b),
|
|
484
485
|
E(i)
|
|
485
486
|
), k = H(T);
|
|
@@ -489,9 +490,9 @@ class bn {
|
|
|
489
490
|
);
|
|
490
491
|
u.push({ vaultId: k, peginTxHash: b });
|
|
491
492
|
}
|
|
492
|
-
const h =
|
|
493
|
+
const h = G({
|
|
493
494
|
chain: this.config.ethChain,
|
|
494
|
-
transport:
|
|
495
|
+
transport: z()
|
|
495
496
|
});
|
|
496
497
|
let m;
|
|
497
498
|
try {
|
|
@@ -569,15 +570,15 @@ class bn {
|
|
|
569
570
|
*/
|
|
570
571
|
async checkVaultExists(t) {
|
|
571
572
|
try {
|
|
572
|
-
return (await
|
|
573
|
+
return (await G({
|
|
573
574
|
chain: this.config.ethChain,
|
|
574
|
-
transport:
|
|
575
|
+
transport: z()
|
|
575
576
|
}).readContract({
|
|
576
577
|
address: this.config.vaultContracts.btcVaultRegistry,
|
|
577
578
|
abi: $,
|
|
578
579
|
functionName: "getBtcVaultBasicInfo",
|
|
579
580
|
args: [t]
|
|
580
|
-
}))[0] !==
|
|
581
|
+
}))[0] !== Jt;
|
|
581
582
|
} catch {
|
|
582
583
|
return !1;
|
|
583
584
|
}
|
|
@@ -596,7 +597,7 @@ class bn {
|
|
|
596
597
|
else {
|
|
597
598
|
n = await this.config.btcWallet.getAddress();
|
|
598
599
|
const o = await this.config.btcWallet.getPublicKeyHex();
|
|
599
|
-
if (!
|
|
600
|
+
if (!oe(
|
|
600
601
|
n,
|
|
601
602
|
o,
|
|
602
603
|
this.config.btcNetwork
|
|
@@ -605,9 +606,9 @@ class bn {
|
|
|
605
606
|
"The BTC address from your wallet does not match the wallet's public key. Please ensure your wallet is using a supported address type (Taproot or Native SegWit)."
|
|
606
607
|
);
|
|
607
608
|
}
|
|
608
|
-
const s =
|
|
609
|
+
const s = bt(this.config.btcNetwork);
|
|
609
610
|
try {
|
|
610
|
-
return `0x${
|
|
611
|
+
return `0x${zt.address.toOutputScript(n, s).toString("hex")}`;
|
|
611
612
|
} catch {
|
|
612
613
|
throw new Error(
|
|
613
614
|
`Invalid BTC payout address: "${n}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
|
|
@@ -713,13 +714,13 @@ const Te = /* @__PURE__ */ Uint8Array.from([
|
|
|
713
714
|
for (let o of n)
|
|
714
715
|
o.push(o[s].map((r) => Te[r]));
|
|
715
716
|
return n;
|
|
716
|
-
})(), Rt = Ot[0],
|
|
717
|
+
})(), Rt = Ot[0], Lt = Ot[1], Ut = /* @__PURE__ */ [
|
|
717
718
|
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
718
719
|
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
719
720
|
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
720
721
|
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
721
722
|
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
|
|
722
|
-
].map((e) => Uint8Array.from(e)), ve = /* @__PURE__ */ Rt.map((e, t) => e.map((n) =>
|
|
723
|
+
].map((e) => Uint8Array.from(e)), ve = /* @__PURE__ */ Rt.map((e, t) => e.map((n) => Ut[t][n])), Ee = /* @__PURE__ */ Lt.map((e, t) => e.map((n) => Ut[t][n])), He = /* @__PURE__ */ Uint32Array.from([
|
|
723
724
|
0,
|
|
724
725
|
1518500249,
|
|
725
726
|
1859775393,
|
|
@@ -757,14 +758,14 @@ class Se extends ue {
|
|
|
757
758
|
W[p] = n.getUint32(s, !0);
|
|
758
759
|
let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, d = this.h2 | 0, u = d, h = this.h3 | 0, m = h, l = this.h4 | 0, y = l;
|
|
759
760
|
for (let p = 0; p < 5; p++) {
|
|
760
|
-
const w = 4 - p, P = He[p], f = _e[p], c = Rt[p], g =
|
|
761
|
+
const w = 4 - p, P = He[p], f = _e[p], c = Rt[p], g = Lt[p], b = ve[p], T = Ee[p];
|
|
761
762
|
for (let k = 0; k < 16; k++) {
|
|
762
|
-
const v =
|
|
763
|
-
o = l, l = h, h =
|
|
763
|
+
const v = U(o + Tt(p, i, d, h) + W[c[k]] + P, b[k]) + l | 0;
|
|
764
|
+
o = l, l = h, h = U(d, 10) | 0, d = i, i = v;
|
|
764
765
|
}
|
|
765
766
|
for (let k = 0; k < 16; k++) {
|
|
766
|
-
const v =
|
|
767
|
-
r = y, y = m, m =
|
|
767
|
+
const v = U(r + Tt(w, a, u, m) + W[g[k]] + f, T[k]) + y | 0;
|
|
768
|
+
r = y, y = m, m = U(u, 10) | 0, u = a, a = v;
|
|
768
769
|
}
|
|
769
770
|
}
|
|
770
771
|
this.set(this.h1 + d + m | 0, this.h2 + h + y | 0, this.h3 + l + r | 0, this.h4 + o + a | 0, this.h0 + i + u | 0);
|
|
@@ -784,8 +785,8 @@ for (let e = 0, t = O, n = 1, s = 0; e < 24; e++) {
|
|
|
784
785
|
t = (t << O ^ (t >> Ae) * Oe) % $e, t & Ce && (o ^= O << (O << BigInt(r)) - O);
|
|
785
786
|
Dt.push(o);
|
|
786
787
|
}
|
|
787
|
-
const Kt = fe(Dt, !0), Re = Kt[0],
|
|
788
|
-
function
|
|
788
|
+
const Kt = fe(Dt, !0), Re = Kt[0], Le = Kt[1], It = (e, t, n) => n > 32 ? ye(e, t, n) : pe(e, t, n), vt = (e, t, n) => n > 32 ? we(e, t, n) : me(e, t, n);
|
|
789
|
+
function Ue(e, t = 24) {
|
|
789
790
|
const n = new Uint32Array(10);
|
|
790
791
|
for (let s = 24 - t; s < 24; s++) {
|
|
791
792
|
for (let i = 0; i < 10; i++)
|
|
@@ -806,7 +807,7 @@ function Le(e, t = 24) {
|
|
|
806
807
|
for (let a = 0; a < 10; a++)
|
|
807
808
|
e[i + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
|
|
808
809
|
}
|
|
809
|
-
e[0] ^= Re[s], e[1] ^=
|
|
810
|
+
e[0] ^= Re[s], e[1] ^= Le[s];
|
|
810
811
|
}
|
|
811
812
|
S(n);
|
|
812
813
|
}
|
|
@@ -824,7 +825,7 @@ class dt {
|
|
|
824
825
|
x(this, "outputLen");
|
|
825
826
|
x(this, "enableXOF", !1);
|
|
826
827
|
x(this, "rounds");
|
|
827
|
-
if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = o, this.rounds = r,
|
|
828
|
+
if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = o, this.rounds = r, L(s, "outputLen"), !(0 < t && t < 200))
|
|
828
829
|
throw new Error("only keccak-f1600 function is supported");
|
|
829
830
|
this.state = new Uint8Array(200), this.state32 = de(this.state);
|
|
830
831
|
}
|
|
@@ -832,7 +833,7 @@ class dt {
|
|
|
832
833
|
return this._cloneInto();
|
|
833
834
|
}
|
|
834
835
|
keccak() {
|
|
835
|
-
xt(this.state32),
|
|
836
|
+
xt(this.state32), Ue(this.state32, this.rounds), xt(this.state32), this.posOut = 0, this.pos = 0;
|
|
836
837
|
}
|
|
837
838
|
update(t) {
|
|
838
839
|
M(this), K(t);
|
|
@@ -868,7 +869,7 @@ class dt {
|
|
|
868
869
|
return this.writeInto(t);
|
|
869
870
|
}
|
|
870
871
|
xof(t) {
|
|
871
|
-
return
|
|
872
|
+
return L(t), this.xofInto(new Uint8Array(t));
|
|
872
873
|
}
|
|
873
874
|
digestInto(t) {
|
|
874
875
|
if (ge(t, this), this.finished)
|
|
@@ -890,7 +891,7 @@ const We = (e, t, n, s = {}) => Bt(() => new dt(t, e, n), s), Mt = /* @__PURE__
|
|
|
890
891
|
function Ve(e, t, n, s) {
|
|
891
892
|
St(e);
|
|
892
893
|
const o = xe({ dkLen: 32, asyncTick: 10 }, s), { c: r, dkLen: i, asyncTick: a } = o;
|
|
893
|
-
if (
|
|
894
|
+
if (L(r, "c"), L(i, "dkLen"), L(a, "asyncTick"), r < 1)
|
|
894
895
|
throw new Error("iterations (c) must be >= 1");
|
|
895
896
|
const d = Pt(t, "password"), u = Pt(n, "salt"), h = new Uint8Array(i), m = N.create(e, d), l = m._cloneInto().update(u);
|
|
896
897
|
return { c: r, dkLen: i, asyncTick: a, DK: h, PRF: m, PRFSalt: l };
|
|
@@ -928,7 +929,7 @@ const Me = (e) => Nt("mnemonic" + e);
|
|
|
928
929
|
function Ne(e, t = "") {
|
|
929
930
|
return De(ut, Ke(e).nfkd, Me(t), { c: 2048, dkLen: 64 });
|
|
930
931
|
}
|
|
931
|
-
const
|
|
932
|
+
const Xe = 508, Et = 16, V = 32, F = 64, Ht = 5, je = 4;
|
|
932
933
|
function R(...e) {
|
|
933
934
|
const t = e.reduce((o, r) => o + r.length, 0), n = new Uint8Array(t);
|
|
934
935
|
let s = 0;
|
|
@@ -936,11 +937,11 @@ function R(...e) {
|
|
|
936
937
|
n.set(o, s), s += o.length;
|
|
937
938
|
return n;
|
|
938
939
|
}
|
|
939
|
-
function
|
|
940
|
+
function J(e) {
|
|
940
941
|
return new TextEncoder().encode(e);
|
|
941
942
|
}
|
|
942
|
-
function
|
|
943
|
-
const t = new Uint8Array(
|
|
943
|
+
function Y(e) {
|
|
944
|
+
const t = new Uint8Array(je);
|
|
944
945
|
return new DataView(t.buffer).setUint32(0, e.length, !1), R(t, e);
|
|
945
946
|
}
|
|
946
947
|
function Q(e, t) {
|
|
@@ -954,7 +955,7 @@ function qe(e) {
|
|
|
954
955
|
const t = Ne(e), n = new Uint8Array(t);
|
|
955
956
|
return t.fill(0), n;
|
|
956
957
|
}
|
|
957
|
-
async function
|
|
958
|
+
async function Ge(e, t, n, s) {
|
|
958
959
|
if (e.length !== F)
|
|
959
960
|
throw new Error(
|
|
960
961
|
`WOTS seed must be ${F} bytes, got ${e.length}`
|
|
@@ -963,9 +964,9 @@ async function ze(e, t, n, s) {
|
|
|
963
964
|
const o = e.slice(V, F), r = e.slice(0, V), i = [o, r];
|
|
964
965
|
try {
|
|
965
966
|
const a = R(
|
|
966
|
-
J(
|
|
967
|
-
J(
|
|
968
|
-
J(
|
|
967
|
+
Y(J(t)),
|
|
968
|
+
Y(J(n)),
|
|
969
|
+
Y(J(s))
|
|
969
970
|
), d = R(r, a);
|
|
970
971
|
i.push(d);
|
|
971
972
|
const u = Q(o, d);
|
|
@@ -975,7 +976,7 @@ async function ze(e, t, n, s) {
|
|
|
975
976
|
const l = [], y = [], p = [], w = [];
|
|
976
977
|
let P = !1;
|
|
977
978
|
try {
|
|
978
|
-
for (let f = 0; f <
|
|
979
|
+
for (let f = 0; f < Xe; f++) {
|
|
979
980
|
const c = new Uint8Array(Ht);
|
|
980
981
|
c[0] = 0, new DataView(c.buffer).setUint32(1, f, !1);
|
|
981
982
|
const g = new Uint8Array(Ht);
|
|
@@ -1000,13 +1001,13 @@ async function ze(e, t, n, s) {
|
|
|
1000
1001
|
a.fill(0);
|
|
1001
1002
|
}
|
|
1002
1003
|
}
|
|
1003
|
-
function
|
|
1004
|
+
function Pn(e) {
|
|
1004
1005
|
return {
|
|
1005
1006
|
false_list: e.falseHashes.map(ct),
|
|
1006
1007
|
true_list: e.trueHashes.map(ct)
|
|
1007
1008
|
};
|
|
1008
1009
|
}
|
|
1009
|
-
function
|
|
1010
|
+
function ze(e) {
|
|
1010
1011
|
if (e.falseHashes.length === 0 || e.trueHashes.length === 0)
|
|
1011
1012
|
throw new Error(
|
|
1012
1013
|
"computeWotsPkHash: keypair hash arrays must not be empty"
|
|
@@ -1020,7 +1021,7 @@ function Ge(e) {
|
|
|
1020
1021
|
const r = Mt(s);
|
|
1021
1022
|
return `0x${ct(r)}`;
|
|
1022
1023
|
}
|
|
1023
|
-
const tt = 32, et = 64, Ze = 4, I = 20, lt = 4,
|
|
1024
|
+
const tt = 32, et = 64, Ze = 4, I = 20, lt = 4, Xt = 2, Je = 0, Ye = 1, D = [64, 64];
|
|
1024
1025
|
function ht(...e) {
|
|
1025
1026
|
const t = e.reduce((o, r) => o + r.length, 0), n = new Uint8Array(t);
|
|
1026
1027
|
let s = 0;
|
|
@@ -1045,7 +1046,7 @@ function tn(e, t) {
|
|
|
1045
1046
|
function gt(e) {
|
|
1046
1047
|
return Wt(Ct(e));
|
|
1047
1048
|
}
|
|
1048
|
-
function
|
|
1049
|
+
function jt(e) {
|
|
1049
1050
|
return (1 << e) - 1;
|
|
1050
1051
|
}
|
|
1051
1052
|
function en(e) {
|
|
@@ -1054,7 +1055,7 @@ function en(e) {
|
|
|
1054
1055
|
return Math.max(t, 2);
|
|
1055
1056
|
}
|
|
1056
1057
|
function nn(e) {
|
|
1057
|
-
const t = lt, n =
|
|
1058
|
+
const t = lt, n = jt(t), s = e * n;
|
|
1058
1059
|
return { d: t, n: e, checksum_radix: en(s) };
|
|
1059
1060
|
}
|
|
1060
1061
|
function rt(e, t) {
|
|
@@ -1075,20 +1076,20 @@ function it(e, t) {
|
|
|
1075
1076
|
return n;
|
|
1076
1077
|
}
|
|
1077
1078
|
function sn(e, t) {
|
|
1078
|
-
const n =
|
|
1079
|
+
const n = jt(t.d), s = t.checksum_radix - 1, o = Math.floor(t.n * n / t.checksum_radix), r = [];
|
|
1079
1080
|
for (let h = 0; h < t.n; h++) {
|
|
1080
|
-
const m = rt(e, h +
|
|
1081
|
+
const m = rt(e, h + Xt), l = it(m, n);
|
|
1081
1082
|
r.push(Array.from(l));
|
|
1082
1083
|
}
|
|
1083
1084
|
const i = rt(
|
|
1084
1085
|
e,
|
|
1085
|
-
|
|
1086
|
+
Je
|
|
1086
1087
|
), a = it(
|
|
1087
1088
|
i,
|
|
1088
1089
|
s
|
|
1089
1090
|
), d = rt(
|
|
1090
1091
|
e,
|
|
1091
|
-
|
|
1092
|
+
Ye
|
|
1092
1093
|
), u = it(
|
|
1093
1094
|
d,
|
|
1094
1095
|
o
|
|
@@ -1100,7 +1101,7 @@ function sn(e, t) {
|
|
|
1100
1101
|
checksum_minor_terminal: Array.from(a)
|
|
1101
1102
|
};
|
|
1102
1103
|
}
|
|
1103
|
-
async function
|
|
1104
|
+
async function kn(e, t, n, s) {
|
|
1104
1105
|
if (e.length !== et)
|
|
1105
1106
|
throw new Error(
|
|
1106
1107
|
`WOTS seed must be exactly ${et} bytes, got ${e.length}`
|
|
@@ -1161,7 +1162,7 @@ function at(e, t, n) {
|
|
|
1161
1162
|
);
|
|
1162
1163
|
}
|
|
1163
1164
|
}
|
|
1164
|
-
function
|
|
1165
|
+
function Tn(e) {
|
|
1165
1166
|
if (e.length === 0)
|
|
1166
1167
|
throw new Error("Public keys array must not be empty");
|
|
1167
1168
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -1172,7 +1173,7 @@ function kn(e) {
|
|
|
1172
1173
|
}
|
|
1173
1174
|
let t = 0;
|
|
1174
1175
|
for (const r of e)
|
|
1175
|
-
t +=
|
|
1176
|
+
t += Xt + r.message_terminals.length;
|
|
1176
1177
|
const n = new Uint8Array(t * I);
|
|
1177
1178
|
let s = 0;
|
|
1178
1179
|
for (const r of e) {
|
|
@@ -1183,17 +1184,17 @@ function kn(e) {
|
|
|
1183
1184
|
const o = Mt(n);
|
|
1184
1185
|
return `0x${Qe(o)}`;
|
|
1185
1186
|
}
|
|
1186
|
-
async function
|
|
1187
|
+
async function In(e, t, n, s) {
|
|
1187
1188
|
const o = qe(e);
|
|
1188
1189
|
try {
|
|
1189
|
-
const r = await
|
|
1190
|
+
const r = await Ge(
|
|
1190
1191
|
o,
|
|
1191
1192
|
t,
|
|
1192
1193
|
n,
|
|
1193
1194
|
s
|
|
1194
1195
|
);
|
|
1195
1196
|
try {
|
|
1196
|
-
return
|
|
1197
|
+
return ze(r);
|
|
1197
1198
|
} finally {
|
|
1198
1199
|
for (const i of r.falsePreimages) i.fill(0);
|
|
1199
1200
|
for (const i of r.truePreimages) i.fill(0);
|
|
@@ -1202,24 +1203,24 @@ async function Tn(e, t, n, s) {
|
|
|
1202
1203
|
o.fill(0);
|
|
1203
1204
|
}
|
|
1204
1205
|
}
|
|
1205
|
-
function
|
|
1206
|
+
function vn(e) {
|
|
1206
1207
|
const t = (e instanceof Error ? e.message : typeof e == "string" ? e : "").toLowerCase();
|
|
1207
1208
|
return t.includes("wots") && t.includes("hash") && t.includes("does not match");
|
|
1208
1209
|
}
|
|
1209
1210
|
export {
|
|
1210
1211
|
B as C,
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1212
|
+
xn as P,
|
|
1213
|
+
kn as a,
|
|
1214
|
+
Tn as b,
|
|
1215
|
+
ze as c,
|
|
1216
|
+
Ge as d,
|
|
1216
1217
|
ft as e,
|
|
1217
|
-
|
|
1218
|
-
|
|
1218
|
+
In as f,
|
|
1219
|
+
wn as g,
|
|
1219
1220
|
_ as h,
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1221
|
+
bn as i,
|
|
1222
|
+
vn as j,
|
|
1223
|
+
Pn as k,
|
|
1223
1224
|
qe as m
|
|
1224
1225
|
};
|
|
1225
|
-
//# sourceMappingURL=errors-
|
|
1226
|
+
//# sourceMappingURL=errors-CHY4WNi-.js.map
|