@babylonlabs-io/ts-sdk 4.0.0 → 5.0.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 (94) hide show
  1. package/dist/PayoutManager-BXzFIZK6.cjs +2 -0
  2. package/dist/PayoutManager-BXzFIZK6.cjs.map +1 -0
  3. package/dist/{PayoutManager-BUWP-H-q.js → PayoutManager-Cjkozmnn.js} +9 -9
  4. package/dist/PayoutManager-Cjkozmnn.js.map +1 -0
  5. package/dist/{PeginManager-CMbRRTnr.cjs → PeginManager-BipOU_e4.cjs} +2 -2
  6. package/dist/PeginManager-BipOU_e4.cjs.map +1 -0
  7. package/dist/{PeginManager-Cas6_j7t.js → PeginManager-Cd5pHNTO.js} +2 -2
  8. package/dist/PeginManager-Cd5pHNTO.js.map +1 -0
  9. package/dist/{buildAndBroadcastReclaim-CVmG3ldA.cjs → buildAndBroadcastReclaim-B00roO6R.cjs} +2 -2
  10. package/dist/buildAndBroadcastReclaim-B00roO6R.cjs.map +1 -0
  11. package/dist/{buildAndBroadcastReclaim-XRWuJWVL.js → buildAndBroadcastReclaim-DU8iOtbn.js} +368 -331
  12. package/dist/buildAndBroadcastReclaim-DU8iOtbn.js.map +1 -0
  13. package/dist/challengeAssert-eUMgmpMk.cjs +2 -0
  14. package/dist/challengeAssert-eUMgmpMk.cjs.map +1 -0
  15. package/dist/{challengeAssert-DUKSjirl.js → challengeAssert-pJP7MKhG.js} +164 -164
  16. package/dist/challengeAssert-pJP7MKhG.js.map +1 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +61 -60
  19. package/dist/{primeVpAuth-C-ET0XF4.js → primeVpAuth-B0noJdcy.js} +5 -3
  20. package/dist/{primeVpAuth-C-ET0XF4.js.map → primeVpAuth-B0noJdcy.js.map} +1 -1
  21. package/dist/primeVpAuth-Ch-ig2My.cjs.map +1 -1
  22. package/dist/signer-set-reader-CJfV-GDz.cjs.map +1 -1
  23. package/dist/signer-set-reader-DiwLeqik.js.map +1 -1
  24. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +5 -1
  25. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -1
  26. package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
  27. package/dist/tbv/core/clients/eth/types.d.ts +20 -0
  28. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  29. package/dist/tbv/core/clients/index.d.ts +4 -2
  30. package/dist/tbv/core/clients/index.d.ts.map +1 -1
  31. package/dist/tbv/core/clients/index.js +1 -1
  32. package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts +4 -2
  33. package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts.map +1 -1
  34. package/dist/tbv/core/deposit-terms/depositTerms.d.ts +13 -10
  35. package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -1
  36. package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts +3 -2
  37. package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts.map +1 -1
  38. package/dist/tbv/core/index.cjs +1 -1
  39. package/dist/tbv/core/index.js +62 -61
  40. package/dist/tbv/core/managers/PayoutManager.d.ts +9 -3
  41. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  42. package/dist/tbv/core/managers/PeginManager.d.ts +13 -3
  43. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  44. package/dist/tbv/core/managers/index.cjs +1 -1
  45. package/dist/tbv/core/managers/index.js +2 -2
  46. package/dist/tbv/core/primitives/challengers.d.ts +12 -5
  47. package/dist/tbv/core/primitives/challengers.d.ts.map +1 -1
  48. package/dist/tbv/core/primitives/index.cjs +1 -1
  49. package/dist/tbv/core/primitives/index.d.ts +1 -1
  50. package/dist/tbv/core/primitives/index.js +1 -1
  51. package/dist/tbv/core/primitives/psbt/pegin.d.ts +26 -4
  52. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  53. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  54. package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts +3 -3
  55. package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts.map +1 -1
  56. package/dist/tbv/core/services/delegated-claim/types.d.ts +3 -3
  57. package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -1
  58. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +19 -4
  59. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  60. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +17 -3
  61. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  62. package/dist/tbv/core/services/index.cjs +1 -1
  63. package/dist/tbv/core/services/index.js +44 -43
  64. package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts +19 -7
  65. package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts.map +1 -1
  66. package/dist/tbv/core/services/refund/__tests__/readRefundPrePeginContext.test.d.ts +12 -0
  67. package/dist/tbv/core/services/refund/__tests__/readRefundPrePeginContext.test.d.ts.map +1 -0
  68. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts +41 -12
  69. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  70. package/dist/tbv/core/services/refund/index.d.ts +1 -0
  71. package/dist/tbv/core/services/refund/index.d.ts.map +1 -1
  72. package/dist/tbv/core/services/refund/readRefundPrePeginContext.d.ts +41 -0
  73. package/dist/tbv/core/services/refund/readRefundPrePeginContext.d.ts.map +1 -0
  74. package/dist/tbv/index.cjs +1 -1
  75. package/dist/tbv/index.js +62 -61
  76. package/dist/{toRefundInputs-BbbvPb2A.js → toRefundInputs-BrJrmOvY.js} +3 -3
  77. package/dist/{toRefundInputs-BbbvPb2A.js.map → toRefundInputs-BrJrmOvY.js.map} +1 -1
  78. package/dist/{toRefundInputs-BSQjDOK9.cjs → toRefundInputs-CR7vtHMa.cjs} +2 -2
  79. package/dist/{toRefundInputs-BSQjDOK9.cjs.map → toRefundInputs-CR7vtHMa.cjs.map} +1 -1
  80. package/dist/types-BnZIbDHb.cjs.map +1 -1
  81. package/dist/types-K_aM5GZO.js.map +1 -1
  82. package/dist/verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs.map +1 -1
  83. package/dist/verifyScriptPathSchnorrSignature-D-fdi-sG.js.map +1 -1
  84. package/package.json +3 -3
  85. package/dist/PayoutManager-BUWP-H-q.js.map +0 -1
  86. package/dist/PayoutManager-Dopxq_Jv.cjs +0 -2
  87. package/dist/PayoutManager-Dopxq_Jv.cjs.map +0 -1
  88. package/dist/PeginManager-CMbRRTnr.cjs.map +0 -1
  89. package/dist/PeginManager-Cas6_j7t.js.map +0 -1
  90. package/dist/buildAndBroadcastReclaim-CVmG3ldA.cjs.map +0 -1
  91. package/dist/buildAndBroadcastReclaim-XRWuJWVL.js.map +0 -1
  92. package/dist/challengeAssert-BE6Wm4x1.cjs +0 -2
  93. package/dist/challengeAssert-BE6Wm4x1.cjs.map +0 -1
  94. package/dist/challengeAssert-DUKSjirl.js.map +0 -1
@@ -1,52 +1,52 @@
1
- var Zt = Object.defineProperty;
2
- var er = (e, t, r) => t in e ? Zt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var W = (e, t, r) => er(e, typeof t != "symbol" ? t + "" : t, r);
1
+ var er = Object.defineProperty;
2
+ var tr = (e, t, r) => t in e ? er(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var W = (e, t, r) => tr(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { B as Be } from "./BTCVaultRegistry.abi-DnP4UkB5.js";
5
- import { e as Ie, s as b, i as tr, u as yt, c as _, v as rr, g as or, p as pe, f as N } from "./bitcoin-C-TuHb-v.js";
6
- import { v as sr, s as vt, b as bt, P as nr, d as ir } from "./PayoutManager-BUWP-H-q.js";
7
- import { verifyWatchtowerArtifacts as ar, buildClaimPsbt as ur, buildAssertClaimerPsbt as cr, buildPayoutClaimerPsbt as lr, buildWronglyChallengedPsbts as dr, buildPayoutDepositorPsbt as hr, finalizeClaimTx as pr, buildWatchtowerArtifacts as gr, extractTapScriptSig as mt, expandWotsSeed as fr, wotsKeypairFromSeed as yr, validateWotsKeypairAgainstGraph as vr, getChallengeAssertOutputScriptPubKey as br, deriveVaultId as mr } from "./tbv/core/wasm/index.js";
8
- import { m as Pr, d as Pt, k as wr, a as _e, V as Le, i as xr, g as Er, f as kr, r as $r, h as Cr } from "./registration-records-D39ApuHS.js";
5
+ import { e as Ie, s as P, i as rr, u as yt, c as _, v as or, g as sr, p as pe, f as N } from "./bitcoin-C-TuHb-v.js";
6
+ import { v as nr, s as vt, b as Pt, P as ir, d as ar } from "./PayoutManager-Cjkozmnn.js";
7
+ import { verifyWatchtowerArtifacts as ur, buildClaimPsbt as cr, buildAssertClaimerPsbt as lr, buildPayoutClaimerPsbt as dr, buildWronglyChallengedPsbts as hr, buildPayoutDepositorPsbt as pr, finalizeClaimTx as gr, buildWatchtowerArtifacts as fr, extractTapScriptSig as bt, expandWotsSeed as yr, wotsKeypairFromSeed as vr, validateWotsKeypairAgainstGraph as Pr, getChallengeAssertOutputScriptPubKey as br, deriveVaultId as mr } from "./tbv/core/wasm/index.js";
8
+ import { m as wr, d as mt, k as xr, a as _e, V as Le, i as Er, g as kr, f as $r, r as Cr, h as Tr } from "./registration-records-D39ApuHS.js";
9
9
  import { Psbt as q, Transaction as S } from "bitcoinjs-lib";
10
- import { F as U, G as A, H as re, I as Q, A as G, z as Z, J as ge, v as Me, E as ee, K as Ve, w as Ue, x as Fe, y as qe, W as Tr, D as Ge, C as Xe, L as _r, O as Sr, Q as Ar } from "./constants-CmDDuM3L.js";
11
- import { p as Br, q as Ir, r as wt, P as X, j as oe, f as Vr, i as ae, g as ue } from "./verifyScriptPathSchnorrSignature-D-fdi-sG.js";
10
+ import { F, G as A, H as re, I as J, A as G, z as Z, J as ge, v as Me, E as ee, K as Ve, w as Fe, x as Ue, y as qe, W as _r, D as Ge, C as Xe, L as Sr, O as Ar, Q as Br } from "./constants-CmDDuM3L.js";
11
+ import { p as Ir, q as Vr, r as wt, P as X, j as oe, f as Rr, i as ae, g as ue } from "./verifyScriptPathSchnorrSignature-D-fdi-sG.js";
12
12
  import { Buffer as H } from "buffer";
13
13
  import { C as xt, X as Et } from "./validation-OSC0xTHB.js";
14
14
  import { a as kt, c as ce } from "./signing-C1rR4tqs.js";
15
15
  import { d as $t } from "./deriveVaultRoot-BcvmER1E.js";
16
- import { O as ze, d as Rr } from "./types-K_aM5GZO.js";
17
- import { zeroAddress as Kr, isAddress as Hr, isAddressEqual as Or } from "viem";
18
- import { v as je, D as R, c as Nr, b as Dr, R as Lr, d as Ct } from "./state-CFn1rT74.js";
19
- import { h as We, b as Mr, s as Ur, j as Fr } from "./sha2-YqVHJiFj.js";
20
- import { c as qr, g as Gr, h as Xr, i as zr, b as jr, f as Tt, e as Wr, a as Yr } from "./challengeAssert-DUKSjirl.js";
16
+ import { O as ze, d as Kr } from "./types-K_aM5GZO.js";
17
+ import { zeroAddress as Hr, isAddress as Or, isAddressEqual as Nr } from "viem";
18
+ import { v as je, D as R, c as Dr, b as Lr, R as Mr, d as Ct } from "./state-CFn1rT74.js";
19
+ import { h as We, b as Fr, s as Ur, j as qr } from "./sha2-YqVHJiFj.js";
20
+ import { c as Gr, g as Xr, h as zr, i as jr, b as Wr, f as Tt, e as Yr, a as Qr } from "./challengeAssert-pJP7MKhG.js";
21
21
  import { a as Jr } from "./secp256k1-BuxBFUHm.js";
22
- import { c as Qr } from "./btcTxHash-BRZ8_EZq.js";
23
- const Zr = /^0x[0-9a-fA-F]{64}$/, eo = /^0x[0-9a-fA-F]{40}$/, to = /^0x([0-9a-fA-F]{2})*$/;
22
+ import { c as Zr } from "./btcTxHash-BRZ8_EZq.js";
23
+ const eo = /^0x[0-9a-fA-F]{64}$/, to = /^0x[0-9a-fA-F]{40}$/, ro = /^0x([0-9a-fA-F]{2})*$/;
24
24
  function ye(e, t) {
25
25
  if (e.length !== 66)
26
26
  throw new Error(
27
27
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
28
28
  );
29
- if (!Zr.test(e))
29
+ if (!eo.test(e))
30
30
  throw new Error(
31
31
  `${t} must contain only hex characters after the 0x prefix`
32
32
  );
33
33
  }
34
- function ro(e, t) {
35
- if (!eo.test(e))
34
+ function oo(e, t) {
35
+ if (!to.test(e))
36
36
  throw new Error(
37
37
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
38
38
  );
39
39
  }
40
- function oo(e, t) {
41
- if (!to.test(e))
40
+ function so(e, t) {
41
+ if (!ro.test(e))
42
42
  throw new Error(
43
43
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
44
44
  );
45
45
  }
46
46
  function Re(e) {
47
- ro(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), ye(e.vaultId, "vaultId");
47
+ oo(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), ye(e.vaultId, "vaultId");
48
48
  const t = Ie(e.secret);
49
- if (ye(t, "secret"), e.hashlock !== void 0 && (ye(e.hashlock, "hashlock"), !sr(t, e.hashlock)))
49
+ if (ye(t, "secret"), e.hashlock !== void 0 && (ye(e.hashlock, "hashlock"), !nr(t, e.hashlock)))
50
50
  throw new Error(
51
51
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
52
52
  );
@@ -68,7 +68,7 @@ async function nn(e) {
68
68
  secret: e.secret,
69
69
  hashlock: o
70
70
  });
71
- return oo(s, "activationMetadata"), n({
71
+ return so(s, "activationMetadata"), n({
72
72
  address: t,
73
73
  abi: Be,
74
74
  functionName: "activateVaultWithSecret",
@@ -120,7 +120,7 @@ function ve(e, t) {
120
120
  throw new K(`${e} PSBT cannot be parsed.`, { cause: r });
121
121
  }
122
122
  }
123
- function so(e, t, r) {
123
+ function no(e, t, r) {
124
124
  const o = t.txInputs[r];
125
125
  if (!o)
126
126
  throw new K(`${e} PSBT has no input ${r}.`);
@@ -131,7 +131,7 @@ function Ye(e) {
131
131
  e.data.globalMap.unsignedTx.toBuffer()
132
132
  ).getHash();
133
133
  }
134
- function be(e, t, r, o, s, n) {
134
+ function Pe(e, t, r, o, s, n) {
135
135
  const a = t.txInputs[r];
136
136
  if (!a)
137
137
  throw new K(`${e} PSBT has no input ${r}.`);
@@ -140,60 +140,60 @@ function be(e, t, r, o, s, n) {
140
140
  `${e} input ${r} does not spend ${n}: the graph pairs this ${e} with a different transaction.`
141
141
  );
142
142
  }
143
- function no(e, t) {
143
+ function io(e, t) {
144
144
  var s;
145
- const r = (s = e.data.inputs[U]) == null ? void 0 : s.witnessUtxo;
145
+ const r = (s = e.data.inputs[F]) == null ? void 0 : s.witnessUtxo;
146
146
  if (r === void 0)
147
147
  throw new K(
148
- `Assert input ${U} carries no witnessUtxo, so the amount and script its signature commits to cannot be checked; refusing to sign assert.`
148
+ `Assert input ${F} carries no witnessUtxo, so the amount and script its signature commits to cannot be checked; refusing to sign assert.`
149
149
  );
150
- const o = t.txOutputs[Q];
150
+ const o = t.txOutputs[J];
151
151
  if (!o)
152
152
  throw new K(
153
- `Claim PSBT has no output ${Q} for the Assert to spend; refusing to sign assert.`
153
+ `Claim PSBT has no output ${J} for the Assert to spend; refusing to sign assert.`
154
154
  );
155
155
  if (r.value !== o.value)
156
156
  throw new K(
157
- `Assert input ${U} declares a prevout of ${r.value} sats but the Claim's output ${Q} is worth ${o.value}; refusing to sign assert.`
157
+ `Assert input ${F} declares a prevout of ${r.value} sats but the Claim's output ${J} is worth ${o.value}; refusing to sign assert.`
158
158
  );
159
159
  if (!r.script.equals(o.script))
160
160
  throw new K(
161
- `Assert input ${U} declares a prevout script that is not the Claim's output ${Q} script; refusing to sign assert.`
161
+ `Assert input ${F} declares a prevout script that is not the Claim's output ${J} script; refusing to sign assert.`
162
162
  );
163
163
  }
164
- function io(e) {
164
+ function ao(e) {
165
165
  const t = ve("Claim", e.claimPsbtBase64), r = ve("Assert", e.assertPsbtBase64), o = ve("Payout", e.payoutClaimerPsbtBase64);
166
- be(
166
+ Pe(
167
167
  "Assert",
168
168
  r,
169
- U,
169
+ F,
170
170
  Ye(t),
171
- Q,
171
+ J,
172
172
  "Claim:0"
173
- ), no(r, t), be(
173
+ ), io(r, t), Pe(
174
174
  "Payout",
175
175
  o,
176
176
  A,
177
177
  Ye(r),
178
178
  G,
179
179
  "Assert:0"
180
- ), be(
180
+ ), Pe(
181
181
  "Payout",
182
182
  o,
183
183
  re,
184
- so("Claim", t, ge),
184
+ no("Claim", t, ge),
185
185
  Z,
186
186
  "this vault's PegIn:0"
187
187
  );
188
188
  }
189
- function me(e, t) {
189
+ function be(e, t) {
190
190
  try {
191
191
  return q.fromBase64(t);
192
192
  } catch (r) {
193
193
  throw new Error(`${e} PSBT cannot be parsed.`, { cause: r });
194
194
  }
195
195
  }
196
- function Je(e, t, r, o) {
196
+ function Qe(e, t, r, o) {
197
197
  var a;
198
198
  const s = [
199
199
  {
@@ -224,7 +224,7 @@ function Je(e, t, r, o) {
224
224
  `${e} Payout input ${A} declares a prevout script that is not the Assert's output ${G} script; refusing to sign payout.`
225
225
  );
226
226
  }
227
- async function ao(e) {
227
+ async function uo(e) {
228
228
  const { vault: t } = e, r = {
229
229
  vaultCoreVersion: t.vaultCoreVersion,
230
230
  numVaultKeepers: t.vaultKeeperBtcPubkeys.length,
@@ -232,11 +232,11 @@ async function ao(e) {
232
232
  councilSize: t.councilSize,
233
233
  protocolFeeRate: t.protocolFeeRate
234
234
  };
235
- Br(r);
236
- const o = me("Claimer Payout", e.payoutClaimerPsbtBase64), s = me(
235
+ Ir(r);
236
+ const o = be("Claimer Payout", e.payoutClaimerPsbtBase64), s = be(
237
237
  "Depositor Payout",
238
238
  e.payoutDepositorPsbtBase64
239
- ), n = me("Assert", e.assertPsbtBase64);
239
+ ), n = be("Assert", e.assertPsbtBase64);
240
240
  if (!s.data.globalMap.unsignedTx.toBuffer().equals(o.data.globalMap.unsignedTx.toBuffer()))
241
241
  throw new Error(
242
242
  "Depositor and claimer Payout PSBTs describe different transactions; refusing to sign payout."
@@ -260,12 +260,12 @@ async function ao(e) {
260
260
  throw new Error(
261
261
  `Payout input ${A} sequence ${u} must equal the Assert CSV timelock ${t.timelockAssert}; refusing to sign payout.`
262
262
  );
263
- Je(
263
+ Qe(
264
264
  "Claimer",
265
265
  o,
266
266
  t.peginVaultOutputValueSats,
267
267
  a
268
- ), Je(
268
+ ), Qe(
269
269
  "Depositor",
270
270
  s,
271
271
  t.peginVaultOutputValueSats,
@@ -282,66 +282,66 @@ async function ao(e) {
282
282
  throw new Error(
283
283
  `Payout outputs (${h} sats) exceed inputs (${l} sats); invalid transaction.`
284
284
  );
285
- await Ir(r, {
285
+ await Vr(r, {
286
286
  implicitFeeSats: l - h,
287
287
  out0Len: c[Ve].script.length,
288
288
  out1Len: void 0
289
289
  });
290
290
  }
291
- class uo extends Error {
291
+ class co extends Error {
292
292
  constructor(t, r) {
293
293
  super(
294
294
  "Transaction graph's challenger set does not match the vault's (local ∪ universal)" + (t.length > 0 ? ` (missing: ${t.join(", ")})` : "") + (r.length > 0 ? ` (unexpected: ${r.join(", ")})` : "") + ". Refusing to sign an incomplete or padded challenger set."
295
295
  ), this.missing = t, this.unexpected = r, this.name = "ChallengerSetMismatchError";
296
296
  }
297
297
  }
298
- function co(e) {
298
+ function lo(e) {
299
299
  const t = wt({
300
300
  claimerBtcPubkey: e.depositorBtcPubkey,
301
301
  depositorBtcPubkey: e.depositorBtcPubkey,
302
302
  vaultProviderBtcPubkey: e.vaultProviderBtcPubkey,
303
303
  vaultKeeperBtcPubkeys: e.vaultKeeperBtcPubkeys
304
- }), r = e.universalChallengerBtcPubkeys.map(Qe), o = t.filter((c) => r.includes(c));
304
+ }), r = e.universalChallengerBtcPubkeys.map(Je), o = t.filter((c) => r.includes(c));
305
305
  if (o.length > 0)
306
306
  throw new Error(
307
307
  `Cannot check the challenger set: vault keepers and universal challengers overlap (${o.join(", ")}).`
308
308
  );
309
- const s = e.graphChallengerPubkeys.map(Qe), n = new Set(s);
309
+ const s = e.graphChallengerPubkeys.map(Je), n = new Set(s);
310
310
  if (n.size !== s.length)
311
311
  throw new Error(
312
312
  "Transaction graph lists the same challenger more than once."
313
313
  );
314
314
  const a = [...t, ...r], i = new Set(a), u = a.filter((c) => !n.has(c)), l = s.filter((c) => !i.has(c));
315
315
  if (u.length > 0 || l.length > 0)
316
- throw new uo(u, l);
316
+ throw new co(u, l);
317
317
  }
318
- function Qe(e) {
319
- return b(e).toLowerCase();
318
+ function Je(e) {
319
+ return P(e).toLowerCase();
320
320
  }
321
- class lo extends Error {
321
+ class ho extends Error {
322
322
  constructor(t, r) {
323
323
  super(
324
324
  `Payout transaction output ${Ve} pays ${r}, not the vault's registered payout script ${t}. Refusing to sign a payout to another destination.`
325
325
  ), this.expectedScriptHex = t, this.actualScriptHex = r, this.name = "PayoutDestinationError";
326
326
  }
327
327
  }
328
- function ho(e) {
328
+ function po(e) {
329
329
  let t;
330
330
  try {
331
331
  t = q.fromBase64(e.payoutPsbtBase64);
332
332
  } catch (c) {
333
333
  throw new Error("Payout PSBT cannot be parsed.", { cause: c });
334
334
  }
335
- const { version: r, locktime: o, outs: s } = po(t);
336
- if (r !== Ue || o !== Fe)
335
+ const { version: r, locktime: o, outs: s } = go(t);
336
+ if (r !== Fe || o !== Ue)
337
337
  throw new Error(
338
- `Payout transaction has version ${r} and locktime ${o}, expected ${Ue} and ${Fe}.`
338
+ `Payout transaction has version ${r} and locktime ${o}, expected ${Fe} and ${Ue}.`
339
339
  );
340
340
  if (s.length !== ee)
341
341
  throw new Error(
342
342
  `Payout transaction has ${s.length} output(s), expected exactly ${ee} for a depositor-as-claimer payout.`
343
343
  );
344
- const n = b(
344
+ const n = P(
345
345
  e.registeredPayoutScriptPubKey
346
346
  ).toLowerCase();
347
347
  if (n.length === 0)
@@ -350,21 +350,21 @@ function ho(e) {
350
350
  );
351
351
  const a = s[Ve].script.toString("hex").toLowerCase();
352
352
  if (a !== n)
353
- throw new lo(n, a);
353
+ throw new ho(n, a);
354
354
  const i = s[ee - 1];
355
355
  if (i.value !== qe)
356
356
  throw new Error(
357
357
  `Payout CPFP anchor value ${i.value} sats must equal ${qe} sats.`
358
358
  );
359
- const u = b(
360
- Pr(b(e.depositorBtcPubkey).toLowerCase())
359
+ const u = P(
360
+ wr(P(e.depositorBtcPubkey).toLowerCase())
361
361
  ), l = i.script.toString("hex").toLowerCase();
362
362
  if (l !== u)
363
363
  throw new Error(
364
364
  `Payout CPFP anchor pays ${l}, not the depositor's BIP-86 P2TR ${u}. Refusing to sign a payout whose fee-bump output is spendable by somebody else.`
365
365
  );
366
366
  }
367
- function po(e) {
367
+ function go(e) {
368
368
  return {
369
369
  version: e.version,
370
370
  locktime: e.locktime,
@@ -379,7 +379,7 @@ class ne extends Error {
379
379
  super(t), this.name = "PayoutInputLeafError";
380
380
  }
381
381
  }
382
- function go(e) {
382
+ function fo(e) {
383
383
  const t = q.fromBase64(e.payoutDepositorPsbtBase64), r = q.fromBase64(e.payoutClaimerPsbtBase64), o = t.data.globalMap.unsignedTx.toBuffer(), s = r.data.globalMap.unsignedTx.toBuffer();
384
384
  if (!o.equals(s))
385
385
  throw new ne(
@@ -404,14 +404,14 @@ function go(e) {
404
404
  ...n.tapMerkleRoot ? { tapMerkleRoot: n.tapMerkleRoot } : {}
405
405
  }), t.toBase64();
406
406
  }
407
- class fo extends Error {
407
+ class yo extends Error {
408
408
  constructor(t, r, o) {
409
409
  super(
410
410
  `Transaction graph does not belong to vault ${t}: its Claim spends PegIn ${o}, which derives vault ${r}. Refusing to sign for a graph served for another vault.`
411
411
  ), this.expectedVaultId = t, this.derivedVaultId = r, this.peginTxid = o, this.name = "VaultIdBindingError";
412
412
  }
413
413
  }
414
- function yo(e) {
414
+ function vo(e) {
415
415
  let t;
416
416
  try {
417
417
  t = q.fromBase64(e);
@@ -427,7 +427,7 @@ function yo(e) {
427
427
  r.index
428
428
  ), Ke(r.hash);
429
429
  }
430
- function vo(e) {
430
+ function Po(e) {
431
431
  const t = e.ins[ge];
432
432
  if (!t)
433
433
  throw new Error(
@@ -447,10 +447,10 @@ function _t(e, t, r) {
447
447
  }
448
448
  function St(e) {
449
449
  const t = z(
450
- Pt(e.peginTxid, e.depositorEthAddress)
450
+ mt(e.peginTxid, e.depositorEthAddress)
451
451
  ), r = z(e.expectedVaultId);
452
452
  if (t !== r)
453
- throw new fo(r, t, e.peginTxid);
453
+ throw new yo(r, t, e.peginTxid);
454
454
  }
455
455
  function z(e) {
456
456
  return `0x${(e.startsWith("0x") ? e.slice(2) : e).toLowerCase()}`;
@@ -459,7 +459,7 @@ function Ke(e) {
459
459
  return H.from(e).reverse().toString("hex");
460
460
  }
461
461
  function le(e, t) {
462
- const r = b(e);
462
+ const r = P(e);
463
463
  if (!/^(?:[0-9a-fA-F]{2})+$/.test(r))
464
464
  throw new Error(`${t} must be non-empty, even-length hex.`);
465
465
  return r.toLowerCase();
@@ -477,7 +477,7 @@ function At(e) {
477
477
  `Vault provider served Groth16 verifying key ${t} but the trusted key for prover circuit version ${e.proverCircuitVersion} is ${r}; refusing to sign a claim whose proof would verify under a substituted key.`
478
478
  );
479
479
  }
480
- const F = 1;
480
+ const U = 1;
481
481
  class bo extends Error {
482
482
  constructor(t, r) {
483
483
  super(
@@ -486,8 +486,8 @@ class bo extends Error {
486
486
  }
487
487
  }
488
488
  const mo = /^(?:[0-9a-fA-F]{2})+$/;
489
- function Po(e) {
490
- const t = Eo(e, "babe_sessions"), r = Object.keys(t);
489
+ function wo(e) {
490
+ const t = ko(e, "babe_sessions"), r = Object.keys(t);
491
491
  if (r.length === 0)
492
492
  return { joined: !1 };
493
493
  for (const [o, s] of Object.entries(t)) {
@@ -499,14 +499,14 @@ function Po(e) {
499
499
  }
500
500
  return { joined: !0, challengerPubkeys: r };
501
501
  }
502
- function wo(e) {
502
+ function xo(e) {
503
503
  let t;
504
504
  try {
505
505
  t = JSON.parse(e);
506
506
  } catch (a) {
507
507
  throw new Error("Artifacts file is not valid JSON.", { cause: a });
508
508
  }
509
- const r = Pe(t.vault_id, "vault_id"), o = xo(Pe(t.claim_tx, "claim_tx")), s = we(
509
+ const r = me(t.vault_id, "vault_id"), o = Eo(me(t.claim_tx, "claim_tx")), s = we(
510
510
  t.prover_circuit_version,
511
511
  "prover_circuit_version"
512
512
  ), n = BigInt(
@@ -522,18 +522,18 @@ function wo(e) {
522
522
  ),
523
523
  vaultId: r,
524
524
  claimTxid: o.getId(),
525
- peginTxid: vo(o),
525
+ peginTxid: Po(o),
526
526
  proverCircuitVersion: s,
527
527
  claimableEventBlockNumber: n,
528
528
  // Required: btc-vault's builder always writes it
529
529
  // (`delegated_claim.rs:874` @ b534ff9e), so an absent one is not a file
530
530
  // this SDK or the CLI produced.
531
- verifyingKeyHex: Pe(t.verifying_key, "verifying_key"),
532
- babeSessions: Po(t.babe_sessions)
531
+ verifyingKeyHex: me(t.verifying_key, "verifying_key"),
532
+ babeSessions: wo(t.babe_sessions)
533
533
  };
534
534
  }
535
535
  async function cn(e) {
536
- const t = wo(e.artifactsJson), r = z(e.expectedVaultId), o = z(t.vaultId);
536
+ const t = xo(e.artifactsJson), r = z(e.expectedVaultId), o = z(t.vaultId);
537
537
  if (r !== o)
538
538
  throw new bo(r, o);
539
539
  St({
@@ -541,7 +541,7 @@ async function cn(e) {
541
541
  depositorEthAddress: e.depositorEthAddress,
542
542
  expectedVaultId: r
543
543
  });
544
- const s = e.txGraphVersion ?? F;
544
+ const s = e.txGraphVersion ?? U;
545
545
  if (t.vaultCoreVersion !== s)
546
546
  throw new Error(
547
547
  `Artifacts record vault core version ${t.vaultCoreVersion}, but verification was asked for version ${s}.`
@@ -569,9 +569,9 @@ async function cn(e) {
569
569
  throw new Error(
570
570
  `Artifacts carry Groth16 verifying key ${n} but the trusted key for prover circuit version ${e.expectedProverCircuitVersion} is ${a}; refusing a file whose proof would verify under a substituted key.`
571
571
  );
572
- return await ar(s, e.artifactsJson), t;
572
+ return await ur(s, e.artifactsJson), t;
573
573
  }
574
- function xo(e) {
574
+ function Eo(e) {
575
575
  try {
576
576
  return S.fromHex(e);
577
577
  } catch (t) {
@@ -580,7 +580,7 @@ function xo(e) {
580
580
  });
581
581
  }
582
582
  }
583
- function Pe(e, t) {
583
+ function me(e, t) {
584
584
  if (typeof e != "string" || e.length === 0)
585
585
  throw new Error(`Artifacts file is missing a usable "${t}".`);
586
586
  return e;
@@ -590,7 +590,7 @@ function we(e, t) {
590
590
  throw new Error(`Artifacts file is missing a usable "${t}".`);
591
591
  return e;
592
592
  }
593
- function Eo(e, t) {
593
+ function ko(e, t) {
594
594
  if (typeof e != "object" || e === null || Array.isArray(e))
595
595
  throw new Error(`Artifacts file is missing a usable "${t}".`);
596
596
  return e;
@@ -610,7 +610,7 @@ function It(e) {
610
610
  id: "assert",
611
611
  kind: "assert",
612
612
  psbtBase64: e.assert,
613
- inputIndex: U
613
+ inputIndex: F
614
614
  },
615
615
  {
616
616
  id: "payoutClaimer",
@@ -631,16 +631,16 @@ function It(e) {
631
631
  id: Bt(r, s),
632
632
  kind: "wronglyChallenged",
633
633
  psbtBase64: o,
634
- inputIndex: Tr
634
+ inputIndex: _r
635
635
  });
636
636
  });
637
637
  return t;
638
638
  }
639
- const ko = "{}", $o = xt - Et;
639
+ const $o = "{}", Co = xt - Et;
640
640
  function V(e) {
641
641
  const t = e.replace(/^0x/, "").toLowerCase();
642
642
  if (t.length === xt)
643
- return t.slice($o);
643
+ return t.slice(Co);
644
644
  if (t.length === Et) return t;
645
645
  throw new Error(
646
646
  `Public key must be 33-byte compressed or 32-byte x-only hex, got ${t.length / 2} bytes.`
@@ -653,7 +653,7 @@ async function Ze(e, t, r) {
653
653
  "Connected wallet does not hold the vault's depositor key. Select the account that made the deposit, then try again."
654
654
  );
655
655
  const s = await e.getAddress();
656
- if (!tr(s, o, r))
656
+ if (!rr(s, o, r))
657
657
  throw new Error(
658
658
  `Connected wallet reports address "${s}", which is not derived from the vault's depositor key. Select the account that made the deposit, then try again.`
659
659
  );
@@ -666,7 +666,7 @@ async function Vt(e, t, r, o) {
666
666
  `Depositor key ${s} is not the vault's registered depositor key ${r.depositorBtcPubkey}; refusing to plan a claim for another key.`
667
667
  );
668
668
  try {
669
- wr(
669
+ xr(
670
670
  Ie(r.registeredPayoutScriptPubKey),
671
671
  r.depositorBtcPubkey,
672
672
  o
@@ -677,46 +677,46 @@ async function Vt(e, t, r, o) {
677
677
  { cause: h }
678
678
  );
679
679
  }
680
- if (e !== F)
680
+ if (e !== U)
681
681
  throw new Error(
682
- `Graph version ${e} is not the delegated-claim graph version ${F}; vaults on other graphs have no delegated-claim path.`
682
+ `Graph version ${e} is not the delegated-claim graph version ${U}; vaults on other graphs have no delegated-claim path.`
683
683
  );
684
684
  if (e !== r.vaultCoreVersion)
685
685
  throw new Error(
686
686
  `Graph version ${e} does not match the vault context's vault core version ${r.vaultCoreVersion}; they are one axis and must agree.`
687
687
  );
688
688
  const [n, a, i, u, l] = await Promise.all([
689
- ur(e, t),
690
689
  cr(e, t),
691
690
  lr(e, t),
692
691
  dr(e, t),
693
- hr(e, t)
692
+ hr(e, t),
693
+ pr(e, t)
694
694
  ]);
695
695
  St({
696
- peginTxid: yo(n),
696
+ peginTxid: vo(n),
697
697
  depositorEthAddress: r.depositorEthAddress,
698
698
  expectedVaultId: r.vaultId
699
- }), io({
699
+ }), ao({
700
700
  claimPsbtBase64: n,
701
701
  assertPsbtBase64: a,
702
702
  payoutClaimerPsbtBase64: i
703
703
  });
704
704
  for (const h of [i, l])
705
- ho({
705
+ po({
706
706
  payoutPsbtBase64: h,
707
707
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
708
708
  depositorBtcPubkey: r.depositorBtcPubkey
709
709
  });
710
- const c = go({
710
+ const c = fo({
711
711
  payoutDepositorPsbtBase64: l,
712
712
  payoutClaimerPsbtBase64: i
713
713
  });
714
- return await ao({
714
+ return await uo({
715
715
  payoutClaimerPsbtBase64: i,
716
716
  payoutDepositorPsbtBase64: c,
717
717
  assertPsbtBase64: a,
718
718
  vault: r
719
- }), co({
719
+ }), lo({
720
720
  graphChallengerPubkeys: Object.keys(u),
721
721
  depositorBtcPubkey: o,
722
722
  vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
@@ -724,7 +724,7 @@ async function Vt(e, t, r, o) {
724
724
  universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys
725
725
  }), { claim: n, assert: a, payoutClaimer: i, payoutDepositor: c, wronglyChallenged: u };
726
726
  }
727
- async function Co(e) {
727
+ async function To(e) {
728
728
  At({
729
729
  servedVerifyingKeyHex: e.source.verifyingKeyHex,
730
730
  trustedVerifyingKeyHex: e.trustedVerifyingKeyHex,
@@ -743,7 +743,7 @@ async function Co(e) {
743
743
  source: e.source,
744
744
  vault: e.vault,
745
745
  // Omitted means unjoined: the browser cannot hold the real sessions.
746
- babeSessionsJson: e.babeSessionsJson === void 0 ? ko : e.babeSessionsJson,
746
+ babeSessionsJson: e.babeSessionsJson === void 0 ? $o : e.babeSessionsJson,
747
747
  requests: It(t)
748
748
  };
749
749
  }
@@ -766,7 +766,7 @@ class Y extends Error {
766
766
  super(t), this.name = "SigningPlanMismatchError";
767
767
  }
768
768
  }
769
- function To(e, t) {
769
+ function _o(e, t) {
770
770
  if (e.length !== t.length)
771
771
  throw new Y(
772
772
  `Plan has ${e.length} requests but the graph builds ${t.length}; the plan was altered after planning.`
@@ -791,7 +791,7 @@ function To(e, t) {
791
791
  );
792
792
  }
793
793
  }
794
- function _o(e, t) {
794
+ function So(e, t) {
795
795
  const r = new Set(e.map((a) => a.id)), o = [...r].filter((a) => !t.has(a)), s = [...t.keys()].filter((a) => !r.has(a));
796
796
  if (o.length === 0 && s.length === 0) return;
797
797
  const n = (a) => a.map((i) => `"${i}"`).join(", ");
@@ -807,7 +807,7 @@ function L(e, t) {
807
807
  );
808
808
  return r;
809
809
  }
810
- async function So(e) {
810
+ async function Ao(e) {
811
811
  const { plan: t, signatures: r } = e, { txGraphVersion: o } = t.vault, s = t.source.txGraphJson, n = At({
812
812
  servedVerifyingKeyHex: t.source.verifyingKeyHex,
813
813
  trustedVerifyingKeyHex: t.trustedVerifyingKeyHex,
@@ -818,7 +818,7 @@ async function So(e) {
818
818
  t.vault,
819
819
  t.depositorPublicKey
820
820
  ), i = It(a);
821
- To(t.requests, i), _o(i, r);
821
+ _o(t.requests, i), So(i, r);
822
822
  for (const c of i)
823
823
  fe(
824
824
  t,
@@ -833,12 +833,12 @@ async function So(e) {
833
833
  Bt(c, d)
834
834
  )
835
835
  );
836
- const l = await pr(
836
+ const l = await gr(
837
837
  o,
838
838
  s,
839
839
  L(r, "claim")
840
840
  );
841
- return gr({
841
+ return fr({
842
842
  txGraphVersion: o,
843
843
  graphJson: s,
844
844
  signedClaimTxHex: l,
@@ -854,10 +854,10 @@ async function So(e) {
854
854
  expectedVaultCoreVersion: t.vault.vaultCoreVersion
855
855
  });
856
856
  }
857
- function Ao(e) {
857
+ function Bo(e) {
858
858
  return typeof e.signDelegatedClaimPsbt == "function";
859
859
  }
860
- class Bo extends Error {
860
+ class Io extends Error {
861
861
  constructor(t, r, o, s) {
862
862
  super(t, s), this.signatures = r, this.failedRequestId = o, this.name = "DelegatedClaimSigningIncompleteError";
863
863
  }
@@ -868,30 +868,30 @@ const Kt = {
868
868
  payoutClaimer: "standalone",
869
869
  claim: "standalone",
870
870
  wronglyChallenged: "standalone"
871
- }, Io = [
871
+ }, Vo = [
872
872
  "payoutClaimer",
873
873
  "claim",
874
874
  "wronglyChallenged"
875
875
  ];
876
- async function Vo(e, t, r = {}) {
876
+ async function Ro(e, t, r = {}) {
877
877
  var s;
878
- if ((s = r.signal) == null || s.throwIfAborted(), Ro(e), V(e.depositorPublicKey) !== e.vault.depositorBtcPubkey)
878
+ if ((s = r.signal) == null || s.throwIfAborted(), Ko(e), V(e.depositorPublicKey) !== e.vault.depositorBtcPubkey)
879
879
  throw new Error(
880
880
  `Plan depositor key ${V(e.depositorPublicKey)} is not the vault's registered depositor key ${e.vault.depositorBtcPubkey}; the plan was not built for this vault.`
881
881
  );
882
882
  if (vt(t)) {
883
- if (!Ao(t))
883
+ if (!Bo(t))
884
884
  throw new Error(
885
885
  "Approval wallet does not implement signDelegatedClaimPsbt; the claim ceremony needs it because the device signs some claim PSBTs with no loaded intent and needs its own derivation fields on them."
886
886
  );
887
- const n = Ho(r, e);
888
- Oo(n.depositTerms, e.vault);
889
- const a = Ko(e), i = await Ze(
887
+ const n = Oo(r, e);
888
+ No(n.depositTerms, e.vault);
889
+ const a = Ho(e), i = await Ze(
890
890
  t,
891
891
  e.depositorPublicKey,
892
892
  e.btcNetwork
893
893
  );
894
- return No(
894
+ return Do(
895
895
  e,
896
896
  t,
897
897
  i,
@@ -905,9 +905,9 @@ async function Vo(e, t, r = {}) {
905
905
  e.depositorPublicKey,
906
906
  e.btcNetwork
907
907
  );
908
- return Lo(e, t, o, r.signal);
908
+ return Mo(e, t, o, r.signal);
909
909
  }
910
- function Ro(e) {
910
+ function Ko(e) {
911
911
  const t = /* @__PURE__ */ new Set();
912
912
  for (const r of e.requests) {
913
913
  if (t.has(r.id))
@@ -917,10 +917,10 @@ function Ro(e) {
917
917
  t.add(r.id);
918
918
  }
919
919
  }
920
- function Ko(e) {
920
+ function Ho(e) {
921
921
  const t = e.requests.filter(
922
922
  (s) => Kt[s.kind] === "intentBound"
923
- ), r = Io.flatMap(
923
+ ), r = Vo.flatMap(
924
924
  (s) => e.requests.filter((n) => n.kind === s)
925
925
  ), o = t.length + r.length;
926
926
  if (o !== e.requests.length)
@@ -935,7 +935,7 @@ function Ht(e, t) {
935
935
  `Delegated-claim signing ended with ${t.size} signatures for ${e.requests.length} requests; the set is incomplete and must not be treated as signed.`
936
936
  );
937
937
  }
938
- function Ho(e, t) {
938
+ function Oo(e, t) {
939
939
  if (e.depositTerms === void 0)
940
940
  throw new Error(
941
941
  "An approval wallet signs Assert and the depositor Payout only under this vault's loaded intent; pass depositTerms (rebuilt from on-chain state) so it can be approved."
@@ -951,7 +951,7 @@ function Ho(e, t) {
951
951
  );
952
952
  return { depositTerms: e.depositTerms, vaultContext: e.vaultContext };
953
953
  }
954
- function Oo(e, t) {
954
+ function No(e, t) {
955
955
  const r = (s) => s.map((n) => V(n)).sort().join(",");
956
956
  if (r(e.vaultKeeperBtcPubkeys) !== r(t.vaultKeeperBtcPubkeys) || r(e.universalChallengerBtcPubkeys) !== r(t.universalChallengerBtcPubkeys))
957
957
  throw new Error(
@@ -984,15 +984,15 @@ function Oo(e, t) {
984
984
  `Deposit terms group at htlcVout ${s.htlcVout} names a different vault provider than the vault context this claim signs for; the device would bind the Assert to the wrong intent.`
985
985
  );
986
986
  }
987
- async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
987
+ async function Do(e, t, r, o, { intentBound: s, standalone: n }, a) {
988
988
  var g;
989
- const i = Do(e, a.resume), u = [...s, ...n];
989
+ const i = Lo(e, a.resume), u = [...s, ...n];
990
990
  let l = 0;
991
991
  const c = {
992
992
  phase: "clearing any loaded intent"
993
993
  }, h = async (p) => {
994
- var m;
995
- c.phase = "signing", (m = a.signal) == null || m.throwIfAborted();
994
+ var b;
995
+ c.phase = "signing", (b = a.signal) == null || b.throwIfAborted();
996
996
  const y = await t.signDelegatedClaimPsbt(
997
997
  He(p.psbtBase64),
998
998
  kt(
@@ -1000,7 +1000,7 @@ async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
1000
1000
  p.inputIndex,
1001
1001
  r
1002
1002
  )
1003
- ), f = await mt(
1003
+ ), f = await bt(
1004
1004
  Rt(y),
1005
1005
  p.inputIndex
1006
1006
  );
@@ -1021,7 +1021,7 @@ async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
1021
1021
  const y = u[l];
1022
1022
  if (i.size === 0 || y === void 0) throw p;
1023
1023
  const f = c.phase === "signing" ? `stopped at "${y.id}"` : `stopped before "${y.id}" while ${c.phase}`;
1024
- throw new Bo(
1024
+ throw new Io(
1025
1025
  `Delegated-claim signing ${f}; ${i.size} of ${e.requests.length} signatures were collected.`,
1026
1026
  i,
1027
1027
  y.id,
@@ -1030,7 +1030,7 @@ async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
1030
1030
  }
1031
1031
  return Ht(e, i), i;
1032
1032
  }
1033
- function Do(e, t) {
1033
+ function Lo(e, t) {
1034
1034
  const r = /* @__PURE__ */ new Map();
1035
1035
  if (!t) return r;
1036
1036
  for (const o of e.requests) {
@@ -1046,8 +1046,8 @@ function Do(e, t) {
1046
1046
  }
1047
1047
  return r;
1048
1048
  }
1049
- async function Lo(e, t, r, o) {
1050
- const s = e.requests, n = await bt(
1049
+ async function Mo(e, t, r, o) {
1050
+ const s = e.requests, n = await Pt(
1051
1051
  t,
1052
1052
  s.map((i) => He(i.psbtBase64)),
1053
1053
  s.map(
@@ -1060,7 +1060,7 @@ async function Lo(e, t, r, o) {
1060
1060
  o
1061
1061
  ), a = /* @__PURE__ */ new Map();
1062
1062
  for (let i = 0; i < s.length; i++) {
1063
- const u = await mt(
1063
+ const u = await bt(
1064
1064
  Rt(n[i]),
1065
1065
  s[i].inputIndex
1066
1066
  );
@@ -1069,34 +1069,34 @@ async function Lo(e, t, r, o) {
1069
1069
  return Ht(e, a), a;
1070
1070
  }
1071
1071
  async function ln(e) {
1072
- const t = await Co({
1072
+ const t = await To({
1073
1073
  depositorPublicKey: e.depositorPublicKey,
1074
1074
  btcNetwork: e.btcNetwork,
1075
1075
  source: e.source,
1076
1076
  trustedVerifyingKeyHex: e.trustedVerifyingKeyHex,
1077
1077
  vault: e.vault,
1078
1078
  babeSessionsJson: e.babeSessionsJson
1079
- }), r = await Vo(t, e.btcWallet, {
1079
+ }), r = await Ro(t, e.btcWallet, {
1080
1080
  depositTerms: e.depositTerms,
1081
1081
  vaultContext: e.vaultContext
1082
1082
  });
1083
- return So({ plan: t, signatures: r });
1083
+ return Ao({ plan: t, signatures: r });
1084
1084
  }
1085
1085
  async function dn(e) {
1086
1086
  const t = await $t(e.btcWallet, e.vaultContext);
1087
1087
  let r;
1088
1088
  try {
1089
- r = await fr(t, e.htlcVout);
1089
+ r = await yr(t, e.htlcVout);
1090
1090
  } finally {
1091
1091
  t.fill(0);
1092
1092
  }
1093
1093
  let o;
1094
1094
  try {
1095
- o = await yr(r);
1095
+ o = await vr(r);
1096
1096
  } finally {
1097
1097
  r.fill(0);
1098
1098
  }
1099
- return Mo(o.pk_hash, e.expectedWotsPkHash), await vr(
1099
+ return Fo(o.pk_hash, e.expectedWotsPkHash), await Pr(
1100
1100
  e.txGraphVersion,
1101
1101
  o.keypair,
1102
1102
  e.txGraphJson
@@ -1105,7 +1105,7 @@ async function dn(e) {
1105
1105
  pkHash: o.pk_hash
1106
1106
  };
1107
1107
  }
1108
- function Mo(e, t) {
1108
+ function Fo(e, t) {
1109
1109
  if (ie(e) !== ie(t))
1110
1110
  throw new Error(
1111
1111
  `Derived WOTS public-key hash ${ie(e)} does not match the vault's on-chain depositorWotsPkHash ${ie(t)}. The wallet, the HTLC output index, or the derivation itself is not the one this vault was created with.`
@@ -1169,7 +1169,7 @@ function Ot(e, t, r) {
1169
1169
  query: e
1170
1170
  };
1171
1171
  }
1172
- async function Fo(e) {
1172
+ async function qo(e) {
1173
1173
  const t = await e.operationKeyReader.getCurrentOperationKeys(
1174
1174
  e.query,
1175
1175
  e.blockNumber
@@ -1186,7 +1186,7 @@ async function Nt(e) {
1186
1186
  epochs: e.epochs
1187
1187
  });
1188
1188
  }
1189
- async function qo(e) {
1189
+ async function Dt(e) {
1190
1190
  const { basic: t, protocol: r } = e.vault, {
1191
1191
  registryReader: o,
1192
1192
  vaultKeeperReader: s,
@@ -1230,9 +1230,9 @@ async function qo(e) {
1230
1230
  }
1231
1231
  async function hn(e) {
1232
1232
  const { vaultId: t, readers: r } = e, o = await r.registryReader.getVaultData(t), { basic: s, protocol: n } = o;
1233
- if (n.vaultCoreVersion !== F)
1233
+ if (n.vaultCoreVersion !== U)
1234
1234
  throw new Error(
1235
- `Vault ${t} is stamped vault core version ${n.vaultCoreVersion}; delegated claim requires ${F}.`
1235
+ `Vault ${t} is stamped vault core version ${n.vaultCoreVersion}; delegated claim requires ${U}.`
1236
1236
  );
1237
1237
  const a = _e(
1238
1238
  s.depositorBtcPubKey,
@@ -1247,10 +1247,10 @@ async function hn(e) {
1247
1247
  `the vault's status is ${s.status}, not Redeemed (${ze.REDEEMED}); no scan was made`
1248
1248
  );
1249
1249
  const [i, u, l, c] = await Promise.all([
1250
- qo({ vaultId: t, vault: o, readers: r }),
1250
+ Dt({ vaultId: t, vault: o, readers: r }),
1251
1251
  r.registryReader.getRegistrationRecordsAtBlock(s.createdAt),
1252
1252
  r.registryReader.getVaultClaimableBy(t, s.depositorBtcPubKey, s.createdAt).catch((v) => {
1253
- throw xr(v) ? new Le(
1253
+ throw Er(v) ? new Le(
1254
1254
  t,
1255
1255
  s.depositorBtcPubKey,
1256
1256
  v.fromBlock,
@@ -1262,9 +1262,9 @@ async function hn(e) {
1262
1262
  r.protocolParamsReader.getOffchainParamsByVersion(
1263
1263
  n.offchainParamsVersion
1264
1264
  )
1265
- ]), h = Rr(c.timelockAssert), d = Er(u, t, s.createdAt);
1266
- kr(d);
1267
- const g = $r(d);
1265
+ ]), h = Kr(c.timelockAssert), d = kr(u, t, s.createdAt);
1266
+ $r(d);
1267
+ const g = Cr(d);
1268
1268
  if (g.toLowerCase() !== n.prePeginTxHash.toLowerCase())
1269
1269
  throw new Error(
1270
1270
  `Registration log of vault ${t} records prePeginTxHash ${g} but the vault record says ${n.prePeginTxHash}; refusing an inconsistent node.`
@@ -1297,7 +1297,7 @@ async function hn(e) {
1297
1297
  throw new Error(
1298
1298
  `Registration log of vault ${t} records proverCircuitVersion ${d.proverCircuitVersion} but the stamped offchain params say ${c.proverCircuitVersion}; refusing an inconsistent node.`
1299
1299
  );
1300
- const p = Cr(n.depositorSignedPeginTx);
1300
+ const p = Tr(n.depositorSignedPeginTx);
1301
1301
  for (const [v, E] of [
1302
1302
  ["Registration", d.peginTxHash],
1303
1303
  ["Redemption", l.peginTxHash]
@@ -1307,7 +1307,7 @@ async function hn(e) {
1307
1307
  `${v} log of vault ${t} records peginTxHash ${E} but the vault's depositor-signed PegIn hashes to ${p}; refusing an inconsistent node.`
1308
1308
  );
1309
1309
  const y = z(
1310
- Pt(p, s.depositor)
1310
+ mt(p, s.depositor)
1311
1311
  );
1312
1312
  if (y !== z(t))
1313
1313
  throw new Error(
@@ -1328,16 +1328,16 @@ async function hn(e) {
1328
1328
  );
1329
1329
  }
1330
1330
  const f = S.fromHex(
1331
- b(n.depositorSignedPeginTx)
1331
+ P(n.depositorSignedPeginTx)
1332
1332
  );
1333
1333
  if (f.ins.length !== 1)
1334
1334
  throw new Error(
1335
1335
  `Depositor-signed PegIn of vault ${t} has ${f.ins.length} inputs; it spends Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout} with exactly one; refusing an inconsistent node.`
1336
1336
  );
1337
- const m = Ke(f.ins[0].hash), $ = f.ins[0].index;
1338
- if (m !== b(n.prePeginTxHash).toLowerCase() || $ !== n.htlcVout)
1337
+ const b = Ke(f.ins[0].hash), $ = f.ins[0].index;
1338
+ if (b !== P(n.prePeginTxHash).toLowerCase() || $ !== n.htlcVout)
1339
1339
  throw new Error(
1340
- `Depositor-signed PegIn of vault ${t} spends ${m}:${$} but the vault record says Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout}; refusing an inconsistent node.`
1340
+ `Depositor-signed PegIn of vault ${t} spends ${b}:${$} but the vault record says Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout}; refusing an inconsistent node.`
1341
1341
  );
1342
1342
  const x = f.outs[Z];
1343
1343
  if (x === void 0)
@@ -1353,7 +1353,7 @@ async function hn(e) {
1353
1353
  vaultId: t,
1354
1354
  depositorEthAddress: s.depositor,
1355
1355
  depositorBtcPubkey: a,
1356
- registeredPayoutScriptPubKey: b(
1356
+ registeredPayoutScriptPubKey: P(
1357
1357
  d.depositorPayoutScriptPubKey
1358
1358
  ),
1359
1359
  vaultProviderBtcPubkey: i.vaultProvider.operationBtcPubkey,
@@ -1363,7 +1363,7 @@ async function hn(e) {
1363
1363
  universalChallengerBtcPubkeys: [
1364
1364
  ...i.universalChallengerOperationKeysSorted
1365
1365
  ],
1366
- txGraphVersion: F,
1366
+ txGraphVersion: U,
1367
1367
  proverCircuitVersion: c.proverCircuitVersion,
1368
1368
  vaultCoreVersion: n.vaultCoreVersion,
1369
1369
  claimableEventBlockNumber: l.blockNumber,
@@ -1387,21 +1387,21 @@ async function hn(e) {
1387
1387
  };
1388
1388
  }
1389
1389
  const Go = 8, Xo = 6e3, zo = 10 * 6e4, jo = 10;
1390
- class Dt extends Error {
1390
+ class Lt extends Error {
1391
1391
  constructor(t) {
1392
1392
  super(t), this.name = "PeginRegistrationMissingError";
1393
1393
  }
1394
1394
  }
1395
- class Lt extends Error {
1395
+ class Mt extends Error {
1396
1396
  constructor(t) {
1397
1397
  super(t), this.name = "PeginRegistrationNotFinalError";
1398
1398
  }
1399
1399
  }
1400
1400
  function Wo(e) {
1401
- return e instanceof Dt || e instanceof Error && e.name === "PeginRegistrationMissingError";
1401
+ return e instanceof Lt || e instanceof Error && e.name === "PeginRegistrationMissingError";
1402
1402
  }
1403
1403
  function pn(e) {
1404
- return e instanceof Lt || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
1404
+ return e instanceof Mt || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
1405
1405
  }
1406
1406
  function et(e) {
1407
1407
  const { currentBlock: t, createdAtBlock: r } = e, o = t - r + 1n;
@@ -1430,18 +1430,18 @@ async function gn(e) {
1430
1430
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
1431
1431
  );
1432
1432
  if (Date.now() - l >= a)
1433
- throw new Lt(
1433
+ throw new Mt(
1434
1434
  `Peg-in registration did not reach ${s} Ethereum confirmations within ${a}ms. The registration transaction was submitted but is not yet final, so the Pre-PegIn Bitcoin transaction was never sent and no funds are at risk. Resume this deposit from the dashboard once the network settles.` + (d instanceof Error ? ` Last read error: ${d.message}` : "")
1435
1435
  );
1436
1436
  try {
1437
1437
  const g = await r(), p = await Promise.all(
1438
1438
  o.map((f) => t.getVaultBasicInfo(f))
1439
1439
  ), y = p.findIndex(
1440
- (f) => f.depositor === Kr || f.createdAt === 0n
1440
+ (f) => f.depositor === Hr || f.createdAt === 0n
1441
1441
  );
1442
1442
  if (y !== -1) {
1443
1443
  if (h += 1, !c && h > jo)
1444
- throw new Dt(
1444
+ throw new Lt(
1445
1445
  `Vault ${o[y]} is still not visible on-chain after ${h} reads — the registration does not exist.`
1446
1446
  );
1447
1447
  console.warn(
@@ -1449,7 +1449,7 @@ async function gn(e) {
1449
1449
  ), u == null || u({ confirmations: 0, required: s });
1450
1450
  } else {
1451
1451
  c = !0, h = 0, d = void 0;
1452
- let f = p[0], m = et({
1452
+ let f = p[0], b = et({
1453
1453
  currentBlock: g,
1454
1454
  createdAtBlock: p[0].createdAt
1455
1455
  });
@@ -1458,10 +1458,10 @@ async function gn(e) {
1458
1458
  currentBlock: g,
1459
1459
  createdAtBlock: $.createdAt
1460
1460
  });
1461
- x < m && (m = x, f = $);
1461
+ x < b && (b = x, f = $);
1462
1462
  }
1463
- if (u == null || u({ confirmations: m, required: s }), m >= s)
1464
- return { confirmations: m, basicInfo: f };
1463
+ if (u == null || u({ confirmations: b, required: s }), b >= s)
1464
+ return { confirmations: b, basicInfo: f };
1465
1465
  }
1466
1466
  } catch (g) {
1467
1467
  if (Wo(g))
@@ -1484,8 +1484,8 @@ async function gn(e) {
1484
1484
  });
1485
1485
  }
1486
1486
  }
1487
- const Yo = /^(?:[0-9a-f]{2})*$/, Jo = /^[0-9a-f]{64}$/, Qo = /^([0-9a-f]{64}):(0|[1-9][0-9]*)$/, Zo = -2147483648, es = 2147483647, Ee = 4294967295, tt = 2, rt = 2, de = 0;
1488
- class P extends Error {
1487
+ const Yo = /^(?:[0-9a-f]{2})*$/, Qo = /^[0-9a-f]{64}$/, Jo = /^([0-9a-f]{64}):(0|[1-9][0-9]*)$/, Zo = -2147483648, es = 2147483647, Ee = 4294967295, tt = 2, rt = 2, de = 0;
1488
+ class m extends Error {
1489
1489
  constructor(t) {
1490
1490
  super(t), this.name = "GraphFingerprintError";
1491
1491
  }
@@ -1493,63 +1493,63 @@ class P extends Error {
1493
1493
  function k(e, t, r) {
1494
1494
  const o = e[t];
1495
1495
  if (o === void 0)
1496
- throw new P(`Graph tx ${r} is missing "${t}"`);
1496
+ throw new m(`Graph tx ${r} is missing "${t}"`);
1497
1497
  return o;
1498
1498
  }
1499
1499
  function te(e, t) {
1500
1500
  if (!Array.isArray(e))
1501
- throw new P(`Graph tx ${t} is not an array`);
1501
+ throw new m(`Graph tx ${t} is not an array`);
1502
1502
  return e;
1503
1503
  }
1504
1504
  function B(e, t) {
1505
1505
  if (e === null || typeof e != "object" || Array.isArray(e))
1506
- throw new P(`Graph tx ${t} is not an object`);
1506
+ throw new m(`Graph tx ${t} is not an object`);
1507
1507
  return e;
1508
1508
  }
1509
- function J(e, t, r, o) {
1509
+ function Q(e, t, r, o) {
1510
1510
  if (typeof e != "number" || !Number.isSafeInteger(e) || e < r || e > o)
1511
- throw new P(
1511
+ throw new m(
1512
1512
  `Graph tx ${t} is not an integer in [${r}, ${o}]`
1513
1513
  );
1514
1514
  return e;
1515
1515
  }
1516
1516
  function ke(e, t) {
1517
1517
  if (typeof e != "string" || !Yo.test(e))
1518
- throw new P(
1518
+ throw new m(
1519
1519
  `Graph tx ${t} is not lowercase hex without a prefix`
1520
1520
  );
1521
1521
  return H.from(e, "hex");
1522
1522
  }
1523
1523
  function he(e, t) {
1524
- if (typeof e != "string" || !Jo.test(e))
1525
- throw new P(
1524
+ if (typeof e != "string" || !Qo.test(e))
1525
+ throw new m(
1526
1526
  `Graph ${t} is not 32 bytes of lowercase hex`
1527
1527
  );
1528
1528
  return e;
1529
1529
  }
1530
1530
  function ot(e, t) {
1531
1531
  const r = B(e, t), o = new S();
1532
- return o.version = J(
1532
+ return o.version = Q(
1533
1533
  k(r, "version", t),
1534
1534
  `${t}.version`,
1535
1535
  Zo,
1536
1536
  es
1537
- ), o.locktime = J(
1537
+ ), o.locktime = Q(
1538
1538
  k(r, "lock_time", t),
1539
1539
  `${t}.lock_time`,
1540
1540
  0,
1541
1541
  Ee
1542
1542
  ), te(k(r, "input", t), `${t}.input`).forEach((s, n) => {
1543
- const a = `${t}.input[${n}]`, i = B(s, a), u = k(i, "previous_output", a), l = typeof u == "string" && Qo.exec(u);
1543
+ const a = `${t}.input[${n}]`, i = B(s, a), u = k(i, "previous_output", a), l = typeof u == "string" && Jo.exec(u);
1544
1544
  if (!l)
1545
- throw new P(
1545
+ throw new m(
1546
1546
  `Graph tx ${a}.previous_output is not "<txid>:<vout>"`
1547
1547
  );
1548
- const c = J(Number(l[2]), `${a}.previous_output vout`, 0, Ee);
1548
+ const c = Q(Number(l[2]), `${a}.previous_output vout`, 0, Ee);
1549
1549
  o.addInput(
1550
1550
  H.from(l[1], "hex").reverse(),
1551
1551
  c,
1552
- J(k(i, "sequence", a), `${a}.sequence`, 0, Ee),
1552
+ Q(k(i, "sequence", a), `${a}.sequence`, 0, Ee),
1553
1553
  ke(k(i, "script_sig", a), `${a}.script_sig`)
1554
1554
  ), o.ins[n].witness = te(
1555
1555
  k(i, "witness", a),
@@ -1559,27 +1559,27 @@ function ot(e, t) {
1559
1559
  const a = `${t}.output[${n}]`, i = B(s, a);
1560
1560
  o.addOutput(
1561
1561
  ke(k(i, "script_pubkey", a), `${a}.script_pubkey`),
1562
- J(k(i, "value", a), `${a}.value`, 0, Number.MAX_SAFE_INTEGER)
1562
+ Q(k(i, "value", a), `${a}.value`, 0, Number.MAX_SAFE_INTEGER)
1563
1563
  );
1564
1564
  }), new Uint8Array(o.toBuffer());
1565
1565
  }
1566
1566
  function D(e, t) {
1567
- const r = b(e).toLowerCase();
1567
+ const r = P(e).toLowerCase();
1568
1568
  let o;
1569
1569
  try {
1570
1570
  o = S.fromHex(r);
1571
1571
  } catch (s) {
1572
- throw new P(
1572
+ throw new m(
1573
1573
  `Presign ${t} is not one transaction: ${s instanceof Error ? s.message : String(s)}`
1574
1574
  );
1575
1575
  }
1576
1576
  if (o.toHex() !== r)
1577
- throw new P(
1577
+ throw new m(
1578
1578
  `Presign ${t} is not a canonical transaction encoding`
1579
1579
  );
1580
1580
  return o;
1581
1581
  }
1582
- function Mt(e, t) {
1582
+ function Ft(e, t) {
1583
1583
  const r = e.ins[t];
1584
1584
  if (r)
1585
1585
  return {
@@ -1589,34 +1589,34 @@ function Mt(e, t) {
1589
1589
  }
1590
1590
  function Ut(e, t) {
1591
1591
  if (!e.outs[de])
1592
- throw new P(
1592
+ throw new m(
1593
1593
  `Presign ${t}.claim_tx must have output ${de}`
1594
1594
  );
1595
1595
  }
1596
1596
  function ts(e, t, r) {
1597
1597
  if (e.ins.length !== 1)
1598
- throw new P(
1598
+ throw new m(
1599
1599
  `Presign ${r}.claim_tx must have exactly one input, got ${e.ins.length}`
1600
1600
  );
1601
1601
  Ut(e, r);
1602
- const o = Mt(e, 0);
1602
+ const o = Ft(e, 0);
1603
1603
  if ((o == null ? void 0 : o.txid) !== t || o.vout !== X) {
1604
1604
  const s = o ? `${o.txid}:${o.vout}` : "no input";
1605
- throw new P(
1605
+ throw new m(
1606
1606
  `Presign ${r}.claim_tx must spend ${t}:${X}, got ${s}`
1607
1607
  );
1608
1608
  }
1609
1609
  }
1610
1610
  function Oe(e, t, r) {
1611
- const o = Mt(e, 0);
1611
+ const o = Ft(e, 0);
1612
1612
  if ((o == null ? void 0 : o.txid) !== t || o.vout !== de) {
1613
1613
  const s = o ? `${o.txid}:${o.vout}` : "no input";
1614
- throw new P(
1614
+ throw new m(
1615
1615
  `Presign ${r}.assert_tx input 0 must spend ${t}:${de}, got ${s}`
1616
1616
  );
1617
1617
  }
1618
1618
  }
1619
- function Ft(e) {
1619
+ function qt(e) {
1620
1620
  const t = D(e.peginTxHex, `${e.path}.pegin_tx`), r = D(e.claimTxHex, `${e.path}.claim_tx`), o = D(e.assertTxHex, `${e.path}.assert_tx`);
1621
1621
  return { peginTx: t, claimTx: r, assertTx: o };
1622
1622
  }
@@ -1625,60 +1625,60 @@ function rs(e) {
1625
1625
  Ut(t, e.path), Oe(r, t.getId(), e.path);
1626
1626
  }
1627
1627
  function os(e) {
1628
- const { peginTx: t, claimTx: r, assertTx: o } = Ft(e);
1628
+ const { peginTx: t, claimTx: r, assertTx: o } = qt(e);
1629
1629
  ts(r, t.getId(), e.path), Oe(o, r.getId(), e.path);
1630
1630
  }
1631
1631
  function ss(e, t) {
1632
1632
  const [r, ...o] = e.ins;
1633
1633
  if (!r || o.length > 0)
1634
- throw new P(
1634
+ throw new m(
1635
1635
  `Presign claim_tx must have exactly one input, got ${e.ins.length}`
1636
1636
  );
1637
1637
  const s = H.from(r.hash).reverse().toString("hex");
1638
1638
  if (s !== t || r.index !== X)
1639
- throw new P(
1639
+ throw new m(
1640
1640
  `Presign claim_tx must spend ${t}:${X}, got ${s}:${r.index}`
1641
1641
  );
1642
1642
  if (e.version !== tt)
1643
- throw new P(
1643
+ throw new m(
1644
1644
  `Presign claim_tx version must be ${tt}, got ${e.version}`
1645
1645
  );
1646
1646
  if (r.witness.length > 0)
1647
- throw new P(
1647
+ throw new m(
1648
1648
  `Presign claim_tx input must have an empty witness, got ${r.witness.length} item(s)`
1649
1649
  );
1650
1650
  if (e.outs.length !== rt)
1651
- throw new P(
1651
+ throw new m(
1652
1652
  `Presign claim_tx must have exactly ${rt} outputs, got ${e.outs.length}`
1653
1653
  );
1654
1654
  }
1655
- function qt(e) {
1655
+ function Gt(e) {
1656
1656
  const t = [...e.challengers].sort(
1657
1657
  (o, s) => o.pubkey < s.pubkey ? -1 : o.pubkey > s.pubkey ? 1 : 0
1658
1658
  ), r = [e.peginTx, e.claimTx, e.assertTx, e.payoutTx];
1659
1659
  return t.forEach((o, s) => {
1660
1660
  const n = he(o.pubkey, "challenger pubkey");
1661
1661
  if (s > 0 && t[s - 1].pubkey === n)
1662
- throw new P(`Graph lists challenger ${n} twice`);
1662
+ throw new m(`Graph lists challenger ${n} twice`);
1663
1663
  r.push(We(n), o.nopayoutTx);
1664
1664
  for (const a of o.outputLabelHashes)
1665
1665
  r.push(We(he(a, "output_label_hashes entry")));
1666
- }), Mr(Ur(Fr(...r)));
1666
+ }), Fr(Ur(qr(...r)));
1667
1667
  }
1668
1668
  function ns(e) {
1669
- const t = b(e.peginTxid).toLowerCase(), { peginTx: r, claimTx: o, assertTx: s } = Ft({
1669
+ const t = P(e.peginTxid).toLowerCase(), { peginTx: r, claimTx: o, assertTx: s } = qt({
1670
1670
  peginTxHex: e.peginTxHex,
1671
1671
  claimTxHex: e.claimTxHex,
1672
1672
  assertTxHex: e.assertTxHex,
1673
1673
  path: "depositor_graph"
1674
1674
  });
1675
1675
  if (r.getId() !== t)
1676
- throw new P(
1676
+ throw new m(
1677
1677
  `Presign pegin_tx hashes to ${r.getId()}, expected ${t}`
1678
1678
  );
1679
1679
  ss(o, t), Oe(s, o.getId(), "depositor_graph");
1680
1680
  const n = (a) => new Uint8Array(a.toBuffer());
1681
- return qt({
1681
+ return Gt({
1682
1682
  peginTx: n(r),
1683
1683
  claimTx: n(o),
1684
1684
  assertTx: n(s),
@@ -1687,7 +1687,7 @@ function ns(e) {
1687
1687
  pubkey: _(a.challenger_pubkey),
1688
1688
  nopayoutTx: n(D(a.nopayout_tx.tx_hex, "nopayout_tx")),
1689
1689
  outputLabelHashes: a.output_label_hashes.map(
1690
- (i) => b(i).toLowerCase()
1690
+ (i) => P(i).toLowerCase()
1691
1691
  )
1692
1692
  }))
1693
1693
  });
@@ -1697,7 +1697,7 @@ function is(e) {
1697
1697
  k(e, "challenger_subgraphs", "graph"),
1698
1698
  "challenger_subgraphs"
1699
1699
  );
1700
- return qt({
1700
+ return Gt({
1701
1701
  peginTx: t("pegin_tx"),
1702
1702
  claimTx: t("claim_tx"),
1703
1703
  assertTx: t("assert_tx"),
@@ -1732,7 +1732,7 @@ function as(e) {
1732
1732
  ).forEach((s, n) => {
1733
1733
  const a = he(s, `challenger_pubkeys.${o}[${n}]`);
1734
1734
  if (r.has(a))
1735
- throw new P(
1735
+ throw new m(
1736
1736
  `Graph declares challenger ${a} more than once`
1737
1737
  );
1738
1738
  r.add(a);
@@ -1742,28 +1742,28 @@ function as(e) {
1742
1742
  function fn(e, t) {
1743
1743
  const r = is(e);
1744
1744
  if (r !== t)
1745
- throw new P(
1745
+ throw new m(
1746
1746
  `Graph fingerprint ${r} does not match the presign fingerprint ${t}`
1747
1747
  );
1748
1748
  const o = Object.keys(
1749
1749
  B(e.challenger_subgraphs, "challenger_subgraphs")
1750
1750
  ), s = as(e);
1751
1751
  if (o.length !== s.size || o.some((n) => !s.has(n)))
1752
- throw new P(
1752
+ throw new m(
1753
1753
  `Graph challenger_subgraphs keys ${o.join(", ")} do not match challenger_pubkeys ${[...s].join(", ")}`
1754
1754
  );
1755
1755
  }
1756
1756
  const us = 1;
1757
1757
  function cs(e, t, r) {
1758
1758
  const o = r.map(
1759
- (h) => b(h).toLowerCase()
1759
+ (h) => P(h).toLowerCase()
1760
1760
  ), s = t.filter((h) => o.includes(h));
1761
1761
  if (s.length > 0)
1762
1762
  throw new Error(
1763
1763
  `Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
1764
1764
  );
1765
1765
  const n = [...t, ...o], a = e.map(
1766
- (h) => b(h.challenger_pubkey).toLowerCase()
1766
+ (h) => P(h.challenger_pubkey).toLowerCase()
1767
1767
  ), i = new Set(a);
1768
1768
  if (i.size !== a.length)
1769
1769
  throw new Error(
@@ -1774,16 +1774,16 @@ function cs(e, t, r) {
1774
1774
  throw new Error(
1775
1775
  "Depositor graph challenger set does not match expected (local ∪ universal)" + (l.length > 0 ? ` (missing: ${l.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
1776
1776
  );
1777
- return or(n);
1777
+ return sr(n);
1778
1778
  }
1779
1779
  function ls(e, t) {
1780
- const r = _r + Sr * t + Ar;
1780
+ const r = Sr + Ar * t + Br;
1781
1781
  if (e.outs.length !== r)
1782
1782
  throw new Error(
1783
1783
  `Assert must have ${r} outputs for ${t} challengers, got ${e.outs.length}`
1784
1784
  );
1785
1785
  }
1786
- async function Gt(e, t) {
1786
+ async function Xt(e, t) {
1787
1787
  const r = wt({
1788
1788
  claimerBtcPubkey: t.depositorBtcPubkey,
1789
1789
  depositorBtcPubkey: t.depositorBtcPubkey,
@@ -1793,13 +1793,13 @@ async function Gt(e, t) {
1793
1793
  e.challenger_presign_data,
1794
1794
  r,
1795
1795
  t.universalChallengerBtcPubkeys
1796
- ), s = b(t.depositorBtcPubkey), n = S.fromHex(
1797
- b(e.assert_tx.tx_hex)
1796
+ ), s = P(t.depositorBtcPubkey), n = S.fromHex(
1797
+ P(e.assert_tx.tx_hex)
1798
1798
  );
1799
1799
  ls(n, o.length);
1800
1800
  const a = [];
1801
1801
  for (const i of e.challenger_presign_data) {
1802
- const u = b(i.challenger_pubkey), l = o.indexOf(
1802
+ const u = P(i.challenger_pubkey), l = o.indexOf(
1803
1803
  u.toLowerCase()
1804
1804
  ), c = await ds({
1805
1805
  challenger: i,
@@ -1824,17 +1824,17 @@ async function ds(e) {
1824
1824
  assertTx: a,
1825
1825
  ctx: i
1826
1826
  } = e;
1827
- Gr(
1827
+ Xr(
1828
1828
  t.nopayout_tx.tx_hex,
1829
1829
  r,
1830
1830
  i.network
1831
1831
  );
1832
1832
  const u = S.fromHex(
1833
- b(t.nopayout_tx.tx_hex)
1833
+ P(t.nopayout_tx.tx_hex)
1834
1834
  ), l = S.fromHex(
1835
- b(t.challenge_assert_x_tx.tx_hex)
1835
+ P(t.challenge_assert_x_tx.tx_hex)
1836
1836
  ), c = S.fromHex(
1837
- b(t.challenge_assert_y_tx.tx_hex)
1837
+ P(t.challenge_assert_y_tx.tx_hex)
1838
1838
  ), h = await br({
1839
1839
  txGraphVersion: i.vaultCoreVersion,
1840
1840
  claimer: n,
@@ -1849,7 +1849,7 @@ async function ds(e) {
1849
1849
  ["X", l],
1850
1850
  ["Y", c]
1851
1851
  ])
1852
- Xr({
1852
+ zr({
1853
1853
  challengeAssertTx: p,
1854
1854
  assertTx: a,
1855
1855
  half: g,
@@ -1863,7 +1863,7 @@ async function ds(e) {
1863
1863
  l.outs[Xe],
1864
1864
  c.outs[Xe]
1865
1865
  ];
1866
- return zr({
1866
+ return jr({
1867
1867
  noPayoutTx: u,
1868
1868
  assertTxid: a.getId(),
1869
1869
  challengeAssertXTxid: l.getId(),
@@ -1880,7 +1880,7 @@ async function ds(e) {
1880
1880
  }));
1881
1881
  }
1882
1882
  async function hs(e, t, r) {
1883
- const o = [], s = [], n = [], { localChallengers: a, noPayouts: i } = await Gt(e, r), u = await Vr({
1883
+ const o = [], s = [], n = [], { localChallengers: a, noPayouts: i } = await Xt(e, r), u = await Rr({
1884
1884
  vaultCoreVersion: r.vaultCoreVersion,
1885
1885
  vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
1886
1886
  vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
@@ -1907,9 +1907,9 @@ async function hs(e, t, r) {
1907
1907
  Ge
1908
1908
  )
1909
1909
  );
1910
- const l = b(r.depositorBtcPubkey);
1910
+ const l = P(r.depositorBtcPubkey);
1911
1911
  for (const { challenger: c, challengerPubkey: h, prevouts: d } of i) {
1912
- const g = o.length, p = await qr({
1912
+ const g = o.length, p = await Gr({
1913
1913
  noPayoutTxHex: c.nopayout_tx.tx_hex,
1914
1914
  challengerPubkey: h,
1915
1915
  prevouts: d,
@@ -1978,14 +1978,14 @@ async function gs(e) {
1978
1978
  assertTxHex: t.assert_tx.tx_hex,
1979
1979
  path: "depositor_graph"
1980
1980
  });
1981
- const s = await r.getPublicKeyHex(), { depositorPubkey: n } = rr(
1981
+ const s = await r.getPublicKeyHex(), { depositorPubkey: n } = or(
1982
1982
  s,
1983
- b(o.depositorBtcPubkey)
1983
+ P(o.depositorBtcPubkey)
1984
1984
  ), { psbtHexes: a, signOptions: i, challengerEntries: u } = await hs(
1985
1985
  t,
1986
1986
  s,
1987
1987
  o
1988
- ), l = await bt(
1988
+ ), l = await Pt(
1989
1989
  r,
1990
1990
  a,
1991
1991
  i
@@ -2000,7 +2000,7 @@ async function gs(e) {
2000
2000
  );
2001
2001
  }
2002
2002
  const fs = 1e4, M = 10;
2003
- async function Xt(e) {
2003
+ async function zt(e) {
2004
2004
  const {
2005
2005
  statusReader: t,
2006
2006
  vaultId: r,
@@ -2035,12 +2035,12 @@ async function Xt(e) {
2035
2035
  const c = l.status;
2036
2036
  if (s.has(c) || c === R.ACTIVATED)
2037
2037
  return c;
2038
- if (c === R.EXPIRED || Nr.has(c))
2038
+ if (c === R.EXPIRED || Dr.has(c))
2039
2039
  throw new Error(
2040
2040
  `Vault ${r.slice(0, M)}… reached terminal status "${c}" while waiting for ${[...s].join(", ")}`
2041
2041
  );
2042
2042
  } catch (l) {
2043
- if (!(l instanceof Dr && l.code === Lr.PEGIN_NOT_FOUND))
2043
+ if (!(l instanceof Lr && l.code === Mr.PEGIN_NOT_FOUND))
2044
2044
  throw l;
2045
2045
  }
2046
2046
  await new Promise((l, c) => {
@@ -2057,16 +2057,16 @@ async function Xt(e) {
2057
2057
  });
2058
2058
  }
2059
2059
  }
2060
- const ys = 1200 * 1e3, zt = /* @__PURE__ */ new Set([
2060
+ const ys = 1200 * 1e3, jt = /* @__PURE__ */ new Set([
2061
2061
  R.PENDING_ACKS,
2062
2062
  R.PENDING_ACTIVATION,
2063
2063
  R.ACTIVATED_PENDING_BROADCAST,
2064
2064
  R.ACTIVATED
2065
2065
  ]), vs = /* @__PURE__ */ new Set([
2066
2066
  R.PENDING_DEPOSITOR_SIGNATURES,
2067
- ...zt
2067
+ ...jt
2068
2068
  ]);
2069
- function bs(e) {
2069
+ function Ps(e) {
2070
2070
  return e.map((t) => ({
2071
2071
  claimerPubkeyXOnly: pe(t.claimer_pubkey),
2072
2072
  payoutTxHex: t.payout_tx.tx_hex,
@@ -2076,7 +2076,7 @@ function bs(e) {
2076
2076
  function I(e) {
2077
2077
  return pe(e).toLowerCase();
2078
2078
  }
2079
- function ms(e, t) {
2079
+ function bs(e, t) {
2080
2080
  const r = (u, l, c) => {
2081
2081
  throw new Error(
2082
2082
  `Deposit terms ${u} (${String(l)}) does not match the vault's version-locked signing context (${String(c)}); refusing to sign payouts against terms that describe a different graph.`
@@ -2114,7 +2114,7 @@ function ms(e, t) {
2114
2114
  t.vaultProviderBtcPubkey
2115
2115
  );
2116
2116
  }
2117
- function Ps(e, t, r, o) {
2117
+ function ms(e, t, r, o) {
2118
2118
  const s = I(o), n = [
2119
2119
  I(t),
2120
2120
  ...r.map(I)
@@ -2161,7 +2161,7 @@ function st(e, t) {
2161
2161
  };
2162
2162
  }
2163
2163
  async function ws(e, t, r, o) {
2164
- const s = new nr({
2164
+ const s = new ir({
2165
2165
  network: t.network,
2166
2166
  btcWallet: e
2167
2167
  }), n = r.length;
@@ -2202,7 +2202,7 @@ async function yn(e) {
2202
2202
  signal: c,
2203
2203
  onProgress: h,
2204
2204
  recordGraphFingerprint: d
2205
- } = e, g = await Xt({
2205
+ } = e, g = await zt({
2206
2206
  statusReader: t,
2207
2207
  vaultId: s,
2208
2208
  peginTxid: n,
@@ -2210,9 +2210,9 @@ async function yn(e) {
2210
2210
  timeoutMs: l,
2211
2211
  signal: c
2212
2212
  });
2213
- if (zt.has(g))
2213
+ if (jt.has(g))
2214
2214
  return;
2215
- c == null || c.throwIfAborted(), u !== void 0 && ms(u, i);
2215
+ c == null || c.throwIfAborted(), u !== void 0 && bs(u, i);
2216
2216
  const p = vt(o) ? o : void 0;
2217
2217
  let y;
2218
2218
  if (p) {
@@ -2236,7 +2236,7 @@ async function yn(e) {
2236
2236
  path: `txs[${se}]`
2237
2237
  });
2238
2238
  });
2239
- const m = ns({
2239
+ const b = ns({
2240
2240
  peginTxid: n,
2241
2241
  peginTxHex: i.peginTxHex,
2242
2242
  claimTxHex: f.depositor_graph.claim_tx.tx_hex,
@@ -2261,12 +2261,12 @@ async function yn(e) {
2261
2261
  vkClaimerPayoutScriptPubKeys: i.vkClaimerPayoutScriptPubKeys,
2262
2262
  vpCommissionScriptPubKey: i.vpCommissionScriptPubKey
2263
2263
  };
2264
- await Gt(
2264
+ await Xt(
2265
2265
  f.depositor_graph,
2266
2266
  $
2267
2267
  ), c == null || c.throwIfAborted();
2268
2268
  const x = I(a);
2269
- Ps(
2269
+ ms(
2270
2270
  f.txs,
2271
2271
  i.vaultProviderBtcPubkey,
2272
2272
  i.vaultKeeperBtcPubkeys,
@@ -2274,7 +2274,7 @@ async function yn(e) {
2274
2274
  );
2275
2275
  const v = f.txs.filter(
2276
2276
  (O) => I(O.claimer_pubkey) !== x
2277
- ), E = bs(v);
2277
+ ), E = Ps(v);
2278
2278
  p && y && (typeof p.validateDepositTerms == "function" && await p.validateDepositTerms(y), await p.approveDepositTerms(y)), c == null || c.throwIfAborted();
2279
2279
  const T = await ws(
2280
2280
  o,
@@ -2288,9 +2288,9 @@ async function yn(e) {
2288
2288
  btcWallet: o,
2289
2289
  signingContext: $
2290
2290
  });
2291
- c == null || c.throwIfAborted(), await d(m), c == null || c.throwIfAborted();
2291
+ c == null || c.throwIfAborted(), await d(b), c == null || c.throwIfAborted();
2292
2292
  const j = { ...T };
2293
- j[b(a)] = w.payout_signatures, await r.submitDepositorPresignatures(
2293
+ j[P(a)] = w.payout_signatures, await r.submitDepositorPresignatures(
2294
2294
  {
2295
2295
  pegin_txid: n,
2296
2296
  depositor_pk: a,
@@ -2316,7 +2316,7 @@ async function vn(e) {
2316
2316
  signal: u
2317
2317
  } = e;
2318
2318
  u == null || u.throwIfAborted();
2319
- const l = await Xt({
2319
+ const l = await zt({
2320
2320
  statusReader: t,
2321
2321
  vaultId: o,
2322
2322
  peginTxid: s,
@@ -2356,7 +2356,7 @@ function Ce(e) {
2356
2356
  function it(e, t) {
2357
2357
  return e.length === t.length && e.every((r, o) => r === t[o]);
2358
2358
  }
2359
- async function bn(e) {
2359
+ async function Pn(e) {
2360
2360
  const {
2361
2361
  vaultProviderEthAddress: t,
2362
2362
  hintBtcPubkey: r,
@@ -2380,11 +2380,11 @@ class Se extends Error {
2380
2380
  super(t), this.name = "ApplicationEntryPointMismatchError";
2381
2381
  }
2382
2382
  }
2383
- function mn(e) {
2383
+ function bn(e) {
2384
2384
  return e instanceof Se || e instanceof Error && e.name === "ApplicationEntryPointMismatchError";
2385
2385
  }
2386
2386
  const at = (e) => e.map(_).sort();
2387
- async function Pn(e) {
2387
+ async function mn(e) {
2388
2388
  const {
2389
2389
  vaultRegistryReader: t,
2390
2390
  vaultKeeperReader: r,
@@ -2415,15 +2415,15 @@ async function Pn(e) {
2415
2415
  o.getLatestUniversalChallengersVersion(d),
2416
2416
  o.getCurrentUcKeyEpoch(d)
2417
2417
  ]);
2418
- if (!Hr(n, { strict: !1 }))
2418
+ if (!Or(n, { strict: !1 }))
2419
2419
  throw new Se(
2420
2420
  `The application entry point this deposit was prepared for is not a valid address: ${n}`
2421
2421
  );
2422
- if (!Or(g, n))
2422
+ if (!Nr(g, n))
2423
2423
  throw new Se(
2424
2424
  `Vault provider ${s} is registered to application ${g}, but this deposit was prepared for ${n}. Refusing to build: the vault keeper roster, its version, and the keeper key epoch would all resolve against a different application than the one selected.`
2425
2425
  );
2426
- const [m, $] = await Promise.all(
2426
+ const [b, $] = await Promise.all(
2427
2427
  [
2428
2428
  r.getCurrentVaultKeepersVersion(
2429
2429
  g,
@@ -2437,7 +2437,7 @@ async function Pn(e) {
2437
2437
  ), [x, v] = await Promise.all([
2438
2438
  r.getVaultKeepersByVersion(
2439
2439
  g,
2440
- m,
2440
+ b,
2441
2441
  d
2442
2442
  ),
2443
2443
  o.getUniversalChallengersByVersion(
@@ -2448,7 +2448,7 @@ async function Pn(e) {
2448
2448
  vaultProvider: _(p),
2449
2449
  vaultKeepers: at(x.map((C) => C.btcPubKey)),
2450
2450
  universalChallengers: at(v.map((C) => C.btcPubKey))
2451
- }, T = await Fo({
2451
+ }, T = await qo({
2452
2452
  operationKeyReader: l,
2453
2453
  query: {
2454
2454
  vaultProviderEthAddress: s,
@@ -2483,14 +2483,14 @@ async function Pn(e) {
2483
2483
  );
2484
2484
  if (!$e(O))
2485
2485
  throw new Error(
2486
- `Vault keeper BTC pubkeys (v${m}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
2486
+ `Vault keeper BTC pubkeys (v${b}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
2487
2487
  );
2488
2488
  if (!$e(se))
2489
2489
  throw new Error(
2490
2490
  `Universal challenger BTC pubkeys (v${y}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
2491
2491
  );
2492
- const Ne = [j, O, se], Qt = Ne.some((C) => C.registration && !C.operation), De = Ne.some((C) => C.operation && !C.registration);
2493
- if (Qt && De) {
2492
+ const Ne = [j, O, se], Zt = Ne.some((C) => C.registration && !C.operation), De = Ne.some((C) => C.operation && !C.registration);
2493
+ if (Zt && De) {
2494
2494
  const C = `Indexer participant hints are internally inconsistent for vault provider ${s}: some roles match the registration keys while others match the rotated operation keys.`;
2495
2495
  throw h == null || h(C), new Error(`${C} Refresh and try again.`);
2496
2496
  }
@@ -2500,7 +2500,7 @@ async function Pn(e) {
2500
2500
  vaultProviderBtcPubkeyXOnly: w.vaultProvider,
2501
2501
  vaultKeeperBtcPubkeysSorted: w.vaultKeepers,
2502
2502
  universalChallengerBtcPubkeysSorted: w.universalChallengers,
2503
- expectedAppVaultKeepersVersion: m,
2503
+ expectedAppVaultKeepersVersion: b,
2504
2504
  expectedUniversalChallengersVersion: y,
2505
2505
  appKeeperKeyEpoch: $,
2506
2506
  ucKeyEpoch: f,
@@ -2587,7 +2587,7 @@ function Cs(e, t, r) {
2587
2587
  return { valid: !0 };
2588
2588
  }
2589
2589
  function Ts(e) {
2590
- const t = b(e);
2590
+ const t = P(e);
2591
2591
  return $s(t) ? { valid: !0 } : {
2592
2592
  valid: !1,
2593
2593
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
@@ -2630,13 +2630,13 @@ function $n(e) {
2630
2630
  throw new Error(l.error);
2631
2631
  _s(s), Ss(n), As(r);
2632
2632
  }
2633
- class jt extends Error {
2633
+ class Wt extends Error {
2634
2634
  constructor(t) {
2635
2635
  super(t), this.name = "ParticipantKeyDriftError";
2636
2636
  }
2637
2637
  }
2638
2638
  function Cn(e) {
2639
- return e instanceof jt || e instanceof Error && e.name === "ParticipantKeyDriftError";
2639
+ return e instanceof Wt || e instanceof Error && e.name === "ParticipantKeyDriftError";
2640
2640
  }
2641
2641
  function ut(e, t, r) {
2642
2642
  return t.length === r.length && t.every((o, s) => o === r[s]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
@@ -2677,17 +2677,17 @@ async function Tn(e) {
2677
2677
  g && i.push(g);
2678
2678
  }
2679
2679
  if (i.length > 0)
2680
- throw new jt(
2680
+ throw new Wt(
2681
2681
  `Aborting BTC broadcast: participant operation keys changed during registration (${i.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
2682
2682
  );
2683
2683
  }
2684
- class Wt extends Error {
2684
+ class Yt extends Error {
2685
2685
  constructor(t) {
2686
2686
  super(t), this.name = "RegisteredVaultVersionMismatchError";
2687
2687
  }
2688
2688
  }
2689
2689
  function _n(e) {
2690
- return e instanceof Wt || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
2690
+ return e instanceof Yt || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
2691
2691
  }
2692
2692
  async function Sn(e) {
2693
2693
  const {
@@ -2710,7 +2710,7 @@ async function Sn(e) {
2710
2710
  `vault ${h}: vaultCoreVersion expected v${a} (build-time active), got v${l.vaultCoreVersion}`
2711
2711
  );
2712
2712
  }), u.length > 0)
2713
- throw new Wt(
2713
+ throw new Yt(
2714
2714
  `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.`
2715
2715
  );
2716
2716
  }
@@ -2722,7 +2722,7 @@ class Bs extends Error {
2722
2722
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
2723
2723
  }
2724
2724
  }
2725
- const Is = /^0x[0-9a-fA-F]{64}$/, Vs = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Yt = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Jt = 160, ct = 2e3, lt = 10n, dt = 100n;
2725
+ const Is = /^0x[0-9a-fA-F]{64}$/, Vs = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Qt = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Jt = 160, ct = 2e3, lt = 10n, dt = 100n;
2726
2726
  function An(e) {
2727
2727
  if (!Number.isFinite(e) || e <= 0)
2728
2728
  throw new Error(
@@ -2788,7 +2788,7 @@ function Hs(e) {
2788
2788
  throw new Error(
2789
2789
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
2790
2790
  );
2791
- if (!e.depositorBtcPubkey || !Yt.test(e.depositorBtcPubkey))
2791
+ if (!e.depositorBtcPubkey || !Qt.test(e.depositorBtcPubkey))
2792
2792
  throw new Error(
2793
2793
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
2794
2794
  );
@@ -2796,7 +2796,7 @@ function Hs(e) {
2796
2796
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
2797
2797
  }
2798
2798
  function Os(e) {
2799
- if (!e.vaultProviderPubkey || !Yt.test(e.vaultProviderPubkey))
2799
+ if (!e.vaultProviderPubkey || !Qt.test(e.vaultProviderPubkey))
2800
2800
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
2801
2801
  if (e.vaultKeeperPubkeys.length === 0)
2802
2802
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -2849,7 +2849,7 @@ async function Bn(e) {
2849
2849
  i == null || i.throwIfAborted();
2850
2850
  const d = pe(
2851
2851
  u.depositorBtcPubkey
2852
- ), g = b(u.unsignedPrePeginTxHex), p = ir(g);
2852
+ ), g = P(u.unsignedPrePeginTxHex), p = ar(g);
2853
2853
  if (p !== void 0 && p.vout !== u.batch.length)
2854
2854
  throw new Error(
2855
2855
  `Auth-anchor OP_RETURN at vout ${p.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.`
@@ -2867,14 +2867,14 @@ async function Bn(e) {
2867
2867
  throw new Error(
2868
2868
  `Funded Pre-PegIn tx has ${f.outs.length} outputs but batch requires at least ${u.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
2869
2869
  );
2870
- const { psbtHex: m } = await jr({
2870
+ const { psbtHex: b } = await Wr({
2871
2871
  prePeginParams: {
2872
2872
  vaultCoreVersion: u.vaultCoreVersion,
2873
2873
  depositorPubkey: d,
2874
- vaultProviderPubkey: b(l.vaultProviderPubkey),
2875
- vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(b),
2876
- universalChallengerPubkeys: l.universalChallengerPubkeys.map(b),
2877
- hashlocks: u.batch.map((w) => b(w.hashlock)),
2874
+ vaultProviderPubkey: P(l.vaultProviderPubkey),
2875
+ vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(P),
2876
+ universalChallengerPubkeys: l.universalChallengerPubkeys.map(P),
2877
+ hashlocks: u.batch.map((w) => P(w.hashlock)),
2878
2878
  timelockRefund: l.timelockRefund,
2879
2879
  // `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
2880
2880
  // is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
@@ -2898,15 +2898,15 @@ async function Bn(e) {
2898
2898
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
2899
2899
  // value would derive the wrong refund script leaf and yield an
2900
2900
  // unspendable PSBT. Match the `hashlocks` array handling above.
2901
- hashlock: b(u.hashlock)
2901
+ hashlock: P(u.hashlock)
2902
2902
  });
2903
2903
  i == null || i.throwIfAborted();
2904
2904
  const $ = ce(
2905
2905
  u.depositorBtcPubkey,
2906
2906
  Rs
2907
- ), x = await n(m, $);
2907
+ ), x = await n(b, $);
2908
2908
  ae({
2909
- requestedPsbtHex: m,
2909
+ requestedPsbtHex: b,
2910
2910
  returnedPsbtHex: x
2911
2911
  });
2912
2912
  const v = 0, E = ue(
@@ -2915,13 +2915,13 @@ async function Bn(e) {
2915
2915
  v
2916
2916
  );
2917
2917
  oe({
2918
- requestedPsbtHex: m,
2918
+ requestedPsbtHex: b,
2919
2919
  signatureHex: E,
2920
2920
  signerXOnlyPubkeyHex: d,
2921
2921
  inputIndex: v
2922
2922
  });
2923
2923
  const T = Tt({
2924
- requestedPsbtHex: m,
2924
+ requestedPsbtHex: b,
2925
2925
  signaturesHex: [E],
2926
2926
  signerXOnlyPubkeyHex: d
2927
2927
  });
@@ -2932,6 +2932,42 @@ async function Bn(e) {
2932
2932
  throw w instanceof Error && Ks.test(w.message) ? new Bs(t, w) : w;
2933
2933
  }
2934
2934
  }
2935
+ async function In(e) {
2936
+ const { vaultId: t, vault: r, readers: o, network: s } = e, [n, a] = await Promise.all([
2937
+ Dt({
2938
+ vaultId: t,
2939
+ vault: {
2940
+ basic: {
2941
+ vaultProvider: r.vaultProvider,
2942
+ applicationEntryPoint: r.applicationEntryPoint
2943
+ },
2944
+ protocol: {
2945
+ appVaultKeepersVersion: r.appVaultKeepersVersion,
2946
+ universalChallengersVersion: r.universalChallengersVersion
2947
+ }
2948
+ },
2949
+ readers: o
2950
+ }),
2951
+ o.protocolParamsReader.getOffchainParamsByVersion(
2952
+ r.offchainParamsVersion
2953
+ )
2954
+ ]);
2955
+ return {
2956
+ vaultProviderPubkey: n.vaultProvider.operationBtcPubkey,
2957
+ vaultKeeperPubkeys: n.vaultKeeperOperationKeysSorted,
2958
+ universalChallengerPubkeys: n.universalChallengerOperationKeysSorted,
2959
+ timelockRefund: a.tRefund,
2960
+ feeRate: a.feeRate,
2961
+ minPeginFeeRate: a.minPeginFeeRate,
2962
+ // The local challengers of the depositor's own claim graph, which this
2963
+ // value sizes, are the vault keepers alone: the same count
2964
+ // `PeginManager.preparePegin` sized the HTLC with.
2965
+ numLocalChallengers: n.vaultKeeperOperationKeysSorted.length,
2966
+ councilQuorum: a.councilQuorum,
2967
+ councilSize: a.securityCouncilKeys.length,
2968
+ network: s
2969
+ };
2970
+ }
2935
2971
  class ht extends Error {
2936
2972
  constructor(r, o, s) {
2937
2973
  super(r);
@@ -2942,13 +2978,13 @@ class ht extends Error {
2942
2978
  this.name = "ReclaimUneconomicalError", this.feeSats = o, this.sweptTotalSats = s;
2943
2979
  }
2944
2980
  }
2945
- const pt = 2e3, gt = 25n, ft = 100n, In = 10n;
2981
+ const pt = 2e3, gt = 25n, ft = 100n, Vn = 10n;
2946
2982
  async function Ns(e, t, r) {
2947
2983
  for (let o = 0; o < e.length; o++) {
2948
- const s = Qr(e[o].depositorSignedPeginTxHex), n = Ie(
2984
+ const s = Zr(e[o].depositorSignedPeginTxHex), n = Ie(
2949
2985
  await mr(
2950
- b(s),
2951
- b(r)
2986
+ P(s),
2987
+ P(r)
2952
2988
  )
2953
2989
  ).toLowerCase();
2954
2990
  if (n !== t[o].toLowerCase())
@@ -2957,7 +2993,7 @@ async function Ns(e, t, r) {
2957
2993
  );
2958
2994
  }
2959
2995
  }
2960
- async function Vn(e) {
2996
+ async function Rn(e) {
2961
2997
  const {
2962
2998
  vaultIds: t,
2963
2999
  depositorEthAddress: r,
@@ -2988,7 +3024,7 @@ async function Vn(e) {
2988
3024
  depositorSignedPeginTxHex: v.depositorSignedPeginTxHex,
2989
3025
  observed: v.observed,
2990
3026
  expectedValue: v.expectedClaimValue
2991
- })), d = Wr(n, h.length), g = h.reduce((v, E) => v + E.expectedValue, 0n), p = g * gt / ft;
3027
+ })), d = Yr(n, h.length), g = h.reduce((v, E) => v + E.expectedValue, 0n), p = g * gt / ft;
2992
3028
  if (d > p)
2993
3029
  throw new ht(
2994
3030
  `Reclaim fee ${d} sats exceeds ${gt}/${ft} of the swept total (${g} sats, cap ${p} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
@@ -2996,7 +3032,7 @@ async function Vn(e) {
2996
3032
  g
2997
3033
  );
2998
3034
  u == null || u.throwIfAborted();
2999
- const { psbtHex: y } = Yr({
3035
+ const { psbtHex: y } = Qr({
3000
3036
  depositorPubkey: c,
3001
3037
  inputs: h,
3002
3038
  feeSats: d
@@ -3005,14 +3041,14 @@ async function Vn(e) {
3005
3041
  const f = ce(
3006
3042
  o,
3007
3043
  h.length
3008
- ), m = await a(y, f);
3044
+ ), b = await a(y, f);
3009
3045
  ae({
3010
3046
  requestedPsbtHex: y,
3011
- returnedPsbtHex: m
3047
+ returnedPsbtHex: b
3012
3048
  });
3013
3049
  const $ = h.map((v, E) => {
3014
3050
  const T = ue(
3015
- m,
3051
+ b,
3016
3052
  c,
3017
3053
  E
3018
3054
  );
@@ -3033,39 +3069,39 @@ export {
3033
3069
  Sn as $,
3034
3070
  K as A,
3035
3071
  fn as B,
3036
- uo as C,
3037
- F as D,
3072
+ co as C,
3073
+ U as D,
3038
3074
  is as E,
3039
3075
  yn as F,
3040
- P as G,
3076
+ m as G,
3041
3077
  gs as H,
3042
3078
  vn as I,
3043
3079
  Se as J,
3044
- mn as K,
3045
- Pn as L,
3080
+ bn as K,
3081
+ mn as L,
3046
3082
  wn as M,
3047
3083
  xn as N,
3048
3084
  $n as O,
3049
- lo as P,
3085
+ ho as P,
3050
3086
  kn as Q,
3051
3087
  En as R,
3052
3088
  Y as S,
3053
3089
  Cs as T,
3054
3090
  Ts as U,
3055
- fo as V,
3056
- jt as W,
3091
+ yo as V,
3092
+ Wt as W,
3057
3093
  Cn as X,
3058
3094
  Tn as Y,
3059
- Wt as Z,
3095
+ Yt as Z,
3060
3096
  _n as _,
3061
3097
  nn as a,
3062
- Xt as a0,
3063
- bn as a1,
3098
+ zt as a0,
3099
+ Pn as a1,
3064
3100
  $e as a2,
3065
3101
  ks as a3,
3066
3102
  nt as a4,
3067
- qo as a5,
3068
- Fo as a6,
3103
+ Dt as a5,
3104
+ qo as a6,
3069
3105
  Nt as a7,
3070
3106
  Bs as a8,
3071
3107
  Bn as a9,
@@ -3074,36 +3110,37 @@ export {
3074
3110
  lt as ac,
3075
3111
  ct as ad,
3076
3112
  Jt as ae,
3077
- ht as af,
3078
- Vn as ag,
3079
- ft as ah,
3080
- gt as ai,
3081
- pt as aj,
3082
- In as ak,
3113
+ In as af,
3114
+ ht as ag,
3115
+ Rn as ah,
3116
+ ft as ai,
3117
+ gt as aj,
3118
+ pt as ak,
3119
+ Vn as al,
3083
3120
  an as b,
3084
3121
  un as c,
3085
3122
  ln as d,
3086
- So as e,
3087
- io as f,
3088
- co as g,
3123
+ Ao as e,
3124
+ ao as f,
3125
+ lo as g,
3089
3126
  dn as h,
3090
- ho as i,
3127
+ po as i,
3091
3128
  ne as j,
3092
- go as k,
3129
+ fo as k,
3093
3130
  bo as l,
3094
3131
  cn as m,
3095
- Bo as n,
3096
- Oo as o,
3097
- Co as p,
3098
- Vo as q,
3132
+ Io as n,
3133
+ No as o,
3134
+ To as p,
3135
+ Ro as q,
3099
3136
  hn as r,
3100
- wo as s,
3137
+ xo as s,
3101
3138
  St as t,
3102
3139
  Go as u,
3103
- Dt as v,
3104
- Lt as w,
3140
+ Lt as v,
3141
+ Mt as w,
3105
3142
  Wo as x,
3106
3143
  pn as y,
3107
3144
  gn as z
3108
3145
  };
3109
- //# sourceMappingURL=buildAndBroadcastReclaim-XRWuJWVL.js.map
3146
+ //# sourceMappingURL=buildAndBroadcastReclaim-DU8iOtbn.js.map