@babylonlabs-io/ts-sdk 0.33.3 → 0.33.4

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 (132) hide show
  1. package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js +417 -0
  2. package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js.map +1 -0
  3. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs +2 -0
  4. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs.map +1 -0
  5. package/dist/PayoutManager-C9XHKZ5j.js +200 -0
  6. package/dist/PayoutManager-C9XHKZ5j.js.map +1 -0
  7. package/dist/PayoutManager-DDnNB0mj.cjs +2 -0
  8. package/dist/PayoutManager-DDnNB0mj.cjs.map +1 -0
  9. package/dist/PeginManager-BXg2S1mH.cjs +2 -0
  10. package/dist/PeginManager-BXg2S1mH.cjs.map +1 -0
  11. package/dist/{PeginManager-C-L3huRO.js → PeginManager-C5HaMAcw.js} +328 -437
  12. package/dist/PeginManager-C5HaMAcw.js.map +1 -0
  13. package/dist/ProtocolParams.abi-BmvHwQJV.cjs +2 -0
  14. package/dist/ProtocolParams.abi-BmvHwQJV.cjs.map +1 -0
  15. package/dist/ProtocolParams.abi-DXu8L0Fn.js +382 -0
  16. package/dist/ProtocolParams.abi-DXu8L0Fn.js.map +1 -0
  17. package/dist/buildAndBroadcastRefund-CIPPpchL.cjs +2 -0
  18. package/dist/buildAndBroadcastRefund-CIPPpchL.cjs.map +1 -0
  19. package/dist/buildAndBroadcastRefund-D_QlvCsw.js +777 -0
  20. package/dist/buildAndBroadcastRefund-D_QlvCsw.js.map +1 -0
  21. package/dist/challengeAssert-BzxQmdZy.js +128 -0
  22. package/dist/challengeAssert-BzxQmdZy.js.map +1 -0
  23. package/dist/challengeAssert-Yyyj-EdR.cjs +2 -0
  24. package/dist/challengeAssert-Yyyj-EdR.cjs.map +1 -0
  25. package/dist/errors-9AkghWyk.js +22 -0
  26. package/dist/errors-9AkghWyk.js.map +1 -0
  27. package/dist/errors-BP73_stm.cjs +2 -0
  28. package/dist/errors-BP73_stm.cjs.map +1 -0
  29. package/dist/errors-Bu0H-dZD.cjs +2 -0
  30. package/dist/errors-Bu0H-dZD.cjs.map +1 -0
  31. package/dist/errors-CznAK5NB.js +96 -0
  32. package/dist/errors-CznAK5NB.js.map +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +156 -146
  35. package/dist/index.js.map +1 -1
  36. package/dist/mempoolApi-CAIge7Nj.js +205 -0
  37. package/dist/mempoolApi-CAIge7Nj.js.map +1 -0
  38. package/dist/mempoolApi-YNkKjQCU.cjs +2 -0
  39. package/dist/mempoolApi-YNkKjQCU.cjs.map +1 -0
  40. package/dist/noPayout-BXeUw0Qq.cjs +2 -0
  41. package/dist/noPayout-BXeUw0Qq.cjs.map +1 -0
  42. package/dist/noPayout-DBX6G96_.js +141 -0
  43. package/dist/noPayout-DBX6G96_.js.map +1 -0
  44. package/dist/payout-BNFMBXS6.js +193 -0
  45. package/dist/payout-BNFMBXS6.js.map +1 -0
  46. package/dist/payout-DQ_fmJUA.cjs +2 -0
  47. package/dist/payout-DQ_fmJUA.cjs.map +1 -0
  48. package/dist/peginInput-C2QPvuhR.js +177 -0
  49. package/dist/peginInput-C2QPvuhR.js.map +1 -0
  50. package/dist/peginInput-tbw9BpZy.cjs +2 -0
  51. package/dist/peginInput-tbw9BpZy.cjs.map +1 -0
  52. package/dist/peginState-BijNNT15.cjs +2 -0
  53. package/dist/peginState-BijNNT15.cjs.map +1 -0
  54. package/dist/peginState-CBAlxgXk.js +51 -0
  55. package/dist/peginState-CBAlxgXk.js.map +1 -0
  56. package/dist/psbtInputFields-2224j2ZY.js +128 -0
  57. package/dist/psbtInputFields-2224j2ZY.js.map +1 -0
  58. package/dist/psbtInputFields-B1lrwYzH.cjs +2 -0
  59. package/dist/psbtInputFields-B1lrwYzH.cjs.map +1 -0
  60. package/dist/reservation-CHUGW0F_.js +142 -0
  61. package/dist/reservation-CHUGW0F_.js.map +1 -0
  62. package/dist/reservation-ho7mjW3X.cjs +2 -0
  63. package/dist/reservation-ho7mjW3X.cjs.map +1 -0
  64. package/dist/signing-Bnsro0hE.cjs +2 -0
  65. package/dist/signing-Bnsro0hE.cjs.map +1 -0
  66. package/dist/signing-DaLvGwQe.js +16 -0
  67. package/dist/signing-DaLvGwQe.js.map +1 -0
  68. package/dist/tbv/core/clients/index.cjs +1 -1
  69. package/dist/tbv/core/clients/index.js +31 -30
  70. package/dist/tbv/core/clients/index.js.map +1 -1
  71. package/dist/tbv/core/contracts/index.cjs +2 -0
  72. package/dist/tbv/core/contracts/index.cjs.map +1 -0
  73. package/dist/tbv/core/contracts/index.js +14 -0
  74. package/dist/tbv/core/contracts/index.js.map +1 -0
  75. package/dist/tbv/core/index.cjs +1 -1
  76. package/dist/tbv/core/index.js +156 -146
  77. package/dist/tbv/core/index.js.map +1 -1
  78. package/dist/tbv/core/managers/index.cjs +2 -0
  79. package/dist/tbv/core/managers/index.cjs.map +1 -0
  80. package/dist/tbv/core/managers/index.js +7 -0
  81. package/dist/tbv/core/managers/index.js.map +1 -0
  82. package/dist/tbv/core/primitives/index.cjs +1 -1
  83. package/dist/tbv/core/primitives/index.js +31 -29
  84. package/dist/tbv/core/primitives/index.js.map +1 -1
  85. package/dist/tbv/core/services/index.cjs +1 -1
  86. package/dist/tbv/core/services/index.js +28 -27
  87. package/dist/tbv/core/services/index.js.map +1 -1
  88. package/dist/tbv/core/utils/index.cjs +1 -1
  89. package/dist/tbv/core/utils/index.js +21 -20
  90. package/dist/tbv/core/utils/index.js.map +1 -1
  91. package/dist/tbv/index.cjs +1 -1
  92. package/dist/tbv/index.js +156 -146
  93. package/dist/tbv/index.js.map +1 -1
  94. package/dist/types-ByW6nSLj.js +318 -0
  95. package/dist/types-ByW6nSLj.js.map +1 -0
  96. package/dist/types-CfCZyfid.cjs +2 -0
  97. package/dist/types-CfCZyfid.cjs.map +1 -0
  98. package/dist/vault-registry-reader-OK2V08tk.cjs +2 -0
  99. package/dist/vault-registry-reader-OK2V08tk.cjs.map +1 -0
  100. package/dist/{vault-registry-reader-CWGbw_wZ.js → vault-registry-reader-WiNVOsnD.js} +263 -840
  101. package/dist/vault-registry-reader-WiNVOsnD.js.map +1 -0
  102. package/package.json +11 -1
  103. package/dist/PeginManager-C-L3huRO.js.map +0 -1
  104. package/dist/PeginManager-DmPmzPHz.cjs +0 -2
  105. package/dist/PeginManager-DmPmzPHz.cjs.map +0 -1
  106. package/dist/buildAndBroadcastRefund-Dx09Zbla.js +0 -965
  107. package/dist/buildAndBroadcastRefund-Dx09Zbla.js.map +0 -1
  108. package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs +0 -2
  109. package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs.map +0 -1
  110. package/dist/challengeAssert-D3tHnLWb.js +0 -298
  111. package/dist/challengeAssert-D3tHnLWb.js.map +0 -1
  112. package/dist/challengeAssert-Dp9d1bg1.cjs +0 -2
  113. package/dist/challengeAssert-Dp9d1bg1.cjs.map +0 -1
  114. package/dist/noPayout-BnsetBKW.js +0 -327
  115. package/dist/noPayout-BnsetBKW.js.map +0 -1
  116. package/dist/noPayout-DWaCtpMU.cjs +0 -2
  117. package/dist/noPayout-DWaCtpMU.cjs.map +0 -1
  118. package/dist/psbtInputFields-6sRcZqdb.cjs +0 -2
  119. package/dist/psbtInputFields-6sRcZqdb.cjs.map +0 -1
  120. package/dist/psbtInputFields-C5QPn1YK.js +0 -264
  121. package/dist/psbtInputFields-C5QPn1YK.js.map +0 -1
  122. package/dist/signing-BZigafm0.js +0 -64
  123. package/dist/signing-BZigafm0.js.map +0 -1
  124. package/dist/signing-DHSXjhLM.cjs +0 -2
  125. package/dist/signing-DHSXjhLM.cjs.map +0 -1
  126. package/dist/types-PthVHz5q.cjs +0 -2
  127. package/dist/types-PthVHz5q.cjs.map +0 -1
  128. package/dist/types-SYvSQWnc.js +0 -732
  129. package/dist/types-SYvSQWnc.js.map +0 -1
  130. package/dist/vault-registry-reader-CKe9TbX6.cjs +0 -2
  131. package/dist/vault-registry-reader-CKe9TbX6.cjs.map +0 -1
  132. package/dist/vault-registry-reader-CWGbw_wZ.js.map +0 -1
@@ -1,840 +1,274 @@
1
- var oe = Object.defineProperty;
2
- var ce = (n, e, t) => e in n ? oe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var l = (n, e, t) => ce(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as le, H as f, K as ue, T as pe } from "./validation-CxqROCno.js";
5
- import { D as de, J as G, B as b } from "./types-SYvSQWnc.js";
6
- import { X as v, C as F, s as _, S as he, h as me } from "./bitcoin-B0S8SHCX.js";
7
- import * as $ from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- import { payments as ye, Transaction as I } from "bitcoinjs-lib";
9
- import { Buffer as y } from "buffer";
10
- import { s as K } from "./sha2-6wN58S6R.js";
11
- const fe = 21e6 * 1e8, U = 3e4;
12
- async function k(n, e) {
13
- const t = new AbortController(), r = setTimeout(
14
- () => t.abort(),
15
- U
16
- ), a = [t.signal, e == null ? void 0 : e.signal].filter(
17
- Boolean
18
- );
19
- try {
20
- return await fetch(n, {
21
- ...e,
22
- signal: AbortSignal.any(a)
23
- });
24
- } catch (s) {
25
- throw clearTimeout(r), s != null && typeof s == "object" && "name" in s && s.name === "AbortError" ? new Error(
26
- `Mempool API request timed out after ${U}ms: ${n}`
27
- ) : s;
28
- }
29
- }
30
- const W = 1e4;
31
- function J(n) {
32
- return Number.isInteger(n) && n > 0 && n <= fe;
33
- }
34
- function ge(n) {
35
- return Number.isInteger(n) && n > 0 && n <= W;
36
- }
37
- function z(n, e) {
38
- return !Number.isInteger(n) || n < 0 ? !1 : e === void 0 || n < e;
39
- }
40
- function C(n) {
41
- if (!pe.test(n))
42
- throw new Error(`Invalid transaction ID format: ${n}`);
43
- }
44
- function Y(n) {
45
- if (!le.test(n))
46
- throw new Error(`Invalid Bitcoin address format: ${n}`);
47
- }
48
- function Q(n, e) {
49
- if (!f.test(n))
50
- throw new Error(
51
- `Invalid scriptPubKey: not valid hex for ${e}`
52
- );
53
- if (!ue.some(
54
- (r) => n.toLowerCase().startsWith(r)
55
- ))
56
- throw new Error(
57
- `Unrecognized scriptPubKey type for ${e}: prefix ${n.slice(0, 6)} does not match any known Bitcoin script type`
58
- );
59
- }
60
- const be = {
61
- mainnet: "https://mempool.space/api",
62
- testnet: "https://mempool.space/testnet/api",
63
- signet: "https://mempool.space/signet/api"
64
- };
65
- async function T(n, e) {
66
- try {
67
- const t = await k(n, e);
68
- if (!t.ok) {
69
- const a = await t.text();
70
- throw new Error(
71
- `Mempool API error (${t.status}): ${a || t.statusText}`
72
- );
73
- }
74
- const r = t.headers.get("content-type");
75
- return r != null && r.includes("application/json") ? await t.json() : await t.text();
76
- } catch (t) {
77
- throw t instanceof Error ? new Error(`Failed to fetch from mempool API: ${t.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
78
- }
79
- }
80
- async function Ze(n, e) {
81
- try {
82
- const t = await k(`${e}/tx`, {
83
- method: "POST",
84
- body: n,
85
- headers: {
86
- "Content-Type": "text/plain"
87
- }
88
- });
89
- if (!t.ok) {
90
- const a = await t.text();
91
- let s;
92
- try {
93
- s = JSON.parse(a).message;
94
- } catch {
95
- s = a;
96
- }
97
- throw new Error(
98
- s || `Failed to broadcast transaction: ${t.statusText}`
99
- );
100
- }
101
- return await t.text();
102
- } catch (t) {
103
- throw t instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${t.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
104
- }
105
- }
106
- async function we(n, e) {
107
- return C(n), T(`${e}/tx/${n}`);
108
- }
109
- async function et(n, e) {
110
- C(n);
111
- try {
112
- const t = await k(`${e}/tx/${n}/hex`);
113
- if (!t.ok) {
114
- const r = await t.text();
115
- throw new Error(
116
- `Mempool API error (${t.status}): ${r || t.statusText}`
117
- );
118
- }
119
- return await t.text();
120
- } catch (t) {
121
- throw t instanceof Error ? new Error(`Failed to get transaction hex for ${n}: ${t.message}`) : new Error(`Failed to get transaction hex for ${n}: Unknown error`);
122
- }
123
- }
124
- async function tt(n, e, t) {
125
- C(n);
126
- const r = await we(n, t);
127
- if (!z(e, r.vout.length))
128
- throw new Error(
129
- `Invalid vout ${e} for transaction ${n} (has ${r.vout.length} outputs)`
130
- );
131
- const a = r.vout[e];
132
- if (!J(a.value))
133
- throw new Error(`Invalid UTXO value ${a.value} for ${n}:${e}`);
134
- return Q(a.scriptpubkey, `${n}:${e}`), {
135
- txid: n,
136
- vout: e,
137
- value: a.value,
138
- scriptPubKey: a.scriptpubkey
139
- };
140
- }
141
- async function nt(n, e) {
142
- Y(n);
143
- try {
144
- const t = await T(`${e}/address/${n}/utxo`), r = await T(`${e}/v1/validate-address/${n}`);
145
- if (!r.isvalid)
146
- throw new Error(
147
- `Invalid Bitcoin address: ${n}. Mempool API validation failed.`
148
- );
149
- Q(r.scriptPubKey, n);
150
- for (const s of t) {
151
- if (C(s.txid), !z(s.vout))
152
- throw new Error(`Invalid vout ${s.vout} for ${s.txid}`);
153
- if (!J(s.value))
154
- throw new Error(
155
- `Invalid UTXO value ${s.value} for ${s.txid}:${s.vout}`
156
- );
157
- }
158
- return t.sort((s, c) => c.value - s.value).map((s) => ({
159
- txid: s.txid,
160
- vout: s.vout,
161
- value: s.value,
162
- scriptPubKey: r.scriptPubKey,
163
- confirmed: s.status.confirmed
164
- }));
165
- } catch (t) {
166
- throw t instanceof Error ? new Error(
167
- `Failed to get UTXOs for address ${n}: ${t.message}`
168
- ) : new Error(
169
- `Failed to get UTXOs for address ${n}: Unknown error`
170
- );
171
- }
172
- }
173
- function rt(n) {
174
- return be[n];
175
- }
176
- async function st(n, e) {
177
- return Y(n), T(`${e}/address/${n}/txs`);
178
- }
179
- async function at(n) {
180
- const e = await k(`${n}/v1/fees/recommended`);
181
- if (!e.ok)
182
- throw new Error(
183
- `Failed to fetch network fees: ${e.status} ${e.statusText}`
184
- );
185
- const t = await e.json(), r = [
186
- "fastestFee",
187
- "halfHourFee",
188
- "hourFee",
189
- "economyFee",
190
- "minimumFee"
191
- ];
192
- for (const a of r)
193
- if (!ge(t[a]))
194
- throw new Error(
195
- `Invalid fee rate ${a}=${t[a]} from mempool API: expected a positive number ≤ ${W}`
196
- );
197
- if (t.minimumFee > t.economyFee || t.economyFee > t.hourFee || t.hourFee > t.halfHourFee || t.halfHourFee > t.fastestFee)
198
- throw new Error(
199
- `Fee rate ordering violation from mempool API: expected minimumFee (${t.minimumFee}) <= economyFee (${t.economyFee}) <= hourFee (${t.hourFee}) <= halfHourFee (${t.halfHourFee}) <= fastestFee (${t.fastestFee}).`
200
- );
201
- return t;
202
- }
203
- const B = [
204
- {
205
- type: "function",
206
- name: "getVaultKeepersByVersion",
207
- inputs: [
208
- {
209
- name: "appEntryPoint",
210
- type: "address",
211
- internalType: "address"
212
- },
213
- {
214
- name: "versionNumber",
215
- type: "uint16",
216
- internalType: "uint16"
217
- }
218
- ],
219
- outputs: [
220
- {
221
- name: "",
222
- type: "tuple[]",
223
- internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
224
- components: [
225
- {
226
- name: "ethAddress",
227
- type: "address",
228
- internalType: "address"
229
- },
230
- {
231
- name: "btcPubKey",
232
- type: "bytes32",
233
- internalType: "bytes32"
234
- }
235
- ]
236
- }
237
- ],
238
- stateMutability: "view"
239
- },
240
- {
241
- type: "function",
242
- name: "getCurrentVaultKeepers",
243
- inputs: [
244
- {
245
- name: "appEntryPoint",
246
- type: "address",
247
- internalType: "address"
248
- }
249
- ],
250
- outputs: [
251
- {
252
- name: "",
253
- type: "tuple[]",
254
- internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
255
- components: [
256
- {
257
- name: "ethAddress",
258
- type: "address",
259
- internalType: "address"
260
- },
261
- {
262
- name: "btcPubKey",
263
- type: "bytes32",
264
- internalType: "bytes32"
265
- }
266
- ]
267
- }
268
- ],
269
- stateMutability: "view"
270
- },
271
- {
272
- type: "function",
273
- name: "getCurrentVaultKeepersVersion",
274
- inputs: [
275
- {
276
- name: "appEntryPoint",
277
- type: "address",
278
- internalType: "address"
279
- }
280
- ],
281
- outputs: [
282
- {
283
- name: "",
284
- type: "uint16",
285
- internalType: "uint16"
286
- }
287
- ],
288
- stateMutability: "view"
289
- }
290
- ], h = [
291
- {
292
- type: "function",
293
- name: "getTBVProtocolParams",
294
- inputs: [],
295
- outputs: [
296
- {
297
- name: "",
298
- type: "tuple",
299
- internalType: "struct IProtocolParams.TBVProtocolParams",
300
- components: [
301
- {
302
- name: "minimumPegInAmount",
303
- type: "uint64",
304
- internalType: "uint64"
305
- },
306
- {
307
- name: "maxPegInAmount",
308
- type: "uint64",
309
- internalType: "uint64"
310
- },
311
- {
312
- name: "pegInAckTimeout",
313
- type: "uint64",
314
- internalType: "uint64"
315
- },
316
- {
317
- name: "pegInActivationTimeout",
318
- type: "uint64",
319
- internalType: "uint64"
320
- },
321
- {
322
- name: "maxHtlcOutputCount",
323
- type: "uint8",
324
- internalType: "uint8"
325
- }
326
- ]
327
- }
328
- ],
329
- stateMutability: "view"
330
- },
331
- {
332
- type: "function",
333
- name: "getLatestOffchainParams",
334
- inputs: [],
335
- outputs: [
336
- {
337
- name: "",
338
- type: "tuple",
339
- internalType: "struct IProtocolParams.VersionedOffchainParams",
340
- components: [
341
- {
342
- name: "timelockAssert",
343
- type: "uint256",
344
- internalType: "uint256"
345
- },
346
- {
347
- name: "timelockChallengeAssert",
348
- type: "uint256",
349
- internalType: "uint256"
350
- },
351
- {
352
- name: "securityCouncilKeys",
353
- type: "bytes32[]",
354
- internalType: "bytes32[]"
355
- },
356
- {
357
- name: "councilQuorum",
358
- type: "uint8",
359
- internalType: "uint8"
360
- },
361
- {
362
- name: "feeRate",
363
- type: "uint64",
364
- internalType: "uint64"
365
- },
366
- {
367
- name: "babeTotalInstances",
368
- type: "uint16",
369
- internalType: "uint16"
370
- },
371
- {
372
- name: "babeInstancesToFinalize",
373
- type: "uint8",
374
- internalType: "uint8"
375
- },
376
- {
377
- name: "minVpCommissionBps",
378
- type: "uint16",
379
- internalType: "uint16"
380
- },
381
- {
382
- name: "tRefund",
383
- type: "uint32",
384
- internalType: "uint32"
385
- },
386
- {
387
- name: "tStale",
388
- type: "uint32",
389
- internalType: "uint32"
390
- },
391
- {
392
- name: "minPeginFeeRate",
393
- type: "uint64",
394
- internalType: "uint64"
395
- },
396
- {
397
- name: "proverProgramVersion",
398
- type: "uint16",
399
- internalType: "uint16"
400
- },
401
- {
402
- name: "minPrepeginDepth",
403
- type: "uint32",
404
- internalType: "uint32"
405
- }
406
- ]
407
- }
408
- ],
409
- stateMutability: "view"
410
- },
411
- {
412
- type: "function",
413
- name: "getOffchainParamsByVersion",
414
- inputs: [
415
- {
416
- name: "versionNumber",
417
- type: "uint16",
418
- internalType: "uint16"
419
- }
420
- ],
421
- outputs: [
422
- {
423
- name: "",
424
- type: "tuple",
425
- internalType: "struct IProtocolParams.VersionedOffchainParams",
426
- components: [
427
- {
428
- name: "timelockAssert",
429
- type: "uint256",
430
- internalType: "uint256"
431
- },
432
- {
433
- name: "timelockChallengeAssert",
434
- type: "uint256",
435
- internalType: "uint256"
436
- },
437
- {
438
- name: "securityCouncilKeys",
439
- type: "bytes32[]",
440
- internalType: "bytes32[]"
441
- },
442
- {
443
- name: "councilQuorum",
444
- type: "uint8",
445
- internalType: "uint8"
446
- },
447
- {
448
- name: "feeRate",
449
- type: "uint64",
450
- internalType: "uint64"
451
- },
452
- {
453
- name: "babeTotalInstances",
454
- type: "uint16",
455
- internalType: "uint16"
456
- },
457
- {
458
- name: "babeInstancesToFinalize",
459
- type: "uint8",
460
- internalType: "uint8"
461
- },
462
- {
463
- name: "minVpCommissionBps",
464
- type: "uint16",
465
- internalType: "uint16"
466
- },
467
- {
468
- name: "tRefund",
469
- type: "uint32",
470
- internalType: "uint32"
471
- },
472
- {
473
- name: "tStale",
474
- type: "uint32",
475
- internalType: "uint32"
476
- },
477
- {
478
- name: "minPeginFeeRate",
479
- type: "uint64",
480
- internalType: "uint64"
481
- },
482
- {
483
- name: "proverProgramVersion",
484
- type: "uint16",
485
- internalType: "uint16"
486
- },
487
- {
488
- name: "minPrepeginDepth",
489
- type: "uint32",
490
- internalType: "uint32"
491
- }
492
- ]
493
- }
494
- ],
495
- stateMutability: "view"
496
- },
497
- {
498
- type: "function",
499
- name: "latestOffchainParamsVersion",
500
- inputs: [],
501
- outputs: [
502
- {
503
- name: "",
504
- type: "uint16",
505
- internalType: "uint16"
506
- }
507
- ],
508
- stateMutability: "view"
509
- },
510
- {
511
- type: "function",
512
- name: "getUniversalChallengersByVersion",
513
- inputs: [
514
- {
515
- name: "versionNumber",
516
- type: "uint16",
517
- internalType: "uint16"
518
- }
519
- ],
520
- outputs: [
521
- {
522
- name: "",
523
- type: "tuple[]",
524
- internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
525
- components: [
526
- {
527
- name: "ethAddress",
528
- type: "address",
529
- internalType: "address"
530
- },
531
- {
532
- name: "btcPubKey",
533
- type: "bytes32",
534
- internalType: "bytes32"
535
- }
536
- ]
537
- }
538
- ],
539
- stateMutability: "view"
540
- },
541
- {
542
- type: "function",
543
- name: "getCurrentUniversalChallengers",
544
- inputs: [],
545
- outputs: [
546
- {
547
- name: "",
548
- type: "tuple[]",
549
- internalType: "struct BTCVaultTypes.AddressBTCKeyPair[]",
550
- components: [
551
- {
552
- name: "ethAddress",
553
- type: "address",
554
- internalType: "address"
555
- },
556
- {
557
- name: "btcPubKey",
558
- type: "bytes32",
559
- internalType: "bytes32"
560
- }
561
- ]
562
- }
563
- ],
564
- stateMutability: "view"
565
- },
566
- {
567
- type: "function",
568
- name: "latestUniversalChallengersVersion",
569
- inputs: [],
570
- outputs: [
571
- {
572
- name: "",
573
- type: "uint16",
574
- internalType: "uint16"
575
- }
576
- ],
577
- stateMutability: "view"
578
- }
579
- ], D = new Set(Object.values(de)), _e = 200;
1
+ var Z = Object.defineProperty;
2
+ var Q = (n, e, t) => e in n ? Z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var c = (n, e, t) => Q(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { D as ee, J as F } from "./types-ByW6nSLj.js";
5
+ import { X as v, C as I, s as w, S as te, h as ne } from "./bitcoin-B0S8SHCX.js";
6
+ import { H as _ } from "./validation-CxqROCno.js";
7
+ import * as k from "@bitcoin-js/tiny-secp256k1-asmjs";
8
+ import { payments as re, Transaction as C } from "bitcoinjs-lib";
9
+ import { Buffer as f } from "buffer";
10
+ import { s as H } from "./sha2-6wN58S6R.js";
11
+ import { B as y } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
12
+ import { P as h, A as $ } from "./ProtocolParams.abi-DXu8L0Fn.js";
13
+ const O = new Set(Object.values(ee)), se = 200;
580
14
  function o(n) {
581
15
  var e;
582
- return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0, _e)) ?? "undefined";
16
+ return ((e = JSON.stringify(n)) == null ? void 0 : e.slice(0, se)) ?? "undefined";
583
17
  }
584
- const Pe = "The vault provider returned an unexpected response. Please try again or contact support.";
585
- class i extends Error {
18
+ const ie = "The vault provider returned an unexpected response. Please try again or contact support.";
19
+ class s extends Error {
586
20
  constructor(t) {
587
- super(Pe);
588
- l(this, "detail");
21
+ super(ie);
22
+ c(this, "detail");
589
23
  this.name = "VpResponseValidationError", this.detail = t;
590
24
  }
591
25
  }
592
26
  const x = 64;
593
- function g(n) {
594
- return typeof n == "string" && n.length > 0 && f.test(n);
27
+ function m(n) {
28
+ return typeof n == "string" && n.length > 0 && _.test(n);
595
29
  }
596
- function Z(n) {
30
+ function M(n) {
597
31
  return typeof n == "string" && n.length > 0;
598
32
  }
599
- function ee(n, e) {
600
- if (!g(n))
601
- throw new i(
33
+ function X(n, e) {
34
+ if (!m(n))
35
+ throw new s(
602
36
  `VP response validation failed: "${e}" must be a non-empty hex string, got ${o(n)}`
603
37
  );
604
38
  }
605
- function w(n, e) {
606
- if (!Z(n))
607
- throw new i(
39
+ function b(n, e) {
40
+ if (!M(n))
41
+ throw new s(
608
42
  `VP response validation failed: "${e}" must be a non-empty string, got ${o(n)}`
609
43
  );
610
44
  }
611
- function te(n, e) {
612
- if (!g(n) || n.length !== v && n.length !== F)
613
- throw new i(
614
- `VP response validation failed: "${e}" must be a ${v} or ${F}-char hex string (BTC pubkey), got ${o(n)}`
45
+ function G(n, e) {
46
+ if (!m(n) || n.length !== v && n.length !== I)
47
+ throw new s(
48
+ `VP response validation failed: "${e}" must be a ${v} or ${I}-char hex string (BTC pubkey), got ${o(n)}`
615
49
  );
616
50
  }
617
- function ve(n) {
51
+ function ae(n) {
618
52
  const e = n.presigning;
619
53
  if (e == null) return;
620
54
  if (typeof e != "object" || Array.isArray(e))
621
- throw new i(
55
+ throw new s(
622
56
  'VP response validation failed: "progress.presigning" must be an object if present'
623
57
  );
624
58
  const t = e;
625
59
  if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
626
- throw new i(
60
+ throw new s(
627
61
  `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${o(t.depositor_graph_created)}`
628
62
  );
629
63
  if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
630
- throw new i(
64
+ throw new s(
631
65
  `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${o(t.vk_challenger_presigning_completed)}`
632
66
  );
633
67
  if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
634
- throw new i(
68
+ throw new s(
635
69
  `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${o(t.vk_challenger_presigning_total)}`
636
70
  );
637
71
  }
638
- function Te(n) {
72
+ function oe(n) {
639
73
  if (n === null || typeof n != "object")
640
- throw new i(
74
+ throw new s(
641
75
  "VP response validation failed: getPeginStatus response is not an object"
642
76
  );
643
77
  const e = n;
644
- if (!g(e.pegin_txid) || e.pegin_txid.length !== x)
645
- throw new i(
78
+ if (!m(e.pegin_txid) || e.pegin_txid.length !== x)
79
+ throw new s(
646
80
  `VP response validation failed: "pegin_txid" must be a ${x}-char hex string (txid), got ${o(e.pegin_txid)}`
647
81
  );
648
82
  if (typeof e.status != "string")
649
- throw new i(
83
+ throw new s(
650
84
  'VP response validation failed: "status" must be a string'
651
85
  );
652
- if (!D.has(e.status))
653
- throw new i(
654
- `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...D].join(", ")}`
86
+ if (!O.has(e.status))
87
+ throw new s(
88
+ `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...O].join(", ")}`
655
89
  );
656
90
  if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
657
- throw new i(
91
+ throw new s(
658
92
  'VP response validation failed: "progress" must be an object'
659
93
  );
660
- if (ve(e.progress), typeof e.health_info != "string")
661
- throw new i(
94
+ if (ae(e.progress), typeof e.health_info != "string")
95
+ throw new s(
662
96
  'VP response validation failed: "health_info" must be a string'
663
97
  );
664
98
  if (e.last_error !== void 0 && typeof e.last_error != "string")
665
- throw new i(
99
+ throw new s(
666
100
  `VP response validation failed: "last_error" must be a string if present, got ${o(e.last_error)}`
667
101
  );
668
102
  }
669
- function xe(n) {
103
+ function ce(n) {
670
104
  if (n === null || typeof n != "object")
671
- throw new i(
105
+ throw new s(
672
106
  "VP response validation failed: requestDepositorPresignTransactions response is not an object"
673
107
  );
674
108
  const e = n;
675
109
  if (!Array.isArray(e.txs))
676
- throw new i(
110
+ throw new s(
677
111
  'VP response validation failed: "txs" must be an array'
678
112
  );
679
113
  for (let t = 0; t < e.txs.length; t++)
680
- Ae(e.txs[t], `txs[${t}]`);
114
+ le(e.txs[t], `txs[${t}]`);
681
115
  if (e.depositor_graph === null || typeof e.depositor_graph != "object")
682
- throw new i(
116
+ throw new s(
683
117
  'VP response validation failed: "depositor_graph" must be an object'
684
118
  );
685
- Se(
119
+ ge(
686
120
  e.depositor_graph
687
121
  );
688
122
  }
689
- function m(n, e) {
123
+ function g(n, e) {
690
124
  if (n === null || typeof n != "object")
691
- throw new i(
125
+ throw new s(
692
126
  `VP response validation failed: "${e}" must be an object`
693
127
  );
694
- ee(n.tx_hex, `${e}.tx_hex`);
128
+ X(n.tx_hex, `${e}.tx_hex`);
695
129
  }
696
- function Ae(n, e) {
130
+ function le(n, e) {
697
131
  if (n === null || typeof n != "object")
698
- throw new i(
132
+ throw new s(
699
133
  `VP response validation failed: "${e}" must be an object`
700
134
  );
701
135
  const t = n;
702
- te(t.claimer_pubkey, `${e}.claimer_pubkey`), m(t.claim_tx, `${e}.claim_tx`), m(t.assert_tx, `${e}.assert_tx`), m(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
136
+ G(t.claimer_pubkey, `${e}.claimer_pubkey`), g(t.claim_tx, `${e}.claim_tx`), g(t.assert_tx, `${e}.assert_tx`), g(t.payout_tx, `${e}.payout_tx`), b(t.payout_psbt, `${e}.payout_psbt`);
703
137
  }
704
- function Ve(n, e) {
138
+ function ue(n, e) {
705
139
  if (n === null || typeof n != "object")
706
- throw new i(
140
+ throw new s(
707
141
  `VP response validation failed: "${e}" must be an object`
708
142
  );
709
143
  const t = n;
710
- w(t.wots_pks_json, `${e}.wots_pks_json`), w(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
144
+ b(t.wots_pks_json, `${e}.wots_pks_json`), b(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
711
145
  }
712
- function $e(n, e) {
146
+ function de(n, e) {
713
147
  if (n === null || typeof n != "object")
714
- throw new i(
148
+ throw new s(
715
149
  `VP response validation failed: "${e}" must be an object`
716
150
  );
717
151
  const t = n;
718
- if (te(t.challenger_pubkey, `${e}.challenger_pubkey`), m(
152
+ if (G(t.challenger_pubkey, `${e}.challenger_pubkey`), g(
719
153
  t.challenge_assert_x_tx,
720
154
  `${e}.challenge_assert_x_tx`
721
- ), m(
155
+ ), g(
722
156
  t.challenge_assert_y_tx,
723
157
  `${e}.challenge_assert_y_tx`
724
- ), m(t.nopayout_tx, `${e}.nopayout_tx`), w(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
725
- throw new i(
158
+ ), g(t.nopayout_tx, `${e}.nopayout_tx`), b(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
159
+ throw new s(
726
160
  `VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
727
161
  );
728
162
  for (let r = 0; r < t.challenge_assert_connectors.length; r++)
729
- Ve(
163
+ ue(
730
164
  t.challenge_assert_connectors[r],
731
165
  `${e}.challenge_assert_connectors[${r}]`
732
166
  );
733
167
  if (!Array.isArray(t.output_label_hashes))
734
- throw new i(
168
+ throw new s(
735
169
  `VP response validation failed: "${e}.output_label_hashes" must be an array`
736
170
  );
737
171
  for (let r = 0; r < t.output_label_hashes.length; r++)
738
- ee(
172
+ X(
739
173
  t.output_label_hashes[r],
740
174
  `${e}.output_label_hashes[${r}]`
741
175
  );
742
176
  }
743
- function ke(n) {
177
+ function pe(n) {
744
178
  if (n === null || typeof n != "object")
745
- throw new i(
179
+ throw new s(
746
180
  "VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
747
181
  );
748
182
  const e = n;
749
- if (!Z(e.tx_graph_json))
750
- throw new i(
183
+ if (!M(e.tx_graph_json))
184
+ throw new s(
751
185
  `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${o(e.tx_graph_json)}`
752
186
  );
753
- if (!g(e.verifying_key_hex))
754
- throw new i(
187
+ if (!m(e.verifying_key_hex))
188
+ throw new s(
755
189
  `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${o(e.verifying_key_hex)}`
756
190
  );
757
191
  if (e.babe_sessions === null || typeof e.babe_sessions != "object")
758
- throw new i(
192
+ throw new s(
759
193
  'VP response validation failed: "babe_sessions" must be an object'
760
194
  );
761
195
  for (const [t, r] of Object.entries(
762
196
  e.babe_sessions
763
197
  )) {
764
198
  if (r === null || typeof r != "object")
765
- throw new i(
199
+ throw new s(
766
200
  `VP response validation failed: "babe_sessions.${t}" must be an object`
767
201
  );
768
- const a = r;
769
- if (!g(a.decryptor_artifacts_hex))
770
- throw new i(
771
- `VP response validation failed: "babe_sessions.${t}.decryptor_artifacts_hex" must be a non-empty hex string, got ${o(a.decryptor_artifacts_hex)}`
202
+ const i = r;
203
+ if (!m(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 ${o(i.decryptor_artifacts_hex)}`
772
206
  );
773
207
  }
774
208
  }
775
- function Ce(n) {
209
+ function he(n) {
776
210
  if (n === null || typeof n != "object")
777
- throw new i(
211
+ throw new s(
778
212
  "VP response validation failed: getPegoutStatus response is not an object"
779
213
  );
780
214
  const e = n;
781
- if (!g(e.pegin_txid) || e.pegin_txid.length !== x)
782
- throw new i(
215
+ if (!m(e.pegin_txid) || e.pegin_txid.length !== x)
216
+ throw new s(
783
217
  `VP response validation failed: "pegin_txid" must be a ${x}-char hex string (txid), got ${o(e.pegin_txid)}`
784
218
  );
785
219
  if (typeof e.found != "boolean")
786
- throw new i(
220
+ throw new s(
787
221
  `VP response validation failed: "found" must be a boolean, got ${o(e.found)}`
788
222
  );
789
223
  if (e.claimer !== void 0) {
790
224
  if (e.claimer === null || typeof e.claimer != "object")
791
- throw new i(
225
+ throw new s(
792
226
  'VP response validation failed: "claimer" must be an object if present'
793
227
  );
794
228
  const t = e.claimer;
795
229
  if (typeof t.status != "string")
796
- throw new i(
230
+ throw new s(
797
231
  `VP response validation failed: "claimer.status" must be a string, got ${o(t.status)}`
798
232
  );
799
233
  if (typeof t.failed != "boolean")
800
- throw new i(
234
+ throw new s(
801
235
  `VP response validation failed: "claimer.failed" must be a boolean, got ${o(t.failed)}`
802
236
  );
803
237
  }
804
238
  if (e.challenger !== void 0) {
805
239
  if (e.challenger === null || typeof e.challenger != "object")
806
- throw new i(
240
+ throw new s(
807
241
  'VP response validation failed: "challenger" must be an object if present'
808
242
  );
809
243
  const t = e.challenger;
810
244
  if (typeof t.status != "string")
811
- throw new i(
245
+ throw new s(
812
246
  `VP response validation failed: "challenger.status" must be a string, got ${o(t.status)}`
813
247
  );
814
248
  }
815
249
  }
816
- function Se(n) {
817
- if (m(n.claim_tx, "depositor_graph.claim_tx"), m(n.assert_tx, "depositor_graph.assert_tx"), m(n.payout_tx, "depositor_graph.payout_tx"), w(n.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(n.challenger_presign_data))
818
- throw new i(
250
+ function ge(n) {
251
+ if (g(n.claim_tx, "depositor_graph.claim_tx"), g(n.assert_tx, "depositor_graph.assert_tx"), g(n.payout_tx, "depositor_graph.payout_tx"), b(n.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(n.challenger_presign_data))
252
+ throw new s(
819
253
  'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
820
254
  );
821
255
  for (let e = 0; e < n.challenger_presign_data.length; e++)
822
- $e(
256
+ de(
823
257
  n.challenger_presign_data[e],
824
258
  `depositor_graph.challenger_presign_data[${e}]`
825
259
  );
826
260
  if (typeof n.offchain_params_version != "number")
827
- throw new i(
261
+ throw new s(
828
262
  'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
829
263
  );
830
264
  }
831
- const Ee = 6e4;
832
- class Ie {
265
+ const fe = 6e4;
266
+ class me {
833
267
  constructor(e, t) {
834
- l(this, "client");
268
+ c(this, "client");
835
269
  const r = {
836
270
  baseUrl: e,
837
- timeout: (t == null ? void 0 : t.timeout) ?? Ee,
271
+ timeout: (t == null ? void 0 : t.timeout) ?? fe,
838
272
  retries: t == null ? void 0 : t.retries,
839
273
  retryDelay: t == null ? void 0 : t.retryDelay,
840
274
  retryableFor: t == null ? void 0 : t.retryableFor,
@@ -842,7 +276,7 @@ class Ie {
842
276
  tokenProvider: t == null ? void 0 : t.tokenProvider,
843
277
  maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
844
278
  };
845
- this.client = new G(r);
279
+ this.client = new F(r);
846
280
  }
847
281
  /**
848
282
  * Request the payout/claim/assert transactions that the depositor
@@ -850,7 +284,7 @@ class Ie {
850
284
  */
851
285
  async requestDepositorPresignTransactions(e, t) {
852
286
  const r = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
853
- return xe(r), r;
287
+ return ce(r), r;
854
288
  }
855
289
  /**
856
290
  * Submit the depositor's pre-signatures for the payout transactions
@@ -881,7 +315,7 @@ class Ie {
881
315
  */
882
316
  async requestDepositorClaimerArtifacts(e, t) {
883
317
  const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
884
- return ke(r), r;
318
+ return pe(r), r;
885
319
  }
886
320
  /** Get the current pegin status from the vault provider daemon. */
887
321
  async getPeginStatus(e, t) {
@@ -890,7 +324,7 @@ class Ie {
890
324
  e,
891
325
  t
892
326
  );
893
- return Te(r), r;
327
+ return oe(r), r;
894
328
  }
895
329
  /** Get the current pegout status from the vault provider daemon. */
896
330
  async getPegoutStatus(e, t) {
@@ -899,52 +333,52 @@ class Ie {
899
333
  e,
900
334
  t
901
335
  );
902
- return Ce(r), r;
336
+ return he(r), r;
903
337
  }
904
338
  }
905
- const Be = "BIP0322-signed-message", Re = "TapTweak", ne = 32, Fe = 64;
906
- function re(n, e) {
907
- const t = new TextEncoder().encode(n), r = K(t), a = new Uint8Array(r.length * 2 + e.length);
908
- return a.set(r, 0), a.set(r, r.length), a.set(e, r.length * 2), K(a);
339
+ const _e = "BIP0322-signed-message", ye = "TapTweak", q = 32, be = 64;
340
+ function W(n, e) {
341
+ const t = new TextEncoder().encode(n), r = H(t), i = new Uint8Array(r.length * 2 + e.length);
342
+ return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2), H(i);
909
343
  }
910
- function Oe(n) {
911
- if (n.length !== ne) return null;
912
- const e = re(Re, n), t = $.xOnlyPointAddTweak(n, e);
344
+ function we(n) {
345
+ if (n.length !== q) return null;
346
+ const e = W(ye, n), t = k.xOnlyPointAddTweak(n, e);
913
347
  return t ? t.xOnlyPubkey : null;
914
348
  }
915
- function Ne(n, e, t) {
916
- if (e.length !== ne || t.length !== Fe) return !1;
349
+ function Pe(n, e, t) {
350
+ if (e.length !== q || t.length !== be) return !1;
917
351
  try {
918
- const r = re(Be, n), a = ye.p2tr({
919
- internalPubkey: y.from(e)
352
+ const r = W(_e, n), i = re.p2tr({
353
+ internalPubkey: f.from(e)
920
354
  });
921
- if (!a.output) return !1;
922
- const s = a.output, c = 0, d = new I();
923
- d.version = 0, d.locktime = 0;
924
- const S = y.concat([
925
- y.from([0, 32]),
926
- y.from(r)
355
+ if (!i.output) return !1;
356
+ const a = i.output, l = 0, p = new C();
357
+ p.version = 0, p.locktime = 0;
358
+ const S = f.concat([
359
+ f.from([0, 32]),
360
+ f.from(r)
927
361
  ]);
928
- d.addInput(
929
- y.alloc(32, 0),
362
+ p.addInput(
363
+ f.alloc(32, 0),
930
364
  // prev_txid = 0x0000...0000
931
365
  4294967295,
932
366
  // prev_vout = 0xFFFFFFFF
933
367
  0,
934
368
  // sequence = 0
935
369
  S
936
- ), d.addOutput(s, c);
937
- const p = new I();
938
- p.version = 0, p.locktime = 0;
939
- const E = d.getHash();
940
- p.addInput(E, 0, 0), p.addOutput(y.from([106]), c);
941
- const N = p.hashForWitnessV1(
370
+ ), p.addOutput(a, l);
371
+ const d = new C();
372
+ d.version = 0, d.locktime = 0;
373
+ const T = p.getHash();
374
+ d.addInput(T, 0, 0), d.addOutput(f.from([106]), l);
375
+ const N = d.hashForWitnessV1(
942
376
  0,
943
- [s],
944
- [c],
945
- I.SIGHASH_DEFAULT
946
- ), H = Oe(e);
947
- return H ? $.verifySchnorr(N, H, t) : !1;
377
+ [a],
378
+ [l],
379
+ C.SIGHASH_DEFAULT
380
+ ), R = we(e);
381
+ return R ? k.verifySchnorr(N, R, t) : !1;
948
382
  } catch {
949
383
  return !1;
950
384
  }
@@ -955,47 +389,47 @@ function A(n, e) {
955
389
  if (r < 24n) return new Uint8Array([t | Number(r)]);
956
390
  if (r < 0x100n) return new Uint8Array([t | 24, Number(r)]);
957
391
  if (r < 0x10000n) {
958
- const s = Number(r);
959
- return new Uint8Array([t | 25, s >>> 8 & 255, s & 255]);
392
+ const a = Number(r);
393
+ return new Uint8Array([t | 25, a >>> 8 & 255, a & 255]);
960
394
  }
961
395
  if (r < 0x100000000n) {
962
- const s = Number(r);
396
+ const a = Number(r);
963
397
  return new Uint8Array([
964
398
  t | 26,
965
- s >>> 24 & 255,
966
- s >>> 16 & 255,
967
- s >>> 8 & 255,
968
- s & 255
399
+ a >>> 24 & 255,
400
+ a >>> 16 & 255,
401
+ a >>> 8 & 255,
402
+ a & 255
969
403
  ]);
970
404
  }
971
- const a = new Uint8Array(9);
972
- a[0] = t | 27;
973
- for (let s = 7; s >= 0; s--)
974
- a[1 + s] = Number(r >> BigInt((7 - s) * 8)) & 255;
975
- return a;
405
+ const i = new Uint8Array(9);
406
+ i[0] = t | 27;
407
+ for (let a = 7; a >= 0; a--)
408
+ i[1 + a] = Number(r >> BigInt((7 - a) * 8)) & 255;
409
+ return i;
976
410
  }
977
- function se(...n) {
978
- const e = n.reduce((a, s) => a + s.length, 0), t = new Uint8Array(e);
411
+ function J(...n) {
412
+ const e = n.reduce((i, a) => i + a.length, 0), t = new Uint8Array(e);
979
413
  let r = 0;
980
- for (const a of n)
981
- t.set(a, r), r += a.length;
414
+ for (const i of n)
415
+ t.set(i, r), r += i.length;
982
416
  return t;
983
417
  }
984
418
  function j(n) {
985
419
  const t = [A(4, n.length)];
986
420
  for (const r of n)
987
421
  t.push(A(0, r));
988
- return se(...t);
422
+ return J(...t);
989
423
  }
990
- function He(n, e, t) {
424
+ function ve(n, e, t) {
991
425
  if (!Number.isSafeInteger(t) || t < 0)
992
426
  throw new Error(
993
427
  `encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
994
428
  );
995
- const r = A(4, 3), a = j(n), s = j(e), c = A(0, t);
996
- return se(r, a, s, c);
429
+ const r = A(4, 3), i = j(n), a = j(e), l = A(0, t);
430
+ return J(r, i, a, l);
997
431
  }
998
- const Ke = new TextEncoder().encode(
432
+ const xe = new TextEncoder().encode(
999
433
  "btc-auth.server-identity.v1"
1000
434
  );
1001
435
  class u extends Error {
@@ -1009,22 +443,22 @@ function P(n) {
1009
443
  e[t] = parseInt(n.slice(t * 2, t * 2 + 2), 16);
1010
444
  return e;
1011
445
  }
1012
- function Ue(n) {
1013
- const { proof: e, pinnedServerPubkey: t, now: r } = n, a = _(t).toLowerCase();
1014
- if (a.length !== v || !f.test(a))
446
+ function Ae(n) {
447
+ const { proof: e, pinnedServerPubkey: t, now: r } = n, i = w(t).toLowerCase();
448
+ if (i.length !== v || !_.test(i))
1015
449
  throw new u(
1016
- `pinnedServerPubkey must be 32-byte hex; got ${a.length} chars`,
450
+ `pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,
1017
451
  "invalid_pubkey_encoding"
1018
452
  );
1019
- const s = _(e.server_pubkey).toLowerCase();
1020
- if (s.length !== v || !f.test(s))
453
+ const a = w(e.server_pubkey).toLowerCase();
454
+ if (a.length !== v || !_.test(a))
1021
455
  throw new u(
1022
- `server_pubkey must be 32-byte hex; got ${s.length} chars`,
456
+ `server_pubkey must be 32-byte hex; got ${a.length} chars`,
1023
457
  "invalid_pubkey_encoding"
1024
458
  );
1025
- if (s !== a)
459
+ if (a !== i)
1026
460
  throw new u(
1027
- `server_pubkey does not match pinned value: expected ${a}, got ${s}`,
461
+ `server_pubkey does not match pinned value: expected ${i}, got ${a}`,
1028
462
  "pinned_pubkey_mismatch"
1029
463
  );
1030
464
  if (!Number.isSafeInteger(e.expires_at))
@@ -1042,71 +476,71 @@ function Ue(n) {
1042
476
  `server identity proof expired at ${e.expires_at}, now ${r}`,
1043
477
  "expired"
1044
478
  );
1045
- const c = _(e.ephemeral_pubkey).toLowerCase();
1046
- if (c.length !== F || !f.test(c))
479
+ const l = w(e.ephemeral_pubkey).toLowerCase();
480
+ if (l.length !== I || !_.test(l))
1047
481
  throw new u(
1048
- `ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
482
+ `ephemeral_pubkey must be 33-byte compressed hex; got ${l.length} chars`,
1049
483
  "invalid_ephemeral_pubkey"
1050
484
  );
1051
- const d = c.slice(0, 2);
1052
- if (d !== "02" && d !== "03")
485
+ const p = l.slice(0, 2);
486
+ if (p !== "02" && p !== "03")
1053
487
  throw new u(
1054
- `ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
488
+ `ephemeral_pubkey must be compressed (prefix 02/03); got ${p}`,
1055
489
  "invalid_ephemeral_pubkey"
1056
490
  );
1057
- const S = P(c);
1058
- if (!$.isPoint(S))
491
+ const S = P(l);
492
+ if (!k.isPoint(S))
1059
493
  throw new u(
1060
494
  "ephemeral_pubkey is not a valid secp256k1 point",
1061
495
  "invalid_ephemeral_pubkey"
1062
496
  );
1063
- const p = _(e.signature).toLowerCase();
1064
- if (p.length !== he || !f.test(p))
497
+ const d = w(e.signature).toLowerCase();
498
+ if (d.length !== te || !_.test(d))
1065
499
  throw new u(
1066
- `signature must be 64-byte Schnorr hex; got ${p.length} chars`,
500
+ `signature must be 64-byte Schnorr hex; got ${d.length} chars`,
1067
501
  "invalid_signature_encoding"
1068
502
  );
1069
- const E = He(
1070
- Ke,
1071
- P(c),
503
+ const T = ve(
504
+ xe,
505
+ P(l),
1072
506
  e.expires_at
1073
507
  );
1074
- if (!Ne(E, P(s), P(p)))
508
+ if (!Pe(T, P(a), P(d)))
1075
509
  throw new u(
1076
510
  "BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
1077
511
  "signature_verification_failed"
1078
512
  );
1079
513
  }
1080
- const De = /* @__PURE__ */ new Set([
514
+ const Ve = /* @__PURE__ */ new Set([
1081
515
  "vaultProvider_submitDepositorWotsKey",
1082
516
  "vaultProvider_submitDepositorPresignatures",
1083
517
  "vaultProvider_requestDepositorPresignTransactions"
1084
- ]), je = 6e4, O = "auth_createDepositorToken";
1085
- function ae(n, e) {
1086
- return new G({
518
+ ]), ke = 6e4, B = "auth_createDepositorToken";
519
+ function Y(n, e) {
520
+ return new F({
1087
521
  baseUrl: n,
1088
- timeout: je,
522
+ timeout: ke,
1089
523
  headers: e,
1090
- retryableFor: (t) => t === O
524
+ retryableFor: (t) => t === B
1091
525
  });
1092
526
  }
1093
- const M = 4102444800, Me = 30;
1094
- class Le {
527
+ const D = 4102444800, Se = 30;
528
+ class Te {
1095
529
  constructor(e) {
1096
530
  // `client` is the only mutable field — see `setClient`. The
1097
531
  // identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
1098
532
  // remain readonly and are checked against re-registration in the
1099
533
  // registry's `getOrCreate`.
1100
- l(this, "client");
1101
- l(this, "peginTxid");
1102
- l(this, "authAnchorHex");
1103
- l(this, "pinnedServerPubkey");
1104
- l(this, "authGatedMethods");
1105
- l(this, "refreshSkewSecs");
1106
- l(this, "now");
1107
- l(this, "cached", null);
1108
- l(this, "inFlight", null);
1109
- 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));
534
+ c(this, "client");
535
+ c(this, "peginTxid");
536
+ c(this, "authAnchorHex");
537
+ c(this, "pinnedServerPubkey");
538
+ c(this, "authGatedMethods");
539
+ c(this, "refreshSkewSecs");
540
+ c(this, "now");
541
+ c(this, "cached", null);
542
+ c(this, "inFlight", null);
543
+ this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.authGatedMethods = e.authGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Se, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1110
544
  }
1111
545
  /**
1112
546
  * Return a bearer token for `method`, or `null` if `method` is not
@@ -1121,7 +555,7 @@ class Le {
1121
555
  * guard. Returning `null` here breaks that recursion deterministically.
1122
556
  */
1123
557
  async getToken(e) {
1124
- if (e === O || !this.authGatedMethods.has(e)) return null;
558
+ if (e === B || !this.authGatedMethods.has(e)) return null;
1125
559
  const t = this.cached;
1126
560
  return t && this.now() + this.refreshSkewSecs < t.expiresAt ? t.token : (await this.acquireSingleFlight()).token;
1127
561
  }
@@ -1148,11 +582,11 @@ class Le {
1148
582
  if (e) return e;
1149
583
  const t = (async () => {
1150
584
  try {
1151
- const r = await this.client.call(O, {
585
+ const r = await this.client.call(B, {
1152
586
  pegin_txid: this.peginTxid,
1153
587
  auth_anchor: this.authAnchorHex
1154
588
  });
1155
- if (Ue({
589
+ if (Ae({
1156
590
  proof: r.server_identity,
1157
591
  pinnedServerPubkey: this.pinnedServerPubkey,
1158
592
  now: this.now()
@@ -1160,16 +594,16 @@ class Le {
1160
594
  throw new Error(
1161
595
  `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
1162
596
  );
1163
- const a = this.now();
1164
- if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= a || r.expires_at > M)
597
+ const i = this.now();
598
+ if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= i || r.expires_at > D)
1165
599
  throw new Error(
1166
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${a}, ${M}])`
600
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${i}, ${D}])`
1167
601
  );
1168
- const s = {
602
+ const a = {
1169
603
  token: r.token,
1170
604
  expiresAt: r.expires_at
1171
605
  };
1172
- return this.cached = s, s;
606
+ return this.cached = a, a;
1173
607
  } finally {
1174
608
  this.inFlight = null;
1175
609
  }
@@ -1177,9 +611,9 @@ class Le {
1177
611
  return this.inFlight = t, t;
1178
612
  }
1179
613
  }
1180
- class Xe {
614
+ class Ce {
1181
615
  constructor() {
1182
- l(this, "entries", /* @__PURE__ */ new Map());
616
+ c(this, "entries", /* @__PURE__ */ new Map());
1183
617
  }
1184
618
  /**
1185
619
  * Return the cached `VpTokenProvider` for `peginTxid` if one exists
@@ -1201,12 +635,12 @@ class Xe {
1201
635
  );
1202
636
  return t.provider.setClient(e.client), t.provider;
1203
637
  }
1204
- const r = new Le({
638
+ const r = new Te({
1205
639
  client: e.client,
1206
640
  peginTxid: e.peginTxid,
1207
641
  authAnchorHex: e.authAnchorHex,
1208
642
  pinnedServerPubkey: e.pinnedServerPubkey,
1209
- authGatedMethods: De
643
+ authGatedMethods: Ve
1210
644
  });
1211
645
  return this.entries.set(e.peginTxid, {
1212
646
  provider: r,
@@ -1240,42 +674,42 @@ class Xe {
1240
674
  return this.entries.size;
1241
675
  }
1242
676
  }
1243
- const ie = new Xe();
1244
- function it(n) {
677
+ const z = new Ce();
678
+ function De(n) {
1245
679
  var r;
1246
- const e = ae(
680
+ const e = Y(
1247
681
  n.baseUrl,
1248
682
  (r = n.options) == null ? void 0 : r.headers
1249
- ), t = ie.getOrCreate({
683
+ ), t = z.getOrCreate({
1250
684
  client: e,
1251
685
  peginTxid: n.peginTxid,
1252
686
  authAnchorHex: n.authAnchorHex,
1253
687
  pinnedServerPubkey: n.pinnedServerPubkey
1254
688
  });
1255
- return new Ie(n.baseUrl, {
689
+ return new me(n.baseUrl, {
1256
690
  ...n.options,
1257
691
  tokenProvider: t
1258
692
  });
1259
693
  }
1260
- function ot(n) {
1261
- ie.getOrCreate({
1262
- client: ae(n.baseUrl, n.headers),
694
+ function Ue(n) {
695
+ z.getOrCreate({
696
+ client: Y(n.baseUrl, n.headers),
1263
697
  peginTxid: n.peginTxid,
1264
698
  authAnchorHex: n.authAnchorHex,
1265
699
  pinnedServerPubkey: n.pinnedServerPubkey
1266
700
  });
1267
701
  }
1268
- async function ct(n, e) {
702
+ async function Ke(n, e) {
1269
703
  const [t, r] = await n.multicall({
1270
704
  contracts: [
1271
705
  {
1272
706
  address: e,
1273
- abi: b,
707
+ abi: y,
1274
708
  functionName: "protocolParams"
1275
709
  },
1276
710
  {
1277
711
  address: e,
1278
- abi: b,
712
+ abi: y,
1279
713
  functionName: "applicationRegistry"
1280
714
  }
1281
715
  ],
@@ -1286,8 +720,8 @@ async function ct(n, e) {
1286
720
  applicationRegistry: r
1287
721
  };
1288
722
  }
1289
- const L = 65535;
1290
- function R(n) {
723
+ const U = 65535;
724
+ function E(n) {
1291
725
  return {
1292
726
  timelockAssert: n.timelockAssert,
1293
727
  timelockChallengeAssert: n.timelockChallengeAssert,
@@ -1304,7 +738,7 @@ function R(n) {
1304
738
  minPrepeginDepth: n.minPrepeginDepth
1305
739
  };
1306
740
  }
1307
- function X(n) {
741
+ function K(n) {
1308
742
  return {
1309
743
  minimumPegInAmount: n.minimumPegInAmount,
1310
744
  maxPegInAmount: n.maxPegInAmount,
@@ -1313,14 +747,14 @@ function X(n) {
1313
747
  maxHtlcOutputCount: n.maxHtlcOutputCount
1314
748
  };
1315
749
  }
1316
- function q(n) {
1317
- if (n > BigInt(L))
750
+ function L(n) {
751
+ if (n > BigInt(U))
1318
752
  throw new Error(
1319
- `timelockAssert value ${n} exceeds uint16 max (${L})`
753
+ `timelockAssert value ${n} exceeds uint16 max (${U})`
1320
754
  );
1321
755
  return Number(n);
1322
756
  }
1323
- class lt {
757
+ class Le {
1324
758
  constructor(e, t) {
1325
759
  this.publicClient = e, this.contractAddress = t;
1326
760
  }
@@ -1330,7 +764,7 @@ class lt {
1330
764
  abi: h,
1331
765
  functionName: "getTBVProtocolParams"
1332
766
  });
1333
- return X(e);
767
+ return K(e);
1334
768
  }
1335
769
  async getLatestOffchainParams() {
1336
770
  const e = await this.publicClient.readContract({
@@ -1338,7 +772,7 @@ class lt {
1338
772
  abi: h,
1339
773
  functionName: "getLatestOffchainParams"
1340
774
  });
1341
- return R(e);
775
+ return E(e);
1342
776
  }
1343
777
  async getOffchainParamsByVersion(e) {
1344
778
  const t = await this.publicClient.readContract({
@@ -1347,7 +781,7 @@ class lt {
1347
781
  functionName: "getOffchainParamsByVersion",
1348
782
  args: [e]
1349
783
  });
1350
- return R(t);
784
+ return E(t);
1351
785
  }
1352
786
  async getLatestOffchainParamsVersion() {
1353
787
  return await this.publicClient.readContract({
@@ -1358,7 +792,7 @@ class lt {
1358
792
  }
1359
793
  async getTimelockPeginByVersion(e) {
1360
794
  const t = await this.getOffchainParamsByVersion(e);
1361
- return q(t.timelockAssert);
795
+ return L(t.timelockAssert);
1362
796
  }
1363
797
  /**
1364
798
  * Read TBV protocol params and latest offchain params atomically via multicall.
@@ -1379,14 +813,14 @@ class lt {
1379
813
  }
1380
814
  ],
1381
815
  allowFailure: !1
1382
- }), t = X(e[0]), r = R(e[1]);
816
+ }), t = K(e[0]), r = E(e[1]);
1383
817
  return {
1384
818
  minimumPegInAmount: t.minimumPegInAmount,
1385
819
  maxPegInAmount: t.maxPegInAmount,
1386
820
  pegInAckTimeout: t.pegInAckTimeout,
1387
821
  pegInActivationTimeout: t.pegInActivationTimeout,
1388
822
  maxHtlcOutputCount: t.maxHtlcOutputCount,
1389
- timelockPegin: q(r.timelockAssert),
823
+ timelockPegin: L(r.timelockAssert),
1390
824
  timelockRefund: r.tRefund,
1391
825
  minVpCommissionBps: r.minVpCommissionBps,
1392
826
  offchainParams: r
@@ -1399,14 +833,14 @@ function V(n) {
1399
833
  btcPubKey: e.btcPubKey
1400
834
  }));
1401
835
  }
1402
- class ut {
836
+ class Fe {
1403
837
  constructor(e, t) {
1404
838
  this.publicClient = e, this.contractAddress = t;
1405
839
  }
1406
840
  async getVaultKeepersByVersion(e, t) {
1407
841
  const r = await this.publicClient.readContract({
1408
842
  address: this.contractAddress,
1409
- abi: B,
843
+ abi: $,
1410
844
  functionName: "getVaultKeepersByVersion",
1411
845
  args: [e, t]
1412
846
  });
@@ -1415,7 +849,7 @@ class ut {
1415
849
  async getCurrentVaultKeepers(e) {
1416
850
  const t = await this.publicClient.readContract({
1417
851
  address: this.contractAddress,
1418
- abi: B,
852
+ abi: $,
1419
853
  functionName: "getCurrentVaultKeepers",
1420
854
  args: [e]
1421
855
  });
@@ -1424,13 +858,13 @@ class ut {
1424
858
  async getCurrentVaultKeepersVersion(e) {
1425
859
  return await this.publicClient.readContract({
1426
860
  address: this.contractAddress,
1427
- abi: B,
861
+ abi: $,
1428
862
  functionName: "getCurrentVaultKeepersVersion",
1429
863
  args: [e]
1430
864
  });
1431
865
  }
1432
866
  }
1433
- class pt {
867
+ class Me {
1434
868
  constructor(e, t) {
1435
869
  this.publicClient = e, this.contractAddress = t;
1436
870
  }
@@ -1459,7 +893,7 @@ class pt {
1459
893
  });
1460
894
  }
1461
895
  }
1462
- class dt {
896
+ class Xe {
1463
897
  constructor(e, t) {
1464
898
  this.publicClient = e, this.contractAddress = t;
1465
899
  }
@@ -1472,7 +906,7 @@ class dt {
1472
906
  async getVaultProviderBtcPubKey(e) {
1473
907
  const r = (await this.publicClient.readContract({
1474
908
  address: this.contractAddress,
1475
- abi: b,
909
+ abi: y,
1476
910
  functionName: "getVaultProviderBTCKey",
1477
911
  args: [e]
1478
912
  })).toLowerCase();
@@ -1480,17 +914,17 @@ class dt {
1480
914
  throw new Error(
1481
915
  `getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0, 2)}")`
1482
916
  );
1483
- const a = r.slice(2);
1484
- if (!$.isXOnlyPoint(me(a)))
917
+ const i = r.slice(2);
918
+ if (!k.isXOnlyPoint(ne(i)))
1485
919
  throw new Error(
1486
920
  `getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`
1487
921
  );
1488
- return a;
922
+ return i;
1489
923
  }
1490
924
  async getVaultBasicInfo(e) {
1491
925
  const t = await this.publicClient.readContract({
1492
926
  address: this.contractAddress,
1493
- abi: b,
927
+ abi: y,
1494
928
  functionName: "getBtcVaultBasicInfo",
1495
929
  args: [e]
1496
930
  });
@@ -1507,7 +941,7 @@ class dt {
1507
941
  async getVaultProtocolInfo(e) {
1508
942
  const t = await this.publicClient.readContract({
1509
943
  address: this.contractAddress,
1510
- abi: b,
944
+ abi: y,
1511
945
  functionName: "getBtcVaultProtocolInfo",
1512
946
  args: [e]
1513
947
  });
@@ -1538,30 +972,19 @@ class dt {
1538
972
  }
1539
973
  }
1540
974
  export {
1541
- B as A,
1542
- be as M,
1543
- h as P,
1544
975
  u as S,
1545
- Ie as V,
1546
- nt as a,
1547
- rt as b,
1548
- at as c,
1549
- et as d,
1550
- we as e,
1551
- tt as f,
1552
- st as g,
1553
- i as h,
1554
- Ue as i,
1555
- Xe as j,
1556
- ie as k,
1557
- it as l,
1558
- ot as m,
1559
- lt as n,
1560
- pt as o,
1561
- Ze as p,
1562
- ut as q,
1563
- ct as r,
1564
- dt as s,
1565
- ke as v
976
+ me as V,
977
+ s as a,
978
+ Ae as b,
979
+ Ce as c,
980
+ z as d,
981
+ De as e,
982
+ Le as f,
983
+ Me as g,
984
+ Fe as h,
985
+ Xe as i,
986
+ Ue as p,
987
+ Ke as r,
988
+ pe as v
1566
989
  };
1567
- //# sourceMappingURL=vault-registry-reader-CWGbw_wZ.js.map
990
+ //# sourceMappingURL=vault-registry-reader-WiNVOsnD.js.map