@babylonlabs-io/ts-sdk 0.58.0 → 0.59.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 (67) hide show
  1. package/dist/BTCVaultRegistry.abi-COxUdCTR.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-COxUdCTR.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-CixOlp3B.js → BTCVaultRegistry.abi-Ch0IiqNK.js} +19 -1
  4. package/dist/BTCVaultRegistry.abi-Ch0IiqNK.js.map +1 -0
  5. package/dist/{PeginManager-CogqZaa2.cjs → PeginManager-792nHwLl.cjs} +2 -2
  6. package/dist/{PeginManager-CogqZaa2.cjs.map → PeginManager-792nHwLl.cjs.map} +1 -1
  7. package/dist/{PeginManager-C8ixWlUM.js → PeginManager-Ddn6NDm3.js} +3 -3
  8. package/dist/{PeginManager-C8ixWlUM.js.map → PeginManager-Ddn6NDm3.js.map} +1 -1
  9. package/dist/{batchPoll-B0VxT62K.js → batchPoll-qXRNTvnR.js} +3 -3
  10. package/dist/{batchPoll-B0VxT62K.js.map → batchPoll-qXRNTvnR.js.map} +1 -1
  11. package/dist/{batchPoll-D5IDDOa8.cjs → batchPoll-xvVjiJXJ.cjs} +2 -2
  12. package/dist/{batchPoll-D5IDDOa8.cjs.map → batchPoll-xvVjiJXJ.cjs.map} +1 -1
  13. package/dist/{buildAndBroadcastRefund-DBA-Mp4I.js → buildAndBroadcastRefund-C-rbYMy6.js} +455 -428
  14. package/dist/buildAndBroadcastRefund-C-rbYMy6.js.map +1 -0
  15. package/dist/buildAndBroadcastRefund-HBOCjeUh.cjs +2 -0
  16. package/dist/buildAndBroadcastRefund-HBOCjeUh.cjs.map +1 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +52 -51
  19. package/dist/{mempoolApi-CMHEz4ez.js → mempoolApi-BTkbTDSY.js} +2 -2
  20. package/dist/{mempoolApi-CMHEz4ez.js.map → mempoolApi-BTkbTDSY.js.map} +1 -1
  21. package/dist/{mempoolApi-DfD3_Y6v.cjs → mempoolApi-DjwZ130O.cjs} +2 -2
  22. package/dist/{mempoolApi-DfD3_Y6v.cjs.map → mempoolApi-DjwZ130O.cjs.map} +1 -1
  23. package/dist/{peginState-BB81JI6I.js → peginState-CxDiaKuk.js} +26 -19
  24. package/dist/peginState-CxDiaKuk.js.map +1 -0
  25. package/dist/peginState-eaQ4IO_R.cjs +2 -0
  26. package/dist/peginState-eaQ4IO_R.cjs.map +1 -0
  27. package/dist/{reservation-CbAXa7VG.js → reservation-B4i_PQhY.js} +2 -2
  28. package/dist/{reservation-CbAXa7VG.js.map → reservation-B4i_PQhY.js.map} +1 -1
  29. package/dist/{reservation-RGKvg2x6.cjs → reservation-CDbInVw0.cjs} +2 -2
  30. package/dist/{reservation-RGKvg2x6.cjs.map → reservation-CDbInVw0.cjs.map} +1 -1
  31. package/dist/tbv/core/clients/index.cjs +1 -1
  32. package/dist/tbv/core/clients/index.js +2 -2
  33. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +14 -0
  34. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  35. package/dist/tbv/core/contracts/index.cjs +1 -1
  36. package/dist/tbv/core/contracts/index.js +1 -1
  37. package/dist/tbv/core/index.cjs +1 -1
  38. package/dist/tbv/core/index.js +58 -57
  39. package/dist/tbv/core/managers/index.cjs +1 -1
  40. package/dist/tbv/core/managers/index.js +1 -1
  41. package/dist/tbv/core/services/activation/activateVault.d.ts +45 -0
  42. package/dist/tbv/core/services/activation/activateVault.d.ts.map +1 -1
  43. package/dist/tbv/core/services/activation/index.d.ts +1 -1
  44. package/dist/tbv/core/services/activation/index.d.ts.map +1 -1
  45. package/dist/tbv/core/services/deposit/peginState.d.ts +24 -0
  46. package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
  47. package/dist/tbv/core/services/index.cjs +1 -1
  48. package/dist/tbv/core/services/index.js +34 -33
  49. package/dist/tbv/core/utils/index.cjs +1 -1
  50. package/dist/tbv/core/utils/index.js +1 -1
  51. package/dist/tbv/index.cjs +1 -1
  52. package/dist/tbv/index.js +58 -57
  53. package/dist/tbv/integrations/aave/index.cjs +1 -1
  54. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  55. package/dist/tbv/integrations/aave/index.d.ts +2 -0
  56. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  57. package/dist/tbv/integrations/aave/index.js +2 -0
  58. package/package.json +1 -1
  59. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs +0 -2
  60. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs.map +0 -1
  61. package/dist/BTCVaultRegistry.abi-CixOlp3B.js.map +0 -1
  62. package/dist/buildAndBroadcastRefund-BL8u-Ti4.cjs +0 -2
  63. package/dist/buildAndBroadcastRefund-BL8u-Ti4.cjs.map +0 -1
  64. package/dist/buildAndBroadcastRefund-DBA-Mp4I.js.map +0 -1
  65. package/dist/peginState-BB81JI6I.js.map +0 -1
  66. package/dist/peginState-CBBJw4Za.cjs +0 -2
  67. package/dist/peginState-CBBJw4Za.cjs.map +0 -1
@@ -1,122 +1,148 @@
1
- var he = Object.defineProperty;
2
- var de = (e, t, r) => t in e ? he(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var A = (e, t, r) => de(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { B as ge } from "./BTCVaultRegistry.abi-CixOlp3B.js";
5
- import { e as fe, v as ye, s as d, u as te, p as L, c as k, f as C } from "./bitcoin-d9eaaZB_.js";
6
- import { v as ve, b as Pe, s as me, P as be, d as we } from "./signPsbtsWithFallback-eY1YgV13.js";
7
- import { D as E, c as ke, b as xe, R as Ee, d as re } from "./json-rpc-client-DuUARJvV.js";
8
- import { Transaction as $, Psbt as Ce } from "bitcoinjs-lib";
9
- import { c as Te, d as N, e as D, f as F } from "./verifyScriptPathSchnorrSignature-Bav08_7R.js";
10
- import { c as Se, a as $e, b as _e } from "./noPayout-DuE-UyhQ.js";
1
+ var ge = Object.defineProperty;
2
+ var fe = (e, t, r) => t in e ? ge(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var A = (e, t, r) => fe(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { B as te } from "./BTCVaultRegistry.abi-Ch0IiqNK.js";
5
+ import { e as ve, v as ye, s as d, u as re, p as L, c as k, f as C } from "./bitcoin-d9eaaZB_.js";
6
+ import { v as Pe, b as me, s as be, P as we, d as ke } from "./signPsbtsWithFallback-eY1YgV13.js";
7
+ import { D as E, c as xe, b as Ee, R as Ce, d as ne } from "./json-rpc-client-DuUARJvV.js";
8
+ import { Transaction as $, Psbt as Te } from "bitcoinjs-lib";
9
+ import { c as Se, d as N, e as D, f as F } from "./verifyScriptPathSchnorrSignature-Bav08_7R.js";
10
+ import { c as $e, a as _e, b as Be } from "./noPayout-DuE-UyhQ.js";
11
11
  import { c as M } from "./signing-DaLvGwQe.js";
12
12
  import { a as X } from "./onChainBtcPubkey-DeF4cKoO.js";
13
- import { a as Be } from "./constants-GjWXdaqV.js";
14
- const Ae = /^0x[0-9a-fA-F]{64}$/, Re = /^0x[0-9a-fA-F]{40}$/, Ke = /^0x([0-9a-fA-F]{2})*$/;
13
+ import { a as Ae } from "./constants-GjWXdaqV.js";
14
+ const Re = /^0x[0-9a-fA-F]{64}$/, Ve = /^0x[0-9a-fA-F]{40}$/, Ke = /^0x([0-9a-fA-F]{2})*$/;
15
15
  function R(e, t) {
16
16
  if (e.length !== 66)
17
17
  throw new Error(
18
18
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
19
19
  );
20
- if (!Ae.test(e))
20
+ if (!Re.test(e))
21
21
  throw new Error(
22
22
  `${t} must contain only hex characters after the 0x prefix`
23
23
  );
24
24
  }
25
- function Ve(e, t) {
26
- if (!Re.test(e))
25
+ function Ie(e, t) {
26
+ if (!Ve.test(e))
27
27
  throw new Error(
28
28
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
29
29
  );
30
30
  }
31
- function Ie(e, t) {
31
+ function Oe(e, t) {
32
32
  if (!Ke.test(e))
33
33
  throw new Error(
34
34
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
35
35
  );
36
36
  }
37
- async function _t(e) {
37
+ function oe(e) {
38
+ Ie(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), R(e.vaultId, "vaultId");
39
+ const t = ve(e.secret);
40
+ if (R(t, "secret"), e.hashlock !== void 0 && (R(e.hashlock, "hashlock"), !Pe(t, e.hashlock)))
41
+ throw new Error(
42
+ "Invalid secret: SHA256(secret) does not match the provided hashlock"
43
+ );
44
+ return t;
45
+ }
46
+ async function Bt(e) {
38
47
  const {
39
48
  btcVaultRegistryAddress: t,
40
49
  vaultId: r,
41
50
  hashlock: n,
42
- activationMetadata: s,
43
- writeContract: l,
51
+ activationMetadata: a,
52
+ writeContract: u,
44
53
  signal: o
45
54
  } = e;
46
- o == null || o.throwIfAborted(), Ve(t, "btcVaultRegistryAddress"), R(r, "vaultId");
47
- const a = fe(e.secret);
48
- if (R(a, "secret"), n !== void 0 && (R(n, "hashlock"), !ve(a, n)))
49
- throw new Error(
50
- "Invalid secret: SHA256(secret) does not match the provided hashlock"
51
- );
52
- return Ie(s, "activationMetadata"), l({
55
+ o == null || o.throwIfAborted();
56
+ const s = oe({
57
+ btcVaultRegistryAddress: t,
58
+ vaultId: r,
59
+ secret: e.secret,
60
+ hashlock: n
61
+ });
62
+ return Oe(a, "activationMetadata"), u({
53
63
  address: t,
54
- abi: ge,
64
+ abi: te,
55
65
  functionName: "activateVaultWithSecret",
56
- args: [r, a, s]
66
+ args: [r, s, a]
67
+ });
68
+ }
69
+ async function At(e) {
70
+ const { btcVaultRegistryAddress: t, vaultId: r, hashlock: n, writeContract: a, signal: u } = e;
71
+ u == null || u.throwIfAborted();
72
+ const o = oe({
73
+ btcVaultRegistryAddress: t,
74
+ vaultId: r,
75
+ secret: e.secret,
76
+ hashlock: n
77
+ });
78
+ return a({
79
+ address: t,
80
+ abi: te,
81
+ functionName: "activateVaultWithSecretAndRedeem",
82
+ args: [r, o]
57
83
  });
58
84
  }
59
- const G = 1, Oe = 1;
60
- function He(e, t) {
61
- const r = d(t).toLowerCase(), s = e.map((l) => d(l).toLowerCase()).filter((l) => l !== r);
62
- if (s.length === 0)
85
+ const G = 1, He = 1;
86
+ function Ne(e, t) {
87
+ const r = d(t).toLowerCase(), a = e.map((u) => d(u).toLowerCase()).filter((u) => u !== r);
88
+ if (a.length === 0)
63
89
  throw new Error(
64
90
  "Cannot derive localChallengers: vault keeper set is empty (or contains only the depositor)"
65
91
  );
66
- if (new Set(s).size !== s.length)
92
+ if (new Set(a).size !== a.length)
67
93
  throw new Error(
68
94
  "Cannot derive localChallengers: duplicate vaultKeeper key — signing context is misconfigured"
69
95
  );
70
- return s;
96
+ return a;
71
97
  }
72
- function Ne(e, t, r) {
98
+ function De(e, t, r) {
73
99
  const n = r.map(
74
100
  (c) => d(c).toLowerCase()
75
- ), s = t.filter((c) => n.includes(c));
76
- if (s.length > 0)
101
+ ), a = t.filter((c) => n.includes(c));
102
+ if (a.length > 0)
77
103
  throw new Error(
78
- `Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
104
+ `Cannot validate challenger set: vault keepers and universal challengers overlap (${a.join(", ")})`
79
105
  );
80
- const l = [...t, ...n], o = e.map(
106
+ const u = [...t, ...n], o = e.map(
81
107
  (c) => d(c.challenger_pubkey).toLowerCase()
82
- ), a = new Set(o);
83
- if (a.size !== o.length)
108
+ ), s = new Set(o);
109
+ if (s.size !== o.length)
84
110
  throw new Error(
85
111
  "Depositor graph contains duplicate challenger entries in challenger_presign_data"
86
112
  );
87
- const u = new Set(l), i = l.filter((c) => !a.has(c)), p = o.filter((c) => !u.has(c));
113
+ const l = new Set(u), i = u.filter((c) => !s.has(c)), p = o.filter((c) => !l.has(c));
88
114
  if (i.length > 0 || p.length > 0)
89
115
  throw new Error(
90
116
  "Depositor graph challenger set does not match expected (local ∪ universal)" + (i.length > 0 ? ` (missing: ${i.join(", ")})` : "") + (p.length > 0 ? ` (unexpected: ${p.join(", ")})` : "")
91
117
  );
92
118
  }
93
- function De(e, t) {
119
+ function Fe(e, t) {
94
120
  const r = e.ins[t];
95
- return te(new Uint8Array(r.hash).slice().reverse());
121
+ return re(new Uint8Array(r.hash).slice().reverse());
96
122
  }
97
- function K(e, t, r, n, s) {
98
- const l = e.ins[t];
99
- if (l.index !== 0)
123
+ function V(e, t, r, n, a) {
124
+ const u = e.ins[t];
125
+ if (u.index !== 0)
100
126
  throw new Error(
101
- `NoPayout (challenger ${s}) input ${t} expected to spend ${n} vout 0, got vout ${l.index}`
127
+ `NoPayout (challenger ${a}) input ${t} expected to spend ${n} vout 0, got vout ${u.index}`
102
128
  );
103
- const o = r.getId(), a = De(e, t);
104
- if (a !== o)
129
+ const o = r.getId(), s = Fe(e, t);
130
+ if (s !== o)
105
131
  throw new Error(
106
- `NoPayout (challenger ${s}) input ${t} does not reference ${n} (expected txid ${o}, got ${a})`
132
+ `NoPayout (challenger ${a}) input ${t} does not reference ${n} (expected txid ${o}, got ${s})`
107
133
  );
108
134
  }
109
- async function Fe(e, t, r) {
110
- const n = [], s = [], l = [], o = He(
135
+ async function Me(e, t, r) {
136
+ const n = [], a = [], u = [], o = Ne(
111
137
  r.vaultKeeperBtcPubkeys,
112
138
  r.depositorBtcPubkey
113
139
  );
114
- Ne(
140
+ De(
115
141
  e.challenger_presign_data,
116
142
  o,
117
143
  r.universalChallengerBtcPubkeys
118
144
  );
119
- const a = await Te({
145
+ const s = await Se({
120
146
  vaultCoreVersion: r.vaultCoreVersion,
121
147
  vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
122
148
  vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
@@ -132,100 +158,100 @@ async function Fe(e, t, r) {
132
158
  network: r.network,
133
159
  claimerBtcPubkey: r.depositorBtcPubkey,
134
160
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
135
- commissionBps: Oe,
161
+ commissionBps: He,
136
162
  protocolFeeRate: r.protocolFeeRate,
137
163
  councilSize: r.councilMembers.length
138
164
  });
139
- n.push(a.psbtHex), s.push(
165
+ n.push(s.psbtHex), a.push(
140
166
  M(
141
167
  t,
142
168
  G
143
169
  )
144
170
  );
145
- const u = d(r.depositorBtcPubkey), i = $.fromHex(
171
+ const l = d(r.depositorBtcPubkey), i = $.fromHex(
146
172
  d(e.assert_tx.tx_hex)
147
173
  );
148
174
  for (const p of e.challenger_presign_data) {
149
- const c = d(p.challenger_pubkey), h = n.length, f = await Me({
175
+ const c = d(p.challenger_pubkey), h = n.length, f = await Ue({
150
176
  challenger: p,
151
177
  challengerPubkey: c,
152
- claimerPubkey: u,
178
+ claimerPubkey: l,
153
179
  localChallengers: o,
154
180
  assertTxParsed: i,
155
181
  ctx: r
156
182
  });
157
- n.push(f), s.push(
183
+ n.push(f), a.push(
158
184
  M(
159
185
  t,
160
186
  G
161
187
  )
162
- ), l.push({
188
+ ), u.push({
163
189
  challengerPubkey: c,
164
190
  noPayoutIdx: h
165
191
  });
166
192
  }
167
- return { psbtHexes: n, signOptions: s, challengerEntries: l };
193
+ return { psbtHexes: n, signOptions: a, challengerEntries: u };
168
194
  }
169
- async function Me(e) {
195
+ async function Ue(e) {
170
196
  const {
171
197
  challenger: t,
172
198
  challengerPubkey: r,
173
199
  claimerPubkey: n,
174
- localChallengers: s,
175
- assertTxParsed: l,
200
+ localChallengers: a,
201
+ assertTxParsed: u,
176
202
  ctx: o
177
203
  } = e;
178
- Se(
204
+ $e(
179
205
  t.nopayout_tx.tx_hex,
180
206
  r,
181
207
  o.network
182
208
  );
183
- const a = $.fromHex(
209
+ const s = $.fromHex(
184
210
  d(t.nopayout_tx.tx_hex)
185
- ), u = $.fromHex(
211
+ ), l = $.fromHex(
186
212
  d(t.challenge_assert_x_tx.tx_hex)
187
213
  ), i = $.fromHex(
188
214
  d(t.challenge_assert_y_tx.tx_hex)
189
215
  );
190
- if (a.ins.length !== 3)
216
+ if (s.ins.length !== 3)
191
217
  throw new Error(
192
- `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${a.ins.length}`
218
+ `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${s.ins.length}`
193
219
  );
194
- K(
195
- a,
220
+ V(
221
+ s,
196
222
  0,
197
- l,
223
+ u,
198
224
  "Assert",
199
225
  r
200
- ), K(
201
- a,
226
+ ), V(
227
+ s,
202
228
  1,
203
- u,
229
+ l,
204
230
  "ChallengeAssertX",
205
231
  r
206
- ), K(
207
- a,
232
+ ), V(
233
+ s,
208
234
  2,
209
235
  i,
210
236
  "ChallengeAssertY",
211
237
  r
212
238
  );
213
239
  const p = [
214
- l.outs[0],
215
240
  u.outs[0],
241
+ l.outs[0],
216
242
  i.outs[0]
217
243
  ].map((c) => ({
218
- script_pubkey: te(new Uint8Array(c.script)),
244
+ script_pubkey: re(new Uint8Array(c.script)),
219
245
  value: c.value
220
246
  }));
221
- return $e({
247
+ return _e({
222
248
  noPayoutTxHex: t.nopayout_tx.tx_hex,
223
249
  challengerPubkey: r,
224
250
  prevouts: p,
225
251
  connectorParams: {
226
252
  txGraphVersion: o.vaultCoreVersion,
227
253
  claimer: n,
228
- localChallengers: s,
254
+ localChallengers: a,
229
255
  universalChallengers: o.universalChallengerBtcPubkeys,
230
256
  timelockAssert: o.timelockAssert,
231
257
  councilMembers: o.councilMembers,
@@ -233,103 +259,103 @@ async function Me(e) {
233
259
  }
234
260
  });
235
261
  }
236
- function Ue(e, t, r) {
262
+ function Le(e, t, r) {
237
263
  N(e[0]);
238
- const s = D(
264
+ const a = D(
239
265
  e[0].returnedPsbtHex,
240
266
  r
241
267
  );
242
268
  F({
243
269
  requestedPsbtHex: e[0].requestedPsbtHex,
244
- signatureHex: s,
270
+ signatureHex: a,
245
271
  signerXOnlyPubkeyHex: r,
246
272
  inputIndex: 0
247
273
  });
248
- const l = {};
274
+ const u = {};
249
275
  for (const o of t) {
250
276
  N(e[o.noPayoutIdx]);
251
- const a = D(
277
+ const s = D(
252
278
  e[o.noPayoutIdx].returnedPsbtHex,
253
279
  r
254
280
  );
255
281
  F({
256
282
  requestedPsbtHex: e[o.noPayoutIdx].requestedPsbtHex,
257
- signatureHex: a,
283
+ signatureHex: s,
258
284
  signerXOnlyPubkeyHex: r,
259
285
  inputIndex: 0
260
- }), l[o.challengerPubkey] = {
261
- nopayout_signature: a
286
+ }), u[o.challengerPubkey] = {
287
+ nopayout_signature: s
262
288
  };
263
289
  }
264
290
  return {
265
291
  payout_signatures: {
266
- payout_signature: s
292
+ payout_signature: a
267
293
  },
268
- per_challenger: l
294
+ per_challenger: u
269
295
  };
270
296
  }
271
- async function Le(e) {
272
- const { depositorGraph: t, btcWallet: r, signingContext: n } = e, s = await r.getPublicKeyHex(), { depositorPubkey: l } = ye(
273
- s,
297
+ async function ze(e) {
298
+ const { depositorGraph: t, btcWallet: r, signingContext: n } = e, a = await r.getPublicKeyHex(), { depositorPubkey: u } = ye(
299
+ a,
274
300
  d(n.depositorBtcPubkey)
275
- ), { psbtHexes: o, signOptions: a, challengerEntries: u } = await Fe(
301
+ ), { psbtHexes: o, signOptions: s, challengerEntries: l } = await Me(
276
302
  t,
277
- s,
303
+ a,
278
304
  n
279
- ), i = await Pe(
305
+ ), i = await me(
280
306
  r,
281
307
  o,
282
- a
308
+ s
283
309
  ), p = o.map((c, h) => ({
284
310
  requestedPsbtHex: c,
285
311
  returnedPsbtHex: i[h]
286
312
  }));
287
- return Ue(
313
+ return Le(
288
314
  p,
289
- u,
290
- l
315
+ l,
316
+ u
291
317
  );
292
318
  }
293
- const ze = 1e4;
294
- async function ne(e) {
319
+ const Xe = 1e4;
320
+ async function ae(e) {
295
321
  const {
296
322
  statusReader: t,
297
323
  peginTxid: r,
298
324
  targetStatuses: n,
299
- timeoutMs: s,
300
- pollIntervalMs: l = ze,
325
+ timeoutMs: a,
326
+ pollIntervalMs: u = Xe,
301
327
  signal: o
302
- } = e, a = Date.now();
328
+ } = e, s = Date.now();
303
329
  for (; ; ) {
304
330
  if (o != null && o.aborted)
305
331
  throw new Error(
306
332
  `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
307
333
  );
308
- if (Date.now() - a >= s)
334
+ if (Date.now() - s >= a)
309
335
  throw new Error(
310
- `Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
336
+ `Polling timeout after ${a}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
311
337
  );
312
338
  try {
313
- const u = await t.getPeginStatus(
339
+ const l = await t.getPeginStatus(
314
340
  { pegin_txid: r },
315
341
  o
316
342
  );
317
- if (u.pegin_txid.toLowerCase() !== r.toLowerCase())
343
+ if (l.pegin_txid.toLowerCase() !== r.toLowerCase())
318
344
  throw new Error(
319
- `getPeginStatus returned status for pegin ${u.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
345
+ `getPeginStatus returned status for pegin ${l.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
320
346
  );
321
- const i = u.status;
347
+ const i = l.status;
322
348
  if (n.has(i) || i === E.ACTIVATED)
323
349
  return i;
324
- if (i === E.EXPIRED || ke.has(i))
350
+ if (i === E.EXPIRED || xe.has(i))
325
351
  throw new Error(
326
352
  `Pegin ${r.slice(0, 8)}… reached terminal status "${i}" while waiting for ${[...n].join(", ")}`
327
353
  );
328
- } catch (u) {
329
- if (!(u instanceof xe && u.code === Ee.PEGIN_NOT_FOUND))
330
- throw u;
354
+ } catch (l) {
355
+ if (!(l instanceof Ee && l.code === Ce.PEGIN_NOT_FOUND))
356
+ throw l;
331
357
  }
332
- await new Promise((u, i) => {
358
+ await new Promise((l, i) => {
333
359
  const p = () => {
334
360
  clearTimeout(c), i(
335
361
  new Error(
@@ -337,22 +363,22 @@ async function ne(e) {
337
363
  )
338
364
  );
339
365
  }, c = setTimeout(() => {
340
- o == null || o.removeEventListener("abort", p), u();
341
- }, l);
366
+ o == null || o.removeEventListener("abort", p), l();
367
+ }, u);
342
368
  o == null || o.addEventListener("abort", p, { once: !0 });
343
369
  });
344
370
  }
345
371
  }
346
- const Xe = 1200 * 1e3, oe = /* @__PURE__ */ new Set([
372
+ const Ge = 1200 * 1e3, se = /* @__PURE__ */ new Set([
347
373
  E.PENDING_ACKS,
348
374
  E.PENDING_ACTIVATION,
349
375
  E.ACTIVATED_PENDING_BROADCAST,
350
376
  E.ACTIVATED
351
- ]), Ge = /* @__PURE__ */ new Set([
377
+ ]), je = /* @__PURE__ */ new Set([
352
378
  E.PENDING_DEPOSITOR_SIGNATURES,
353
- ...oe
379
+ ...se
354
380
  ]);
355
- function je(e) {
381
+ function qe(e) {
356
382
  return e.map((t) => ({
357
383
  claimerPubkeyXOnly: L(t.claimer_pubkey),
358
384
  payoutTxHex: t.payout_tx.tx_hex,
@@ -362,22 +388,22 @@ function je(e) {
362
388
  function w(e) {
363
389
  return L(e).toLowerCase();
364
390
  }
365
- function qe(e, t) {
366
- const r = (a, u, i) => {
391
+ function Qe(e, t) {
392
+ const r = (s, l, i) => {
367
393
  throw new Error(
368
- `Deposit terms ${a} (${String(u)}) does not match the vault's version-locked signing context (${String(i)}); refusing to sign payouts against terms that describe a different graph.`
394
+ `Deposit terms ${s} (${String(l)}) does not match the vault's version-locked signing context (${String(i)}); refusing to sign payouts against terms that describe a different graph.`
369
395
  );
370
396
  };
371
397
  e.protocolFeeRate !== t.protocolFeeRate && r("protocolFeeRate", e.protocolFeeRate, t.protocolFeeRate);
372
- const n = (a) => a.map(w).sort(), s = (a, u) => {
373
- const i = n(a), p = n(u);
398
+ const n = (s) => s.map(w).sort(), a = (s, l) => {
399
+ const i = n(s), p = n(l);
374
400
  return i.length === p.length && i.every((c, h) => c === p[h]);
375
401
  };
376
- s(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
402
+ a(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
377
403
  "vaultKeeperBtcPubkeys",
378
404
  e.vaultKeeperBtcPubkeys.join(","),
379
405
  t.vaultKeeperBtcPubkeys.join(",")
380
- ), s(
406
+ ), a(
381
407
  e.universalChallengerBtcPubkeys,
382
408
  t.universalChallengerBtcPubkeys
383
409
  ) || r(
@@ -385,34 +411,34 @@ function qe(e, t) {
385
411
  e.universalChallengerBtcPubkeys.join(","),
386
412
  t.universalChallengerBtcPubkeys.join(",")
387
413
  );
388
- const l = w(t.vaultProviderBtcPubkey), o = e.vaults.map(
389
- (a) => w(a.vaultProviderBtcPubkey)
414
+ const u = w(t.vaultProviderBtcPubkey), o = e.vaults.map(
415
+ (s) => w(s.vaultProviderBtcPubkey)
390
416
  );
391
- o.includes(l) || r(
417
+ o.includes(u) || r(
392
418
  "vaults[].vaultProviderBtcPubkey",
393
419
  o.join(",") || "<no vaults>",
394
420
  t.vaultProviderBtcPubkey
395
421
  );
396
422
  }
397
- function Qe(e, t, r, n) {
398
- const s = w(n), l = [
423
+ function We(e, t, r, n) {
424
+ const a = w(n), u = [
399
425
  w(t),
400
426
  ...r.map(w)
401
- ], o = new Set(l);
402
- if (o.size !== l.length)
427
+ ], o = new Set(u);
428
+ if (o.size !== u.length)
403
429
  throw new Error(
404
430
  "Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
405
431
  );
406
- if (o.has(s))
432
+ if (o.has(a))
407
433
  throw new Error(
408
434
  "Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
409
435
  );
410
- const a = e.map(
436
+ const s = e.map(
411
437
  (h) => w(h.claimer_pubkey)
412
438
  );
413
- if (new Set(a).size !== a.length)
439
+ if (new Set(s).size !== s.length)
414
440
  throw new Error("Presign response contains duplicate claimer entries");
415
- const u = a.filter((h) => h !== s), i = new Set(u), p = l.filter((h) => !i.has(h)), c = u.filter((h) => !o.has(h));
441
+ const l = s.filter((h) => h !== a), i = new Set(l), p = u.filter((h) => !i.has(h)), c = l.filter((h) => !o.has(h));
416
442
  if (p.length > 0 || c.length > 0)
417
443
  throw new Error(
418
444
  "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (p.length > 0 ? ` (missing: ${p.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
@@ -440,92 +466,92 @@ function j(e, t) {
440
466
  };
441
467
  }
442
468
  async function Ye(e, t, r, n) {
443
- const s = new be({
469
+ const a = new we({
444
470
  network: t.network,
445
471
  btcWallet: e
446
- }), l = r.length;
447
- n == null || n(0, l);
472
+ }), u = r.length;
473
+ n == null || n(0, u);
448
474
  let o;
449
- if (s.supportsBatchSigning())
450
- o = (await s.signPayoutTransactionsBatch(
475
+ if (a.supportsBatchSigning())
476
+ o = (await a.signPayoutTransactionsBatch(
451
477
  r.map((i) => j(i, t))
452
478
  )).map((i) => i.payoutSignature);
453
479
  else {
454
480
  o = [];
455
- for (let u = 0; u < r.length; u++) {
456
- n == null || n(u, l);
457
- const i = await s.signPayoutTransaction(
458
- j(r[u], t)
481
+ for (let l = 0; l < r.length; l++) {
482
+ n == null || n(l, u);
483
+ const i = await a.signPayoutTransaction(
484
+ j(r[l], t)
459
485
  );
460
486
  o.push(i.signature);
461
487
  }
462
488
  }
463
- const a = {};
464
- for (let u = 0; u < r.length; u++)
465
- a[r[u].claimerPubkeyXOnly] = {
466
- payout_signature: o[u]
489
+ const s = {};
490
+ for (let l = 0; l < r.length; l++)
491
+ s[r[l].claimerPubkeyXOnly] = {
492
+ payout_signature: o[l]
467
493
  };
468
- return n == null || n(l, l), a;
494
+ return n == null || n(u, u), s;
469
495
  }
470
- async function Bt(e) {
496
+ async function Rt(e) {
471
497
  const {
472
498
  statusReader: t,
473
499
  presignClient: r,
474
500
  btcWallet: n,
475
- peginTxid: s,
476
- depositorPk: l,
501
+ peginTxid: a,
502
+ depositorPk: u,
477
503
  signingContext: o,
478
- depositTerms: a,
479
- timeoutMs: u = Xe,
504
+ depositTerms: s,
505
+ timeoutMs: l = Ge,
480
506
  signal: i,
481
507
  onProgress: p
482
- } = e, c = await ne({
508
+ } = e, c = await ae({
483
509
  statusReader: t,
484
- peginTxid: s,
485
- targetStatuses: Ge,
486
- timeoutMs: u,
510
+ peginTxid: a,
511
+ targetStatuses: je,
512
+ timeoutMs: l,
487
513
  signal: i
488
514
  });
489
- if (oe.has(c))
515
+ if (se.has(c))
490
516
  return;
491
- if (i == null || i.throwIfAborted(), a !== void 0 && qe(a, o), me(n)) {
492
- if (!a)
517
+ if (i == null || i.throwIfAborted(), s !== void 0 && Qe(s, o), be(n)) {
518
+ if (!s)
493
519
  throw new Error(
494
520
  "runDepositorPresignFlow: this wallet requires approved deposit terms but none were provided. Fresh deposits must pass PreparePeginResult.depositTerms; resume-path rebuild is not wired yet."
495
521
  );
496
- await n.approveDepositTerms(a);
522
+ await n.approveDepositTerms(s);
497
523
  }
498
524
  const h = await r.requestDepositorPresignTransactions(
499
525
  {
500
- pegin_txid: s,
501
- depositor_pk: l
526
+ pegin_txid: a,
527
+ depositor_pk: u
502
528
  },
503
529
  i
504
530
  );
505
531
  i == null || i.throwIfAborted();
506
- const f = w(l);
507
- Qe(
532
+ const f = w(u);
533
+ We(
508
534
  h.txs,
509
535
  o.vaultProviderBtcPubkey,
510
536
  o.vaultKeeperBtcPubkeys,
511
- l
537
+ u
512
538
  );
513
- const y = h.txs.filter(
514
- (v) => w(v.claimer_pubkey) !== f
515
- ), T = je(y), x = await Ye(
539
+ const v = h.txs.filter(
540
+ (y) => w(y.claimer_pubkey) !== f
541
+ ), T = qe(v), x = await Ye(
516
542
  n,
517
543
  o,
518
544
  T,
519
545
  p
520
546
  );
521
547
  i == null || i.throwIfAborted();
522
- const m = await Le({
548
+ const m = await ze({
523
549
  depositorGraph: h.depositor_graph,
524
550
  btcWallet: n,
525
551
  signingContext: {
526
552
  vaultCoreVersion: o.vaultCoreVersion,
527
553
  peginTxHex: o.peginTxHex,
528
- depositorBtcPubkey: l,
554
+ depositorBtcPubkey: u,
529
555
  vaultProviderBtcPubkey: o.vaultProviderBtcPubkey,
530
556
  vaultKeeperBtcPubkeys: o.vaultKeeperBtcPubkeys,
531
557
  universalChallengerBtcPubkeys: o.universalChallengerBtcPubkeys,
@@ -542,51 +568,51 @@ async function Bt(e) {
542
568
  });
543
569
  i == null || i.throwIfAborted();
544
570
  const b = { ...x };
545
- b[d(l)] = m.payout_signatures, await r.submitDepositorPresignatures(
571
+ b[d(u)] = m.payout_signatures, await r.submitDepositorPresignatures(
546
572
  {
547
- pegin_txid: s,
548
- depositor_pk: l,
573
+ pegin_txid: a,
574
+ depositor_pk: u,
549
575
  signatures: b,
550
576
  depositor_claimer_presignatures: m
551
577
  },
552
578
  i
553
579
  );
554
580
  }
555
- const We = 300 * 1e3, Je = /* @__PURE__ */ new Set([
581
+ const Je = 300 * 1e3, Ze = /* @__PURE__ */ new Set([
556
582
  E.PENDING_DEPOSITOR_WOTS_PK,
557
- ...re
583
+ ...ne
558
584
  ]);
559
- async function At(e) {
585
+ async function Vt(e) {
560
586
  const {
561
587
  statusReader: t,
562
588
  wotsSubmitter: r,
563
589
  peginTxid: n,
564
- depositorPk: s,
565
- wotsPublicKeys: l,
566
- timeoutMs: o = We,
567
- signal: a
590
+ depositorPk: a,
591
+ wotsPublicKeys: u,
592
+ timeoutMs: o = Je,
593
+ signal: s
568
594
  } = e;
569
- a == null || a.throwIfAborted();
570
- const u = await ne({
595
+ s == null || s.throwIfAborted();
596
+ const l = await ae({
571
597
  statusReader: t,
572
598
  peginTxid: n,
573
- targetStatuses: Je,
599
+ targetStatuses: Ze,
574
600
  timeoutMs: o,
575
- signal: a
601
+ signal: s
576
602
  });
577
- re.has(u) || (a == null || a.throwIfAborted(), await r.submitDepositorWotsKey(
603
+ ne.has(l) || (s == null || s.throwIfAborted(), await r.submitDepositorWotsKey(
578
604
  {
579
605
  pegin_txid: n,
580
- depositor_pk: s,
581
- wots_public_keys: l
606
+ depositor_pk: a,
607
+ wots_public_keys: u
582
608
  },
583
- a
609
+ s
584
610
  ));
585
611
  }
586
- function V(e) {
612
+ function K(e) {
587
613
  return e.registration || e.operation;
588
614
  }
589
- function Ze(e, t, r) {
615
+ function et(e, t, r) {
590
616
  const n = k(e);
591
617
  return {
592
618
  registration: n === k(t),
@@ -606,38 +632,38 @@ function I(e) {
606
632
  function Q(e, t) {
607
633
  return e.length === t.length && e.every((r, n) => r === t[n]);
608
634
  }
609
- async function Rt(e) {
635
+ async function Kt(e) {
610
636
  const {
611
637
  vaultProviderEthAddress: t,
612
638
  hintBtcPubkey: r,
613
639
  registrationBtcPubkey: n,
614
- readCurrentOperationBtcPubkey: s,
615
- context: l
640
+ readCurrentOperationBtcPubkey: a,
641
+ context: u
616
642
  } = e;
617
643
  if (!r) return;
618
644
  const o = k(r);
619
645
  if (o === k(n)) return;
620
- const a = k(
621
- await s()
646
+ const s = k(
647
+ await a()
622
648
  );
623
- if (o !== a)
649
+ if (o !== s)
624
650
  throw new Error(
625
- `Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${l ? ` ${l}` : ""}`
651
+ `Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${u ? ` ${u}` : ""}`
626
652
  );
627
653
  }
628
654
  function O(e, t, r) {
629
- const n = `${e} operation key (admin=${t.ethAddress})`, s = X(
655
+ const n = `${e} operation key (admin=${t.ethAddress})`, a = X(
630
656
  t.btcPubKey,
631
657
  `${e} roster key (admin=${t.ethAddress})`
632
- ), l = X(r, n);
658
+ ), u = X(r, n);
633
659
  return {
634
660
  adminAddress: t.ethAddress,
635
- genesisBtcPubkey: s,
636
- operationBtcPubkey: l,
637
- rotated: l !== s
661
+ genesisBtcPubkey: a,
662
+ operationBtcPubkey: u,
663
+ rotated: u !== a
638
664
  };
639
665
  }
640
- function et(e) {
666
+ function tt(e) {
641
667
  const t = /* @__PURE__ */ new Map();
642
668
  for (const r of e) {
643
669
  const n = t.get(r.operationBtcPubkey);
@@ -648,7 +674,7 @@ function et(e) {
648
674
  t.set(r.operationBtcPubkey, r.adminAddress);
649
675
  }
650
676
  }
651
- function ae(e, t, r) {
677
+ function ie(e, t, r) {
652
678
  if (t.vaultKeepers.length !== e.vaultKeepers.length || t.universalChallengers.length !== e.universalChallengers.length)
653
679
  throw new Error(
654
680
  `Operation-key resolution returned ${t.vaultKeepers.length} keeper and ${t.universalChallengers.length} challenger keys for a roster of ${e.vaultKeepers.length} keepers and ${e.universalChallengers.length} challengers`
@@ -660,148 +686,148 @@ function ae(e, t, r) {
660
686
  btcPubKey: e.vaultProviderGenesisBtcPubkey
661
687
  },
662
688
  t.vaultProvider
663
- ), s = e.vaultKeepers.map(
664
- (o, a) => O("vault keeper", o, t.vaultKeepers[a])
665
- ), l = e.universalChallengers.map(
666
- (o, a) => O("universal challenger", o, t.universalChallengers[a])
689
+ ), a = e.vaultKeepers.map(
690
+ (o, s) => O("vault keeper", o, t.vaultKeepers[s])
691
+ ), u = e.universalChallengers.map(
692
+ (o, s) => O("universal challenger", o, t.universalChallengers[s])
667
693
  );
668
- return et([
694
+ return tt([
669
695
  n,
670
- ...s,
671
- ...l
696
+ ...a,
697
+ ...u
672
698
  ]), {
673
699
  vaultProvider: n,
674
- vaultKeepers: s,
675
- universalChallengers: l,
700
+ vaultKeepers: a,
701
+ universalChallengers: u,
676
702
  // Derived from the pairs, never the reverse — see ParticipantKeySet.
677
- vaultKeeperOperationKeysSorted: s.map((o) => o.operationBtcPubkey).sort(),
678
- universalChallengerOperationKeysSorted: l.map((o) => o.operationBtcPubkey).sort(),
703
+ vaultKeeperOperationKeysSorted: a.map((o) => o.operationBtcPubkey).sort(),
704
+ universalChallengerOperationKeysSorted: u.map((o) => o.operationBtcPubkey).sort(),
679
705
  resolvedAt: r,
680
706
  query: e
681
707
  };
682
708
  }
683
- async function tt(e) {
709
+ async function rt(e) {
684
710
  const t = await e.operationKeyReader.getCurrentOperationKeys(
685
711
  e.query
686
712
  );
687
- return ae(e.query, t, { mode: "current" });
713
+ return ie(e.query, t, { mode: "current" });
688
714
  }
689
- async function rt(e) {
715
+ async function nt(e) {
690
716
  const t = await e.operationKeyReader.getOperationKeysAtEpochs(
691
717
  e.query,
692
718
  e.epochs
693
719
  );
694
- return ae(e.query, t, {
720
+ return ie(e.query, t, {
695
721
  mode: "epochs",
696
722
  epochs: e.epochs
697
723
  });
698
724
  }
699
- const Y = (e) => e.map(k).sort();
700
- async function Kt(e) {
725
+ const W = (e) => e.map(k).sort();
726
+ async function It(e) {
701
727
  const {
702
728
  vaultRegistryReader: t,
703
729
  vaultKeeperReader: r,
704
730
  universalChallengerReader: n,
705
- vaultProviderEthAddress: s,
706
- applicationEntryPoint: l,
731
+ vaultProviderEthAddress: a,
732
+ applicationEntryPoint: u,
707
733
  expectedVaultProviderBtcPubkey: o,
708
- expectedVaultKeeperBtcPubkeys: a,
709
- expectedUniversalChallengerBtcPubkeys: u,
734
+ expectedVaultKeeperBtcPubkeys: s,
735
+ expectedUniversalChallengerBtcPubkeys: l,
710
736
  operationKeyReader: i,
711
737
  onIndexerServingOperationKeys: p,
712
738
  onIndexerHintsInconsistent: c
713
739
  } = e, [
714
740
  h,
715
741
  f,
716
- y
742
+ v
717
743
  ] = await Promise.all([
718
- t.getVaultProviderBtcPubKey(s),
719
- r.getCurrentVaultKeepersVersion(l),
744
+ t.getVaultProviderBtcPubKey(a),
745
+ r.getCurrentVaultKeepersVersion(u),
720
746
  n.getLatestUniversalChallengersVersion()
721
747
  ]), [T, x] = await Promise.all([
722
748
  r.getVaultKeepersByVersion(
723
- l,
749
+ u,
724
750
  f
725
751
  ),
726
752
  n.getUniversalChallengersByVersion(
727
- y
753
+ v
728
754
  )
729
755
  ]), m = {
730
756
  vaultProvider: k(h),
731
- vaultKeepers: Y(T.map((P) => P.btcPubKey)),
732
- universalChallengers: Y(x.map((P) => P.btcPubKey))
733
- }, b = await tt({
757
+ vaultKeepers: W(T.map((P) => P.btcPubKey)),
758
+ universalChallengers: W(x.map((P) => P.btcPubKey))
759
+ }, b = await rt({
734
760
  operationKeyReader: i,
735
761
  query: {
736
- vaultProviderEthAddress: s,
762
+ vaultProviderEthAddress: a,
737
763
  vaultProviderGenesisBtcPubkey: `0x${h}`,
738
- applicationEntryPoint: l,
764
+ applicationEntryPoint: u,
739
765
  vaultKeepers: T,
740
766
  universalChallengers: x
741
767
  }
742
- }), v = {
768
+ }), y = {
743
769
  vaultProvider: b.vaultProvider.operationBtcPubkey,
744
770
  vaultKeepers: [...b.vaultKeeperOperationKeysSorted],
745
771
  universalChallengers: [
746
772
  ...b.universalChallengerOperationKeysSorted
747
773
  ]
748
- }, S = Ze(
774
+ }, S = et(
749
775
  o,
750
776
  m.vaultProvider,
751
- v.vaultProvider
777
+ y.vaultProvider
752
778
  ), _ = q(
753
- a,
779
+ s,
754
780
  m.vaultKeepers,
755
- v.vaultKeepers
781
+ y.vaultKeepers
756
782
  ), B = q(
757
- u,
783
+ l,
758
784
  m.universalChallengers,
759
- v.universalChallengers
785
+ y.universalChallengers
760
786
  );
761
- if (!V(S))
787
+ if (!K(S))
762
788
  throw new Error(
763
- `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
789
+ `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${a}. Refresh and try again.`
764
790
  );
765
- if (!V(_))
791
+ if (!K(_))
766
792
  throw new Error(
767
793
  `Vault keeper BTC pubkeys (v${f}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
768
794
  );
769
- if (!V(B))
795
+ if (!K(B))
770
796
  throw new Error(
771
- `Universal challenger BTC pubkeys (v${y}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
797
+ `Universal challenger BTC pubkeys (v${v}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
772
798
  );
773
- const g = [S, _, B], pe = g.some((P) => P.registration && !P.operation), z = g.some((P) => P.operation && !P.registration);
774
- if (pe && z) {
775
- const P = `Indexer participant hints are internally inconsistent for vault provider ${s}: some roles match the registration keys while others match the rotated operation keys.`;
799
+ const g = [S, _, B], de = g.some((P) => P.registration && !P.operation), z = g.some((P) => P.operation && !P.registration);
800
+ if (de && z) {
801
+ const P = `Indexer participant hints are internally inconsistent for vault provider ${a}: some roles match the registration keys while others match the rotated operation keys.`;
776
802
  throw c == null || c(P), new Error(`${P} Refresh and try again.`);
777
803
  }
778
804
  return z && (p == null || p(
779
- `Indexer is serving rotated operation keys for vault provider ${s}`
805
+ `Indexer is serving rotated operation keys for vault provider ${a}`
780
806
  )), {
781
- vaultProviderBtcPubkeyXOnly: v.vaultProvider,
782
- vaultKeeperBtcPubkeysSorted: v.vaultKeepers,
783
- universalChallengerBtcPubkeysSorted: v.universalChallengers,
807
+ vaultProviderBtcPubkeyXOnly: y.vaultProvider,
808
+ vaultKeeperBtcPubkeysSorted: y.vaultKeepers,
809
+ universalChallengerBtcPubkeysSorted: y.universalChallengers,
784
810
  expectedAppVaultKeepersVersion: f,
785
- expectedUniversalChallengersVersion: y,
811
+ expectedUniversalChallengersVersion: v,
786
812
  registrationKeys: m,
787
813
  participantKeys: b
788
814
  };
789
815
  }
790
- function nt(e) {
816
+ function ot(e) {
791
817
  return /^[0-9a-fA-F]{64}$/.test(e);
792
818
  }
793
- function Vt(e) {
819
+ function Ot(e) {
794
820
  const {
795
821
  amountSats: t,
796
822
  minDeposit: r,
797
823
  maxDeposit: n,
798
- btcBalance: s,
799
- estimatedFeeSats: l,
824
+ btcBalance: a,
825
+ estimatedFeeSats: u,
800
826
  depositorClaimValue: o
801
827
  } = e;
802
- return !(t <= 0n || t < r || n && n > 0n && t > n || l == null || o == null || t + l + o > s);
828
+ return !(t <= 0n || t < r || n && n > 0n && t > n || u == null || o == null || t + u + o > a);
803
829
  }
804
- function It(e, t, r) {
830
+ function Ht(e, t, r) {
805
831
  return e <= 0n ? {
806
832
  valid: !1,
807
833
  error: "Deposit amount must be greater than zero"
@@ -813,7 +839,7 @@ function It(e, t, r) {
813
839
  error: `Maximum deposit is ${C(r)} BTC`
814
840
  } : { valid: !0 };
815
841
  }
816
- function Ot(e) {
842
+ function Nt(e) {
817
843
  const { amount: t, effectiveRemaining: r } = e;
818
844
  return r === null ? { valid: !0 } : r === 0n ? {
819
845
  valid: !1,
@@ -823,191 +849,191 @@ function Ot(e) {
823
849
  error: `Vault size exceeds remaining capacity (${C(r)} BTC)`
824
850
  } : { valid: !0 };
825
851
  }
826
- function Ht(e, t) {
852
+ function Dt(e, t) {
827
853
  if (!e || e.length === 0)
828
854
  return {
829
855
  valid: !1,
830
856
  error: "At least one vault provider must be selected"
831
857
  };
832
858
  const r = t.map(
833
- (s) => s.toLowerCase()
859
+ (a) => a.toLowerCase()
834
860
  );
835
861
  return e.filter(
836
- (s) => !r.includes(s.toLowerCase())
862
+ (a) => !r.includes(a.toLowerCase())
837
863
  ).length > 0 ? {
838
864
  valid: !1,
839
865
  error: "Invalid vault provider selected"
840
866
  } : { valid: !0 };
841
867
  }
842
- function ot(e, t, r) {
868
+ function at(e, t, r) {
843
869
  if (!e || e.length === 0)
844
870
  return {
845
871
  valid: !1,
846
872
  error: "At least one vault amount required"
847
873
  };
848
874
  for (let n = 0; n < e.length; n++) {
849
- const s = e[n];
850
- if (s <= 0n)
875
+ const a = e[n];
876
+ if (a <= 0n)
851
877
  return {
852
878
  valid: !1,
853
879
  error: `Vault ${n + 1} amount must be positive`
854
880
  };
855
- if (t && s < t)
881
+ if (t && a < t)
856
882
  return {
857
883
  valid: !1,
858
- error: `Vault ${n + 1} amount ${C(s)} BTC is below minimum deposit ${C(t)} BTC`
884
+ error: `Vault ${n + 1} amount ${C(a)} BTC is below minimum deposit ${C(t)} BTC`
859
885
  };
860
- if (r && s > r)
886
+ if (r && a > r)
861
887
  return {
862
888
  valid: !1,
863
- error: `Vault ${n + 1} amount ${C(s)} BTC exceeds maximum deposit ${C(r)} BTC`
889
+ error: `Vault ${n + 1} amount ${C(a)} BTC exceeds maximum deposit ${C(r)} BTC`
864
890
  };
865
891
  }
866
892
  return { valid: !0 };
867
893
  }
868
- function at(e) {
894
+ function st(e) {
869
895
  const t = d(e);
870
- return nt(t) ? { valid: !0 } : {
896
+ return ot(t) ? { valid: !0 } : {
871
897
  valid: !1,
872
898
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
873
899
  };
874
900
  }
875
- function st(e) {
901
+ function it(e) {
876
902
  if (!e || e.length === 0)
877
903
  throw new Error(
878
904
  "No vault keepers available. The system requires at least one vault keeper to create a deposit."
879
905
  );
880
906
  }
881
- function it(e) {
907
+ function ut(e) {
882
908
  if (!e || e.length === 0)
883
909
  throw new Error(
884
910
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
885
911
  );
886
912
  }
887
- function ut(e) {
913
+ function lt(e) {
888
914
  if (e.length === 0)
889
915
  throw new Error("No spendable UTXOs available");
890
916
  }
891
- function Nt(e) {
917
+ function Ft(e) {
892
918
  const {
893
919
  vaultAmounts: t,
894
920
  confirmedUTXOs: r,
895
921
  vaultProviderBtcPubkey: n,
896
- vaultKeeperBtcPubkeys: s,
897
- universalChallengerBtcPubkeys: l,
922
+ vaultKeeperBtcPubkeys: a,
923
+ universalChallengerBtcPubkeys: u,
898
924
  minDeposit: o,
899
- maxDeposit: a
900
- } = e, u = ot(
925
+ maxDeposit: s
926
+ } = e, l = at(
901
927
  t,
902
928
  o,
903
- a
929
+ s
904
930
  );
905
- if (!u.valid)
906
- throw new Error(u.error);
907
- const i = at(n);
931
+ if (!l.valid)
932
+ throw new Error(l.error);
933
+ const i = st(n);
908
934
  if (!i.valid)
909
935
  throw new Error(i.error);
910
- st(s), it(l), ut(r);
936
+ it(a), ut(u), lt(r);
911
937
  }
912
- class se extends Error {
938
+ class ue extends Error {
913
939
  constructor(t) {
914
940
  super(t), this.name = "ParticipantKeyDriftError";
915
941
  }
916
942
  }
917
- function Dt(e) {
918
- return e instanceof se || e instanceof Error && e.name === "ParticipantKeyDriftError";
943
+ function Mt(e) {
944
+ return e instanceof ue || e instanceof Error && e.name === "ParticipantKeyDriftError";
919
945
  }
920
- function W(e, t, r) {
921
- return t.length === r.length && t.every((n, s) => n === r[s]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
946
+ function Y(e, t, r) {
947
+ return t.length === r.length && t.every((n, a) => n === r[a]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
922
948
  }
923
- async function Ft(e) {
924
- const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: n, expected: s } = e, l = s.query;
949
+ async function Ut(e) {
950
+ const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: n, expected: a } = e, u = a.query;
925
951
  if (n.length === 0) return;
926
- const o = await t.getVaultKeyEpochsBatch(n), a = [];
927
- for (const [u, i] of o.entries()) {
928
- const p = n[u];
952
+ const o = await t.getVaultKeyEpochsBatch(n), s = [];
953
+ for (const [l, i] of o.entries()) {
954
+ const p = n[l];
929
955
  let c;
930
956
  try {
931
- c = await rt({
957
+ c = await nt({
932
958
  operationKeyReader: r,
933
- query: l,
959
+ query: u,
934
960
  epochs: i
935
961
  });
936
- } catch (y) {
937
- a.push(
938
- `vault ${p}: could not resolve participants at frozen epochs (vp=${i.vpKeyEpoch}, keeper=${i.appKeeperKeyEpoch}, uc=${i.ucKeyEpoch}): ${y.message}`
962
+ } catch (v) {
963
+ s.push(
964
+ `vault ${p}: could not resolve participants at frozen epochs (vp=${i.vpKeyEpoch}, keeper=${i.appKeeperKeyEpoch}, uc=${i.ucKeyEpoch}): ${v.message}`
939
965
  );
940
966
  continue;
941
967
  }
942
- c.vaultProvider.operationBtcPubkey !== s.vaultProvider.operationBtcPubkey && a.push(
943
- `vault ${p}: vault provider key expected ${s.vaultProvider.operationBtcPubkey}, got ${c.vaultProvider.operationBtcPubkey}`
968
+ c.vaultProvider.operationBtcPubkey !== a.vaultProvider.operationBtcPubkey && s.push(
969
+ `vault ${p}: vault provider key expected ${a.vaultProvider.operationBtcPubkey}, got ${c.vaultProvider.operationBtcPubkey}`
944
970
  );
945
- const h = W(
971
+ const h = Y(
946
972
  `vault ${p}: vault keeper keys`,
947
- s.vaultKeeperOperationKeysSorted,
973
+ a.vaultKeeperOperationKeysSorted,
948
974
  c.vaultKeeperOperationKeysSorted
949
975
  );
950
- h && a.push(h);
951
- const f = W(
976
+ h && s.push(h);
977
+ const f = Y(
952
978
  `vault ${p}: universal challenger keys`,
953
- s.universalChallengerOperationKeysSorted,
979
+ a.universalChallengerOperationKeysSorted,
954
980
  c.universalChallengerOperationKeysSorted
955
981
  );
956
- f && a.push(f);
982
+ f && s.push(f);
957
983
  }
958
- if (a.length > 0)
959
- throw new se(
960
- `Aborting BTC broadcast: participant operation keys changed during registration (${a.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
984
+ if (s.length > 0)
985
+ throw new ue(
986
+ `Aborting BTC broadcast: participant operation keys changed during registration (${s.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
961
987
  );
962
988
  }
963
- class ie extends Error {
989
+ class le extends Error {
964
990
  constructor(t) {
965
991
  super(t), this.name = "RegisteredVaultVersionMismatchError";
966
992
  }
967
993
  }
968
- function Mt(e) {
969
- return e instanceof ie || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
994
+ function Lt(e) {
995
+ return e instanceof le || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
970
996
  }
971
- async function Ut(e) {
997
+ async function zt(e) {
972
998
  const {
973
999
  vaultRegistryReader: t,
974
1000
  vaultIds: r,
975
1001
  expectedOffchainParamsVersion: n,
976
- expectedAppVaultKeepersVersion: s,
977
- expectedUniversalChallengersVersion: l,
1002
+ expectedAppVaultKeepersVersion: a,
1003
+ expectedUniversalChallengersVersion: u,
978
1004
  expectedVaultCoreVersion: o
979
- } = e, a = await t.getProtocolInfoBatch(r), u = [];
980
- if (a.forEach((i, p) => {
1005
+ } = e, s = await t.getProtocolInfoBatch(r), l = [];
1006
+ if (s.forEach((i, p) => {
981
1007
  const c = r[p];
982
- i.offchainParamsVersion !== n && u.push(
1008
+ i.offchainParamsVersion !== n && l.push(
983
1009
  `vault ${c}: offchainParams expected v${n}, got v${i.offchainParamsVersion}`
984
- ), i.appVaultKeepersVersion !== s && u.push(
985
- `vault ${c}: appVaultKeepers expected v${s}, got v${i.appVaultKeepersVersion}`
986
- ), i.universalChallengersVersion !== l && u.push(
987
- `vault ${c}: universalChallengers expected v${l}, got v${i.universalChallengersVersion}`
988
- ), i.vaultCoreVersion !== o && u.push(
1010
+ ), i.appVaultKeepersVersion !== a && l.push(
1011
+ `vault ${c}: appVaultKeepers expected v${a}, got v${i.appVaultKeepersVersion}`
1012
+ ), i.universalChallengersVersion !== u && l.push(
1013
+ `vault ${c}: universalChallengers expected v${u}, got v${i.universalChallengersVersion}`
1014
+ ), i.vaultCoreVersion !== o && l.push(
989
1015
  `vault ${c}: vaultCoreVersion expected v${o} (build-time active), got v${i.vaultCoreVersion}`
990
1016
  );
991
- }), u.length > 0)
992
- throw new ie(
993
- `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${u.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
1017
+ }), l.length > 0)
1018
+ throw new le(
1019
+ `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${l.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
994
1020
  );
995
1021
  }
996
- var ue = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(ue || {});
997
- const lt = /* @__PURE__ */ new Set([
1022
+ var ce = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(ce || {});
1023
+ const ct = /* @__PURE__ */ new Set([
998
1024
  "PayoutBroadcast",
999
1025
  "PayoutBlocked"
1000
1026
  /* PAYOUT_BLOCKED */
1001
1027
  ]);
1002
- function Lt(e) {
1003
- return Object.values(ue).includes(
1028
+ function Xt(e) {
1029
+ return Object.values(ce).includes(
1004
1030
  e
1005
1031
  );
1006
1032
  }
1007
- function zt(e) {
1008
- return !!e && lt.has(e);
1033
+ function Gt(e) {
1034
+ return !!e && ct.has(e);
1009
1035
  }
1010
- class ct extends Error {
1036
+ class pt extends Error {
1011
1037
  constructor(r, n) {
1012
1038
  super(`Refund not yet mature (BIP68 not final): ${n.message}`);
1013
1039
  A(this, "vaultId");
@@ -1015,21 +1041,21 @@ class ct extends Error {
1015
1041
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
1016
1042
  }
1017
1043
  }
1018
- const pt = /^0x[0-9a-fA-F]{64}$/, ht = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, le = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, ce = 160, J = 2e3, Z = 10n, ee = 100n;
1019
- function Xt(e) {
1044
+ const ht = /^0x[0-9a-fA-F]{64}$/, dt = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, pe = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, he = 160, J = 2e3, Z = 10n, ee = 100n;
1045
+ function jt(e) {
1020
1046
  if (!Number.isFinite(e) || e <= 0)
1021
1047
  throw new Error(
1022
1048
  `feeRateSatsVb must be a positive finite number, got ${e}`
1023
1049
  );
1024
- return BigInt(Math.ceil(e * ce));
1050
+ return BigInt(Math.ceil(e * he));
1025
1051
  }
1026
- const dt = 1, gt = /non-BIP68-final/i;
1052
+ const gt = 1, ft = /non-BIP68-final/i;
1027
1053
  function U(e, t) {
1028
1054
  if (e.length !== 66)
1029
1055
  throw new Error(
1030
1056
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
1031
1057
  );
1032
- if (!pt.test(e))
1058
+ if (!ht.test(e))
1033
1059
  throw new Error(
1034
1060
  `${t} must contain only hex characters after the 0x prefix`
1035
1061
  );
@@ -1038,7 +1064,7 @@ function H(e, t) {
1038
1064
  if (!Number.isInteger(e) || e < 0)
1039
1065
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
1040
1066
  }
1041
- function ft(e) {
1067
+ function vt(e) {
1042
1068
  if (U(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
1043
1069
  throw new Error(
1044
1070
  `htlcVout must be a non-negative integer, got ${e.htlcVout}`
@@ -1072,16 +1098,16 @@ function ft(e) {
1072
1098
  if (H(e.offchainParamsVersion, "offchainParamsVersion"), H(e.appVaultKeepersVersion, "appVaultKeepersVersion"), H(
1073
1099
  e.universalChallengersVersion,
1074
1100
  "universalChallengersVersion"
1075
- ), Be(
1101
+ ), Ae(
1076
1102
  e.vaultCoreVersion,
1077
1103
  "VaultRefundData.vaultCoreVersion"
1078
1104
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
1079
1105
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
1080
- if (!ht.test(e.unsignedPrePeginTxHex))
1106
+ if (!dt.test(e.unsignedPrePeginTxHex))
1081
1107
  throw new Error(
1082
1108
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
1083
1109
  );
1084
- if (!e.depositorBtcPubkey || !le.test(e.depositorBtcPubkey))
1110
+ if (!e.depositorBtcPubkey || !pe.test(e.depositorBtcPubkey))
1085
1111
  throw new Error(
1086
1112
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
1087
1113
  );
@@ -1089,7 +1115,7 @@ function ft(e) {
1089
1115
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
1090
1116
  }
1091
1117
  function yt(e) {
1092
- if (!e.vaultProviderPubkey || !le.test(e.vaultProviderPubkey))
1118
+ if (!e.vaultProviderPubkey || !pe.test(e.vaultProviderPubkey))
1093
1119
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
1094
1120
  if (e.vaultKeeperPubkeys.length === 0)
1095
1121
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -1114,8 +1140,8 @@ function yt(e) {
1114
1140
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
1115
1141
  );
1116
1142
  }
1117
- function vt(e) {
1118
- const t = Ce.fromHex(e);
1143
+ function Pt(e) {
1144
+ const t = Te.fromHex(e);
1119
1145
  try {
1120
1146
  t.finalizeAllInputs();
1121
1147
  } catch (r) {
@@ -1125,40 +1151,40 @@ function vt(e) {
1125
1151
  }
1126
1152
  return t.extractTransaction().toHex();
1127
1153
  }
1128
- async function Gt(e) {
1154
+ async function qt(e) {
1129
1155
  const {
1130
1156
  vaultId: t,
1131
1157
  readVault: r,
1132
1158
  readPrePeginContext: n,
1133
- feeRate: s,
1134
- signPsbt: l,
1159
+ feeRate: a,
1160
+ signPsbt: u,
1135
1161
  broadcastTx: o,
1136
- signal: a
1162
+ signal: s
1137
1163
  } = e;
1138
- a == null || a.throwIfAborted(), U(t, "vaultId");
1139
- const u = await r();
1140
- ft(u), a == null || a.throwIfAborted();
1141
- const i = await n(u);
1142
- if (yt(i), a == null || a.throwIfAborted(), !Number.isFinite(s) || s <= 0)
1143
- throw new Error(`feeRate must be a positive number, got ${s}`);
1144
- if (s > J)
1164
+ s == null || s.throwIfAborted(), U(t, "vaultId");
1165
+ const l = await r();
1166
+ vt(l), s == null || s.throwIfAborted();
1167
+ const i = await n(l);
1168
+ if (yt(i), s == null || s.throwIfAborted(), !Number.isFinite(a) || a <= 0)
1169
+ throw new Error(`feeRate must be a positive number, got ${a}`);
1170
+ if (a > J)
1145
1171
  throw new Error(
1146
- `feeRate ${s} sat/vB exceeds refund safety cap ${J} sat/vB; refusing to sign refund.`
1172
+ `feeRate ${a} sat/vB exceeds refund safety cap ${J} sat/vB; refusing to sign refund.`
1147
1173
  );
1148
- const p = BigInt(Math.ceil(s * ce)), c = u.amount * Z / ee;
1174
+ const p = BigInt(Math.ceil(a * he)), c = l.amount * Z / ee;
1149
1175
  if (p > c)
1150
1176
  throw new Error(
1151
- `Refund fee ${p} sats exceeds the per-vault safety cap of ${c} sats (${Z}/${ee} of vault.amount=${u.amount}); refusing to sign refund.`
1177
+ `Refund fee ${p} sats exceeds the per-vault safety cap of ${c} sats (${Z}/${ee} of vault.amount=${l.amount}); refusing to sign refund.`
1152
1178
  );
1153
- a == null || a.throwIfAborted();
1179
+ s == null || s.throwIfAborted();
1154
1180
  const h = L(
1155
- u.depositorBtcPubkey
1156
- ), f = d(u.unsignedPrePeginTxHex), y = we(f);
1157
- if (y !== void 0 && y.vout !== u.batch.length)
1181
+ l.depositorBtcPubkey
1182
+ ), f = d(l.unsignedPrePeginTxHex), v = ke(f);
1183
+ if (v !== void 0 && v.vout !== l.batch.length)
1158
1184
  throw new Error(
1159
- `Auth-anchor OP_RETURN at vout ${y.vout} does not match batch size (${u.batch.length} HTLC outputs expect the anchor at vout ${u.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
1185
+ `Auth-anchor OP_RETURN at vout ${v.vout} does not match batch size (${l.batch.length} HTLC outputs expect the anchor at vout ${l.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
1160
1186
  );
1161
- const T = y == null ? void 0 : y.hash;
1187
+ const T = v == null ? void 0 : v.hash;
1162
1188
  let x;
1163
1189
  try {
1164
1190
  x = $.fromHex(f);
@@ -1167,18 +1193,18 @@ async function Gt(e) {
1167
1193
  `Failed to parse funded Pre-PegIn transaction hex: ${g instanceof Error ? g.message : String(g)}`
1168
1194
  );
1169
1195
  }
1170
- if (x.outs.length < u.batch.length)
1196
+ if (x.outs.length < l.batch.length)
1171
1197
  throw new Error(
1172
- `Funded Pre-PegIn tx has ${x.outs.length} outputs but batch requires at least ${u.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
1198
+ `Funded Pre-PegIn tx has ${x.outs.length} outputs but batch requires at least ${l.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
1173
1199
  );
1174
- const { psbtHex: m } = await _e({
1200
+ const { psbtHex: m } = await Be({
1175
1201
  prePeginParams: {
1176
- vaultCoreVersion: u.vaultCoreVersion,
1202
+ vaultCoreVersion: l.vaultCoreVersion,
1177
1203
  depositorPubkey: h,
1178
1204
  vaultProviderPubkey: d(i.vaultProviderPubkey),
1179
1205
  vaultKeeperPubkeys: i.vaultKeeperPubkeys.map(d),
1180
1206
  universalChallengerPubkeys: i.universalChallengerPubkeys.map(d),
1181
- hashlocks: u.batch.map((g) => d(g.hashlock)),
1207
+ hashlocks: l.batch.map((g) => d(g.hashlock)),
1182
1208
  timelockRefund: i.timelockRefund,
1183
1209
  // `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
1184
1210
  // is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
@@ -1186,7 +1212,7 @@ async function Gt(e) {
1186
1212
  // HTLC output. `buildRefundPsbt`'s value cross-check then binds the result
1187
1213
  // to the funded tx bytes, refusing the refund if the template's HTLC value
1188
1214
  // disagrees with the on-chain commitment.
1189
- pegInAmounts: u.batch.map((g) => g.amount),
1215
+ pegInAmounts: l.batch.map((g) => g.amount),
1190
1216
  feeRate: i.feeRate,
1191
1217
  minPeginFeeRate: i.minPeginFeeRate,
1192
1218
  numLocalChallengers: i.numLocalChallengers,
@@ -1196,25 +1222,25 @@ async function Gt(e) {
1196
1222
  authAnchorHash: T
1197
1223
  },
1198
1224
  fundedPrePeginTxHex: f,
1199
- htlcVout: u.htlcVout,
1225
+ htlcVout: l.htlcVout,
1200
1226
  refundFee: p,
1201
1227
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
1202
1228
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
1203
1229
  // value would derive the wrong refund script leaf and yield an
1204
1230
  // unspendable PSBT. Match the `hashlocks` array handling above.
1205
- hashlock: d(u.hashlock)
1231
+ hashlock: d(l.hashlock)
1206
1232
  });
1207
- a == null || a.throwIfAborted();
1233
+ s == null || s.throwIfAborted();
1208
1234
  const b = M(
1209
- u.depositorBtcPubkey,
1210
- dt
1211
- ), v = await l(m, b);
1235
+ l.depositorBtcPubkey,
1236
+ gt
1237
+ ), y = await u(m, b);
1212
1238
  N({
1213
1239
  requestedPsbtHex: m,
1214
- returnedPsbtHex: v
1240
+ returnedPsbtHex: y
1215
1241
  });
1216
1242
  const S = 0, _ = D(
1217
- v,
1243
+ y,
1218
1244
  h,
1219
1245
  S
1220
1246
  );
@@ -1224,49 +1250,50 @@ async function Gt(e) {
1224
1250
  signerXOnlyPubkeyHex: h,
1225
1251
  inputIndex: S
1226
1252
  });
1227
- const B = vt(v);
1228
- a == null || a.throwIfAborted();
1253
+ const B = Pt(y);
1254
+ s == null || s.throwIfAborted();
1229
1255
  try {
1230
1256
  return await o(B);
1231
1257
  } catch (g) {
1232
- throw g instanceof Error && gt.test(g.message) ? new ct(t, g) : g;
1258
+ throw g instanceof Error && ft.test(g.message) ? new pt(t, g) : g;
1233
1259
  }
1234
1260
  }
1235
1261
  export {
1236
- Xt as A,
1237
- ct as B,
1238
- ue as C,
1239
- ee as D,
1240
- Z as E,
1241
- J as F,
1242
- ce as G,
1243
- se as P,
1244
- ie as R,
1245
- _t as a,
1262
+ qt as A,
1263
+ pt as B,
1264
+ ce as C,
1265
+ jt as D,
1266
+ ee as E,
1267
+ Z as F,
1268
+ J as G,
1269
+ he as H,
1270
+ ue as P,
1271
+ le as R,
1272
+ Bt as a,
1246
1273
  At as b,
1247
- It as c,
1248
- Nt as d,
1249
- Ht as e,
1250
- Ot as f,
1251
- ot as g,
1274
+ Vt as c,
1275
+ Ht as d,
1276
+ Ft as e,
1277
+ Dt as f,
1278
+ Nt as g,
1252
1279
  at as h,
1253
- Vt as i,
1254
- Dt as j,
1255
- Ft as k,
1256
- Mt as l,
1257
- Ut as m,
1258
- Rt as n,
1259
- V as o,
1260
- Ze as p,
1261
- q,
1262
- Bt as r,
1263
- Le as s,
1264
- tt as t,
1280
+ Ot as i,
1281
+ st as j,
1282
+ Mt as k,
1283
+ Ut as l,
1284
+ Lt as m,
1285
+ zt as n,
1286
+ Kt as o,
1287
+ K as p,
1288
+ et as q,
1289
+ Rt as r,
1290
+ ze as s,
1291
+ q as t,
1265
1292
  rt as u,
1266
- Kt as v,
1267
- ne as w,
1268
- Lt as x,
1269
- zt as y,
1293
+ It as v,
1294
+ ae as w,
1295
+ nt as x,
1296
+ Xt as y,
1270
1297
  Gt as z
1271
1298
  };
1272
- //# sourceMappingURL=buildAndBroadcastRefund-DBA-Mp4I.js.map
1299
+ //# sourceMappingURL=buildAndBroadcastRefund-C-rbYMy6.js.map