@babylonlabs-io/ts-sdk 0.33.3 → 0.33.5
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/BTCVaultRegistry.abi-DbJ5lsFJ.js +417 -0
- package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js.map +1 -0
- package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs +2 -0
- package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs.map +1 -0
- package/dist/PayoutManager-C9XHKZ5j.js +200 -0
- package/dist/PayoutManager-C9XHKZ5j.js.map +1 -0
- package/dist/PayoutManager-DDnNB0mj.cjs +2 -0
- package/dist/PayoutManager-DDnNB0mj.cjs.map +1 -0
- package/dist/PeginManager-BXg2S1mH.cjs +2 -0
- package/dist/PeginManager-BXg2S1mH.cjs.map +1 -0
- package/dist/{PeginManager-C-L3huRO.js → PeginManager-C5HaMAcw.js} +328 -437
- package/dist/PeginManager-C5HaMAcw.js.map +1 -0
- package/dist/ProtocolParams.abi-BmvHwQJV.cjs +2 -0
- package/dist/ProtocolParams.abi-BmvHwQJV.cjs.map +1 -0
- package/dist/ProtocolParams.abi-DXu8L0Fn.js +382 -0
- package/dist/ProtocolParams.abi-DXu8L0Fn.js.map +1 -0
- package/dist/buildAndBroadcastRefund-B332dykQ.cjs +2 -0
- package/dist/buildAndBroadcastRefund-B332dykQ.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-CPjXNaMi.js +782 -0
- package/dist/buildAndBroadcastRefund-CPjXNaMi.js.map +1 -0
- package/dist/challengeAssert-BzxQmdZy.js +128 -0
- package/dist/challengeAssert-BzxQmdZy.js.map +1 -0
- package/dist/challengeAssert-Yyyj-EdR.cjs +2 -0
- package/dist/challengeAssert-Yyyj-EdR.cjs.map +1 -0
- package/dist/errors-9AkghWyk.js +22 -0
- package/dist/errors-9AkghWyk.js.map +1 -0
- package/dist/errors-BP73_stm.cjs +2 -0
- package/dist/errors-BP73_stm.cjs.map +1 -0
- package/dist/errors-Bu0H-dZD.cjs +2 -0
- package/dist/errors-Bu0H-dZD.cjs.map +1 -0
- package/dist/errors-CznAK5NB.js +96 -0
- package/dist/errors-CznAK5NB.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +159 -147
- package/dist/index.js.map +1 -1
- package/dist/mempoolApi-CAIge7Nj.js +205 -0
- package/dist/mempoolApi-CAIge7Nj.js.map +1 -0
- package/dist/mempoolApi-YNkKjQCU.cjs +2 -0
- package/dist/mempoolApi-YNkKjQCU.cjs.map +1 -0
- package/dist/noPayout-BXeUw0Qq.cjs +2 -0
- package/dist/noPayout-BXeUw0Qq.cjs.map +1 -0
- package/dist/noPayout-DBX6G96_.js +141 -0
- package/dist/noPayout-DBX6G96_.js.map +1 -0
- package/dist/payout-BNFMBXS6.js +193 -0
- package/dist/payout-BNFMBXS6.js.map +1 -0
- package/dist/payout-DQ_fmJUA.cjs +2 -0
- package/dist/payout-DQ_fmJUA.cjs.map +1 -0
- package/dist/peginInput-C2QPvuhR.js +177 -0
- package/dist/peginInput-C2QPvuhR.js.map +1 -0
- package/dist/peginInput-tbw9BpZy.cjs +2 -0
- package/dist/peginInput-tbw9BpZy.cjs.map +1 -0
- package/dist/peginState-BijNNT15.cjs +2 -0
- package/dist/peginState-BijNNT15.cjs.map +1 -0
- package/dist/peginState-CBAlxgXk.js +51 -0
- package/dist/peginState-CBAlxgXk.js.map +1 -0
- package/dist/psbtInputFields-2224j2ZY.js +128 -0
- package/dist/psbtInputFields-2224j2ZY.js.map +1 -0
- package/dist/psbtInputFields-B1lrwYzH.cjs +2 -0
- package/dist/psbtInputFields-B1lrwYzH.cjs.map +1 -0
- package/dist/reservation-CHUGW0F_.js +142 -0
- package/dist/reservation-CHUGW0F_.js.map +1 -0
- package/dist/reservation-ho7mjW3X.cjs +2 -0
- package/dist/reservation-ho7mjW3X.cjs.map +1 -0
- package/dist/signing-Bnsro0hE.cjs +2 -0
- package/dist/signing-Bnsro0hE.cjs.map +1 -0
- package/dist/signing-DaLvGwQe.js +16 -0
- package/dist/signing-DaLvGwQe.js.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +35 -32
- package/dist/tbv/core/clients/index.js.map +1 -1
- package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/api.d.ts +13 -4
- package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts +45 -0
- package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts +55 -0
- package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/index.d.ts +2 -0
- 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 +3 -3
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/types.d.ts +68 -24
- package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/validators.d.ts +12 -2
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
- package/dist/tbv/core/contracts/index.cjs +2 -0
- package/dist/tbv/core/contracts/index.cjs.map +1 -0
- package/dist/tbv/core/contracts/index.js +14 -0
- package/dist/tbv/core/contracts/index.js.map +1 -0
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +157 -145
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/index.cjs +2 -0
- package/dist/tbv/core/managers/index.cjs.map +1 -0
- package/dist/tbv/core/managers/index.js +7 -0
- package/dist/tbv/core/managers/index.js.map +1 -0
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.js +31 -29
- package/dist/tbv/core/primitives/index.js.map +1 -1
- package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +28 -27
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/services/pegout/state.d.ts +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +21 -20
- package/dist/tbv/core/utils/index.js.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +157 -145
- package/dist/tbv/index.js.map +1 -1
- package/dist/types-DnyyBNcC.cjs +2 -0
- package/dist/types-DnyyBNcC.cjs.map +1 -0
- package/dist/types-TiIjyo2b.js +320 -0
- package/dist/types-TiIjyo2b.js.map +1 -0
- package/dist/vault-registry-reader-BDFpXeH7.js +1152 -0
- package/dist/vault-registry-reader-BDFpXeH7.js.map +1 -0
- package/dist/vault-registry-reader-ejm2UYzk.cjs +2 -0
- package/dist/vault-registry-reader-ejm2UYzk.cjs.map +1 -0
- package/package.json +11 -1
- package/dist/PeginManager-C-L3huRO.js.map +0 -1
- package/dist/PeginManager-DmPmzPHz.cjs +0 -2
- package/dist/PeginManager-DmPmzPHz.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-Dx09Zbla.js +0 -965
- package/dist/buildAndBroadcastRefund-Dx09Zbla.js.map +0 -1
- package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs +0 -2
- package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs.map +0 -1
- package/dist/challengeAssert-D3tHnLWb.js +0 -298
- package/dist/challengeAssert-D3tHnLWb.js.map +0 -1
- package/dist/challengeAssert-Dp9d1bg1.cjs +0 -2
- package/dist/challengeAssert-Dp9d1bg1.cjs.map +0 -1
- package/dist/noPayout-BnsetBKW.js +0 -327
- package/dist/noPayout-BnsetBKW.js.map +0 -1
- package/dist/noPayout-DWaCtpMU.cjs +0 -2
- package/dist/noPayout-DWaCtpMU.cjs.map +0 -1
- package/dist/psbtInputFields-6sRcZqdb.cjs +0 -2
- package/dist/psbtInputFields-6sRcZqdb.cjs.map +0 -1
- package/dist/psbtInputFields-C5QPn1YK.js +0 -264
- package/dist/psbtInputFields-C5QPn1YK.js.map +0 -1
- package/dist/signing-BZigafm0.js +0 -64
- package/dist/signing-BZigafm0.js.map +0 -1
- package/dist/signing-DHSXjhLM.cjs +0 -2
- package/dist/signing-DHSXjhLM.cjs.map +0 -1
- package/dist/types-PthVHz5q.cjs +0 -2
- package/dist/types-PthVHz5q.cjs.map +0 -1
- package/dist/types-SYvSQWnc.js +0 -732
- package/dist/types-SYvSQWnc.js.map +0 -1
- package/dist/vault-registry-reader-CKe9TbX6.cjs +0 -2
- package/dist/vault-registry-reader-CKe9TbX6.cjs.map +0 -1
- package/dist/vault-registry-reader-CWGbw_wZ.js +0 -1567
- package/dist/vault-registry-reader-CWGbw_wZ.js.map +0 -1
|
@@ -0,0 +1,1152 @@
|
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var le = (n, e, t) => e in n ? ce(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var h = (n, e, t) => le(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { D as ue, J as Y, e as de } from "./types-TiIjyo2b.js";
|
|
5
|
+
import { X as B, C as K, s as C, S as pe, h as he } from "./bitcoin-B0S8SHCX.js";
|
|
6
|
+
import { H as k } from "./validation-CxqROCno.js";
|
|
7
|
+
import * as N from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
|
+
import { payments as ge, Transaction as D } from "bitcoinjs-lib";
|
|
9
|
+
import { Buffer as x } from "buffer";
|
|
10
|
+
import { s as G } from "./sha2-6wN58S6R.js";
|
|
11
|
+
import { B as S } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
|
|
12
|
+
import { P as b, A as O } from "./ProtocolParams.abi-DXu8L0Fn.js";
|
|
13
|
+
const F = new Set(Object.values(ue)), fe = 200;
|
|
14
|
+
function c(n) {
|
|
15
|
+
var e;
|
|
16
|
+
return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0, fe)) ?? "undefined";
|
|
17
|
+
}
|
|
18
|
+
const _e = "The vault provider returned an unexpected response. Please try again or contact support.";
|
|
19
|
+
class s extends Error {
|
|
20
|
+
constructor(t) {
|
|
21
|
+
super(_e);
|
|
22
|
+
h(this, "detail");
|
|
23
|
+
this.name = "VpResponseValidationError", this.detail = t;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const V = 64;
|
|
27
|
+
function P(n) {
|
|
28
|
+
return typeof n == "string" && n.length > 0 && k.test(n);
|
|
29
|
+
}
|
|
30
|
+
function Z(n) {
|
|
31
|
+
return typeof n == "string" && n.length > 0;
|
|
32
|
+
}
|
|
33
|
+
function Q(n, e) {
|
|
34
|
+
if (!P(n))
|
|
35
|
+
throw new s(
|
|
36
|
+
`VP response validation failed: "${e}" must be a non-empty hex string, got ${c(n)}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function g(n, e) {
|
|
40
|
+
if (!Z(n))
|
|
41
|
+
throw new s(
|
|
42
|
+
`VP response validation failed: "${e}" must be a non-empty string, got ${c(n)}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function ee(n, e) {
|
|
46
|
+
if (!P(n) || n.length !== B && n.length !== K)
|
|
47
|
+
throw new s(
|
|
48
|
+
`VP response validation failed: "${e}" must be a ${B} or ${K}-char hex string (BTC pubkey), got ${c(n)}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function me(n) {
|
|
52
|
+
const e = n.presigning;
|
|
53
|
+
if (e == null) return;
|
|
54
|
+
if (typeof e != "object" || Array.isArray(e))
|
|
55
|
+
throw new s(
|
|
56
|
+
'VP response validation failed: "progress.presigning" must be an object if present'
|
|
57
|
+
);
|
|
58
|
+
const t = e;
|
|
59
|
+
if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
|
|
60
|
+
throw new s(
|
|
61
|
+
`VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${c(t.depositor_graph_created)}`
|
|
62
|
+
);
|
|
63
|
+
if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
|
|
64
|
+
throw new s(
|
|
65
|
+
`VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${c(t.vk_challenger_presigning_completed)}`
|
|
66
|
+
);
|
|
67
|
+
if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
|
|
68
|
+
throw new s(
|
|
69
|
+
`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${c(t.vk_challenger_presigning_total)}`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
function te(n) {
|
|
73
|
+
if (n === null || typeof n != "object")
|
|
74
|
+
throw new s(
|
|
75
|
+
"VP response validation failed: getPeginStatus response is not an object"
|
|
76
|
+
);
|
|
77
|
+
const e = n;
|
|
78
|
+
if (!P(e.pegin_txid) || e.pegin_txid.length !== V)
|
|
79
|
+
throw new s(
|
|
80
|
+
`VP response validation failed: "pegin_txid" must be a ${V}-char hex string (txid), got ${c(e.pegin_txid)}`
|
|
81
|
+
);
|
|
82
|
+
if (typeof e.status != "string")
|
|
83
|
+
throw new s(
|
|
84
|
+
'VP response validation failed: "status" must be a string'
|
|
85
|
+
);
|
|
86
|
+
if (!F.has(e.status))
|
|
87
|
+
throw new s(
|
|
88
|
+
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...F].join(", ")}`
|
|
89
|
+
);
|
|
90
|
+
if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
|
|
91
|
+
throw new s(
|
|
92
|
+
'VP response validation failed: "progress" must be an object'
|
|
93
|
+
);
|
|
94
|
+
if (me(e.progress), typeof e.health_info != "string")
|
|
95
|
+
throw new s(
|
|
96
|
+
'VP response validation failed: "health_info" must be a string'
|
|
97
|
+
);
|
|
98
|
+
if (e.last_error !== void 0 && typeof e.last_error != "string")
|
|
99
|
+
throw new s(
|
|
100
|
+
`VP response validation failed: "last_error" must be a string if present, got ${c(e.last_error)}`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function be(n) {
|
|
104
|
+
if (n === null || typeof n != "object")
|
|
105
|
+
throw new s(
|
|
106
|
+
"VP response validation failed: requestDepositorPresignTransactions response is not an object"
|
|
107
|
+
);
|
|
108
|
+
const e = n;
|
|
109
|
+
if (!Array.isArray(e.txs))
|
|
110
|
+
throw new s(
|
|
111
|
+
'VP response validation failed: "txs" must be an array'
|
|
112
|
+
);
|
|
113
|
+
for (let t = 0; t < e.txs.length; t++)
|
|
114
|
+
ye(e.txs[t], `txs[${t}]`);
|
|
115
|
+
if (e.depositor_graph === null || typeof e.depositor_graph != "object")
|
|
116
|
+
throw new s(
|
|
117
|
+
'VP response validation failed: "depositor_graph" must be an object'
|
|
118
|
+
);
|
|
119
|
+
$e(
|
|
120
|
+
e.depositor_graph
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
function y(n, e) {
|
|
124
|
+
if (n === null || typeof n != "object")
|
|
125
|
+
throw new s(
|
|
126
|
+
`VP response validation failed: "${e}" must be an object`
|
|
127
|
+
);
|
|
128
|
+
Q(n.tx_hex, `${e}.tx_hex`);
|
|
129
|
+
}
|
|
130
|
+
function ye(n, e) {
|
|
131
|
+
if (n === null || typeof n != "object")
|
|
132
|
+
throw new s(
|
|
133
|
+
`VP response validation failed: "${e}" must be an object`
|
|
134
|
+
);
|
|
135
|
+
const t = n;
|
|
136
|
+
ee(t.claimer_pubkey, `${e}.claimer_pubkey`), y(t.claim_tx, `${e}.claim_tx`), y(t.assert_tx, `${e}.assert_tx`), y(t.payout_tx, `${e}.payout_tx`), g(t.payout_psbt, `${e}.payout_psbt`);
|
|
137
|
+
}
|
|
138
|
+
function we(n, e) {
|
|
139
|
+
if (n === null || typeof n != "object")
|
|
140
|
+
throw new s(
|
|
141
|
+
`VP response validation failed: "${e}" must be an object`
|
|
142
|
+
);
|
|
143
|
+
const t = n;
|
|
144
|
+
g(t.wots_pks_json, `${e}.wots_pks_json`), g(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
|
|
145
|
+
}
|
|
146
|
+
function Pe(n, e) {
|
|
147
|
+
if (n === null || typeof n != "object")
|
|
148
|
+
throw new s(
|
|
149
|
+
`VP response validation failed: "${e}" must be an object`
|
|
150
|
+
);
|
|
151
|
+
const t = n;
|
|
152
|
+
if (ee(t.challenger_pubkey, `${e}.challenger_pubkey`), y(
|
|
153
|
+
t.challenge_assert_x_tx,
|
|
154
|
+
`${e}.challenge_assert_x_tx`
|
|
155
|
+
), y(
|
|
156
|
+
t.challenge_assert_y_tx,
|
|
157
|
+
`${e}.challenge_assert_y_tx`
|
|
158
|
+
), y(t.nopayout_tx, `${e}.nopayout_tx`), g(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
|
|
159
|
+
throw new s(
|
|
160
|
+
`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
|
|
161
|
+
);
|
|
162
|
+
for (let r = 0; r < t.challenge_assert_connectors.length; r++)
|
|
163
|
+
we(
|
|
164
|
+
t.challenge_assert_connectors[r],
|
|
165
|
+
`${e}.challenge_assert_connectors[${r}]`
|
|
166
|
+
);
|
|
167
|
+
if (!Array.isArray(t.output_label_hashes))
|
|
168
|
+
throw new s(
|
|
169
|
+
`VP response validation failed: "${e}.output_label_hashes" must be an array`
|
|
170
|
+
);
|
|
171
|
+
for (let r = 0; r < t.output_label_hashes.length; r++)
|
|
172
|
+
Q(
|
|
173
|
+
t.output_label_hashes[r],
|
|
174
|
+
`${e}.output_label_hashes[${r}]`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
function ve(n) {
|
|
178
|
+
if (n === null || typeof n != "object")
|
|
179
|
+
throw new s(
|
|
180
|
+
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
181
|
+
);
|
|
182
|
+
const e = n;
|
|
183
|
+
if (!Z(e.tx_graph_json))
|
|
184
|
+
throw new s(
|
|
185
|
+
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${c(e.tx_graph_json)}`
|
|
186
|
+
);
|
|
187
|
+
if (!P(e.verifying_key_hex))
|
|
188
|
+
throw new s(
|
|
189
|
+
`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${c(e.verifying_key_hex)}`
|
|
190
|
+
);
|
|
191
|
+
if (e.babe_sessions === null || typeof e.babe_sessions != "object")
|
|
192
|
+
throw new s(
|
|
193
|
+
'VP response validation failed: "babe_sessions" must be an object'
|
|
194
|
+
);
|
|
195
|
+
for (const [t, r] of Object.entries(
|
|
196
|
+
e.babe_sessions
|
|
197
|
+
)) {
|
|
198
|
+
if (r === null || typeof r != "object")
|
|
199
|
+
throw new s(
|
|
200
|
+
`VP response validation failed: "babe_sessions.${t}" must be an object`
|
|
201
|
+
);
|
|
202
|
+
const i = r;
|
|
203
|
+
if (!P(i.decryptor_artifacts_hex))
|
|
204
|
+
throw new s(
|
|
205
|
+
`VP response validation failed: "babe_sessions.${t}.decryptor_artifacts_hex" must be a non-empty hex string, got ${c(i.decryptor_artifacts_hex)}`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function xe(n) {
|
|
210
|
+
if (n === null || typeof n != "object")
|
|
211
|
+
throw new s(
|
|
212
|
+
"VP response validation failed: pegout status payload is not an object"
|
|
213
|
+
);
|
|
214
|
+
const e = n;
|
|
215
|
+
if (!P(e.pegin_txid) || e.pegin_txid.length !== V)
|
|
216
|
+
throw new s(
|
|
217
|
+
`VP response validation failed: "pegin_txid" must be a ${V}-char hex string (txid), got ${c(e.pegin_txid)}`
|
|
218
|
+
);
|
|
219
|
+
if (typeof e.found != "boolean")
|
|
220
|
+
throw new s(
|
|
221
|
+
`VP response validation failed: "found" must be a boolean, got ${c(e.found)}`
|
|
222
|
+
);
|
|
223
|
+
if (e.claimer !== null) {
|
|
224
|
+
if (typeof e.claimer != "object")
|
|
225
|
+
throw new s(
|
|
226
|
+
`VP response validation failed: "claimer" must be an object or null, got ${c(e.claimer)}`
|
|
227
|
+
);
|
|
228
|
+
Ve(e.claimer);
|
|
229
|
+
}
|
|
230
|
+
if (!Array.isArray(e.challengers))
|
|
231
|
+
throw new s(
|
|
232
|
+
`VP response validation failed: "challengers" must be an array, got ${c(e.challengers)}`
|
|
233
|
+
);
|
|
234
|
+
for (let t = 0; t < e.challengers.length; t++)
|
|
235
|
+
Ae(e.challengers[t], t);
|
|
236
|
+
}
|
|
237
|
+
function Ve(n) {
|
|
238
|
+
if (g(n.status, "claimer.status"), typeof n.failed != "boolean")
|
|
239
|
+
throw new s(
|
|
240
|
+
`VP response validation failed: "claimer.failed" must be a boolean, got ${c(n.failed)}`
|
|
241
|
+
);
|
|
242
|
+
if (g(n.claim_txid, "claimer.claim_txid"), g(n.claimer_pubkey, "claimer.claimer_pubkey"), g(n.assert_txid, "claimer.assert_txid"), n.challenger_pubkey !== null && typeof n.challenger_pubkey != "string")
|
|
243
|
+
throw new s(
|
|
244
|
+
`VP response validation failed: "claimer.challenger_pubkey" must be a string or null, got ${c(n.challenger_pubkey)}`
|
|
245
|
+
);
|
|
246
|
+
if (typeof n.created_at != "number")
|
|
247
|
+
throw new s(
|
|
248
|
+
`VP response validation failed: "claimer.created_at" must be a number, got ${c(n.created_at)}`
|
|
249
|
+
);
|
|
250
|
+
if (typeof n.updated_at != "number")
|
|
251
|
+
throw new s(
|
|
252
|
+
`VP response validation failed: "claimer.updated_at" must be a number, got ${c(n.updated_at)}`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
function Ae(n, e) {
|
|
256
|
+
if (n === null || typeof n != "object")
|
|
257
|
+
throw new s(
|
|
258
|
+
`VP response validation failed: "challengers[${e}]" must be an object, got ${c(n)}`
|
|
259
|
+
);
|
|
260
|
+
const t = n;
|
|
261
|
+
if (g(t.status, `challengers[${e}].status`), g(t.claim_txid, `challengers[${e}].claim_txid`), g(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), E(t.assert_txid, `challengers[${e}].assert_txid`), E(
|
|
262
|
+
t.challenge_assert_x_txid,
|
|
263
|
+
`challengers[${e}].challenge_assert_x_txid`
|
|
264
|
+
), E(
|
|
265
|
+
t.challenge_assert_y_txid,
|
|
266
|
+
`challengers[${e}].challenge_assert_y_txid`
|
|
267
|
+
), E(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
|
|
268
|
+
throw new s(
|
|
269
|
+
`VP response validation failed: "challengers[${e}].created_at" must be a number, got ${c(t.created_at)}`
|
|
270
|
+
);
|
|
271
|
+
if (typeof t.updated_at != "number")
|
|
272
|
+
throw new s(
|
|
273
|
+
`VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${c(t.updated_at)}`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
function E(n, e) {
|
|
277
|
+
if (n !== null && typeof n != "string")
|
|
278
|
+
throw new s(
|
|
279
|
+
`VP response validation failed: "${e}" must be a string or null, got ${c(n)}`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
function ke(n) {
|
|
283
|
+
ne(n, "batchGetPeginStatus", (e) => {
|
|
284
|
+
e.result !== null && te(e.result);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function Se(n) {
|
|
288
|
+
ne(n, "batchGetPegoutStatus", (e) => {
|
|
289
|
+
e.result !== null && xe(e.result);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function ne(n, e, t) {
|
|
293
|
+
if (n === null || typeof n != "object")
|
|
294
|
+
throw new s(
|
|
295
|
+
`VP response validation failed: ${e} response is not an object`
|
|
296
|
+
);
|
|
297
|
+
const r = n;
|
|
298
|
+
if (!Array.isArray(r.results))
|
|
299
|
+
throw new s(
|
|
300
|
+
`VP response validation failed: "${e}.results" must be an array, got ${c(r.results)}`
|
|
301
|
+
);
|
|
302
|
+
for (let i = 0; i < r.results.length; i++) {
|
|
303
|
+
const a = r.results[i];
|
|
304
|
+
if (a === null || typeof a != "object")
|
|
305
|
+
throw new s(
|
|
306
|
+
`VP response validation failed: "${e}.results[${i}]" must be an object, got ${c(a)}`
|
|
307
|
+
);
|
|
308
|
+
const o = a;
|
|
309
|
+
if (!P(o.pegin_txid) || o.pegin_txid.length !== V)
|
|
310
|
+
throw new s(
|
|
311
|
+
`VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${V}-char hex string, got ${c(o.pegin_txid)}`
|
|
312
|
+
);
|
|
313
|
+
if (o.error !== null && typeof o.error != "string")
|
|
314
|
+
throw new s(
|
|
315
|
+
`VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${c(o.error)}`
|
|
316
|
+
);
|
|
317
|
+
if (o.result === null && o.error === null)
|
|
318
|
+
throw new s(
|
|
319
|
+
`VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
|
|
320
|
+
);
|
|
321
|
+
if (o.result !== null && o.error !== null)
|
|
322
|
+
throw new s(
|
|
323
|
+
`VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
|
|
324
|
+
);
|
|
325
|
+
t(o, i);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function $e(n) {
|
|
329
|
+
if (y(n.claim_tx, "depositor_graph.claim_tx"), y(n.assert_tx, "depositor_graph.assert_tx"), y(n.payout_tx, "depositor_graph.payout_tx"), g(n.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(n.challenger_presign_data))
|
|
330
|
+
throw new s(
|
|
331
|
+
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
332
|
+
);
|
|
333
|
+
for (let e = 0; e < n.challenger_presign_data.length; e++)
|
|
334
|
+
Pe(
|
|
335
|
+
n.challenger_presign_data[e],
|
|
336
|
+
`depositor_graph.challenger_presign_data[${e}]`
|
|
337
|
+
);
|
|
338
|
+
if (typeof n.offchain_params_version != "number")
|
|
339
|
+
throw new s(
|
|
340
|
+
'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
const Te = 6e4;
|
|
344
|
+
class Ce {
|
|
345
|
+
constructor(e, t) {
|
|
346
|
+
h(this, "client");
|
|
347
|
+
const r = {
|
|
348
|
+
baseUrl: e,
|
|
349
|
+
timeout: (t == null ? void 0 : t.timeout) ?? Te,
|
|
350
|
+
retries: t == null ? void 0 : t.retries,
|
|
351
|
+
retryDelay: t == null ? void 0 : t.retryDelay,
|
|
352
|
+
retryableFor: t == null ? void 0 : t.retryableFor,
|
|
353
|
+
headers: t == null ? void 0 : t.headers,
|
|
354
|
+
tokenProvider: t == null ? void 0 : t.tokenProvider,
|
|
355
|
+
maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
|
|
356
|
+
};
|
|
357
|
+
this.client = new Y(r);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Request the payout/claim/assert transactions that the depositor
|
|
361
|
+
* needs to pre-sign before the vault can be activated on Bitcoin.
|
|
362
|
+
*/
|
|
363
|
+
async requestDepositorPresignTransactions(e, t) {
|
|
364
|
+
const r = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
|
|
365
|
+
return be(r), r;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Submit the depositor's pre-signatures for the payout transactions
|
|
369
|
+
* and the depositor-as-claimer graph.
|
|
370
|
+
*/
|
|
371
|
+
async submitDepositorPresignatures(e, t) {
|
|
372
|
+
return this.client.call(
|
|
373
|
+
"vaultProvider_submitDepositorPresignatures",
|
|
374
|
+
e,
|
|
375
|
+
t
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Submit the depositor's WOTS public key to the vault provider.
|
|
380
|
+
* Called after the pegin is finalized on Ethereum, when the VP is in
|
|
381
|
+
* `PendingDepositorWotsPK` status.
|
|
382
|
+
*/
|
|
383
|
+
async submitDepositorWotsKey(e, t) {
|
|
384
|
+
return this.client.call(
|
|
385
|
+
"vaultProvider_submitDepositorWotsKey",
|
|
386
|
+
e,
|
|
387
|
+
t
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Request the BaBe DecryptorArtifacts needed for the depositor to
|
|
392
|
+
* independently evaluate garbled circuits during a challenge.
|
|
393
|
+
*/
|
|
394
|
+
async requestDepositorClaimerArtifacts(e, t) {
|
|
395
|
+
const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
|
|
396
|
+
return ve(r), r;
|
|
397
|
+
}
|
|
398
|
+
/** Get the current pegin status from the vault provider daemon. */
|
|
399
|
+
async getPeginStatus(e, t) {
|
|
400
|
+
const r = await this.client.call(
|
|
401
|
+
"vaultProvider_getPeginStatus",
|
|
402
|
+
e,
|
|
403
|
+
t
|
|
404
|
+
);
|
|
405
|
+
return te(r), r;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get pegin status for many txids in one round trip. Per-result envelope
|
|
409
|
+
* isolates per-pegin failures from the overall RPC. Caller must chunk
|
|
410
|
+
* inputs at `VP_BATCH_MAX_SIZE`.
|
|
411
|
+
*/
|
|
412
|
+
async batchGetPeginStatus(e, t) {
|
|
413
|
+
const r = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
|
|
414
|
+
return ke(r), r;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Get pegout status for many txids in one round trip. Same per-result
|
|
418
|
+
* envelope semantics as `batchGetPeginStatus`.
|
|
419
|
+
*/
|
|
420
|
+
async batchGetPegoutStatus(e, t) {
|
|
421
|
+
const r = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
|
|
422
|
+
return Se(r), r;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function Ee(n, e) {
|
|
426
|
+
const t = /* @__PURE__ */ new Set();
|
|
427
|
+
for (const d of n)
|
|
428
|
+
t.add(d.toLowerCase());
|
|
429
|
+
const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = [], o = [];
|
|
430
|
+
for (const d of e) {
|
|
431
|
+
const l = d.pegin_txid.toLowerCase();
|
|
432
|
+
if (!t.has(l)) {
|
|
433
|
+
o.push(l);
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
if (i.has(l)) {
|
|
437
|
+
a.push(l);
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
i.add(l), r.set(l, { result: d.result, error: d.error });
|
|
441
|
+
}
|
|
442
|
+
const u = [];
|
|
443
|
+
for (const d of t)
|
|
444
|
+
i.has(d) || u.push(d);
|
|
445
|
+
return { byTxid: r, missing: u, unexpected: o, duplicate: a };
|
|
446
|
+
}
|
|
447
|
+
async function et(n) {
|
|
448
|
+
const {
|
|
449
|
+
items: e,
|
|
450
|
+
getTxid: t,
|
|
451
|
+
batchCall: r,
|
|
452
|
+
onItem: i,
|
|
453
|
+
onMissing: a,
|
|
454
|
+
onDuplicate: o,
|
|
455
|
+
onDuplicateBatch: u,
|
|
456
|
+
onWholeBatchError: d,
|
|
457
|
+
onUnexpected: l,
|
|
458
|
+
batchSize: m = de
|
|
459
|
+
} = n;
|
|
460
|
+
if (!Number.isInteger(m) || m <= 0)
|
|
461
|
+
throw new Error(
|
|
462
|
+
`batchPollByProvider: batchSize must be a positive integer, got ${m}`
|
|
463
|
+
);
|
|
464
|
+
for (let w = 0; w < e.length; w += m) {
|
|
465
|
+
const A = e.slice(w, w + m), $ = /* @__PURE__ */ new Map(), j = [];
|
|
466
|
+
for (const p of A) {
|
|
467
|
+
const f = t(p).toLowerCase();
|
|
468
|
+
$.set(f, p), j.push(f);
|
|
469
|
+
}
|
|
470
|
+
let v;
|
|
471
|
+
try {
|
|
472
|
+
const p = await r(j);
|
|
473
|
+
v = Ee(j, p.results);
|
|
474
|
+
} catch (p) {
|
|
475
|
+
d(A, p);
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
l && v.unexpected.length > 0 && l(v.unexpected);
|
|
479
|
+
const T = new Set(v.duplicate);
|
|
480
|
+
for (const p of T) {
|
|
481
|
+
const f = $.get(p);
|
|
482
|
+
f && o(f);
|
|
483
|
+
}
|
|
484
|
+
u && T.size > 0 && u(T.size);
|
|
485
|
+
for (const p of v.missing) {
|
|
486
|
+
const f = $.get(p);
|
|
487
|
+
f && a(f);
|
|
488
|
+
}
|
|
489
|
+
for (const [p, f] of v.byTxid) {
|
|
490
|
+
if (T.has(p)) continue;
|
|
491
|
+
const M = $.get(p);
|
|
492
|
+
M && i(M, {
|
|
493
|
+
pegin_txid: p,
|
|
494
|
+
result: f.result,
|
|
495
|
+
error: f.error
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const Ie = "BIP0322-signed-message", Be = "TapTweak", re = 32, Re = 64;
|
|
501
|
+
function se(n, e) {
|
|
502
|
+
const t = new TextEncoder().encode(n), r = G(t), i = new Uint8Array(r.length * 2 + e.length);
|
|
503
|
+
return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2), G(i);
|
|
504
|
+
}
|
|
505
|
+
function He(n) {
|
|
506
|
+
if (n.length !== re) return null;
|
|
507
|
+
const e = se(Be, n), t = N.xOnlyPointAddTweak(n, e);
|
|
508
|
+
return t ? t.xOnlyPubkey : null;
|
|
509
|
+
}
|
|
510
|
+
function Ne(n, e, t) {
|
|
511
|
+
if (e.length !== re || t.length !== Re) return !1;
|
|
512
|
+
try {
|
|
513
|
+
const r = se(Ie, n), i = ge.p2tr({
|
|
514
|
+
internalPubkey: x.from(e)
|
|
515
|
+
});
|
|
516
|
+
if (!i.output) return !1;
|
|
517
|
+
const a = i.output, o = 0, u = new D();
|
|
518
|
+
u.version = 0, u.locktime = 0;
|
|
519
|
+
const d = x.concat([
|
|
520
|
+
x.from([0, 32]),
|
|
521
|
+
x.from(r)
|
|
522
|
+
]);
|
|
523
|
+
u.addInput(
|
|
524
|
+
x.alloc(32, 0),
|
|
525
|
+
// prev_txid = 0x0000...0000
|
|
526
|
+
4294967295,
|
|
527
|
+
// prev_vout = 0xFFFFFFFF
|
|
528
|
+
0,
|
|
529
|
+
// sequence = 0
|
|
530
|
+
d
|
|
531
|
+
), u.addOutput(a, o);
|
|
532
|
+
const l = new D();
|
|
533
|
+
l.version = 0, l.locktime = 0;
|
|
534
|
+
const m = u.getHash();
|
|
535
|
+
l.addInput(m, 0, 0), l.addOutput(x.from([106]), o);
|
|
536
|
+
const w = l.hashForWitnessV1(
|
|
537
|
+
0,
|
|
538
|
+
[a],
|
|
539
|
+
[o],
|
|
540
|
+
D.SIGHASH_DEFAULT
|
|
541
|
+
), A = He(e);
|
|
542
|
+
return A ? N.verifySchnorr(w, A, t) : !1;
|
|
543
|
+
} catch {
|
|
544
|
+
return !1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function R(n, e) {
|
|
548
|
+
const t = (n & 7) << 5, r = typeof e == "bigint" ? e : BigInt(e);
|
|
549
|
+
if (r < 0n) throw new Error("cborHead: negative argument");
|
|
550
|
+
if (r < 24n) return new Uint8Array([t | Number(r)]);
|
|
551
|
+
if (r < 0x100n) return new Uint8Array([t | 24, Number(r)]);
|
|
552
|
+
if (r < 0x10000n) {
|
|
553
|
+
const a = Number(r);
|
|
554
|
+
return new Uint8Array([t | 25, a >>> 8 & 255, a & 255]);
|
|
555
|
+
}
|
|
556
|
+
if (r < 0x100000000n) {
|
|
557
|
+
const a = Number(r);
|
|
558
|
+
return new Uint8Array([
|
|
559
|
+
t | 26,
|
|
560
|
+
a >>> 24 & 255,
|
|
561
|
+
a >>> 16 & 255,
|
|
562
|
+
a >>> 8 & 255,
|
|
563
|
+
a & 255
|
|
564
|
+
]);
|
|
565
|
+
}
|
|
566
|
+
const i = new Uint8Array(9);
|
|
567
|
+
i[0] = t | 27;
|
|
568
|
+
for (let a = 7; a >= 0; a--)
|
|
569
|
+
i[1 + a] = Number(r >> BigInt((7 - a) * 8)) & 255;
|
|
570
|
+
return i;
|
|
571
|
+
}
|
|
572
|
+
function ie(...n) {
|
|
573
|
+
const e = n.reduce((i, a) => i + a.length, 0), t = new Uint8Array(e);
|
|
574
|
+
let r = 0;
|
|
575
|
+
for (const i of n)
|
|
576
|
+
t.set(i, r), r += i.length;
|
|
577
|
+
return t;
|
|
578
|
+
}
|
|
579
|
+
function X(n) {
|
|
580
|
+
const t = [R(4, n.length)];
|
|
581
|
+
for (const r of n)
|
|
582
|
+
t.push(R(0, r));
|
|
583
|
+
return ie(...t);
|
|
584
|
+
}
|
|
585
|
+
function je(n, e, t) {
|
|
586
|
+
if (!Number.isSafeInteger(t) || t < 0)
|
|
587
|
+
throw new Error(
|
|
588
|
+
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
|
|
589
|
+
);
|
|
590
|
+
const r = R(4, 3), i = X(n), a = X(e), o = R(0, t);
|
|
591
|
+
return ie(r, i, a, o);
|
|
592
|
+
}
|
|
593
|
+
const De = new TextEncoder().encode(
|
|
594
|
+
"btc-auth.server-identity.v1"
|
|
595
|
+
);
|
|
596
|
+
class _ extends Error {
|
|
597
|
+
constructor(e, t) {
|
|
598
|
+
super(e), this.reason = t, this.name = "ServerIdentityError";
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function I(n) {
|
|
602
|
+
const e = new Uint8Array(n.length / 2);
|
|
603
|
+
for (let t = 0; t < e.length; t++)
|
|
604
|
+
e[t] = parseInt(n.slice(t * 2, t * 2 + 2), 16);
|
|
605
|
+
return e;
|
|
606
|
+
}
|
|
607
|
+
function Oe(n) {
|
|
608
|
+
const { proof: e, pinnedServerPubkey: t, now: r } = n, i = C(t).toLowerCase();
|
|
609
|
+
if (i.length !== B || !k.test(i))
|
|
610
|
+
throw new _(
|
|
611
|
+
`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,
|
|
612
|
+
"invalid_pubkey_encoding"
|
|
613
|
+
);
|
|
614
|
+
const a = C(e.server_pubkey).toLowerCase();
|
|
615
|
+
if (a.length !== B || !k.test(a))
|
|
616
|
+
throw new _(
|
|
617
|
+
`server_pubkey must be 32-byte hex; got ${a.length} chars`,
|
|
618
|
+
"invalid_pubkey_encoding"
|
|
619
|
+
);
|
|
620
|
+
if (a !== i)
|
|
621
|
+
throw new _(
|
|
622
|
+
`server_pubkey does not match pinned value: expected ${i}, got ${a}`,
|
|
623
|
+
"pinned_pubkey_mismatch"
|
|
624
|
+
);
|
|
625
|
+
if (!Number.isSafeInteger(e.expires_at))
|
|
626
|
+
throw new _(
|
|
627
|
+
`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,
|
|
628
|
+
"invalid_expires_at"
|
|
629
|
+
);
|
|
630
|
+
if (!Number.isSafeInteger(r))
|
|
631
|
+
throw new _(
|
|
632
|
+
`now must be a finite integer; got ${JSON.stringify(r)}`,
|
|
633
|
+
"invalid_expires_at"
|
|
634
|
+
);
|
|
635
|
+
if (e.expires_at <= r)
|
|
636
|
+
throw new _(
|
|
637
|
+
`server identity proof expired at ${e.expires_at}, now ${r}`,
|
|
638
|
+
"expired"
|
|
639
|
+
);
|
|
640
|
+
const o = C(e.ephemeral_pubkey).toLowerCase();
|
|
641
|
+
if (o.length !== K || !k.test(o))
|
|
642
|
+
throw new _(
|
|
643
|
+
`ephemeral_pubkey must be 33-byte compressed hex; got ${o.length} chars`,
|
|
644
|
+
"invalid_ephemeral_pubkey"
|
|
645
|
+
);
|
|
646
|
+
const u = o.slice(0, 2);
|
|
647
|
+
if (u !== "02" && u !== "03")
|
|
648
|
+
throw new _(
|
|
649
|
+
`ephemeral_pubkey must be compressed (prefix 02/03); got ${u}`,
|
|
650
|
+
"invalid_ephemeral_pubkey"
|
|
651
|
+
);
|
|
652
|
+
const d = I(o);
|
|
653
|
+
if (!N.isPoint(d))
|
|
654
|
+
throw new _(
|
|
655
|
+
"ephemeral_pubkey is not a valid secp256k1 point",
|
|
656
|
+
"invalid_ephemeral_pubkey"
|
|
657
|
+
);
|
|
658
|
+
const l = C(e.signature).toLowerCase();
|
|
659
|
+
if (l.length !== pe || !k.test(l))
|
|
660
|
+
throw new _(
|
|
661
|
+
`signature must be 64-byte Schnorr hex; got ${l.length} chars`,
|
|
662
|
+
"invalid_signature_encoding"
|
|
663
|
+
);
|
|
664
|
+
const m = je(
|
|
665
|
+
De,
|
|
666
|
+
I(o),
|
|
667
|
+
e.expires_at
|
|
668
|
+
);
|
|
669
|
+
if (!Ne(m, I(a), I(l)))
|
|
670
|
+
throw new _(
|
|
671
|
+
"BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
|
|
672
|
+
"signature_verification_failed"
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
const Ue = /* @__PURE__ */ new Set([
|
|
676
|
+
"vaultProvider_submitDepositorWotsKey",
|
|
677
|
+
"vaultProvider_submitDepositorPresignatures",
|
|
678
|
+
"vaultProvider_requestDepositorPresignTransactions"
|
|
679
|
+
]), Ke = 6e4, L = "auth_createDepositorToken";
|
|
680
|
+
function ae(n, e) {
|
|
681
|
+
return new Y({
|
|
682
|
+
baseUrl: n,
|
|
683
|
+
timeout: Ke,
|
|
684
|
+
headers: e,
|
|
685
|
+
retryableFor: (t) => t === L
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
const q = 4102444800, Le = 30;
|
|
689
|
+
class Me {
|
|
690
|
+
constructor(e) {
|
|
691
|
+
// `client` is the only mutable field — see `setClient`. The
|
|
692
|
+
// identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
|
|
693
|
+
// remain readonly and are checked against re-registration in the
|
|
694
|
+
// registry's `getOrCreate`.
|
|
695
|
+
h(this, "client");
|
|
696
|
+
h(this, "peginTxid");
|
|
697
|
+
h(this, "authAnchorHex");
|
|
698
|
+
h(this, "pinnedServerPubkey");
|
|
699
|
+
h(this, "authGatedMethods");
|
|
700
|
+
h(this, "refreshSkewSecs");
|
|
701
|
+
h(this, "now");
|
|
702
|
+
h(this, "cached", null);
|
|
703
|
+
h(this, "inFlight", null);
|
|
704
|
+
this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Le, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Return a bearer token for `method`, or `null` if `method` is not
|
|
708
|
+
* auth-gated. Triggers a token acquisition if no token is cached or
|
|
709
|
+
* the cached token is within {@link refreshSkewSecs} of expiry.
|
|
710
|
+
*
|
|
711
|
+
* The token-issuing method itself is hard-exempted from the gate —
|
|
712
|
+
* if `auth_createDepositorToken` were ever included in
|
|
713
|
+
* `authGatedMethods` (caller misconfiguration) the provider would
|
|
714
|
+
* recurse into `acquireSingleFlight` from inside the JSON-RPC header
|
|
715
|
+
* builder before `inFlight` is assigned, defeating the single-flight
|
|
716
|
+
* guard. Returning `null` here breaks that recursion deterministically.
|
|
717
|
+
*/
|
|
718
|
+
async getToken(e) {
|
|
719
|
+
if (e === L || !this.authGatedMethods.has(e)) return null;
|
|
720
|
+
const t = this.cached;
|
|
721
|
+
return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight()).token;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Drop the cached token. Next `getToken` call re-acquires.
|
|
725
|
+
* Called by `JsonRpcClient` on wire `auth_expired` responses.
|
|
726
|
+
*/
|
|
727
|
+
invalidate() {
|
|
728
|
+
this.cached = null;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Swap in a different transport for subsequent token-issuing calls.
|
|
732
|
+
* Used by the registry when a later caller registers the same
|
|
733
|
+
* `peginTxid` against a different `baseUrl` — the cached token
|
|
734
|
+
* (bound to identity, not transport) stays valid, but future
|
|
735
|
+
* refreshes hit the new URL. An in-flight acquire keeps using the
|
|
736
|
+
* old client (it captured the reference); next call uses the new.
|
|
737
|
+
*/
|
|
738
|
+
setClient(e) {
|
|
739
|
+
this.client = e;
|
|
740
|
+
}
|
|
741
|
+
acquireSingleFlight() {
|
|
742
|
+
const e = this.inFlight;
|
|
743
|
+
if (e) return e;
|
|
744
|
+
const t = (async () => {
|
|
745
|
+
try {
|
|
746
|
+
const r = await this.client.call(L, {
|
|
747
|
+
pegin_txid: this.peginTxid,
|
|
748
|
+
auth_anchor: this.authAnchorHex
|
|
749
|
+
});
|
|
750
|
+
if (Oe({
|
|
751
|
+
proof: r.server_identity,
|
|
752
|
+
pinnedServerPubkey: this.pinnedServerPubkey,
|
|
753
|
+
now: this.now()
|
|
754
|
+
}), typeof r.token != "string" || r.token.length === 0)
|
|
755
|
+
throw new Error(
|
|
756
|
+
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
|
|
757
|
+
);
|
|
758
|
+
const i = this.now();
|
|
759
|
+
if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= i || r.expires_at > q)
|
|
760
|
+
throw new Error(
|
|
761
|
+
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${i}, ${q}])`
|
|
762
|
+
);
|
|
763
|
+
const a = {
|
|
764
|
+
token: r.token,
|
|
765
|
+
expiresAt: r.expires_at
|
|
766
|
+
};
|
|
767
|
+
return this.cached = a, a;
|
|
768
|
+
} finally {
|
|
769
|
+
this.inFlight = null;
|
|
770
|
+
}
|
|
771
|
+
})();
|
|
772
|
+
return this.inFlight = t, t;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
class Ge {
|
|
776
|
+
constructor() {
|
|
777
|
+
h(this, "entries", /* @__PURE__ */ new Map());
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Return the cached `VpTokenProvider` for `peginTxid` if one exists
|
|
781
|
+
* with matching `authAnchorHex` and `pinnedServerPubkey`, otherwise
|
|
782
|
+
* construct and cache a fresh provider. A mismatch on either field
|
|
783
|
+
* throws — silent overwrite would mask derivation drift or VP
|
|
784
|
+
* pubkey rotation.
|
|
785
|
+
*/
|
|
786
|
+
getOrCreate(e) {
|
|
787
|
+
const t = this.entries.get(e.peginTxid);
|
|
788
|
+
if (t) {
|
|
789
|
+
if (t.authAnchorHex !== e.authAnchorHex)
|
|
790
|
+
throw new Error(
|
|
791
|
+
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${t.authAnchorHex.slice(0, 8)}…; got ${e.authAnchorHex.slice(0, 8)}…`
|
|
792
|
+
);
|
|
793
|
+
if (t.pinnedServerPubkey !== e.pinnedServerPubkey)
|
|
794
|
+
throw new Error(
|
|
795
|
+
`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${t.pinnedServerPubkey.slice(0, 8)}…; got ${e.pinnedServerPubkey.slice(0, 8)}…`
|
|
796
|
+
);
|
|
797
|
+
return t.provider.setClient(e.client), t.provider;
|
|
798
|
+
}
|
|
799
|
+
const r = new Me({
|
|
800
|
+
client: e.client,
|
|
801
|
+
peginTxid: e.peginTxid,
|
|
802
|
+
authAnchorHex: e.authAnchorHex,
|
|
803
|
+
pinnedServerPubkey: e.pinnedServerPubkey,
|
|
804
|
+
authGatedMethods: Ue
|
|
805
|
+
});
|
|
806
|
+
return this.entries.set(e.peginTxid, {
|
|
807
|
+
provider: r,
|
|
808
|
+
authAnchorHex: e.authAnchorHex,
|
|
809
|
+
pinnedServerPubkey: e.pinnedServerPubkey
|
|
810
|
+
}), r;
|
|
811
|
+
}
|
|
812
|
+
/** Return the cached provider, or `undefined` if none. */
|
|
813
|
+
peek(e) {
|
|
814
|
+
var t;
|
|
815
|
+
return (t = this.entries.get(e)) == null ? void 0 : t.provider;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Evict the entry for `peginTxid`. Idempotent. Called on terminal
|
|
819
|
+
* paths — activation success, user-cancel, or component unmount —
|
|
820
|
+
* so `authAnchorHex` doesn't outlive the deposit session.
|
|
821
|
+
*/
|
|
822
|
+
release(e) {
|
|
823
|
+
this.entries.delete(e);
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Wipe every cached entry. Test-only escape hatch — not exposed on
|
|
827
|
+
* the public {@link VpTokenRegistryPublic} singleton type.
|
|
828
|
+
*
|
|
829
|
+
* @internal
|
|
830
|
+
*/
|
|
831
|
+
clear() {
|
|
832
|
+
this.entries.clear();
|
|
833
|
+
}
|
|
834
|
+
get size() {
|
|
835
|
+
return this.entries.size;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const oe = new Ge();
|
|
839
|
+
function tt(n) {
|
|
840
|
+
var r;
|
|
841
|
+
const e = ae(
|
|
842
|
+
n.baseUrl,
|
|
843
|
+
(r = n.options) == null ? void 0 : r.headers
|
|
844
|
+
), t = oe.getOrCreate({
|
|
845
|
+
client: e,
|
|
846
|
+
peginTxid: n.peginTxid,
|
|
847
|
+
authAnchorHex: n.authAnchorHex,
|
|
848
|
+
pinnedServerPubkey: n.pinnedServerPubkey
|
|
849
|
+
});
|
|
850
|
+
return new Ce(n.baseUrl, {
|
|
851
|
+
...n.options,
|
|
852
|
+
tokenProvider: t
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
function nt(n) {
|
|
856
|
+
oe.getOrCreate({
|
|
857
|
+
client: ae(n.baseUrl, n.headers),
|
|
858
|
+
peginTxid: n.peginTxid,
|
|
859
|
+
authAnchorHex: n.authAnchorHex,
|
|
860
|
+
pinnedServerPubkey: n.pinnedServerPubkey
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
async function rt(n, e) {
|
|
864
|
+
const [t, r] = await n.multicall({
|
|
865
|
+
contracts: [
|
|
866
|
+
{
|
|
867
|
+
address: e,
|
|
868
|
+
abi: S,
|
|
869
|
+
functionName: "protocolParams"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
address: e,
|
|
873
|
+
abi: S,
|
|
874
|
+
functionName: "applicationRegistry"
|
|
875
|
+
}
|
|
876
|
+
],
|
|
877
|
+
allowFailure: !1
|
|
878
|
+
});
|
|
879
|
+
return {
|
|
880
|
+
protocolParams: t,
|
|
881
|
+
applicationRegistry: r
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
const W = 65535;
|
|
885
|
+
function U(n) {
|
|
886
|
+
return {
|
|
887
|
+
timelockAssert: n.timelockAssert,
|
|
888
|
+
timelockChallengeAssert: n.timelockChallengeAssert,
|
|
889
|
+
securityCouncilKeys: [...n.securityCouncilKeys],
|
|
890
|
+
councilQuorum: n.councilQuorum,
|
|
891
|
+
feeRate: n.feeRate,
|
|
892
|
+
babeTotalInstances: n.babeTotalInstances,
|
|
893
|
+
babeInstancesToFinalize: n.babeInstancesToFinalize,
|
|
894
|
+
minVpCommissionBps: n.minVpCommissionBps,
|
|
895
|
+
tRefund: n.tRefund,
|
|
896
|
+
tStale: n.tStale,
|
|
897
|
+
minPeginFeeRate: n.minPeginFeeRate,
|
|
898
|
+
proverProgramVersion: n.proverProgramVersion,
|
|
899
|
+
minPrepeginDepth: n.minPrepeginDepth
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
function z(n) {
|
|
903
|
+
return {
|
|
904
|
+
minimumPegInAmount: n.minimumPegInAmount,
|
|
905
|
+
maxPegInAmount: n.maxPegInAmount,
|
|
906
|
+
pegInAckTimeout: n.pegInAckTimeout,
|
|
907
|
+
pegInActivationTimeout: n.pegInActivationTimeout,
|
|
908
|
+
maxHtlcOutputCount: n.maxHtlcOutputCount
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function J(n) {
|
|
912
|
+
if (n > BigInt(W))
|
|
913
|
+
throw new Error(
|
|
914
|
+
`timelockAssert value ${n} exceeds uint16 max (${W})`
|
|
915
|
+
);
|
|
916
|
+
return Number(n);
|
|
917
|
+
}
|
|
918
|
+
class st {
|
|
919
|
+
constructor(e, t) {
|
|
920
|
+
this.publicClient = e, this.contractAddress = t;
|
|
921
|
+
}
|
|
922
|
+
async getTBVProtocolParams() {
|
|
923
|
+
const e = await this.publicClient.readContract({
|
|
924
|
+
address: this.contractAddress,
|
|
925
|
+
abi: b,
|
|
926
|
+
functionName: "getTBVProtocolParams"
|
|
927
|
+
});
|
|
928
|
+
return z(e);
|
|
929
|
+
}
|
|
930
|
+
async getLatestOffchainParams() {
|
|
931
|
+
const e = await this.publicClient.readContract({
|
|
932
|
+
address: this.contractAddress,
|
|
933
|
+
abi: b,
|
|
934
|
+
functionName: "getLatestOffchainParams"
|
|
935
|
+
});
|
|
936
|
+
return U(e);
|
|
937
|
+
}
|
|
938
|
+
async getOffchainParamsByVersion(e) {
|
|
939
|
+
const t = await this.publicClient.readContract({
|
|
940
|
+
address: this.contractAddress,
|
|
941
|
+
abi: b,
|
|
942
|
+
functionName: "getOffchainParamsByVersion",
|
|
943
|
+
args: [e]
|
|
944
|
+
});
|
|
945
|
+
return U(t);
|
|
946
|
+
}
|
|
947
|
+
async getLatestOffchainParamsVersion() {
|
|
948
|
+
return await this.publicClient.readContract({
|
|
949
|
+
address: this.contractAddress,
|
|
950
|
+
abi: b,
|
|
951
|
+
functionName: "latestOffchainParamsVersion"
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
async getTimelockPeginByVersion(e) {
|
|
955
|
+
const t = await this.getOffchainParamsByVersion(e);
|
|
956
|
+
return J(t.timelockAssert);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Read TBV protocol params and latest offchain params atomically via multicall.
|
|
960
|
+
* Prevents TOCTOU inconsistency if governance updates params between reads.
|
|
961
|
+
*/
|
|
962
|
+
async getPegInConfiguration() {
|
|
963
|
+
const e = await this.publicClient.multicall({
|
|
964
|
+
contracts: [
|
|
965
|
+
{
|
|
966
|
+
address: this.contractAddress,
|
|
967
|
+
abi: b,
|
|
968
|
+
functionName: "getTBVProtocolParams"
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
address: this.contractAddress,
|
|
972
|
+
abi: b,
|
|
973
|
+
functionName: "getLatestOffchainParams"
|
|
974
|
+
}
|
|
975
|
+
],
|
|
976
|
+
allowFailure: !1
|
|
977
|
+
}), t = z(e[0]), r = U(e[1]);
|
|
978
|
+
return {
|
|
979
|
+
minimumPegInAmount: t.minimumPegInAmount,
|
|
980
|
+
maxPegInAmount: t.maxPegInAmount,
|
|
981
|
+
pegInAckTimeout: t.pegInAckTimeout,
|
|
982
|
+
pegInActivationTimeout: t.pegInActivationTimeout,
|
|
983
|
+
maxHtlcOutputCount: t.maxHtlcOutputCount,
|
|
984
|
+
timelockPegin: J(r.timelockAssert),
|
|
985
|
+
timelockRefund: r.tRefund,
|
|
986
|
+
minVpCommissionBps: r.minVpCommissionBps,
|
|
987
|
+
offchainParams: r
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
function H(n) {
|
|
992
|
+
return n.map((e) => ({
|
|
993
|
+
ethAddress: e.ethAddress,
|
|
994
|
+
btcPubKey: e.btcPubKey
|
|
995
|
+
}));
|
|
996
|
+
}
|
|
997
|
+
class it {
|
|
998
|
+
constructor(e, t) {
|
|
999
|
+
this.publicClient = e, this.contractAddress = t;
|
|
1000
|
+
}
|
|
1001
|
+
async getVaultKeepersByVersion(e, t) {
|
|
1002
|
+
const r = await this.publicClient.readContract({
|
|
1003
|
+
address: this.contractAddress,
|
|
1004
|
+
abi: O,
|
|
1005
|
+
functionName: "getVaultKeepersByVersion",
|
|
1006
|
+
args: [e, t]
|
|
1007
|
+
});
|
|
1008
|
+
return H(r);
|
|
1009
|
+
}
|
|
1010
|
+
async getCurrentVaultKeepers(e) {
|
|
1011
|
+
const t = await this.publicClient.readContract({
|
|
1012
|
+
address: this.contractAddress,
|
|
1013
|
+
abi: O,
|
|
1014
|
+
functionName: "getCurrentVaultKeepers",
|
|
1015
|
+
args: [e]
|
|
1016
|
+
});
|
|
1017
|
+
return H(t);
|
|
1018
|
+
}
|
|
1019
|
+
async getCurrentVaultKeepersVersion(e) {
|
|
1020
|
+
return await this.publicClient.readContract({
|
|
1021
|
+
address: this.contractAddress,
|
|
1022
|
+
abi: O,
|
|
1023
|
+
functionName: "getCurrentVaultKeepersVersion",
|
|
1024
|
+
args: [e]
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
class at {
|
|
1029
|
+
constructor(e, t) {
|
|
1030
|
+
this.publicClient = e, this.contractAddress = t;
|
|
1031
|
+
}
|
|
1032
|
+
async getUniversalChallengersByVersion(e) {
|
|
1033
|
+
const t = await this.publicClient.readContract({
|
|
1034
|
+
address: this.contractAddress,
|
|
1035
|
+
abi: b,
|
|
1036
|
+
functionName: "getUniversalChallengersByVersion",
|
|
1037
|
+
args: [e]
|
|
1038
|
+
});
|
|
1039
|
+
return H(t);
|
|
1040
|
+
}
|
|
1041
|
+
async getCurrentUniversalChallengers() {
|
|
1042
|
+
const e = await this.publicClient.readContract({
|
|
1043
|
+
address: this.contractAddress,
|
|
1044
|
+
abi: b,
|
|
1045
|
+
functionName: "getCurrentUniversalChallengers"
|
|
1046
|
+
});
|
|
1047
|
+
return H(e);
|
|
1048
|
+
}
|
|
1049
|
+
async getLatestUniversalChallengersVersion() {
|
|
1050
|
+
return await this.publicClient.readContract({
|
|
1051
|
+
address: this.contractAddress,
|
|
1052
|
+
abi: b,
|
|
1053
|
+
functionName: "latestUniversalChallengersVersion"
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
class ot {
|
|
1058
|
+
constructor(e, t) {
|
|
1059
|
+
this.publicClient = e, this.contractAddress = t;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Read the VP's persistent x-only BTC pubkey from the on-chain
|
|
1063
|
+
* registry. Validates length, hex form, and secp256k1 curve
|
|
1064
|
+
* membership before minting the brand. Returns 64-char lowercase
|
|
1065
|
+
* hex without the `0x` prefix.
|
|
1066
|
+
*/
|
|
1067
|
+
async getVaultProviderBtcPubKey(e) {
|
|
1068
|
+
const r = (await this.publicClient.readContract({
|
|
1069
|
+
address: this.contractAddress,
|
|
1070
|
+
abi: S,
|
|
1071
|
+
functionName: "getVaultProviderBTCKey",
|
|
1072
|
+
args: [e]
|
|
1073
|
+
})).toLowerCase();
|
|
1074
|
+
if (!/^0x[0-9a-f]{64}$/.test(r))
|
|
1075
|
+
throw new Error(
|
|
1076
|
+
`getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0, 2)}")`
|
|
1077
|
+
);
|
|
1078
|
+
const i = r.slice(2);
|
|
1079
|
+
if (!N.isXOnlyPoint(he(i)))
|
|
1080
|
+
throw new Error(
|
|
1081
|
+
`getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`
|
|
1082
|
+
);
|
|
1083
|
+
return i;
|
|
1084
|
+
}
|
|
1085
|
+
async getVaultBasicInfo(e) {
|
|
1086
|
+
const t = await this.publicClient.readContract({
|
|
1087
|
+
address: this.contractAddress,
|
|
1088
|
+
abi: S,
|
|
1089
|
+
functionName: "getBtcVaultBasicInfo",
|
|
1090
|
+
args: [e]
|
|
1091
|
+
});
|
|
1092
|
+
return {
|
|
1093
|
+
depositor: t.depositor,
|
|
1094
|
+
depositorBtcPubKey: t.depositorBtcPubKey,
|
|
1095
|
+
amount: t.amount,
|
|
1096
|
+
vaultProvider: t.vaultProvider,
|
|
1097
|
+
status: t.status,
|
|
1098
|
+
applicationEntryPoint: t.applicationEntryPoint,
|
|
1099
|
+
createdAt: t.createdAt
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
async getVaultProtocolInfo(e) {
|
|
1103
|
+
const t = await this.publicClient.readContract({
|
|
1104
|
+
address: this.contractAddress,
|
|
1105
|
+
abi: S,
|
|
1106
|
+
functionName: "getBtcVaultProtocolInfo",
|
|
1107
|
+
args: [e]
|
|
1108
|
+
});
|
|
1109
|
+
return {
|
|
1110
|
+
depositorSignedPeginTx: t.depositorSignedPeginTx,
|
|
1111
|
+
universalChallengersVersion: t.universalChallengersVersion,
|
|
1112
|
+
appVaultKeepersVersion: t.appVaultKeepersVersion,
|
|
1113
|
+
offchainParamsVersion: t.offchainParamsVersion,
|
|
1114
|
+
verifiedAt: t.verifiedAt,
|
|
1115
|
+
depositorWotsPkHash: t.depositorWotsPkHash,
|
|
1116
|
+
hashlock: t.hashlock,
|
|
1117
|
+
htlcVout: t.htlcVout,
|
|
1118
|
+
depositorPopSignature: t.depositorPopSignature,
|
|
1119
|
+
prePeginTxHash: t.prePeginTxHash,
|
|
1120
|
+
vaultProviderCommissionBps: t.vaultProviderCommissionBps
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
async getVaultData(e) {
|
|
1124
|
+
const [t, r] = await Promise.all([
|
|
1125
|
+
this.getVaultBasicInfo(e),
|
|
1126
|
+
this.getVaultProtocolInfo(e)
|
|
1127
|
+
]);
|
|
1128
|
+
if (!r.depositorSignedPeginTx || r.depositorSignedPeginTx === "0x")
|
|
1129
|
+
throw new Error(
|
|
1130
|
+
`Vault ${e} not found on-chain or has no pegin transaction`
|
|
1131
|
+
);
|
|
1132
|
+
return { basic: t, protocol: r };
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
export {
|
|
1136
|
+
_ as S,
|
|
1137
|
+
Ce as V,
|
|
1138
|
+
s as a,
|
|
1139
|
+
et as b,
|
|
1140
|
+
Oe as c,
|
|
1141
|
+
Ge as d,
|
|
1142
|
+
oe as e,
|
|
1143
|
+
tt as f,
|
|
1144
|
+
st as g,
|
|
1145
|
+
at as h,
|
|
1146
|
+
it as i,
|
|
1147
|
+
ot as j,
|
|
1148
|
+
nt as p,
|
|
1149
|
+
rt as r,
|
|
1150
|
+
ve as v
|
|
1151
|
+
};
|
|
1152
|
+
//# sourceMappingURL=vault-registry-reader-BDFpXeH7.js.map
|