@babylonlabs-io/ts-sdk 0.28.1 → 0.30.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 (74) hide show
  1. package/dist/PeginManager-Zrv-ncJi.cjs +2 -0
  2. package/dist/PeginManager-Zrv-ncJi.cjs.map +1 -0
  3. package/dist/{PeginManager-DzMSIQ0I.js → PeginManager-_pamUKlS.js} +622 -580
  4. package/dist/PeginManager-_pamUKlS.js.map +1 -0
  5. package/dist/{buildAndBroadcastRefund-xWS8frc6.js → buildAndBroadcastRefund-BY6mYmFl.js} +406 -303
  6. package/dist/buildAndBroadcastRefund-BY6mYmFl.js.map +1 -0
  7. package/dist/buildAndBroadcastRefund-CO60ReNf.cjs +2 -0
  8. package/dist/buildAndBroadcastRefund-CO60ReNf.cjs.map +1 -0
  9. package/dist/challengeAssert-mYikGC34.js +269 -0
  10. package/dist/challengeAssert-mYikGC34.js.map +1 -0
  11. package/dist/challengeAssert-yYFflBOx.cjs +2 -0
  12. package/dist/challengeAssert-yYFflBOx.cjs.map +1 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.js +144 -143
  15. package/dist/noPayout-B8JiTaYt.js +333 -0
  16. package/dist/noPayout-B8JiTaYt.js.map +1 -0
  17. package/dist/noPayout-CwgYkZYs.cjs +2 -0
  18. package/dist/noPayout-CwgYkZYs.cjs.map +1 -0
  19. package/dist/tbv/core/index.cjs +1 -1
  20. package/dist/tbv/core/index.js +145 -144
  21. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  22. package/dist/tbv/core/managers/PeginManager.d.ts +17 -14
  23. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  24. package/dist/tbv/core/managers/pegin/__tests__/assertAuthAnchorOpReturn.test.d.ts +2 -0
  25. package/dist/tbv/core/managers/pegin/__tests__/assertAuthAnchorOpReturn.test.d.ts.map +1 -0
  26. package/dist/tbv/core/managers/pegin/__tests__/expandPerVaultSecrets.test.d.ts +2 -0
  27. package/dist/tbv/core/managers/pegin/__tests__/expandPerVaultSecrets.test.d.ts.map +1 -0
  28. package/dist/tbv/core/managers/pegin/__tests__/normalizeWalletInputs.test.d.ts +2 -0
  29. package/dist/tbv/core/managers/pegin/__tests__/normalizeWalletInputs.test.d.ts.map +1 -0
  30. package/dist/tbv/core/managers/pegin/__tests__/signPsbtsWithFallback.test.d.ts +2 -0
  31. package/dist/tbv/core/managers/pegin/__tests__/signPsbtsWithFallback.test.d.ts.map +1 -0
  32. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts +25 -0
  33. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts.map +1 -0
  34. package/dist/tbv/core/managers/pegin/expandPerVaultSecrets.d.ts +25 -0
  35. package/dist/tbv/core/managers/pegin/expandPerVaultSecrets.d.ts.map +1 -0
  36. package/dist/tbv/core/managers/pegin/index.d.ts +12 -0
  37. package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -0
  38. package/dist/tbv/core/managers/pegin/normalizeWalletInputs.d.ts +23 -0
  39. package/dist/tbv/core/managers/pegin/normalizeWalletInputs.d.ts.map +1 -0
  40. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts +12 -0
  41. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts.map +1 -0
  42. package/dist/tbv/core/primitives/index.cjs +1 -1
  43. package/dist/tbv/core/primitives/index.d.ts +1 -1
  44. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  45. package/dist/tbv/core/primitives/index.js +26 -25
  46. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +18 -1
  47. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
  48. package/dist/tbv/core/primitives/psbt/payout.d.ts +15 -0
  49. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  50. package/dist/tbv/core/services/deposit/index.d.ts +1 -1
  51. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  52. package/dist/tbv/core/services/deposit/signAndSubmitPayouts.d.ts +21 -0
  53. package/dist/tbv/core/services/deposit/signAndSubmitPayouts.d.ts.map +1 -1
  54. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +50 -4
  55. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  56. package/dist/tbv/core/services/index.cjs +1 -1
  57. package/dist/tbv/core/services/index.js +1 -1
  58. package/dist/tbv/index.cjs +1 -1
  59. package/dist/tbv/index.js +145 -144
  60. package/package.json +1 -1
  61. package/dist/PeginManager-Da4uSHzl.cjs +0 -2
  62. package/dist/PeginManager-Da4uSHzl.cjs.map +0 -1
  63. package/dist/PeginManager-DzMSIQ0I.js.map +0 -1
  64. package/dist/buildAndBroadcastRefund-DkEpTFkv.cjs +0 -2
  65. package/dist/buildAndBroadcastRefund-DkEpTFkv.cjs.map +0 -1
  66. package/dist/buildAndBroadcastRefund-xWS8frc6.js.map +0 -1
  67. package/dist/challengeAssert-BM8m9gPM.cjs +0 -2
  68. package/dist/challengeAssert-BM8m9gPM.cjs.map +0 -1
  69. package/dist/challengeAssert-j2Vwqo0-.js +0 -304
  70. package/dist/challengeAssert-j2Vwqo0-.js.map +0 -1
  71. package/dist/payout-B_fvQU3q.js +0 -261
  72. package/dist/payout-B_fvQU3q.js.map +0 -1
  73. package/dist/payout-DP6KMFP1.cjs +0 -2
  74. package/dist/payout-DP6KMFP1.cjs.map +0 -1
@@ -1,16 +1,16 @@
1
- var W = Object.defineProperty;
2
- var X = (e, t, r) => t in e ? W(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var y = (e, t, r) => X(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { B as G, c as Y, a as j, R as q, d as N, D as g } from "./types-CnG3JsRs.js";
5
- import { e as Q, s as l, v as A, b as J, p as P, f } from "./bitcoin-B-Y0DlqR.js";
1
+ var z = Object.defineProperty;
2
+ var G = (e, t, r) => t in e ? z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var x = (e, t, r) => G(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { B as Q, c as Y, a as j, R as q, d as O, D as y } from "./types-CnG3JsRs.js";
5
+ import { e as J, s as c, u as K, v as H, p as m, f } from "./bitcoin-B-Y0DlqR.js";
6
6
  import { s as Z } from "./sha2-6wN58S6R.js";
7
7
  import * as ee from "bitcoinjs-lib";
8
- import { Psbt as B, Transaction as te } from "bitcoinjs-lib";
9
- import { Buffer as V } from "buffer";
8
+ import { Transaction as w, Psbt as te } from "bitcoinjs-lib";
9
+ import { Buffer as re } from "buffer";
10
10
  import { c as b } from "./signing-BZigafm0.js";
11
11
  import "@babylonlabs-io/babylon-tbv-rust-wasm";
12
- import { e as w, a as I, b as re } from "./payout-B_fvQU3q.js";
13
- const H = 66;
12
+ import { a as V, c as S, e as v, g as oe, d as ne, b as se } from "./noPayout-B8JiTaYt.js";
13
+ const $ = 66;
14
14
  function L(e) {
15
15
  if (!e.startsWith("0x") && !e.startsWith("0X"))
16
16
  throw new Error("Expected 0x-prefixed hex string");
@@ -24,201 +24,300 @@ function L(e) {
24
24
  r[o] = parseInt(t.slice(o * 2, o * 2 + 2), 16);
25
25
  return r;
26
26
  }
27
- function oe(e) {
27
+ function ie(e) {
28
28
  return `0x${Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("")}`;
29
29
  }
30
- function S(e, t) {
31
- if (e.length !== H)
30
+ function A(e, t) {
31
+ if (e.length !== $)
32
32
  throw new Error(
33
- `${t} must be exactly 32 bytes (${H} hex chars with 0x prefix), got ${e.length}`
33
+ `${t} must be exactly 32 bytes (${$} hex chars with 0x prefix), got ${e.length}`
34
34
  );
35
35
  }
36
- function ne(e) {
37
- S(e, "Secret");
36
+ function ae(e) {
37
+ A(e, "Secret");
38
38
  const t = L(e), r = Z(t);
39
- return oe(r);
39
+ return ie(r);
40
40
  }
41
- function ie(e, t) {
42
- return S(e, "Secret"), S(t, "Hashlock"), L(t), ne(e).toLowerCase() === t.toLowerCase();
41
+ function ue(e, t) {
42
+ return A(e, "Secret"), A(t, "Hashlock"), L(t), ae(e).toLowerCase() === t.toLowerCase();
43
43
  }
44
- const se = /^0x[0-9a-fA-F]{64}$/, ae = /^0x[0-9a-fA-F]{40}$/, ue = /^0x([0-9a-fA-F]{2})*$/;
44
+ const le = /^0x[0-9a-fA-F]{64}$/, ce = /^0x[0-9a-fA-F]{40}$/, de = /^0x([0-9a-fA-F]{2})*$/;
45
45
  function E(e, t) {
46
46
  if (e.length !== 66)
47
47
  throw new Error(
48
48
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
49
49
  );
50
- if (!se.test(e))
50
+ if (!le.test(e))
51
51
  throw new Error(
52
52
  `${t} must contain only hex characters after the 0x prefix`
53
53
  );
54
54
  }
55
- function ce(e, t) {
56
- if (!ae.test(e))
55
+ function he(e, t) {
56
+ if (!ce.test(e))
57
57
  throw new Error(
58
58
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
59
59
  );
60
60
  }
61
- function le(e, t) {
62
- if (!ue.test(e))
61
+ function pe(e, t) {
62
+ if (!de.test(e))
63
63
  throw new Error(
64
64
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
65
65
  );
66
66
  }
67
- async function Je(e) {
67
+ async function rt(e) {
68
68
  const {
69
69
  btcVaultRegistryAddress: t,
70
70
  vaultId: r,
71
71
  hashlock: o,
72
72
  activationMetadata: i,
73
- writeContract: c,
74
- signal: a
73
+ writeContract: u,
74
+ signal: s
75
75
  } = e;
76
- a == null || a.throwIfAborted(), ce(t, "btcVaultRegistryAddress"), E(r, "vaultId");
77
- const s = Q(e.secret);
78
- if (E(s, "secret"), o !== void 0 && (E(o, "hashlock"), !ie(s, o)))
76
+ s == null || s.throwIfAborted(), he(t, "btcVaultRegistryAddress"), E(r, "vaultId");
77
+ const a = J(e.secret);
78
+ if (E(a, "secret"), o !== void 0 && (E(o, "hashlock"), !ue(a, o)))
79
79
  throw new Error(
80
80
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
81
81
  );
82
- return le(i, "activationMetadata"), c({
82
+ return pe(i, "activationMetadata"), u({
83
83
  address: t,
84
- abi: G,
84
+ abi: Q,
85
85
  functionName: "activateVaultWithSecret",
86
- args: [r, s, i]
86
+ args: [r, a, i]
87
87
  });
88
88
  }
89
- const de = 1e4;
89
+ const fe = 1e4;
90
90
  async function D(e) {
91
91
  const {
92
92
  statusReader: t,
93
93
  peginTxid: r,
94
94
  targetStatuses: o,
95
95
  timeoutMs: i,
96
- pollIntervalMs: c = de,
97
- signal: a
98
- } = e, s = Date.now();
96
+ pollIntervalMs: u = fe,
97
+ signal: s
98
+ } = e, a = Date.now();
99
99
  for (; ; ) {
100
- if (a != null && a.aborted)
100
+ if (s != null && s.aborted)
101
101
  throw new Error(
102
102
  `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
103
103
  );
104
- if (Date.now() - s >= i)
104
+ if (Date.now() - a >= i)
105
105
  throw new Error(
106
106
  `Polling timeout after ${i}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
107
107
  );
108
108
  try {
109
- const u = (await t.getPeginStatus(
109
+ const l = (await t.getPeginStatus(
110
110
  { pegin_txid: r },
111
- a
111
+ s
112
112
  )).status;
113
- if (o.has(u))
114
- return u;
115
- if (Y.has(u) && !o.has(u))
113
+ if (o.has(l))
114
+ return l;
115
+ if (Y.has(l) && !o.has(l))
116
116
  throw new Error(
117
- `Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...o].join(", ")}`
117
+ `Pegin ${r.slice(0, 8)}… reached terminal status "${l}" while waiting for ${[...o].join(", ")}`
118
118
  );
119
119
  } catch (n) {
120
120
  if (!(n instanceof j && n.code === q.NOT_FOUND || n instanceof Error && n.message.includes("PegIn not found")))
121
121
  throw n;
122
122
  }
123
- await new Promise((n, u) => {
123
+ await new Promise((n, l) => {
124
124
  const d = () => {
125
- clearTimeout(h), u(
125
+ clearTimeout(h), l(
126
126
  new Error(
127
127
  `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
128
128
  )
129
129
  );
130
130
  }, h = setTimeout(() => {
131
- a == null || a.removeEventListener("abort", d), n();
132
- }, c);
133
- a == null || a.addEventListener("abort", d, { once: !0 });
131
+ s == null || s.removeEventListener("abort", d), n();
132
+ }, u);
133
+ s == null || s.addEventListener("abort", d, { once: !0 });
134
134
  });
135
135
  }
136
136
  }
137
- const pe = 300 * 1e3, fe = /* @__PURE__ */ new Set([
138
- g.PENDING_DEPOSITOR_WOTS_PK,
139
- ...N
137
+ const ge = 300 * 1e3, Pe = /* @__PURE__ */ new Set([
138
+ y.PENDING_DEPOSITOR_WOTS_PK,
139
+ ...O
140
140
  ]);
141
- async function Ze(e) {
141
+ async function ot(e) {
142
142
  const {
143
143
  statusReader: t,
144
144
  wotsSubmitter: r,
145
145
  peginTxid: o,
146
146
  depositorPk: i,
147
- wotsPublicKeys: c,
148
- timeoutMs: a = pe,
149
- signal: s
147
+ wotsPublicKeys: u,
148
+ timeoutMs: s = ge,
149
+ signal: a
150
150
  } = e;
151
- s == null || s.throwIfAborted();
151
+ a == null || a.throwIfAborted();
152
152
  const n = await D({
153
153
  statusReader: t,
154
154
  peginTxid: o,
155
- targetStatuses: fe,
156
- timeoutMs: a,
157
- signal: s
155
+ targetStatuses: Pe,
156
+ timeoutMs: s,
157
+ signal: a
158
158
  });
159
- N.has(n) || (s == null || s.throwIfAborted(), await r.submitDepositorWotsKey(
159
+ O.has(n) || (a == null || a.throwIfAborted(), await r.submitDepositorWotsKey(
160
160
  {
161
161
  pegin_txid: o,
162
162
  depositor_pk: i,
163
- wots_public_keys: c
163
+ wots_public_keys: u
164
164
  },
165
- s
165
+ a
166
166
  ));
167
167
  }
168
- const R = 1;
169
- function he(e, t, r) {
170
- const o = B.fromBase64(e), i = o.data.getTransaction().toString("hex").toLowerCase(), c = l(t).toLowerCase();
171
- if (i !== c)
168
+ const I = 1;
169
+ function ye(e, t, r) {
170
+ const o = c(r).toLowerCase(), u = [e, ...t].map(
171
+ (s) => c(s).toLowerCase()
172
+ ).filter((s) => s !== o);
173
+ if (u.length === 0)
172
174
  throw new Error(
173
- `PSBT integrity check failed for ${r}: unsigned transaction does not match tx_hex`
175
+ "Cannot derive localChallengers: removing depositor from {vaultProvider, vaultKeepers} left an empty set"
174
176
  );
175
- return o;
177
+ return u;
176
178
  }
177
- function ge(e) {
178
- const t = B.fromHex(e.toHex());
179
- for (const r of t.data.inputs)
180
- delete r.tapBip32Derivation, delete r.tapMerkleRoot;
181
- return t;
179
+ function be(e, t) {
180
+ const r = e.ins[t];
181
+ return K(new Uint8Array(r.hash).slice().reverse());
182
182
  }
183
- function $(e, t, r) {
184
- if (!e)
185
- throw new Error(`Missing ${r} PSBT`);
186
- const o = he(e, t, r);
187
- return ge(o).toHex();
183
+ function _(e, t, r, o, i) {
184
+ const u = e.ins[t];
185
+ if (u.index !== 0)
186
+ throw new Error(
187
+ `NoPayout (challenger ${i}) input ${t} expected to spend ${o} vout 0, got vout ${u.index}`
188
+ );
189
+ const s = r.getId(), a = be(e, t);
190
+ if (a !== s)
191
+ throw new Error(
192
+ `NoPayout (challenger ${i}) input ${t} does not reference ${o} (expected txid ${s}, got ${a})`
193
+ );
188
194
  }
189
- function be(e, t) {
190
- const r = [], o = [], i = [], c = $(
191
- e.payout_psbt,
195
+ async function xe(e, t, r) {
196
+ const o = [], i = [], u = [];
197
+ V(
192
198
  e.payout_tx.tx_hex,
193
- "depositor payout"
199
+ r.registeredPayoutScriptPubKey
200
+ );
201
+ const s = await S({
202
+ payoutTxHex: e.payout_tx.tx_hex,
203
+ peginTxHex: r.peginTxHex,
204
+ assertTxHex: e.assert_tx.tx_hex,
205
+ depositorBtcPubkey: r.depositorBtcPubkey,
206
+ vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
207
+ vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
208
+ universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
209
+ timelockPegin: r.timelockPegin,
210
+ network: r.network
211
+ });
212
+ o.push(s.psbtHex), i.push(
213
+ b(
214
+ t,
215
+ I
216
+ )
194
217
  );
195
- r.push(c), o.push(
196
- b(t, R)
218
+ const a = ye(
219
+ r.vaultProviderBtcPubkey,
220
+ r.vaultKeeperBtcPubkeys,
221
+ r.depositorBtcPubkey
222
+ ), n = c(r.depositorBtcPubkey), l = w.fromHex(
223
+ c(e.assert_tx.tx_hex)
197
224
  );
198
- for (const a of e.challenger_presign_data) {
199
- const s = l(a.challenger_pubkey), n = r.length, u = $(
200
- a.nopayout_psbt,
201
- a.nopayout_tx.tx_hex,
202
- `nopayout (challenger ${s})`
203
- );
204
- r.push(u), o.push(
205
- b(t, R)
206
- ), i.push({
207
- challengerPubkey: s,
208
- noPayoutIdx: n
225
+ for (const d of e.challenger_presign_data) {
226
+ const h = c(d.challenger_pubkey), g = o.length, P = await we({
227
+ challenger: d,
228
+ challengerPubkey: h,
229
+ claimerPubkey: n,
230
+ localChallengers: a,
231
+ assertTxParsed: l,
232
+ ctx: r
233
+ });
234
+ o.push(P), i.push(
235
+ b(
236
+ t,
237
+ I
238
+ )
239
+ ), u.push({
240
+ challengerPubkey: h,
241
+ noPayoutIdx: g
209
242
  });
210
243
  }
211
- return { psbtHexes: r, signOptions: o, challengerEntries: i };
244
+ return { psbtHexes: o, signOptions: i, challengerEntries: u };
212
245
  }
213
- function ye(e, t, r) {
214
- const o = w(
246
+ async function we(e) {
247
+ const {
248
+ challenger: t,
249
+ challengerPubkey: r,
250
+ claimerPubkey: o,
251
+ localChallengers: i,
252
+ assertTxParsed: u,
253
+ ctx: s
254
+ } = e;
255
+ oe(
256
+ t.nopayout_tx.tx_hex,
257
+ r,
258
+ s.network
259
+ );
260
+ const a = w.fromHex(
261
+ c(t.nopayout_tx.tx_hex)
262
+ ), n = w.fromHex(
263
+ c(t.challenge_assert_x_tx.tx_hex)
264
+ ), l = w.fromHex(
265
+ c(t.challenge_assert_y_tx.tx_hex)
266
+ );
267
+ if (a.ins.length !== 3)
268
+ throw new Error(
269
+ `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${a.ins.length}`
270
+ );
271
+ _(
272
+ a,
273
+ 0,
274
+ u,
275
+ "Assert",
276
+ r
277
+ ), _(
278
+ a,
279
+ 1,
280
+ n,
281
+ "ChallengeAssertX",
282
+ r
283
+ ), _(
284
+ a,
285
+ 2,
286
+ l,
287
+ "ChallengeAssertY",
288
+ r
289
+ );
290
+ const d = [
291
+ u.outs[0],
292
+ n.outs[0],
293
+ l.outs[0]
294
+ ].map((h) => ({
295
+ script_pubkey: K(new Uint8Array(h.script)),
296
+ value: h.value
297
+ }));
298
+ return ne({
299
+ noPayoutTxHex: t.nopayout_tx.tx_hex,
300
+ challengerPubkey: r,
301
+ prevouts: d,
302
+ connectorParams: {
303
+ claimer: o,
304
+ localChallengers: i,
305
+ universalChallengers: s.universalChallengerBtcPubkeys,
306
+ timelockAssert: s.timelockAssert,
307
+ councilMembers: s.councilMembers,
308
+ councilQuorum: s.councilQuorum
309
+ }
310
+ });
311
+ }
312
+ function me(e, t, r) {
313
+ const o = v(
215
314
  e[0],
216
315
  r
217
316
  ), i = {};
218
- for (const c of t)
219
- i[c.challengerPubkey] = {
220
- nopayout_signature: w(
221
- e[c.noPayoutIdx],
317
+ for (const u of t)
318
+ i[u.challengerPubkey] = {
319
+ nopayout_signature: v(
320
+ e[u.noPayoutIdx],
222
321
  r
223
322
  )
224
323
  };
@@ -229,7 +328,7 @@ function ye(e, t, r) {
229
328
  per_challenger: i
230
329
  };
231
330
  }
232
- async function Pe(e, t, r) {
331
+ async function ve(e, t, r) {
233
332
  if (typeof e.signPsbts == "function")
234
333
  return e.signPsbts(t, r);
235
334
  const o = [];
@@ -237,30 +336,34 @@ async function Pe(e, t, r) {
237
336
  o.push(await e.signPsbt(t[i], r == null ? void 0 : r[i]));
238
337
  return o;
239
338
  }
240
- async function we(e) {
241
- const { depositorGraph: t, depositorBtcPubkey: r, btcWallet: o } = e, i = l(r), c = await o.getPublicKeyHex(), { psbtHexes: a, signOptions: s, challengerEntries: n } = be(t, c), u = await Pe(
242
- o,
243
- a,
244
- s
339
+ async function ke(e) {
340
+ const { depositorGraph: t, btcWallet: r, signingContext: o } = e, i = c(o.depositorBtcPubkey), u = await r.getPublicKeyHex(), { psbtHexes: s, signOptions: a, challengerEntries: n } = await xe(
341
+ t,
342
+ u,
343
+ o
344
+ ), l = await ve(
345
+ r,
346
+ s,
347
+ a
245
348
  );
246
- if (u.length !== a.length)
349
+ if (l.length !== s.length)
247
350
  throw new Error(
248
- `Wallet returned ${u.length} signed PSBTs, expected ${a.length}`
351
+ `Wallet returned ${l.length} signed PSBTs, expected ${s.length}`
249
352
  );
250
- return ye(
251
- u,
353
+ return me(
354
+ l,
252
355
  n,
253
356
  i
254
357
  );
255
358
  }
256
- class xe {
359
+ class Te {
257
360
  /**
258
361
  * Creates a new PayoutManager instance.
259
362
  *
260
363
  * @param config - Manager configuration including wallet
261
364
  */
262
365
  constructor(t) {
263
- y(this, "config");
366
+ x(this, "config");
264
367
  this.config = t;
265
368
  }
266
369
  /**
@@ -290,10 +393,10 @@ class xe {
290
393
  t.payoutTxHex,
291
394
  t.registeredPayoutScriptPubKey
292
395
  );
293
- const r = await this.config.btcWallet.getPublicKeyHex(), { depositorPubkey: o } = A(
396
+ const r = await this.config.btcWallet.getPublicKeyHex(), { depositorPubkey: o } = H(
294
397
  r,
295
398
  t.depositorBtcPubkey
296
- ), i = await I({
399
+ ), i = await S({
297
400
  payoutTxHex: t.payoutTxHex,
298
401
  peginTxHex: t.peginTxHex,
299
402
  assertTxHex: t.assertTxHex,
@@ -303,12 +406,12 @@ class xe {
303
406
  universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
304
407
  timelockPegin: t.timelockPegin,
305
408
  network: this.config.network
306
- }), c = await this.config.btcWallet.signPsbt(
409
+ }), u = await this.config.btcWallet.signPsbt(
307
410
  i.psbtHex,
308
411
  b(r, 1)
309
412
  );
310
413
  return {
311
- signature: w(c, o),
414
+ signature: v(u, o),
312
415
  depositorBtcPubkey: o
313
416
  };
314
417
  }
@@ -342,22 +445,22 @@ class xe {
342
445
  throw new Error(
343
446
  "Wallet does not support batch signing (signPsbts method not available)"
344
447
  );
345
- const r = await this.config.btcWallet.getPublicKeyHex(), o = [], i = [], c = [];
448
+ const r = await this.config.btcWallet.getPublicKeyHex(), o = [], i = [], u = [];
346
449
  for (const n of t) {
347
450
  this.validatePayoutOutputs(
348
451
  n.payoutTxHex,
349
452
  n.registeredPayoutScriptPubKey
350
453
  );
351
- const { depositorPubkey: u } = A(
454
+ const { depositorPubkey: l } = H(
352
455
  r,
353
456
  n.depositorBtcPubkey
354
457
  );
355
- c.push(u);
356
- const d = await I({
458
+ u.push(l);
459
+ const d = await S({
357
460
  payoutTxHex: n.payoutTxHex,
358
461
  peginTxHex: n.peginTxHex,
359
462
  assertTxHex: n.assertTxHex,
360
- depositorBtcPubkey: u,
463
+ depositorBtcPubkey: l,
361
464
  vaultProviderBtcPubkey: n.vaultProviderBtcPubkey,
362
465
  vaultKeeperBtcPubkeys: n.vaultKeeperBtcPubkeys,
363
466
  universalChallengerBtcPubkeys: n.universalChallengerBtcPubkeys,
@@ -366,26 +469,26 @@ class xe {
366
469
  });
367
470
  o.push(d.psbtHex), i.push(b(r, 1));
368
471
  }
369
- const a = await this.config.btcWallet.signPsbts(
472
+ const s = await this.config.btcWallet.signPsbts(
370
473
  o,
371
474
  i
372
475
  );
373
- if (a.length !== t.length)
476
+ if (s.length !== t.length)
374
477
  throw new Error(
375
- `Expected ${t.length} signed PSBTs but received ${a.length}`
478
+ `Expected ${t.length} signed PSBTs but received ${s.length}`
376
479
  );
377
- const s = [];
480
+ const a = [];
378
481
  for (let n = 0; n < t.length; n++) {
379
- const u = c[n], d = w(
380
- a[n],
381
- u
482
+ const l = u[n], d = v(
483
+ s[n],
484
+ l
382
485
  );
383
- s.push({
486
+ a.push({
384
487
  payoutSignature: d,
385
- depositorBtcPubkey: u
488
+ depositorBtcPubkey: l
386
489
  });
387
490
  }
388
- return s;
491
+ return a;
389
492
  }
390
493
  /**
391
494
  * Validates that the payout transaction's largest output pays to the
@@ -402,64 +505,52 @@ class xe {
402
505
  * @throws Error if the largest output does not pay to the registered address
403
506
  */
404
507
  validatePayoutOutputs(t, r) {
405
- if (!J(r))
406
- throw new Error(
407
- "Invalid registeredPayoutScriptPubKey: not valid hex"
408
- );
409
- const o = V.from(
410
- l(r),
411
- "hex"
412
- ), i = te.fromHex(l(t));
413
- if (i.outs.length === 0)
414
- throw new Error("Payout transaction has no outputs");
415
- if (!i.outs.reduce(
416
- (a, s) => s.value > a.value ? s : a
417
- ).script.equals(o))
418
- throw new Error(
419
- "Payout transaction does not pay to the registered depositor payout address"
420
- );
508
+ V(
509
+ t,
510
+ r
511
+ );
421
512
  }
422
513
  }
423
- const me = 1200 * 1e3, K = /* @__PURE__ */ new Set([
424
- g.PENDING_ACKS,
425
- g.PENDING_ACTIVATION,
426
- g.ACTIVATED
427
- ]), Te = /* @__PURE__ */ new Set([
428
- g.PENDING_DEPOSITOR_SIGNATURES,
429
- ...K
514
+ const Ee = 1200 * 1e3, M = /* @__PURE__ */ new Set([
515
+ y.PENDING_ACKS,
516
+ y.PENDING_ACTIVATION,
517
+ y.ACTIVATED
518
+ ]), _e = /* @__PURE__ */ new Set([
519
+ y.PENDING_DEPOSITOR_SIGNATURES,
520
+ ...M
430
521
  ]);
431
- function ve(e) {
522
+ function Be(e) {
432
523
  return e.map((t) => ({
433
- claimerPubkeyXOnly: P(t.claimer_pubkey),
524
+ claimerPubkeyXOnly: m(t.claimer_pubkey),
434
525
  payoutTxHex: t.payout_tx.tx_hex,
435
526
  assertTxHex: t.assert_tx.tx_hex
436
527
  }));
437
528
  }
438
- function Ee(e) {
529
+ function Se(e) {
439
530
  const { output: t } = ee.payments.p2tr({
440
- internalPubkey: V.from(e, "hex")
531
+ internalPubkey: re.from(e, "hex")
441
532
  });
442
533
  if (!t)
443
534
  throw new Error("Failed to derive BIP-86 P2TR scriptPubKey");
444
535
  return t.toString("hex");
445
536
  }
446
- function ke(e, t) {
447
- const r = l(e).toLowerCase(), o = l(
537
+ function Ae(e, t) {
538
+ const r = c(e).toLowerCase(), o = c(
448
539
  t.vaultProviderBtcPubkey
449
- ).toLowerCase(), i = l(
540
+ ).toLowerCase(), i = c(
450
541
  t.depositorBtcPubkey
451
542
  ).toLowerCase();
452
543
  if (r === o || r === i)
453
544
  return t.registeredPayoutScriptPubKey;
454
545
  if (!t.vaultKeeperBtcPubkeys.some(
455
- (s) => l(s).toLowerCase() === r
546
+ (a) => c(a).toLowerCase() === r
456
547
  ))
457
548
  throw new Error(
458
549
  `Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
459
550
  );
460
- return `0x${Ee(r)}`;
551
+ return `0x${Se(r)}`;
461
552
  }
462
- function C(e, t) {
553
+ function R(e, t) {
463
554
  return {
464
555
  payoutTxHex: e.payoutTxHex,
465
556
  peginTxHex: t.peginTxHex,
@@ -469,110 +560,122 @@ function C(e, t) {
469
560
  universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
470
561
  depositorBtcPubkey: t.depositorBtcPubkey,
471
562
  timelockPegin: t.timelockPegin,
472
- registeredPayoutScriptPubKey: ke(
563
+ registeredPayoutScriptPubKey: Ae(
473
564
  e.claimerPubkeyXOnly,
474
565
  t
475
566
  )
476
567
  };
477
568
  }
478
- async function Se(e, t, r, o) {
479
- const i = new xe({
569
+ async function Ce(e, t, r, o) {
570
+ const i = new Te({
480
571
  network: t.network,
481
572
  btcWallet: e
482
- }), c = r.length;
483
- o == null || o(0, c);
484
- let a;
573
+ }), u = r.length;
574
+ o == null || o(0, u);
575
+ let s;
485
576
  if (i.supportsBatchSigning())
486
- a = (await i.signPayoutTransactionsBatch(
487
- r.map((u) => C(u, t))
488
- )).map((u) => u.payoutSignature);
577
+ s = (await i.signPayoutTransactionsBatch(
578
+ r.map((l) => R(l, t))
579
+ )).map((l) => l.payoutSignature);
489
580
  else {
490
- a = [];
581
+ s = [];
491
582
  for (let n = 0; n < r.length; n++) {
492
- o == null || o(n, c);
493
- const u = await i.signPayoutTransaction(
494
- C(r[n], t)
583
+ o == null || o(n, u);
584
+ const l = await i.signPayoutTransaction(
585
+ R(r[n], t)
495
586
  );
496
- a.push(u.signature);
587
+ s.push(l.signature);
497
588
  }
498
589
  }
499
- const s = {};
590
+ const a = {};
500
591
  for (let n = 0; n < r.length; n++)
501
- s[r[n].claimerPubkeyXOnly] = {
502
- payout_signature: a[n]
592
+ a[r[n].claimerPubkeyXOnly] = {
593
+ payout_signature: s[n]
503
594
  };
504
- return o == null || o(c, c), s;
595
+ return o == null || o(u, u), a;
505
596
  }
506
- async function et(e) {
597
+ async function nt(e) {
507
598
  const {
508
599
  statusReader: t,
509
600
  presignClient: r,
510
601
  btcWallet: o,
511
602
  peginTxid: i,
512
- depositorPk: c,
513
- signingContext: a,
514
- timeoutMs: s = me,
603
+ depositorPk: u,
604
+ signingContext: s,
605
+ timeoutMs: a = Ee,
515
606
  signal: n,
516
- onProgress: u
607
+ onProgress: l
517
608
  } = e, d = await D({
518
609
  statusReader: t,
519
610
  peginTxid: i,
520
- targetStatuses: Te,
521
- timeoutMs: s,
611
+ targetStatuses: _e,
612
+ timeoutMs: a,
522
613
  signal: n
523
614
  });
524
- if (K.has(d))
615
+ if (M.has(d))
525
616
  return;
526
617
  n == null || n.throwIfAborted();
527
618
  const h = await r.requestDepositorPresignTransactions(
528
619
  {
529
620
  pegin_txid: i,
530
- depositor_pk: c
621
+ depositor_pk: u
531
622
  },
532
623
  n
533
624
  );
534
625
  n == null || n.throwIfAborted();
535
- const x = P(c), m = h.txs.filter(
536
- (z) => P(z.claimer_pubkey) !== x
537
- ), T = ve(m), v = await Se(
626
+ const g = m(u), P = h.txs.filter(
627
+ (X) => m(X.claimer_pubkey) !== g
628
+ ), k = Be(P), T = await Ce(
538
629
  o,
539
- a,
540
- T,
541
- u
630
+ s,
631
+ k,
632
+ l
542
633
  );
543
634
  n == null || n.throwIfAborted();
544
- const p = await we({
635
+ const p = await ke({
545
636
  depositorGraph: h.depositor_graph,
546
- depositorBtcPubkey: c,
547
- btcWallet: o
637
+ btcWallet: o,
638
+ signingContext: {
639
+ peginTxHex: s.peginTxHex,
640
+ depositorBtcPubkey: u,
641
+ vaultProviderBtcPubkey: s.vaultProviderBtcPubkey,
642
+ vaultKeeperBtcPubkeys: s.vaultKeeperBtcPubkeys,
643
+ universalChallengerBtcPubkeys: s.universalChallengerBtcPubkeys,
644
+ timelockPegin: s.timelockPegin,
645
+ timelockAssert: s.timelockAssert,
646
+ councilMembers: s.councilMembers,
647
+ councilQuorum: s.councilQuorum,
648
+ network: s.network,
649
+ registeredPayoutScriptPubKey: s.registeredPayoutScriptPubKey
650
+ }
548
651
  });
549
652
  n == null || n.throwIfAborted();
550
- const _ = { ...v };
551
- _[l(c)] = p.payout_signatures, await r.submitDepositorPresignatures(
653
+ const C = { ...T };
654
+ C[c(u)] = p.payout_signatures, await r.submitDepositorPresignatures(
552
655
  {
553
656
  pegin_txid: i,
554
- depositor_pk: c,
555
- signatures: _,
657
+ depositor_pk: u,
658
+ signatures: C,
556
659
  depositor_claimer_presignatures: p
557
660
  },
558
661
  n
559
662
  );
560
663
  }
561
- function Be(e) {
664
+ function He(e) {
562
665
  return /^[0-9a-fA-F]{64}$/.test(e);
563
666
  }
564
- function tt(e) {
667
+ function st(e) {
565
668
  const {
566
669
  amountSats: t,
567
670
  minDeposit: r,
568
671
  maxDeposit: o,
569
672
  btcBalance: i,
570
- estimatedFeeSats: c,
571
- depositorClaimValue: a
673
+ estimatedFeeSats: u,
674
+ depositorClaimValue: s
572
675
  } = e;
573
- return !(t <= 0n || t < r || o && o > 0n && t > o || c == null || a == null || t + c + a > i);
676
+ return !(t <= 0n || t < r || o && o > 0n && t > o || u == null || s == null || t + u + s > i);
574
677
  }
575
- function rt(e, t, r) {
678
+ function it(e, t, r) {
576
679
  return e <= 0n ? {
577
680
  valid: !1,
578
681
  error: "Deposit amount must be greater than zero"
@@ -584,7 +687,7 @@ function rt(e, t, r) {
584
687
  error: `Maximum deposit is ${f(r)} BTC`
585
688
  } : { valid: !0 };
586
689
  }
587
- function ot(e) {
690
+ function at(e) {
588
691
  const { amount: t, effectiveRemaining: r } = e;
589
692
  return r === null ? { valid: !0 } : r === 0n ? {
590
693
  valid: !1,
@@ -594,7 +697,7 @@ function ot(e) {
594
697
  error: `Vault size exceeds remaining capacity (${f(r)} BTC)`
595
698
  } : { valid: !0 };
596
699
  }
597
- function nt(e, t) {
700
+ function ut(e, t) {
598
701
  if (!e || e.length === 0)
599
702
  return {
600
703
  valid: !1,
@@ -610,7 +713,7 @@ function nt(e, t) {
610
713
  error: "Invalid vault provider selected"
611
714
  } : { valid: !0 };
612
715
  }
613
- function _e(e, t, r) {
716
+ function $e(e, t, r) {
614
717
  if (!e || e.length === 0)
615
718
  return {
616
719
  valid: !1,
@@ -636,98 +739,98 @@ function _e(e, t, r) {
636
739
  }
637
740
  return { valid: !0 };
638
741
  }
639
- function Ae(e) {
640
- const t = l(e);
641
- return Be(t) ? { valid: !0 } : {
742
+ function Ie(e) {
743
+ const t = c(e);
744
+ return He(t) ? { valid: !0 } : {
642
745
  valid: !1,
643
746
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
644
747
  };
645
748
  }
646
- function Ie(e) {
749
+ function Re(e) {
647
750
  if (!e || e.length === 0)
648
751
  throw new Error(
649
752
  "No vault keepers available. The system requires at least one vault keeper to create a deposit."
650
753
  );
651
754
  }
652
- function He(e) {
755
+ function Ne(e) {
653
756
  if (!e || e.length === 0)
654
757
  throw new Error(
655
758
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
656
759
  );
657
760
  }
658
- function Re(e) {
761
+ function Oe(e) {
659
762
  if (e.length === 0)
660
763
  throw new Error("No spendable UTXOs available");
661
764
  }
662
- function it(e) {
765
+ function lt(e) {
663
766
  const {
664
767
  vaultAmounts: t,
665
768
  confirmedUTXOs: r,
666
769
  vaultProviderBtcPubkey: o,
667
770
  vaultKeeperBtcPubkeys: i,
668
- universalChallengerBtcPubkeys: c,
669
- minDeposit: a,
670
- maxDeposit: s
671
- } = e, n = _e(
771
+ universalChallengerBtcPubkeys: u,
772
+ minDeposit: s,
773
+ maxDeposit: a
774
+ } = e, n = $e(
672
775
  t,
673
- a,
674
- s
776
+ s,
777
+ a
675
778
  );
676
779
  if (!n.valid)
677
780
  throw new Error(n.error);
678
- const u = Ae(o);
679
- if (!u.valid)
680
- throw new Error(u.error);
681
- Ie(i), He(c), Re(r);
781
+ const l = Ie(o);
782
+ if (!l.valid)
783
+ throw new Error(l.error);
784
+ Re(i), Ne(u), Oe(r);
682
785
  }
683
786
  var U = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.CHALLENGE_ASSERT_OBSERVED = "ChallengeAssertObserved", e.WRONGLY_CHALLENGED_BROADCAST = "WronglyChallengedBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.FAILED = "Failed", e))(U || {});
684
- const $e = /* @__PURE__ */ new Set([
787
+ const Ke = /* @__PURE__ */ new Set([
685
788
  "PayoutBroadcast",
686
789
  "Failed"
687
790
  /* FAILED */
688
791
  ]);
689
- function st(e) {
792
+ function ct(e) {
690
793
  return Object.values(U).includes(
691
794
  e
692
795
  );
693
796
  }
694
- function at(e) {
695
- return !!e && $e.has(e);
797
+ function dt(e) {
798
+ return !!e && Ke.has(e);
696
799
  }
697
- class Ce extends Error {
800
+ class Ve extends Error {
698
801
  constructor(r, o) {
699
802
  super(`Refund not yet mature (BIP68 not final): ${o.message}`);
700
- y(this, "vaultId");
701
- y(this, "cause");
803
+ x(this, "vaultId");
804
+ x(this, "cause");
702
805
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
703
806
  }
704
807
  }
705
- const Oe = /^0x[0-9a-fA-F]{64}$/, Ne = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, F = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Ve = 160, Le = 1, O = 65535, De = /non-BIP68-final/i;
706
- function M(e, t) {
808
+ const Le = /^0x[0-9a-fA-F]{64}$/, De = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, F = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Me = 160, Ue = 1, N = 65535, Fe = /non-BIP68-final/i;
809
+ function W(e, t) {
707
810
  if (e.length !== 66)
708
811
  throw new Error(
709
812
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
710
813
  );
711
- if (!Oe.test(e))
814
+ if (!Le.test(e))
712
815
  throw new Error(
713
816
  `${t} must contain only hex characters after the 0x prefix`
714
817
  );
715
818
  }
716
- function k(e, t) {
819
+ function B(e, t) {
717
820
  if (!Number.isInteger(e) || e < 0)
718
821
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
719
822
  }
720
- function Ke(e) {
721
- if (M(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > O)
823
+ function We(e) {
824
+ if (W(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > N)
722
825
  throw new Error(
723
- `htlcVout must be an integer 0-${O}, got ${e.htlcVout}`
826
+ `htlcVout must be an integer 0-${N}, got ${e.htlcVout}`
724
827
  );
725
- if (k(e.offchainParamsVersion, "offchainParamsVersion"), k(e.appVaultKeepersVersion, "appVaultKeepersVersion"), k(
828
+ if (B(e.offchainParamsVersion, "offchainParamsVersion"), B(e.appVaultKeepersVersion, "appVaultKeepersVersion"), B(
726
829
  e.universalChallengersVersion,
727
830
  "universalChallengersVersion"
728
831
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
729
832
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
730
- if (!Ne.test(e.unsignedPrePeginTxHex))
833
+ if (!De.test(e.unsignedPrePeginTxHex))
731
834
  throw new Error(
732
835
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
733
836
  );
@@ -738,7 +841,7 @@ function Ke(e) {
738
841
  if (typeof e.amount != "bigint" || e.amount <= 0n)
739
842
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
740
843
  }
741
- function Ue(e) {
844
+ function Xe(e) {
742
845
  if (!e.vaultProviderPubkey || !F.test(e.vaultProviderPubkey))
743
846
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
744
847
  if (e.vaultKeeperPubkeys.length === 0)
@@ -760,8 +863,8 @@ function Ue(e) {
760
863
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
761
864
  );
762
865
  }
763
- function Fe(e) {
764
- const t = B.fromHex(e);
866
+ function ze(e) {
867
+ const t = te.fromHex(e);
765
868
  try {
766
869
  t.finalizeAllInputs();
767
870
  } catch (r) {
@@ -771,82 +874,82 @@ function Fe(e) {
771
874
  }
772
875
  return t.extractTransaction().toHex();
773
876
  }
774
- async function ut(e) {
877
+ async function ht(e) {
775
878
  const {
776
879
  vaultId: t,
777
880
  readVault: r,
778
881
  readPrePeginContext: o,
779
882
  feeRate: i,
780
- signPsbt: c,
781
- broadcastTx: a,
782
- signal: s
883
+ signPsbt: u,
884
+ broadcastTx: s,
885
+ signal: a
783
886
  } = e;
784
- s == null || s.throwIfAborted(), M(t, "vaultId");
887
+ a == null || a.throwIfAborted(), W(t, "vaultId");
785
888
  const n = await r();
786
- Ke(n), s == null || s.throwIfAborted();
787
- const u = await o(n);
788
- if (Ue(u), s == null || s.throwIfAborted(), !Number.isFinite(i) || i <= 0)
889
+ We(n), a == null || a.throwIfAborted();
890
+ const l = await o(n);
891
+ if (Xe(l), a == null || a.throwIfAborted(), !Number.isFinite(i) || i <= 0)
789
892
  throw new Error(`feeRate must be a positive number, got ${i}`);
790
- const d = BigInt(Math.ceil(i * Ve));
791
- s == null || s.throwIfAborted();
792
- const h = P(
893
+ const d = BigInt(Math.ceil(i * Me));
894
+ a == null || a.throwIfAborted();
895
+ const h = m(
793
896
  n.depositorBtcPubkey
794
- ), { psbtHex: x } = await re({
897
+ ), { psbtHex: g } = await se({
795
898
  prePeginParams: {
796
899
  depositorPubkey: h,
797
- vaultProviderPubkey: l(u.vaultProviderPubkey),
798
- vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(l),
799
- universalChallengerPubkeys: u.universalChallengerPubkeys.map(l),
800
- hashlocks: [l(n.hashlock)],
801
- timelockRefund: u.timelockRefund,
900
+ vaultProviderPubkey: c(l.vaultProviderPubkey),
901
+ vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(c),
902
+ universalChallengerPubkeys: l.universalChallengerPubkeys.map(c),
903
+ hashlocks: [c(n.hashlock)],
904
+ timelockRefund: l.timelockRefund,
802
905
  pegInAmounts: [n.amount],
803
- feeRate: u.feeRate,
804
- numLocalChallengers: u.numLocalChallengers,
805
- councilQuorum: u.councilQuorum,
806
- councilSize: u.councilSize,
807
- network: u.network
906
+ feeRate: l.feeRate,
907
+ numLocalChallengers: l.numLocalChallengers,
908
+ councilQuorum: l.councilQuorum,
909
+ councilSize: l.councilSize,
910
+ network: l.network
808
911
  },
809
- fundedPrePeginTxHex: l(n.unsignedPrePeginTxHex),
912
+ fundedPrePeginTxHex: c(n.unsignedPrePeginTxHex),
810
913
  htlcVout: n.htlcVout,
811
914
  refundFee: d,
812
915
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
813
916
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
814
917
  // value would derive the wrong refund script leaf and yield an
815
918
  // unspendable PSBT. Match the `hashlocks` array handling above.
816
- hashlock: l(n.hashlock)
919
+ hashlock: c(n.hashlock)
817
920
  });
818
- s == null || s.throwIfAborted();
819
- const m = b(
921
+ a == null || a.throwIfAborted();
922
+ const P = b(
820
923
  n.depositorBtcPubkey,
821
- Le
822
- ), T = await c(x, m), v = Fe(T);
823
- s == null || s.throwIfAborted();
924
+ Ue
925
+ ), k = await u(g, P), T = ze(k);
926
+ a == null || a.throwIfAborted();
824
927
  try {
825
- return await a(v);
928
+ return await s(T);
826
929
  } catch (p) {
827
- throw p instanceof Error && De.test(p.message) ? new Ce(t, p) : p;
930
+ throw p instanceof Error && Fe.test(p.message) ? new Ve(t, p) : p;
828
931
  }
829
932
  }
830
933
  export {
831
- Ce as B,
934
+ Ve as B,
832
935
  U as C,
833
- xe as P,
834
- Je as a,
835
- we as b,
836
- ot as c,
837
- nt as d,
838
- _e as e,
839
- Ae as f,
840
- it as g,
841
- ne as h,
842
- tt as i,
843
- ie as j,
844
- st as k,
845
- at as l,
846
- ut as m,
847
- et as p,
848
- Ze as s,
849
- rt as v,
936
+ Te as P,
937
+ rt as a,
938
+ ke as b,
939
+ at as c,
940
+ ut as d,
941
+ $e as e,
942
+ Ie as f,
943
+ lt as g,
944
+ ae as h,
945
+ st as i,
946
+ ue as j,
947
+ ct as k,
948
+ dt as l,
949
+ ht as m,
950
+ nt as p,
951
+ ot as s,
952
+ it as v,
850
953
  D as w
851
954
  };
852
- //# sourceMappingURL=buildAndBroadcastRefund-xWS8frc6.js.map
955
+ //# sourceMappingURL=buildAndBroadcastRefund-BY6mYmFl.js.map