@babylonlabs-io/ts-sdk 0.26.3 → 0.27.1
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/{bitcoin-nOOgeRyl.js → bitcoin-B-Y0DlqR.js} +63 -60
- package/dist/bitcoin-B-Y0DlqR.js.map +1 -0
- package/dist/bitcoin-DIN0OupO.cjs +2 -0
- package/dist/bitcoin-DIN0OupO.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-BEASMFsz.cjs +2 -0
- package/dist/buildAndBroadcastRefund-BEASMFsz.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-BzYJv-Fv.js +862 -0
- package/dist/buildAndBroadcastRefund-BzYJv-Fv.js.map +1 -0
- package/dist/challengeAssert-BM8m9gPM.cjs +2 -0
- package/dist/challengeAssert-BM8m9gPM.cjs.map +1 -0
- package/dist/{challengeAssert-CH32j5cZ.js → challengeAssert-j2Vwqo0-.js} +135 -120
- package/dist/challengeAssert-j2Vwqo0-.js.map +1 -0
- package/dist/context-B4fYDTxy.cjs +2 -0
- package/dist/context-B4fYDTxy.cjs.map +1 -0
- package/dist/{errors-kc6XZy1U.js → context-ktqanzXE.js} +442 -324
- package/dist/context-ktqanzXE.js.map +1 -0
- package/dist/fundPeginTransaction-DaWoYCgO.cjs +2 -0
- package/dist/fundPeginTransaction-DaWoYCgO.cjs.map +1 -0
- package/dist/fundPeginTransaction-oV-dNJOU.js +76 -0
- package/dist/fundPeginTransaction-oV-dNJOU.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +100 -91
- package/dist/{payout-DzGsAnhf.js → payout-B_fvQU3q.js} +2 -2
- package/dist/{payout-DzGsAnhf.js.map → payout-B_fvQU3q.js.map} +1 -1
- package/dist/{payout-RFIh7GLN.cjs → payout-DP6KMFP1.cjs} +2 -2
- package/dist/{payout-RFIh7GLN.cjs.map → payout-DP6KMFP1.cjs.map} +1 -1
- package/dist/psbtInputFields-CB8hqjQ5.cjs +2 -0
- package/dist/psbtInputFields-CB8hqjQ5.cjs.map +1 -0
- package/dist/{psbtInputFields-B_cRzwBi.js → psbtInputFields-DeTFSJOq.js} +71 -65
- package/dist/psbtInputFields-DeTFSJOq.js.map +1 -0
- package/dist/sha2-1XZuToHP.cjs +2 -0
- package/dist/sha2-1XZuToHP.cjs.map +1 -0
- package/dist/sha2-ZzfZqQSw.js +1123 -0
- package/dist/sha2-ZzfZqQSw.js.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +27 -24
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts +17 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/cbor.test.d.ts +15 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/cbor.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/goldenVectors.d.ts +44 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/goldenVectors.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/serverIdentity.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/serverIdentity.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/tokenProvider.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/tokenProvider.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts +56 -0
- package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/cbor.d.ts +44 -0
- package/dist/tbv/core/clients/vault-provider/auth/cbor.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/index.d.ts +10 -0
- package/dist/tbv/core/clients/vault-provider/auth/index.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/serverIdentity.d.ts +68 -0
- package/dist/tbv/core/clients/vault-provider/auth/serverIdentity.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts +81 -0
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/index.d.ts +2 -1
- package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +66 -1
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +3 -0
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +96 -87
- 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 +3 -3
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +17 -2
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +19 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +1 -1
- package/dist/tbv/core/utils/fee/__tests__/constants.test.d.ts +2 -0
- package/dist/tbv/core/utils/fee/__tests__/constants.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/fee/constants.d.ts +30 -9
- package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +28 -27
- package/dist/tbv/core/utils/utxo/reservation.d.ts +5 -0
- package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/__tests__/context.golden.test.d.ts +34 -0
- package/dist/tbv/core/vault-secrets/__tests__/context.golden.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/__tests__/context.test.d.ts +6 -0
- package/dist/tbv/core/vault-secrets/__tests__/context.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/__tests__/expand.test.d.ts +10 -0
- package/dist/tbv/core/vault-secrets/__tests__/expand.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/__tests__/info.test.d.ts +8 -0
- package/dist/tbv/core/vault-secrets/__tests__/info.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/context.d.ts +52 -0
- package/dist/tbv/core/vault-secrets/context.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/expand.d.ts +43 -0
- package/dist/tbv/core/vault-secrets/expand.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/index.d.ts +16 -0
- package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/info.d.ts +55 -0
- package/dist/tbv/core/vault-secrets/info.d.ts.map +1 -0
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +96 -87
- package/dist/vault-registry-reader-BizmBSBV.cjs +2 -0
- package/dist/vault-registry-reader-BizmBSBV.cjs.map +1 -0
- package/dist/{index-D7s2ilf8.js → vault-registry-reader-CpCOte7w.js} +522 -268
- package/dist/vault-registry-reader-CpCOte7w.js.map +1 -0
- package/package.json +6 -1
- package/dist/bitcoin-CNnPFU6Y.cjs +0 -2
- package/dist/bitcoin-CNnPFU6Y.cjs.map +0 -1
- package/dist/bitcoin-nOOgeRyl.js.map +0 -1
- package/dist/buildAndBroadcastRefund-Ccp-2GWW.js +0 -1334
- package/dist/buildAndBroadcastRefund-Ccp-2GWW.js.map +0 -1
- package/dist/buildAndBroadcastRefund-Mr3ck5ek.cjs +0 -2
- package/dist/buildAndBroadcastRefund-Mr3ck5ek.cjs.map +0 -1
- package/dist/challengeAssert-CH32j5cZ.js.map +0 -1
- package/dist/challengeAssert-X7V3Ik_Q.cjs +0 -2
- package/dist/challengeAssert-X7V3Ik_Q.cjs.map +0 -1
- package/dist/errors-DJkMz2Gt.cjs +0 -2
- package/dist/errors-DJkMz2Gt.cjs.map +0 -1
- package/dist/errors-kc6XZy1U.js.map +0 -1
- package/dist/fundPeginTransaction-BLYXxLBv.js +0 -70
- package/dist/fundPeginTransaction-BLYXxLBv.js.map +0 -1
- package/dist/fundPeginTransaction-DxNOeyNI.cjs +0 -2
- package/dist/fundPeginTransaction-DxNOeyNI.cjs.map +0 -1
- package/dist/index-CIuXb72l.cjs +0 -2
- package/dist/index-CIuXb72l.cjs.map +0 -1
- package/dist/index-D7s2ilf8.js.map +0 -1
- package/dist/psbtInputFields-B_cRzwBi.js.map +0 -1
- package/dist/psbtInputFields-DFwuqxdh.cjs +0 -2
- package/dist/psbtInputFields-DFwuqxdh.cjs.map +0 -1
- package/dist/types-WrGfwlJd.js +0 -608
- package/dist/types-WrGfwlJd.js.map +0 -1
- package/dist/types-xU3SBcpH.cjs +0 -2
- package/dist/types-xU3SBcpH.cjs.map +0 -1
|
@@ -1,80 +1,84 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { B as
|
|
5
|
-
import { D as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var se = (n, e, t) => e in n ? ae(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var l = (n, e, t) => se(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { B as ie, H as y, K as oe, T as ce } from "./validation-CxqROCno.js";
|
|
5
|
+
import { D as le, J as ue, s as K, B as P } from "./sha2-ZzfZqQSw.js";
|
|
6
|
+
import { X as v, C as F, s as _, S as pe } from "./bitcoin-B-Y0DlqR.js";
|
|
7
|
+
import * as N from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
|
+
import { payments as de, Transaction as k } from "bitcoinjs-lib";
|
|
9
|
+
import { Buffer as f } from "buffer";
|
|
10
|
+
const me = 21e6 * 1e8, U = 3e4;
|
|
11
|
+
async function $(n, e) {
|
|
12
|
+
const t = new AbortController(), r = setTimeout(
|
|
9
13
|
() => t.abort(),
|
|
10
|
-
|
|
11
|
-
),
|
|
14
|
+
U
|
|
15
|
+
), s = [t.signal, e == null ? void 0 : e.signal].filter(
|
|
12
16
|
Boolean
|
|
13
17
|
);
|
|
14
18
|
try {
|
|
15
19
|
return await fetch(n, {
|
|
16
20
|
...e,
|
|
17
|
-
signal: AbortSignal.any(
|
|
21
|
+
signal: AbortSignal.any(s)
|
|
18
22
|
});
|
|
19
|
-
} catch (
|
|
20
|
-
throw clearTimeout(
|
|
21
|
-
`Mempool API request timed out after ${
|
|
22
|
-
) :
|
|
23
|
+
} catch (a) {
|
|
24
|
+
throw clearTimeout(r), a != null && typeof a == "object" && "name" in a && a.name === "AbortError" ? new Error(
|
|
25
|
+
`Mempool API request timed out after ${U}ms: ${n}`
|
|
26
|
+
) : a;
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
|
-
const
|
|
26
|
-
function
|
|
27
|
-
return Number.isInteger(n) && n > 0 && n <=
|
|
29
|
+
const G = 1e4;
|
|
30
|
+
function W(n) {
|
|
31
|
+
return Number.isInteger(n) && n > 0 && n <= me;
|
|
28
32
|
}
|
|
29
|
-
function
|
|
30
|
-
return Number.isInteger(n) && n > 0 && n <=
|
|
33
|
+
function he(n) {
|
|
34
|
+
return Number.isInteger(n) && n > 0 && n <= G;
|
|
31
35
|
}
|
|
32
|
-
function
|
|
36
|
+
function J(n, e) {
|
|
33
37
|
return !Number.isInteger(n) || n < 0 ? !1 : e === void 0 || n < e;
|
|
34
38
|
}
|
|
35
|
-
function
|
|
36
|
-
if (!
|
|
39
|
+
function E(n) {
|
|
40
|
+
if (!ce.test(n))
|
|
37
41
|
throw new Error(`Invalid transaction ID format: ${n}`);
|
|
38
42
|
}
|
|
39
|
-
function
|
|
40
|
-
if (!
|
|
43
|
+
function z(n) {
|
|
44
|
+
if (!ie.test(n))
|
|
41
45
|
throw new Error(`Invalid Bitcoin address format: ${n}`);
|
|
42
46
|
}
|
|
43
|
-
function
|
|
44
|
-
if (!
|
|
47
|
+
function Y(n, e) {
|
|
48
|
+
if (!y.test(n))
|
|
45
49
|
throw new Error(
|
|
46
50
|
`Invalid scriptPubKey: not valid hex for ${e}`
|
|
47
51
|
);
|
|
48
|
-
if (!
|
|
49
|
-
(
|
|
52
|
+
if (!oe.some(
|
|
53
|
+
(r) => n.toLowerCase().startsWith(r)
|
|
50
54
|
))
|
|
51
55
|
throw new Error(
|
|
52
56
|
`Unrecognized scriptPubKey type for ${e}: prefix ${n.slice(0, 6)} does not match any known Bitcoin script type`
|
|
53
57
|
);
|
|
54
58
|
}
|
|
55
|
-
const
|
|
59
|
+
const fe = {
|
|
56
60
|
mainnet: "https://mempool.space/api",
|
|
57
61
|
testnet: "https://mempool.space/testnet/api",
|
|
58
62
|
signet: "https://mempool.space/signet/api"
|
|
59
63
|
};
|
|
60
|
-
async function
|
|
64
|
+
async function T(n, e) {
|
|
61
65
|
try {
|
|
62
|
-
const t = await
|
|
66
|
+
const t = await $(n, e);
|
|
63
67
|
if (!t.ok) {
|
|
64
|
-
const
|
|
68
|
+
const s = await t.text();
|
|
65
69
|
throw new Error(
|
|
66
|
-
`Mempool API error (${t.status}): ${
|
|
70
|
+
`Mempool API error (${t.status}): ${s || t.statusText}`
|
|
67
71
|
);
|
|
68
72
|
}
|
|
69
|
-
const
|
|
70
|
-
return
|
|
73
|
+
const r = t.headers.get("content-type");
|
|
74
|
+
return r != null && r.includes("application/json") ? await t.json() : await t.text();
|
|
71
75
|
} catch (t) {
|
|
72
76
|
throw t instanceof Error ? new Error(`Failed to fetch from mempool API: ${t.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
|
-
async function
|
|
79
|
+
async function Le(n, e) {
|
|
76
80
|
try {
|
|
77
|
-
const t = await
|
|
81
|
+
const t = await $(`${e}/tx`, {
|
|
78
82
|
method: "POST",
|
|
79
83
|
body: n,
|
|
80
84
|
headers: {
|
|
@@ -82,15 +86,15 @@ async function pe(n, e) {
|
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
if (!t.ok) {
|
|
85
|
-
const
|
|
86
|
-
let
|
|
89
|
+
const s = await t.text();
|
|
90
|
+
let a;
|
|
87
91
|
try {
|
|
88
|
-
|
|
92
|
+
a = JSON.parse(s).message;
|
|
89
93
|
} catch {
|
|
90
|
-
|
|
94
|
+
a = s;
|
|
91
95
|
}
|
|
92
96
|
throw new Error(
|
|
93
|
-
|
|
97
|
+
a || `Failed to broadcast transaction: ${t.statusText}`
|
|
94
98
|
);
|
|
95
99
|
}
|
|
96
100
|
return await t.text();
|
|
@@ -98,17 +102,17 @@ async function pe(n, e) {
|
|
|
98
102
|
throw t instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${t.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
|
-
async function
|
|
102
|
-
return
|
|
105
|
+
async function ye(n, e) {
|
|
106
|
+
return E(n), T(`${e}/tx/${n}`);
|
|
103
107
|
}
|
|
104
|
-
async function
|
|
105
|
-
|
|
108
|
+
async function Xe(n, e) {
|
|
109
|
+
E(n);
|
|
106
110
|
try {
|
|
107
|
-
const t = await
|
|
111
|
+
const t = await $(`${e}/tx/${n}/hex`);
|
|
108
112
|
if (!t.ok) {
|
|
109
|
-
const
|
|
113
|
+
const r = await t.text();
|
|
110
114
|
throw new Error(
|
|
111
|
-
`Mempool API error (${t.status}): ${
|
|
115
|
+
`Mempool API error (${t.status}): ${r || t.statusText}`
|
|
112
116
|
);
|
|
113
117
|
}
|
|
114
118
|
return await t.text();
|
|
@@ -116,46 +120,46 @@ async function me(n, e) {
|
|
|
116
120
|
throw t instanceof Error ? new Error(`Failed to get transaction hex for ${n}: ${t.message}`) : new Error(`Failed to get transaction hex for ${n}: Unknown error`);
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
|
-
async function
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
123
|
+
async function qe(n, e, t) {
|
|
124
|
+
E(n);
|
|
125
|
+
const r = await ye(n, t);
|
|
126
|
+
if (!J(e, r.vout.length))
|
|
123
127
|
throw new Error(
|
|
124
|
-
`Invalid vout ${e} for transaction ${n} (has ${
|
|
128
|
+
`Invalid vout ${e} for transaction ${n} (has ${r.vout.length} outputs)`
|
|
125
129
|
);
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
throw new Error(`Invalid UTXO value ${
|
|
129
|
-
return
|
|
130
|
+
const s = r.vout[e];
|
|
131
|
+
if (!W(s.value))
|
|
132
|
+
throw new Error(`Invalid UTXO value ${s.value} for ${n}:${e}`);
|
|
133
|
+
return Y(s.scriptpubkey, `${n}:${e}`), {
|
|
130
134
|
txid: n,
|
|
131
135
|
vout: e,
|
|
132
|
-
value:
|
|
133
|
-
scriptPubKey:
|
|
136
|
+
value: s.value,
|
|
137
|
+
scriptPubKey: s.scriptpubkey
|
|
134
138
|
};
|
|
135
139
|
}
|
|
136
|
-
async function
|
|
137
|
-
|
|
140
|
+
async function Ge(n, e) {
|
|
141
|
+
z(n);
|
|
138
142
|
try {
|
|
139
|
-
const t = await
|
|
140
|
-
if (!
|
|
143
|
+
const t = await T(`${e}/address/${n}/utxo`), r = await T(`${e}/v1/validate-address/${n}`);
|
|
144
|
+
if (!r.isvalid)
|
|
141
145
|
throw new Error(
|
|
142
146
|
`Invalid Bitcoin address: ${n}. Mempool API validation failed.`
|
|
143
147
|
);
|
|
144
|
-
|
|
145
|
-
for (const
|
|
146
|
-
if (
|
|
147
|
-
throw new Error(`Invalid vout ${
|
|
148
|
-
if (!
|
|
148
|
+
Y(r.scriptPubKey, n);
|
|
149
|
+
for (const a of t) {
|
|
150
|
+
if (E(a.txid), !J(a.vout))
|
|
151
|
+
throw new Error(`Invalid vout ${a.vout} for ${a.txid}`);
|
|
152
|
+
if (!W(a.value))
|
|
149
153
|
throw new Error(
|
|
150
|
-
`Invalid UTXO value ${
|
|
154
|
+
`Invalid UTXO value ${a.value} for ${a.txid}:${a.vout}`
|
|
151
155
|
);
|
|
152
156
|
}
|
|
153
|
-
return t.sort((
|
|
154
|
-
txid:
|
|
155
|
-
vout:
|
|
156
|
-
value:
|
|
157
|
-
scriptPubKey:
|
|
158
|
-
confirmed:
|
|
157
|
+
return t.sort((a, c) => c.value - a.value).map((a) => ({
|
|
158
|
+
txid: a.txid,
|
|
159
|
+
vout: a.vout,
|
|
160
|
+
value: a.value,
|
|
161
|
+
scriptPubKey: r.scriptPubKey,
|
|
162
|
+
confirmed: a.status.confirmed
|
|
159
163
|
}));
|
|
160
164
|
} catch (t) {
|
|
161
165
|
throw t instanceof Error ? new Error(
|
|
@@ -165,29 +169,29 @@ async function ye(n, e) {
|
|
|
165
169
|
);
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
|
-
function
|
|
169
|
-
return
|
|
172
|
+
function We(n) {
|
|
173
|
+
return fe[n];
|
|
170
174
|
}
|
|
171
|
-
async function
|
|
172
|
-
return
|
|
175
|
+
async function Je(n, e) {
|
|
176
|
+
return z(n), T(`${e}/address/${n}/txs`);
|
|
173
177
|
}
|
|
174
|
-
async function
|
|
175
|
-
const e = await
|
|
178
|
+
async function ze(n) {
|
|
179
|
+
const e = await $(`${n}/v1/fees/recommended`);
|
|
176
180
|
if (!e.ok)
|
|
177
181
|
throw new Error(
|
|
178
182
|
`Failed to fetch network fees: ${e.status} ${e.statusText}`
|
|
179
183
|
);
|
|
180
|
-
const t = await e.json(),
|
|
184
|
+
const t = await e.json(), r = [
|
|
181
185
|
"fastestFee",
|
|
182
186
|
"halfHourFee",
|
|
183
187
|
"hourFee",
|
|
184
188
|
"economyFee",
|
|
185
189
|
"minimumFee"
|
|
186
190
|
];
|
|
187
|
-
for (const
|
|
188
|
-
if (!
|
|
191
|
+
for (const s of r)
|
|
192
|
+
if (!he(t[s]))
|
|
189
193
|
throw new Error(
|
|
190
|
-
`Invalid fee rate ${
|
|
194
|
+
`Invalid fee rate ${s}=${t[s]} from mempool API: expected a positive number ≤ ${G}`
|
|
191
195
|
);
|
|
192
196
|
if (t.minimumFee > t.economyFee || t.economyFee > t.hourFee || t.hourFee > t.halfHourFee || t.halfHourFee > t.fastestFee)
|
|
193
197
|
throw new Error(
|
|
@@ -195,7 +199,7 @@ async function he(n) {
|
|
|
195
199
|
);
|
|
196
200
|
return t;
|
|
197
201
|
}
|
|
198
|
-
const
|
|
202
|
+
const S = [
|
|
199
203
|
{
|
|
200
204
|
type: "function",
|
|
201
205
|
name: "getVaultKeepersByVersion",
|
|
@@ -282,7 +286,7 @@ const _ = [
|
|
|
282
286
|
],
|
|
283
287
|
stateMutability: "view"
|
|
284
288
|
}
|
|
285
|
-
],
|
|
289
|
+
], m = [
|
|
286
290
|
{
|
|
287
291
|
type: "function",
|
|
288
292
|
name: "getTBVProtocolParams",
|
|
@@ -571,279 +575,279 @@ const _ = [
|
|
|
571
575
|
],
|
|
572
576
|
stateMutability: "view"
|
|
573
577
|
}
|
|
574
|
-
],
|
|
578
|
+
], j = new Set(Object.values(le)), ge = 200;
|
|
575
579
|
function o(n) {
|
|
576
580
|
var e;
|
|
577
|
-
return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0,
|
|
581
|
+
return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0, ge)) ?? "undefined";
|
|
578
582
|
}
|
|
579
|
-
const
|
|
580
|
-
class
|
|
583
|
+
const be = "The vault provider returned an unexpected response. Please try again or contact support.";
|
|
584
|
+
class i extends Error {
|
|
581
585
|
constructor(t) {
|
|
582
|
-
super(
|
|
583
|
-
|
|
586
|
+
super(be);
|
|
587
|
+
l(this, "detail");
|
|
584
588
|
this.name = "VpResponseValidationError", this.detail = t;
|
|
585
589
|
}
|
|
586
590
|
}
|
|
587
|
-
const
|
|
588
|
-
function
|
|
589
|
-
return typeof n == "string" && n.length > 0 &&
|
|
591
|
+
const x = 64;
|
|
592
|
+
function g(n) {
|
|
593
|
+
return typeof n == "string" && n.length > 0 && y.test(n);
|
|
590
594
|
}
|
|
591
|
-
function
|
|
595
|
+
function Q(n) {
|
|
592
596
|
return typeof n == "string" && n.length > 0;
|
|
593
597
|
}
|
|
594
|
-
function
|
|
595
|
-
if (!
|
|
596
|
-
throw new
|
|
598
|
+
function Z(n, e) {
|
|
599
|
+
if (!g(n))
|
|
600
|
+
throw new i(
|
|
597
601
|
`VP response validation failed: "${e}" must be a non-empty hex string, got ${o(n)}`
|
|
598
602
|
);
|
|
599
603
|
}
|
|
600
|
-
function
|
|
601
|
-
if (!
|
|
602
|
-
throw new
|
|
604
|
+
function b(n, e) {
|
|
605
|
+
if (!Q(n))
|
|
606
|
+
throw new i(
|
|
603
607
|
`VP response validation failed: "${e}" must be a non-empty string, got ${o(n)}`
|
|
604
608
|
);
|
|
605
609
|
}
|
|
606
|
-
function
|
|
607
|
-
if (!
|
|
608
|
-
throw new
|
|
609
|
-
`VP response validation failed: "${e}" must be a ${
|
|
610
|
+
function ee(n, e) {
|
|
611
|
+
if (!g(n) || n.length !== v && n.length !== F)
|
|
612
|
+
throw new i(
|
|
613
|
+
`VP response validation failed: "${e}" must be a ${v} or ${F}-char hex string (BTC pubkey), got ${o(n)}`
|
|
610
614
|
);
|
|
611
615
|
}
|
|
612
|
-
function
|
|
616
|
+
function _e(n) {
|
|
613
617
|
const e = n.presigning;
|
|
614
618
|
if (e == null) return;
|
|
615
619
|
if (typeof e != "object" || Array.isArray(e))
|
|
616
|
-
throw new
|
|
620
|
+
throw new i(
|
|
617
621
|
'VP response validation failed: "progress.presigning" must be an object if present'
|
|
618
622
|
);
|
|
619
623
|
const t = e;
|
|
620
624
|
if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
|
|
621
|
-
throw new
|
|
625
|
+
throw new i(
|
|
622
626
|
`VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${o(t.depositor_graph_created)}`
|
|
623
627
|
);
|
|
624
628
|
if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
|
|
625
|
-
throw new
|
|
629
|
+
throw new i(
|
|
626
630
|
`VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${o(t.vk_challenger_presigning_completed)}`
|
|
627
631
|
);
|
|
628
632
|
if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
|
|
629
|
-
throw new
|
|
633
|
+
throw new i(
|
|
630
634
|
`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${o(t.vk_challenger_presigning_total)}`
|
|
631
635
|
);
|
|
632
636
|
}
|
|
633
|
-
function
|
|
637
|
+
function we(n) {
|
|
634
638
|
if (n === null || typeof n != "object")
|
|
635
|
-
throw new
|
|
639
|
+
throw new i(
|
|
636
640
|
"VP response validation failed: getPeginStatus response is not an object"
|
|
637
641
|
);
|
|
638
642
|
const e = n;
|
|
639
|
-
if (!
|
|
640
|
-
throw new
|
|
641
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
643
|
+
if (!g(e.pegin_txid) || e.pegin_txid.length !== x)
|
|
644
|
+
throw new i(
|
|
645
|
+
`VP response validation failed: "pegin_txid" must be a ${x}-char hex string (txid), got ${o(e.pegin_txid)}`
|
|
642
646
|
);
|
|
643
647
|
if (typeof e.status != "string")
|
|
644
|
-
throw new
|
|
648
|
+
throw new i(
|
|
645
649
|
'VP response validation failed: "status" must be a string'
|
|
646
650
|
);
|
|
647
|
-
if (!
|
|
648
|
-
throw new
|
|
649
|
-
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...
|
|
651
|
+
if (!j.has(e.status))
|
|
652
|
+
throw new i(
|
|
653
|
+
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...j].join(", ")}`
|
|
650
654
|
);
|
|
651
655
|
if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
|
|
652
|
-
throw new
|
|
656
|
+
throw new i(
|
|
653
657
|
'VP response validation failed: "progress" must be an object'
|
|
654
658
|
);
|
|
655
|
-
if (
|
|
656
|
-
throw new
|
|
659
|
+
if (_e(e.progress), typeof e.health_info != "string")
|
|
660
|
+
throw new i(
|
|
657
661
|
'VP response validation failed: "health_info" must be a string'
|
|
658
662
|
);
|
|
659
663
|
if (e.last_error !== void 0 && typeof e.last_error != "string")
|
|
660
|
-
throw new
|
|
664
|
+
throw new i(
|
|
661
665
|
`VP response validation failed: "last_error" must be a string if present, got ${o(e.last_error)}`
|
|
662
666
|
);
|
|
663
667
|
}
|
|
664
|
-
function
|
|
668
|
+
function Pe(n) {
|
|
665
669
|
if (n === null || typeof n != "object")
|
|
666
|
-
throw new
|
|
670
|
+
throw new i(
|
|
667
671
|
"VP response validation failed: requestDepositorPresignTransactions response is not an object"
|
|
668
672
|
);
|
|
669
673
|
const e = n;
|
|
670
674
|
if (!Array.isArray(e.txs))
|
|
671
|
-
throw new
|
|
675
|
+
throw new i(
|
|
672
676
|
'VP response validation failed: "txs" must be an array'
|
|
673
677
|
);
|
|
674
678
|
for (let t = 0; t < e.txs.length; t++)
|
|
675
|
-
|
|
679
|
+
ve(e.txs[t], `txs[${t}]`);
|
|
676
680
|
if (e.depositor_graph === null || typeof e.depositor_graph != "object")
|
|
677
|
-
throw new
|
|
681
|
+
throw new i(
|
|
678
682
|
'VP response validation failed: "depositor_graph" must be an object'
|
|
679
683
|
);
|
|
680
|
-
|
|
684
|
+
$e(
|
|
681
685
|
e.depositor_graph
|
|
682
686
|
);
|
|
683
687
|
}
|
|
684
|
-
function
|
|
688
|
+
function h(n, e) {
|
|
685
689
|
if (n === null || typeof n != "object")
|
|
686
|
-
throw new
|
|
690
|
+
throw new i(
|
|
687
691
|
`VP response validation failed: "${e}" must be an object`
|
|
688
692
|
);
|
|
689
|
-
|
|
693
|
+
Z(n.tx_hex, `${e}.tx_hex`);
|
|
690
694
|
}
|
|
691
|
-
function
|
|
695
|
+
function ve(n, e) {
|
|
692
696
|
if (n === null || typeof n != "object")
|
|
693
|
-
throw new
|
|
697
|
+
throw new i(
|
|
694
698
|
`VP response validation failed: "${e}" must be an object`
|
|
695
699
|
);
|
|
696
700
|
const t = n;
|
|
697
|
-
|
|
701
|
+
ee(t.claimer_pubkey, `${e}.claimer_pubkey`), h(t.claim_tx, `${e}.claim_tx`), h(t.assert_tx, `${e}.assert_tx`), h(t.payout_tx, `${e}.payout_tx`), b(t.payout_psbt, `${e}.payout_psbt`);
|
|
698
702
|
}
|
|
699
|
-
function
|
|
703
|
+
function Te(n, e) {
|
|
700
704
|
if (n === null || typeof n != "object")
|
|
701
|
-
throw new
|
|
705
|
+
throw new i(
|
|
702
706
|
`VP response validation failed: "${e}" must be an object`
|
|
703
707
|
);
|
|
704
708
|
const t = n;
|
|
705
|
-
|
|
709
|
+
b(t.wots_pks_json, `${e}.wots_pks_json`), b(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
|
|
706
710
|
}
|
|
707
|
-
function
|
|
711
|
+
function xe(n, e) {
|
|
708
712
|
if (n === null || typeof n != "object")
|
|
709
|
-
throw new
|
|
713
|
+
throw new i(
|
|
710
714
|
`VP response validation failed: "${e}" must be an object`
|
|
711
715
|
);
|
|
712
716
|
const t = n;
|
|
713
|
-
if (
|
|
717
|
+
if (ee(t.challenger_pubkey, `${e}.challenger_pubkey`), h(
|
|
714
718
|
t.challenge_assert_x_tx,
|
|
715
719
|
`${e}.challenge_assert_x_tx`
|
|
716
|
-
),
|
|
720
|
+
), h(
|
|
717
721
|
t.challenge_assert_y_tx,
|
|
718
722
|
`${e}.challenge_assert_y_tx`
|
|
719
|
-
),
|
|
720
|
-
throw new
|
|
723
|
+
), h(t.nopayout_tx, `${e}.nopayout_tx`), b(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
|
|
724
|
+
throw new i(
|
|
721
725
|
`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
|
|
722
726
|
);
|
|
723
|
-
for (let
|
|
724
|
-
|
|
725
|
-
t.challenge_assert_connectors[
|
|
726
|
-
`${e}.challenge_assert_connectors[${
|
|
727
|
+
for (let r = 0; r < t.challenge_assert_connectors.length; r++)
|
|
728
|
+
Te(
|
|
729
|
+
t.challenge_assert_connectors[r],
|
|
730
|
+
`${e}.challenge_assert_connectors[${r}]`
|
|
727
731
|
);
|
|
728
732
|
if (!Array.isArray(t.output_label_hashes))
|
|
729
|
-
throw new
|
|
733
|
+
throw new i(
|
|
730
734
|
`VP response validation failed: "${e}.output_label_hashes" must be an array`
|
|
731
735
|
);
|
|
732
|
-
for (let
|
|
733
|
-
|
|
734
|
-
t.output_label_hashes[
|
|
735
|
-
`${e}.output_label_hashes[${
|
|
736
|
+
for (let r = 0; r < t.output_label_hashes.length; r++)
|
|
737
|
+
Z(
|
|
738
|
+
t.output_label_hashes[r],
|
|
739
|
+
`${e}.output_label_hashes[${r}]`
|
|
736
740
|
);
|
|
737
741
|
}
|
|
738
|
-
function
|
|
742
|
+
function Ae(n) {
|
|
739
743
|
if (n === null || typeof n != "object")
|
|
740
|
-
throw new
|
|
744
|
+
throw new i(
|
|
741
745
|
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
742
746
|
);
|
|
743
747
|
const e = n;
|
|
744
|
-
if (!
|
|
745
|
-
throw new
|
|
748
|
+
if (!Q(e.tx_graph_json))
|
|
749
|
+
throw new i(
|
|
746
750
|
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${o(e.tx_graph_json)}`
|
|
747
751
|
);
|
|
748
|
-
if (!
|
|
749
|
-
throw new
|
|
752
|
+
if (!g(e.verifying_key_hex))
|
|
753
|
+
throw new i(
|
|
750
754
|
`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${o(e.verifying_key_hex)}`
|
|
751
755
|
);
|
|
752
756
|
if (e.babe_sessions === null || typeof e.babe_sessions != "object")
|
|
753
|
-
throw new
|
|
757
|
+
throw new i(
|
|
754
758
|
'VP response validation failed: "babe_sessions" must be an object'
|
|
755
759
|
);
|
|
756
|
-
for (const [t,
|
|
760
|
+
for (const [t, r] of Object.entries(
|
|
757
761
|
e.babe_sessions
|
|
758
762
|
)) {
|
|
759
|
-
if (
|
|
760
|
-
throw new
|
|
763
|
+
if (r === null || typeof r != "object")
|
|
764
|
+
throw new i(
|
|
761
765
|
`VP response validation failed: "babe_sessions.${t}" must be an object`
|
|
762
766
|
);
|
|
763
|
-
const
|
|
764
|
-
if (!
|
|
765
|
-
throw new
|
|
766
|
-
`VP response validation failed: "babe_sessions.${t}.decryptor_artifacts_hex" must be a non-empty hex string, got ${o(
|
|
767
|
+
const s = r;
|
|
768
|
+
if (!g(s.decryptor_artifacts_hex))
|
|
769
|
+
throw new i(
|
|
770
|
+
`VP response validation failed: "babe_sessions.${t}.decryptor_artifacts_hex" must be a non-empty hex string, got ${o(s.decryptor_artifacts_hex)}`
|
|
767
771
|
);
|
|
768
772
|
}
|
|
769
773
|
}
|
|
770
|
-
function
|
|
774
|
+
function Ve(n) {
|
|
771
775
|
if (n === null || typeof n != "object")
|
|
772
|
-
throw new
|
|
776
|
+
throw new i(
|
|
773
777
|
"VP response validation failed: getPegoutStatus response is not an object"
|
|
774
778
|
);
|
|
775
779
|
const e = n;
|
|
776
|
-
if (!
|
|
777
|
-
throw new
|
|
778
|
-
`VP response validation failed: "pegin_txid" must be a ${
|
|
780
|
+
if (!g(e.pegin_txid) || e.pegin_txid.length !== x)
|
|
781
|
+
throw new i(
|
|
782
|
+
`VP response validation failed: "pegin_txid" must be a ${x}-char hex string (txid), got ${o(e.pegin_txid)}`
|
|
779
783
|
);
|
|
780
784
|
if (typeof e.found != "boolean")
|
|
781
|
-
throw new
|
|
785
|
+
throw new i(
|
|
782
786
|
`VP response validation failed: "found" must be a boolean, got ${o(e.found)}`
|
|
783
787
|
);
|
|
784
788
|
if (e.claimer !== void 0) {
|
|
785
789
|
if (e.claimer === null || typeof e.claimer != "object")
|
|
786
|
-
throw new
|
|
790
|
+
throw new i(
|
|
787
791
|
'VP response validation failed: "claimer" must be an object if present'
|
|
788
792
|
);
|
|
789
793
|
const t = e.claimer;
|
|
790
794
|
if (typeof t.status != "string")
|
|
791
|
-
throw new
|
|
795
|
+
throw new i(
|
|
792
796
|
`VP response validation failed: "claimer.status" must be a string, got ${o(t.status)}`
|
|
793
797
|
);
|
|
794
798
|
if (typeof t.failed != "boolean")
|
|
795
|
-
throw new
|
|
799
|
+
throw new i(
|
|
796
800
|
`VP response validation failed: "claimer.failed" must be a boolean, got ${o(t.failed)}`
|
|
797
801
|
);
|
|
798
802
|
}
|
|
799
803
|
if (e.challenger !== void 0) {
|
|
800
804
|
if (e.challenger === null || typeof e.challenger != "object")
|
|
801
|
-
throw new
|
|
805
|
+
throw new i(
|
|
802
806
|
'VP response validation failed: "challenger" must be an object if present'
|
|
803
807
|
);
|
|
804
808
|
const t = e.challenger;
|
|
805
809
|
if (typeof t.status != "string")
|
|
806
|
-
throw new
|
|
810
|
+
throw new i(
|
|
807
811
|
`VP response validation failed: "challenger.status" must be a string, got ${o(t.status)}`
|
|
808
812
|
);
|
|
809
813
|
}
|
|
810
814
|
}
|
|
811
|
-
function
|
|
812
|
-
if (
|
|
813
|
-
throw new
|
|
815
|
+
function $e(n) {
|
|
816
|
+
if (h(n.claim_tx, "depositor_graph.claim_tx"), h(n.assert_tx, "depositor_graph.assert_tx"), h(n.payout_tx, "depositor_graph.payout_tx"), b(n.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(n.challenger_presign_data))
|
|
817
|
+
throw new i(
|
|
814
818
|
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
815
819
|
);
|
|
816
820
|
for (let e = 0; e < n.challenger_presign_data.length; e++)
|
|
817
|
-
|
|
821
|
+
xe(
|
|
818
822
|
n.challenger_presign_data[e],
|
|
819
823
|
`depositor_graph.challenger_presign_data[${e}]`
|
|
820
824
|
);
|
|
821
825
|
if (typeof n.offchain_params_version != "number")
|
|
822
|
-
throw new
|
|
826
|
+
throw new i(
|
|
823
827
|
'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
|
|
824
828
|
);
|
|
825
829
|
}
|
|
826
|
-
const
|
|
827
|
-
class
|
|
830
|
+
const Ee = 6e4;
|
|
831
|
+
class Ye {
|
|
828
832
|
constructor(e, t) {
|
|
829
|
-
|
|
830
|
-
const
|
|
833
|
+
l(this, "client");
|
|
834
|
+
const r = {
|
|
831
835
|
baseUrl: e,
|
|
832
|
-
timeout: (t == null ? void 0 : t.timeout) ??
|
|
836
|
+
timeout: (t == null ? void 0 : t.timeout) ?? Ee,
|
|
833
837
|
retries: t == null ? void 0 : t.retries,
|
|
834
838
|
retryDelay: t == null ? void 0 : t.retryDelay,
|
|
835
839
|
retryableFor: t == null ? void 0 : t.retryableFor,
|
|
836
840
|
headers: t == null ? void 0 : t.headers
|
|
837
841
|
};
|
|
838
|
-
this.client = new
|
|
842
|
+
this.client = new ue(r);
|
|
839
843
|
}
|
|
840
844
|
/**
|
|
841
845
|
* Request the payout/claim/assert transactions that the depositor
|
|
842
846
|
* needs to pre-sign before the vault can be activated on Bitcoin.
|
|
843
847
|
*/
|
|
844
848
|
async requestDepositorPresignTransactions(e, t) {
|
|
845
|
-
const
|
|
846
|
-
return
|
|
849
|
+
const r = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
|
|
850
|
+
return Pe(r), r;
|
|
847
851
|
}
|
|
848
852
|
/**
|
|
849
853
|
* Submit the depositor's pre-signatures for the payout transactions
|
|
@@ -873,39 +877,286 @@ class be {
|
|
|
873
877
|
* independently evaluate garbled circuits during a challenge.
|
|
874
878
|
*/
|
|
875
879
|
async requestDepositorClaimerArtifacts(e, t) {
|
|
876
|
-
const
|
|
877
|
-
return
|
|
880
|
+
const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
|
|
881
|
+
return Ae(r), r;
|
|
878
882
|
}
|
|
879
883
|
/** Get the current pegin status from the vault provider daemon. */
|
|
880
884
|
async getPeginStatus(e, t) {
|
|
881
|
-
const
|
|
885
|
+
const r = await this.client.call(
|
|
882
886
|
"vaultProvider_getPeginStatus",
|
|
883
887
|
e,
|
|
884
888
|
t
|
|
885
889
|
);
|
|
886
|
-
return
|
|
890
|
+
return we(r), r;
|
|
887
891
|
}
|
|
888
892
|
/** Get the current pegout status from the vault provider daemon. */
|
|
889
893
|
async getPegoutStatus(e, t) {
|
|
890
|
-
const
|
|
894
|
+
const r = await this.client.call(
|
|
891
895
|
"vaultProvider_getPegoutStatus",
|
|
892
896
|
e,
|
|
893
897
|
t
|
|
894
898
|
);
|
|
895
|
-
return
|
|
899
|
+
return Ve(r), r;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
const Ie = "BIP0322-signed-message", Ce = "TapTweak", te = 32, ke = 64;
|
|
903
|
+
function ne(n, e) {
|
|
904
|
+
const t = new TextEncoder().encode(n), r = K(t), s = new Uint8Array(r.length * 2 + e.length);
|
|
905
|
+
return s.set(r, 0), s.set(r, r.length), s.set(e, r.length * 2), K(s);
|
|
906
|
+
}
|
|
907
|
+
function Se(n) {
|
|
908
|
+
if (n.length !== te) return null;
|
|
909
|
+
const e = ne(Ce, n), t = N.xOnlyPointAddTweak(n, e);
|
|
910
|
+
return t ? t.xOnlyPubkey : null;
|
|
911
|
+
}
|
|
912
|
+
function Be(n, e, t) {
|
|
913
|
+
if (e.length !== te || t.length !== ke) return !1;
|
|
914
|
+
try {
|
|
915
|
+
const r = ne(Ie, n), s = de.p2tr({
|
|
916
|
+
internalPubkey: f.from(e)
|
|
917
|
+
});
|
|
918
|
+
if (!s.output) return !1;
|
|
919
|
+
const a = s.output, c = 0, d = new k();
|
|
920
|
+
d.version = 0, d.locktime = 0;
|
|
921
|
+
const I = f.concat([
|
|
922
|
+
f.from([0, 32]),
|
|
923
|
+
f.from(r)
|
|
924
|
+
]);
|
|
925
|
+
d.addInput(
|
|
926
|
+
f.alloc(32, 0),
|
|
927
|
+
// prev_txid = 0x0000...0000
|
|
928
|
+
4294967295,
|
|
929
|
+
// prev_vout = 0xFFFFFFFF
|
|
930
|
+
0,
|
|
931
|
+
// sequence = 0
|
|
932
|
+
I
|
|
933
|
+
), d.addOutput(a, c);
|
|
934
|
+
const p = new k();
|
|
935
|
+
p.version = 0, p.locktime = 0;
|
|
936
|
+
const C = d.getHash();
|
|
937
|
+
p.addInput(C, 0, 0), p.addOutput(f.from([106]), c);
|
|
938
|
+
const R = p.hashForWitnessV1(
|
|
939
|
+
0,
|
|
940
|
+
[a],
|
|
941
|
+
[c],
|
|
942
|
+
k.SIGHASH_DEFAULT
|
|
943
|
+
), O = Se(e);
|
|
944
|
+
return O ? N.verifySchnorr(R, O, t) : !1;
|
|
945
|
+
} catch {
|
|
946
|
+
return !1;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function A(n, e) {
|
|
950
|
+
const t = (n & 7) << 5, r = typeof e == "bigint" ? e : BigInt(e);
|
|
951
|
+
if (r < 0n) throw new Error("cborHead: negative argument");
|
|
952
|
+
if (r < 24n) return new Uint8Array([t | Number(r)]);
|
|
953
|
+
if (r < 0x100n) return new Uint8Array([t | 24, Number(r)]);
|
|
954
|
+
if (r < 0x10000n) {
|
|
955
|
+
const a = Number(r);
|
|
956
|
+
return new Uint8Array([t | 25, a >>> 8 & 255, a & 255]);
|
|
957
|
+
}
|
|
958
|
+
if (r < 0x100000000n) {
|
|
959
|
+
const a = Number(r);
|
|
960
|
+
return new Uint8Array([
|
|
961
|
+
t | 26,
|
|
962
|
+
a >>> 24 & 255,
|
|
963
|
+
a >>> 16 & 255,
|
|
964
|
+
a >>> 8 & 255,
|
|
965
|
+
a & 255
|
|
966
|
+
]);
|
|
967
|
+
}
|
|
968
|
+
const s = new Uint8Array(9);
|
|
969
|
+
s[0] = t | 27;
|
|
970
|
+
for (let a = 7; a >= 0; a--)
|
|
971
|
+
s[1 + a] = Number(r >> BigInt((7 - a) * 8)) & 255;
|
|
972
|
+
return s;
|
|
973
|
+
}
|
|
974
|
+
function re(...n) {
|
|
975
|
+
const e = n.reduce((s, a) => s + a.length, 0), t = new Uint8Array(e);
|
|
976
|
+
let r = 0;
|
|
977
|
+
for (const s of n)
|
|
978
|
+
t.set(s, r), r += s.length;
|
|
979
|
+
return t;
|
|
980
|
+
}
|
|
981
|
+
function D(n) {
|
|
982
|
+
const t = [A(4, n.length)];
|
|
983
|
+
for (const r of n)
|
|
984
|
+
t.push(A(0, r));
|
|
985
|
+
return re(...t);
|
|
986
|
+
}
|
|
987
|
+
function Fe(n, e, t) {
|
|
988
|
+
if (!Number.isSafeInteger(t) || t < 0)
|
|
989
|
+
throw new Error(
|
|
990
|
+
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
|
|
991
|
+
);
|
|
992
|
+
const r = A(4, 3), s = D(n), a = D(e), c = A(0, t);
|
|
993
|
+
return re(r, s, a, c);
|
|
994
|
+
}
|
|
995
|
+
const Ne = new TextEncoder().encode(
|
|
996
|
+
"btc-auth.server-identity.v1"
|
|
997
|
+
);
|
|
998
|
+
class u extends Error {
|
|
999
|
+
constructor(e, t) {
|
|
1000
|
+
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
function w(n) {
|
|
1004
|
+
const e = new Uint8Array(n.length / 2);
|
|
1005
|
+
for (let t = 0; t < e.length; t++)
|
|
1006
|
+
e[t] = parseInt(n.slice(t * 2, t * 2 + 2), 16);
|
|
1007
|
+
return e;
|
|
1008
|
+
}
|
|
1009
|
+
function Re(n) {
|
|
1010
|
+
const { proof: e, pinnedServerPubkey: t, now: r } = n, s = _(t).toLowerCase();
|
|
1011
|
+
if (s.length !== v || !y.test(s))
|
|
1012
|
+
throw new u(
|
|
1013
|
+
`pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
|
|
1014
|
+
"invalid_pubkey_encoding"
|
|
1015
|
+
);
|
|
1016
|
+
const a = _(e.server_pubkey).toLowerCase();
|
|
1017
|
+
if (a.length !== v || !y.test(a))
|
|
1018
|
+
throw new u(
|
|
1019
|
+
`server_pubkey must be 32-byte hex; got ${a.length} chars`,
|
|
1020
|
+
"invalid_pubkey_encoding"
|
|
1021
|
+
);
|
|
1022
|
+
if (a !== s)
|
|
1023
|
+
throw new u(
|
|
1024
|
+
`server_pubkey does not match pinned value: expected ${s}, got ${a}`,
|
|
1025
|
+
"pinned_pubkey_mismatch"
|
|
1026
|
+
);
|
|
1027
|
+
if (!Number.isSafeInteger(e.expires_at))
|
|
1028
|
+
throw new u(
|
|
1029
|
+
`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,
|
|
1030
|
+
"invalid_expires_at"
|
|
1031
|
+
);
|
|
1032
|
+
if (!Number.isSafeInteger(r))
|
|
1033
|
+
throw new u(
|
|
1034
|
+
`now must be a finite integer; got ${JSON.stringify(r)}`,
|
|
1035
|
+
"invalid_expires_at"
|
|
1036
|
+
);
|
|
1037
|
+
if (e.expires_at <= r)
|
|
1038
|
+
throw new u(
|
|
1039
|
+
`server identity proof expired at ${e.expires_at}, now ${r}`,
|
|
1040
|
+
"expired"
|
|
1041
|
+
);
|
|
1042
|
+
const c = _(e.ephemeral_pubkey).toLowerCase();
|
|
1043
|
+
if (c.length !== F || !y.test(c))
|
|
1044
|
+
throw new u(
|
|
1045
|
+
`ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
|
|
1046
|
+
"invalid_ephemeral_pubkey"
|
|
1047
|
+
);
|
|
1048
|
+
const d = c.slice(0, 2);
|
|
1049
|
+
if (d !== "02" && d !== "03")
|
|
1050
|
+
throw new u(
|
|
1051
|
+
`ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
|
|
1052
|
+
"invalid_ephemeral_pubkey"
|
|
1053
|
+
);
|
|
1054
|
+
const I = w(c);
|
|
1055
|
+
if (!N.isPoint(I))
|
|
1056
|
+
throw new u(
|
|
1057
|
+
"ephemeral_pubkey is not a valid secp256k1 point",
|
|
1058
|
+
"invalid_ephemeral_pubkey"
|
|
1059
|
+
);
|
|
1060
|
+
const p = _(e.signature).toLowerCase();
|
|
1061
|
+
if (p.length !== pe || !y.test(p))
|
|
1062
|
+
throw new u(
|
|
1063
|
+
`signature must be 64-byte Schnorr hex; got ${p.length} chars`,
|
|
1064
|
+
"invalid_signature_encoding"
|
|
1065
|
+
);
|
|
1066
|
+
const C = Fe(
|
|
1067
|
+
Ne,
|
|
1068
|
+
w(c),
|
|
1069
|
+
e.expires_at
|
|
1070
|
+
);
|
|
1071
|
+
if (!Be(C, w(a), w(p)))
|
|
1072
|
+
throw new u(
|
|
1073
|
+
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
1074
|
+
"signature_verification_failed"
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
const H = "auth_createDepositorToken", M = 4102444800, Oe = 30;
|
|
1078
|
+
class Qe {
|
|
1079
|
+
constructor(e) {
|
|
1080
|
+
l(this, "client");
|
|
1081
|
+
l(this, "peginTxid");
|
|
1082
|
+
l(this, "authAnchorHex");
|
|
1083
|
+
l(this, "pinnedServerPubkey");
|
|
1084
|
+
l(this, "authGatedMethods");
|
|
1085
|
+
l(this, "refreshSkewSecs");
|
|
1086
|
+
l(this, "now");
|
|
1087
|
+
l(this, "cached", null);
|
|
1088
|
+
l(this, "inFlight", null);
|
|
1089
|
+
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Oe, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Return a bearer token for `method`, or `null` if `method` is not
|
|
1093
|
+
* auth-gated. Triggers a token acquisition if no token is cached or
|
|
1094
|
+
* the cached token is within {@link refreshSkewSecs} of expiry.
|
|
1095
|
+
*
|
|
1096
|
+
* The token-issuing method itself is hard-exempted from the gate —
|
|
1097
|
+
* if `auth_createDepositorToken` were ever included in
|
|
1098
|
+
* `authGatedMethods` (caller misconfiguration) the provider would
|
|
1099
|
+
* recurse into `acquireSingleFlight` from inside the JSON-RPC header
|
|
1100
|
+
* builder before `inFlight` is assigned, defeating the single-flight
|
|
1101
|
+
* guard. Returning `null` here breaks that recursion deterministically.
|
|
1102
|
+
*/
|
|
1103
|
+
async getToken(e) {
|
|
1104
|
+
if (e === H || !this.authGatedMethods.has(e)) return null;
|
|
1105
|
+
const t = this.cached;
|
|
1106
|
+
return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight()).token;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Drop the cached token. Next `getToken` call re-acquires.
|
|
1110
|
+
* Called by `JsonRpcClient` on wire `auth_expired` responses.
|
|
1111
|
+
*/
|
|
1112
|
+
invalidate() {
|
|
1113
|
+
this.cached = null;
|
|
1114
|
+
}
|
|
1115
|
+
acquireSingleFlight() {
|
|
1116
|
+
const e = this.inFlight;
|
|
1117
|
+
if (e) return e;
|
|
1118
|
+
const t = (async () => {
|
|
1119
|
+
try {
|
|
1120
|
+
const r = await this.client.call(H, {
|
|
1121
|
+
pegin_txid: this.peginTxid,
|
|
1122
|
+
auth_anchor: this.authAnchorHex
|
|
1123
|
+
});
|
|
1124
|
+
if (Re({
|
|
1125
|
+
proof: r.server_identity,
|
|
1126
|
+
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
1127
|
+
now: this.now()
|
|
1128
|
+
}), typeof r.token != "string" || r.token.length === 0)
|
|
1129
|
+
throw new Error(
|
|
1130
|
+
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
|
|
1131
|
+
);
|
|
1132
|
+
const s = this.now();
|
|
1133
|
+
if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= s || r.expires_at > M)
|
|
1134
|
+
throw new Error(
|
|
1135
|
+
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${s}, ${M}])`
|
|
1136
|
+
);
|
|
1137
|
+
const a = {
|
|
1138
|
+
token: r.token,
|
|
1139
|
+
expiresAt: r.expires_at
|
|
1140
|
+
};
|
|
1141
|
+
return this.cached = a, a;
|
|
1142
|
+
} finally {
|
|
1143
|
+
this.inFlight = null;
|
|
1144
|
+
}
|
|
1145
|
+
})();
|
|
1146
|
+
return this.inFlight = t, t;
|
|
896
1147
|
}
|
|
897
1148
|
}
|
|
898
|
-
async function
|
|
899
|
-
const [t,
|
|
1149
|
+
async function Ze(n, e) {
|
|
1150
|
+
const [t, r] = await n.multicall({
|
|
900
1151
|
contracts: [
|
|
901
1152
|
{
|
|
902
1153
|
address: e,
|
|
903
|
-
abi:
|
|
1154
|
+
abi: P,
|
|
904
1155
|
functionName: "protocolParams"
|
|
905
1156
|
},
|
|
906
1157
|
{
|
|
907
1158
|
address: e,
|
|
908
|
-
abi:
|
|
1159
|
+
abi: P,
|
|
909
1160
|
functionName: "applicationRegistry"
|
|
910
1161
|
}
|
|
911
1162
|
],
|
|
@@ -913,11 +1164,11 @@ async function _e(n, e) {
|
|
|
913
1164
|
});
|
|
914
1165
|
return {
|
|
915
1166
|
protocolParams: t,
|
|
916
|
-
applicationRegistry:
|
|
1167
|
+
applicationRegistry: r
|
|
917
1168
|
};
|
|
918
1169
|
}
|
|
919
|
-
const
|
|
920
|
-
function
|
|
1170
|
+
const L = 65535;
|
|
1171
|
+
function B(n) {
|
|
921
1172
|
return {
|
|
922
1173
|
timelockAssert: n.timelockAssert,
|
|
923
1174
|
timelockChallengeAssert: n.timelockChallengeAssert,
|
|
@@ -934,7 +1185,7 @@ function w(n) {
|
|
|
934
1185
|
minPrepeginDepth: n.minPrepeginDepth
|
|
935
1186
|
};
|
|
936
1187
|
}
|
|
937
|
-
function
|
|
1188
|
+
function X(n) {
|
|
938
1189
|
return {
|
|
939
1190
|
minimumPegInAmount: n.minimumPegInAmount,
|
|
940
1191
|
maxPegInAmount: n.maxPegInAmount,
|
|
@@ -943,52 +1194,52 @@ function x(n) {
|
|
|
943
1194
|
maxHtlcOutputCount: n.maxHtlcOutputCount
|
|
944
1195
|
};
|
|
945
1196
|
}
|
|
946
|
-
function
|
|
947
|
-
if (n > BigInt(
|
|
1197
|
+
function q(n) {
|
|
1198
|
+
if (n > BigInt(L))
|
|
948
1199
|
throw new Error(
|
|
949
|
-
`timelockAssert value ${n} exceeds uint16 max (${
|
|
1200
|
+
`timelockAssert value ${n} exceeds uint16 max (${L})`
|
|
950
1201
|
);
|
|
951
1202
|
return Number(n);
|
|
952
1203
|
}
|
|
953
|
-
class
|
|
1204
|
+
class et {
|
|
954
1205
|
constructor(e, t) {
|
|
955
1206
|
this.publicClient = e, this.contractAddress = t;
|
|
956
1207
|
}
|
|
957
1208
|
async getTBVProtocolParams() {
|
|
958
1209
|
const e = await this.publicClient.readContract({
|
|
959
1210
|
address: this.contractAddress,
|
|
960
|
-
abi:
|
|
1211
|
+
abi: m,
|
|
961
1212
|
functionName: "getTBVProtocolParams"
|
|
962
1213
|
});
|
|
963
|
-
return
|
|
1214
|
+
return X(e);
|
|
964
1215
|
}
|
|
965
1216
|
async getLatestOffchainParams() {
|
|
966
1217
|
const e = await this.publicClient.readContract({
|
|
967
1218
|
address: this.contractAddress,
|
|
968
|
-
abi:
|
|
1219
|
+
abi: m,
|
|
969
1220
|
functionName: "getLatestOffchainParams"
|
|
970
1221
|
});
|
|
971
|
-
return
|
|
1222
|
+
return B(e);
|
|
972
1223
|
}
|
|
973
1224
|
async getOffchainParamsByVersion(e) {
|
|
974
1225
|
const t = await this.publicClient.readContract({
|
|
975
1226
|
address: this.contractAddress,
|
|
976
|
-
abi:
|
|
1227
|
+
abi: m,
|
|
977
1228
|
functionName: "getOffchainParamsByVersion",
|
|
978
1229
|
args: [e]
|
|
979
1230
|
});
|
|
980
|
-
return
|
|
1231
|
+
return B(t);
|
|
981
1232
|
}
|
|
982
1233
|
async getLatestOffchainParamsVersion() {
|
|
983
1234
|
return await this.publicClient.readContract({
|
|
984
1235
|
address: this.contractAddress,
|
|
985
|
-
abi:
|
|
1236
|
+
abi: m,
|
|
986
1237
|
functionName: "latestOffchainParamsVersion"
|
|
987
1238
|
});
|
|
988
1239
|
}
|
|
989
1240
|
async getTimelockPeginByVersion(e) {
|
|
990
1241
|
const t = await this.getOffchainParamsByVersion(e);
|
|
991
|
-
return
|
|
1242
|
+
return q(t.timelockAssert);
|
|
992
1243
|
}
|
|
993
1244
|
/**
|
|
994
1245
|
* Read TBV protocol params and latest offchain params atomically via multicall.
|
|
@@ -999,104 +1250,104 @@ class we {
|
|
|
999
1250
|
contracts: [
|
|
1000
1251
|
{
|
|
1001
1252
|
address: this.contractAddress,
|
|
1002
|
-
abi:
|
|
1253
|
+
abi: m,
|
|
1003
1254
|
functionName: "getTBVProtocolParams"
|
|
1004
1255
|
},
|
|
1005
1256
|
{
|
|
1006
1257
|
address: this.contractAddress,
|
|
1007
|
-
abi:
|
|
1258
|
+
abi: m,
|
|
1008
1259
|
functionName: "getLatestOffchainParams"
|
|
1009
1260
|
}
|
|
1010
1261
|
],
|
|
1011
1262
|
allowFailure: !1
|
|
1012
|
-
}), t =
|
|
1263
|
+
}), t = X(e[0]), r = B(e[1]);
|
|
1013
1264
|
return {
|
|
1014
1265
|
minimumPegInAmount: t.minimumPegInAmount,
|
|
1015
1266
|
maxPegInAmount: t.maxPegInAmount,
|
|
1016
1267
|
pegInAckTimeout: t.pegInAckTimeout,
|
|
1017
1268
|
pegInActivationTimeout: t.pegInActivationTimeout,
|
|
1018
1269
|
maxHtlcOutputCount: t.maxHtlcOutputCount,
|
|
1019
|
-
timelockPegin:
|
|
1020
|
-
timelockRefund:
|
|
1021
|
-
minVpCommissionBps:
|
|
1022
|
-
offchainParams:
|
|
1270
|
+
timelockPegin: q(r.timelockAssert),
|
|
1271
|
+
timelockRefund: r.tRefund,
|
|
1272
|
+
minVpCommissionBps: r.minVpCommissionBps,
|
|
1273
|
+
offchainParams: r
|
|
1023
1274
|
};
|
|
1024
1275
|
}
|
|
1025
1276
|
}
|
|
1026
|
-
function
|
|
1277
|
+
function V(n) {
|
|
1027
1278
|
return n.map((e) => ({
|
|
1028
1279
|
ethAddress: e.ethAddress,
|
|
1029
1280
|
btcPubKey: e.btcPubKey
|
|
1030
1281
|
}));
|
|
1031
1282
|
}
|
|
1032
|
-
class
|
|
1283
|
+
class tt {
|
|
1033
1284
|
constructor(e, t) {
|
|
1034
1285
|
this.publicClient = e, this.contractAddress = t;
|
|
1035
1286
|
}
|
|
1036
1287
|
async getVaultKeepersByVersion(e, t) {
|
|
1037
|
-
const
|
|
1288
|
+
const r = await this.publicClient.readContract({
|
|
1038
1289
|
address: this.contractAddress,
|
|
1039
|
-
abi:
|
|
1290
|
+
abi: S,
|
|
1040
1291
|
functionName: "getVaultKeepersByVersion",
|
|
1041
1292
|
args: [e, t]
|
|
1042
1293
|
});
|
|
1043
|
-
return
|
|
1294
|
+
return V(r);
|
|
1044
1295
|
}
|
|
1045
1296
|
async getCurrentVaultKeepers(e) {
|
|
1046
1297
|
const t = await this.publicClient.readContract({
|
|
1047
1298
|
address: this.contractAddress,
|
|
1048
|
-
abi:
|
|
1299
|
+
abi: S,
|
|
1049
1300
|
functionName: "getCurrentVaultKeepers",
|
|
1050
1301
|
args: [e]
|
|
1051
1302
|
});
|
|
1052
|
-
return
|
|
1303
|
+
return V(t);
|
|
1053
1304
|
}
|
|
1054
1305
|
async getCurrentVaultKeepersVersion(e) {
|
|
1055
1306
|
return await this.publicClient.readContract({
|
|
1056
1307
|
address: this.contractAddress,
|
|
1057
|
-
abi:
|
|
1308
|
+
abi: S,
|
|
1058
1309
|
functionName: "getCurrentVaultKeepersVersion",
|
|
1059
1310
|
args: [e]
|
|
1060
1311
|
});
|
|
1061
1312
|
}
|
|
1062
1313
|
}
|
|
1063
|
-
class
|
|
1314
|
+
class nt {
|
|
1064
1315
|
constructor(e, t) {
|
|
1065
1316
|
this.publicClient = e, this.contractAddress = t;
|
|
1066
1317
|
}
|
|
1067
1318
|
async getUniversalChallengersByVersion(e) {
|
|
1068
1319
|
const t = await this.publicClient.readContract({
|
|
1069
1320
|
address: this.contractAddress,
|
|
1070
|
-
abi:
|
|
1321
|
+
abi: m,
|
|
1071
1322
|
functionName: "getUniversalChallengersByVersion",
|
|
1072
1323
|
args: [e]
|
|
1073
1324
|
});
|
|
1074
|
-
return
|
|
1325
|
+
return V(t);
|
|
1075
1326
|
}
|
|
1076
1327
|
async getCurrentUniversalChallengers() {
|
|
1077
1328
|
const e = await this.publicClient.readContract({
|
|
1078
1329
|
address: this.contractAddress,
|
|
1079
|
-
abi:
|
|
1330
|
+
abi: m,
|
|
1080
1331
|
functionName: "getCurrentUniversalChallengers"
|
|
1081
1332
|
});
|
|
1082
|
-
return
|
|
1333
|
+
return V(e);
|
|
1083
1334
|
}
|
|
1084
1335
|
async getLatestUniversalChallengersVersion() {
|
|
1085
1336
|
return await this.publicClient.readContract({
|
|
1086
1337
|
address: this.contractAddress,
|
|
1087
|
-
abi:
|
|
1338
|
+
abi: m,
|
|
1088
1339
|
functionName: "latestUniversalChallengersVersion"
|
|
1089
1340
|
});
|
|
1090
1341
|
}
|
|
1091
1342
|
}
|
|
1092
|
-
class
|
|
1343
|
+
class rt {
|
|
1093
1344
|
constructor(e, t) {
|
|
1094
1345
|
this.publicClient = e, this.contractAddress = t;
|
|
1095
1346
|
}
|
|
1096
1347
|
async getVaultBasicInfo(e) {
|
|
1097
1348
|
const t = await this.publicClient.readContract({
|
|
1098
1349
|
address: this.contractAddress,
|
|
1099
|
-
abi:
|
|
1350
|
+
abi: P,
|
|
1100
1351
|
functionName: "getBtcVaultBasicInfo",
|
|
1101
1352
|
args: [e]
|
|
1102
1353
|
});
|
|
@@ -1113,7 +1364,7 @@ class ve {
|
|
|
1113
1364
|
async getVaultProtocolInfo(e) {
|
|
1114
1365
|
const t = await this.publicClient.readContract({
|
|
1115
1366
|
address: this.contractAddress,
|
|
1116
|
-
abi:
|
|
1367
|
+
abi: P,
|
|
1117
1368
|
functionName: "getBtcVaultProtocolInfo",
|
|
1118
1369
|
args: [e]
|
|
1119
1370
|
});
|
|
@@ -1132,36 +1383,39 @@ class ve {
|
|
|
1132
1383
|
};
|
|
1133
1384
|
}
|
|
1134
1385
|
async getVaultData(e) {
|
|
1135
|
-
const [t,
|
|
1386
|
+
const [t, r] = await Promise.all([
|
|
1136
1387
|
this.getVaultBasicInfo(e),
|
|
1137
1388
|
this.getVaultProtocolInfo(e)
|
|
1138
1389
|
]);
|
|
1139
|
-
if (!
|
|
1390
|
+
if (!r.depositorSignedPeginTx || r.depositorSignedPeginTx === "0x")
|
|
1140
1391
|
throw new Error(
|
|
1141
1392
|
`Vault ${e} not found on-chain or has no pegin transaction`
|
|
1142
1393
|
);
|
|
1143
|
-
return { basic: t, protocol:
|
|
1394
|
+
return { basic: t, protocol: r };
|
|
1144
1395
|
}
|
|
1145
1396
|
}
|
|
1146
1397
|
export {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1398
|
+
S as A,
|
|
1399
|
+
fe as M,
|
|
1400
|
+
m as P,
|
|
1401
|
+
u as S,
|
|
1402
|
+
Ye as V,
|
|
1403
|
+
Ge as a,
|
|
1404
|
+
We as b,
|
|
1405
|
+
ze as c,
|
|
1406
|
+
Xe as d,
|
|
1407
|
+
ye as e,
|
|
1408
|
+
qe as f,
|
|
1409
|
+
Je as g,
|
|
1410
|
+
i as h,
|
|
1411
|
+
Re as i,
|
|
1412
|
+
Qe as j,
|
|
1413
|
+
et as k,
|
|
1414
|
+
nt as l,
|
|
1415
|
+
tt as m,
|
|
1416
|
+
rt as n,
|
|
1417
|
+
Le as p,
|
|
1418
|
+
Ze as r,
|
|
1419
|
+
Ae as v
|
|
1166
1420
|
};
|
|
1167
|
-
//# sourceMappingURL=
|
|
1421
|
+
//# sourceMappingURL=vault-registry-reader-CpCOte7w.js.map
|