@babylonlabs-io/ts-sdk 0.31.0 → 0.33.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/dist/{PeginManager-c44Uvd1N.js → PeginManager-BMrWtTji.js} +137 -125
- package/dist/PeginManager-BMrWtTji.js.map +1 -0
- package/dist/PeginManager-DUMF84XK.cjs +2 -0
- package/dist/PeginManager-DUMF84XK.cjs.map +1 -0
- package/dist/{bitcoin-B-Y0DlqR.js → bitcoin-0_T6KJON.js} +32 -28
- package/dist/bitcoin-0_T6KJON.js.map +1 -0
- package/dist/bitcoin-EYBKDtEW.cjs +2 -0
- package/dist/bitcoin-EYBKDtEW.cjs.map +1 -0
- package/dist/{buildAndBroadcastRefund-CLLaz8D3.cjs → buildAndBroadcastRefund-6pR681fI.cjs} +2 -2
- package/dist/buildAndBroadcastRefund-6pR681fI.cjs.map +1 -0
- package/dist/{buildAndBroadcastRefund-BRQaCQrJ.js → buildAndBroadcastRefund-Ba56IKL7.js} +40 -40
- package/dist/buildAndBroadcastRefund-Ba56IKL7.js.map +1 -0
- package/dist/challengeAssert-DSlCIBoT.js +304 -0
- package/dist/challengeAssert-DSlCIBoT.js.map +1 -0
- package/dist/challengeAssert-DuhkzZG-.cjs +2 -0
- package/dist/challengeAssert-DuhkzZG-.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +75 -71
- package/dist/{noPayout-CwgYkZYs.cjs → noPayout-CDhbGn_B.cjs} +2 -2
- package/dist/{noPayout-CwgYkZYs.cjs.map → noPayout-CDhbGn_B.cjs.map} +1 -1
- package/dist/{noPayout-B8JiTaYt.js → noPayout-DohtepqZ.js} +2 -2
- package/dist/{noPayout-B8JiTaYt.js.map → noPayout-DohtepqZ.js.map} +1 -1
- package/dist/{psbtInputFields-CB8hqjQ5.cjs → psbtInputFields-BLi7Ta-T.cjs} +2 -2
- package/dist/{psbtInputFields-CB8hqjQ5.cjs.map → psbtInputFields-BLi7Ta-T.cjs.map} +1 -1
- package/dist/{psbtInputFields-DeTFSJOq.js → psbtInputFields-DPCFHgGd.js} +2 -2
- package/dist/{psbtInputFields-DeTFSJOq.js.map → psbtInputFields-DPCFHgGd.js.map} +1 -1
- package/dist/tbv/core/clients/eth/index.d.ts +1 -1
- package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +13 -0
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +8 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +30 -27
- package/dist/tbv/core/clients/vault-provider/api.d.ts +13 -2
- package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/createAuthenticatedVpClient.test.d.ts +11 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/createAuthenticatedVpClient.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/tokenRegistry.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/tokenRegistry.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts +16 -0
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/gatedMethods.d.ts +10 -0
- package/dist/tbv/core/clients/vault-provider/auth/gatedMethods.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/index.d.ts +5 -2
- package/dist/tbv/core/clients/vault-provider/auth/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/innerTokenClient.d.ts +4 -0
- package/dist/tbv/core/clients/vault-provider/auth/innerTokenClient.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts +11 -0
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts +18 -23
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts +48 -0
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +8 -12
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +14 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +66 -62
- package/dist/tbv/core/managers/index.d.ts +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/challengeAssert.d.ts +10 -7
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/constants.d.ts +26 -0
- package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts +13 -6
- package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +13 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/__tests__/runDepositorPresignFlow.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/runDepositorPresignFlow.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +2 -2
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/{signAndSubmitPayouts.d.ts → runDepositorPresignFlow.d.ts} +3 -3
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +11 -11
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +2 -2
- package/dist/tbv/core/vault-secrets/__tests__/parseFundingOutpoints.test.d.ts +2 -0
- package/dist/tbv/core/vault-secrets/__tests__/parseFundingOutpoints.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/index.d.ts +1 -0
- package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/parseFundingOutpoints.d.ts +3 -0
- package/dist/tbv/core/vault-secrets/parseFundingOutpoints.d.ts.map +1 -0
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +66 -62
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{types-jmEyzzhY.cjs → types-C2IUB0Jd.cjs} +2 -2
- package/dist/types-C2IUB0Jd.cjs.map +1 -0
- package/dist/{types-CnG3JsRs.js → types-D1o_3Q__.js} +20 -9
- package/dist/types-D1o_3Q__.js.map +1 -0
- package/dist/{vault-registry-reader-BywZhqJL.js → vault-registry-reader-BeIEh62N.js} +436 -292
- package/dist/vault-registry-reader-BeIEh62N.js.map +1 -0
- package/dist/vault-registry-reader-DdUgC5IF.cjs +2 -0
- package/dist/vault-registry-reader-DdUgC5IF.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/PeginManager-DmVq6ffv.cjs +0 -2
- package/dist/PeginManager-DmVq6ffv.cjs.map +0 -1
- package/dist/PeginManager-c44Uvd1N.js.map +0 -1
- package/dist/bitcoin-B-Y0DlqR.js.map +0 -1
- package/dist/bitcoin-DIN0OupO.cjs +0 -2
- package/dist/bitcoin-DIN0OupO.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-BRQaCQrJ.js.map +0 -1
- package/dist/buildAndBroadcastRefund-CLLaz8D3.cjs.map +0 -1
- package/dist/challengeAssert-mYikGC34.js +0 -269
- package/dist/challengeAssert-mYikGC34.js.map +0 -1
- package/dist/challengeAssert-yYFflBOx.cjs +0 -2
- package/dist/challengeAssert-yYFflBOx.cjs.map +0 -1
- package/dist/tbv/core/services/deposit/__tests__/signAndSubmitPayouts.test.d.ts +0 -2
- package/dist/tbv/core/services/deposit/__tests__/signAndSubmitPayouts.test.d.ts.map +0 -1
- package/dist/tbv/core/services/deposit/signAndSubmitPayouts.d.ts.map +0 -1
- package/dist/types-CnG3JsRs.js.map +0 -1
- package/dist/types-jmEyzzhY.cjs.map +0 -1
- package/dist/vault-registry-reader-BywZhqJL.js.map +0 -1
- package/dist/vault-registry-reader-DdruADqa.cjs +0 -2
- package/dist/vault-registry-reader-DdruADqa.cjs.map +0 -1
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (n, e, t) =>
|
|
4
|
-
import { B as
|
|
5
|
-
import { D as
|
|
6
|
-
import { X as v, C as
|
|
7
|
-
import * as
|
|
8
|
-
import { payments as
|
|
9
|
-
import { Buffer as
|
|
1
|
+
var oe = Object.defineProperty;
|
|
2
|
+
var ce = (n, e, t) => e in n ? oe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var l = (n, e, t) => ce(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { B as le, H as f, K as ue, T as pe } from "./validation-CxqROCno.js";
|
|
5
|
+
import { D as de, J as G, B as b } from "./types-D1o_3Q__.js";
|
|
6
|
+
import { X as v, C as O, s as _, S as he, h as me } from "./bitcoin-0_T6KJON.js";
|
|
7
|
+
import * as $ from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
|
+
import { payments as ye, Transaction as I } from "bitcoinjs-lib";
|
|
9
|
+
import { Buffer as y } from "buffer";
|
|
10
10
|
import { s as K } from "./sha2-6wN58S6R.js";
|
|
11
|
-
const
|
|
12
|
-
async function
|
|
11
|
+
const fe = 21e6 * 1e8, U = 3e4;
|
|
12
|
+
async function k(n, e) {
|
|
13
13
|
const t = new AbortController(), r = setTimeout(
|
|
14
14
|
() => t.abort(),
|
|
15
15
|
U
|
|
16
|
-
),
|
|
16
|
+
), i = [t.signal, e == null ? void 0 : e.signal].filter(
|
|
17
17
|
Boolean
|
|
18
18
|
);
|
|
19
19
|
try {
|
|
20
20
|
return await fetch(n, {
|
|
21
21
|
...e,
|
|
22
|
-
signal: AbortSignal.any(
|
|
22
|
+
signal: AbortSignal.any(i)
|
|
23
23
|
});
|
|
24
|
-
} catch (
|
|
25
|
-
throw clearTimeout(r),
|
|
24
|
+
} catch (s) {
|
|
25
|
+
throw clearTimeout(r), s != null && typeof s == "object" && "name" in s && s.name === "AbortError" ? new Error(
|
|
26
26
|
`Mempool API request timed out after ${U}ms: ${n}`
|
|
27
|
-
) :
|
|
27
|
+
) : s;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
function
|
|
32
|
-
return Number.isInteger(n) && n > 0 && n <=
|
|
30
|
+
const W = 1e4;
|
|
31
|
+
function J(n) {
|
|
32
|
+
return Number.isInteger(n) && n > 0 && n <= fe;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return Number.isInteger(n) && n > 0 && n <=
|
|
34
|
+
function ge(n) {
|
|
35
|
+
return Number.isInteger(n) && n > 0 && n <= W;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function z(n, e) {
|
|
38
38
|
return !Number.isInteger(n) || n < 0 ? !1 : e === void 0 || n < e;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
if (!
|
|
40
|
+
function C(n) {
|
|
41
|
+
if (!pe.test(n))
|
|
42
42
|
throw new Error(`Invalid transaction ID format: ${n}`);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
if (!
|
|
44
|
+
function Y(n) {
|
|
45
|
+
if (!le.test(n))
|
|
46
46
|
throw new Error(`Invalid Bitcoin address format: ${n}`);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
if (!
|
|
48
|
+
function Q(n, e) {
|
|
49
|
+
if (!f.test(n))
|
|
50
50
|
throw new Error(
|
|
51
51
|
`Invalid scriptPubKey: not valid hex for ${e}`
|
|
52
52
|
);
|
|
53
|
-
if (!
|
|
53
|
+
if (!ue.some(
|
|
54
54
|
(r) => n.toLowerCase().startsWith(r)
|
|
55
55
|
))
|
|
56
56
|
throw new Error(
|
|
57
57
|
`Unrecognized scriptPubKey type for ${e}: prefix ${n.slice(0, 6)} does not match any known Bitcoin script type`
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
60
|
+
const be = {
|
|
61
61
|
mainnet: "https://mempool.space/api",
|
|
62
62
|
testnet: "https://mempool.space/testnet/api",
|
|
63
63
|
signet: "https://mempool.space/signet/api"
|
|
64
64
|
};
|
|
65
65
|
async function T(n, e) {
|
|
66
66
|
try {
|
|
67
|
-
const t = await
|
|
67
|
+
const t = await k(n, e);
|
|
68
68
|
if (!t.ok) {
|
|
69
|
-
const
|
|
69
|
+
const i = await t.text();
|
|
70
70
|
throw new Error(
|
|
71
|
-
`Mempool API error (${t.status}): ${
|
|
71
|
+
`Mempool API error (${t.status}): ${i || t.statusText}`
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
const r = t.headers.get("content-type");
|
|
@@ -77,9 +77,9 @@ async function T(n, e) {
|
|
|
77
77
|
throw t instanceof Error ? new Error(`Failed to fetch from mempool API: ${t.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
async function
|
|
80
|
+
async function Ze(n, e) {
|
|
81
81
|
try {
|
|
82
|
-
const t = await
|
|
82
|
+
const t = await k(`${e}/tx`, {
|
|
83
83
|
method: "POST",
|
|
84
84
|
body: n,
|
|
85
85
|
headers: {
|
|
@@ -87,15 +87,15 @@ async function Xe(n, e) {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
if (!t.ok) {
|
|
90
|
-
const
|
|
91
|
-
let
|
|
90
|
+
const i = await t.text();
|
|
91
|
+
let s;
|
|
92
92
|
try {
|
|
93
|
-
|
|
93
|
+
s = JSON.parse(i).message;
|
|
94
94
|
} catch {
|
|
95
|
-
|
|
95
|
+
s = i;
|
|
96
96
|
}
|
|
97
97
|
throw new Error(
|
|
98
|
-
|
|
98
|
+
s || `Failed to broadcast transaction: ${t.statusText}`
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
return await t.text();
|
|
@@ -103,13 +103,13 @@ async function Xe(n, e) {
|
|
|
103
103
|
throw t instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${t.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
async function
|
|
107
|
-
return
|
|
106
|
+
async function we(n, e) {
|
|
107
|
+
return C(n), T(`${e}/tx/${n}`);
|
|
108
108
|
}
|
|
109
|
-
async function
|
|
110
|
-
|
|
109
|
+
async function et(n, e) {
|
|
110
|
+
C(n);
|
|
111
111
|
try {
|
|
112
|
-
const t = await
|
|
112
|
+
const t = await k(`${e}/tx/${n}/hex`);
|
|
113
113
|
if (!t.ok) {
|
|
114
114
|
const r = await t.text();
|
|
115
115
|
throw new Error(
|
|
@@ -121,46 +121,46 @@ async function qe(n, e) {
|
|
|
121
121
|
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`);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
async function
|
|
125
|
-
|
|
126
|
-
const r = await
|
|
127
|
-
if (!
|
|
124
|
+
async function tt(n, e, t) {
|
|
125
|
+
C(n);
|
|
126
|
+
const r = await we(n, t);
|
|
127
|
+
if (!z(e, r.vout.length))
|
|
128
128
|
throw new Error(
|
|
129
129
|
`Invalid vout ${e} for transaction ${n} (has ${r.vout.length} outputs)`
|
|
130
130
|
);
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
133
|
-
throw new Error(`Invalid UTXO value ${
|
|
134
|
-
return
|
|
131
|
+
const i = r.vout[e];
|
|
132
|
+
if (!J(i.value))
|
|
133
|
+
throw new Error(`Invalid UTXO value ${i.value} for ${n}:${e}`);
|
|
134
|
+
return Q(i.scriptpubkey, `${n}:${e}`), {
|
|
135
135
|
txid: n,
|
|
136
136
|
vout: e,
|
|
137
|
-
value:
|
|
138
|
-
scriptPubKey:
|
|
137
|
+
value: i.value,
|
|
138
|
+
scriptPubKey: i.scriptpubkey
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
-
async function
|
|
142
|
-
|
|
141
|
+
async function nt(n, e) {
|
|
142
|
+
Y(n);
|
|
143
143
|
try {
|
|
144
144
|
const t = await T(`${e}/address/${n}/utxo`), r = await T(`${e}/v1/validate-address/${n}`);
|
|
145
145
|
if (!r.isvalid)
|
|
146
146
|
throw new Error(
|
|
147
147
|
`Invalid Bitcoin address: ${n}. Mempool API validation failed.`
|
|
148
148
|
);
|
|
149
|
-
|
|
150
|
-
for (const
|
|
151
|
-
if (
|
|
152
|
-
throw new Error(`Invalid vout ${
|
|
153
|
-
if (!
|
|
149
|
+
Q(r.scriptPubKey, n);
|
|
150
|
+
for (const s of t) {
|
|
151
|
+
if (C(s.txid), !z(s.vout))
|
|
152
|
+
throw new Error(`Invalid vout ${s.vout} for ${s.txid}`);
|
|
153
|
+
if (!J(s.value))
|
|
154
154
|
throw new Error(
|
|
155
|
-
`Invalid UTXO value ${
|
|
155
|
+
`Invalid UTXO value ${s.value} for ${s.txid}:${s.vout}`
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
|
-
return t.sort((
|
|
159
|
-
txid:
|
|
160
|
-
vout:
|
|
161
|
-
value:
|
|
158
|
+
return t.sort((s, c) => c.value - s.value).map((s) => ({
|
|
159
|
+
txid: s.txid,
|
|
160
|
+
vout: s.vout,
|
|
161
|
+
value: s.value,
|
|
162
162
|
scriptPubKey: r.scriptPubKey,
|
|
163
|
-
confirmed:
|
|
163
|
+
confirmed: s.status.confirmed
|
|
164
164
|
}));
|
|
165
165
|
} catch (t) {
|
|
166
166
|
throw t instanceof Error ? new Error(
|
|
@@ -170,14 +170,14 @@ async function We(n, e) {
|
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
173
|
+
function rt(n) {
|
|
174
|
+
return be[n];
|
|
175
175
|
}
|
|
176
|
-
async function
|
|
177
|
-
return
|
|
176
|
+
async function st(n, e) {
|
|
177
|
+
return Y(n), T(`${e}/address/${n}/txs`);
|
|
178
178
|
}
|
|
179
|
-
async function
|
|
180
|
-
const e = await
|
|
179
|
+
async function it(n) {
|
|
180
|
+
const e = await k(`${n}/v1/fees/recommended`);
|
|
181
181
|
if (!e.ok)
|
|
182
182
|
throw new Error(
|
|
183
183
|
`Failed to fetch network fees: ${e.status} ${e.statusText}`
|
|
@@ -189,10 +189,10 @@ async function Ye(n) {
|
|
|
189
189
|
"economyFee",
|
|
190
190
|
"minimumFee"
|
|
191
191
|
];
|
|
192
|
-
for (const
|
|
193
|
-
if (!
|
|
192
|
+
for (const i of r)
|
|
193
|
+
if (!ge(t[i]))
|
|
194
194
|
throw new Error(
|
|
195
|
-
`Invalid fee rate ${
|
|
195
|
+
`Invalid fee rate ${i}=${t[i]} from mempool API: expected a positive number ≤ ${W}`
|
|
196
196
|
);
|
|
197
197
|
if (t.minimumFee > t.economyFee || t.economyFee > t.hourFee || t.hourFee > t.halfHourFee || t.halfHourFee > t.fastestFee)
|
|
198
198
|
throw new Error(
|
|
@@ -200,7 +200,7 @@ async function Ye(n) {
|
|
|
200
200
|
);
|
|
201
201
|
return t;
|
|
202
202
|
}
|
|
203
|
-
const
|
|
203
|
+
const B = [
|
|
204
204
|
{
|
|
205
205
|
type: "function",
|
|
206
206
|
name: "getVaultKeepersByVersion",
|
|
@@ -287,7 +287,7 @@ const S = [
|
|
|
287
287
|
],
|
|
288
288
|
stateMutability: "view"
|
|
289
289
|
}
|
|
290
|
-
],
|
|
290
|
+
], h = [
|
|
291
291
|
{
|
|
292
292
|
type: "function",
|
|
293
293
|
name: "getTBVProtocolParams",
|
|
@@ -576,260 +576,260 @@ const S = [
|
|
|
576
576
|
],
|
|
577
577
|
stateMutability: "view"
|
|
578
578
|
}
|
|
579
|
-
],
|
|
579
|
+
], D = new Set(Object.values(de)), _e = 200;
|
|
580
580
|
function o(n) {
|
|
581
581
|
var e;
|
|
582
|
-
return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0,
|
|
582
|
+
return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0, _e)) ?? "undefined";
|
|
583
583
|
}
|
|
584
|
-
const
|
|
585
|
-
class
|
|
584
|
+
const Pe = "The vault provider returned an unexpected response. Please try again or contact support.";
|
|
585
|
+
class a extends Error {
|
|
586
586
|
constructor(t) {
|
|
587
|
-
super(
|
|
587
|
+
super(Pe);
|
|
588
588
|
l(this, "detail");
|
|
589
589
|
this.name = "VpResponseValidationError", this.detail = t;
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
592
|
const x = 64;
|
|
593
593
|
function g(n) {
|
|
594
|
-
return typeof n == "string" && n.length > 0 &&
|
|
594
|
+
return typeof n == "string" && n.length > 0 && f.test(n);
|
|
595
595
|
}
|
|
596
|
-
function
|
|
596
|
+
function Z(n) {
|
|
597
597
|
return typeof n == "string" && n.length > 0;
|
|
598
598
|
}
|
|
599
|
-
function
|
|
599
|
+
function ee(n, e) {
|
|
600
600
|
if (!g(n))
|
|
601
|
-
throw new
|
|
601
|
+
throw new a(
|
|
602
602
|
`VP response validation failed: "${e}" must be a non-empty hex string, got ${o(n)}`
|
|
603
603
|
);
|
|
604
604
|
}
|
|
605
|
-
function
|
|
606
|
-
if (!
|
|
607
|
-
throw new
|
|
605
|
+
function w(n, e) {
|
|
606
|
+
if (!Z(n))
|
|
607
|
+
throw new a(
|
|
608
608
|
`VP response validation failed: "${e}" must be a non-empty string, got ${o(n)}`
|
|
609
609
|
);
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
if (!g(n) || n.length !== v && n.length !==
|
|
613
|
-
throw new
|
|
614
|
-
`VP response validation failed: "${e}" must be a ${v} or ${
|
|
611
|
+
function te(n, e) {
|
|
612
|
+
if (!g(n) || n.length !== v && n.length !== O)
|
|
613
|
+
throw new a(
|
|
614
|
+
`VP response validation failed: "${e}" must be a ${v} or ${O}-char hex string (BTC pubkey), got ${o(n)}`
|
|
615
615
|
);
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function ve(n) {
|
|
618
618
|
const e = n.presigning;
|
|
619
619
|
if (e == null) return;
|
|
620
620
|
if (typeof e != "object" || Array.isArray(e))
|
|
621
|
-
throw new
|
|
621
|
+
throw new a(
|
|
622
622
|
'VP response validation failed: "progress.presigning" must be an object if present'
|
|
623
623
|
);
|
|
624
624
|
const t = e;
|
|
625
625
|
if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
|
|
626
|
-
throw new
|
|
626
|
+
throw new a(
|
|
627
627
|
`VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${o(t.depositor_graph_created)}`
|
|
628
628
|
);
|
|
629
629
|
if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
|
|
630
|
-
throw new
|
|
630
|
+
throw new a(
|
|
631
631
|
`VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${o(t.vk_challenger_presigning_completed)}`
|
|
632
632
|
);
|
|
633
633
|
if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
|
|
634
|
-
throw new
|
|
634
|
+
throw new a(
|
|
635
635
|
`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${o(t.vk_challenger_presigning_total)}`
|
|
636
636
|
);
|
|
637
637
|
}
|
|
638
|
-
function
|
|
638
|
+
function Te(n) {
|
|
639
639
|
if (n === null || typeof n != "object")
|
|
640
|
-
throw new
|
|
640
|
+
throw new a(
|
|
641
641
|
"VP response validation failed: getPeginStatus response is not an object"
|
|
642
642
|
);
|
|
643
643
|
const e = n;
|
|
644
644
|
if (!g(e.pegin_txid) || e.pegin_txid.length !== x)
|
|
645
|
-
throw new
|
|
645
|
+
throw new a(
|
|
646
646
|
`VP response validation failed: "pegin_txid" must be a ${x}-char hex string (txid), got ${o(e.pegin_txid)}`
|
|
647
647
|
);
|
|
648
648
|
if (typeof e.status != "string")
|
|
649
|
-
throw new
|
|
649
|
+
throw new a(
|
|
650
650
|
'VP response validation failed: "status" must be a string'
|
|
651
651
|
);
|
|
652
|
-
if (!
|
|
653
|
-
throw new
|
|
654
|
-
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...
|
|
652
|
+
if (!D.has(e.status))
|
|
653
|
+
throw new a(
|
|
654
|
+
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...D].join(", ")}`
|
|
655
655
|
);
|
|
656
656
|
if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
|
|
657
|
-
throw new
|
|
657
|
+
throw new a(
|
|
658
658
|
'VP response validation failed: "progress" must be an object'
|
|
659
659
|
);
|
|
660
|
-
if (
|
|
661
|
-
throw new
|
|
660
|
+
if (ve(e.progress), typeof e.health_info != "string")
|
|
661
|
+
throw new a(
|
|
662
662
|
'VP response validation failed: "health_info" must be a string'
|
|
663
663
|
);
|
|
664
664
|
if (e.last_error !== void 0 && typeof e.last_error != "string")
|
|
665
|
-
throw new
|
|
665
|
+
throw new a(
|
|
666
666
|
`VP response validation failed: "last_error" must be a string if present, got ${o(e.last_error)}`
|
|
667
667
|
);
|
|
668
668
|
}
|
|
669
|
-
function
|
|
669
|
+
function xe(n) {
|
|
670
670
|
if (n === null || typeof n != "object")
|
|
671
|
-
throw new
|
|
671
|
+
throw new a(
|
|
672
672
|
"VP response validation failed: requestDepositorPresignTransactions response is not an object"
|
|
673
673
|
);
|
|
674
674
|
const e = n;
|
|
675
675
|
if (!Array.isArray(e.txs))
|
|
676
|
-
throw new
|
|
676
|
+
throw new a(
|
|
677
677
|
'VP response validation failed: "txs" must be an array'
|
|
678
678
|
);
|
|
679
679
|
for (let t = 0; t < e.txs.length; t++)
|
|
680
|
-
|
|
680
|
+
Ae(e.txs[t], `txs[${t}]`);
|
|
681
681
|
if (e.depositor_graph === null || typeof e.depositor_graph != "object")
|
|
682
|
-
throw new
|
|
682
|
+
throw new a(
|
|
683
683
|
'VP response validation failed: "depositor_graph" must be an object'
|
|
684
684
|
);
|
|
685
|
-
|
|
685
|
+
Se(
|
|
686
686
|
e.depositor_graph
|
|
687
687
|
);
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function m(n, e) {
|
|
690
690
|
if (n === null || typeof n != "object")
|
|
691
|
-
throw new
|
|
691
|
+
throw new a(
|
|
692
692
|
`VP response validation failed: "${e}" must be an object`
|
|
693
693
|
);
|
|
694
|
-
|
|
694
|
+
ee(n.tx_hex, `${e}.tx_hex`);
|
|
695
695
|
}
|
|
696
|
-
function
|
|
696
|
+
function Ae(n, e) {
|
|
697
697
|
if (n === null || typeof n != "object")
|
|
698
|
-
throw new
|
|
698
|
+
throw new a(
|
|
699
699
|
`VP response validation failed: "${e}" must be an object`
|
|
700
700
|
);
|
|
701
701
|
const t = n;
|
|
702
|
-
|
|
702
|
+
te(t.claimer_pubkey, `${e}.claimer_pubkey`), m(t.claim_tx, `${e}.claim_tx`), m(t.assert_tx, `${e}.assert_tx`), m(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
|
|
703
703
|
}
|
|
704
|
-
function
|
|
704
|
+
function Ve(n, e) {
|
|
705
705
|
if (n === null || typeof n != "object")
|
|
706
|
-
throw new
|
|
706
|
+
throw new a(
|
|
707
707
|
`VP response validation failed: "${e}" must be an object`
|
|
708
708
|
);
|
|
709
709
|
const t = n;
|
|
710
|
-
|
|
710
|
+
w(t.wots_pks_json, `${e}.wots_pks_json`), w(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function $e(n, e) {
|
|
713
713
|
if (n === null || typeof n != "object")
|
|
714
|
-
throw new
|
|
714
|
+
throw new a(
|
|
715
715
|
`VP response validation failed: "${e}" must be an object`
|
|
716
716
|
);
|
|
717
717
|
const t = n;
|
|
718
|
-
if (
|
|
718
|
+
if (te(t.challenger_pubkey, `${e}.challenger_pubkey`), m(
|
|
719
719
|
t.challenge_assert_x_tx,
|
|
720
720
|
`${e}.challenge_assert_x_tx`
|
|
721
|
-
),
|
|
721
|
+
), m(
|
|
722
722
|
t.challenge_assert_y_tx,
|
|
723
723
|
`${e}.challenge_assert_y_tx`
|
|
724
|
-
),
|
|
725
|
-
throw new
|
|
724
|
+
), m(t.nopayout_tx, `${e}.nopayout_tx`), w(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
|
|
725
|
+
throw new a(
|
|
726
726
|
`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
|
|
727
727
|
);
|
|
728
728
|
for (let r = 0; r < t.challenge_assert_connectors.length; r++)
|
|
729
|
-
|
|
729
|
+
Ve(
|
|
730
730
|
t.challenge_assert_connectors[r],
|
|
731
731
|
`${e}.challenge_assert_connectors[${r}]`
|
|
732
732
|
);
|
|
733
733
|
if (!Array.isArray(t.output_label_hashes))
|
|
734
|
-
throw new
|
|
734
|
+
throw new a(
|
|
735
735
|
`VP response validation failed: "${e}.output_label_hashes" must be an array`
|
|
736
736
|
);
|
|
737
737
|
for (let r = 0; r < t.output_label_hashes.length; r++)
|
|
738
|
-
|
|
738
|
+
ee(
|
|
739
739
|
t.output_label_hashes[r],
|
|
740
740
|
`${e}.output_label_hashes[${r}]`
|
|
741
741
|
);
|
|
742
742
|
}
|
|
743
|
-
function
|
|
743
|
+
function ke(n) {
|
|
744
744
|
if (n === null || typeof n != "object")
|
|
745
|
-
throw new
|
|
745
|
+
throw new a(
|
|
746
746
|
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
747
747
|
);
|
|
748
748
|
const e = n;
|
|
749
|
-
if (!
|
|
750
|
-
throw new
|
|
749
|
+
if (!Z(e.tx_graph_json))
|
|
750
|
+
throw new a(
|
|
751
751
|
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${o(e.tx_graph_json)}`
|
|
752
752
|
);
|
|
753
753
|
if (!g(e.verifying_key_hex))
|
|
754
|
-
throw new
|
|
754
|
+
throw new a(
|
|
755
755
|
`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${o(e.verifying_key_hex)}`
|
|
756
756
|
);
|
|
757
757
|
if (e.babe_sessions === null || typeof e.babe_sessions != "object")
|
|
758
|
-
throw new
|
|
758
|
+
throw new a(
|
|
759
759
|
'VP response validation failed: "babe_sessions" must be an object'
|
|
760
760
|
);
|
|
761
761
|
for (const [t, r] of Object.entries(
|
|
762
762
|
e.babe_sessions
|
|
763
763
|
)) {
|
|
764
764
|
if (r === null || typeof r != "object")
|
|
765
|
-
throw new
|
|
765
|
+
throw new a(
|
|
766
766
|
`VP response validation failed: "babe_sessions.${t}" must be an object`
|
|
767
767
|
);
|
|
768
|
-
const
|
|
769
|
-
if (!g(
|
|
770
|
-
throw new
|
|
771
|
-
`VP response validation failed: "babe_sessions.${t}.decryptor_artifacts_hex" must be a non-empty hex string, got ${o(
|
|
768
|
+
const i = r;
|
|
769
|
+
if (!g(i.decryptor_artifacts_hex))
|
|
770
|
+
throw new a(
|
|
771
|
+
`VP response validation failed: "babe_sessions.${t}.decryptor_artifacts_hex" must be a non-empty hex string, got ${o(i.decryptor_artifacts_hex)}`
|
|
772
772
|
);
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function Ce(n) {
|
|
776
776
|
if (n === null || typeof n != "object")
|
|
777
|
-
throw new
|
|
777
|
+
throw new a(
|
|
778
778
|
"VP response validation failed: getPegoutStatus response is not an object"
|
|
779
779
|
);
|
|
780
780
|
const e = n;
|
|
781
781
|
if (!g(e.pegin_txid) || e.pegin_txid.length !== x)
|
|
782
|
-
throw new
|
|
782
|
+
throw new a(
|
|
783
783
|
`VP response validation failed: "pegin_txid" must be a ${x}-char hex string (txid), got ${o(e.pegin_txid)}`
|
|
784
784
|
);
|
|
785
785
|
if (typeof e.found != "boolean")
|
|
786
|
-
throw new
|
|
786
|
+
throw new a(
|
|
787
787
|
`VP response validation failed: "found" must be a boolean, got ${o(e.found)}`
|
|
788
788
|
);
|
|
789
789
|
if (e.claimer !== void 0) {
|
|
790
790
|
if (e.claimer === null || typeof e.claimer != "object")
|
|
791
|
-
throw new
|
|
791
|
+
throw new a(
|
|
792
792
|
'VP response validation failed: "claimer" must be an object if present'
|
|
793
793
|
);
|
|
794
794
|
const t = e.claimer;
|
|
795
795
|
if (typeof t.status != "string")
|
|
796
|
-
throw new
|
|
796
|
+
throw new a(
|
|
797
797
|
`VP response validation failed: "claimer.status" must be a string, got ${o(t.status)}`
|
|
798
798
|
);
|
|
799
799
|
if (typeof t.failed != "boolean")
|
|
800
|
-
throw new
|
|
800
|
+
throw new a(
|
|
801
801
|
`VP response validation failed: "claimer.failed" must be a boolean, got ${o(t.failed)}`
|
|
802
802
|
);
|
|
803
803
|
}
|
|
804
804
|
if (e.challenger !== void 0) {
|
|
805
805
|
if (e.challenger === null || typeof e.challenger != "object")
|
|
806
|
-
throw new
|
|
806
|
+
throw new a(
|
|
807
807
|
'VP response validation failed: "challenger" must be an object if present'
|
|
808
808
|
);
|
|
809
809
|
const t = e.challenger;
|
|
810
810
|
if (typeof t.status != "string")
|
|
811
|
-
throw new
|
|
811
|
+
throw new a(
|
|
812
812
|
`VP response validation failed: "challenger.status" must be a string, got ${o(t.status)}`
|
|
813
813
|
);
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
|
-
function
|
|
817
|
-
if (
|
|
818
|
-
throw new
|
|
816
|
+
function Se(n) {
|
|
817
|
+
if (m(n.claim_tx, "depositor_graph.claim_tx"), m(n.assert_tx, "depositor_graph.assert_tx"), m(n.payout_tx, "depositor_graph.payout_tx"), w(n.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(n.challenger_presign_data))
|
|
818
|
+
throw new a(
|
|
819
819
|
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
820
820
|
);
|
|
821
821
|
for (let e = 0; e < n.challenger_presign_data.length; e++)
|
|
822
|
-
|
|
822
|
+
$e(
|
|
823
823
|
n.challenger_presign_data[e],
|
|
824
824
|
`depositor_graph.challenger_presign_data[${e}]`
|
|
825
825
|
);
|
|
826
826
|
if (typeof n.offchain_params_version != "number")
|
|
827
|
-
throw new
|
|
827
|
+
throw new a(
|
|
828
828
|
'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
|
|
829
829
|
);
|
|
830
830
|
}
|
|
831
831
|
const Ee = 6e4;
|
|
832
|
-
class
|
|
832
|
+
class Ie {
|
|
833
833
|
constructor(e, t) {
|
|
834
834
|
l(this, "client");
|
|
835
835
|
const r = {
|
|
@@ -838,9 +838,10 @@ class Qe {
|
|
|
838
838
|
retries: t == null ? void 0 : t.retries,
|
|
839
839
|
retryDelay: t == null ? void 0 : t.retryDelay,
|
|
840
840
|
retryableFor: t == null ? void 0 : t.retryableFor,
|
|
841
|
-
headers: t == null ? void 0 : t.headers
|
|
841
|
+
headers: t == null ? void 0 : t.headers,
|
|
842
|
+
tokenProvider: t == null ? void 0 : t.tokenProvider
|
|
842
843
|
};
|
|
843
|
-
this.client = new
|
|
844
|
+
this.client = new G(r);
|
|
844
845
|
}
|
|
845
846
|
/**
|
|
846
847
|
* Request the payout/claim/assert transactions that the depositor
|
|
@@ -848,7 +849,7 @@ class Qe {
|
|
|
848
849
|
*/
|
|
849
850
|
async requestDepositorPresignTransactions(e, t) {
|
|
850
851
|
const r = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
|
|
851
|
-
return
|
|
852
|
+
return xe(r), r;
|
|
852
853
|
}
|
|
853
854
|
/**
|
|
854
855
|
* Submit the depositor's pre-signatures for the payout transactions
|
|
@@ -879,7 +880,7 @@ class Qe {
|
|
|
879
880
|
*/
|
|
880
881
|
async requestDepositorClaimerArtifacts(e, t) {
|
|
881
882
|
const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
|
|
882
|
-
return
|
|
883
|
+
return ke(r), r;
|
|
883
884
|
}
|
|
884
885
|
/** Get the current pegin status from the vault provider daemon. */
|
|
885
886
|
async getPeginStatus(e, t) {
|
|
@@ -888,7 +889,7 @@ class Qe {
|
|
|
888
889
|
e,
|
|
889
890
|
t
|
|
890
891
|
);
|
|
891
|
-
return
|
|
892
|
+
return Te(r), r;
|
|
892
893
|
}
|
|
893
894
|
/** Get the current pegout status from the vault provider daemon. */
|
|
894
895
|
async getPegoutStatus(e, t) {
|
|
@@ -897,52 +898,52 @@ class Qe {
|
|
|
897
898
|
e,
|
|
898
899
|
t
|
|
899
900
|
);
|
|
900
|
-
return
|
|
901
|
+
return Ce(r), r;
|
|
901
902
|
}
|
|
902
903
|
}
|
|
903
|
-
const
|
|
904
|
-
function
|
|
905
|
-
const t = new TextEncoder().encode(n), r = K(t),
|
|
906
|
-
return
|
|
904
|
+
const Be = "BIP0322-signed-message", Fe = "TapTweak", ne = 32, Oe = 64;
|
|
905
|
+
function re(n, e) {
|
|
906
|
+
const t = new TextEncoder().encode(n), r = K(t), i = new Uint8Array(r.length * 2 + e.length);
|
|
907
|
+
return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2), K(i);
|
|
907
908
|
}
|
|
908
|
-
function
|
|
909
|
-
if (n.length !==
|
|
910
|
-
const e =
|
|
909
|
+
function Re(n) {
|
|
910
|
+
if (n.length !== ne) return null;
|
|
911
|
+
const e = re(Fe, n), t = $.xOnlyPointAddTweak(n, e);
|
|
911
912
|
return t ? t.xOnlyPubkey : null;
|
|
912
913
|
}
|
|
913
|
-
function
|
|
914
|
-
if (e.length !==
|
|
914
|
+
function Ne(n, e, t) {
|
|
915
|
+
if (e.length !== ne || t.length !== Oe) return !1;
|
|
915
916
|
try {
|
|
916
|
-
const r =
|
|
917
|
-
internalPubkey:
|
|
917
|
+
const r = re(Be, n), i = ye.p2tr({
|
|
918
|
+
internalPubkey: y.from(e)
|
|
918
919
|
});
|
|
919
|
-
if (!
|
|
920
|
-
const
|
|
920
|
+
if (!i.output) return !1;
|
|
921
|
+
const s = i.output, c = 0, d = new I();
|
|
921
922
|
d.version = 0, d.locktime = 0;
|
|
922
|
-
const
|
|
923
|
-
|
|
924
|
-
|
|
923
|
+
const S = y.concat([
|
|
924
|
+
y.from([0, 32]),
|
|
925
|
+
y.from(r)
|
|
925
926
|
]);
|
|
926
927
|
d.addInput(
|
|
927
|
-
|
|
928
|
+
y.alloc(32, 0),
|
|
928
929
|
// prev_txid = 0x0000...0000
|
|
929
930
|
4294967295,
|
|
930
931
|
// prev_vout = 0xFFFFFFFF
|
|
931
932
|
0,
|
|
932
933
|
// sequence = 0
|
|
933
|
-
|
|
934
|
-
), d.addOutput(
|
|
935
|
-
const p = new
|
|
934
|
+
S
|
|
935
|
+
), d.addOutput(s, c);
|
|
936
|
+
const p = new I();
|
|
936
937
|
p.version = 0, p.locktime = 0;
|
|
937
|
-
const
|
|
938
|
-
p.addInput(
|
|
939
|
-
const
|
|
938
|
+
const E = d.getHash();
|
|
939
|
+
p.addInput(E, 0, 0), p.addOutput(y.from([106]), c);
|
|
940
|
+
const N = p.hashForWitnessV1(
|
|
940
941
|
0,
|
|
941
|
-
[
|
|
942
|
+
[s],
|
|
942
943
|
[c],
|
|
943
|
-
|
|
944
|
-
),
|
|
945
|
-
return
|
|
944
|
+
I.SIGHASH_DEFAULT
|
|
945
|
+
), H = Re(e);
|
|
946
|
+
return H ? $.verifySchnorr(N, H, t) : !1;
|
|
946
947
|
} catch {
|
|
947
948
|
return !1;
|
|
948
949
|
}
|
|
@@ -953,47 +954,47 @@ function A(n, e) {
|
|
|
953
954
|
if (r < 24n) return new Uint8Array([t | Number(r)]);
|
|
954
955
|
if (r < 0x100n) return new Uint8Array([t | 24, Number(r)]);
|
|
955
956
|
if (r < 0x10000n) {
|
|
956
|
-
const
|
|
957
|
-
return new Uint8Array([t | 25,
|
|
957
|
+
const s = Number(r);
|
|
958
|
+
return new Uint8Array([t | 25, s >>> 8 & 255, s & 255]);
|
|
958
959
|
}
|
|
959
960
|
if (r < 0x100000000n) {
|
|
960
|
-
const
|
|
961
|
+
const s = Number(r);
|
|
961
962
|
return new Uint8Array([
|
|
962
963
|
t | 26,
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
964
|
+
s >>> 24 & 255,
|
|
965
|
+
s >>> 16 & 255,
|
|
966
|
+
s >>> 8 & 255,
|
|
967
|
+
s & 255
|
|
967
968
|
]);
|
|
968
969
|
}
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
for (let
|
|
972
|
-
|
|
973
|
-
return
|
|
970
|
+
const i = new Uint8Array(9);
|
|
971
|
+
i[0] = t | 27;
|
|
972
|
+
for (let s = 7; s >= 0; s--)
|
|
973
|
+
i[1 + s] = Number(r >> BigInt((7 - s) * 8)) & 255;
|
|
974
|
+
return i;
|
|
974
975
|
}
|
|
975
|
-
function
|
|
976
|
-
const e = n.reduce((
|
|
976
|
+
function se(...n) {
|
|
977
|
+
const e = n.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
|
|
977
978
|
let r = 0;
|
|
978
|
-
for (const
|
|
979
|
-
t.set(
|
|
979
|
+
for (const i of n)
|
|
980
|
+
t.set(i, r), r += i.length;
|
|
980
981
|
return t;
|
|
981
982
|
}
|
|
982
|
-
function
|
|
983
|
+
function j(n) {
|
|
983
984
|
const t = [A(4, n.length)];
|
|
984
985
|
for (const r of n)
|
|
985
986
|
t.push(A(0, r));
|
|
986
|
-
return
|
|
987
|
+
return se(...t);
|
|
987
988
|
}
|
|
988
|
-
function
|
|
989
|
+
function He(n, e, t) {
|
|
989
990
|
if (!Number.isSafeInteger(t) || t < 0)
|
|
990
991
|
throw new Error(
|
|
991
992
|
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
|
|
992
993
|
);
|
|
993
|
-
const r = A(4, 3),
|
|
994
|
-
return
|
|
994
|
+
const r = A(4, 3), i = j(n), s = j(e), c = A(0, t);
|
|
995
|
+
return se(r, i, s, c);
|
|
995
996
|
}
|
|
996
|
-
const
|
|
997
|
+
const Ke = new TextEncoder().encode(
|
|
997
998
|
"btc-auth.server-identity.v1"
|
|
998
999
|
);
|
|
999
1000
|
class u extends Error {
|
|
@@ -1001,28 +1002,28 @@ class u extends Error {
|
|
|
1001
1002
|
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
1002
1003
|
}
|
|
1003
1004
|
}
|
|
1004
|
-
function
|
|
1005
|
+
function P(n) {
|
|
1005
1006
|
const e = new Uint8Array(n.length / 2);
|
|
1006
1007
|
for (let t = 0; t < e.length; t++)
|
|
1007
1008
|
e[t] = parseInt(n.slice(t * 2, t * 2 + 2), 16);
|
|
1008
1009
|
return e;
|
|
1009
1010
|
}
|
|
1010
|
-
function
|
|
1011
|
-
const { proof: e, pinnedServerPubkey: t, now: r } = n,
|
|
1012
|
-
if (
|
|
1011
|
+
function Ue(n) {
|
|
1012
|
+
const { proof: e, pinnedServerPubkey: t, now: r } = n, i = _(t).toLowerCase();
|
|
1013
|
+
if (i.length !== v || !f.test(i))
|
|
1013
1014
|
throw new u(
|
|
1014
|
-
`pinnedServerPubkey must be 32-byte hex; got ${
|
|
1015
|
+
`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,
|
|
1015
1016
|
"invalid_pubkey_encoding"
|
|
1016
1017
|
);
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1018
|
+
const s = _(e.server_pubkey).toLowerCase();
|
|
1019
|
+
if (s.length !== v || !f.test(s))
|
|
1019
1020
|
throw new u(
|
|
1020
|
-
`server_pubkey must be 32-byte hex; got ${
|
|
1021
|
+
`server_pubkey must be 32-byte hex; got ${s.length} chars`,
|
|
1021
1022
|
"invalid_pubkey_encoding"
|
|
1022
1023
|
);
|
|
1023
|
-
if (
|
|
1024
|
+
if (s !== i)
|
|
1024
1025
|
throw new u(
|
|
1025
|
-
`server_pubkey does not match pinned value: expected ${
|
|
1026
|
+
`server_pubkey does not match pinned value: expected ${i}, got ${s}`,
|
|
1026
1027
|
"pinned_pubkey_mismatch"
|
|
1027
1028
|
);
|
|
1028
1029
|
if (!Number.isSafeInteger(e.expires_at))
|
|
@@ -1041,7 +1042,7 @@ function Re(n) {
|
|
|
1041
1042
|
"expired"
|
|
1042
1043
|
);
|
|
1043
1044
|
const c = _(e.ephemeral_pubkey).toLowerCase();
|
|
1044
|
-
if (c.length !==
|
|
1045
|
+
if (c.length !== O || !f.test(c))
|
|
1045
1046
|
throw new u(
|
|
1046
1047
|
`ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
|
|
1047
1048
|
"invalid_ephemeral_pubkey"
|
|
@@ -1052,32 +1053,49 @@ function Re(n) {
|
|
|
1052
1053
|
`ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
|
|
1053
1054
|
"invalid_ephemeral_pubkey"
|
|
1054
1055
|
);
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1056
|
+
const S = P(c);
|
|
1057
|
+
if (!$.isPoint(S))
|
|
1057
1058
|
throw new u(
|
|
1058
1059
|
"ephemeral_pubkey is not a valid secp256k1 point",
|
|
1059
1060
|
"invalid_ephemeral_pubkey"
|
|
1060
1061
|
);
|
|
1061
1062
|
const p = _(e.signature).toLowerCase();
|
|
1062
|
-
if (p.length !==
|
|
1063
|
+
if (p.length !== he || !f.test(p))
|
|
1063
1064
|
throw new u(
|
|
1064
1065
|
`signature must be 64-byte Schnorr hex; got ${p.length} chars`,
|
|
1065
1066
|
"invalid_signature_encoding"
|
|
1066
1067
|
);
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
|
|
1068
|
+
const E = He(
|
|
1069
|
+
Ke,
|
|
1070
|
+
P(c),
|
|
1070
1071
|
e.expires_at
|
|
1071
1072
|
);
|
|
1072
|
-
if (!
|
|
1073
|
+
if (!Ne(E, P(s), P(p)))
|
|
1073
1074
|
throw new u(
|
|
1074
1075
|
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
1075
1076
|
"signature_verification_failed"
|
|
1076
1077
|
);
|
|
1077
1078
|
}
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1079
|
+
const De = /* @__PURE__ */ new Set([
|
|
1080
|
+
"vaultProvider_submitDepositorWotsKey",
|
|
1081
|
+
"vaultProvider_submitDepositorPresignatures",
|
|
1082
|
+
"vaultProvider_requestDepositorPresignTransactions"
|
|
1083
|
+
]), je = 6e4, R = "auth_createDepositorToken";
|
|
1084
|
+
function ie(n, e) {
|
|
1085
|
+
return new G({
|
|
1086
|
+
baseUrl: n,
|
|
1087
|
+
timeout: je,
|
|
1088
|
+
headers: e,
|
|
1089
|
+
retryableFor: (t) => t === R
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
const M = 4102444800, Me = 30;
|
|
1093
|
+
class Le {
|
|
1080
1094
|
constructor(e) {
|
|
1095
|
+
// `client` is the only mutable field — see `setClient`. The
|
|
1096
|
+
// identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
|
|
1097
|
+
// remain readonly and are checked against re-registration in the
|
|
1098
|
+
// registry's `getOrCreate`.
|
|
1081
1099
|
l(this, "client");
|
|
1082
1100
|
l(this, "peginTxid");
|
|
1083
1101
|
l(this, "authAnchorHex");
|
|
@@ -1087,7 +1105,7 @@ class Ze {
|
|
|
1087
1105
|
l(this, "now");
|
|
1088
1106
|
l(this, "cached", null);
|
|
1089
1107
|
l(this, "inFlight", null);
|
|
1090
|
-
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ??
|
|
1108
|
+
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Me, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
1091
1109
|
}
|
|
1092
1110
|
/**
|
|
1093
1111
|
* Return a bearer token for `method`, or `null` if `method` is not
|
|
@@ -1102,7 +1120,7 @@ class Ze {
|
|
|
1102
1120
|
* guard. Returning `null` here breaks that recursion deterministically.
|
|
1103
1121
|
*/
|
|
1104
1122
|
async getToken(e) {
|
|
1105
|
-
if (e ===
|
|
1123
|
+
if (e === R || !this.authGatedMethods.has(e)) return null;
|
|
1106
1124
|
const t = this.cached;
|
|
1107
1125
|
return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight()).token;
|
|
1108
1126
|
}
|
|
@@ -1113,16 +1131,27 @@ class Ze {
|
|
|
1113
1131
|
invalidate() {
|
|
1114
1132
|
this.cached = null;
|
|
1115
1133
|
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Swap in a different transport for subsequent token-issuing calls.
|
|
1136
|
+
* Used by the registry when a later caller registers the same
|
|
1137
|
+
* `peginTxid` against a different `baseUrl` — the cached token
|
|
1138
|
+
* (bound to identity, not transport) stays valid, but future
|
|
1139
|
+
* refreshes hit the new URL. An in-flight acquire keeps using the
|
|
1140
|
+
* old client (it captured the reference); next call uses the new.
|
|
1141
|
+
*/
|
|
1142
|
+
setClient(e) {
|
|
1143
|
+
this.client = e;
|
|
1144
|
+
}
|
|
1116
1145
|
acquireSingleFlight() {
|
|
1117
1146
|
const e = this.inFlight;
|
|
1118
1147
|
if (e) return e;
|
|
1119
1148
|
const t = (async () => {
|
|
1120
1149
|
try {
|
|
1121
|
-
const r = await this.client.call(
|
|
1150
|
+
const r = await this.client.call(R, {
|
|
1122
1151
|
pegin_txid: this.peginTxid,
|
|
1123
1152
|
auth_anchor: this.authAnchorHex
|
|
1124
1153
|
});
|
|
1125
|
-
if (
|
|
1154
|
+
if (Ue({
|
|
1126
1155
|
proof: r.server_identity,
|
|
1127
1156
|
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
1128
1157
|
now: this.now()
|
|
@@ -1130,16 +1159,16 @@ class Ze {
|
|
|
1130
1159
|
throw new Error(
|
|
1131
1160
|
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
|
|
1132
1161
|
);
|
|
1133
|
-
const
|
|
1134
|
-
if (!Number.isSafeInteger(r.expires_at) || r.expires_at <=
|
|
1162
|
+
const i = this.now();
|
|
1163
|
+
if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= i || r.expires_at > M)
|
|
1135
1164
|
throw new Error(
|
|
1136
|
-
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${
|
|
1165
|
+
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${i}, ${M}])`
|
|
1137
1166
|
);
|
|
1138
|
-
const
|
|
1167
|
+
const s = {
|
|
1139
1168
|
token: r.token,
|
|
1140
1169
|
expiresAt: r.expires_at
|
|
1141
1170
|
};
|
|
1142
|
-
return this.cached =
|
|
1171
|
+
return this.cached = s, s;
|
|
1143
1172
|
} finally {
|
|
1144
1173
|
this.inFlight = null;
|
|
1145
1174
|
}
|
|
@@ -1147,17 +1176,105 @@ class Ze {
|
|
|
1147
1176
|
return this.inFlight = t, t;
|
|
1148
1177
|
}
|
|
1149
1178
|
}
|
|
1150
|
-
|
|
1179
|
+
class Xe {
|
|
1180
|
+
constructor() {
|
|
1181
|
+
l(this, "entries", /* @__PURE__ */ new Map());
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Return the cached `VpTokenProvider` for `peginTxid` if one exists
|
|
1185
|
+
* with matching `authAnchorHex` and `pinnedServerPubkey`, otherwise
|
|
1186
|
+
* construct and cache a fresh provider. A mismatch on either field
|
|
1187
|
+
* throws — silent overwrite would mask derivation drift or VP
|
|
1188
|
+
* pubkey rotation.
|
|
1189
|
+
*/
|
|
1190
|
+
getOrCreate(e) {
|
|
1191
|
+
const t = this.entries.get(e.peginTxid);
|
|
1192
|
+
if (t) {
|
|
1193
|
+
if (t.authAnchorHex !== e.authAnchorHex)
|
|
1194
|
+
throw new Error(
|
|
1195
|
+
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${t.authAnchorHex.slice(0, 8)}…; got ${e.authAnchorHex.slice(0, 8)}…`
|
|
1196
|
+
);
|
|
1197
|
+
if (t.pinnedServerPubkey !== e.pinnedServerPubkey)
|
|
1198
|
+
throw new Error(
|
|
1199
|
+
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${t.pinnedServerPubkey.slice(0, 8)}…; got ${e.pinnedServerPubkey.slice(0, 8)}…`
|
|
1200
|
+
);
|
|
1201
|
+
return t.provider.setClient(e.client), t.provider;
|
|
1202
|
+
}
|
|
1203
|
+
const r = new Le({
|
|
1204
|
+
client: e.client,
|
|
1205
|
+
peginTxid: e.peginTxid,
|
|
1206
|
+
authAnchorHex: e.authAnchorHex,
|
|
1207
|
+
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
1208
|
+
authGatedMethods: De
|
|
1209
|
+
});
|
|
1210
|
+
return this.entries.set(e.peginTxid, {
|
|
1211
|
+
provider: r,
|
|
1212
|
+
authAnchorHex: e.authAnchorHex,
|
|
1213
|
+
pinnedServerPubkey: e.pinnedServerPubkey
|
|
1214
|
+
}), r;
|
|
1215
|
+
}
|
|
1216
|
+
/** Return the cached provider, or `undefined` if none. */
|
|
1217
|
+
peek(e) {
|
|
1218
|
+
var t;
|
|
1219
|
+
return (t = this.entries.get(e)) == null ? void 0 : t.provider;
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Evict the entry for `peginTxid`. Idempotent. Called on terminal
|
|
1223
|
+
* paths — activation success, user-cancel, or component unmount —
|
|
1224
|
+
* so `authAnchorHex` doesn't outlive the deposit session.
|
|
1225
|
+
*/
|
|
1226
|
+
release(e) {
|
|
1227
|
+
this.entries.delete(e);
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Wipe every cached entry. Test-only escape hatch — not exposed on
|
|
1231
|
+
* the public {@link VpTokenRegistryPublic} singleton type.
|
|
1232
|
+
*
|
|
1233
|
+
* @internal
|
|
1234
|
+
*/
|
|
1235
|
+
clear() {
|
|
1236
|
+
this.entries.clear();
|
|
1237
|
+
}
|
|
1238
|
+
get size() {
|
|
1239
|
+
return this.entries.size;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
const ae = new Xe();
|
|
1243
|
+
function at(n) {
|
|
1244
|
+
var r;
|
|
1245
|
+
const e = ie(
|
|
1246
|
+
n.baseUrl,
|
|
1247
|
+
(r = n.options) == null ? void 0 : r.headers
|
|
1248
|
+
), t = ae.getOrCreate({
|
|
1249
|
+
client: e,
|
|
1250
|
+
peginTxid: n.peginTxid,
|
|
1251
|
+
authAnchorHex: n.authAnchorHex,
|
|
1252
|
+
pinnedServerPubkey: n.pinnedServerPubkey
|
|
1253
|
+
});
|
|
1254
|
+
return new Ie(n.baseUrl, {
|
|
1255
|
+
...n.options,
|
|
1256
|
+
tokenProvider: t
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
function ot(n) {
|
|
1260
|
+
ae.getOrCreate({
|
|
1261
|
+
client: ie(n.baseUrl, n.headers),
|
|
1262
|
+
peginTxid: n.peginTxid,
|
|
1263
|
+
authAnchorHex: n.authAnchorHex,
|
|
1264
|
+
pinnedServerPubkey: n.pinnedServerPubkey
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
async function ct(n, e) {
|
|
1151
1268
|
const [t, r] = await n.multicall({
|
|
1152
1269
|
contracts: [
|
|
1153
1270
|
{
|
|
1154
1271
|
address: e,
|
|
1155
|
-
abi:
|
|
1272
|
+
abi: b,
|
|
1156
1273
|
functionName: "protocolParams"
|
|
1157
1274
|
},
|
|
1158
1275
|
{
|
|
1159
1276
|
address: e,
|
|
1160
|
-
abi:
|
|
1277
|
+
abi: b,
|
|
1161
1278
|
functionName: "applicationRegistry"
|
|
1162
1279
|
}
|
|
1163
1280
|
],
|
|
@@ -1169,7 +1286,7 @@ async function et(n, e) {
|
|
|
1169
1286
|
};
|
|
1170
1287
|
}
|
|
1171
1288
|
const L = 65535;
|
|
1172
|
-
function
|
|
1289
|
+
function F(n) {
|
|
1173
1290
|
return {
|
|
1174
1291
|
timelockAssert: n.timelockAssert,
|
|
1175
1292
|
timelockChallengeAssert: n.timelockChallengeAssert,
|
|
@@ -1202,14 +1319,14 @@ function q(n) {
|
|
|
1202
1319
|
);
|
|
1203
1320
|
return Number(n);
|
|
1204
1321
|
}
|
|
1205
|
-
class
|
|
1322
|
+
class lt {
|
|
1206
1323
|
constructor(e, t) {
|
|
1207
1324
|
this.publicClient = e, this.contractAddress = t;
|
|
1208
1325
|
}
|
|
1209
1326
|
async getTBVProtocolParams() {
|
|
1210
1327
|
const e = await this.publicClient.readContract({
|
|
1211
1328
|
address: this.contractAddress,
|
|
1212
|
-
abi:
|
|
1329
|
+
abi: h,
|
|
1213
1330
|
functionName: "getTBVProtocolParams"
|
|
1214
1331
|
});
|
|
1215
1332
|
return X(e);
|
|
@@ -1217,24 +1334,24 @@ class tt {
|
|
|
1217
1334
|
async getLatestOffchainParams() {
|
|
1218
1335
|
const e = await this.publicClient.readContract({
|
|
1219
1336
|
address: this.contractAddress,
|
|
1220
|
-
abi:
|
|
1337
|
+
abi: h,
|
|
1221
1338
|
functionName: "getLatestOffchainParams"
|
|
1222
1339
|
});
|
|
1223
|
-
return
|
|
1340
|
+
return F(e);
|
|
1224
1341
|
}
|
|
1225
1342
|
async getOffchainParamsByVersion(e) {
|
|
1226
1343
|
const t = await this.publicClient.readContract({
|
|
1227
1344
|
address: this.contractAddress,
|
|
1228
|
-
abi:
|
|
1345
|
+
abi: h,
|
|
1229
1346
|
functionName: "getOffchainParamsByVersion",
|
|
1230
1347
|
args: [e]
|
|
1231
1348
|
});
|
|
1232
|
-
return
|
|
1349
|
+
return F(t);
|
|
1233
1350
|
}
|
|
1234
1351
|
async getLatestOffchainParamsVersion() {
|
|
1235
1352
|
return await this.publicClient.readContract({
|
|
1236
1353
|
address: this.contractAddress,
|
|
1237
|
-
abi:
|
|
1354
|
+
abi: h,
|
|
1238
1355
|
functionName: "latestOffchainParamsVersion"
|
|
1239
1356
|
});
|
|
1240
1357
|
}
|
|
@@ -1251,17 +1368,17 @@ class tt {
|
|
|
1251
1368
|
contracts: [
|
|
1252
1369
|
{
|
|
1253
1370
|
address: this.contractAddress,
|
|
1254
|
-
abi:
|
|
1371
|
+
abi: h,
|
|
1255
1372
|
functionName: "getTBVProtocolParams"
|
|
1256
1373
|
},
|
|
1257
1374
|
{
|
|
1258
1375
|
address: this.contractAddress,
|
|
1259
|
-
abi:
|
|
1376
|
+
abi: h,
|
|
1260
1377
|
functionName: "getLatestOffchainParams"
|
|
1261
1378
|
}
|
|
1262
1379
|
],
|
|
1263
1380
|
allowFailure: !1
|
|
1264
|
-
}), t = X(e[0]), r =
|
|
1381
|
+
}), t = X(e[0]), r = F(e[1]);
|
|
1265
1382
|
return {
|
|
1266
1383
|
minimumPegInAmount: t.minimumPegInAmount,
|
|
1267
1384
|
maxPegInAmount: t.maxPegInAmount,
|
|
@@ -1281,14 +1398,14 @@ function V(n) {
|
|
|
1281
1398
|
btcPubKey: e.btcPubKey
|
|
1282
1399
|
}));
|
|
1283
1400
|
}
|
|
1284
|
-
class
|
|
1401
|
+
class ut {
|
|
1285
1402
|
constructor(e, t) {
|
|
1286
1403
|
this.publicClient = e, this.contractAddress = t;
|
|
1287
1404
|
}
|
|
1288
1405
|
async getVaultKeepersByVersion(e, t) {
|
|
1289
1406
|
const r = await this.publicClient.readContract({
|
|
1290
1407
|
address: this.contractAddress,
|
|
1291
|
-
abi:
|
|
1408
|
+
abi: B,
|
|
1292
1409
|
functionName: "getVaultKeepersByVersion",
|
|
1293
1410
|
args: [e, t]
|
|
1294
1411
|
});
|
|
@@ -1297,7 +1414,7 @@ class nt {
|
|
|
1297
1414
|
async getCurrentVaultKeepers(e) {
|
|
1298
1415
|
const t = await this.publicClient.readContract({
|
|
1299
1416
|
address: this.contractAddress,
|
|
1300
|
-
abi:
|
|
1417
|
+
abi: B,
|
|
1301
1418
|
functionName: "getCurrentVaultKeepers",
|
|
1302
1419
|
args: [e]
|
|
1303
1420
|
});
|
|
@@ -1306,20 +1423,20 @@ class nt {
|
|
|
1306
1423
|
async getCurrentVaultKeepersVersion(e) {
|
|
1307
1424
|
return await this.publicClient.readContract({
|
|
1308
1425
|
address: this.contractAddress,
|
|
1309
|
-
abi:
|
|
1426
|
+
abi: B,
|
|
1310
1427
|
functionName: "getCurrentVaultKeepersVersion",
|
|
1311
1428
|
args: [e]
|
|
1312
1429
|
});
|
|
1313
1430
|
}
|
|
1314
1431
|
}
|
|
1315
|
-
class
|
|
1432
|
+
class pt {
|
|
1316
1433
|
constructor(e, t) {
|
|
1317
1434
|
this.publicClient = e, this.contractAddress = t;
|
|
1318
1435
|
}
|
|
1319
1436
|
async getUniversalChallengersByVersion(e) {
|
|
1320
1437
|
const t = await this.publicClient.readContract({
|
|
1321
1438
|
address: this.contractAddress,
|
|
1322
|
-
abi:
|
|
1439
|
+
abi: h,
|
|
1323
1440
|
functionName: "getUniversalChallengersByVersion",
|
|
1324
1441
|
args: [e]
|
|
1325
1442
|
});
|
|
@@ -1328,7 +1445,7 @@ class rt {
|
|
|
1328
1445
|
async getCurrentUniversalChallengers() {
|
|
1329
1446
|
const e = await this.publicClient.readContract({
|
|
1330
1447
|
address: this.contractAddress,
|
|
1331
|
-
abi:
|
|
1448
|
+
abi: h,
|
|
1332
1449
|
functionName: "getCurrentUniversalChallengers"
|
|
1333
1450
|
});
|
|
1334
1451
|
return V(e);
|
|
@@ -1336,19 +1453,43 @@ class rt {
|
|
|
1336
1453
|
async getLatestUniversalChallengersVersion() {
|
|
1337
1454
|
return await this.publicClient.readContract({
|
|
1338
1455
|
address: this.contractAddress,
|
|
1339
|
-
abi:
|
|
1456
|
+
abi: h,
|
|
1340
1457
|
functionName: "latestUniversalChallengersVersion"
|
|
1341
1458
|
});
|
|
1342
1459
|
}
|
|
1343
1460
|
}
|
|
1344
|
-
class
|
|
1461
|
+
class dt {
|
|
1345
1462
|
constructor(e, t) {
|
|
1346
1463
|
this.publicClient = e, this.contractAddress = t;
|
|
1347
1464
|
}
|
|
1465
|
+
/**
|
|
1466
|
+
* Read the VP's persistent x-only BTC pubkey from the on-chain
|
|
1467
|
+
* registry. Validates length, hex form, and secp256k1 curve
|
|
1468
|
+
* membership before minting the brand. Returns 64-char lowercase
|
|
1469
|
+
* hex without the `0x` prefix.
|
|
1470
|
+
*/
|
|
1471
|
+
async getVaultProviderBtcPubKey(e) {
|
|
1472
|
+
const r = (await this.publicClient.readContract({
|
|
1473
|
+
address: this.contractAddress,
|
|
1474
|
+
abi: b,
|
|
1475
|
+
functionName: "getVaultProviderBTCKey",
|
|
1476
|
+
args: [e]
|
|
1477
|
+
})).toLowerCase();
|
|
1478
|
+
if (!/^0x[0-9a-f]{64}$/.test(r))
|
|
1479
|
+
throw new Error(
|
|
1480
|
+
`getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0, 2)}")`
|
|
1481
|
+
);
|
|
1482
|
+
const i = r.slice(2);
|
|
1483
|
+
if (!$.isXOnlyPoint(me(i)))
|
|
1484
|
+
throw new Error(
|
|
1485
|
+
`getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`
|
|
1486
|
+
);
|
|
1487
|
+
return i;
|
|
1488
|
+
}
|
|
1348
1489
|
async getVaultBasicInfo(e) {
|
|
1349
1490
|
const t = await this.publicClient.readContract({
|
|
1350
1491
|
address: this.contractAddress,
|
|
1351
|
-
abi:
|
|
1492
|
+
abi: b,
|
|
1352
1493
|
functionName: "getBtcVaultBasicInfo",
|
|
1353
1494
|
args: [e]
|
|
1354
1495
|
});
|
|
@@ -1365,7 +1506,7 @@ class at {
|
|
|
1365
1506
|
async getVaultProtocolInfo(e) {
|
|
1366
1507
|
const t = await this.publicClient.readContract({
|
|
1367
1508
|
address: this.contractAddress,
|
|
1368
|
-
abi:
|
|
1509
|
+
abi: b,
|
|
1369
1510
|
functionName: "getBtcVaultProtocolInfo",
|
|
1370
1511
|
args: [e]
|
|
1371
1512
|
});
|
|
@@ -1396,27 +1537,30 @@ class at {
|
|
|
1396
1537
|
}
|
|
1397
1538
|
}
|
|
1398
1539
|
export {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1540
|
+
B as A,
|
|
1541
|
+
be as M,
|
|
1542
|
+
h as P,
|
|
1402
1543
|
u as S,
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1544
|
+
Ie as V,
|
|
1545
|
+
nt as a,
|
|
1546
|
+
rt as b,
|
|
1547
|
+
it as c,
|
|
1548
|
+
et as d,
|
|
1549
|
+
we as e,
|
|
1550
|
+
tt as f,
|
|
1551
|
+
st as g,
|
|
1552
|
+
a as h,
|
|
1553
|
+
Ue as i,
|
|
1554
|
+
Xe as j,
|
|
1555
|
+
ae as k,
|
|
1556
|
+
at as l,
|
|
1557
|
+
ot as m,
|
|
1558
|
+
lt as n,
|
|
1559
|
+
pt as o,
|
|
1560
|
+
Ze as p,
|
|
1561
|
+
ut as q,
|
|
1562
|
+
ct as r,
|
|
1563
|
+
dt as s,
|
|
1564
|
+
ke as v
|
|
1421
1565
|
};
|
|
1422
|
-
//# sourceMappingURL=vault-registry-reader-
|
|
1566
|
+
//# sourceMappingURL=vault-registry-reader-BeIEh62N.js.map
|