@babylonlabs-io/ts-sdk 3.0.0 → 3.0.2

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 (112) hide show
  1. package/dist/{PeginManager-CKf7Bjmj.js → PeginManager-D8WGB8eN.js} +2 -2
  2. package/dist/{PeginManager-CKf7Bjmj.js.map → PeginManager-D8WGB8eN.js.map} +1 -1
  3. package/dist/{PeginManager-Dt2Z5ljw.cjs → PeginManager-IgDHy_eU.cjs} +2 -2
  4. package/dist/{PeginManager-Dt2Z5ljw.cjs.map → PeginManager-IgDHy_eU.cjs.map} +1 -1
  5. package/dist/buildAndBroadcastReclaim-B8aFMGf-.cjs +2 -0
  6. package/dist/buildAndBroadcastReclaim-B8aFMGf-.cjs.map +1 -0
  7. package/dist/{buildAndBroadcastReclaim-T5ZFPUpM.js → buildAndBroadcastReclaim-D5520lbL.js} +1015 -935
  8. package/dist/buildAndBroadcastReclaim-D5520lbL.js.map +1 -0
  9. package/dist/index-D2mybjXD.js +522 -0
  10. package/dist/index-D2mybjXD.js.map +1 -0
  11. package/dist/index-MRdle0fs.cjs +2 -0
  12. package/dist/index-MRdle0fs.cjs.map +1 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.js +215 -214
  15. package/dist/pegin-registration-client-B0j6ugt9.cjs +2 -0
  16. package/dist/pegin-registration-client-B0j6ugt9.cjs.map +1 -0
  17. package/dist/{pegin-registration-client-C5Hktrja.js → pegin-registration-client-ilkV1mLP.js} +103 -88
  18. package/dist/pegin-registration-client-ilkV1mLP.js.map +1 -0
  19. package/dist/primeVpAuth-BDWBKYhv.cjs +2 -0
  20. package/dist/primeVpAuth-BDWBKYhv.cjs.map +1 -0
  21. package/dist/primeVpAuth-D0ZnsjRi.js +805 -0
  22. package/dist/primeVpAuth-D0ZnsjRi.js.map +1 -0
  23. package/dist/state-C4WoNCy1.cjs +2 -0
  24. package/dist/state-C4WoNCy1.cjs.map +1 -0
  25. package/dist/{state-mE-QfITd.js → state-CFn1rT74.js} +128 -101
  26. package/dist/state-CFn1rT74.js.map +1 -0
  27. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  28. package/dist/tbv/core/clients/eth/index.js +2 -2
  29. package/dist/tbv/core/clients/eth/types.d.ts +12 -5
  30. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  31. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +12 -3
  32. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  33. package/dist/tbv/core/clients/index.cjs +1 -1
  34. package/dist/tbv/core/clients/index.js +52 -51
  35. package/dist/tbv/core/clients/mempool/index.cjs +1 -1
  36. package/dist/tbv/core/clients/mempool/index.cjs.map +1 -1
  37. package/dist/tbv/core/clients/mempool/index.d.ts +1 -1
  38. package/dist/tbv/core/clients/mempool/index.d.ts.map +1 -1
  39. package/dist/tbv/core/clients/mempool/index.js +85 -71
  40. package/dist/tbv/core/clients/mempool/index.js.map +1 -1
  41. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts +10 -0
  42. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
  43. package/dist/tbv/core/clients/vault-provider/api.d.ts +17 -14
  44. package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
  45. package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts +8 -0
  46. package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts.map +1 -1
  47. package/dist/tbv/core/clients/vault-provider/auth/index.d.ts +1 -1
  48. package/dist/tbv/core/clients/vault-provider/auth/index.d.ts.map +1 -1
  49. package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts +8 -0
  50. package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts.map +1 -1
  51. package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts +18 -2
  52. package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts.map +1 -1
  53. package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts +26 -6
  54. package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts.map +1 -1
  55. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts +17 -15
  56. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts.map +1 -1
  57. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts +15 -9
  58. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts.map +1 -1
  59. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +3 -2
  60. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  61. package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
  62. package/dist/tbv/core/clients/vault-provider/status/index.js +2 -2
  63. package/dist/tbv/core/clients/vault-provider/types.d.ts +36 -23
  64. package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
  65. package/dist/tbv/core/clients/vault-provider/validators.d.ts +12 -4
  66. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  67. package/dist/tbv/core/index.cjs +1 -1
  68. package/dist/tbv/core/index.js +213 -212
  69. package/dist/tbv/core/managers/index.cjs +1 -1
  70. package/dist/tbv/core/managers/index.js +1 -1
  71. package/dist/tbv/core/services/deposit/graphFingerprint.d.ts +39 -0
  72. package/dist/tbv/core/services/deposit/graphFingerprint.d.ts.map +1 -1
  73. package/dist/tbv/core/services/deposit/interfaces.d.ts +2 -2
  74. package/dist/tbv/core/services/deposit/interfaces.d.ts.map +1 -1
  75. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +3 -1
  76. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  77. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  78. package/dist/tbv/core/services/deposit/submitWotsPublicKey.d.ts +3 -1
  79. package/dist/tbv/core/services/deposit/submitWotsPublicKey.d.ts.map +1 -1
  80. package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts +11 -2
  81. package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -1
  82. package/dist/tbv/core/services/index.cjs +1 -1
  83. package/dist/tbv/core/services/index.js +2 -2
  84. package/dist/tbv/core/services/pegout/state.d.ts +2 -2
  85. package/dist/tbv/index.cjs +1 -1
  86. package/dist/tbv/index.js +213 -212
  87. package/dist/{toRefundInputs-DIIdhjvu.js → toRefundInputs-10RYIfh1.js} +2 -2
  88. package/dist/{toRefundInputs-DIIdhjvu.js.map → toRefundInputs-10RYIfh1.js.map} +1 -1
  89. package/dist/{toRefundInputs-B_GlIXjk.cjs → toRefundInputs-a-0HRyrl.cjs} +2 -2
  90. package/dist/{toRefundInputs-B_GlIXjk.cjs.map → toRefundInputs-a-0HRyrl.cjs.map} +1 -1
  91. package/dist/{types-DJxOEU3P.cjs → types-BueQoMjO.cjs} +2 -2
  92. package/dist/{types-DJxOEU3P.cjs.map → types-BueQoMjO.cjs.map} +1 -1
  93. package/dist/{types-Dz1kVqn6.js → types-DGkejGZH.js} +2 -2
  94. package/dist/{types-Dz1kVqn6.js.map → types-DGkejGZH.js.map} +1 -1
  95. package/package.json +3 -3
  96. package/dist/buildAndBroadcastReclaim-BDc-SK9i.cjs +0 -2
  97. package/dist/buildAndBroadcastReclaim-BDc-SK9i.cjs.map +0 -1
  98. package/dist/buildAndBroadcastReclaim-T5ZFPUpM.js.map +0 -1
  99. package/dist/index-B6w5MM-8.js +0 -528
  100. package/dist/index-B6w5MM-8.js.map +0 -1
  101. package/dist/index-EHLYplSd.cjs +0 -2
  102. package/dist/index-EHLYplSd.cjs.map +0 -1
  103. package/dist/pegin-registration-client-BdJ6c7si.cjs +0 -2
  104. package/dist/pegin-registration-client-BdJ6c7si.cjs.map +0 -1
  105. package/dist/pegin-registration-client-C5Hktrja.js.map +0 -1
  106. package/dist/primeVpAuth-Bdy_B_Sq.js +0 -745
  107. package/dist/primeVpAuth-Bdy_B_Sq.js.map +0 -1
  108. package/dist/primeVpAuth-CQRsu6VB.cjs +0 -2
  109. package/dist/primeVpAuth-CQRsu6VB.cjs.map +0 -1
  110. package/dist/state-DMFlvLL3.cjs +0 -2
  111. package/dist/state-DMFlvLL3.cjs.map +0 -1
  112. package/dist/state-mE-QfITd.js.map +0 -1
@@ -1,81 +1,81 @@
1
- var at = Object.defineProperty;
2
- var it = (e, t, r) => t in e ? at(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var O = (e, t, r) => it(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { B as Ne } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
5
- import { e as He, s as f, i as ut, c as $, v as ct, u as Ke, p as j, f as V } from "./bitcoin-C-TuHb-v.js";
6
- import { v as lt, d as De, s as ht, P as pt, a as dt } from "./PayoutManager-BSwbUQeF.js";
7
- import { Buffer as I } from "buffer";
8
- import { b as gt, a as M, c as ft } from "./signing-Dhr2t0Z6.js";
9
- import { buildClaimPsbt as yt, buildAssertClaimerPsbt as bt, buildPayoutClaimerPsbt as mt, buildWronglyChallengedPsbts as Pt, buildPayoutDepositorPsbt as vt, finalizeClaimTx as wt, buildWatchtowerArtifacts as xt, extractTapScriptSig as Et, expandWotsSeed as kt, wotsKeypairFromSeed as _t, validateWotsKeypairAgainstGraph as Tt, verifyWatchtowerArtifacts as $t, deriveVaultId as Ct } from "./tbv/core/wasm/index.js";
10
- import { p as Me, P as le, f as At, i as F, g as U, j as L } from "./verifyScriptPathSchnorrSignature-CpjSTfMj.js";
11
- import { Psbt as Fe, Transaction as B } from "bitcoinjs-lib";
12
- import { m as he, n as pe, N as q, o as de, D as ge } from "./constants-D5vORbQE.js";
13
- import { d as St } from "./deriveVaultRoot-BcvmER1E.js";
14
- import { d as It, a as fe } from "./onChainBtcPubkey-CCTdl53s.js";
15
- import { zeroAddress as Rt, isAddress as Bt, isAddressEqual as Vt } from "viem";
16
- import { D as R, c as Ot, b as Nt, R as Ht, d as Ue } from "./state-mE-QfITd.js";
17
- import { h as ye, b as Kt, s as Dt, j as Mt } from "./sha2-YqVHJiFj.js";
18
- import { d as Ft, c as Ut, b as Lt, f as Le, e as Gt, a as Xt } from "./noPayout-qBXWKwav.js";
19
- import { a as jt } from "./secp256k1-D-H9jmd7.js";
20
- const qt = /^0x[0-9a-fA-F]{64}$/, zt = /^0x[0-9a-fA-F]{40}$/, Wt = /^0x([0-9a-fA-F]{2})*$/;
21
- function z(e, t) {
1
+ var dt = Object.defineProperty;
2
+ var gt = (e, t, r) => t in e ? dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var K = (e, t, r) => gt(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { B as Me } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
5
+ import { e as Fe, s as b, i as ft, c as C, v as yt, u as Le, p as Q, f as H } from "./bitcoin-C-TuHb-v.js";
6
+ import { v as bt, d as Ue, s as mt, P as vt, a as Pt } from "./PayoutManager-BSwbUQeF.js";
7
+ import { Buffer as A } from "buffer";
8
+ import { b as xt, a as U, c as wt } from "./signing-Dhr2t0Z6.js";
9
+ import { buildClaimPsbt as Et, buildAssertClaimerPsbt as _t, buildPayoutClaimerPsbt as kt, buildWronglyChallengedPsbts as Tt, buildPayoutDepositorPsbt as $t, finalizeClaimTx as Ct, buildWatchtowerArtifacts as At, extractTapScriptSig as St, expandWotsSeed as It, wotsKeypairFromSeed as Rt, validateWotsKeypairAgainstGraph as Bt, verifyWatchtowerArtifacts as Vt, deriveVaultId as Ht } from "./tbv/core/wasm/index.js";
10
+ import { p as Ge, P as G, f as Ot, i as X, g as q, j } from "./verifyScriptPathSchnorrSignature-CpjSTfMj.js";
11
+ import { Psbt as Xe, Transaction as B } from "bitcoinjs-lib";
12
+ import { m as ge, n as fe, N as J, o as ye, D as be } from "./constants-D5vORbQE.js";
13
+ import { d as Nt } from "./deriveVaultRoot-BcvmER1E.js";
14
+ import { d as Kt, a as me } from "./onChainBtcPubkey-CCTdl53s.js";
15
+ import { zeroAddress as Dt, isAddress as Mt, isAddressEqual as Ft } from "viem";
16
+ import { v as ve, D as R, c as Lt, b as Ut, R as Gt, d as qe } from "./state-CFn1rT74.js";
17
+ import { h as Pe, b as Xt, s as qt, j as jt } from "./sha2-YqVHJiFj.js";
18
+ import { d as zt, c as Wt, b as Yt, f as je, e as Qt, a as Jt } from "./noPayout-qBXWKwav.js";
19
+ import { a as Zt } from "./secp256k1-D-H9jmd7.js";
20
+ const er = /^0x[0-9a-fA-F]{64}$/, tr = /^0x[0-9a-fA-F]{40}$/, rr = /^0x([0-9a-fA-F]{2})*$/;
21
+ function Z(e, t) {
22
22
  if (e.length !== 66)
23
23
  throw new Error(
24
24
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
25
25
  );
26
- if (!qt.test(e))
26
+ if (!er.test(e))
27
27
  throw new Error(
28
28
  `${t} must contain only hex characters after the 0x prefix`
29
29
  );
30
30
  }
31
- function Yt(e, t) {
32
- if (!zt.test(e))
31
+ function or(e, t) {
32
+ if (!tr.test(e))
33
33
  throw new Error(
34
34
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
35
35
  );
36
36
  }
37
- function Qt(e, t) {
38
- if (!Wt.test(e))
37
+ function nr(e, t) {
38
+ if (!rr.test(e))
39
39
  throw new Error(
40
40
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
41
41
  );
42
42
  }
43
- function Ge(e) {
44
- Yt(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), z(e.vaultId, "vaultId");
45
- const t = He(e.secret);
46
- if (z(t, "secret"), e.hashlock !== void 0 && (z(e.hashlock, "hashlock"), !lt(t, e.hashlock)))
43
+ function ze(e) {
44
+ or(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), Z(e.vaultId, "vaultId");
45
+ const t = Fe(e.secret);
46
+ if (Z(t, "secret"), e.hashlock !== void 0 && (Z(e.hashlock, "hashlock"), !bt(t, e.hashlock)))
47
47
  throw new Error(
48
48
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
49
49
  );
50
50
  return t;
51
51
  }
52
- async function Bo(e) {
52
+ async function Uo(e) {
53
53
  const {
54
54
  btcVaultRegistryAddress: t,
55
55
  vaultId: r,
56
56
  hashlock: o,
57
57
  activationMetadata: n,
58
- writeContract: a,
59
- signal: s
58
+ writeContract: i,
59
+ signal: a
60
60
  } = e;
61
- s == null || s.throwIfAborted();
62
- const i = Ge({
61
+ a == null || a.throwIfAborted();
62
+ const s = ze({
63
63
  btcVaultRegistryAddress: t,
64
64
  vaultId: r,
65
65
  secret: e.secret,
66
66
  hashlock: o
67
67
  });
68
- return Qt(n, "activationMetadata"), a({
68
+ return nr(n, "activationMetadata"), i({
69
69
  address: t,
70
- abi: Ne,
70
+ abi: Me,
71
71
  functionName: "activateVaultWithSecret",
72
- args: [r, i, n]
72
+ args: [r, s, n]
73
73
  });
74
74
  }
75
- async function Vo(e) {
76
- const { btcVaultRegistryAddress: t, vaultId: r, hashlock: o, writeContract: n, signal: a } = e;
77
- a == null || a.throwIfAborted();
78
- const s = Ge({
75
+ async function Go(e) {
76
+ const { btcVaultRegistryAddress: t, vaultId: r, hashlock: o, writeContract: n, signal: i } = e;
77
+ i == null || i.throwIfAborted();
78
+ const a = ze({
79
79
  btcVaultRegistryAddress: t,
80
80
  vaultId: r,
81
81
  secret: e.secret,
@@ -83,201 +83,201 @@ async function Vo(e) {
83
83
  });
84
84
  return n({
85
85
  address: t,
86
- abi: Ne,
86
+ abi: Me,
87
87
  functionName: "activateVaultWithSecretAndRedeem",
88
- args: [r, s]
88
+ args: [r, a]
89
89
  });
90
90
  }
91
- class Jt extends Error {
91
+ class sr extends Error {
92
92
  constructor(t, r) {
93
93
  super(
94
94
  "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."
95
95
  ), this.missing = t, this.unexpected = r, this.name = "ChallengerSetMismatchError";
96
96
  }
97
97
  }
98
- function Zt(e) {
99
- const t = Me({
98
+ function ar(e) {
99
+ const t = Ge({
100
100
  claimerBtcPubkey: e.depositorBtcPubkey,
101
101
  depositorBtcPubkey: e.depositorBtcPubkey,
102
102
  vaultProviderBtcPubkey: e.vaultProviderBtcPubkey,
103
103
  vaultKeeperBtcPubkeys: e.vaultKeeperBtcPubkeys
104
- }), r = e.universalChallengerBtcPubkeys.map(be), o = t.filter((h) => r.includes(h));
104
+ }), r = e.universalChallengerBtcPubkeys.map(xe), o = t.filter((c) => r.includes(c));
105
105
  if (o.length > 0)
106
106
  throw new Error(
107
107
  `Cannot check the challenger set: vault keepers and universal challengers overlap (${o.join(", ")}).`
108
108
  );
109
- const n = e.graphChallengerPubkeys.map(be), a = new Set(n);
110
- if (a.size !== n.length)
109
+ const n = e.graphChallengerPubkeys.map(xe), i = new Set(n);
110
+ if (i.size !== n.length)
111
111
  throw new Error(
112
112
  "Transaction graph lists the same challenger more than once."
113
113
  );
114
- const s = [...t, ...r], i = new Set(s), u = s.filter((h) => !a.has(h)), c = n.filter((h) => !i.has(h));
115
- if (u.length > 0 || c.length > 0)
116
- throw new Jt(u, c);
114
+ const a = [...t, ...r], s = new Set(a), u = a.filter((c) => !i.has(c)), l = n.filter((c) => !s.has(c));
115
+ if (u.length > 0 || l.length > 0)
116
+ throw new sr(u, l);
117
117
  }
118
- function be(e) {
119
- return f(e).toLowerCase();
118
+ function xe(e) {
119
+ return b(e).toLowerCase();
120
120
  }
121
- const Xe = 0;
122
- class er extends Error {
121
+ const We = 0;
122
+ class ir extends Error {
123
123
  constructor(t, r) {
124
124
  super(
125
- `Payout transaction output ${Xe} pays ${r}, not the vault's registered payout script ${t}. Refusing to sign a payout to another destination.`
125
+ `Payout transaction output ${We} pays ${r}, not the vault's registered payout script ${t}. Refusing to sign a payout to another destination.`
126
126
  ), this.expectedScriptHex = t, this.actualScriptHex = r, this.name = "PayoutDestinationError";
127
127
  }
128
128
  }
129
- function tr(e) {
129
+ function ur(e) {
130
130
  let t;
131
131
  try {
132
- t = Fe.fromBase64(e.payoutPsbtBase64);
132
+ t = Xe.fromBase64(e.payoutPsbtBase64);
133
133
  } catch (u) {
134
134
  throw new Error("Payout PSBT cannot be parsed.", { cause: u });
135
135
  }
136
- const { version: r, locktime: o, outs: n } = rr(t);
137
- if (r !== he || o !== pe)
136
+ const { version: r, locktime: o, outs: n } = cr(t);
137
+ if (r !== ge || o !== fe)
138
138
  throw new Error(
139
- `Payout transaction has version ${r} and locktime ${o}, expected ${he} and ${pe}.`
139
+ `Payout transaction has version ${r} and locktime ${o}, expected ${ge} and ${fe}.`
140
140
  );
141
- if (n.length !== q)
141
+ if (n.length !== J)
142
142
  throw new Error(
143
- `Payout transaction has ${n.length} output(s), expected exactly ${q} for a depositor-as-claimer payout.`
143
+ `Payout transaction has ${n.length} output(s), expected exactly ${J} for a depositor-as-claimer payout.`
144
144
  );
145
- const a = f(
145
+ const i = b(
146
146
  e.registeredPayoutScriptPubKey
147
147
  ).toLowerCase();
148
- if (a.length === 0)
148
+ if (i.length === 0)
149
149
  throw new Error(
150
150
  "registeredPayoutScriptPubKey is empty; the vault's on-chain payout script is required to check the Payout destination."
151
151
  );
152
- const s = n[Xe].script.toString("hex").toLowerCase();
153
- if (!I.from(s, "hex").equals(I.from(a, "hex")))
154
- throw new er(a, s);
155
- const i = n[q - 1];
156
- if (i.value !== de)
152
+ const a = n[We].script.toString("hex").toLowerCase();
153
+ if (!A.from(a, "hex").equals(A.from(i, "hex")))
154
+ throw new ir(i, a);
155
+ const s = n[J - 1];
156
+ if (s.value !== ye)
157
157
  throw new Error(
158
- `Payout CPFP anchor value ${i.value} sats must equal ${de} sats.`
158
+ `Payout CPFP anchor value ${s.value} sats must equal ${ye} sats.`
159
159
  );
160
160
  }
161
- function rr(e) {
161
+ function cr(e) {
162
162
  return {
163
163
  version: e.version,
164
164
  locktime: e.locktime,
165
165
  outs: e.txOutputs.map((t) => ({
166
- script: I.from(t.script),
166
+ script: A.from(t.script),
167
167
  value: t.value
168
168
  }))
169
169
  };
170
170
  }
171
- const je = 0;
172
- class or extends Error {
171
+ const Ye = 0;
172
+ class lr extends Error {
173
173
  constructor(t, r, o) {
174
174
  super(
175
175
  `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.`
176
176
  ), this.expectedVaultId = t, this.derivedVaultId = r, this.peginTxid = o, this.name = "VaultIdBindingError";
177
177
  }
178
178
  }
179
- function nr(e) {
179
+ function hr(e) {
180
180
  let t;
181
181
  try {
182
- t = Fe.fromBase64(e);
182
+ t = Xe.fromBase64(e);
183
183
  } catch (o) {
184
184
  throw new Error("Claim PSBT cannot be parsed.", { cause: o });
185
185
  }
186
- const r = t.txInputs[je];
186
+ const r = t.txInputs[Ye];
187
187
  if (!r)
188
188
  throw new Error("Claim PSBT carries no PegIn input to bind the vault to.");
189
- return ze(r.hash);
189
+ return Je(r.hash);
190
190
  }
191
- function sr(e) {
192
- const t = e.ins[je];
191
+ function pr(e) {
192
+ const t = e.ins[Ye];
193
193
  if (!t)
194
194
  throw new Error(
195
195
  "Artifacts file's claim_tx carries no PegIn input to bind the vault to."
196
196
  );
197
- return ze(t.hash);
197
+ return Je(t.hash);
198
198
  }
199
- function qe(e) {
200
- const t = G(
201
- It(e.peginTxid, e.depositorEthAddress)
202
- ), r = G(e.expectedVaultId);
199
+ function Qe(e) {
200
+ const t = z(
201
+ Kt(e.peginTxid, e.depositorEthAddress)
202
+ ), r = z(e.expectedVaultId);
203
203
  if (t !== r)
204
- throw new or(r, t, e.peginTxid);
204
+ throw new lr(r, t, e.peginTxid);
205
205
  }
206
- function G(e) {
206
+ function z(e) {
207
207
  return `0x${(e.startsWith("0x") ? e.slice(2) : e).toLowerCase()}`;
208
208
  }
209
- function ze(e) {
210
- return I.from(e).reverse().toString("hex");
211
- }
212
- const ar = 0, ir = 0, ur = 1, cr = 0, lr = 0;
213
- async function Oo(e) {
214
- const { txGraphVersion: t } = e.vault, r = e.source.txGraphJson, [o, n, a, s] = await Promise.all([
215
- yt(t, r),
216
- bt(t, r),
217
- mt(t, r),
218
- Pt(t, r)
209
+ function Je(e) {
210
+ return A.from(e).reverse().toString("hex");
211
+ }
212
+ const dr = 0, gr = 0, fr = 1, yr = 0, br = 0;
213
+ async function Xo(e) {
214
+ const { txGraphVersion: t } = e.vault, r = e.source.txGraphJson, [o, n, i, a] = await Promise.all([
215
+ Et(t, r),
216
+ _t(t, r),
217
+ kt(t, r),
218
+ Tt(t, r)
219
219
  ]);
220
- qe({
221
- peginTxid: nr(o),
220
+ Qe({
221
+ peginTxid: hr(o),
222
222
  depositorEthAddress: e.vault.depositorEthAddress,
223
223
  expectedVaultId: e.vault.vaultId
224
224
  });
225
- const i = await vt(
225
+ const s = await $t(
226
226
  t,
227
227
  r
228
228
  );
229
- for (const x of [a, i])
230
- tr({
229
+ for (const x of [i, s])
230
+ ur({
231
231
  payoutPsbtBase64: x,
232
232
  registeredPayoutScriptPubKey: e.vault.registeredPayoutScriptPubKey
233
233
  });
234
- Zt({
235
- graphChallengerPubkeys: Object.keys(s),
234
+ ar({
235
+ graphChallengerPubkeys: Object.keys(a),
236
236
  depositorBtcPubkey: e.depositorPublicKey,
237
237
  vaultProviderBtcPubkey: e.vault.vaultProviderBtcPubkey,
238
238
  vaultKeeperBtcPubkeys: e.vault.vaultKeeperBtcPubkeys,
239
239
  universalChallengerBtcPubkeys: e.vault.universalChallengerBtcPubkeys
240
240
  });
241
241
  const u = [
242
- { psbtBase64: o, inputIndex: ar },
243
- { psbtBase64: n, inputIndex: ir },
244
- { psbtBase64: a, inputIndex: ur },
242
+ { psbtBase64: o, inputIndex: dr },
243
+ { psbtBase64: n, inputIndex: gr },
244
+ { psbtBase64: i, inputIndex: fr },
245
245
  {
246
- psbtBase64: i,
247
- inputIndex: cr
246
+ psbtBase64: s,
247
+ inputIndex: yr
248
248
  }
249
- ], c = Object.keys(s);
250
- for (const x of c)
251
- for (const w of s[x])
252
- u.push({ psbtBase64: w, inputIndex: lr });
253
- const h = await pr(
249
+ ], l = Object.keys(a);
250
+ for (const x of l)
251
+ for (const w of a[x])
252
+ u.push({ psbtBase64: w, inputIndex: br });
253
+ const c = await vr(
254
254
  e.btcWallet,
255
255
  e.depositorPublicKey,
256
256
  e.btcNetwork,
257
257
  u
258
258
  );
259
- let l = 0;
260
- const p = h[l++], d = h[l++], g = h[l++], b = h[l++], y = {};
261
- for (const x of c) {
262
- const w = s[x].length;
263
- y[x] = h.slice(
264
- l,
265
- l + w
266
- ), l += w;
259
+ let h = 0;
260
+ const p = c[h++], d = c[h++], g = c[h++], y = c[h++], f = {};
261
+ for (const x of l) {
262
+ const w = a[x].length;
263
+ f[x] = c.slice(
264
+ h,
265
+ h + w
266
+ ), h += w;
267
267
  }
268
- const m = await wt(
268
+ const P = await Ct(
269
269
  t,
270
270
  r,
271
271
  p
272
272
  );
273
- return xt({
273
+ return At({
274
274
  txGraphVersion: t,
275
275
  graphJson: r,
276
- signedClaimTxHex: m,
276
+ signedClaimTxHex: P,
277
277
  assertClaimerSigHex: d,
278
278
  payoutClaimerSigHex: g,
279
- wronglyChallengedSigs: y,
280
- depositorPayoutSigHex: b,
279
+ wronglyChallengedSigs: f,
280
+ depositorPayoutSigHex: y,
281
281
  verifyingKeyHex: e.source.verifyingKeyHex,
282
282
  claimableEventBlockNumber: e.vault.claimableEventBlockNumber,
283
283
  proverCircuitVersion: e.vault.proverCircuitVersion,
@@ -286,7 +286,7 @@ async function Oo(e) {
286
286
  expectedVaultCoreVersion: e.vault.vaultCoreVersion
287
287
  });
288
288
  }
289
- function me(e) {
289
+ function we(e) {
290
290
  const t = e.replace(/^0x/, "").toLowerCase();
291
291
  if (t.length === 66) return t.slice(2);
292
292
  if (t.length === 64) return t;
@@ -294,62 +294,62 @@ function me(e) {
294
294
  `Public key must be 33-byte compressed or 32-byte x-only hex, got ${t.length / 2} bytes.`
295
295
  );
296
296
  }
297
- async function hr(e, t, r) {
297
+ async function mr(e, t, r) {
298
298
  const o = await e.getPublicKeyHex();
299
- if (me(o) !== me(t))
299
+ if (we(o) !== we(t))
300
300
  throw new Error(
301
301
  "Connected wallet does not hold the vault's depositor key. Select the account that made the deposit, then try again."
302
302
  );
303
303
  const n = await e.getAddress();
304
- if (!ut(n, t, r))
304
+ if (!ft(n, t, r))
305
305
  throw new Error(
306
306
  `Connected wallet reports address "${n}", which is not derived from the vault's depositor key. Select the account that made the deposit, then try again.`
307
307
  );
308
308
  return n;
309
309
  }
310
- async function pr(e, t, r, o) {
311
- const n = await hr(
310
+ async function vr(e, t, r, o) {
311
+ const n = await mr(
312
312
  e,
313
313
  t,
314
314
  r
315
- ), a = await De(
315
+ ), i = await Ue(
316
316
  e,
317
- o.map((s) => dr(s.psbtBase64)),
317
+ o.map((a) => Pr(a.psbtBase64)),
318
318
  o.map(
319
- (s) => gt(
319
+ (a) => xt(
320
320
  t,
321
- s.inputIndex,
321
+ a.inputIndex,
322
322
  n
323
323
  )
324
324
  )
325
325
  );
326
326
  return Promise.all(
327
- a.map(
328
- (s, i) => Et(gr(s), o[i].inputIndex)
327
+ i.map(
328
+ (a, s) => St(xr(a), o[s].inputIndex)
329
329
  )
330
330
  );
331
331
  }
332
- function dr(e) {
333
- return I.from(e, "base64").toString("hex");
332
+ function Pr(e) {
333
+ return A.from(e, "base64").toString("hex");
334
334
  }
335
- function gr(e) {
336
- return I.from(e, "hex").toString("base64");
335
+ function xr(e) {
336
+ return A.from(e, "hex").toString("base64");
337
337
  }
338
- async function No(e) {
339
- const t = await St(e.btcWallet, e.vaultContext);
338
+ async function qo(e) {
339
+ const t = await Nt(e.btcWallet, e.vaultContext);
340
340
  let r;
341
341
  try {
342
- r = await kt(t, e.htlcVout);
342
+ r = await It(t, e.htlcVout);
343
343
  } finally {
344
344
  t.fill(0);
345
345
  }
346
346
  let o;
347
347
  try {
348
- o = await _t(r);
348
+ o = await Rt(r);
349
349
  } finally {
350
350
  r.fill(0);
351
351
  }
352
- return fr(o.pk_hash, e.expectedWotsPkHash), await Tt(
352
+ return wr(o.pk_hash, e.expectedWotsPkHash), await Bt(
353
353
  e.txGraphVersion,
354
354
  o.keypair,
355
355
  e.txGraphJson
@@ -358,61 +358,61 @@ async function No(e) {
358
358
  pkHash: o.pk_hash
359
359
  };
360
360
  }
361
- function fr(e, t) {
362
- if (D(e) !== D(t))
361
+ function wr(e, t) {
362
+ if (L(e) !== L(t))
363
363
  throw new Error(
364
- `Derived WOTS public-key hash ${D(e)} does not match the vault's on-chain depositorWotsPkHash ${D(t)}. The wallet, the HTLC output index, or the derivation itself is not the one this vault was created with.`
364
+ `Derived WOTS public-key hash ${L(e)} does not match the vault's on-chain depositorWotsPkHash ${L(t)}. The wallet, the HTLC output index, or the derivation itself is not the one this vault was created with.`
365
365
  );
366
366
  }
367
- function D(e) {
367
+ function L(e) {
368
368
  return `0x${(e.startsWith("0x") ? e.slice(2) : e).toLowerCase()}`;
369
369
  }
370
- const yr = 3;
371
- class br extends Error {
370
+ const Er = 3;
371
+ class _r extends Error {
372
372
  constructor(t, r) {
373
373
  super(
374
374
  `Artifacts belong to vault ${r}, not ${t}. Select the artifacts file saved for this vault.`
375
375
  ), this.expectedVaultId = t, this.actualVaultId = r, this.name = "ArtifactsVaultMismatchError";
376
376
  }
377
377
  }
378
- function mr(e) {
378
+ function kr(e) {
379
379
  let t;
380
380
  try {
381
381
  t = JSON.parse(e);
382
- } catch (s) {
383
- throw new Error("Artifacts file is not valid JSON.", { cause: s });
382
+ } catch (a) {
383
+ throw new Error("Artifacts file is not valid JSON.", { cause: a });
384
384
  }
385
- const r = Pe(t.vault_id, "vault_id"), o = Pr(Pe(t.claim_tx, "claim_tx")), n = W(
385
+ const r = Ee(t.vault_id, "vault_id"), o = Tr(Ee(t.claim_tx, "claim_tx")), n = ee(
386
386
  t.prover_circuit_version,
387
387
  "prover_circuit_version"
388
- ), a = t.claimable_event_block_number === void 0 ? 0n : BigInt(
389
- W(
388
+ ), i = t.claimable_event_block_number === void 0 ? 0n : BigInt(
389
+ ee(
390
390
  t.claimable_event_block_number,
391
391
  "claimable_event_block_number"
392
392
  )
393
393
  );
394
394
  return {
395
- vaultCoreVersion: t.vault_core_version === void 0 ? void 0 : W(t.vault_core_version, "vault_core_version"),
395
+ vaultCoreVersion: t.vault_core_version === void 0 ? void 0 : ee(t.vault_core_version, "vault_core_version"),
396
396
  vaultId: r,
397
397
  claimTxid: o.getId(),
398
- peginTxid: sr(o),
398
+ peginTxid: pr(o),
399
399
  proverCircuitVersion: n,
400
- claimableEventBlockNumber: a,
400
+ claimableEventBlockNumber: i,
401
401
  babeSessionChallengerPubkeys: Object.keys(
402
- vr(t.babe_sessions, "babe_sessions")
402
+ $r(t.babe_sessions, "babe_sessions")
403
403
  )
404
404
  };
405
405
  }
406
- async function Ho(e) {
407
- const t = mr(e.artifactsJson), r = G(e.expectedVaultId), o = G(t.vaultId);
406
+ async function jo(e) {
407
+ const t = kr(e.artifactsJson), r = z(e.expectedVaultId), o = z(t.vaultId);
408
408
  if (r !== o)
409
- throw new br(r, o);
410
- qe({
409
+ throw new _r(r, o);
410
+ Qe({
411
411
  peginTxid: t.peginTxid,
412
412
  depositorEthAddress: e.depositorEthAddress,
413
413
  expectedVaultId: r
414
414
  });
415
- const n = e.txGraphVersion ?? yr;
415
+ const n = e.txGraphVersion ?? Er;
416
416
  if (t.vaultCoreVersion !== void 0 && t.vaultCoreVersion !== n)
417
417
  throw new Error(
418
418
  `Artifacts record vault core version ${t.vaultCoreVersion}, but verification was asked for version ${n}.`
@@ -421,9 +421,9 @@ async function Ho(e) {
421
421
  throw new Error(
422
422
  "Artifacts carry no claimable event block number. They were assembled before the Ethereum withdrawal was initiated; assemble them again."
423
423
  );
424
- return await $t(n, e.artifactsJson), t;
424
+ return await Vt(n, e.artifactsJson), t;
425
425
  }
426
- function Pr(e) {
426
+ function Tr(e) {
427
427
  try {
428
428
  return B.fromHex(e);
429
429
  } catch (t) {
@@ -432,122 +432,122 @@ function Pr(e) {
432
432
  });
433
433
  }
434
434
  }
435
- function Pe(e, t) {
435
+ function Ee(e, t) {
436
436
  if (typeof e != "string" || e.length === 0)
437
437
  throw new Error(`Artifacts file is missing a usable "${t}".`);
438
438
  return e;
439
439
  }
440
- function W(e, t) {
440
+ function ee(e, t) {
441
441
  if (typeof e != "number" || !Number.isSafeInteger(e) || e < 0)
442
442
  throw new Error(`Artifacts file is missing a usable "${t}".`);
443
443
  return e;
444
444
  }
445
- function vr(e, t) {
445
+ function $r(e, t) {
446
446
  if (e === void 0) return {};
447
447
  if (typeof e != "object" || e === null || Array.isArray(e))
448
448
  throw new Error(`Artifacts file is missing a usable "${t}".`);
449
449
  return e;
450
450
  }
451
- const wr = 8, xr = 6e3, Er = 10 * 6e4, kr = 10;
452
- class We extends Error {
451
+ const Cr = 8, Ar = 6e3, Sr = 10 * 6e4, Ir = 10;
452
+ class Ze extends Error {
453
453
  constructor(t) {
454
454
  super(t), this.name = "PeginRegistrationMissingError";
455
455
  }
456
456
  }
457
- class Ye extends Error {
457
+ class et extends Error {
458
458
  constructor(t) {
459
459
  super(t), this.name = "PeginRegistrationNotFinalError";
460
460
  }
461
461
  }
462
- function _r(e) {
463
- return e instanceof We || e instanceof Error && e.name === "PeginRegistrationMissingError";
462
+ function Rr(e) {
463
+ return e instanceof Ze || e instanceof Error && e.name === "PeginRegistrationMissingError";
464
464
  }
465
- function Ko(e) {
466
- return e instanceof Ye || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
465
+ function zo(e) {
466
+ return e instanceof et || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
467
467
  }
468
- function ve(e) {
468
+ function _e(e) {
469
469
  const { currentBlock: t, createdAtBlock: r } = e, o = t - r + 1n;
470
470
  return o < 0n ? 0 : Number(o);
471
471
  }
472
- async function Do(e) {
472
+ async function Wo(e) {
473
473
  const {
474
474
  vaultRegistryReader: t,
475
475
  getBlockNumber: r,
476
476
  vaultIds: o,
477
- required: n = wr,
478
- pollIntervalMs: a = xr,
479
- timeoutMs: s = Er,
480
- signal: i,
477
+ required: n = Cr,
478
+ pollIntervalMs: i = Ar,
479
+ timeoutMs: a = Sr,
480
+ signal: s,
481
481
  onProgress: u
482
482
  } = e;
483
483
  if (o.length === 0)
484
484
  throw new Error(
485
485
  "waitForPeginRegistrationDepth requires at least one vault ID"
486
486
  );
487
- const c = Date.now();
488
- let h = !1, l = 0, p;
487
+ const l = Date.now();
488
+ let c = !1, h = 0, p;
489
489
  for (; ; ) {
490
- if (i != null && i.aborted)
490
+ if (s != null && s.aborted)
491
491
  throw new Error(
492
492
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
493
493
  );
494
- if (Date.now() - c >= s)
495
- throw new Ye(
496
- `Peg-in registration did not reach ${n} Ethereum confirmations within ${s}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.` + (p instanceof Error ? ` Last read error: ${p.message}` : "")
494
+ if (Date.now() - l >= a)
495
+ throw new et(
496
+ `Peg-in registration did not reach ${n} 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.` + (p instanceof Error ? ` Last read error: ${p.message}` : "")
497
497
  );
498
498
  try {
499
499
  const d = await r(), g = await Promise.all(
500
- o.map((y) => t.getVaultBasicInfo(y))
501
- ), b = g.findIndex(
502
- (y) => y.depositor === Rt || y.createdAt === 0n
500
+ o.map((f) => t.getVaultBasicInfo(f))
501
+ ), y = g.findIndex(
502
+ (f) => f.depositor === Dt || f.createdAt === 0n
503
503
  );
504
- if (b !== -1) {
505
- if (l += 1, !h && l > kr)
506
- throw new We(
507
- `Vault ${o[b]} is still not visible on-chain after ${l} reads — the registration does not exist.`
504
+ if (y !== -1) {
505
+ if (h += 1, !c && h > Ir)
506
+ throw new Ze(
507
+ `Vault ${o[y]} is still not visible on-chain after ${h} reads — the registration does not exist.`
508
508
  );
509
509
  console.warn(
510
- `Peg-in registration for vault ${o[b]} is not visible in chain state at block ${d} — a lagging RPC backend or an Ethereum reorg. Still polling.`
510
+ `Peg-in registration for vault ${o[y]} is not visible in chain state at block ${d} — a lagging RPC backend or an Ethereum reorg. Still polling.`
511
511
  ), u == null || u({ confirmations: 0, required: n });
512
512
  } else {
513
- h = !0, l = 0, p = void 0;
514
- let y = g[0], m = ve({
513
+ c = !0, h = 0, p = void 0;
514
+ let f = g[0], P = _e({
515
515
  currentBlock: d,
516
516
  createdAtBlock: g[0].createdAt
517
517
  });
518
518
  for (const x of g.slice(1)) {
519
- const w = ve({
519
+ const w = _e({
520
520
  currentBlock: d,
521
521
  createdAtBlock: x.createdAt
522
522
  });
523
- w < m && (m = w, y = x);
523
+ w < P && (P = w, f = x);
524
524
  }
525
- if (u == null || u({ confirmations: m, required: n }), m >= n)
526
- return { confirmations: m, basicInfo: y };
525
+ if (u == null || u({ confirmations: P, required: n }), P >= n)
526
+ return { confirmations: P, basicInfo: f };
527
527
  }
528
528
  } catch (d) {
529
- if (_r(d))
529
+ if (Rr(d))
530
530
  throw d;
531
531
  console.warn(
532
- `Registration-depth read failed (retrying in ${a}ms): ` + (d instanceof Error ? d.message : String(d))
532
+ `Registration-depth read failed (retrying in ${i}ms): ` + (d instanceof Error ? d.message : String(d))
533
533
  ), p = d;
534
534
  }
535
535
  await new Promise((d, g) => {
536
- const b = () => {
537
- clearTimeout(y), g(
536
+ const y = () => {
537
+ clearTimeout(f), g(
538
538
  new Error(
539
539
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
540
540
  )
541
541
  );
542
- }, y = setTimeout(() => {
543
- i == null || i.removeEventListener("abort", b), d();
544
- }, a);
545
- i == null || i.addEventListener("abort", b, { once: !0 });
542
+ }, f = setTimeout(() => {
543
+ s == null || s.removeEventListener("abort", y), d();
544
+ }, i);
545
+ s == null || s.addEventListener("abort", y, { once: !0 });
546
546
  });
547
547
  }
548
548
  }
549
- const Tr = /^(?:[0-9a-f]{2})*$/, $r = /^[0-9a-f]{64}$/, Cr = /^([0-9a-f]{64}):(0|[1-9][0-9]*)$/, Ar = -2147483648, Sr = 2147483647, Y = 4294967295, we = 2, xe = 2;
550
- class v extends Error {
549
+ const Br = /^(?:[0-9a-f]{2})*$/, Vr = /^[0-9a-f]{64}$/, Hr = /^([0-9a-f]{64}):(0|[1-9][0-9]*)$/, Or = -2147483648, Nr = 2147483647, te = 4294967295, ke = 2, Te = 2, W = 0;
550
+ class m extends Error {
551
551
  constructor(t) {
552
552
  super(t), this.name = "GraphFingerprintError";
553
553
  }
@@ -555,264 +555,317 @@ class v extends Error {
555
555
  function E(e, t, r) {
556
556
  const o = e[t];
557
557
  if (o === void 0)
558
- throw new v(`Graph tx ${r} is missing "${t}"`);
558
+ throw new m(`Graph tx ${r} is missing "${t}"`);
559
559
  return o;
560
560
  }
561
- function K(e, t) {
561
+ function M(e, t) {
562
562
  if (!Array.isArray(e))
563
- throw new v(`Graph tx ${t} is not an array`);
563
+ throw new m(`Graph tx ${t} is not an array`);
564
564
  return e;
565
565
  }
566
- function A(e, t) {
566
+ function S(e, t) {
567
567
  if (e === null || typeof e != "object" || Array.isArray(e))
568
- throw new v(`Graph tx ${t} is not an object`);
568
+ throw new m(`Graph tx ${t} is not an object`);
569
569
  return e;
570
570
  }
571
- function N(e, t, r, o) {
571
+ function D(e, t, r, o) {
572
572
  if (typeof e != "number" || !Number.isSafeInteger(e) || e < r || e > o)
573
- throw new v(
573
+ throw new m(
574
574
  `Graph tx ${t} is not an integer in [${r}, ${o}]`
575
575
  );
576
576
  return e;
577
577
  }
578
- function Q(e, t) {
579
- if (typeof e != "string" || !Tr.test(e))
580
- throw new v(
578
+ function re(e, t) {
579
+ if (typeof e != "string" || !Br.test(e))
580
+ throw new m(
581
581
  `Graph tx ${t} is not lowercase hex without a prefix`
582
582
  );
583
- return I.from(e, "hex");
583
+ return A.from(e, "hex");
584
584
  }
585
- function X(e, t) {
586
- if (typeof e != "string" || !$r.test(e))
587
- throw new v(
585
+ function Y(e, t) {
586
+ if (typeof e != "string" || !Vr.test(e))
587
+ throw new m(
588
588
  `Graph ${t} is not 32 bytes of lowercase hex`
589
589
  );
590
590
  return e;
591
591
  }
592
- function Ee(e, t) {
593
- const r = A(e, t), o = new B();
594
- return o.version = N(
592
+ function $e(e, t) {
593
+ const r = S(e, t), o = new B();
594
+ return o.version = D(
595
595
  E(r, "version", t),
596
596
  `${t}.version`,
597
- Ar,
598
- Sr
599
- ), o.locktime = N(
597
+ Or,
598
+ Nr
599
+ ), o.locktime = D(
600
600
  E(r, "lock_time", t),
601
601
  `${t}.lock_time`,
602
602
  0,
603
- Y
604
- ), K(E(r, "input", t), `${t}.input`).forEach((n, a) => {
605
- const s = `${t}.input[${a}]`, i = A(n, s), u = E(i, "previous_output", s), c = typeof u == "string" && Cr.exec(u);
606
- if (!c)
607
- throw new v(
608
- `Graph tx ${s}.previous_output is not "<txid>:<vout>"`
603
+ te
604
+ ), M(E(r, "input", t), `${t}.input`).forEach((n, i) => {
605
+ const a = `${t}.input[${i}]`, s = S(n, a), u = E(s, "previous_output", a), l = typeof u == "string" && Hr.exec(u);
606
+ if (!l)
607
+ throw new m(
608
+ `Graph tx ${a}.previous_output is not "<txid>:<vout>"`
609
609
  );
610
- const h = N(Number(c[2]), `${s}.previous_output vout`, 0, Y);
610
+ const c = D(Number(l[2]), `${a}.previous_output vout`, 0, te);
611
611
  o.addInput(
612
- I.from(c[1], "hex").reverse(),
613
- h,
614
- N(E(i, "sequence", s), `${s}.sequence`, 0, Y),
615
- Q(E(i, "script_sig", s), `${s}.script_sig`)
616
- ), o.ins[a].witness = K(
617
- E(i, "witness", s),
618
- `${s}.witness`
619
- ).map((l, p) => Q(l, `${s}.witness[${p}]`));
620
- }), K(E(r, "output", t), `${t}.output`).forEach((n, a) => {
621
- const s = `${t}.output[${a}]`, i = A(n, s);
612
+ A.from(l[1], "hex").reverse(),
613
+ c,
614
+ D(E(s, "sequence", a), `${a}.sequence`, 0, te),
615
+ re(E(s, "script_sig", a), `${a}.script_sig`)
616
+ ), o.ins[i].witness = M(
617
+ E(s, "witness", a),
618
+ `${a}.witness`
619
+ ).map((h, p) => re(h, `${a}.witness[${p}]`));
620
+ }), M(E(r, "output", t), `${t}.output`).forEach((n, i) => {
621
+ const a = `${t}.output[${i}]`, s = S(n, a);
622
622
  o.addOutput(
623
- Q(E(i, "script_pubkey", s), `${s}.script_pubkey`),
624
- N(E(i, "value", s), `${s}.value`, 0, Number.MAX_SAFE_INTEGER)
623
+ re(E(s, "script_pubkey", a), `${a}.script_pubkey`),
624
+ D(E(s, "value", a), `${a}.value`, 0, Number.MAX_SAFE_INTEGER)
625
625
  );
626
626
  }), new Uint8Array(o.toBuffer());
627
627
  }
628
- function H(e, t) {
629
- const r = f(e).toLowerCase();
628
+ function O(e, t) {
629
+ const r = b(e).toLowerCase();
630
630
  let o;
631
631
  try {
632
632
  o = B.fromHex(r);
633
633
  } catch (n) {
634
- throw new v(
634
+ throw new m(
635
635
  `Presign ${t} is not one transaction: ${n instanceof Error ? n.message : String(n)}`
636
636
  );
637
637
  }
638
638
  if (o.toHex() !== r)
639
- throw new v(
639
+ throw new m(
640
640
  `Presign ${t} is not a canonical transaction encoding`
641
641
  );
642
642
  return o;
643
643
  }
644
- function Ir(e, t) {
644
+ function tt(e, t) {
645
+ const r = e.ins[t];
646
+ if (r)
647
+ return {
648
+ txid: A.from(r.hash).reverse().toString("hex"),
649
+ vout: r.index
650
+ };
651
+ }
652
+ function rt(e, t) {
653
+ if (!e.outs[W])
654
+ throw new m(
655
+ `Presign ${t}.claim_tx must have output ${W}`
656
+ );
657
+ }
658
+ function Kr(e, t, r) {
659
+ if (e.ins.length !== 1)
660
+ throw new m(
661
+ `Presign ${r}.claim_tx must have exactly one input, got ${e.ins.length}`
662
+ );
663
+ rt(e, r);
664
+ const o = tt(e, 0);
665
+ if ((o == null ? void 0 : o.txid) !== t || o.vout !== G) {
666
+ const n = o ? `${o.txid}:${o.vout}` : "no input";
667
+ throw new m(
668
+ `Presign ${r}.claim_tx must spend ${t}:${G}, got ${n}`
669
+ );
670
+ }
671
+ }
672
+ function le(e, t, r) {
673
+ const o = tt(e, 0);
674
+ if ((o == null ? void 0 : o.txid) !== t || o.vout !== W) {
675
+ const n = o ? `${o.txid}:${o.vout}` : "no input";
676
+ throw new m(
677
+ `Presign ${r}.assert_tx input 0 must spend ${t}:${W}, got ${n}`
678
+ );
679
+ }
680
+ }
681
+ function ot(e) {
682
+ const t = O(e.peginTxHex, `${e.path}.pegin_tx`), r = O(e.claimTxHex, `${e.path}.claim_tx`), o = O(e.assertTxHex, `${e.path}.assert_tx`);
683
+ return { peginTx: t, claimTx: r, assertTx: o };
684
+ }
685
+ function Dr(e) {
686
+ const t = O(e.claimTxHex, `${e.path}.claim_tx`), r = O(e.assertTxHex, `${e.path}.assert_tx`);
687
+ rt(t, e.path), le(r, t.getId(), e.path);
688
+ }
689
+ function Mr(e) {
690
+ const { peginTx: t, claimTx: r, assertTx: o } = ot(e);
691
+ Kr(r, t.getId(), e.path), le(o, r.getId(), e.path);
692
+ }
693
+ function Fr(e, t) {
645
694
  const [r, ...o] = e.ins;
646
695
  if (!r || o.length > 0)
647
- throw new v(
696
+ throw new m(
648
697
  `Presign claim_tx must have exactly one input, got ${e.ins.length}`
649
698
  );
650
- const n = I.from(r.hash).reverse().toString("hex");
651
- if (n !== t || r.index !== le)
652
- throw new v(
653
- `Presign claim_tx must spend ${t}:${le}, got ${n}:${r.index}`
699
+ const n = A.from(r.hash).reverse().toString("hex");
700
+ if (n !== t || r.index !== G)
701
+ throw new m(
702
+ `Presign claim_tx must spend ${t}:${G}, got ${n}:${r.index}`
654
703
  );
655
- if (e.version !== we)
656
- throw new v(
657
- `Presign claim_tx version must be ${we}, got ${e.version}`
704
+ if (e.version !== ke)
705
+ throw new m(
706
+ `Presign claim_tx version must be ${ke}, got ${e.version}`
658
707
  );
659
708
  if (r.witness.length > 0)
660
- throw new v(
709
+ throw new m(
661
710
  `Presign claim_tx input must have an empty witness, got ${r.witness.length} item(s)`
662
711
  );
663
- if (e.outs.length !== xe)
664
- throw new v(
665
- `Presign claim_tx must have exactly ${xe} outputs, got ${e.outs.length}`
712
+ if (e.outs.length !== Te)
713
+ throw new m(
714
+ `Presign claim_tx must have exactly ${Te} outputs, got ${e.outs.length}`
666
715
  );
667
716
  }
668
- function Qe(e) {
717
+ function nt(e) {
669
718
  const t = [...e.challengers].sort(
670
719
  (o, n) => o.pubkey < n.pubkey ? -1 : o.pubkey > n.pubkey ? 1 : 0
671
720
  ), r = [e.peginTx, e.claimTx, e.assertTx, e.payoutTx];
672
721
  return t.forEach((o, n) => {
673
- const a = X(o.pubkey, "challenger pubkey");
674
- if (n > 0 && t[n - 1].pubkey === a)
675
- throw new v(`Graph lists challenger ${a} twice`);
676
- r.push(ye(a), o.nopayoutTx);
677
- for (const s of o.outputLabelHashes)
678
- r.push(ye(X(s, "output_label_hashes entry")));
679
- }), Kt(Dt(Mt(...r)));
680
- }
681
- function Rr(e) {
682
- const t = f(e.peginTxid).toLowerCase(), r = H(e.peginTxHex, "pegin_tx");
722
+ const i = Y(o.pubkey, "challenger pubkey");
723
+ if (n > 0 && t[n - 1].pubkey === i)
724
+ throw new m(`Graph lists challenger ${i} twice`);
725
+ r.push(Pe(i), o.nopayoutTx);
726
+ for (const a of o.outputLabelHashes)
727
+ r.push(Pe(Y(a, "output_label_hashes entry")));
728
+ }), Xt(qt(jt(...r)));
729
+ }
730
+ function Lr(e) {
731
+ const t = b(e.peginTxid).toLowerCase(), { peginTx: r, claimTx: o, assertTx: n } = ot({
732
+ peginTxHex: e.peginTxHex,
733
+ claimTxHex: e.claimTxHex,
734
+ assertTxHex: e.assertTxHex,
735
+ path: "depositor_graph"
736
+ });
683
737
  if (r.getId() !== t)
684
- throw new v(
738
+ throw new m(
685
739
  `Presign pegin_tx hashes to ${r.getId()}, expected ${t}`
686
740
  );
687
- const o = H(e.claimTxHex, "claim_tx");
688
- Ir(o, t);
689
- const n = (a) => new Uint8Array(a.toBuffer());
690
- return Qe({
691
- peginTx: n(r),
692
- claimTx: n(o),
693
- assertTx: n(H(e.assertTxHex, "assert_tx")),
694
- payoutTx: n(H(e.payoutTxHex, "payout_tx")),
741
+ Fr(o, t), le(n, o.getId(), "depositor_graph");
742
+ const i = (a) => new Uint8Array(a.toBuffer());
743
+ return nt({
744
+ peginTx: i(r),
745
+ claimTx: i(o),
746
+ assertTx: i(n),
747
+ payoutTx: i(O(e.payoutTxHex, "payout_tx")),
695
748
  challengers: e.challengers.map((a) => ({
696
- pubkey: $(a.challenger_pubkey),
697
- nopayoutTx: n(H(a.nopayout_tx.tx_hex, "nopayout_tx")),
749
+ pubkey: C(a.challenger_pubkey),
750
+ nopayoutTx: i(O(a.nopayout_tx.tx_hex, "nopayout_tx")),
698
751
  outputLabelHashes: a.output_label_hashes.map(
699
- (s) => f(s).toLowerCase()
752
+ (s) => b(s).toLowerCase()
700
753
  )
701
754
  }))
702
755
  });
703
756
  }
704
- function Br(e) {
705
- const t = (o) => Ee(A(E(e, o, "graph"), o).tx, o), r = A(
757
+ function Ur(e) {
758
+ const t = (o) => $e(S(E(e, o, "graph"), o).tx, o), r = S(
706
759
  E(e, "challenger_subgraphs", "graph"),
707
760
  "challenger_subgraphs"
708
761
  );
709
- return Qe({
762
+ return nt({
710
763
  peginTx: t("pegin_tx"),
711
764
  claimTx: t("claim_tx"),
712
765
  assertTx: t("assert_tx"),
713
766
  payoutTx: t("payout_tx"),
714
767
  challengers: Object.entries(r).map(([o, n]) => {
715
- const a = `challenger_subgraphs[${o}]`, s = A(n, a);
768
+ const i = `challenger_subgraphs[${o}]`, a = S(n, i);
716
769
  return {
717
770
  pubkey: o,
718
- nopayoutTx: Ee(
719
- A(E(s, "nopayout_tx", a), `${a}.nopayout_tx`).tx,
720
- `${a}.nopayout_tx`
771
+ nopayoutTx: $e(
772
+ S(E(a, "nopayout_tx", i), `${i}.nopayout_tx`).tx,
773
+ `${i}.nopayout_tx`
721
774
  ),
722
- outputLabelHashes: K(
723
- E(s, "output_label_hashes", a),
724
- `${a}.output_label_hashes`
775
+ outputLabelHashes: M(
776
+ E(a, "output_label_hashes", i),
777
+ `${i}.output_label_hashes`
725
778
  ).map(
726
- (i, u) => X(i, `${a}.output_label_hashes[${u}]`)
779
+ (s, u) => Y(s, `${i}.output_label_hashes[${u}]`)
727
780
  )
728
781
  };
729
782
  })
730
783
  });
731
784
  }
732
- function Vr(e) {
733
- const t = A(
785
+ function Gr(e) {
786
+ const t = S(
734
787
  E(e, "challenger_pubkeys", "graph"),
735
788
  "challenger_pubkeys"
736
789
  ), r = /* @__PURE__ */ new Set();
737
790
  for (const o of ["local", "universal"])
738
- K(
791
+ M(
739
792
  E(t, o, "challenger_pubkeys"),
740
793
  `challenger_pubkeys.${o}`
741
- ).forEach((n, a) => {
742
- const s = X(n, `challenger_pubkeys.${o}[${a}]`);
743
- if (r.has(s))
744
- throw new v(
745
- `Graph declares challenger ${s} more than once`
794
+ ).forEach((n, i) => {
795
+ const a = Y(n, `challenger_pubkeys.${o}[${i}]`);
796
+ if (r.has(a))
797
+ throw new m(
798
+ `Graph declares challenger ${a} more than once`
746
799
  );
747
- r.add(s);
800
+ r.add(a);
748
801
  });
749
802
  return r;
750
803
  }
751
- function Mo(e, t) {
752
- const r = Br(e);
804
+ function Yo(e, t) {
805
+ const r = Ur(e);
753
806
  if (r !== t)
754
- throw new v(
807
+ throw new m(
755
808
  `Graph fingerprint ${r} does not match the presign fingerprint ${t}`
756
809
  );
757
810
  const o = Object.keys(
758
- A(e.challenger_subgraphs, "challenger_subgraphs")
759
- ), n = Vr(e);
760
- if (o.length !== n.size || o.some((a) => !n.has(a)))
761
- throw new v(
811
+ S(e.challenger_subgraphs, "challenger_subgraphs")
812
+ ), n = Gr(e);
813
+ if (o.length !== n.size || o.some((i) => !n.has(i)))
814
+ throw new m(
762
815
  `Graph challenger_subgraphs keys ${o.join(", ")} do not match challenger_pubkeys ${[...n].join(", ")}`
763
816
  );
764
817
  }
765
- const Or = 1;
766
- function Nr(e, t, r) {
818
+ const Xr = 1;
819
+ function qr(e, t, r) {
767
820
  const o = r.map(
768
- (l) => f(l).toLowerCase()
769
- ), n = t.filter((l) => o.includes(l));
821
+ (h) => b(h).toLowerCase()
822
+ ), n = t.filter((h) => o.includes(h));
770
823
  if (n.length > 0)
771
824
  throw new Error(
772
825
  `Cannot validate challenger set: vault keepers and universal challengers overlap (${n.join(", ")})`
773
826
  );
774
- const a = [...t, ...o], s = e.map(
775
- (l) => f(l.challenger_pubkey).toLowerCase()
776
- ), i = new Set(s);
777
- if (i.size !== s.length)
827
+ const i = [...t, ...o], a = e.map(
828
+ (h) => b(h.challenger_pubkey).toLowerCase()
829
+ ), s = new Set(a);
830
+ if (s.size !== a.length)
778
831
  throw new Error(
779
832
  "Depositor graph contains duplicate challenger entries in challenger_presign_data"
780
833
  );
781
- const u = new Set(a), c = a.filter((l) => !i.has(l)), h = s.filter((l) => !u.has(l));
782
- if (c.length > 0 || h.length > 0)
834
+ const u = new Set(i), l = i.filter((h) => !s.has(h)), c = a.filter((h) => !u.has(h));
835
+ if (l.length > 0 || c.length > 0)
783
836
  throw new Error(
784
- "Depositor graph challenger set does not match expected (local ∪ universal)" + (c.length > 0 ? ` (missing: ${c.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
837
+ "Depositor graph challenger set does not match expected (local ∪ universal)" + (l.length > 0 ? ` (missing: ${l.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
785
838
  );
786
839
  }
787
- function Hr(e, t) {
840
+ function jr(e, t) {
788
841
  const r = e.ins[t];
789
- return Ke(new Uint8Array(r.hash).slice().reverse());
842
+ return Le(new Uint8Array(r.hash).slice().reverse());
790
843
  }
791
- function J(e, t, r, o, n) {
792
- const a = e.ins[t];
793
- if (a.index !== 0)
844
+ function oe(e, t, r, o, n) {
845
+ const i = e.ins[t];
846
+ if (i.index !== 0)
794
847
  throw new Error(
795
- `NoPayout (challenger ${n}) input ${t} expected to spend ${o} vout 0, got vout ${a.index}`
848
+ `NoPayout (challenger ${n}) input ${t} expected to spend ${o} vout 0, got vout ${i.index}`
796
849
  );
797
- const s = r.getId(), i = Hr(e, t);
798
- if (i !== s)
850
+ const a = r.getId(), s = jr(e, t);
851
+ if (s !== a)
799
852
  throw new Error(
800
- `NoPayout (challenger ${n}) input ${t} does not reference ${o} (expected txid ${s}, got ${i})`
853
+ `NoPayout (challenger ${n}) input ${t} does not reference ${o} (expected txid ${a}, got ${s})`
801
854
  );
802
855
  }
803
- async function Kr(e, t, r) {
804
- const o = [], n = [], a = [], s = Me({
856
+ async function zr(e, t, r) {
857
+ const o = [], n = [], i = [], a = Ge({
805
858
  claimerBtcPubkey: r.depositorBtcPubkey,
806
859
  depositorBtcPubkey: r.depositorBtcPubkey,
807
860
  vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
808
861
  vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys
809
862
  });
810
- Nr(
863
+ qr(
811
864
  e.challenger_presign_data,
812
- s,
865
+ a,
813
866
  r.universalChallengerBtcPubkeys
814
867
  );
815
- const i = await At({
868
+ const s = await Ot({
816
869
  vaultCoreVersion: r.vaultCoreVersion,
817
870
  vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
818
871
  vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
@@ -828,241 +881,253 @@ async function Kr(e, t, r) {
828
881
  network: r.network,
829
882
  claimerBtcPubkey: r.depositorBtcPubkey,
830
883
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
831
- commissionBps: Or,
884
+ commissionBps: Xr,
832
885
  protocolFeeRate: r.protocolFeeRate,
833
886
  councilMembers: r.councilMembers,
834
887
  councilQuorum: r.councilQuorum
835
888
  });
836
- o.push(i.psbtHex), n.push(
837
- M(
889
+ o.push(s.psbtHex), n.push(
890
+ U(
838
891
  t,
839
- ge
892
+ be
840
893
  )
841
894
  );
842
- const u = f(r.depositorBtcPubkey), c = B.fromHex(
843
- f(e.assert_tx.tx_hex)
895
+ const u = b(r.depositorBtcPubkey), l = B.fromHex(
896
+ b(e.assert_tx.tx_hex)
844
897
  );
845
- for (const h of e.challenger_presign_data) {
846
- const l = f(h.challenger_pubkey), p = o.length, d = await Dr({
847
- challenger: h,
848
- challengerPubkey: l,
898
+ for (const c of e.challenger_presign_data) {
899
+ const h = b(c.challenger_pubkey), p = o.length, d = await Wr({
900
+ challenger: c,
901
+ challengerPubkey: h,
849
902
  claimerPubkey: u,
850
- localChallengers: s,
851
- assertTxParsed: c,
903
+ localChallengers: a,
904
+ assertTxParsed: l,
852
905
  ctx: r
853
906
  });
854
907
  o.push(d), n.push(
855
- M(
908
+ U(
856
909
  t,
857
- ge
910
+ be
858
911
  )
859
- ), a.push({
860
- challengerPubkey: l,
912
+ ), i.push({
913
+ challengerPubkey: h,
861
914
  noPayoutIdx: p
862
915
  });
863
916
  }
864
- return { psbtHexes: o, signOptions: n, challengerEntries: a };
917
+ return { psbtHexes: o, signOptions: n, challengerEntries: i };
865
918
  }
866
- async function Dr(e) {
919
+ async function Wr(e) {
867
920
  const {
868
921
  challenger: t,
869
922
  challengerPubkey: r,
870
923
  claimerPubkey: o,
871
924
  localChallengers: n,
872
- assertTxParsed: a,
873
- ctx: s
925
+ assertTxParsed: i,
926
+ ctx: a
874
927
  } = e;
875
- Ft(
928
+ zt(
876
929
  t.nopayout_tx.tx_hex,
877
930
  r,
878
- s.network
931
+ a.network
879
932
  );
880
- const i = B.fromHex(
881
- f(t.nopayout_tx.tx_hex)
933
+ const s = B.fromHex(
934
+ b(t.nopayout_tx.tx_hex)
882
935
  ), u = B.fromHex(
883
- f(t.challenge_assert_x_tx.tx_hex)
884
- ), c = B.fromHex(
885
- f(t.challenge_assert_y_tx.tx_hex)
936
+ b(t.challenge_assert_x_tx.tx_hex)
937
+ ), l = B.fromHex(
938
+ b(t.challenge_assert_y_tx.tx_hex)
886
939
  );
887
- if (i.ins.length !== 3)
940
+ if (s.ins.length !== 3)
888
941
  throw new Error(
889
- `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
942
+ `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${s.ins.length}`
890
943
  );
891
- J(
892
- i,
944
+ oe(
945
+ s,
893
946
  0,
894
- a,
947
+ i,
895
948
  "Assert",
896
949
  r
897
- ), J(
898
- i,
950
+ ), oe(
951
+ s,
899
952
  1,
900
953
  u,
901
954
  "ChallengeAssertX",
902
955
  r
903
- ), J(
904
- i,
956
+ ), oe(
957
+ s,
905
958
  2,
906
- c,
959
+ l,
907
960
  "ChallengeAssertY",
908
961
  r
909
962
  );
910
- const h = [
911
- a.outs[0],
963
+ const c = [
964
+ i.outs[0],
912
965
  u.outs[0],
913
- c.outs[0]
914
- ].map((l) => ({
915
- script_pubkey: Ke(new Uint8Array(l.script)),
916
- value: l.value
966
+ l.outs[0]
967
+ ].map((h) => ({
968
+ script_pubkey: Le(new Uint8Array(h.script)),
969
+ value: h.value
917
970
  }));
918
- return Ut({
971
+ return Wt({
919
972
  noPayoutTxHex: t.nopayout_tx.tx_hex,
920
973
  challengerPubkey: r,
921
- prevouts: h,
974
+ prevouts: c,
922
975
  connectorParams: {
923
- txGraphVersion: s.vaultCoreVersion,
976
+ txGraphVersion: a.vaultCoreVersion,
924
977
  claimer: o,
925
978
  localChallengers: n,
926
- universalChallengers: s.universalChallengerBtcPubkeys,
927
- timelockAssert: s.timelockAssert,
928
- councilMembers: s.councilMembers,
929
- councilQuorum: s.councilQuorum
979
+ universalChallengers: a.universalChallengerBtcPubkeys,
980
+ timelockAssert: a.timelockAssert,
981
+ councilMembers: a.councilMembers,
982
+ councilQuorum: a.councilQuorum
930
983
  }
931
984
  });
932
985
  }
933
- function Mr(e, t, r) {
934
- F(e[0]);
935
- const n = U(
986
+ function Yr(e, t, r) {
987
+ X(e[0]);
988
+ const n = q(
936
989
  e[0].returnedPsbtHex,
937
990
  r
938
991
  );
939
- L({
992
+ j({
940
993
  requestedPsbtHex: e[0].requestedPsbtHex,
941
994
  signatureHex: n,
942
995
  signerXOnlyPubkeyHex: r,
943
996
  inputIndex: 0
944
997
  });
945
- const a = {};
946
- for (const s of t) {
947
- F(e[s.noPayoutIdx]);
948
- const i = U(
949
- e[s.noPayoutIdx].returnedPsbtHex,
998
+ const i = {};
999
+ for (const a of t) {
1000
+ X(e[a.noPayoutIdx]);
1001
+ const s = q(
1002
+ e[a.noPayoutIdx].returnedPsbtHex,
950
1003
  r
951
1004
  );
952
- L({
953
- requestedPsbtHex: e[s.noPayoutIdx].requestedPsbtHex,
954
- signatureHex: i,
1005
+ j({
1006
+ requestedPsbtHex: e[a.noPayoutIdx].requestedPsbtHex,
1007
+ signatureHex: s,
955
1008
  signerXOnlyPubkeyHex: r,
956
1009
  inputIndex: 0
957
- }), a[s.challengerPubkey] = {
958
- nopayout_signature: i
1010
+ }), i[a.challengerPubkey] = {
1011
+ nopayout_signature: s
959
1012
  };
960
1013
  }
961
1014
  return {
962
1015
  payout_signatures: {
963
1016
  payout_signature: n
964
1017
  },
965
- per_challenger: a
1018
+ per_challenger: i
966
1019
  };
967
1020
  }
968
- async function Fr(e) {
969
- const { depositorGraph: t, btcWallet: r, signingContext: o } = e, n = await r.getPublicKeyHex(), { depositorPubkey: a } = ct(
1021
+ async function Qr(e) {
1022
+ const { depositorGraph: t, btcWallet: r, signingContext: o } = e;
1023
+ Mr({
1024
+ peginTxHex: o.peginTxHex,
1025
+ claimTxHex: t.claim_tx.tx_hex,
1026
+ assertTxHex: t.assert_tx.tx_hex,
1027
+ path: "depositor_graph"
1028
+ });
1029
+ const n = await r.getPublicKeyHex(), { depositorPubkey: i } = yt(
970
1030
  n,
971
- f(o.depositorBtcPubkey)
972
- ), { psbtHexes: s, signOptions: i, challengerEntries: u } = await Kr(
1031
+ b(o.depositorBtcPubkey)
1032
+ ), { psbtHexes: a, signOptions: s, challengerEntries: u } = await zr(
973
1033
  t,
974
1034
  n,
975
1035
  o
976
- ), c = await De(
1036
+ ), l = await Ue(
977
1037
  r,
978
- s,
979
- i
980
- ), h = s.map((l, p) => ({
981
- requestedPsbtHex: l,
982
- returnedPsbtHex: c[p]
1038
+ a,
1039
+ s
1040
+ ), c = a.map((h, p) => ({
1041
+ requestedPsbtHex: h,
1042
+ returnedPsbtHex: l[p]
983
1043
  }));
984
- return Mr(
985
- h,
1044
+ return Yr(
1045
+ c,
986
1046
  u,
987
- a
1047
+ i
988
1048
  );
989
1049
  }
990
- const Ur = 1e4;
991
- async function Je(e) {
1050
+ const Jr = 1e4, N = 10;
1051
+ async function st(e) {
992
1052
  const {
993
1053
  statusReader: t,
994
- peginTxid: r,
995
- targetStatuses: o,
996
- timeoutMs: n,
997
- pollIntervalMs: a = Ur,
1054
+ vaultId: r,
1055
+ peginTxid: o,
1056
+ targetStatuses: n,
1057
+ timeoutMs: i,
1058
+ pollIntervalMs: a = Jr,
998
1059
  signal: s
999
- } = e, i = Date.now();
1060
+ } = e, u = Date.now();
1000
1061
  for (; ; ) {
1001
1062
  if (s != null && s.aborted)
1002
1063
  throw new Error(
1003
- `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
1064
+ `Polling aborted for vault ${r.slice(0, N)}… (target: ${[...n].join(", ")})`
1004
1065
  );
1005
- if (Date.now() - i >= n)
1066
+ if (Date.now() - u >= i)
1006
1067
  throw new Error(
1007
- `Polling timeout after ${n}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
1068
+ `Polling timeout after ${i}ms for vault ${r.slice(0, N)}… (target: ${[...n].join(", ")})`
1008
1069
  );
1009
1070
  try {
1010
- const u = await t.getPeginStatus(
1011
- { pegin_txid: r },
1071
+ const l = await t.getPeginStatusByVaultId(
1072
+ { vault_id: r },
1012
1073
  s
1013
1074
  );
1014
- if (u.pegin_txid.toLowerCase() !== r.toLowerCase())
1075
+ if (ve(l.vault_id) !== ve(r))
1015
1076
  throw new Error(
1016
- `getPeginStatus returned status for pegin ${u.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
1077
+ `getPeginStatusByVaultId returned status for vault ${l.vault_id.slice(0, N)}…, requested ${r.slice(0, N)}…`
1017
1078
  );
1018
- const c = u.status;
1019
- if (o.has(c) || c === R.ACTIVATED)
1079
+ if (l.pegin_txid.toLowerCase() !== o.toLowerCase())
1080
+ throw new Error(
1081
+ `getPeginStatusByVaultId returned status for pegin ${l.pegin_txid.slice(0, 8)}…, requested ${o.slice(0, 8)}…`
1082
+ );
1083
+ const c = l.status;
1084
+ if (n.has(c) || c === R.ACTIVATED)
1020
1085
  return c;
1021
- if (c === R.EXPIRED || Ot.has(c))
1086
+ if (c === R.EXPIRED || Lt.has(c))
1022
1087
  throw new Error(
1023
- `Pegin ${r.slice(0, 8)}… reached terminal status "${c}" while waiting for ${[...o].join(", ")}`
1088
+ `Vault ${r.slice(0, N)}… reached terminal status "${c}" while waiting for ${[...n].join(", ")}`
1024
1089
  );
1025
- } catch (u) {
1026
- if (!(u instanceof Nt && u.code === Ht.PEGIN_NOT_FOUND))
1027
- throw u;
1090
+ } catch (l) {
1091
+ if (!(l instanceof Ut && l.code === Gt.PEGIN_NOT_FOUND))
1092
+ throw l;
1028
1093
  }
1029
- await new Promise((u, c) => {
1094
+ await new Promise((l, c) => {
1030
1095
  const h = () => {
1031
- clearTimeout(l), c(
1096
+ clearTimeout(p), c(
1032
1097
  new Error(
1033
- `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
1098
+ `Polling aborted for vault ${r.slice(0, N)}… (target: ${[...n].join(", ")})`
1034
1099
  )
1035
1100
  );
1036
- }, l = setTimeout(() => {
1037
- s == null || s.removeEventListener("abort", h), u();
1101
+ }, p = setTimeout(() => {
1102
+ s == null || s.removeEventListener("abort", h), l();
1038
1103
  }, a);
1039
1104
  s == null || s.addEventListener("abort", h, { once: !0 });
1040
1105
  });
1041
1106
  }
1042
1107
  }
1043
- const Lr = 1200 * 1e3, Ze = /* @__PURE__ */ new Set([
1108
+ const Zr = 1200 * 1e3, at = /* @__PURE__ */ new Set([
1044
1109
  R.PENDING_ACKS,
1045
1110
  R.PENDING_ACTIVATION,
1046
1111
  R.ACTIVATED_PENDING_BROADCAST,
1047
1112
  R.ACTIVATED
1048
- ]), Gr = /* @__PURE__ */ new Set([
1113
+ ]), eo = /* @__PURE__ */ new Set([
1049
1114
  R.PENDING_DEPOSITOR_SIGNATURES,
1050
- ...Ze
1115
+ ...at
1051
1116
  ]);
1052
- function Xr(e) {
1117
+ function to(e) {
1053
1118
  return e.map((t) => ({
1054
- claimerPubkeyXOnly: j(t.claimer_pubkey),
1119
+ claimerPubkeyXOnly: Q(t.claimer_pubkey),
1055
1120
  payoutTxHex: t.payout_tx.tx_hex,
1056
1121
  assertTxHex: t.assert_tx.tx_hex
1057
1122
  }));
1058
1123
  }
1059
- function S(e) {
1060
- return j(e).toLowerCase();
1124
+ function I(e) {
1125
+ return Q(e).toLowerCase();
1061
1126
  }
1062
- function jr(e, t) {
1063
- const r = (u, c, h) => {
1127
+ function ro(e, t) {
1128
+ const r = (u, l, c) => {
1064
1129
  throw new Error(
1065
- `Deposit terms ${u} (${String(c)}) does not match the vault's version-locked signing context (${String(h)}); refusing to sign payouts against terms that describe a different graph.`
1130
+ `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.`
1066
1131
  );
1067
1132
  }, o = [
1068
1133
  ["protocolFeeRate", e.protocolFeeRate, t.protocolFeeRate],
@@ -1070,17 +1135,17 @@ function jr(e, t) {
1070
1135
  ["timelockPegin", e.timelockPegin, t.timelockPegin],
1071
1136
  ["timelockAssert", e.timelockAssert, t.timelockAssert]
1072
1137
  ];
1073
- for (const [u, c, h] of o)
1074
- c !== h && r(u, c, h);
1075
- const n = (u) => u.map(S).sort(), a = (u, c) => {
1076
- const h = n(u), l = n(c);
1077
- return h.length === l.length && h.every((p, d) => p === l[d]);
1138
+ for (const [u, l, c] of o)
1139
+ l !== c && r(u, l, c);
1140
+ const n = (u) => u.map(I).sort(), i = (u, l) => {
1141
+ const c = n(u), h = n(l);
1142
+ return c.length === h.length && c.every((p, d) => p === h[d]);
1078
1143
  };
1079
- a(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
1144
+ i(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
1080
1145
  "vaultKeeperBtcPubkeys",
1081
1146
  e.vaultKeeperBtcPubkeys.join(","),
1082
1147
  t.vaultKeeperBtcPubkeys.join(",")
1083
- ), a(
1148
+ ), i(
1084
1149
  e.universalChallengerBtcPubkeys,
1085
1150
  t.universalChallengerBtcPubkeys
1086
1151
  ) || r(
@@ -1088,40 +1153,40 @@ function jr(e, t) {
1088
1153
  e.universalChallengerBtcPubkeys.join(","),
1089
1154
  t.universalChallengerBtcPubkeys.join(",")
1090
1155
  );
1091
- const s = S(t.vaultProviderBtcPubkey), i = e.vaults.map(
1092
- (u) => S(u.vaultProviderBtcPubkey)
1156
+ const a = I(t.vaultProviderBtcPubkey), s = e.vaults.map(
1157
+ (u) => I(u.vaultProviderBtcPubkey)
1093
1158
  );
1094
- i.includes(s) || r(
1159
+ s.includes(a) || r(
1095
1160
  "vaults[].vaultProviderBtcPubkey",
1096
- i.join(",") || "<no vaults>",
1161
+ s.join(",") || "<no vaults>",
1097
1162
  t.vaultProviderBtcPubkey
1098
1163
  );
1099
1164
  }
1100
- function qr(e, t, r, o) {
1101
- const n = S(o), a = [
1102
- S(t),
1103
- ...r.map(S)
1104
- ], s = new Set(a);
1105
- if (s.size !== a.length)
1165
+ function oo(e, t, r, o) {
1166
+ const n = I(o), i = [
1167
+ I(t),
1168
+ ...r.map(I)
1169
+ ], a = new Set(i);
1170
+ if (a.size !== i.length)
1106
1171
  throw new Error(
1107
1172
  "Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
1108
1173
  );
1109
- if (s.has(n))
1174
+ if (a.has(n))
1110
1175
  throw new Error(
1111
1176
  "Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
1112
1177
  );
1113
- const i = e.map(
1114
- (p) => S(p.claimer_pubkey)
1178
+ const s = e.map(
1179
+ (p) => I(p.claimer_pubkey)
1115
1180
  );
1116
- if (new Set(i).size !== i.length)
1181
+ if (new Set(s).size !== s.length)
1117
1182
  throw new Error("Presign response contains duplicate claimer entries");
1118
- const u = i.filter((p) => p !== n), c = new Set(u), h = a.filter((p) => !c.has(p)), l = u.filter((p) => !s.has(p));
1119
- if (h.length > 0 || l.length > 0)
1183
+ const u = s.filter((p) => p !== n), l = new Set(u), c = i.filter((p) => !l.has(p)), h = u.filter((p) => !a.has(p));
1184
+ if (c.length > 0 || h.length > 0)
1120
1185
  throw new Error(
1121
- "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (h.length > 0 ? ` (missing: ${h.join(", ")})` : "") + (l.length > 0 ? ` (unexpected: ${l.join(", ")})` : "")
1186
+ "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (c.length > 0 ? ` (missing: ${c.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
1122
1187
  );
1123
1188
  }
1124
- function ke(e, t) {
1189
+ function Ce(e, t) {
1125
1190
  return {
1126
1191
  vaultCoreVersion: t.vaultCoreVersion,
1127
1192
  payoutTxHex: e.payoutTxHex,
@@ -1143,96 +1208,109 @@ function ke(e, t) {
1143
1208
  vpCommissionScriptPubKey: t.vpCommissionScriptPubKey
1144
1209
  };
1145
1210
  }
1146
- async function zr(e, t, r, o) {
1147
- const n = new pt({
1211
+ async function no(e, t, r, o) {
1212
+ const n = new vt({
1148
1213
  network: t.network,
1149
1214
  btcWallet: e
1150
- }), a = r.length;
1151
- o == null || o(0, a);
1152
- let s;
1215
+ }), i = r.length;
1216
+ o == null || o(0, i);
1217
+ let a;
1153
1218
  if (n.supportsBatchSigning())
1154
- s = (await n.signPayoutTransactionsBatch(
1155
- r.map((c) => ke(c, t))
1156
- )).map((c) => c.payoutSignature);
1219
+ a = (await n.signPayoutTransactionsBatch(
1220
+ r.map((l) => Ce(l, t))
1221
+ )).map((l) => l.payoutSignature);
1157
1222
  else {
1158
- s = [];
1223
+ a = [];
1159
1224
  for (let u = 0; u < r.length; u++) {
1160
- o == null || o(u, a);
1161
- const c = await n.signPayoutTransaction(
1162
- ke(r[u], t)
1225
+ o == null || o(u, i);
1226
+ const l = await n.signPayoutTransaction(
1227
+ Ce(r[u], t)
1163
1228
  );
1164
- s.push(c.signature);
1229
+ a.push(l.signature);
1165
1230
  }
1166
1231
  }
1167
- const i = {};
1232
+ const s = {};
1168
1233
  for (let u = 0; u < r.length; u++)
1169
- i[r[u].claimerPubkeyXOnly] = {
1170
- payout_signature: s[u]
1234
+ s[r[u].claimerPubkeyXOnly] = {
1235
+ payout_signature: a[u]
1171
1236
  };
1172
- return o == null || o(a, a), i;
1237
+ return o == null || o(i, i), s;
1173
1238
  }
1174
- async function Fo(e) {
1239
+ async function Qo(e) {
1175
1240
  const {
1176
1241
  statusReader: t,
1177
1242
  presignClient: r,
1178
1243
  btcWallet: o,
1179
- peginTxid: n,
1244
+ vaultId: n,
1245
+ peginTxid: i,
1180
1246
  depositorPk: a,
1181
1247
  signingContext: s,
1182
- depositTerms: i,
1183
- timeoutMs: u = Lr,
1248
+ depositTerms: u,
1249
+ timeoutMs: l = Zr,
1184
1250
  signal: c,
1185
1251
  onProgress: h,
1186
- recordGraphFingerprint: l
1187
- } = e, p = await Je({
1252
+ recordGraphFingerprint: p
1253
+ } = e, d = await st({
1188
1254
  statusReader: t,
1189
- peginTxid: n,
1190
- targetStatuses: Gr,
1191
- timeoutMs: u,
1255
+ vaultId: n,
1256
+ peginTxid: i,
1257
+ targetStatuses: eo,
1258
+ timeoutMs: l,
1192
1259
  signal: c
1193
1260
  });
1194
- if (Ze.has(p))
1261
+ if (at.has(d))
1195
1262
  return;
1196
- if (c == null || c.throwIfAborted(), i !== void 0 && jr(i, s), ht(o)) {
1197
- if (!i)
1263
+ c == null || c.throwIfAborted(), u !== void 0 && ro(u, s);
1264
+ const g = mt(o) ? o : void 0;
1265
+ let y;
1266
+ if (g) {
1267
+ if (!u)
1198
1268
  throw new Error(
1199
1269
  "runDepositorPresignFlow: this wallet requires approved deposit terms but none were provided. Fresh deposits must pass PreparePeginResult.depositTerms; resume flows must rebuild them from on-chain state (the vault app's rebuildDepositTerms)."
1200
1270
  );
1201
- typeof o.validateDepositTerms == "function" && await o.validateDepositTerms(i), await o.approveDepositTerms(i);
1271
+ y = u;
1202
1272
  }
1203
- const d = await r.requestDepositorPresignTransactions(
1273
+ const f = await r.requestDepositorPresignTransactions(
1204
1274
  {
1205
- pegin_txid: n,
1275
+ pegin_txid: i,
1206
1276
  depositor_pk: a
1207
1277
  },
1208
1278
  c
1209
1279
  );
1210
- c == null || c.throwIfAborted();
1211
- const g = Rr({
1212
- peginTxid: n,
1280
+ c == null || c.throwIfAborted(), f.txs.forEach((V, F) => {
1281
+ Dr({
1282
+ claimTxHex: V.claim_tx.tx_hex,
1283
+ assertTxHex: V.assert_tx.tx_hex,
1284
+ path: `txs[${F}]`
1285
+ });
1286
+ });
1287
+ const P = Lr({
1288
+ peginTxid: i,
1213
1289
  peginTxHex: s.peginTxHex,
1214
- claimTxHex: d.depositor_graph.claim_tx.tx_hex,
1215
- assertTxHex: d.depositor_graph.assert_tx.tx_hex,
1216
- payoutTxHex: d.depositor_graph.payout_tx.tx_hex,
1217
- challengers: d.depositor_graph.challenger_presign_data
1218
- }), b = S(a);
1219
- qr(
1220
- d.txs,
1290
+ claimTxHex: f.depositor_graph.claim_tx.tx_hex,
1291
+ assertTxHex: f.depositor_graph.assert_tx.tx_hex,
1292
+ payoutTxHex: f.depositor_graph.payout_tx.tx_hex,
1293
+ challengers: f.depositor_graph.challenger_presign_data
1294
+ }), x = I(a);
1295
+ oo(
1296
+ f.txs,
1221
1297
  s.vaultProviderBtcPubkey,
1222
1298
  s.vaultKeeperBtcPubkeys,
1223
1299
  a
1224
1300
  );
1225
- const y = d.txs.filter(
1226
- (_) => S(_.claimer_pubkey) !== b
1227
- ), m = Xr(y), x = await zr(
1301
+ const w = f.txs.filter(
1302
+ (V) => I(V.claimer_pubkey) !== x
1303
+ ), _ = to(w);
1304
+ g && y && (typeof g.validateDepositTerms == "function" && await g.validateDepositTerms(y), await g.approveDepositTerms(y)), c == null || c.throwIfAborted();
1305
+ const k = await no(
1228
1306
  o,
1229
1307
  s,
1230
- m,
1308
+ _,
1231
1309
  h
1232
1310
  );
1233
1311
  c == null || c.throwIfAborted();
1234
- const w = await Fr({
1235
- depositorGraph: d.depositor_graph,
1312
+ const T = await Qr({
1313
+ depositorGraph: f.depositor_graph,
1236
1314
  btcWallet: o,
1237
1315
  signingContext: {
1238
1316
  vaultCoreVersion: s.vaultCoreVersion,
@@ -1252,104 +1330,106 @@ async function Fo(e) {
1252
1330
  vpCommissionScriptPubKey: s.vpCommissionScriptPubKey
1253
1331
  }
1254
1332
  });
1255
- c == null || c.throwIfAborted(), await l(g), c == null || c.throwIfAborted();
1256
- const k = { ...x };
1257
- k[f(a)] = w.payout_signatures, await r.submitDepositorPresignatures(
1333
+ c == null || c.throwIfAborted(), await p(P), c == null || c.throwIfAborted();
1334
+ const v = { ...k };
1335
+ v[b(a)] = T.payout_signatures, await r.submitDepositorPresignatures(
1258
1336
  {
1259
- pegin_txid: n,
1337
+ pegin_txid: i,
1260
1338
  depositor_pk: a,
1261
- signatures: k,
1262
- depositor_claimer_presignatures: w
1339
+ signatures: v,
1340
+ depositor_claimer_presignatures: T
1263
1341
  },
1264
1342
  c
1265
1343
  );
1266
1344
  }
1267
- const Wr = 300 * 1e3, Yr = /* @__PURE__ */ new Set([
1345
+ const so = 300 * 1e3, ao = /* @__PURE__ */ new Set([
1268
1346
  R.PENDING_DEPOSITOR_WOTS_PK,
1269
- ...Ue
1347
+ ...qe
1270
1348
  ]);
1271
- async function Uo(e) {
1349
+ async function Jo(e) {
1272
1350
  const {
1273
1351
  statusReader: t,
1274
1352
  wotsSubmitter: r,
1275
- peginTxid: o,
1276
- depositorPk: n,
1353
+ vaultId: o,
1354
+ peginTxid: n,
1355
+ depositorPk: i,
1277
1356
  wotsPublicKeys: a,
1278
- timeoutMs: s = Wr,
1279
- signal: i
1357
+ timeoutMs: s = so,
1358
+ signal: u
1280
1359
  } = e;
1281
- i == null || i.throwIfAborted();
1282
- const u = await Je({
1360
+ u == null || u.throwIfAborted();
1361
+ const l = await st({
1283
1362
  statusReader: t,
1284
- peginTxid: o,
1285
- targetStatuses: Yr,
1363
+ vaultId: o,
1364
+ peginTxid: n,
1365
+ targetStatuses: ao,
1286
1366
  timeoutMs: s,
1287
- signal: i
1367
+ signal: u
1288
1368
  });
1289
- Ue.has(u) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
1369
+ qe.has(l) || (u == null || u.throwIfAborted(), await r.submitDepositorWotsKey(
1290
1370
  {
1291
- pegin_txid: o,
1292
- depositor_pk: n,
1371
+ pegin_txid: n,
1372
+ depositor_pk: i,
1293
1373
  wots_public_keys: a
1294
1374
  },
1295
- i
1375
+ u
1296
1376
  ));
1297
1377
  }
1298
- function Z(e) {
1378
+ function ne(e) {
1299
1379
  return e.registration || e.operation;
1300
1380
  }
1301
- function Qr(e, t, r) {
1302
- const o = $(e);
1381
+ function io(e, t, r) {
1382
+ const o = C(e);
1303
1383
  return {
1304
- registration: o === $(t),
1305
- operation: o === $(r)
1384
+ registration: o === C(t),
1385
+ operation: o === C(r)
1306
1386
  };
1307
1387
  }
1308
- function _e(e, t, r) {
1309
- const o = ee(e);
1388
+ function Ae(e, t, r) {
1389
+ const o = se(e);
1310
1390
  return {
1311
- registration: Te(o, ee(t)),
1312
- operation: Te(o, ee(r))
1391
+ registration: Se(o, se(t)),
1392
+ operation: Se(o, se(r))
1313
1393
  };
1314
1394
  }
1315
- function ee(e) {
1316
- return e.map($).sort();
1395
+ function se(e) {
1396
+ return e.map(C).sort();
1317
1397
  }
1318
- function Te(e, t) {
1398
+ function Se(e, t) {
1319
1399
  return e.length === t.length && e.every((r, o) => r === t[o]);
1320
1400
  }
1321
- async function Lo(e) {
1401
+ async function Zo(e) {
1322
1402
  const {
1323
1403
  vaultProviderEthAddress: t,
1324
1404
  hintBtcPubkey: r,
1325
1405
  registrationBtcPubkey: o,
1326
1406
  readCurrentOperationBtcPubkey: n,
1327
- context: a
1407
+ context: i
1328
1408
  } = e;
1329
1409
  if (!r) return;
1330
- const s = $(r);
1331
- if (s === $(o)) return;
1332
- const i = $(
1410
+ const a = C(r);
1411
+ if (a === C(o)) return;
1412
+ const s = C(
1333
1413
  await n()
1334
1414
  );
1335
- if (s !== i)
1415
+ if (a !== s)
1336
1416
  throw new Error(
1337
- `Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${a ? ` ${a}` : ""}`
1417
+ `Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${i ? ` ${i}` : ""}`
1338
1418
  );
1339
1419
  }
1340
- function te(e, t, r) {
1341
- const o = `${e} operation key (admin=${t.ethAddress})`, n = fe(
1420
+ function ae(e, t, r) {
1421
+ const o = `${e} operation key (admin=${t.ethAddress})`, n = me(
1342
1422
  t.btcPubKey,
1343
1423
  `${e} roster key (admin=${t.ethAddress})`
1344
- ), a = fe(r, o);
1424
+ ), i = me(r, o);
1345
1425
  return {
1346
1426
  adminAddress: t.ethAddress,
1347
1427
  genesisBtcPubkey: n,
1348
- operationBtcPubkey: a,
1349
- rotated: a !== n
1428
+ operationBtcPubkey: i,
1429
+ rotated: i !== n
1350
1430
  };
1351
1431
  }
1352
- function Jr(e) {
1432
+ function uo(e) {
1353
1433
  const t = /* @__PURE__ */ new Map();
1354
1434
  for (const r of e) {
1355
1435
  const o = t.get(r.operationBtcPubkey);
@@ -1360,12 +1440,12 @@ function Jr(e) {
1360
1440
  t.set(r.operationBtcPubkey, r.adminAddress);
1361
1441
  }
1362
1442
  }
1363
- function et(e, t, r) {
1443
+ function it(e, t, r) {
1364
1444
  if (t.vaultKeepers.length !== e.vaultKeepers.length || t.universalChallengers.length !== e.universalChallengers.length)
1365
1445
  throw new Error(
1366
1446
  `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`
1367
1447
  );
1368
- const o = te(
1448
+ const o = ae(
1369
1449
  "vault provider",
1370
1450
  {
1371
1451
  ethAddress: e.vaultProviderEthAddress,
@@ -1373,70 +1453,70 @@ function et(e, t, r) {
1373
1453
  },
1374
1454
  t.vaultProvider
1375
1455
  ), n = e.vaultKeepers.map(
1376
- (s, i) => te("vault keeper", s, t.vaultKeepers[i])
1377
- ), a = e.universalChallengers.map(
1378
- (s, i) => te("universal challenger", s, t.universalChallengers[i])
1456
+ (a, s) => ae("vault keeper", a, t.vaultKeepers[s])
1457
+ ), i = e.universalChallengers.map(
1458
+ (a, s) => ae("universal challenger", a, t.universalChallengers[s])
1379
1459
  );
1380
- return Jr([
1460
+ return uo([
1381
1461
  o,
1382
1462
  ...n,
1383
- ...a
1463
+ ...i
1384
1464
  ]), {
1385
1465
  vaultProvider: o,
1386
1466
  vaultKeepers: n,
1387
- universalChallengers: a,
1467
+ universalChallengers: i,
1388
1468
  // Derived from the pairs, never the reverse — see ParticipantKeySet.
1389
- vaultKeeperOperationKeysSorted: n.map((s) => s.operationBtcPubkey).sort(),
1390
- universalChallengerOperationKeysSorted: a.map((s) => s.operationBtcPubkey).sort(),
1469
+ vaultKeeperOperationKeysSorted: n.map((a) => a.operationBtcPubkey).sort(),
1470
+ universalChallengerOperationKeysSorted: i.map((a) => a.operationBtcPubkey).sort(),
1391
1471
  resolvedAt: r,
1392
1472
  query: e
1393
1473
  };
1394
1474
  }
1395
- async function Zr(e) {
1475
+ async function co(e) {
1396
1476
  const t = await e.operationKeyReader.getCurrentOperationKeys(
1397
1477
  e.query,
1398
1478
  e.blockNumber
1399
1479
  );
1400
- return et(e.query, t, { mode: "current" });
1480
+ return it(e.query, t, { mode: "current" });
1401
1481
  }
1402
- async function eo(e) {
1482
+ async function lo(e) {
1403
1483
  const t = await e.operationKeyReader.getOperationKeysAtEpochs(
1404
1484
  e.query,
1405
1485
  e.epochs
1406
1486
  );
1407
- return et(e.query, t, {
1487
+ return it(e.query, t, {
1408
1488
  mode: "epochs",
1409
1489
  epochs: e.epochs
1410
1490
  });
1411
1491
  }
1412
- class oe extends Error {
1492
+ class ue extends Error {
1413
1493
  constructor(t) {
1414
1494
  super(t), this.name = "ApplicationEntryPointMismatchError";
1415
1495
  }
1416
1496
  }
1417
- function Go(e) {
1418
- return e instanceof oe || e instanceof Error && e.name === "ApplicationEntryPointMismatchError";
1497
+ function en(e) {
1498
+ return e instanceof ue || e instanceof Error && e.name === "ApplicationEntryPointMismatchError";
1419
1499
  }
1420
- const $e = (e) => e.map($).sort();
1421
- async function Xo(e) {
1500
+ const Ie = (e) => e.map(C).sort();
1501
+ async function tn(e) {
1422
1502
  const {
1423
1503
  vaultRegistryReader: t,
1424
1504
  vaultKeeperReader: r,
1425
1505
  universalChallengerReader: o,
1426
1506
  vaultProviderEthAddress: n,
1427
- applicationEntryPoint: a,
1428
- expectedVaultProviderBtcPubkey: s,
1429
- expectedVaultKeeperBtcPubkeys: i,
1507
+ applicationEntryPoint: i,
1508
+ expectedVaultProviderBtcPubkey: a,
1509
+ expectedVaultKeeperBtcPubkeys: s,
1430
1510
  expectedUniversalChallengerBtcPubkeys: u,
1431
- operationKeyReader: c,
1432
- onIndexerServingOperationKeys: h,
1433
- onIndexerHintsInconsistent: l,
1511
+ operationKeyReader: l,
1512
+ onIndexerServingOperationKeys: c,
1513
+ onIndexerHintsInconsistent: h,
1434
1514
  blockNumber: p
1435
1515
  } = e, [
1436
1516
  d,
1437
1517
  g,
1438
- b,
1439
- y
1518
+ y,
1519
+ f
1440
1520
  ] = await Promise.all([
1441
1521
  t.getVaultProviderApplication(
1442
1522
  n,
@@ -1449,15 +1529,15 @@ async function Xo(e) {
1449
1529
  o.getLatestUniversalChallengersVersion(p),
1450
1530
  o.getCurrentUcKeyEpoch(p)
1451
1531
  ]);
1452
- if (!Bt(a, { strict: !1 }))
1453
- throw new oe(
1454
- `The application entry point this deposit was prepared for is not a valid address: ${a}`
1532
+ if (!Mt(i, { strict: !1 }))
1533
+ throw new ue(
1534
+ `The application entry point this deposit was prepared for is not a valid address: ${i}`
1455
1535
  );
1456
- if (!Vt(d, a))
1457
- throw new oe(
1458
- `Vault provider ${n} is registered to application ${d}, but this deposit was prepared for ${a}. 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.`
1536
+ if (!Ft(d, i))
1537
+ throw new ue(
1538
+ `Vault provider ${n} is registered to application ${d}, but this deposit was prepared for ${i}. 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.`
1459
1539
  );
1460
- const [m, x] = await Promise.all(
1540
+ const [P, x] = await Promise.all(
1461
1541
  [
1462
1542
  r.getCurrentVaultKeepersVersion(
1463
1543
  d,
@@ -1468,117 +1548,117 @@ async function Xo(e) {
1468
1548
  p
1469
1549
  )
1470
1550
  ]
1471
- ), [w, k] = await Promise.all([
1551
+ ), [w, _] = await Promise.all([
1472
1552
  r.getVaultKeepersByVersion(
1473
1553
  d,
1474
- m,
1554
+ P,
1475
1555
  p
1476
1556
  ),
1477
1557
  o.getUniversalChallengersByVersion(
1478
- b,
1558
+ y,
1479
1559
  p
1480
1560
  )
1481
- ]), _ = {
1482
- vaultProvider: $(g),
1483
- vaultKeepers: $e(w.map((T) => T.btcPubKey)),
1484
- universalChallengers: $e(k.map((T) => T.btcPubKey))
1485
- }, C = await Zr({
1486
- operationKeyReader: c,
1561
+ ]), k = {
1562
+ vaultProvider: C(g),
1563
+ vaultKeepers: Ie(w.map(($) => $.btcPubKey)),
1564
+ universalChallengers: Ie(_.map(($) => $.btcPubKey))
1565
+ }, T = await co({
1566
+ operationKeyReader: l,
1487
1567
  query: {
1488
1568
  vaultProviderEthAddress: n,
1489
1569
  vaultProviderGenesisBtcPubkey: `0x${g}`,
1490
1570
  applicationEntryPoint: d,
1491
1571
  vaultKeepers: w,
1492
- universalChallengers: k
1572
+ universalChallengers: _
1493
1573
  },
1494
1574
  blockNumber: p
1495
- }), P = {
1496
- vaultProvider: C.vaultProvider.operationBtcPubkey,
1497
- vaultKeepers: [...C.vaultKeeperOperationKeysSorted],
1575
+ }), v = {
1576
+ vaultProvider: T.vaultProvider.operationBtcPubkey,
1577
+ vaultKeepers: [...T.vaultKeeperOperationKeysSorted],
1498
1578
  universalChallengers: [
1499
- ...C.universalChallengerOperationKeysSorted
1579
+ ...T.universalChallengerOperationKeysSorted
1500
1580
  ]
1501
- }, se = Qr(
1581
+ }, V = io(
1582
+ a,
1583
+ k.vaultProvider,
1584
+ v.vaultProvider
1585
+ ), F = Ae(
1502
1586
  s,
1503
- _.vaultProvider,
1504
- P.vaultProvider
1505
- ), ae = _e(
1506
- i,
1507
- _.vaultKeepers,
1508
- P.vaultKeepers
1509
- ), ie = _e(
1587
+ k.vaultKeepers,
1588
+ v.vaultKeepers
1589
+ ), he = Ae(
1510
1590
  u,
1511
- _.universalChallengers,
1512
- P.universalChallengers
1591
+ k.universalChallengers,
1592
+ v.universalChallengers
1513
1593
  );
1514
- if (!Z(se))
1594
+ if (!ne(V))
1515
1595
  throw new Error(
1516
1596
  `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${n}. Refresh and try again.`
1517
1597
  );
1518
- if (!Z(ae))
1598
+ if (!ne(F))
1519
1599
  throw new Error(
1520
- `Vault keeper BTC pubkeys (v${m}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
1600
+ `Vault keeper BTC pubkeys (v${P}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
1521
1601
  );
1522
- if (!Z(ie))
1602
+ if (!ne(he))
1523
1603
  throw new Error(
1524
- `Universal challenger BTC pubkeys (v${b}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
1604
+ `Universal challenger BTC pubkeys (v${y}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
1525
1605
  );
1526
- const ue = [se, ae, ie], st = ue.some((T) => T.registration && !T.operation), ce = ue.some((T) => T.operation && !T.registration);
1527
- if (st && ce) {
1528
- const T = `Indexer participant hints are internally inconsistent for vault provider ${n}: some roles match the registration keys while others match the rotated operation keys.`;
1529
- throw l == null || l(T), new Error(`${T} Refresh and try again.`);
1606
+ const pe = [V, F, he], pt = pe.some(($) => $.registration && !$.operation), de = pe.some(($) => $.operation && !$.registration);
1607
+ if (pt && de) {
1608
+ const $ = `Indexer participant hints are internally inconsistent for vault provider ${n}: some roles match the registration keys while others match the rotated operation keys.`;
1609
+ throw h == null || h($), new Error(`${$} Refresh and try again.`);
1530
1610
  }
1531
- return ce && (h == null || h(
1611
+ return de && (c == null || c(
1532
1612
  `Indexer is serving rotated operation keys for vault provider ${n}`
1533
1613
  )), {
1534
- vaultProviderBtcPubkeyXOnly: P.vaultProvider,
1535
- vaultKeeperBtcPubkeysSorted: P.vaultKeepers,
1536
- universalChallengerBtcPubkeysSorted: P.universalChallengers,
1537
- expectedAppVaultKeepersVersion: m,
1538
- expectedUniversalChallengersVersion: b,
1614
+ vaultProviderBtcPubkeyXOnly: v.vaultProvider,
1615
+ vaultKeeperBtcPubkeysSorted: v.vaultKeepers,
1616
+ universalChallengerBtcPubkeysSorted: v.universalChallengers,
1617
+ expectedAppVaultKeepersVersion: P,
1618
+ expectedUniversalChallengersVersion: y,
1539
1619
  appKeeperKeyEpoch: x,
1540
- ucKeyEpoch: y,
1541
- registrationKeys: _,
1542
- participantKeys: C
1620
+ ucKeyEpoch: f,
1621
+ registrationKeys: k,
1622
+ participantKeys: T
1543
1623
  };
1544
1624
  }
1545
- function to(e) {
1625
+ function ho(e) {
1546
1626
  return /^[0-9a-fA-F]{64}$/.test(e);
1547
1627
  }
1548
- function jo(e) {
1628
+ function rn(e) {
1549
1629
  const {
1550
1630
  amountSats: t,
1551
1631
  minDeposit: r,
1552
1632
  maxDeposit: o,
1553
1633
  btcBalance: n,
1554
- estimatedFeeSats: a,
1555
- depositorClaimValue: s
1634
+ estimatedFeeSats: i,
1635
+ depositorClaimValue: a
1556
1636
  } = e;
1557
- return !(t <= 0n || t < r || o && o > 0n && t > o || a == null || s == null || t + a + s > n);
1637
+ return !(t <= 0n || t < r || o && o > 0n && t > o || i == null || a == null || t + i + a > n);
1558
1638
  }
1559
- function qo(e, t, r) {
1639
+ function on(e, t, r) {
1560
1640
  return e <= 0n ? {
1561
1641
  valid: !1,
1562
1642
  error: "Deposit amount must be greater than zero"
1563
1643
  } : e < t ? {
1564
1644
  valid: !1,
1565
- error: `Minimum deposit is ${V(t)} BTC`
1645
+ error: `Minimum deposit is ${H(t)} BTC`
1566
1646
  } : r && r > 0n && e > r ? {
1567
1647
  valid: !1,
1568
- error: `Maximum deposit is ${V(r)} BTC`
1648
+ error: `Maximum deposit is ${H(r)} BTC`
1569
1649
  } : { valid: !0 };
1570
1650
  }
1571
- function zo(e) {
1651
+ function nn(e) {
1572
1652
  const { amount: t, effectiveRemaining: r } = e;
1573
1653
  return r === null ? { valid: !0 } : r === 0n ? {
1574
1654
  valid: !1,
1575
1655
  error: "Supply cap reached — deposits temporarily paused"
1576
1656
  } : t > r ? {
1577
1657
  valid: !1,
1578
- error: `Vault size exceeds remaining capacity (${V(r)} BTC)`
1658
+ error: `Vault size exceeds remaining capacity (${H(r)} BTC)`
1579
1659
  } : { valid: !0 };
1580
1660
  }
1581
- function Wo(e, t) {
1661
+ function sn(e, t) {
1582
1662
  if (!e || e.length === 0)
1583
1663
  return {
1584
1664
  valid: !1,
@@ -1594,7 +1674,7 @@ function Wo(e, t) {
1594
1674
  error: "Invalid vault provider selected"
1595
1675
  } : { valid: !0 };
1596
1676
  }
1597
- function ro(e, t, r) {
1677
+ function po(e, t, r) {
1598
1678
  if (!e || e.length === 0)
1599
1679
  return {
1600
1680
  valid: !1,
@@ -1610,177 +1690,177 @@ function ro(e, t, r) {
1610
1690
  if (t && n < t)
1611
1691
  return {
1612
1692
  valid: !1,
1613
- error: `Vault ${o + 1} amount ${V(n)} BTC is below minimum deposit ${V(t)} BTC`
1693
+ error: `Vault ${o + 1} amount ${H(n)} BTC is below minimum deposit ${H(t)} BTC`
1614
1694
  };
1615
1695
  if (r && n > r)
1616
1696
  return {
1617
1697
  valid: !1,
1618
- error: `Vault ${o + 1} amount ${V(n)} BTC exceeds maximum deposit ${V(r)} BTC`
1698
+ error: `Vault ${o + 1} amount ${H(n)} BTC exceeds maximum deposit ${H(r)} BTC`
1619
1699
  };
1620
1700
  }
1621
1701
  return { valid: !0 };
1622
1702
  }
1623
- function oo(e) {
1624
- const t = f(e);
1625
- return to(t) ? { valid: !0 } : {
1703
+ function go(e) {
1704
+ const t = b(e);
1705
+ return ho(t) ? { valid: !0 } : {
1626
1706
  valid: !1,
1627
1707
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
1628
1708
  };
1629
1709
  }
1630
- function no(e) {
1710
+ function fo(e) {
1631
1711
  if (!e || e.length === 0)
1632
1712
  throw new Error(
1633
1713
  "No vault keepers available. The system requires at least one vault keeper to create a deposit."
1634
1714
  );
1635
1715
  }
1636
- function so(e) {
1716
+ function yo(e) {
1637
1717
  if (!e || e.length === 0)
1638
1718
  throw new Error(
1639
1719
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
1640
1720
  );
1641
1721
  }
1642
- function ao(e) {
1722
+ function bo(e) {
1643
1723
  if (e.length === 0)
1644
1724
  throw new Error("No spendable UTXOs available");
1645
1725
  }
1646
- function Yo(e) {
1726
+ function an(e) {
1647
1727
  const {
1648
1728
  vaultAmounts: t,
1649
1729
  confirmedUTXOs: r,
1650
1730
  vaultProviderBtcPubkey: o,
1651
1731
  vaultKeeperBtcPubkeys: n,
1652
- universalChallengerBtcPubkeys: a,
1653
- minDeposit: s,
1654
- maxDeposit: i
1655
- } = e, u = ro(
1732
+ universalChallengerBtcPubkeys: i,
1733
+ minDeposit: a,
1734
+ maxDeposit: s
1735
+ } = e, u = po(
1656
1736
  t,
1657
- s,
1658
- i
1737
+ a,
1738
+ s
1659
1739
  );
1660
1740
  if (!u.valid)
1661
1741
  throw new Error(u.error);
1662
- const c = oo(o);
1663
- if (!c.valid)
1664
- throw new Error(c.error);
1665
- no(n), so(a), ao(r);
1742
+ const l = go(o);
1743
+ if (!l.valid)
1744
+ throw new Error(l.error);
1745
+ fo(n), yo(i), bo(r);
1666
1746
  }
1667
- class tt extends Error {
1747
+ class ut extends Error {
1668
1748
  constructor(t) {
1669
1749
  super(t), this.name = "ParticipantKeyDriftError";
1670
1750
  }
1671
1751
  }
1672
- function Qo(e) {
1673
- return e instanceof tt || e instanceof Error && e.name === "ParticipantKeyDriftError";
1752
+ function un(e) {
1753
+ return e instanceof ut || e instanceof Error && e.name === "ParticipantKeyDriftError";
1674
1754
  }
1675
- function Ce(e, t, r) {
1755
+ function Re(e, t, r) {
1676
1756
  return t.length === r.length && t.every((o, n) => o === r[n]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
1677
1757
  }
1678
- async function Jo(e) {
1679
- const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: o, expected: n } = e, a = n.query;
1758
+ async function cn(e) {
1759
+ const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: o, expected: n } = e, i = n.query;
1680
1760
  if (o.length === 0) return;
1681
- const s = await t.getVaultKeyEpochsBatch(o), i = [];
1682
- for (const [u, c] of s.entries()) {
1683
- const h = o[u];
1684
- let l;
1761
+ const a = await t.getVaultKeyEpochsBatch(o), s = [];
1762
+ for (const [u, l] of a.entries()) {
1763
+ const c = o[u];
1764
+ let h;
1685
1765
  try {
1686
- l = await eo({
1766
+ h = await lo({
1687
1767
  operationKeyReader: r,
1688
- query: a,
1689
- epochs: c
1768
+ query: i,
1769
+ epochs: l
1690
1770
  });
1691
1771
  } catch (g) {
1692
- i.push(
1693
- `vault ${h}: could not resolve participants at frozen epochs (vp=${c.vpKeyEpoch}, keeper=${c.appKeeperKeyEpoch}, uc=${c.ucKeyEpoch}): ${g.message}`
1772
+ s.push(
1773
+ `vault ${c}: could not resolve participants at frozen epochs (vp=${l.vpKeyEpoch}, keeper=${l.appKeeperKeyEpoch}, uc=${l.ucKeyEpoch}): ${g.message}`
1694
1774
  );
1695
1775
  continue;
1696
1776
  }
1697
- l.vaultProvider.operationBtcPubkey !== n.vaultProvider.operationBtcPubkey && i.push(
1698
- `vault ${h}: vault provider key expected ${n.vaultProvider.operationBtcPubkey}, got ${l.vaultProvider.operationBtcPubkey}`
1777
+ h.vaultProvider.operationBtcPubkey !== n.vaultProvider.operationBtcPubkey && s.push(
1778
+ `vault ${c}: vault provider key expected ${n.vaultProvider.operationBtcPubkey}, got ${h.vaultProvider.operationBtcPubkey}`
1699
1779
  );
1700
- const p = Ce(
1701
- `vault ${h}: vault keeper keys`,
1780
+ const p = Re(
1781
+ `vault ${c}: vault keeper keys`,
1702
1782
  n.vaultKeeperOperationKeysSorted,
1703
- l.vaultKeeperOperationKeysSorted
1783
+ h.vaultKeeperOperationKeysSorted
1704
1784
  );
1705
- p && i.push(p);
1706
- const d = Ce(
1707
- `vault ${h}: universal challenger keys`,
1785
+ p && s.push(p);
1786
+ const d = Re(
1787
+ `vault ${c}: universal challenger keys`,
1708
1788
  n.universalChallengerOperationKeysSorted,
1709
- l.universalChallengerOperationKeysSorted
1789
+ h.universalChallengerOperationKeysSorted
1710
1790
  );
1711
- d && i.push(d);
1791
+ d && s.push(d);
1712
1792
  }
1713
- if (i.length > 0)
1714
- throw new tt(
1715
- `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.`
1793
+ if (s.length > 0)
1794
+ throw new ut(
1795
+ `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.`
1716
1796
  );
1717
1797
  }
1718
- class rt extends Error {
1798
+ class ct extends Error {
1719
1799
  constructor(t) {
1720
1800
  super(t), this.name = "RegisteredVaultVersionMismatchError";
1721
1801
  }
1722
1802
  }
1723
- function Zo(e) {
1724
- return e instanceof rt || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
1803
+ function ln(e) {
1804
+ return e instanceof ct || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
1725
1805
  }
1726
- async function en(e) {
1806
+ async function hn(e) {
1727
1807
  const {
1728
1808
  vaultRegistryReader: t,
1729
1809
  vaultIds: r,
1730
1810
  expectedOffchainParamsVersion: o,
1731
1811
  expectedAppVaultKeepersVersion: n,
1732
- expectedUniversalChallengersVersion: a,
1733
- expectedVaultCoreVersion: s
1734
- } = e, i = await t.getProtocolInfoBatch(r), u = [];
1735
- if (i.forEach((c, h) => {
1736
- const l = r[h];
1737
- c.offchainParamsVersion !== o && u.push(
1738
- `vault ${l}: offchainParams expected v${o}, got v${c.offchainParamsVersion}`
1739
- ), c.appVaultKeepersVersion !== n && u.push(
1740
- `vault ${l}: appVaultKeepers expected v${n}, got v${c.appVaultKeepersVersion}`
1741
- ), c.universalChallengersVersion !== a && u.push(
1742
- `vault ${l}: universalChallengers expected v${a}, got v${c.universalChallengersVersion}`
1743
- ), c.vaultCoreVersion !== s && u.push(
1744
- `vault ${l}: vaultCoreVersion expected v${s} (build-time active), got v${c.vaultCoreVersion}`
1812
+ expectedUniversalChallengersVersion: i,
1813
+ expectedVaultCoreVersion: a
1814
+ } = e, s = await t.getProtocolInfoBatch(r), u = [];
1815
+ if (s.forEach((l, c) => {
1816
+ const h = r[c];
1817
+ l.offchainParamsVersion !== o && u.push(
1818
+ `vault ${h}: offchainParams expected v${o}, got v${l.offchainParamsVersion}`
1819
+ ), l.appVaultKeepersVersion !== n && u.push(
1820
+ `vault ${h}: appVaultKeepers expected v${n}, got v${l.appVaultKeepersVersion}`
1821
+ ), l.universalChallengersVersion !== i && u.push(
1822
+ `vault ${h}: universalChallengers expected v${i}, got v${l.universalChallengersVersion}`
1823
+ ), l.vaultCoreVersion !== a && u.push(
1824
+ `vault ${h}: vaultCoreVersion expected v${a} (build-time active), got v${l.vaultCoreVersion}`
1745
1825
  );
1746
1826
  }), u.length > 0)
1747
- throw new rt(
1827
+ throw new ct(
1748
1828
  `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.`
1749
1829
  );
1750
1830
  }
1751
- class io extends Error {
1831
+ class mo extends Error {
1752
1832
  constructor(r, o) {
1753
1833
  super(`Refund not yet mature (BIP68 not final): ${o.message}`);
1754
- O(this, "vaultId");
1755
- O(this, "cause");
1834
+ K(this, "vaultId");
1835
+ K(this, "cause");
1756
1836
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
1757
1837
  }
1758
1838
  }
1759
- const uo = /^0x[0-9a-fA-F]{64}$/, co = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, ot = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, nt = 160, Ae = 2e3, Se = 10n, Ie = 100n;
1760
- function tn(e) {
1839
+ const vo = /^0x[0-9a-fA-F]{64}$/, Po = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, lt = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, ht = 160, Be = 2e3, Ve = 10n, He = 100n;
1840
+ function pn(e) {
1761
1841
  if (!Number.isFinite(e) || e <= 0)
1762
1842
  throw new Error(
1763
1843
  `feeRateSatsVb must be a positive finite number, got ${e}`
1764
1844
  );
1765
- return BigInt(Math.ceil(e * nt));
1845
+ return BigInt(Math.ceil(e * ht));
1766
1846
  }
1767
- const lo = 1, ho = /non-BIP68-final/i;
1768
- function ne(e, t) {
1847
+ const xo = 1, wo = /non-BIP68-final/i;
1848
+ function ce(e, t) {
1769
1849
  if (e.length !== 66)
1770
1850
  throw new Error(
1771
1851
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
1772
1852
  );
1773
- if (!uo.test(e))
1853
+ if (!vo.test(e))
1774
1854
  throw new Error(
1775
1855
  `${t} must contain only hex characters after the 0x prefix`
1776
1856
  );
1777
1857
  }
1778
- function re(e, t) {
1858
+ function ie(e, t) {
1779
1859
  if (!Number.isInteger(e) || e < 0)
1780
1860
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
1781
1861
  }
1782
- function po(e) {
1783
- if (ne(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
1862
+ function Eo(e) {
1863
+ if (ce(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
1784
1864
  throw new Error(
1785
1865
  `htlcVout must be a non-negative integer, got ${e.htlcVout}`
1786
1866
  );
@@ -1792,7 +1872,7 @@ function po(e) {
1792
1872
  );
1793
1873
  for (let r = 0; r < e.batch.length; r++) {
1794
1874
  const o = e.batch[r];
1795
- if (ne(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
1875
+ if (ce(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
1796
1876
  throw new Error(
1797
1877
  `batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${o.htlcVout}`
1798
1878
  );
@@ -1810,27 +1890,27 @@ function po(e) {
1810
1890
  throw new Error(
1811
1891
  `batch[${e.htlcVout}].amount (${t.amount}) does not match target amount (${e.amount})`
1812
1892
  );
1813
- if (re(e.offchainParamsVersion, "offchainParamsVersion"), re(e.appVaultKeepersVersion, "appVaultKeepersVersion"), re(
1893
+ if (ie(e.offchainParamsVersion, "offchainParamsVersion"), ie(e.appVaultKeepersVersion, "appVaultKeepersVersion"), ie(
1814
1894
  e.universalChallengersVersion,
1815
1895
  "universalChallengersVersion"
1816
- ), jt(
1896
+ ), Zt(
1817
1897
  e.vaultCoreVersion,
1818
1898
  "VaultRefundData.vaultCoreVersion"
1819
1899
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
1820
1900
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
1821
- if (!co.test(e.unsignedPrePeginTxHex))
1901
+ if (!Po.test(e.unsignedPrePeginTxHex))
1822
1902
  throw new Error(
1823
1903
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
1824
1904
  );
1825
- if (!e.depositorBtcPubkey || !ot.test(e.depositorBtcPubkey))
1905
+ if (!e.depositorBtcPubkey || !lt.test(e.depositorBtcPubkey))
1826
1906
  throw new Error(
1827
1907
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
1828
1908
  );
1829
1909
  if (typeof e.amount != "bigint" || e.amount <= 0n)
1830
1910
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
1831
1911
  }
1832
- function go(e) {
1833
- if (!e.vaultProviderPubkey || !ot.test(e.vaultProviderPubkey))
1912
+ function _o(e) {
1913
+ if (!e.vaultProviderPubkey || !lt.test(e.vaultProviderPubkey))
1834
1914
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
1835
1915
  if (e.vaultKeeperPubkeys.length === 0)
1836
1916
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -1855,276 +1935,276 @@ function go(e) {
1855
1935
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
1856
1936
  );
1857
1937
  }
1858
- async function rn(e) {
1938
+ async function dn(e) {
1859
1939
  const {
1860
1940
  vaultId: t,
1861
1941
  readVault: r,
1862
1942
  readPrePeginContext: o,
1863
1943
  feeRate: n,
1864
- signPsbt: a,
1865
- broadcastTx: s,
1866
- signal: i
1944
+ signPsbt: i,
1945
+ broadcastTx: a,
1946
+ signal: s
1867
1947
  } = e;
1868
- i == null || i.throwIfAborted(), ne(t, "vaultId");
1948
+ s == null || s.throwIfAborted(), ce(t, "vaultId");
1869
1949
  const u = await r();
1870
- po(u), i == null || i.throwIfAborted();
1871
- const c = await o(u);
1872
- if (go(c), i == null || i.throwIfAborted(), !Number.isFinite(n) || n <= 0)
1950
+ Eo(u), s == null || s.throwIfAborted();
1951
+ const l = await o(u);
1952
+ if (_o(l), s == null || s.throwIfAborted(), !Number.isFinite(n) || n <= 0)
1873
1953
  throw new Error(`feeRate must be a positive number, got ${n}`);
1874
- if (n > Ae)
1954
+ if (n > Be)
1875
1955
  throw new Error(
1876
- `feeRate ${n} sat/vB exceeds refund safety cap ${Ae} sat/vB; refusing to sign refund.`
1956
+ `feeRate ${n} sat/vB exceeds refund safety cap ${Be} sat/vB; refusing to sign refund.`
1877
1957
  );
1878
- const h = BigInt(Math.ceil(n * nt)), l = u.amount * Se / Ie;
1879
- if (h > l)
1958
+ const c = BigInt(Math.ceil(n * ht)), h = u.amount * Ve / He;
1959
+ if (c > h)
1880
1960
  throw new Error(
1881
- `Refund fee ${h} sats exceeds the per-vault safety cap of ${l} sats (${Se}/${Ie} of vault.amount=${u.amount}); refusing to sign refund.`
1961
+ `Refund fee ${c} sats exceeds the per-vault safety cap of ${h} sats (${Ve}/${He} of vault.amount=${u.amount}); refusing to sign refund.`
1882
1962
  );
1883
- i == null || i.throwIfAborted();
1884
- const p = j(
1963
+ s == null || s.throwIfAborted();
1964
+ const p = Q(
1885
1965
  u.depositorBtcPubkey
1886
- ), d = f(u.unsignedPrePeginTxHex), g = dt(d);
1966
+ ), d = b(u.unsignedPrePeginTxHex), g = Pt(d);
1887
1967
  if (g !== void 0 && g.vout !== u.batch.length)
1888
1968
  throw new Error(
1889
1969
  `Auth-anchor OP_RETURN at vout ${g.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.`
1890
1970
  );
1891
- const b = g == null ? void 0 : g.hash;
1892
- let y;
1971
+ const y = g == null ? void 0 : g.hash;
1972
+ let f;
1893
1973
  try {
1894
- y = B.fromHex(d);
1895
- } catch (P) {
1974
+ f = B.fromHex(d);
1975
+ } catch (v) {
1896
1976
  throw new Error(
1897
- `Failed to parse funded Pre-PegIn transaction hex: ${P instanceof Error ? P.message : String(P)}`
1977
+ `Failed to parse funded Pre-PegIn transaction hex: ${v instanceof Error ? v.message : String(v)}`
1898
1978
  );
1899
1979
  }
1900
- if (y.outs.length < u.batch.length)
1980
+ if (f.outs.length < u.batch.length)
1901
1981
  throw new Error(
1902
- `Funded Pre-PegIn tx has ${y.outs.length} outputs but batch requires at least ${u.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
1982
+ `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.`
1903
1983
  );
1904
- const { psbtHex: m } = await Lt({
1984
+ const { psbtHex: P } = await Yt({
1905
1985
  prePeginParams: {
1906
1986
  vaultCoreVersion: u.vaultCoreVersion,
1907
1987
  depositorPubkey: p,
1908
- vaultProviderPubkey: f(c.vaultProviderPubkey),
1909
- vaultKeeperPubkeys: c.vaultKeeperPubkeys.map(f),
1910
- universalChallengerPubkeys: c.universalChallengerPubkeys.map(f),
1911
- hashlocks: u.batch.map((P) => f(P.hashlock)),
1912
- timelockRefund: c.timelockRefund,
1988
+ vaultProviderPubkey: b(l.vaultProviderPubkey),
1989
+ vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(b),
1990
+ universalChallengerPubkeys: l.universalChallengerPubkeys.map(b),
1991
+ hashlocks: u.batch.map((v) => b(v.hashlock)),
1992
+ timelockRefund: l.timelockRefund,
1913
1993
  // `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
1914
1994
  // is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
1915
1995
  // reserve (`depositorClaimValue + minPeginFee`) internally when sizing the
1916
1996
  // HTLC output. `buildRefundPsbt`'s value cross-check then binds the result
1917
1997
  // to the funded tx bytes, refusing the refund if the template's HTLC value
1918
1998
  // disagrees with the on-chain commitment.
1919
- pegInAmounts: u.batch.map((P) => P.amount),
1920
- feeRate: c.feeRate,
1921
- minPeginFeeRate: c.minPeginFeeRate,
1922
- numLocalChallengers: c.numLocalChallengers,
1923
- councilQuorum: c.councilQuorum,
1924
- councilSize: c.councilSize,
1925
- network: c.network,
1926
- authAnchorHash: b
1999
+ pegInAmounts: u.batch.map((v) => v.amount),
2000
+ feeRate: l.feeRate,
2001
+ minPeginFeeRate: l.minPeginFeeRate,
2002
+ numLocalChallengers: l.numLocalChallengers,
2003
+ councilQuorum: l.councilQuorum,
2004
+ councilSize: l.councilSize,
2005
+ network: l.network,
2006
+ authAnchorHash: y
1927
2007
  },
1928
2008
  fundedPrePeginTxHex: d,
1929
2009
  htlcVout: u.htlcVout,
1930
- refundFee: h,
2010
+ refundFee: c,
1931
2011
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
1932
2012
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
1933
2013
  // value would derive the wrong refund script leaf and yield an
1934
2014
  // unspendable PSBT. Match the `hashlocks` array handling above.
1935
- hashlock: f(u.hashlock)
2015
+ hashlock: b(u.hashlock)
1936
2016
  });
1937
- i == null || i.throwIfAborted();
1938
- const x = M(
2017
+ s == null || s.throwIfAborted();
2018
+ const x = U(
1939
2019
  u.depositorBtcPubkey,
1940
- lo
1941
- ), w = await a(m, x);
1942
- F({
1943
- requestedPsbtHex: m,
2020
+ xo
2021
+ ), w = await i(P, x);
2022
+ X({
2023
+ requestedPsbtHex: P,
1944
2024
  returnedPsbtHex: w
1945
2025
  });
1946
- const k = 0, _ = U(
2026
+ const _ = 0, k = q(
1947
2027
  w,
1948
2028
  p,
1949
- k
2029
+ _
1950
2030
  );
1951
- L({
1952
- requestedPsbtHex: m,
1953
- signatureHex: _,
2031
+ j({
2032
+ requestedPsbtHex: P,
2033
+ signatureHex: k,
1954
2034
  signerXOnlyPubkeyHex: p,
1955
- inputIndex: k
2035
+ inputIndex: _
1956
2036
  });
1957
- const C = Le({
1958
- requestedPsbtHex: m,
1959
- signaturesHex: [_],
2037
+ const T = je({
2038
+ requestedPsbtHex: P,
2039
+ signaturesHex: [k],
1960
2040
  signerXOnlyPubkeyHex: p
1961
2041
  });
1962
- i == null || i.throwIfAborted();
2042
+ s == null || s.throwIfAborted();
1963
2043
  try {
1964
- return await s(C);
1965
- } catch (P) {
1966
- throw P instanceof Error && ho.test(P.message) ? new io(t, P) : P;
2044
+ return await a(T);
2045
+ } catch (v) {
2046
+ throw v instanceof Error && wo.test(v.message) ? new mo(t, v) : v;
1967
2047
  }
1968
2048
  }
1969
- class Re extends Error {
2049
+ class Oe extends Error {
1970
2050
  constructor(r, o, n) {
1971
2051
  super(r);
1972
2052
  /** Fee the reclaim would have paid, in satoshis. */
1973
- O(this, "feeSats");
2053
+ K(this, "feeSats");
1974
2054
  /** Sum of the reserves the reclaim would have swept, in satoshis. */
1975
- O(this, "sweptTotalSats");
2055
+ K(this, "sweptTotalSats");
1976
2056
  this.name = "ReclaimUneconomicalError", this.feeSats = o, this.sweptTotalSats = n;
1977
2057
  }
1978
2058
  }
1979
- const Be = 2e3, Ve = 25n, Oe = 100n, on = 10n;
1980
- async function fo(e, t, r) {
2059
+ const Ne = 2e3, Ke = 25n, De = 100n, gn = 10n;
2060
+ async function ko(e, t, r) {
1981
2061
  for (let o = 0; o < e.length; o++) {
1982
- const n = ft(e[o].depositorSignedPeginTxHex), a = He(
1983
- await Ct(
1984
- f(n),
1985
- f(r)
2062
+ const n = wt(e[o].depositorSignedPeginTxHex), i = Fe(
2063
+ await Ht(
2064
+ b(n),
2065
+ b(r)
1986
2066
  )
1987
2067
  ).toLowerCase();
1988
- if (a !== t[o].toLowerCase())
2068
+ if (i !== t[o].toLowerCase())
1989
2069
  throw new Error(
1990
- `Reserve ${o} belongs to vault ${a}, not the requested ${t[o].toLowerCase()}. Refusing to sweep a reserve whose vault is not the one the caller asked for — the reserve funds that vault's claim transaction and cannot be replaced.`
2070
+ `Reserve ${o} belongs to vault ${i}, not the requested ${t[o].toLowerCase()}. Refusing to sweep a reserve whose vault is not the one the caller asked for — the reserve funds that vault's claim transaction and cannot be replaced.`
1991
2071
  );
1992
2072
  }
1993
2073
  }
1994
- async function nn(e) {
2074
+ async function fn(e) {
1995
2075
  const {
1996
2076
  vaultIds: t,
1997
2077
  depositorEthAddress: r,
1998
2078
  depositorBtcPubkey: o,
1999
2079
  readVaults: n,
2000
- feeRate: a,
2001
- signPsbt: s,
2002
- broadcastTx: i,
2080
+ feeRate: i,
2081
+ signPsbt: a,
2082
+ broadcastTx: s,
2003
2083
  signal: u
2004
2084
  } = e;
2005
2085
  if (u == null || u.throwIfAborted(), t.length === 0)
2006
2086
  throw new Error("Reclaim requires at least one vault id; got none.");
2007
- if (!Number.isFinite(a) || a <= 0)
2008
- throw new Error(`feeRate must be a positive number, got ${a}`);
2009
- if (a > Be)
2010
- throw new Re(
2011
- `Fee rate ${a} sat/vB exceeds the reclaim safety cap of ${Be} sat/vB; refusing to sign.`,
2087
+ if (!Number.isFinite(i) || i <= 0)
2088
+ throw new Error(`feeRate must be a positive number, got ${i}`);
2089
+ if (i > Ne)
2090
+ throw new Oe(
2091
+ `Fee rate ${i} sat/vB exceeds the reclaim safety cap of ${Ne} sat/vB; refusing to sign.`,
2012
2092
  0n,
2013
2093
  0n
2014
2094
  );
2015
- const c = await n();
2016
- if (u == null || u.throwIfAborted(), c.length !== t.length)
2095
+ const l = await n();
2096
+ if (u == null || u.throwIfAborted(), l.length !== t.length)
2017
2097
  throw new Error(
2018
- `readVaults returned ${c.length} reserves for ${t.length} vault id(s); refusing to sweep a set that does not match the request.`
2019
- );
2020
- await fo(c, t, r), u == null || u.throwIfAborted();
2021
- const h = j(o), l = c.map((k) => ({
2022
- depositorSignedPeginTxHex: k.depositorSignedPeginTxHex,
2023
- observed: k.observed,
2024
- expectedValue: k.expectedClaimValue
2025
- })), p = Gt(a, l.length), d = l.reduce((k, _) => k + _.expectedValue, 0n), g = d * Ve / Oe;
2098
+ `readVaults returned ${l.length} reserves for ${t.length} vault id(s); refusing to sweep a set that does not match the request.`
2099
+ );
2100
+ await ko(l, t, r), u == null || u.throwIfAborted();
2101
+ const c = Q(o), h = l.map((_) => ({
2102
+ depositorSignedPeginTxHex: _.depositorSignedPeginTxHex,
2103
+ observed: _.observed,
2104
+ expectedValue: _.expectedClaimValue
2105
+ })), p = Qt(i, h.length), d = h.reduce((_, k) => _ + k.expectedValue, 0n), g = d * Ke / De;
2026
2106
  if (p > g)
2027
- throw new Re(
2028
- `Reclaim fee ${p} sats exceeds ${Ve}/${Oe} of the swept total (${d} sats, cap ${g} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
2107
+ throw new Oe(
2108
+ `Reclaim fee ${p} sats exceeds ${Ke}/${De} of the swept total (${d} sats, cap ${g} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
2029
2109
  p,
2030
2110
  d
2031
2111
  );
2032
2112
  u == null || u.throwIfAborted();
2033
- const { psbtHex: b } = Xt({
2034
- depositorPubkey: h,
2035
- inputs: l,
2113
+ const { psbtHex: y } = Jt({
2114
+ depositorPubkey: c,
2115
+ inputs: h,
2036
2116
  feeSats: p
2037
2117
  });
2038
2118
  u == null || u.throwIfAborted();
2039
- const y = M(
2119
+ const f = U(
2040
2120
  o,
2041
- l.length
2042
- ), m = await s(b, y);
2043
- F({
2044
- requestedPsbtHex: b,
2045
- returnedPsbtHex: m
2121
+ h.length
2122
+ ), P = await a(y, f);
2123
+ X({
2124
+ requestedPsbtHex: y,
2125
+ returnedPsbtHex: P
2046
2126
  });
2047
- const x = l.map((k, _) => {
2048
- const C = U(
2049
- m,
2050
- h,
2051
- _
2052
- );
2053
- return L({
2054
- requestedPsbtHex: b,
2055
- signatureHex: C,
2056
- signerXOnlyPubkeyHex: h,
2057
- inputIndex: _
2058
- }), C;
2059
- }), w = Le({
2060
- requestedPsbtHex: b,
2127
+ const x = h.map((_, k) => {
2128
+ const T = q(
2129
+ P,
2130
+ c,
2131
+ k
2132
+ );
2133
+ return j({
2134
+ requestedPsbtHex: y,
2135
+ signatureHex: T,
2136
+ signerXOnlyPubkeyHex: c,
2137
+ inputIndex: k
2138
+ }), T;
2139
+ }), w = je({
2140
+ requestedPsbtHex: y,
2061
2141
  signaturesHex: x,
2062
- signerXOnlyPubkeyHex: h
2142
+ signerXOnlyPubkeyHex: c
2063
2143
  });
2064
- return u == null || u.throwIfAborted(), i(w);
2144
+ return u == null || u.throwIfAborted(), s(w);
2065
2145
  }
2066
2146
  export {
2067
- Se as $,
2068
- br as A,
2069
- Wo as B,
2070
- Jt as C,
2071
- yr as D,
2072
- zo as E,
2073
- ro as F,
2074
- v as G,
2075
- oo as H,
2076
- tt as I,
2077
- Qo as J,
2078
- Jo as K,
2079
- Zo as L,
2080
- en as M,
2081
- Je as N,
2082
- Lo as O,
2083
- er as P,
2084
- Z as Q,
2085
- rt as R,
2086
- Qr as S,
2087
- _e as T,
2088
- Zr as U,
2089
- or as V,
2090
- eo as W,
2091
- io as X,
2092
- rn as Y,
2093
- tn as Z,
2094
- Ie as _,
2095
- Bo as a,
2096
- Ae as a0,
2097
- nt as a1,
2098
- Re as a2,
2099
- nn as a3,
2100
- Oe as a4,
2101
- Ve as a5,
2102
- Be as a6,
2103
- on as a7,
2104
- Vo as b,
2105
- Oo as c,
2106
- No as d,
2107
- Ho as e,
2108
- Zt as f,
2109
- tr as g,
2110
- qe as h,
2111
- wr as i,
2112
- We as j,
2113
- Ye as k,
2114
- _r as l,
2115
- Ko as m,
2116
- Mo as n,
2117
- Br as o,
2118
- Fr as p,
2119
- Uo as q,
2120
- Fo as r,
2121
- mr as s,
2122
- oe as t,
2123
- Go as u,
2124
- Xo as v,
2125
- Do as w,
2126
- jo as x,
2127
- qo as y,
2128
- Yo as z
2147
+ Ve as $,
2148
+ _r as A,
2149
+ sn as B,
2150
+ sr as C,
2151
+ Er as D,
2152
+ nn as E,
2153
+ po as F,
2154
+ m as G,
2155
+ go as H,
2156
+ ut as I,
2157
+ un as J,
2158
+ cn as K,
2159
+ ln as L,
2160
+ hn as M,
2161
+ st as N,
2162
+ Zo as O,
2163
+ ir as P,
2164
+ ne as Q,
2165
+ ct as R,
2166
+ io as S,
2167
+ Ae as T,
2168
+ co as U,
2169
+ lr as V,
2170
+ lo as W,
2171
+ mo as X,
2172
+ dn as Y,
2173
+ pn as Z,
2174
+ He as _,
2175
+ Uo as a,
2176
+ Be as a0,
2177
+ ht as a1,
2178
+ Oe as a2,
2179
+ fn as a3,
2180
+ De as a4,
2181
+ Ke as a5,
2182
+ Ne as a6,
2183
+ gn as a7,
2184
+ Go as b,
2185
+ Xo as c,
2186
+ qo as d,
2187
+ jo as e,
2188
+ ar as f,
2189
+ ur as g,
2190
+ Qe as h,
2191
+ Cr as i,
2192
+ Ze as j,
2193
+ et as k,
2194
+ Rr as l,
2195
+ zo as m,
2196
+ Yo as n,
2197
+ Ur as o,
2198
+ Qr as p,
2199
+ Jo as q,
2200
+ Qo as r,
2201
+ kr as s,
2202
+ ue as t,
2203
+ en as u,
2204
+ tn as v,
2205
+ Wo as w,
2206
+ rn as x,
2207
+ on as y,
2208
+ an as z
2129
2209
  };
2130
- //# sourceMappingURL=buildAndBroadcastReclaim-T5ZFPUpM.js.map
2210
+ //# sourceMappingURL=buildAndBroadcastReclaim-D5520lbL.js.map