@babylonlabs-io/ts-sdk 0.8.1 → 0.10.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 (75) hide show
  1. package/dist/errors-CIDTtluC.cjs +2 -0
  2. package/dist/errors-CIDTtluC.cjs.map +1 -0
  3. package/dist/errors-fLxe1eml.js +2086 -0
  4. package/dist/errors-fLxe1eml.js.map +1 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +73 -69
  7. package/dist/index.js.map +1 -1
  8. package/dist/shared/index.cjs +1 -1
  9. package/dist/shared/index.cjs.map +1 -1
  10. package/dist/shared/index.d.ts +2 -4
  11. package/dist/shared/index.d.ts.map +1 -1
  12. package/dist/shared/index.js +6 -5
  13. package/dist/shared/index.js.map +1 -1
  14. package/dist/shared/wallets/index.d.ts +2 -4
  15. package/dist/shared/wallets/index.d.ts.map +1 -1
  16. package/dist/shared/wallets/interfaces/index.d.ts +1 -1
  17. package/dist/shared/wallets/interfaces/index.d.ts.map +1 -1
  18. package/dist/tbv/core/index.cjs +1 -1
  19. package/dist/tbv/core/index.d.ts +1 -0
  20. package/dist/tbv/core/index.d.ts.map +1 -1
  21. package/dist/tbv/core/index.js +62 -55
  22. package/dist/tbv/core/lamport/__tests__/derivation.test.d.ts +2 -0
  23. package/dist/tbv/core/lamport/__tests__/derivation.test.d.ts.map +1 -0
  24. package/dist/tbv/core/lamport/derivation.d.ts +78 -0
  25. package/dist/tbv/core/lamport/derivation.d.ts.map +1 -0
  26. package/dist/tbv/core/lamport/deriveLamportPkHash.d.ts +9 -0
  27. package/dist/tbv/core/lamport/deriveLamportPkHash.d.ts.map +1 -0
  28. package/dist/tbv/core/lamport/errors.d.ts +7 -0
  29. package/dist/tbv/core/lamport/errors.d.ts.map +1 -0
  30. package/dist/tbv/core/lamport/index.d.ts +5 -0
  31. package/dist/tbv/core/lamport/index.d.ts.map +1 -0
  32. package/dist/tbv/core/lamport/types.d.ts +33 -0
  33. package/dist/tbv/core/lamport/types.d.ts.map +1 -0
  34. package/dist/tbv/core/managers/PeginManager.d.ts +10 -31
  35. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  36. package/dist/tbv/core/utils/__tests__/signing.test.d.ts +2 -0
  37. package/dist/tbv/core/utils/__tests__/signing.test.d.ts.map +1 -0
  38. package/dist/tbv/core/utils/index.d.ts +1 -0
  39. package/dist/tbv/core/utils/index.d.ts.map +1 -1
  40. package/dist/{shared/wallets/signOptions.d.ts → tbv/core/utils/signing.d.ts} +2 -2
  41. package/dist/tbv/core/utils/signing.d.ts.map +1 -0
  42. package/dist/tbv/index.cjs +1 -1
  43. package/dist/tbv/index.js +62 -55
  44. package/dist/{shared/wallets/mocks → testing}/MockBitcoinWallet.d.ts +2 -2
  45. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -0
  46. package/dist/testing/MockEthereumWallet.d.ts.map +1 -0
  47. package/dist/testing/__tests__/MockEthereumWallet.test.d.ts +2 -0
  48. package/dist/testing/__tests__/MockEthereumWallet.test.d.ts.map +1 -0
  49. package/dist/testing/index.cjs +2 -0
  50. package/dist/testing/index.cjs.map +1 -0
  51. package/dist/testing/index.d.ts.map +1 -0
  52. package/dist/{MockEthereumWallet-ibdry7pZ.js → testing/index.js} +6 -8
  53. package/dist/testing/index.js.map +1 -0
  54. package/package.json +8 -1
  55. package/dist/MockEthereumWallet-CKQlH2AM.cjs +0 -2
  56. package/dist/MockEthereumWallet-CKQlH2AM.cjs.map +0 -1
  57. package/dist/MockEthereumWallet-ibdry7pZ.js.map +0 -1
  58. package/dist/PayoutManager-6IBl1Fdt.js +0 -1203
  59. package/dist/PayoutManager-6IBl1Fdt.js.map +0 -1
  60. package/dist/PayoutManager-EZFN4Y4Z.cjs +0 -2
  61. package/dist/PayoutManager-EZFN4Y4Z.cjs.map +0 -1
  62. package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts +0 -2
  63. package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts.map +0 -1
  64. package/dist/shared/wallets/__tests__/signOptions.test.d.ts +0 -2
  65. package/dist/shared/wallets/__tests__/signOptions.test.d.ts.map +0 -1
  66. package/dist/shared/wallets/mocks/MockBitcoinWallet.d.ts.map +0 -1
  67. package/dist/shared/wallets/mocks/MockEthereumWallet.d.ts.map +0 -1
  68. package/dist/shared/wallets/mocks/index.d.ts.map +0 -1
  69. package/dist/shared/wallets/signOptions.d.ts.map +0 -1
  70. package/dist/signOptions-Deg5lCoC.cjs +0 -2
  71. package/dist/signOptions-Deg5lCoC.cjs.map +0 -1
  72. package/dist/signOptions-Drwr3bXB.js +0 -16
  73. package/dist/signOptions-Drwr3bXB.js.map +0 -1
  74. /package/dist/{shared/wallets/mocks → testing}/MockEthereumWallet.d.ts +0 -0
  75. /package/dist/{shared/wallets/mocks → testing}/index.d.ts +0 -0
@@ -1,1203 +0,0 @@
1
- var Z = Object.defineProperty;
2
- var G = (n, t, e) => t in n ? Z(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var S = (n, t, e) => G(n, typeof t != "symbol" ? t + "" : t, e);
4
- import * as Q from "bitcoinjs-lib";
5
- import { script as Y, Transaction as $, address as tt, Psbt as F } from "bitcoinjs-lib";
6
- import { Buffer as g } from "buffer";
7
- import { P as et, x as nt, D as q, M as R, B as rt, T as st, A as C, t as k, b as ot, z as at, a as it, d as ct, e as ut, f as lt, r as B, p as dt, w as W, g as N, h as K } from "./challengeAssert-D50t_Qyo.js";
8
- import { createPublicClient as M, http as X, encodeFunctionData as pt, zeroAddress as ht } from "viem";
9
- import { c as O } from "./signOptions-Drwr3bXB.js";
10
- import { SINGLE_DEPOSIT_HTLC_VOUT as D } from "@babylonlabs-io/babylon-tbv-rust-wasm";
11
- function ft(n, t, e) {
12
- if (n.length === 0)
13
- throw new Error("Insufficient funds: no UTXOs available");
14
- const r = n.filter((a) => {
15
- const u = g.from(a.scriptPubKey, "hex");
16
- return !!Y.decompile(u);
17
- });
18
- if (r.length === 0)
19
- throw new Error(
20
- "Insufficient funds: no valid UTXOs available (all have invalid scripts)"
21
- );
22
- const o = [...r].sort((a, u) => u.value - a.value), s = [];
23
- let c = 0n, i = 0n;
24
- for (const a of o) {
25
- s.push(a), c += BigInt(a.value);
26
- const u = s.length * et, l = 2 * R, p = u + l + st;
27
- if (i = BigInt(Math.ceil(p * e)) + BigInt(nt(e)), c - t - i > q) {
28
- const y = BigInt(
29
- Math.ceil(R * e)
30
- );
31
- i += y;
32
- }
33
- if (c >= t + i) {
34
- const y = c - t - i;
35
- return {
36
- selectedUTXOs: s,
37
- totalValue: c,
38
- fee: i,
39
- changeAmount: y
40
- };
41
- }
42
- }
43
- throw new Error(
44
- `Insufficient funds: need ${t + i} sats (${t} pegin + ${i} fee), have ${c} sats`
45
- );
46
- }
47
- function Ht(n) {
48
- return n > q;
49
- }
50
- function Ft() {
51
- return rt;
52
- }
53
- function _(n) {
54
- const t = n.startsWith("0x") ? n.slice(2) : n;
55
- return `0x${$.fromHex(t).getId()}`;
56
- }
57
- function Ct(n, t, e) {
58
- if (n.length === 0)
59
- throw new Error("No input UTXOs provided for split transaction");
60
- if (t.length === 0)
61
- throw new Error("No outputs specified for split transaction");
62
- for (const a of t)
63
- if (a.amount <= 0n)
64
- throw new Error(
65
- `Invalid output amount for ${a.address}: ${a.amount} satoshis. Amount must be greater than zero.`
66
- );
67
- const r = C(e), o = new $();
68
- o.version = 2;
69
- for (const a of n) {
70
- const u = g.from(a.txid, "hex").reverse();
71
- o.addInput(u, a.vout);
72
- }
73
- const s = [];
74
- for (let a = 0; a < t.length; a++) {
75
- const u = t[a];
76
- let l;
77
- try {
78
- l = tt.toOutputScript(u.address, r);
79
- } catch (p) {
80
- throw new Error(
81
- `Failed to decode address "${u.address}": ${p instanceof Error ? p.message : String(p)}`
82
- );
83
- }
84
- o.addOutput(l, Number(u.amount)), s.push({
85
- txid: "",
86
- // Will be set after txid calculation
87
- vout: a,
88
- value: Number(u.amount),
89
- scriptPubKey: l.toString("hex")
90
- });
91
- }
92
- const c = o.toHex(), i = o.getId();
93
- for (const a of s)
94
- a.txid = i;
95
- return {
96
- txHex: c,
97
- txid: i,
98
- outputs: s
99
- };
100
- }
101
- function Ot(n, t, e) {
102
- const r = $.fromHex(n), o = new F();
103
- if (o.setVersion(r.version), o.setLocktime(r.locktime), !g.isBuffer(e) || e.length !== 32)
104
- throw new Error(
105
- `Invalid publicKeyNoCoord: expected 32-byte Buffer (x-only pubkey), got ${g.isBuffer(e) ? `${e.length}-byte Buffer` : typeof e}`
106
- );
107
- if (t.length !== r.ins.length)
108
- throw new Error(
109
- `UTXO count mismatch: transaction has ${r.ins.length} input${r.ins.length !== 1 ? "s" : ""}, but ${t.length} UTXO${t.length !== 1 ? "s were" : " was"} provided`
110
- );
111
- for (let s = 0; s < r.ins.length; s++) {
112
- const c = r.ins[s], i = t[s];
113
- if (!i)
114
- throw new Error(`Missing UTXO data for input ${s}`);
115
- const a = g.from(c.hash).reverse().toString("hex"), u = c.index;
116
- if (i.txid !== a || i.vout !== u)
117
- throw new Error(
118
- `Input ${s} outpoint mismatch: transaction expects ${a}:${u}, but UTXO ${i.txid}:${i.vout} was provided. Ensure inputs array matches the order used in createSplitTransaction().`
119
- );
120
- const l = g.from(i.scriptPubKey, "hex");
121
- if (!(l.length === 34 && l[0] === 81 && // OP_1 (witness version 1)
122
- l[1] === 32))
123
- throw new Error(
124
- `Input ${s} must be P2TR (Taproot). createSplitTransactionPsbt() requires P2TR inputs because it uses tapInternalKey for Taproot signing. ScriptPubKey: ${i.scriptPubKey.substring(0, 20)}...`
125
- );
126
- const h = {
127
- script: g.from(i.scriptPubKey, "hex"),
128
- value: i.value
129
- };
130
- o.addInput({
131
- hash: c.hash,
132
- index: c.index,
133
- sequence: c.sequence,
134
- witnessUtxo: h,
135
- tapInternalKey: e
136
- });
137
- }
138
- for (const s of r.outs)
139
- o.addOutput({
140
- script: s.script,
141
- value: s.value
142
- });
143
- return o.toHex();
144
- }
145
- var E = /* @__PURE__ */ ((n) => (n.P2PKH = "P2PKH", n.P2SH = "P2SH", n.P2WPKH = "P2WPKH", n.P2WSH = "P2WSH", n.P2TR = "P2TR", n.UNKNOWN = "UNKNOWN", n))(E || {});
146
- function gt(n) {
147
- const t = n.length;
148
- return t === 25 && n[0] === 118 && // OP_DUP
149
- n[1] === 169 && // OP_HASH160
150
- n[2] === 20 && // Push 20 bytes
151
- n[23] === 136 && // OP_EQUALVERIFY
152
- n[24] === 172 ? "P2PKH" : t === 23 && n[0] === 169 && // OP_HASH160
153
- n[1] === 20 && // Push 20 bytes
154
- n[22] === 135 ? "P2SH" : t === 22 && n[0] === 0 && // OP_0
155
- n[1] === 20 ? "P2WPKH" : t === 34 && n[0] === 0 && // OP_0
156
- n[1] === 32 ? "P2WSH" : t === 34 && n[0] === 81 && // OP_1
157
- n[1] === 32 ? "P2TR" : "UNKNOWN";
158
- }
159
- function yt(n, t) {
160
- const e = g.from(n.scriptPubKey, "hex"), r = gt(e);
161
- switch (r) {
162
- case E.P2WPKH:
163
- return {
164
- witnessUtxo: {
165
- script: e,
166
- value: n.value
167
- }
168
- };
169
- case E.P2WSH: {
170
- if (!n.witnessScript)
171
- throw new Error("Missing witnessScript for P2WSH input");
172
- return {
173
- witnessUtxo: {
174
- script: e,
175
- value: n.value
176
- },
177
- witnessScript: g.from(n.witnessScript, "hex")
178
- };
179
- }
180
- case E.P2TR: {
181
- if (t && t.length !== 32)
182
- throw new Error(
183
- `Invalid tapInternalKey length: expected 32 bytes, got ${t.length}`
184
- );
185
- return {
186
- witnessUtxo: {
187
- script: e,
188
- value: n.value
189
- },
190
- // tapInternalKey is needed for Taproot signing
191
- ...t && { tapInternalKey: t }
192
- };
193
- }
194
- default:
195
- throw new Error(`Unsupported script type: ${r}`);
196
- }
197
- }
198
- const bt = 21e6 * 1e8, L = 1e4;
199
- function j(n) {
200
- return Number.isInteger(n) && n > 0 && n <= bt;
201
- }
202
- function mt(n) {
203
- return Number.isInteger(n) && n > 0 && n <= L;
204
- }
205
- function J(n, t) {
206
- return !Number.isInteger(n) || n < 0 ? !1 : t === void 0 || n < t;
207
- }
208
- const Pt = {
209
- mainnet: "https://mempool.space/api",
210
- testnet: "https://mempool.space/testnet/api",
211
- signet: "https://mempool.space/signet/api"
212
- };
213
- async function I(n, t) {
214
- try {
215
- const e = await fetch(n, t);
216
- if (!e.ok) {
217
- const o = await e.text();
218
- throw new Error(
219
- `Mempool API error (${e.status}): ${o || e.statusText}`
220
- );
221
- }
222
- const r = e.headers.get("content-type");
223
- return r != null && r.includes("application/json") ? await e.json() : await e.text();
224
- } catch (e) {
225
- throw e instanceof Error ? new Error(`Failed to fetch from mempool API: ${e.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
226
- }
227
- }
228
- async function xt(n, t) {
229
- try {
230
- const e = await fetch(`${t}/tx`, {
231
- method: "POST",
232
- body: n,
233
- headers: {
234
- "Content-Type": "text/plain"
235
- }
236
- });
237
- if (!e.ok) {
238
- const o = await e.text();
239
- let s;
240
- try {
241
- s = JSON.parse(o).message;
242
- } catch {
243
- s = o;
244
- }
245
- throw new Error(
246
- s || `Failed to broadcast transaction: ${e.statusText}`
247
- );
248
- }
249
- return await e.text();
250
- } catch (e) {
251
- throw e instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${e.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
252
- }
253
- }
254
- async function wt(n, t) {
255
- return I(`${t}/tx/${n}`);
256
- }
257
- async function Ut(n, t) {
258
- try {
259
- const e = await fetch(`${t}/tx/${n}/hex`);
260
- if (!e.ok) {
261
- const r = await e.text();
262
- throw new Error(
263
- `Mempool API error (${e.status}): ${r || e.statusText}`
264
- );
265
- }
266
- return await e.text();
267
- } catch (e) {
268
- throw e instanceof Error ? new Error(`Failed to get transaction hex for ${n}: ${e.message}`) : new Error(`Failed to get transaction hex for ${n}: Unknown error`);
269
- }
270
- }
271
- async function Tt(n, t, e) {
272
- const r = await wt(n, e);
273
- if (!J(t, r.vout.length))
274
- throw new Error(
275
- `Invalid vout ${t} for transaction ${n} (has ${r.vout.length} outputs)`
276
- );
277
- const o = r.vout[t];
278
- if (!j(o.value))
279
- throw new Error(`Invalid UTXO value ${o.value} for ${n}:${t}`);
280
- return {
281
- txid: n,
282
- vout: t,
283
- value: o.value,
284
- scriptPubKey: o.scriptpubkey
285
- };
286
- }
287
- async function At(n, t) {
288
- try {
289
- const e = await I(`${t}/address/${n}/utxo`), r = await I(`${t}/v1/validate-address/${n}`);
290
- if (!r.isvalid)
291
- throw new Error(
292
- `Invalid Bitcoin address: ${n}. Mempool API validation failed.`
293
- );
294
- for (const s of e) {
295
- if (!J(s.vout))
296
- throw new Error(`Invalid vout ${s.vout} for ${s.txid}`);
297
- if (!j(s.value))
298
- throw new Error(
299
- `Invalid UTXO value ${s.value} for ${s.txid}:${s.vout}`
300
- );
301
- }
302
- return e.sort((s, c) => c.value - s.value).map((s) => ({
303
- txid: s.txid,
304
- vout: s.vout,
305
- value: s.value,
306
- scriptPubKey: r.scriptPubKey,
307
- confirmed: s.status.confirmed
308
- }));
309
- } catch (e) {
310
- throw e instanceof Error ? new Error(
311
- `Failed to get UTXOs for address ${n}: ${e.message}`
312
- ) : new Error(
313
- `Failed to get UTXOs for address ${n}: Unknown error`
314
- );
315
- }
316
- }
317
- function Vt(n) {
318
- return Pt[n];
319
- }
320
- async function Rt(n, t) {
321
- return I(`${t}/address/${n}/txs`);
322
- }
323
- async function Wt(n) {
324
- const t = await fetch(`${n}/v1/fees/recommended`);
325
- if (!t.ok)
326
- throw new Error(
327
- `Failed to fetch network fees: ${t.status} ${t.statusText}`
328
- );
329
- const e = await t.json(), r = [
330
- "fastestFee",
331
- "halfHourFee",
332
- "hourFee",
333
- "economyFee",
334
- "minimumFee"
335
- ];
336
- for (const o of r)
337
- if (!mt(e[o]))
338
- throw new Error(
339
- `Invalid fee rate ${o}=${e[o]} from mempool API: expected a positive number ≤ ${L}`
340
- );
341
- if (e.minimumFee > e.economyFee || e.economyFee > e.hourFee || e.hourFee > e.halfHourFee || e.halfHourFee > e.fastestFee)
342
- throw new Error(
343
- `Fee rate ordering violation from mempool API: expected minimumFee (${e.minimumFee}) <= economyFee (${e.economyFee}) <= hourFee (${e.hourFee}) <= halfHourFee (${e.halfHourFee}) <= fastestFee (${e.fastestFee}).`
344
- );
345
- return e;
346
- }
347
- const H = [
348
- {
349
- type: "function",
350
- name: "submitPeginRequest",
351
- inputs: [
352
- {
353
- name: "depositor",
354
- type: "address",
355
- internalType: "address"
356
- },
357
- {
358
- name: "depositorBtcPubKey",
359
- type: "bytes32",
360
- internalType: "bytes32"
361
- },
362
- {
363
- name: "btcPopSignature",
364
- type: "bytes",
365
- internalType: "bytes"
366
- },
367
- {
368
- name: "unsignedPrePeginTx",
369
- type: "bytes",
370
- internalType: "bytes"
371
- },
372
- {
373
- name: "depositorSignedPeginTx",
374
- type: "bytes",
375
- internalType: "bytes"
376
- },
377
- {
378
- name: "vaultProvider",
379
- type: "address",
380
- internalType: "address"
381
- },
382
- {
383
- name: "hashlock",
384
- type: "bytes32",
385
- internalType: "bytes32"
386
- },
387
- {
388
- name: "htlcVout",
389
- type: "uint8",
390
- internalType: "uint8"
391
- },
392
- {
393
- name: "depositorPayoutBtcAddress",
394
- type: "bytes",
395
- internalType: "bytes"
396
- },
397
- {
398
- name: "depositorLamportPkHash",
399
- type: "bytes32",
400
- internalType: "bytes32"
401
- }
402
- ],
403
- outputs: [
404
- {
405
- name: "",
406
- type: "bytes32",
407
- internalType: "bytes32"
408
- }
409
- ],
410
- stateMutability: "payable"
411
- },
412
- {
413
- type: "function",
414
- name: "submitPeginRequest",
415
- inputs: [
416
- {
417
- name: "depositor",
418
- type: "address",
419
- internalType: "address"
420
- },
421
- {
422
- name: "depositorBtcPubKey",
423
- type: "bytes32",
424
- internalType: "bytes32"
425
- },
426
- {
427
- name: "btcPopSignature",
428
- type: "bytes",
429
- internalType: "bytes"
430
- },
431
- {
432
- name: "unsignedPrePeginTx",
433
- type: "bytes",
434
- internalType: "bytes"
435
- },
436
- {
437
- name: "depositorSignedPeginTx",
438
- type: "bytes",
439
- internalType: "bytes"
440
- },
441
- {
442
- name: "vaultProvider",
443
- type: "address",
444
- internalType: "address"
445
- },
446
- {
447
- name: "hashlock",
448
- type: "bytes32",
449
- internalType: "bytes32"
450
- },
451
- {
452
- name: "htlcVout",
453
- type: "uint8",
454
- internalType: "uint8"
455
- },
456
- {
457
- name: "referralCode",
458
- type: "uint32",
459
- internalType: "uint32"
460
- },
461
- {
462
- name: "depositorPayoutBtcAddress",
463
- type: "bytes",
464
- internalType: "bytes"
465
- },
466
- {
467
- name: "depositorLamportPkHash",
468
- type: "bytes32",
469
- internalType: "bytes32"
470
- }
471
- ],
472
- outputs: [
473
- {
474
- name: "",
475
- type: "bytes32",
476
- internalType: "bytes32"
477
- }
478
- ],
479
- stateMutability: "payable"
480
- },
481
- {
482
- type: "function",
483
- name: "activateVaultWithSecret",
484
- inputs: [
485
- {
486
- name: "vaultId",
487
- type: "bytes32",
488
- internalType: "bytes32"
489
- },
490
- {
491
- name: "s",
492
- type: "bytes32",
493
- internalType: "bytes32"
494
- }
495
- ],
496
- outputs: [],
497
- stateMutability: "nonpayable"
498
- },
499
- {
500
- type: "function",
501
- name: "getPegInFee",
502
- inputs: [
503
- {
504
- name: "vaultProvider",
505
- type: "address",
506
- internalType: "address"
507
- }
508
- ],
509
- outputs: [
510
- {
511
- name: "totalFee",
512
- type: "uint256",
513
- internalType: "uint256"
514
- }
515
- ],
516
- stateMutability: "view"
517
- },
518
- {
519
- type: "function",
520
- name: "getBTCVault",
521
- inputs: [
522
- {
523
- name: "vaultId",
524
- type: "bytes32",
525
- internalType: "bytes32"
526
- }
527
- ],
528
- outputs: [
529
- {
530
- name: "vault",
531
- type: "tuple",
532
- internalType: "struct IBTCVaultRegistry.BTCVault",
533
- components: [
534
- { name: "depositor", type: "address", internalType: "address" },
535
- { name: "depositorBtcPubKey", type: "bytes32", internalType: "bytes32" },
536
- { name: "depositorSignedPeginTx", type: "bytes", internalType: "bytes" },
537
- { name: "amount", type: "uint256", internalType: "uint256" },
538
- { name: "vaultProvider", type: "address", internalType: "address" },
539
- { name: "status", type: "uint8", internalType: "enum IBTCVaultRegistry.BTCVaultStatus" },
540
- { name: "applicationEntryPoint", type: "address", internalType: "address" },
541
- { name: "universalChallengersVersion", type: "uint16", internalType: "uint16" },
542
- { name: "appVaultKeepersVersion", type: "uint16", internalType: "uint16" },
543
- { name: "offchainParamsVersion", type: "uint16", internalType: "uint16" },
544
- { name: "proverProgramVersion", type: "uint16", internalType: "uint16" },
545
- { name: "createdAt", type: "uint256", internalType: "uint256" },
546
- { name: "verifiedAt", type: "uint256", internalType: "uint256" },
547
- { name: "depositorLamportPkHash", type: "bytes32", internalType: "bytes32" },
548
- { name: "hashlock", type: "bytes32", internalType: "bytes32" },
549
- { name: "htlcVout", type: "uint8", internalType: "uint8" }
550
- ]
551
- }
552
- ],
553
- stateMutability: "view"
554
- },
555
- {
556
- type: "error",
557
- name: "InvalidPeginFee",
558
- inputs: [
559
- {
560
- name: "provided",
561
- type: "uint256",
562
- internalType: "uint256"
563
- },
564
- {
565
- name: "required",
566
- type: "uint256",
567
- internalType: "uint256"
568
- }
569
- ]
570
- },
571
- {
572
- type: "error",
573
- name: "InvalidSecret",
574
- inputs: []
575
- },
576
- {
577
- type: "error",
578
- name: "ActivationDeadlineExpired",
579
- inputs: []
580
- },
581
- {
582
- type: "error",
583
- name: "InvalidHashlock",
584
- inputs: []
585
- },
586
- {
587
- type: "error",
588
- name: "DuplicateHashlock",
589
- inputs: []
590
- },
591
- {
592
- type: "error",
593
- name: "CapExceeded",
594
- inputs: []
595
- },
596
- {
597
- type: "error",
598
- name: "InvalidOutputIndex",
599
- inputs: []
600
- },
601
- {
602
- type: "error",
603
- name: "PeginSignaturesIncomplete",
604
- inputs: []
605
- }
606
- ], P = {
607
- // VaultAlreadyExists()
608
- "0x04aabf33": "Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.",
609
- // ScriptPubKeyMismatch() - taproot output doesn't match expected script
610
- "0x4fec082d": "Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. This may be caused by incorrect vault participants or key configuration.",
611
- // InvalidBTCProofOfPossession()
612
- "0x6cc363a5": "Invalid BTC proof of possession: The signature could not be verified. Please ensure you're signing with the correct Bitcoin wallet.",
613
- // InvalidBTCPublicKey()
614
- "0x6c3f2bf6": "Invalid BTC public key: The Bitcoin public key format is invalid.",
615
- // InvalidAmount()
616
- "0x2c5211c6": "Invalid amount: The deposit amount is invalid or below the minimum required.",
617
- // ApplicationNotRegistered()
618
- "0x0405f772": "Application not registered: The application controller is not registered in the system.",
619
- // InvalidProviderStatus()
620
- "0x24e165cc": "Invalid provider status: The vault provider is not in a valid state to accept deposits.",
621
- // ZeroAddress()
622
- "0xd92e233d": "Zero address: One of the required addresses is the zero address.",
623
- // BtcKeyMismatch()
624
- "0x65aa7007": "BTC key mismatch: The Bitcoin public key does not match the expected key.",
625
- // Unauthorized()
626
- "0x82b42900": "Unauthorized: You must be the depositor or vault provider to submit this transaction.",
627
- // InvalidSignature() - common signature verification error
628
- "0x8baa579f": "Invalid signature: The BTC proof of possession signature could not be verified.",
629
- // InvalidBtcTransaction()
630
- "0x2f9d01e9": "Invalid BTC transaction: The Bitcoin transaction format is invalid.",
631
- // VaultProviderNotRegistered()
632
- "0x5a3c6b3e": "Vault provider not registered: The selected vault provider is not registered.",
633
- // InvalidPeginFee(uint256,uint256)
634
- "0x979f4518": "Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction."
635
- };
636
- function U(n) {
637
- if (!n || typeof n != "object") return;
638
- const t = n;
639
- if (typeof t.data == "string" && t.data.startsWith("0x"))
640
- return t.data;
641
- if (typeof t.details == "string" && t.details.startsWith("0x"))
642
- return t.details;
643
- let e = t.cause, r = 0;
644
- const o = 5;
645
- for (; e && typeof e == "object" && r < o; ) {
646
- const i = e;
647
- if (typeof i.data == "string" && i.data.startsWith("0x"))
648
- return i.data;
649
- e = i.cause, r++;
650
- }
651
- const c = (typeof t.message == "string" ? t.message : "").match(/\b(0x[a-fA-F0-9]{8})\b/);
652
- if (c)
653
- return c[1];
654
- }
655
- function Nt(n) {
656
- const t = U(n);
657
- if (t) {
658
- const e = t.substring(0, 10);
659
- return P[t] ?? P[e];
660
- }
661
- }
662
- function Kt(n) {
663
- const t = U(n);
664
- if (t === void 0) return !1;
665
- const e = t.substring(0, 10);
666
- return t in P || e in P;
667
- }
668
- function z(n) {
669
- console.error("[Contract Error] Raw error:", n);
670
- const t = U(n);
671
- if (console.error("[Contract Error] Extracted error data:", t), t) {
672
- const r = t.substring(0, 10), o = P[t] ?? P[r];
673
- if (o)
674
- throw console.error("[Contract Error] Known error:", o), new Error(o);
675
- }
676
- const e = (n == null ? void 0 : n.message) || "";
677
- if (e.includes("gas limit too high") || e.includes("21000000") || e.includes("Internal JSON-RPC error")) {
678
- const r = t ? ` (error code: ${t})` : "";
679
- throw console.error(
680
- "[Contract Error] Transaction rejected. Error code:",
681
- t,
682
- "Message:",
683
- e
684
- ), new Error(
685
- `Transaction failed: The contract rejected this transaction${r}. Possible causes: (1) Vault already exists for this transaction, (2) Invalid signature, (3) Unauthorized caller. Please check your transaction parameters and try again.`
686
- );
687
- }
688
- throw n instanceof Error ? (console.error("[Contract Error] Unhandled error:", n.message), n) : new Error(`Contract call failed: ${String(n)}`);
689
- }
690
- class Mt {
691
- /**
692
- * Creates a new PeginManager instance.
693
- *
694
- * @param config - Manager configuration including wallets and contract addresses
695
- */
696
- constructor(t) {
697
- S(this, "config");
698
- this.config = t;
699
- }
700
- /**
701
- * Prepares a peg-in by building the Pre-PegIn HTLC transaction,
702
- * funding it, constructing the PegIn transaction, and signing the PegIn input.
703
- *
704
- * This method orchestrates the following steps:
705
- * 1. Get depositor BTC public key from wallet
706
- * 2. Build unfunded Pre-PegIn transaction (HTLC output) using primitives
707
- * 3. Select UTXOs to cover the HTLC value
708
- * 4. Fund the Pre-PegIn transaction
709
- * 5. Derive the PegIn transaction from the funded Pre-PegIn txid
710
- * 6. Build PSBT for signing the PegIn input (HTLC leaf 0)
711
- * 7. Sign via BTC wallet and extract depositor signature
712
- *
713
- * The returned `fundedPrePeginTxHex` is funded but unsigned (inputs unsigned).
714
- * Use `signAndBroadcast()` AFTER registering on Ethereum to broadcast it.
715
- *
716
- * @param params - Pegin parameters including amount, HTLC params, UTXOs
717
- * @returns Pegin result with funded Pre-PegIn tx, signed PegIn input, and signatures
718
- * @throws Error if wallet operations fail or insufficient funds
719
- */
720
- async preparePegin(t) {
721
- const e = await this.config.btcWallet.getPublicKeyHex(), r = e.length === 66 ? e.slice(2) : e, o = k(t.vaultProviderBtcPubkey), s = t.vaultKeeperBtcPubkeys.map(k), c = t.universalChallengerBtcPubkeys.map(k);
722
- if (t.hashlocks.length !== 1)
723
- throw new Error(
724
- "hashlocks must contain exactly one entry (batched deposits not yet supported)"
725
- );
726
- const i = s.length, a = {
727
- depositorPubkey: r,
728
- vaultProviderPubkey: o,
729
- vaultKeeperPubkeys: s,
730
- universalChallengerPubkeys: c,
731
- hashlocks: t.hashlocks,
732
- timelockRefund: t.timelockRefund,
733
- pegInAmount: t.amount,
734
- feeRate: t.protocolFeeRate,
735
- numLocalChallengers: i,
736
- councilQuorum: t.councilQuorum,
737
- councilSize: t.councilSize,
738
- network: this.config.btcNetwork
739
- }, u = await ot(a), l = ft(
740
- [...t.availableUTXOs],
741
- u.totalOutputValue,
742
- t.mempoolFeeRate
743
- ), p = C(this.config.btcNetwork), h = at({
744
- unfundedTxHex: u.psbtHex,
745
- selectedUTXOs: l.selectedUTXOs,
746
- changeAddress: t.changeAddress,
747
- changeAmount: l.changeAmount,
748
- network: p
749
- }), y = k(_(h)), m = await it({
750
- prePeginParams: a,
751
- timelockPegin: t.timelockPegin,
752
- fundedPrePeginTxHex: h,
753
- htlcVout: D
754
- }), x = await ct({
755
- peginTxHex: m.txHex,
756
- fundedPrePeginTxHex: h,
757
- depositorPubkey: r,
758
- vaultProviderPubkey: o,
759
- vaultKeeperPubkeys: s,
760
- universalChallengerPubkeys: c,
761
- hashlock: t.hashlocks[0],
762
- timelockRefund: t.timelockRefund,
763
- network: this.config.btcNetwork
764
- }), d = await this.config.btcWallet.signPsbt(
765
- x.psbtHex,
766
- O(e, 1)
767
- ), f = ut(
768
- d,
769
- r
770
- ), b = lt(d);
771
- return {
772
- fundedPrePeginTxHex: h,
773
- htlcValue: u.htlcValue,
774
- signedPeginInputPsbtHex: d,
775
- peginInputSignature: f,
776
- vaultScriptPubKey: m.vaultScriptPubKey,
777
- peginTxHex: b,
778
- prePeginTxid: y,
779
- peginTxid: m.txid,
780
- selectedUTXOs: l.selectedUTXOs,
781
- fee: l.fee,
782
- changeAmount: l.changeAmount
783
- };
784
- }
785
- /**
786
- * Signs and broadcasts a funded peg-in transaction to the Bitcoin network.
787
- *
788
- * This method:
789
- * 1. Parses the funded transaction hex
790
- * 2. Fetches UTXO data from mempool for each input
791
- * 3. Creates a PSBT with proper witnessUtxo/tapInternalKey
792
- * 4. Signs via btcWallet.signPsbt()
793
- * 5. Finalizes and extracts the transaction
794
- * 6. Broadcasts via mempool API
795
- *
796
- * @param params - Transaction hex and depositor public key
797
- * @returns The broadcasted Bitcoin transaction ID
798
- * @throws Error if signing or broadcasting fails
799
- */
800
- async signAndBroadcast(t) {
801
- const { fundedPrePeginTxHex: e, depositorBtcPubkey: r } = t, o = e.startsWith("0x") ? e.slice(2) : e, s = $.fromHex(o);
802
- if (s.ins.length === 0)
803
- throw new Error("Transaction has no inputs");
804
- const c = new F();
805
- c.setVersion(s.version), c.setLocktime(s.locktime);
806
- const i = r.startsWith("0x") ? r.slice(2) : r;
807
- if (i.length !== 64 || !/^[0-9a-fA-F]+$/.test(i))
808
- throw new Error(
809
- "Invalid depositorBtcPubkey: expected 64 hex characters (x-only pubkey)"
810
- );
811
- const a = g.from(i, "hex");
812
- if (a.length !== 32)
813
- throw new Error(
814
- `Invalid depositorBtcPubkey length: expected 32 bytes, got ${a.length}`
815
- );
816
- const u = this.config.mempoolApiUrl, l = s.ins.map((d) => {
817
- const f = g.from(d.hash).reverse().toString("hex"), b = d.index;
818
- return Tt(f, b, u).then((w) => ({
819
- input: d,
820
- utxoData: w,
821
- txid: f,
822
- vout: b
823
- }));
824
- }), p = await Promise.all(l);
825
- for (const { input: d, utxoData: f, txid: b, vout: w } of p) {
826
- const T = yt(
827
- {
828
- value: f.value,
829
- scriptPubKey: f.scriptPubKey
830
- },
831
- a
832
- );
833
- c.addInput({
834
- hash: d.hash,
835
- index: d.index,
836
- sequence: d.sequence,
837
- ...T
838
- });
839
- }
840
- for (const d of s.outs)
841
- c.addOutput({
842
- script: d.script,
843
- value: d.value
844
- });
845
- const h = await this.config.btcWallet.signPsbt(c.toHex()), y = F.fromHex(h);
846
- try {
847
- y.finalizeAllInputs();
848
- } catch (d) {
849
- if (!y.data.inputs.every(
850
- (b) => b.finalScriptWitness || b.finalScriptSig
851
- ))
852
- throw new Error(
853
- `PSBT finalization failed and wallet did not auto-finalize: ${d}`
854
- );
855
- }
856
- const m = y.extractTransaction().toHex();
857
- return await xt(m, u);
858
- }
859
- /**
860
- * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
861
- *
862
- * This method:
863
- * 1. Gets depositor ETH address from wallet
864
- * 2. Creates proof of possession (BTC signature of ETH address)
865
- * 3. Checks if vault already exists (pre-flight check)
866
- * 4. Encodes the contract call using viem
867
- * 5. Estimates gas (catches contract errors early with proper revert reasons)
868
- * 6. Sends transaction with pre-estimated gas via ethWallet.sendTransaction()
869
- *
870
- * @param params - Registration parameters including BTC pubkey and unsigned tx
871
- * @returns Result containing Ethereum transaction hash and vault ID
872
- * @throws Error if signing or transaction fails
873
- * @throws Error if vault already exists
874
- * @throws Error if contract simulation fails (e.g., invalid signature, unauthorized)
875
- */
876
- async registerPeginOnChain(t) {
877
- const {
878
- depositorBtcPubkey: e,
879
- unsignedPrePeginTx: r,
880
- depositorSignedPeginTx: o,
881
- vaultProvider: s,
882
- hashlock: c,
883
- onPopSigned: i,
884
- depositorPayoutBtcAddress: a,
885
- depositorLamportPkHash: u,
886
- preSignedBtcPopSignature: l
887
- } = t;
888
- if (!this.config.ethWallet.account)
889
- throw new Error("Ethereum wallet account not found");
890
- const p = this.config.ethWallet.account.address, h = await this.resolvePopSignature(
891
- p,
892
- l
893
- );
894
- i && await i();
895
- const y = B(e), m = B(r), x = B(o), d = await this.resolvePayoutScriptPubKey(
896
- a
897
- ), f = _(x);
898
- if (await this.checkVaultExists(f))
899
- throw new Error(
900
- `Vault already exists for this transaction (ID: ${f}). Vault IDs are deterministically derived from the unsigned Bitcoin transaction, so using the same UTXOs and amount will always produce the same vault. To create a new vault, please use different UTXOs or a different amount to generate a unique transaction.`
901
- );
902
- const w = M({
903
- chain: this.config.ethChain,
904
- transport: X()
905
- });
906
- let T;
907
- try {
908
- T = await w.readContract({
909
- address: this.config.vaultContracts.btcVaultRegistry,
910
- abi: H,
911
- functionName: "getPegInFee",
912
- args: [s]
913
- });
914
- } catch {
915
- throw new Error(
916
- "Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct."
917
- );
918
- }
919
- const A = pt({
920
- abi: H,
921
- functionName: "submitPeginRequest",
922
- args: [
923
- p,
924
- y,
925
- h,
926
- m,
927
- x,
928
- s,
929
- c,
930
- D,
931
- d,
932
- u
933
- ]
934
- });
935
- let V;
936
- try {
937
- V = await w.estimateGas({
938
- to: this.config.vaultContracts.btcVaultRegistry,
939
- data: A,
940
- value: T,
941
- account: this.config.ethWallet.account.address
942
- });
943
- } catch (v) {
944
- z(v);
945
- }
946
- try {
947
- return {
948
- ethTxHash: await this.config.ethWallet.sendTransaction({
949
- to: this.config.vaultContracts.btcVaultRegistry,
950
- data: A,
951
- value: T,
952
- account: this.config.ethWallet.account,
953
- chain: this.config.ethChain,
954
- gas: V
955
- }),
956
- vaultId: f,
957
- btcPopSignature: h
958
- };
959
- } catch (v) {
960
- z(v);
961
- }
962
- }
963
- /**
964
- * Check if a vault already exists for a given vault ID.
965
- *
966
- * @param vaultId - The Bitcoin transaction hash (vault ID)
967
- * @returns True if vault exists, false otherwise
968
- */
969
- async checkVaultExists(t) {
970
- try {
971
- return (await M({
972
- chain: this.config.ethChain,
973
- transport: X()
974
- }).readContract({
975
- address: this.config.vaultContracts.btcVaultRegistry,
976
- abi: H,
977
- functionName: "getBTCVault",
978
- args: [t]
979
- })).depositor !== ht;
980
- } catch {
981
- return !1;
982
- }
983
- }
984
- /**
985
- * Resolve the BTC payout address to a scriptPubKey hex for the contract.
986
- *
987
- * If a payout address is provided, converts it directly.
988
- * If omitted, uses the wallet's address and validates it against the
989
- * wallet's public key to guard against a compromised wallet provider.
990
- */
991
- async resolvePayoutScriptPubKey(t) {
992
- let e;
993
- if (t)
994
- e = t;
995
- else {
996
- e = await this.config.btcWallet.getAddress();
997
- const o = await this.config.btcWallet.getPublicKeyHex();
998
- if (!dt(
999
- e,
1000
- o,
1001
- this.config.btcNetwork
1002
- ))
1003
- throw new Error(
1004
- "The BTC address from your wallet does not match the wallet's public key. Please ensure your wallet is using a supported address type (Taproot or Native SegWit)."
1005
- );
1006
- }
1007
- const r = C(this.config.btcNetwork);
1008
- try {
1009
- return `0x${Q.address.toOutputScript(e, r).toString("hex")}`;
1010
- } catch {
1011
- throw new Error(
1012
- `Invalid BTC payout address: "${e}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
1013
- );
1014
- }
1015
- }
1016
- /**
1017
- * Resolve or create a BTC Proof-of-Possession signature.
1018
- *
1019
- * Reuses a pre-signed signature when provided (e.g. multi-vault deposits),
1020
- * otherwise signs a BIP-322 message with the BTC wallet.
1021
- */
1022
- async resolvePopSignature(t, e) {
1023
- if (e)
1024
- return e;
1025
- const r = this.config.vaultContracts.btcVaultRegistry, o = `${t.toLowerCase()}:${this.config.ethChain.id}:pegin:${r.toLowerCase()}`, s = await this.config.btcWallet.signMessage(
1026
- o,
1027
- "bip322-simple"
1028
- );
1029
- return s.startsWith("0x") ? s : `0x${g.from(s, "base64").toString("hex")}`;
1030
- }
1031
- /**
1032
- * Gets the configured Bitcoin network.
1033
- *
1034
- * @returns The Bitcoin network (mainnet, testnet, signet, regtest)
1035
- */
1036
- getNetwork() {
1037
- return this.config.btcNetwork;
1038
- }
1039
- /**
1040
- * Gets the configured BTCVaultRegistry contract address.
1041
- *
1042
- * @returns The Ethereum address of the BTCVaultRegistry contract
1043
- */
1044
- getVaultContractAddress() {
1045
- return this.config.vaultContracts.btcVaultRegistry;
1046
- }
1047
- }
1048
- class Xt {
1049
- /**
1050
- * Creates a new PayoutManager instance.
1051
- *
1052
- * @param config - Manager configuration including wallet
1053
- */
1054
- constructor(t) {
1055
- S(this, "config");
1056
- this.config = t;
1057
- }
1058
- /**
1059
- * Signs a Payout transaction and extracts the Schnorr signature.
1060
- *
1061
- * Flow:
1062
- * 1. Vault provider submits Claim transaction
1063
- * 2. Claimer submits Assert transaction to prove validity
1064
- * 3. Payout can be executed (references Assert tx)
1065
- *
1066
- * This method orchestrates the following steps:
1067
- * 1. Get wallet's public key and convert to x-only format
1068
- * 2. Validate wallet pubkey matches on-chain depositor pubkey (if provided)
1069
- * 3. Build unsigned PSBT using primitives
1070
- * 4. Sign PSBT via btcWallet.signPsbt()
1071
- * 5. Extract 64-byte Schnorr signature using primitives
1072
- *
1073
- * The returned signature can be submitted to the vault provider API.
1074
- *
1075
- * @param params - Payout signing parameters
1076
- * @returns Signature result with 64-byte Schnorr signature and depositor pubkey
1077
- * @throws Error if wallet pubkey doesn't match depositor pubkey
1078
- * @throws Error if wallet operations fail or signature extraction fails
1079
- */
1080
- async signPayoutTransaction(t) {
1081
- const e = await this.config.btcWallet.getPublicKeyHex(), { depositorPubkey: r } = W(
1082
- e,
1083
- t.depositorBtcPubkey
1084
- ), o = await N({
1085
- payoutTxHex: t.payoutTxHex,
1086
- peginTxHex: t.peginTxHex,
1087
- assertTxHex: t.assertTxHex,
1088
- depositorBtcPubkey: r,
1089
- vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
1090
- vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
1091
- universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
1092
- timelockPegin: t.timelockPegin,
1093
- network: this.config.network
1094
- }), s = await this.config.btcWallet.signPsbt(
1095
- o.psbtHex,
1096
- O(e, 1)
1097
- );
1098
- return {
1099
- signature: K(s, r),
1100
- depositorBtcPubkey: r
1101
- };
1102
- }
1103
- /**
1104
- * Gets the configured Bitcoin network.
1105
- *
1106
- * @returns The Bitcoin network (mainnet, testnet, signet, regtest)
1107
- */
1108
- getNetwork() {
1109
- return this.config.network;
1110
- }
1111
- /**
1112
- * Checks if the wallet supports batch signing (signPsbts).
1113
- *
1114
- * @returns true if batch signing is supported
1115
- */
1116
- supportsBatchSigning() {
1117
- return typeof this.config.btcWallet.signPsbts == "function";
1118
- }
1119
- /**
1120
- * Batch signs multiple payout transactions (1 per claimer).
1121
- * This allows signing all transactions with a single wallet interaction.
1122
- *
1123
- * @param transactions - Array of payout params to sign
1124
- * @returns Array of signature results matching input order
1125
- * @throws Error if wallet doesn't support batch signing
1126
- * @throws Error if any signing operation fails
1127
- */
1128
- async signPayoutTransactionsBatch(t) {
1129
- if (!this.supportsBatchSigning())
1130
- throw new Error(
1131
- "Wallet does not support batch signing (signPsbts method not available)"
1132
- );
1133
- const e = await this.config.btcWallet.getPublicKeyHex(), r = [], o = [], s = [];
1134
- for (const a of t) {
1135
- const { depositorPubkey: u } = W(
1136
- e,
1137
- a.depositorBtcPubkey
1138
- );
1139
- s.push(u);
1140
- const l = await N({
1141
- payoutTxHex: a.payoutTxHex,
1142
- peginTxHex: a.peginTxHex,
1143
- assertTxHex: a.assertTxHex,
1144
- depositorBtcPubkey: u,
1145
- vaultProviderBtcPubkey: a.vaultProviderBtcPubkey,
1146
- vaultKeeperBtcPubkeys: a.vaultKeeperBtcPubkeys,
1147
- universalChallengerBtcPubkeys: a.universalChallengerBtcPubkeys,
1148
- timelockPegin: a.timelockPegin,
1149
- network: this.config.network
1150
- });
1151
- r.push(l.psbtHex), o.push(O(e, 1));
1152
- }
1153
- const c = await this.config.btcWallet.signPsbts(
1154
- r,
1155
- o
1156
- );
1157
- if (c.length !== t.length)
1158
- throw new Error(
1159
- `Expected ${t.length} signed PSBTs but received ${c.length}`
1160
- );
1161
- const i = [];
1162
- for (let a = 0; a < t.length; a++) {
1163
- const u = s[a], l = K(
1164
- c[a],
1165
- u
1166
- );
1167
- i.push({
1168
- payoutSignature: l,
1169
- depositorBtcPubkey: u
1170
- });
1171
- }
1172
- return i;
1173
- }
1174
- }
1175
- export {
1176
- E as B,
1177
- P as C,
1178
- Pt as M,
1179
- Mt as P,
1180
- Ht as a,
1181
- Ct as b,
1182
- _ as c,
1183
- Ot as d,
1184
- gt as e,
1185
- yt as f,
1186
- Ft as g,
1187
- Xt as h,
1188
- Rt as i,
1189
- At as j,
1190
- Vt as k,
1191
- Wt as l,
1192
- Ut as m,
1193
- wt as n,
1194
- Tt as o,
1195
- xt as p,
1196
- H as q,
1197
- U as r,
1198
- ft as s,
1199
- Nt as t,
1200
- Kt as u,
1201
- z as v
1202
- };
1203
- //# sourceMappingURL=PayoutManager-6IBl1Fdt.js.map