@babylonlabs-io/ts-sdk 0.33.8 → 0.35.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.
Files changed (89) hide show
  1. package/dist/{PayoutManager-DDnNB0mj.cjs → PayoutManager-BhJoQZsG.cjs} +2 -2
  2. package/dist/PayoutManager-BhJoQZsG.cjs.map +1 -0
  3. package/dist/{PayoutManager-C9XHKZ5j.js → PayoutManager-s_uH8Uuj.js} +2 -2
  4. package/dist/PayoutManager-s_uH8Uuj.js.map +1 -0
  5. package/dist/PeginManager-DF1oinIQ.js +1172 -0
  6. package/dist/PeginManager-DF1oinIQ.js.map +1 -0
  7. package/dist/PeginManager-cPQuJTB9.cjs +2 -0
  8. package/dist/PeginManager-cPQuJTB9.cjs.map +1 -0
  9. package/dist/{buildAndBroadcastRefund-C7hnNWbj.cjs → buildAndBroadcastRefund-BQ0CaL6Q.cjs} +2 -2
  10. package/dist/{buildAndBroadcastRefund-C7hnNWbj.cjs.map → buildAndBroadcastRefund-BQ0CaL6Q.cjs.map} +1 -1
  11. package/dist/{buildAndBroadcastRefund-B6fGRmvo.js → buildAndBroadcastRefund-DzX11N9S.js} +2 -2
  12. package/dist/{buildAndBroadcastRefund-B6fGRmvo.js.map → buildAndBroadcastRefund-DzX11N9S.js.map} +1 -1
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.js +127 -123
  15. package/dist/sha2-BYVxyZzX.js +274 -0
  16. package/dist/{sha2-6wN58S6R.js.map → sha2-BYVxyZzX.js.map} +1 -1
  17. package/dist/sha2-DsrLC4NM.cjs +2 -0
  18. package/dist/{sha2-CsTynrfJ.cjs.map → sha2-DsrLC4NM.cjs.map} +1 -1
  19. package/dist/tbv/core/clients/eth/index.d.ts +2 -1
  20. package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
  21. package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts +21 -3
  22. package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -1
  23. package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts +27 -0
  24. package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts.map +1 -0
  25. package/dist/tbv/core/clients/eth/types.d.ts +30 -0
  26. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  27. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +6 -0
  28. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  29. package/dist/tbv/core/clients/index.cjs +1 -1
  30. package/dist/tbv/core/clients/index.js +30 -27
  31. package/dist/tbv/core/index.cjs +1 -1
  32. package/dist/tbv/core/index.js +126 -122
  33. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  34. package/dist/tbv/core/managers/index.cjs +1 -1
  35. package/dist/tbv/core/managers/index.js +2 -2
  36. package/dist/tbv/core/services/index.cjs +1 -1
  37. package/dist/tbv/core/services/index.js +2 -2
  38. package/dist/tbv/core/utils/eth/__tests__/waitForTransactionReceiptSmartAware.test.d.ts +2 -0
  39. package/dist/tbv/core/utils/eth/__tests__/waitForTransactionReceiptSmartAware.test.d.ts.map +1 -0
  40. package/dist/tbv/core/utils/eth/index.d.ts +2 -0
  41. package/dist/tbv/core/utils/eth/index.d.ts.map +1 -0
  42. package/dist/tbv/core/utils/eth/waitForTransactionReceiptSmartAware.d.ts +18 -0
  43. package/dist/tbv/core/utils/eth/waitForTransactionReceiptSmartAware.d.ts.map +1 -0
  44. package/dist/tbv/core/utils/index.cjs +1 -1
  45. package/dist/tbv/core/utils/index.d.ts +1 -0
  46. package/dist/tbv/core/utils/index.d.ts.map +1 -1
  47. package/dist/tbv/core/utils/index.js +14 -13
  48. package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts +1 -1
  49. package/dist/tbv/core/vault-secrets/__tests__/expand.test.d.ts +4 -6
  50. package/dist/tbv/core/vault-secrets/__tests__/expand.test.d.ts.map +1 -1
  51. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts +1 -1
  52. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -1
  53. package/dist/tbv/core/vault-secrets/index.d.ts +1 -1
  54. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  55. package/dist/tbv/index.cjs +1 -1
  56. package/dist/tbv/index.js +126 -122
  57. package/dist/testing/index.cjs +1 -1
  58. package/dist/testing/index.js +1 -1
  59. package/dist/vault-registry-reader-BBk0p-u-.js +1292 -0
  60. package/dist/vault-registry-reader-BBk0p-u-.js.map +1 -0
  61. package/dist/vault-registry-reader-DQgnZilV.cjs +2 -0
  62. package/dist/vault-registry-reader-DQgnZilV.cjs.map +1 -0
  63. package/dist/waitForTransactionReceiptSmartAware-Cj_DKm0G.js +217 -0
  64. package/dist/waitForTransactionReceiptSmartAware-Cj_DKm0G.js.map +1 -0
  65. package/dist/waitForTransactionReceiptSmartAware-D9ykVriz.cjs +2 -0
  66. package/dist/waitForTransactionReceiptSmartAware-D9ykVriz.cjs.map +1 -0
  67. package/package.json +1 -2
  68. package/dist/PayoutManager-C9XHKZ5j.js.map +0 -1
  69. package/dist/PayoutManager-DDnNB0mj.cjs.map +0 -1
  70. package/dist/PeginManager-C8-I4gFH.js +0 -1280
  71. package/dist/PeginManager-C8-I4gFH.js.map +0 -1
  72. package/dist/PeginManager-D0TW9RET.cjs +0 -2
  73. package/dist/PeginManager-D0TW9RET.cjs.map +0 -1
  74. package/dist/psbtInputFields-2224j2ZY.js +0 -128
  75. package/dist/psbtInputFields-2224j2ZY.js.map +0 -1
  76. package/dist/psbtInputFields-B1lrwYzH.cjs +0 -2
  77. package/dist/psbtInputFields-B1lrwYzH.cjs.map +0 -1
  78. package/dist/sha2-6wN58S6R.js +0 -280
  79. package/dist/sha2-CsTynrfJ.cjs +0 -2
  80. package/dist/tbv/core/vault-secrets/__tests__/info.test.d.ts +0 -8
  81. package/dist/tbv/core/vault-secrets/__tests__/info.test.d.ts.map +0 -1
  82. package/dist/tbv/core/vault-secrets/expand.d.ts +0 -58
  83. package/dist/tbv/core/vault-secrets/expand.d.ts.map +0 -1
  84. package/dist/tbv/core/vault-secrets/info.d.ts +0 -55
  85. package/dist/tbv/core/vault-secrets/info.d.ts.map +0 -1
  86. package/dist/vault-registry-reader-DNiXOSYM.cjs +0 -2
  87. package/dist/vault-registry-reader-DNiXOSYM.cjs.map +0 -1
  88. package/dist/vault-registry-reader-PsSxB0JZ.js +0 -1162
  89. package/dist/vault-registry-reader-PsSxB0JZ.js.map +0 -1
@@ -1,1162 +0,0 @@
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 S } from "./validation-CxqROCno.js";
7
- import * as N from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- import { payments as ge, Transaction as O } from "bitcoinjs-lib";
9
- import { Buffer as V } from "buffer";
10
- import { s as F } from "./sha2-6wN58S6R.js";
11
- import { B as k } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
12
- import { P as b, A as D } from "./ProtocolParams.abi-DXu8L0Fn.js";
13
- const G = 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 A = 64;
27
- function P(n) {
28
- return typeof n == "string" && n.length > 0 && S.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 _(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 !== A)
79
- throw new s(
80
- `VP response validation failed: "pegin_txid" must be a ${A}-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 (!G.has(e.status))
87
- throw new s(
88
- `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...G].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`), _(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
- _(t.wots_pks_json, `${e}.wots_pks_json`), _(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`), _(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 xe(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 ve(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 !== A)
216
- throw new s(
217
- `VP response validation failed: "pegin_txid" must be a ${A}-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 (_(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 (_(n.claim_txid, "claimer.claim_txid"), _(n.claimer_pubkey, "claimer.claimer_pubkey"), _(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 (_(t.status, `challengers[${e}].status`), _(t.claim_txid, `challengers[${e}].claim_txid`), _(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 Se(n) {
283
- ne(n, "batchGetPeginStatus", (e) => {
284
- e.result !== null && te(e.result);
285
- });
286
- }
287
- function ke(n) {
288
- ne(n, "batchGetPegoutStatus", (e) => {
289
- e.result !== null && ve(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 !== A)
310
- throw new s(
311
- `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${A}-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"), _(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 xe(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 Se(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 ke(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 u = d.pegin_txid.toLowerCase();
432
- if (!t.has(u)) {
433
- o.push(u);
434
- continue;
435
- }
436
- if (i.has(u)) {
437
- a.push(u);
438
- continue;
439
- }
440
- i.add(u), r.set(u, { result: d.result, error: d.error });
441
- }
442
- const l = [];
443
- for (const d of t)
444
- i.has(d) || l.push(d);
445
- return { byTxid: r, missing: l, unexpected: o, duplicate: a };
446
- }
447
- async function tt(n) {
448
- const {
449
- items: e,
450
- getTxid: t,
451
- batchCall: r,
452
- onItem: i,
453
- onMissing: a,
454
- onDuplicate: o,
455
- onDuplicateBatch: l,
456
- onWholeBatchError: d,
457
- onUnexpected: u,
458
- batchSize: f = de
459
- } = n;
460
- if (!Number.isInteger(f) || f <= 0)
461
- throw new Error(
462
- `batchPollByProvider: batchSize must be a positive integer, got ${f}`
463
- );
464
- for (let w = 0; w < e.length; w += f) {
465
- const x = e.slice(w, w + f), $ = /* @__PURE__ */ new Map(), j = [];
466
- for (const p of x) {
467
- const m = t(p).toLowerCase();
468
- $.set(m, p), j.push(m);
469
- }
470
- let v;
471
- try {
472
- const p = await r(j);
473
- v = Ee(j, p.results);
474
- } catch (p) {
475
- d(x, p);
476
- continue;
477
- }
478
- u && v.unexpected.length > 0 && u(v.unexpected);
479
- const T = new Set(v.duplicate);
480
- for (const p of T) {
481
- const m = $.get(p);
482
- m && o(m);
483
- }
484
- l && T.size > 0 && l(T.size);
485
- for (const p of v.missing) {
486
- const m = $.get(p);
487
- m && a(m);
488
- }
489
- for (const [p, m] of v.byTxid) {
490
- if (T.has(p)) continue;
491
- const M = $.get(p);
492
- M && i(M, {
493
- pegin_txid: p,
494
- result: m.result,
495
- error: m.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 = F(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), F(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: V.from(e)
515
- });
516
- if (!i.output) return !1;
517
- const a = i.output, o = 0, l = new O();
518
- l.version = 0, l.locktime = 0;
519
- const d = V.concat([
520
- V.from([0, 32]),
521
- V.from(r)
522
- ]);
523
- l.addInput(
524
- V.alloc(32, 0),
525
- // prev_txid = 0x0000...0000
526
- 4294967295,
527
- // prev_vout = 0xFFFFFFFF
528
- 0,
529
- // sequence = 0
530
- d
531
- ), l.addOutput(a, o);
532
- const u = new O();
533
- u.version = 0, u.locktime = 0;
534
- const f = l.getHash();
535
- u.addInput(f, 0, 0), u.addOutput(V.from([106]), o);
536
- const w = u.hashForWitnessV1(
537
- 0,
538
- [a],
539
- [o],
540
- O.SIGHASH_DEFAULT
541
- ), x = He(e);
542
- return x ? N.verifySchnorr(w, x, 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 Oe = new TextEncoder().encode(
594
- "btc-auth.server-identity.v1"
595
- ), De = 2 * 3600;
596
- class g 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 Ue(n) {
608
- const { proof: e, pinnedServerPubkey: t, now: r } = n, i = n.maxLifetimeSecs ?? De, a = C(t).toLowerCase();
609
- if (a.length !== B || !S.test(a))
610
- throw new g(
611
- `pinnedServerPubkey must be 32-byte hex; got ${a.length} chars`,
612
- "invalid_pubkey_encoding"
613
- );
614
- const o = C(e.server_pubkey).toLowerCase();
615
- if (o.length !== B || !S.test(o))
616
- throw new g(
617
- `server_pubkey must be 32-byte hex; got ${o.length} chars`,
618
- "invalid_pubkey_encoding"
619
- );
620
- if (o !== a)
621
- throw new g(
622
- `server_pubkey does not match pinned value: expected ${a}, got ${o}`,
623
- "pinned_pubkey_mismatch"
624
- );
625
- if (!Number.isSafeInteger(e.expires_at))
626
- throw new g(
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 g(
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 g(
637
- `server identity proof expired at ${e.expires_at}, now ${r}`,
638
- "expired"
639
- );
640
- if (!Number.isSafeInteger(i) || i <= 0)
641
- throw new g(
642
- `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
643
- "invalid_max_lifetime"
644
- );
645
- if (e.expires_at - r > i)
646
- throw new g(
647
- `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${i}s`,
648
- "expires_too_far"
649
- );
650
- const l = C(e.ephemeral_pubkey).toLowerCase();
651
- if (l.length !== K || !S.test(l))
652
- throw new g(
653
- `ephemeral_pubkey must be 33-byte compressed hex; got ${l.length} chars`,
654
- "invalid_ephemeral_pubkey"
655
- );
656
- const d = l.slice(0, 2);
657
- if (d !== "02" && d !== "03")
658
- throw new g(
659
- `ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
660
- "invalid_ephemeral_pubkey"
661
- );
662
- const u = I(l);
663
- if (!N.isPoint(u))
664
- throw new g(
665
- "ephemeral_pubkey is not a valid secp256k1 point",
666
- "invalid_ephemeral_pubkey"
667
- );
668
- const f = C(e.signature).toLowerCase();
669
- if (f.length !== pe || !S.test(f))
670
- throw new g(
671
- `signature must be 64-byte Schnorr hex; got ${f.length} chars`,
672
- "invalid_signature_encoding"
673
- );
674
- const w = je(
675
- Oe,
676
- I(l),
677
- e.expires_at
678
- );
679
- if (!Ne(w, I(o), I(f)))
680
- throw new g(
681
- "BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
682
- "signature_verification_failed"
683
- );
684
- }
685
- const Ke = /* @__PURE__ */ new Set([
686
- "vaultProvider_submitDepositorWotsKey",
687
- "vaultProvider_submitDepositorPresignatures",
688
- "vaultProvider_requestDepositorPresignTransactions"
689
- ]), Le = 6e4, L = "auth_createDepositorToken";
690
- function ae(n, e) {
691
- return new Y({
692
- baseUrl: n,
693
- timeout: Le,
694
- headers: e,
695
- retryableFor: (t) => t === L
696
- });
697
- }
698
- const q = 4102444800, Me = 30;
699
- class Fe {
700
- constructor(e) {
701
- // `client` is the only mutable field — see `setClient`. The
702
- // identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
703
- // remain readonly and are checked against re-registration in the
704
- // registry's `getOrCreate`.
705
- h(this, "client");
706
- h(this, "peginTxid");
707
- h(this, "authAnchorHex");
708
- h(this, "pinnedServerPubkey");
709
- h(this, "authGatedMethods");
710
- h(this, "refreshSkewSecs");
711
- h(this, "now");
712
- h(this, "cached", null);
713
- h(this, "inFlight", null);
714
- 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));
715
- }
716
- /**
717
- * Return a bearer token for `method`, or `null` if `method` is not
718
- * auth-gated. Triggers a token acquisition if no token is cached or
719
- * the cached token is within {@link refreshSkewSecs} of expiry.
720
- *
721
- * The token-issuing method itself is hard-exempted from the gate —
722
- * if `auth_createDepositorToken` were ever included in
723
- * `authGatedMethods` (caller misconfiguration) the provider would
724
- * recurse into `acquireSingleFlight` from inside the JSON-RPC header
725
- * builder before `inFlight` is assigned, defeating the single-flight
726
- * guard. Returning `null` here breaks that recursion deterministically.
727
- */
728
- async getToken(e) {
729
- if (e === L || !this.authGatedMethods.has(e)) return null;
730
- const t = this.cached;
731
- return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight()).token;
732
- }
733
- /**
734
- * Drop the cached token. Next `getToken` call re-acquires.
735
- * Called by `JsonRpcClient` on wire `auth_expired` responses.
736
- */
737
- invalidate() {
738
- this.cached = null;
739
- }
740
- /**
741
- * Swap in a different transport for subsequent token-issuing calls.
742
- * Used by the registry when a later caller registers the same
743
- * `peginTxid` against a different `baseUrl` — the cached token
744
- * (bound to identity, not transport) stays valid, but future
745
- * refreshes hit the new URL. An in-flight acquire keeps using the
746
- * old client (it captured the reference); next call uses the new.
747
- */
748
- setClient(e) {
749
- this.client = e;
750
- }
751
- acquireSingleFlight() {
752
- const e = this.inFlight;
753
- if (e) return e;
754
- const t = (async () => {
755
- try {
756
- const r = await this.client.call(L, {
757
- pegin_txid: this.peginTxid,
758
- auth_anchor: this.authAnchorHex
759
- });
760
- if (Ue({
761
- proof: r.server_identity,
762
- pinnedServerPubkey: this.pinnedServerPubkey,
763
- now: this.now()
764
- }), typeof r.token != "string" || r.token.length === 0)
765
- throw new Error(
766
- `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
767
- );
768
- const i = this.now();
769
- if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= i || r.expires_at > q)
770
- throw new Error(
771
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${i}, ${q}])`
772
- );
773
- const a = {
774
- token: r.token,
775
- expiresAt: r.expires_at
776
- };
777
- return this.cached = a, a;
778
- } finally {
779
- this.inFlight = null;
780
- }
781
- })();
782
- return this.inFlight = t, t;
783
- }
784
- }
785
- class Ge {
786
- constructor() {
787
- h(this, "entries", /* @__PURE__ */ new Map());
788
- }
789
- /**
790
- * Return the cached `VpTokenProvider` for `peginTxid` if one exists
791
- * with matching `authAnchorHex` and `pinnedServerPubkey`, otherwise
792
- * construct and cache a fresh provider. A mismatch on either field
793
- * throws — silent overwrite would mask derivation drift or VP
794
- * pubkey rotation.
795
- */
796
- getOrCreate(e) {
797
- const t = this.entries.get(e.peginTxid);
798
- if (t) {
799
- if (t.authAnchorHex !== e.authAnchorHex)
800
- throw new Error(
801
- `VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${t.authAnchorHex.slice(0, 8)}…; got ${e.authAnchorHex.slice(0, 8)}…`
802
- );
803
- if (t.pinnedServerPubkey !== e.pinnedServerPubkey)
804
- throw new Error(
805
- `VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${t.pinnedServerPubkey.slice(0, 8)}…; got ${e.pinnedServerPubkey.slice(0, 8)}…`
806
- );
807
- return t.provider.setClient(e.client), t.provider;
808
- }
809
- const r = new Fe({
810
- client: e.client,
811
- peginTxid: e.peginTxid,
812
- authAnchorHex: e.authAnchorHex,
813
- pinnedServerPubkey: e.pinnedServerPubkey,
814
- authGatedMethods: Ke
815
- });
816
- return this.entries.set(e.peginTxid, {
817
- provider: r,
818
- authAnchorHex: e.authAnchorHex,
819
- pinnedServerPubkey: e.pinnedServerPubkey
820
- }), r;
821
- }
822
- /** Return the cached provider, or `undefined` if none. */
823
- peek(e) {
824
- var t;
825
- return (t = this.entries.get(e)) == null ? void 0 : t.provider;
826
- }
827
- /**
828
- * Evict the entry for `peginTxid`. Idempotent. Called on terminal
829
- * paths — activation success, user-cancel, or component unmount —
830
- * so `authAnchorHex` doesn't outlive the deposit session.
831
- */
832
- release(e) {
833
- this.entries.delete(e);
834
- }
835
- /**
836
- * Wipe every cached entry. Test-only escape hatch — not exposed on
837
- * the public {@link VpTokenRegistryPublic} singleton type.
838
- *
839
- * @internal
840
- */
841
- clear() {
842
- this.entries.clear();
843
- }
844
- get size() {
845
- return this.entries.size;
846
- }
847
- }
848
- const oe = new Ge();
849
- function nt(n) {
850
- var r;
851
- const e = ae(
852
- n.baseUrl,
853
- (r = n.options) == null ? void 0 : r.headers
854
- ), t = oe.getOrCreate({
855
- client: e,
856
- peginTxid: n.peginTxid,
857
- authAnchorHex: n.authAnchorHex,
858
- pinnedServerPubkey: n.pinnedServerPubkey
859
- });
860
- return new Ce(n.baseUrl, {
861
- ...n.options,
862
- tokenProvider: t
863
- });
864
- }
865
- function rt(n) {
866
- oe.getOrCreate({
867
- client: ae(n.baseUrl, n.headers),
868
- peginTxid: n.peginTxid,
869
- authAnchorHex: n.authAnchorHex,
870
- pinnedServerPubkey: n.pinnedServerPubkey
871
- });
872
- }
873
- async function st(n, e) {
874
- const [t, r] = await n.multicall({
875
- contracts: [
876
- {
877
- address: e,
878
- abi: k,
879
- functionName: "protocolParams"
880
- },
881
- {
882
- address: e,
883
- abi: k,
884
- functionName: "applicationRegistry"
885
- }
886
- ],
887
- allowFailure: !1
888
- });
889
- return {
890
- protocolParams: t,
891
- applicationRegistry: r
892
- };
893
- }
894
- const W = 65535;
895
- function U(n) {
896
- return {
897
- timelockAssert: n.timelockAssert,
898
- timelockChallengeAssert: n.timelockChallengeAssert,
899
- securityCouncilKeys: [...n.securityCouncilKeys],
900
- councilQuorum: n.councilQuorum,
901
- feeRate: n.feeRate,
902
- babeTotalInstances: n.babeTotalInstances,
903
- babeInstancesToFinalize: n.babeInstancesToFinalize,
904
- minVpCommissionBps: n.minVpCommissionBps,
905
- tRefund: n.tRefund,
906
- tStale: n.tStale,
907
- minPeginFeeRate: n.minPeginFeeRate,
908
- proverProgramVersion: n.proverProgramVersion,
909
- minPrepeginDepth: n.minPrepeginDepth
910
- };
911
- }
912
- function z(n) {
913
- return {
914
- minimumPegInAmount: n.minimumPegInAmount,
915
- maxPegInAmount: n.maxPegInAmount,
916
- pegInAckTimeout: n.pegInAckTimeout,
917
- pegInActivationTimeout: n.pegInActivationTimeout,
918
- maxHtlcOutputCount: n.maxHtlcOutputCount
919
- };
920
- }
921
- function J(n) {
922
- if (n > BigInt(W))
923
- throw new Error(
924
- `timelockAssert value ${n} exceeds uint16 max (${W})`
925
- );
926
- return Number(n);
927
- }
928
- class it {
929
- constructor(e, t) {
930
- this.publicClient = e, this.contractAddress = t;
931
- }
932
- async getTBVProtocolParams() {
933
- const e = await this.publicClient.readContract({
934
- address: this.contractAddress,
935
- abi: b,
936
- functionName: "getTBVProtocolParams"
937
- });
938
- return z(e);
939
- }
940
- async getLatestOffchainParams() {
941
- const e = await this.publicClient.readContract({
942
- address: this.contractAddress,
943
- abi: b,
944
- functionName: "getLatestOffchainParams"
945
- });
946
- return U(e);
947
- }
948
- async getOffchainParamsByVersion(e) {
949
- const t = await this.publicClient.readContract({
950
- address: this.contractAddress,
951
- abi: b,
952
- functionName: "getOffchainParamsByVersion",
953
- args: [e]
954
- });
955
- return U(t);
956
- }
957
- async getLatestOffchainParamsVersion() {
958
- return await this.publicClient.readContract({
959
- address: this.contractAddress,
960
- abi: b,
961
- functionName: "latestOffchainParamsVersion"
962
- });
963
- }
964
- async getTimelockPeginByVersion(e) {
965
- const t = await this.getOffchainParamsByVersion(e);
966
- return J(t.timelockAssert);
967
- }
968
- /**
969
- * Read TBV protocol params and latest offchain params atomically via multicall.
970
- * Prevents TOCTOU inconsistency if governance updates params between reads.
971
- */
972
- async getPegInConfiguration() {
973
- const e = await this.publicClient.multicall({
974
- contracts: [
975
- {
976
- address: this.contractAddress,
977
- abi: b,
978
- functionName: "getTBVProtocolParams"
979
- },
980
- {
981
- address: this.contractAddress,
982
- abi: b,
983
- functionName: "getLatestOffchainParams"
984
- }
985
- ],
986
- allowFailure: !1
987
- }), t = z(e[0]), r = U(e[1]);
988
- return {
989
- minimumPegInAmount: t.minimumPegInAmount,
990
- maxPegInAmount: t.maxPegInAmount,
991
- pegInAckTimeout: t.pegInAckTimeout,
992
- pegInActivationTimeout: t.pegInActivationTimeout,
993
- maxHtlcOutputCount: t.maxHtlcOutputCount,
994
- timelockPegin: J(r.timelockAssert),
995
- timelockRefund: r.tRefund,
996
- minVpCommissionBps: r.minVpCommissionBps,
997
- offchainParams: r
998
- };
999
- }
1000
- }
1001
- function H(n) {
1002
- return n.map((e) => ({
1003
- ethAddress: e.ethAddress,
1004
- btcPubKey: e.btcPubKey
1005
- }));
1006
- }
1007
- class at {
1008
- constructor(e, t) {
1009
- this.publicClient = e, this.contractAddress = t;
1010
- }
1011
- async getVaultKeepersByVersion(e, t) {
1012
- const r = await this.publicClient.readContract({
1013
- address: this.contractAddress,
1014
- abi: D,
1015
- functionName: "getVaultKeepersByVersion",
1016
- args: [e, t]
1017
- });
1018
- return H(r);
1019
- }
1020
- async getCurrentVaultKeepers(e) {
1021
- const t = await this.publicClient.readContract({
1022
- address: this.contractAddress,
1023
- abi: D,
1024
- functionName: "getCurrentVaultKeepers",
1025
- args: [e]
1026
- });
1027
- return H(t);
1028
- }
1029
- async getCurrentVaultKeepersVersion(e) {
1030
- return await this.publicClient.readContract({
1031
- address: this.contractAddress,
1032
- abi: D,
1033
- functionName: "getCurrentVaultKeepersVersion",
1034
- args: [e]
1035
- });
1036
- }
1037
- }
1038
- class ot {
1039
- constructor(e, t) {
1040
- this.publicClient = e, this.contractAddress = t;
1041
- }
1042
- async getUniversalChallengersByVersion(e) {
1043
- const t = await this.publicClient.readContract({
1044
- address: this.contractAddress,
1045
- abi: b,
1046
- functionName: "getUniversalChallengersByVersion",
1047
- args: [e]
1048
- });
1049
- return H(t);
1050
- }
1051
- async getCurrentUniversalChallengers() {
1052
- const e = await this.publicClient.readContract({
1053
- address: this.contractAddress,
1054
- abi: b,
1055
- functionName: "getCurrentUniversalChallengers"
1056
- });
1057
- return H(e);
1058
- }
1059
- async getLatestUniversalChallengersVersion() {
1060
- return await this.publicClient.readContract({
1061
- address: this.contractAddress,
1062
- abi: b,
1063
- functionName: "latestUniversalChallengersVersion"
1064
- });
1065
- }
1066
- }
1067
- class ct {
1068
- constructor(e, t) {
1069
- this.publicClient = e, this.contractAddress = t;
1070
- }
1071
- /**
1072
- * Read the VP's persistent x-only BTC pubkey from the on-chain
1073
- * registry. Validates length, hex form, and secp256k1 curve
1074
- * membership before minting the brand. Returns 64-char lowercase
1075
- * hex without the `0x` prefix.
1076
- */
1077
- async getVaultProviderBtcPubKey(e) {
1078
- const r = (await this.publicClient.readContract({
1079
- address: this.contractAddress,
1080
- abi: k,
1081
- functionName: "getVaultProviderBTCKey",
1082
- args: [e]
1083
- })).toLowerCase();
1084
- if (!/^0x[0-9a-f]{64}$/.test(r))
1085
- throw new Error(
1086
- `getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0, 2)}")`
1087
- );
1088
- const i = r.slice(2);
1089
- if (!N.isXOnlyPoint(he(i)))
1090
- throw new Error(
1091
- `getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`
1092
- );
1093
- return i;
1094
- }
1095
- async getVaultBasicInfo(e) {
1096
- const t = await this.publicClient.readContract({
1097
- address: this.contractAddress,
1098
- abi: k,
1099
- functionName: "getBtcVaultBasicInfo",
1100
- args: [e]
1101
- });
1102
- return {
1103
- depositor: t.depositor,
1104
- depositorBtcPubKey: t.depositorBtcPubKey,
1105
- amount: t.amount,
1106
- vaultProvider: t.vaultProvider,
1107
- status: t.status,
1108
- applicationEntryPoint: t.applicationEntryPoint,
1109
- createdAt: t.createdAt
1110
- };
1111
- }
1112
- async getVaultProtocolInfo(e) {
1113
- const t = await this.publicClient.readContract({
1114
- address: this.contractAddress,
1115
- abi: k,
1116
- functionName: "getBtcVaultProtocolInfo",
1117
- args: [e]
1118
- });
1119
- return {
1120
- depositorSignedPeginTx: t.depositorSignedPeginTx,
1121
- universalChallengersVersion: t.universalChallengersVersion,
1122
- appVaultKeepersVersion: t.appVaultKeepersVersion,
1123
- offchainParamsVersion: t.offchainParamsVersion,
1124
- verifiedAt: t.verifiedAt,
1125
- depositorWotsPkHash: t.depositorWotsPkHash,
1126
- hashlock: t.hashlock,
1127
- htlcVout: t.htlcVout,
1128
- depositorPopSignature: t.depositorPopSignature,
1129
- prePeginTxHash: t.prePeginTxHash,
1130
- vaultProviderCommissionBps: t.vaultProviderCommissionBps
1131
- };
1132
- }
1133
- async getVaultData(e) {
1134
- const [t, r] = await Promise.all([
1135
- this.getVaultBasicInfo(e),
1136
- this.getVaultProtocolInfo(e)
1137
- ]);
1138
- if (!r.depositorSignedPeginTx || r.depositorSignedPeginTx === "0x")
1139
- throw new Error(
1140
- `Vault ${e} not found on-chain or has no pegin transaction`
1141
- );
1142
- return { basic: t, protocol: r };
1143
- }
1144
- }
1145
- export {
1146
- g as S,
1147
- Ce as V,
1148
- s as a,
1149
- tt as b,
1150
- Ue as c,
1151
- Ge as d,
1152
- oe as e,
1153
- nt as f,
1154
- it as g,
1155
- ot as h,
1156
- at as i,
1157
- ct as j,
1158
- rt as p,
1159
- st as r,
1160
- xe as v
1161
- };
1162
- //# sourceMappingURL=vault-registry-reader-PsSxB0JZ.js.map