@babylonlabs-io/ts-sdk 0.77.0 → 0.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/{BTCVaultRegistry.abi-CJwWI2EO.js → BTCVaultRegistry.abi-B0x9_Bza.js} +321 -2
  2. package/dist/BTCVaultRegistry.abi-B0x9_Bza.js.map +1 -0
  3. package/dist/BTCVaultRegistry.abi-BQ5tFNSu.cjs +2 -0
  4. package/dist/BTCVaultRegistry.abi-BQ5tFNSu.cjs.map +1 -0
  5. package/dist/{BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js → BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js} +57 -20
  6. package/dist/BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js.map +1 -0
  7. package/dist/BTCVaultRegistryKeyEpochs.abi-DCJnzKer.cjs +2 -0
  8. package/dist/BTCVaultRegistryKeyEpochs.abi-DCJnzKer.cjs.map +1 -0
  9. package/dist/{PeginManager-DNimKlmw.js → PeginManager-BXlh3ar0.js} +289 -348
  10. package/dist/PeginManager-BXlh3ar0.js.map +1 -0
  11. package/dist/PeginManager-BuVSknB0.cjs +2 -0
  12. package/dist/PeginManager-BuVSknB0.cjs.map +1 -0
  13. package/dist/ProtocolParams.abi-Db2USqQm.cjs +2 -0
  14. package/dist/ProtocolParams.abi-Db2USqQm.cjs.map +1 -0
  15. package/dist/ProtocolParams.abi-q0AidvYX.js +526 -0
  16. package/dist/ProtocolParams.abi-q0AidvYX.js.map +1 -0
  17. package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs +2 -0
  18. package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs.map +1 -0
  19. package/dist/{buildAndBroadcastReclaim-DCGcupg7.js → buildAndBroadcastReclaim-O6z9kvc4.js} +502 -468
  20. package/dist/buildAndBroadcastReclaim-O6z9kvc4.js.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +229 -222
  23. package/dist/pegin-registration-client-CZgcU2_0.cjs +2 -0
  24. package/dist/pegin-registration-client-CZgcU2_0.cjs.map +1 -0
  25. package/dist/{pegin-registration-client-CXK3B_D1.js → pegin-registration-client-pcczkzMg.js} +344 -240
  26. package/dist/pegin-registration-client-pcczkzMg.js.map +1 -0
  27. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  28. package/dist/tbv/core/clients/eth/index.d.ts +1 -0
  29. package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
  30. package/dist/tbv/core/clients/eth/index.js +14 -12
  31. package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts +17 -0
  32. package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts.map +1 -1
  33. package/dist/tbv/core/clients/eth/registration-logs-error.d.ts +20 -0
  34. package/dist/tbv/core/clients/eth/registration-logs-error.d.ts.map +1 -0
  35. package/dist/tbv/core/clients/eth/signer-set-reader.d.ts +2 -0
  36. package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
  37. package/dist/tbv/core/clients/eth/types.d.ts +40 -0
  38. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  39. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +31 -0
  40. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  41. package/dist/tbv/core/clients/index.cjs +1 -1
  42. package/dist/tbv/core/clients/index.js +41 -39
  43. package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts +24 -0
  44. package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts.map +1 -0
  45. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +14 -0
  46. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
  47. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +265 -1
  48. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  49. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +10 -0
  50. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  51. package/dist/tbv/core/contracts/errors.d.ts +41 -4
  52. package/dist/tbv/core/contracts/errors.d.ts.map +1 -1
  53. package/dist/tbv/core/contracts/index.cjs +1 -1
  54. package/dist/tbv/core/contracts/index.cjs.map +1 -1
  55. package/dist/tbv/core/contracts/index.d.ts +1 -1
  56. package/dist/tbv/core/contracts/index.d.ts.map +1 -1
  57. package/dist/tbv/core/contracts/index.js +15 -492
  58. package/dist/tbv/core/contracts/index.js.map +1 -1
  59. package/dist/tbv/core/deposit-terms/commissionCeiling.d.ts +3 -2
  60. package/dist/tbv/core/deposit-terms/commissionCeiling.d.ts.map +1 -1
  61. package/dist/tbv/core/index.cjs +1 -1
  62. package/dist/tbv/core/index.js +224 -217
  63. package/dist/tbv/core/managers/PeginManager.d.ts +13 -25
  64. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  65. package/dist/tbv/core/managers/index.cjs +1 -1
  66. package/dist/tbv/core/managers/index.d.ts +2 -2
  67. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  68. package/dist/tbv/core/managers/index.js +4 -5
  69. package/dist/tbv/core/pegin-fingerprint/index.d.ts +1 -1
  70. package/dist/tbv/core/pegin-fingerprint/index.d.ts.map +1 -1
  71. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts +10 -0
  72. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts.map +1 -1
  73. package/dist/tbv/core/services/deposit/index.d.ts +1 -1
  74. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  75. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +50 -3
  76. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
  77. package/dist/tbv/core/services/index.cjs +1 -1
  78. package/dist/tbv/core/services/index.js +56 -54
  79. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -1
  80. package/dist/tbv/index.cjs +1 -1
  81. package/dist/tbv/index.js +224 -217
  82. package/dist/{toRefundInputs-BNSXIymn.js → toRefundInputs-9inv4Ai4.js} +96 -92
  83. package/dist/toRefundInputs-9inv4Ai4.js.map +1 -0
  84. package/dist/toRefundInputs-DitGWAnz.cjs +2 -0
  85. package/dist/toRefundInputs-DitGWAnz.cjs.map +1 -0
  86. package/dist/{types-C5DyrC8F.js → types-B9YhlXe8.js} +109 -83
  87. package/dist/types-B9YhlXe8.js.map +1 -0
  88. package/dist/types-C1tpDycc.cjs +2 -0
  89. package/dist/types-C1tpDycc.cjs.map +1 -0
  90. package/package.json +3 -3
  91. package/dist/BTCVaultRegistry.abi-CJwWI2EO.js.map +0 -1
  92. package/dist/BTCVaultRegistry.abi-z7d_eP22.cjs +0 -2
  93. package/dist/BTCVaultRegistry.abi-z7d_eP22.cjs.map +0 -1
  94. package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs +0 -2
  95. package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs.map +0 -1
  96. package/dist/BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js.map +0 -1
  97. package/dist/PeginManager-DEByBX5R.cjs +0 -2
  98. package/dist/PeginManager-DEByBX5R.cjs.map +0 -1
  99. package/dist/PeginManager-DNimKlmw.js.map +0 -1
  100. package/dist/buildAndBroadcastReclaim-Cqc6Jiqk.cjs +0 -2
  101. package/dist/buildAndBroadcastReclaim-Cqc6Jiqk.cjs.map +0 -1
  102. package/dist/buildAndBroadcastReclaim-DCGcupg7.js.map +0 -1
  103. package/dist/pegin-registration-client-CXK3B_D1.js.map +0 -1
  104. package/dist/pegin-registration-client-DLsMNm8Z.cjs +0 -2
  105. package/dist/pegin-registration-client-DLsMNm8Z.cjs.map +0 -1
  106. package/dist/toRefundInputs-BNSXIymn.js.map +0 -1
  107. package/dist/toRefundInputs-meTyor7r.cjs +0 -2
  108. package/dist/toRefundInputs-meTyor7r.cjs.map +0 -1
  109. package/dist/types-BzSOthHH.cjs +0 -2
  110. package/dist/types-BzSOthHH.cjs.map +0 -1
  111. package/dist/types-C5DyrC8F.js.map +0 -1
@@ -1,52 +1,52 @@
1
- var xe = Object.defineProperty;
2
- var Te = (e, t, r) => t in e ? xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var S = (e, t, r) => Te(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { B as ie } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
5
- import { e as ue, v as Re, s as P, u as le, p as O, c as R, f as _ } from "./bitcoin-C-TuHb-v.js";
6
- import { v as Ce, d as Ae, s as _e, P as Se, a as $e } from "./signPsbtsWithFallback-f7QLp0q8.js";
7
- import { zeroAddress as Be } from "viem";
8
- import { D as C, c as Ie, b as Ve, R as Ke, d as ce } from "./json-rpc-client-DuUARJvV.js";
1
+ var Re = Object.defineProperty;
2
+ var _e = (e, t, r) => t in e ? Re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var S = (e, t, r) => _e(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { B as pe } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
5
+ import { e as he, v as Se, s as y, u as de, p as O, c as C, f as _ } from "./bitcoin-C-TuHb-v.js";
6
+ import { v as $e, d as Be, s as Ie, P as Ve, a as Ke } from "./signPsbtsWithFallback-f7QLp0q8.js";
7
+ import { zeroAddress as Oe, isAddress as Ne, isAddressEqual as He } from "viem";
8
+ import { D as R, c as De, b as Me, R as Fe, d as ge } from "./json-rpc-client-DuUARJvV.js";
9
9
  import { Transaction as $ } from "bitcoinjs-lib";
10
- import { p as Oe, f as Ne, i as B, g as I, j as V } from "./verifyScriptPathSchnorrSignature-D_epga4j.js";
11
- import { D as q } from "./constants-D5vORbQE.js";
12
- import { d as He, c as De, b as Fe, f as he, e as Me, a as Le } from "./noPayout-DiGr4eas.js";
13
- import { a as K, c as Ue } from "./signing-Cm-McVR2.js";
14
- import { a as z } from "./onChainBtcPubkey-C-6UWpD8.js";
15
- import { a as Xe } from "./secp256k1-D-H9jmd7.js";
16
- import { deriveVaultId as Ge } from "./tbv/core/wasm/index.js";
17
- const qe = /^0x[0-9a-fA-F]{64}$/, ze = /^0x[0-9a-fA-F]{40}$/, je = /^0x([0-9a-fA-F]{2})*$/;
10
+ import { p as Ue, f as Le, i as B, g as I, j as V } from "./verifyScriptPathSchnorrSignature-D_epga4j.js";
11
+ import { D as W } from "./constants-D5vORbQE.js";
12
+ import { d as Xe, c as qe, b as Ge, f as fe, e as ze, a as je } from "./noPayout-DiGr4eas.js";
13
+ import { a as K, c as Qe } from "./signing-Cm-McVR2.js";
14
+ import { a as Y } from "./onChainBtcPubkey-C-6UWpD8.js";
15
+ import { a as We } from "./secp256k1-D-H9jmd7.js";
16
+ import { deriveVaultId as Ye } from "./tbv/core/wasm/index.js";
17
+ const Je = /^0x[0-9a-fA-F]{64}$/, Ze = /^0x[0-9a-fA-F]{40}$/, et = /^0x([0-9a-fA-F]{2})*$/;
18
18
  function N(e, t) {
19
19
  if (e.length !== 66)
20
20
  throw new Error(
21
21
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
22
22
  );
23
- if (!qe.test(e))
23
+ if (!Je.test(e))
24
24
  throw new Error(
25
25
  `${t} must contain only hex characters after the 0x prefix`
26
26
  );
27
27
  }
28
- function Qe(e, t) {
29
- if (!ze.test(e))
28
+ function tt(e, t) {
29
+ if (!Ze.test(e))
30
30
  throw new Error(
31
31
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
32
32
  );
33
33
  }
34
- function We(e, t) {
35
- if (!je.test(e))
34
+ function rt(e, t) {
35
+ if (!et.test(e))
36
36
  throw new Error(
37
37
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
38
38
  );
39
39
  }
40
- function de(e) {
41
- Qe(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), N(e.vaultId, "vaultId");
42
- const t = ue(e.secret);
43
- if (N(t, "secret"), e.hashlock !== void 0 && (N(e.hashlock, "hashlock"), !Ce(t, e.hashlock)))
40
+ function me(e) {
41
+ tt(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), N(e.vaultId, "vaultId");
42
+ const t = he(e.secret);
43
+ if (N(t, "secret"), e.hashlock !== void 0 && (N(e.hashlock, "hashlock"), !$e(t, e.hashlock)))
44
44
  throw new Error(
45
45
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
46
46
  );
47
47
  return t;
48
48
  }
49
- async function Yt(e) {
49
+ async function or(e) {
50
50
  const {
51
51
  btcVaultRegistryAddress: t,
52
52
  vaultId: r,
@@ -56,23 +56,23 @@ async function Yt(e) {
56
56
  signal: s
57
57
  } = e;
58
58
  s == null || s.throwIfAborted();
59
- const i = de({
59
+ const i = me({
60
60
  btcVaultRegistryAddress: t,
61
61
  vaultId: r,
62
62
  secret: e.secret,
63
63
  hashlock: o
64
64
  });
65
- return We(a, "activationMetadata"), l({
65
+ return rt(a, "activationMetadata"), l({
66
66
  address: t,
67
- abi: ie,
67
+ abi: pe,
68
68
  functionName: "activateVaultWithSecret",
69
69
  args: [r, i, a]
70
70
  });
71
71
  }
72
- async function Jt(e) {
72
+ async function nr(e) {
73
73
  const { btcVaultRegistryAddress: t, vaultId: r, hashlock: o, writeContract: a, signal: l } = e;
74
74
  l == null || l.throwIfAborted();
75
- const s = de({
75
+ const s = me({
76
76
  btcVaultRegistryAddress: t,
77
77
  vaultId: r,
78
78
  secret: e.secret,
@@ -80,40 +80,40 @@ async function Jt(e) {
80
80
  });
81
81
  return a({
82
82
  address: t,
83
- abi: ie,
83
+ abi: pe,
84
84
  functionName: "activateVaultWithSecretAndRedeem",
85
85
  args: [r, s]
86
86
  });
87
87
  }
88
- const Ye = 8, Je = 6e3, Ze = 10 * 6e4, et = 10;
89
- class pe extends Error {
88
+ const ot = 8, nt = 6e3, st = 10 * 6e4, at = 10;
89
+ class Pe extends Error {
90
90
  constructor(t) {
91
91
  super(t), this.name = "PeginRegistrationMissingError";
92
92
  }
93
93
  }
94
- class ge extends Error {
94
+ class ve extends Error {
95
95
  constructor(t) {
96
96
  super(t), this.name = "PeginRegistrationNotFinalError";
97
97
  }
98
98
  }
99
- function tt(e) {
100
- return e instanceof pe || e instanceof Error && e.name === "PeginRegistrationMissingError";
99
+ function it(e) {
100
+ return e instanceof Pe || e instanceof Error && e.name === "PeginRegistrationMissingError";
101
101
  }
102
- function Zt(e) {
103
- return e instanceof ge || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
102
+ function sr(e) {
103
+ return e instanceof ve || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
104
104
  }
105
- function j(e) {
105
+ function J(e) {
106
106
  const { currentBlock: t, createdAtBlock: r } = e, o = t - r + 1n;
107
107
  return o < 0n ? 0 : Number(o);
108
108
  }
109
- async function er(e) {
109
+ async function ar(e) {
110
110
  const {
111
111
  vaultRegistryReader: t,
112
112
  getBlockNumber: r,
113
113
  vaultIds: o,
114
- required: a = Ye,
115
- pollIntervalMs: l = Je,
116
- timeoutMs: s = Ze,
114
+ required: a = ot,
115
+ pollIntervalMs: l = nt,
116
+ timeoutMs: s = st,
117
117
  signal: i,
118
118
  onProgress: n
119
119
  } = e;
@@ -122,92 +122,92 @@ async function er(e) {
122
122
  "waitForPeginRegistrationDepth requires at least one vault ID"
123
123
  );
124
124
  const u = Date.now();
125
- let h = !1, c = 0, d;
125
+ let p = !1, c = 0, h;
126
126
  for (; ; ) {
127
127
  if (i != null && i.aborted)
128
128
  throw new Error(
129
129
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
130
130
  );
131
131
  if (Date.now() - u >= s)
132
- throw new ge(
133
- `Peg-in registration did not reach ${a} 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.` + (d instanceof Error ? ` Last read error: ${d.message}` : "")
132
+ throw new ve(
133
+ `Peg-in registration did not reach ${a} 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.` + (h instanceof Error ? ` Last read error: ${h.message}` : "")
134
134
  );
135
135
  try {
136
- const p = await r(), g = await Promise.all(
137
- o.map((f) => t.getVaultBasicInfo(f))
136
+ const d = await r(), g = await Promise.all(
137
+ o.map((P) => t.getVaultBasicInfo(P))
138
138
  ), m = g.findIndex(
139
- (f) => f.depositor === Be || f.createdAt === 0n
139
+ (P) => P.depositor === Oe || P.createdAt === 0n
140
140
  );
141
141
  if (m !== -1) {
142
- if (c += 1, !h && c > et)
143
- throw new pe(
142
+ if (c += 1, !p && c > at)
143
+ throw new Pe(
144
144
  `Vault ${o[m]} is still not visible on-chain after ${c} reads — the registration does not exist.`
145
145
  );
146
146
  console.warn(
147
- `Peg-in registration for vault ${o[m]} is not visible in chain state at block ${p} — a lagging RPC backend or an Ethereum reorg. Still polling.`
147
+ `Peg-in registration for vault ${o[m]} is not visible in chain state at block ${d} — a lagging RPC backend or an Ethereum reorg. Still polling.`
148
148
  ), n == null || n({ confirmations: 0, required: a });
149
149
  } else {
150
- h = !0, c = 0, d = void 0;
151
- let f = g[0], v = j({
152
- currentBlock: p,
150
+ p = !0, c = 0, h = void 0;
151
+ let P = g[0], f = J({
152
+ currentBlock: d,
153
153
  createdAtBlock: g[0].createdAt
154
154
  });
155
- for (const w of g.slice(1)) {
156
- const k = j({
157
- currentBlock: p,
158
- createdAtBlock: w.createdAt
155
+ for (const x of g.slice(1)) {
156
+ const b = J({
157
+ currentBlock: d,
158
+ createdAtBlock: x.createdAt
159
159
  });
160
- k < v && (v = k, f = w);
160
+ b < f && (f = b, P = x);
161
161
  }
162
- if (n == null || n({ confirmations: v, required: a }), v >= a)
163
- return { confirmations: v, basicInfo: f };
162
+ if (n == null || n({ confirmations: f, required: a }), f >= a)
163
+ return { confirmations: f, basicInfo: P };
164
164
  }
165
- } catch (p) {
166
- if (tt(p))
167
- throw p;
165
+ } catch (d) {
166
+ if (it(d))
167
+ throw d;
168
168
  console.warn(
169
- `Registration-depth read failed (retrying in ${l}ms): ` + (p instanceof Error ? p.message : String(p))
170
- ), d = p;
169
+ `Registration-depth read failed (retrying in ${l}ms): ` + (d instanceof Error ? d.message : String(d))
170
+ ), h = d;
171
171
  }
172
- await new Promise((p, g) => {
172
+ await new Promise((d, g) => {
173
173
  const m = () => {
174
- clearTimeout(f), g(
174
+ clearTimeout(P), g(
175
175
  new Error(
176
176
  `Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
177
177
  )
178
178
  );
179
- }, f = setTimeout(() => {
180
- i == null || i.removeEventListener("abort", m), p();
179
+ }, P = setTimeout(() => {
180
+ i == null || i.removeEventListener("abort", m), d();
181
181
  }, l);
182
182
  i == null || i.addEventListener("abort", m, { once: !0 });
183
183
  });
184
184
  }
185
185
  }
186
- const rt = 1;
187
- function ot(e, t, r) {
186
+ const ut = 1;
187
+ function lt(e, t, r) {
188
188
  const o = r.map(
189
- (c) => P(c).toLowerCase()
189
+ (c) => y(c).toLowerCase()
190
190
  ), a = t.filter((c) => o.includes(c));
191
191
  if (a.length > 0)
192
192
  throw new Error(
193
193
  `Cannot validate challenger set: vault keepers and universal challengers overlap (${a.join(", ")})`
194
194
  );
195
195
  const l = [...t, ...o], s = e.map(
196
- (c) => P(c.challenger_pubkey).toLowerCase()
196
+ (c) => y(c.challenger_pubkey).toLowerCase()
197
197
  ), i = new Set(s);
198
198
  if (i.size !== s.length)
199
199
  throw new Error(
200
200
  "Depositor graph contains duplicate challenger entries in challenger_presign_data"
201
201
  );
202
- const n = new Set(l), u = l.filter((c) => !i.has(c)), h = s.filter((c) => !n.has(c));
203
- if (u.length > 0 || h.length > 0)
202
+ const n = new Set(l), u = l.filter((c) => !i.has(c)), p = s.filter((c) => !n.has(c));
203
+ if (u.length > 0 || p.length > 0)
204
204
  throw new Error(
205
- "Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
205
+ "Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (p.length > 0 ? ` (unexpected: ${p.join(", ")})` : "")
206
206
  );
207
207
  }
208
- function nt(e, t) {
208
+ function ct(e, t) {
209
209
  const r = e.ins[t];
210
- return le(new Uint8Array(r.hash).slice().reverse());
210
+ return de(new Uint8Array(r.hash).slice().reverse());
211
211
  }
212
212
  function H(e, t, r, o, a) {
213
213
  const l = e.ins[t];
@@ -215,25 +215,25 @@ function H(e, t, r, o, a) {
215
215
  throw new Error(
216
216
  `NoPayout (challenger ${a}) input ${t} expected to spend ${o} vout 0, got vout ${l.index}`
217
217
  );
218
- const s = r.getId(), i = nt(e, t);
218
+ const s = r.getId(), i = ct(e, t);
219
219
  if (i !== s)
220
220
  throw new Error(
221
221
  `NoPayout (challenger ${a}) input ${t} does not reference ${o} (expected txid ${s}, got ${i})`
222
222
  );
223
223
  }
224
- async function st(e, t, r) {
225
- const o = [], a = [], l = [], s = Oe({
224
+ async function pt(e, t, r) {
225
+ const o = [], a = [], l = [], s = Ue({
226
226
  claimerBtcPubkey: r.depositorBtcPubkey,
227
227
  depositorBtcPubkey: r.depositorBtcPubkey,
228
228
  vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
229
229
  vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys
230
230
  });
231
- ot(
231
+ lt(
232
232
  e.challenger_presign_data,
233
233
  s,
234
234
  r.universalChallengerBtcPubkeys
235
235
  );
236
- const i = await Ne({
236
+ const i = await Le({
237
237
  vaultCoreVersion: r.vaultCoreVersion,
238
238
  vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
239
239
  vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
@@ -249,7 +249,7 @@ async function st(e, t, r) {
249
249
  network: r.network,
250
250
  claimerBtcPubkey: r.depositorBtcPubkey,
251
251
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
252
- commissionBps: rt,
252
+ commissionBps: ut,
253
253
  protocolFeeRate: r.protocolFeeRate,
254
254
  councilMembers: r.councilMembers,
255
255
  councilQuorum: r.councilQuorum
@@ -257,34 +257,34 @@ async function st(e, t, r) {
257
257
  o.push(i.psbtHex), a.push(
258
258
  K(
259
259
  t,
260
- q
260
+ W
261
261
  )
262
262
  );
263
- const n = P(r.depositorBtcPubkey), u = $.fromHex(
264
- P(e.assert_tx.tx_hex)
263
+ const n = y(r.depositorBtcPubkey), u = $.fromHex(
264
+ y(e.assert_tx.tx_hex)
265
265
  );
266
- for (const h of e.challenger_presign_data) {
267
- const c = P(h.challenger_pubkey), d = o.length, p = await at({
268
- challenger: h,
266
+ for (const p of e.challenger_presign_data) {
267
+ const c = y(p.challenger_pubkey), h = o.length, d = await ht({
268
+ challenger: p,
269
269
  challengerPubkey: c,
270
270
  claimerPubkey: n,
271
271
  localChallengers: s,
272
272
  assertTxParsed: u,
273
273
  ctx: r
274
274
  });
275
- o.push(p), a.push(
275
+ o.push(d), a.push(
276
276
  K(
277
277
  t,
278
- q
278
+ W
279
279
  )
280
280
  ), l.push({
281
281
  challengerPubkey: c,
282
- noPayoutIdx: d
282
+ noPayoutIdx: h
283
283
  });
284
284
  }
285
285
  return { psbtHexes: o, signOptions: a, challengerEntries: l };
286
286
  }
287
- async function at(e) {
287
+ async function ht(e) {
288
288
  const {
289
289
  challenger: t,
290
290
  challengerPubkey: r,
@@ -293,17 +293,17 @@ async function at(e) {
293
293
  assertTxParsed: l,
294
294
  ctx: s
295
295
  } = e;
296
- He(
296
+ Xe(
297
297
  t.nopayout_tx.tx_hex,
298
298
  r,
299
299
  s.network
300
300
  );
301
301
  const i = $.fromHex(
302
- P(t.nopayout_tx.tx_hex)
302
+ y(t.nopayout_tx.tx_hex)
303
303
  ), n = $.fromHex(
304
- P(t.challenge_assert_x_tx.tx_hex)
304
+ y(t.challenge_assert_x_tx.tx_hex)
305
305
  ), u = $.fromHex(
306
- P(t.challenge_assert_y_tx.tx_hex)
306
+ y(t.challenge_assert_y_tx.tx_hex)
307
307
  );
308
308
  if (i.ins.length !== 3)
309
309
  throw new Error(
@@ -328,18 +328,18 @@ async function at(e) {
328
328
  "ChallengeAssertY",
329
329
  r
330
330
  );
331
- const h = [
331
+ const p = [
332
332
  l.outs[0],
333
333
  n.outs[0],
334
334
  u.outs[0]
335
335
  ].map((c) => ({
336
- script_pubkey: le(new Uint8Array(c.script)),
336
+ script_pubkey: de(new Uint8Array(c.script)),
337
337
  value: c.value
338
338
  }));
339
- return De({
339
+ return qe({
340
340
  noPayoutTxHex: t.nopayout_tx.tx_hex,
341
341
  challengerPubkey: r,
342
- prevouts: h,
342
+ prevouts: p,
343
343
  connectorParams: {
344
344
  txGraphVersion: s.vaultCoreVersion,
345
345
  claimer: o,
@@ -351,7 +351,7 @@ async function at(e) {
351
351
  }
352
352
  });
353
353
  }
354
- function it(e, t, r) {
354
+ function dt(e, t, r) {
355
355
  B(e[0]);
356
356
  const a = I(
357
357
  e[0].returnedPsbtHex,
@@ -386,36 +386,36 @@ function it(e, t, r) {
386
386
  per_challenger: l
387
387
  };
388
388
  }
389
- async function ut(e) {
390
- const { depositorGraph: t, btcWallet: r, signingContext: o } = e, a = await r.getPublicKeyHex(), { depositorPubkey: l } = Re(
389
+ async function gt(e) {
390
+ const { depositorGraph: t, btcWallet: r, signingContext: o } = e, a = await r.getPublicKeyHex(), { depositorPubkey: l } = Se(
391
391
  a,
392
- P(o.depositorBtcPubkey)
393
- ), { psbtHexes: s, signOptions: i, challengerEntries: n } = await st(
392
+ y(o.depositorBtcPubkey)
393
+ ), { psbtHexes: s, signOptions: i, challengerEntries: n } = await pt(
394
394
  t,
395
395
  a,
396
396
  o
397
- ), u = await Ae(
397
+ ), u = await Be(
398
398
  r,
399
399
  s,
400
400
  i
401
- ), h = s.map((c, d) => ({
401
+ ), p = s.map((c, h) => ({
402
402
  requestedPsbtHex: c,
403
- returnedPsbtHex: u[d]
403
+ returnedPsbtHex: u[h]
404
404
  }));
405
- return it(
406
- h,
405
+ return dt(
406
+ p,
407
407
  n,
408
408
  l
409
409
  );
410
410
  }
411
- const lt = 1e4;
412
- async function fe(e) {
411
+ const ft = 1e4;
412
+ async function ye(e) {
413
413
  const {
414
414
  statusReader: t,
415
415
  peginTxid: r,
416
416
  targetStatuses: o,
417
417
  timeoutMs: a,
418
- pollIntervalMs: l = lt,
418
+ pollIntervalMs: l = ft,
419
419
  signal: s
420
420
  } = e, i = Date.now();
421
421
  for (; ; ) {
@@ -437,53 +437,53 @@ async function fe(e) {
437
437
  `getPeginStatus returned status for pegin ${n.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
438
438
  );
439
439
  const u = n.status;
440
- if (o.has(u) || u === C.ACTIVATED)
440
+ if (o.has(u) || u === R.ACTIVATED)
441
441
  return u;
442
- if (u === C.EXPIRED || Ie.has(u))
442
+ if (u === R.EXPIRED || De.has(u))
443
443
  throw new Error(
444
444
  `Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...o].join(", ")}`
445
445
  );
446
446
  } catch (n) {
447
- if (!(n instanceof Ve && n.code === Ke.PEGIN_NOT_FOUND))
447
+ if (!(n instanceof Me && n.code === Fe.PEGIN_NOT_FOUND))
448
448
  throw n;
449
449
  }
450
450
  await new Promise((n, u) => {
451
- const h = () => {
451
+ const p = () => {
452
452
  clearTimeout(c), u(
453
453
  new Error(
454
454
  `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
455
455
  )
456
456
  );
457
457
  }, c = setTimeout(() => {
458
- s == null || s.removeEventListener("abort", h), n();
458
+ s == null || s.removeEventListener("abort", p), n();
459
459
  }, l);
460
- s == null || s.addEventListener("abort", h, { once: !0 });
460
+ s == null || s.addEventListener("abort", p, { once: !0 });
461
461
  });
462
462
  }
463
463
  }
464
- const ct = 1200 * 1e3, me = /* @__PURE__ */ new Set([
465
- C.PENDING_ACKS,
466
- C.PENDING_ACTIVATION,
467
- C.ACTIVATED_PENDING_BROADCAST,
468
- C.ACTIVATED
469
- ]), ht = /* @__PURE__ */ new Set([
470
- C.PENDING_DEPOSITOR_SIGNATURES,
471
- ...me
464
+ const mt = 1200 * 1e3, be = /* @__PURE__ */ new Set([
465
+ R.PENDING_ACKS,
466
+ R.PENDING_ACTIVATION,
467
+ R.ACTIVATED_PENDING_BROADCAST,
468
+ R.ACTIVATED
469
+ ]), Pt = /* @__PURE__ */ new Set([
470
+ R.PENDING_DEPOSITOR_SIGNATURES,
471
+ ...be
472
472
  ]);
473
- function dt(e) {
473
+ function vt(e) {
474
474
  return e.map((t) => ({
475
475
  claimerPubkeyXOnly: O(t.claimer_pubkey),
476
476
  payoutTxHex: t.payout_tx.tx_hex,
477
477
  assertTxHex: t.assert_tx.tx_hex
478
478
  }));
479
479
  }
480
- function T(e) {
480
+ function A(e) {
481
481
  return O(e).toLowerCase();
482
482
  }
483
- function pt(e, t) {
484
- const r = (n, u, h) => {
483
+ function yt(e, t) {
484
+ const r = (n, u, p) => {
485
485
  throw new Error(
486
- `Deposit terms ${n} (${String(u)}) does not match the vault's version-locked signing context (${String(h)}); refusing to sign payouts against terms that describe a different graph.`
486
+ `Deposit terms ${n} (${String(u)}) does not match the vault's version-locked signing context (${String(p)}); refusing to sign payouts against terms that describe a different graph.`
487
487
  );
488
488
  }, o = [
489
489
  ["protocolFeeRate", e.protocolFeeRate, t.protocolFeeRate],
@@ -491,11 +491,11 @@ function pt(e, t) {
491
491
  ["timelockPegin", e.timelockPegin, t.timelockPegin],
492
492
  ["timelockAssert", e.timelockAssert, t.timelockAssert]
493
493
  ];
494
- for (const [n, u, h] of o)
495
- u !== h && r(n, u, h);
496
- const a = (n) => n.map(T).sort(), l = (n, u) => {
497
- const h = a(n), c = a(u);
498
- return h.length === c.length && h.every((d, p) => d === c[p]);
494
+ for (const [n, u, p] of o)
495
+ u !== p && r(n, u, p);
496
+ const a = (n) => n.map(A).sort(), l = (n, u) => {
497
+ const p = a(n), c = a(u);
498
+ return p.length === c.length && p.every((h, d) => h === c[d]);
499
499
  };
500
500
  l(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
501
501
  "vaultKeeperBtcPubkeys",
@@ -509,8 +509,8 @@ function pt(e, t) {
509
509
  e.universalChallengerBtcPubkeys.join(","),
510
510
  t.universalChallengerBtcPubkeys.join(",")
511
511
  );
512
- const s = T(t.vaultProviderBtcPubkey), i = e.vaults.map(
513
- (n) => T(n.vaultProviderBtcPubkey)
512
+ const s = A(t.vaultProviderBtcPubkey), i = e.vaults.map(
513
+ (n) => A(n.vaultProviderBtcPubkey)
514
514
  );
515
515
  i.includes(s) || r(
516
516
  "vaults[].vaultProviderBtcPubkey",
@@ -518,10 +518,10 @@ function pt(e, t) {
518
518
  t.vaultProviderBtcPubkey
519
519
  );
520
520
  }
521
- function gt(e, t, r, o) {
522
- const a = T(o), l = [
523
- T(t),
524
- ...r.map(T)
521
+ function bt(e, t, r, o) {
522
+ const a = A(o), l = [
523
+ A(t),
524
+ ...r.map(A)
525
525
  ], s = new Set(l);
526
526
  if (s.size !== l.length)
527
527
  throw new Error(
@@ -532,17 +532,17 @@ function gt(e, t, r, o) {
532
532
  "Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
533
533
  );
534
534
  const i = e.map(
535
- (d) => T(d.claimer_pubkey)
535
+ (h) => A(h.claimer_pubkey)
536
536
  );
537
537
  if (new Set(i).size !== i.length)
538
538
  throw new Error("Presign response contains duplicate claimer entries");
539
- const n = i.filter((d) => d !== a), u = new Set(n), h = l.filter((d) => !u.has(d)), c = n.filter((d) => !s.has(d));
540
- if (h.length > 0 || c.length > 0)
539
+ const n = i.filter((h) => h !== a), u = new Set(n), p = l.filter((h) => !u.has(h)), c = n.filter((h) => !s.has(h));
540
+ if (p.length > 0 || c.length > 0)
541
541
  throw new Error(
542
- "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (h.length > 0 ? ` (missing: ${h.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
542
+ "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (p.length > 0 ? ` (missing: ${p.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
543
543
  );
544
544
  }
545
- function Q(e, t) {
545
+ function Z(e, t) {
546
546
  return {
547
547
  vaultCoreVersion: t.vaultCoreVersion,
548
548
  payoutTxHex: e.payoutTxHex,
@@ -564,8 +564,8 @@ function Q(e, t) {
564
564
  vpCommissionScriptPubKey: t.vpCommissionScriptPubKey
565
565
  };
566
566
  }
567
- async function ft(e, t, r, o) {
568
- const a = new Se({
567
+ async function wt(e, t, r, o) {
568
+ const a = new Ve({
569
569
  network: t.network,
570
570
  btcWallet: e
571
571
  }), l = r.length;
@@ -573,14 +573,14 @@ async function ft(e, t, r, o) {
573
573
  let s;
574
574
  if (a.supportsBatchSigning())
575
575
  s = (await a.signPayoutTransactionsBatch(
576
- r.map((u) => Q(u, t))
576
+ r.map((u) => Z(u, t))
577
577
  )).map((u) => u.payoutSignature);
578
578
  else {
579
579
  s = [];
580
580
  for (let n = 0; n < r.length; n++) {
581
581
  o == null || o(n, l);
582
582
  const u = await a.signPayoutTransaction(
583
- Q(r[n], t)
583
+ Z(r[n], t)
584
584
  );
585
585
  s.push(u.signature);
586
586
  }
@@ -592,7 +592,7 @@ async function ft(e, t, r, o) {
592
592
  };
593
593
  return o == null || o(l, l), i;
594
594
  }
595
- async function tr(e) {
595
+ async function ir(e) {
596
596
  const {
597
597
  statusReader: t,
598
598
  presignClient: r,
@@ -601,26 +601,26 @@ async function tr(e) {
601
601
  depositorPk: l,
602
602
  signingContext: s,
603
603
  depositTerms: i,
604
- timeoutMs: n = ct,
604
+ timeoutMs: n = mt,
605
605
  signal: u,
606
- onProgress: h
607
- } = e, c = await fe({
606
+ onProgress: p
607
+ } = e, c = await ye({
608
608
  statusReader: t,
609
609
  peginTxid: a,
610
- targetStatuses: ht,
610
+ targetStatuses: Pt,
611
611
  timeoutMs: n,
612
612
  signal: u
613
613
  });
614
- if (me.has(c))
614
+ if (be.has(c))
615
615
  return;
616
- if (u == null || u.throwIfAborted(), i !== void 0 && pt(i, s), _e(o)) {
616
+ if (u == null || u.throwIfAborted(), i !== void 0 && yt(i, s), Ie(o)) {
617
617
  if (!i)
618
618
  throw new Error(
619
619
  "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)."
620
620
  );
621
621
  typeof o.validateDepositTerms == "function" && await o.validateDepositTerms(i), await o.approveDepositTerms(i);
622
622
  }
623
- const d = await r.requestDepositorPresignTransactions(
623
+ const h = await r.requestDepositorPresignTransactions(
624
624
  {
625
625
  pegin_txid: a,
626
626
  depositor_pk: l
@@ -628,24 +628,24 @@ async function tr(e) {
628
628
  u
629
629
  );
630
630
  u == null || u.throwIfAborted();
631
- const p = T(l);
632
- gt(
633
- d.txs,
631
+ const d = A(l);
632
+ bt(
633
+ h.txs,
634
634
  s.vaultProviderBtcPubkey,
635
635
  s.vaultKeeperBtcPubkeys,
636
636
  l
637
637
  );
638
- const g = d.txs.filter(
639
- (k) => T(k.claimer_pubkey) !== p
640
- ), m = dt(g), f = await ft(
638
+ const g = h.txs.filter(
639
+ (b) => A(b.claimer_pubkey) !== d
640
+ ), m = vt(g), P = await wt(
641
641
  o,
642
642
  s,
643
643
  m,
644
- h
644
+ p
645
645
  );
646
646
  u == null || u.throwIfAborted();
647
- const v = await ut({
648
- depositorGraph: d.depositor_graph,
647
+ const f = await gt({
648
+ depositorGraph: h.depositor_graph,
649
649
  btcWallet: o,
650
650
  signingContext: {
651
651
  vaultCoreVersion: s.vaultCoreVersion,
@@ -666,40 +666,40 @@ async function tr(e) {
666
666
  }
667
667
  });
668
668
  u == null || u.throwIfAborted();
669
- const w = { ...f };
670
- w[P(l)] = v.payout_signatures, await r.submitDepositorPresignatures(
669
+ const x = { ...P };
670
+ x[y(l)] = f.payout_signatures, await r.submitDepositorPresignatures(
671
671
  {
672
672
  pegin_txid: a,
673
673
  depositor_pk: l,
674
- signatures: w,
675
- depositor_claimer_presignatures: v
674
+ signatures: x,
675
+ depositor_claimer_presignatures: f
676
676
  },
677
677
  u
678
678
  );
679
679
  }
680
- const mt = 300 * 1e3, vt = /* @__PURE__ */ new Set([
681
- C.PENDING_DEPOSITOR_WOTS_PK,
682
- ...ce
680
+ const Et = 300 * 1e3, kt = /* @__PURE__ */ new Set([
681
+ R.PENDING_DEPOSITOR_WOTS_PK,
682
+ ...ge
683
683
  ]);
684
- async function rr(e) {
684
+ async function ur(e) {
685
685
  const {
686
686
  statusReader: t,
687
687
  wotsSubmitter: r,
688
688
  peginTxid: o,
689
689
  depositorPk: a,
690
690
  wotsPublicKeys: l,
691
- timeoutMs: s = mt,
691
+ timeoutMs: s = Et,
692
692
  signal: i
693
693
  } = e;
694
694
  i == null || i.throwIfAborted();
695
- const n = await fe({
695
+ const n = await ye({
696
696
  statusReader: t,
697
697
  peginTxid: o,
698
- targetStatuses: vt,
698
+ targetStatuses: kt,
699
699
  timeoutMs: s,
700
700
  signal: i
701
701
  });
702
- ce.has(n) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
702
+ ge.has(n) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
703
703
  {
704
704
  pegin_txid: o,
705
705
  depositor_pk: a,
@@ -711,27 +711,27 @@ async function rr(e) {
711
711
  function D(e) {
712
712
  return e.registration || e.operation;
713
713
  }
714
- function Pt(e, t, r) {
715
- const o = R(e);
714
+ function xt(e, t, r) {
715
+ const o = C(e);
716
716
  return {
717
- registration: o === R(t),
718
- operation: o === R(r)
717
+ registration: o === C(t),
718
+ operation: o === C(r)
719
719
  };
720
720
  }
721
- function W(e, t, r) {
722
- const o = F(e);
721
+ function ee(e, t, r) {
722
+ const o = M(e);
723
723
  return {
724
- registration: Y(o, F(t)),
725
- operation: Y(o, F(r))
724
+ registration: te(o, M(t)),
725
+ operation: te(o, M(r))
726
726
  };
727
727
  }
728
- function F(e) {
729
- return e.map(R).sort();
728
+ function M(e) {
729
+ return e.map(C).sort();
730
730
  }
731
- function Y(e, t) {
731
+ function te(e, t) {
732
732
  return e.length === t.length && e.every((r, o) => r === t[o]);
733
733
  }
734
- async function or(e) {
734
+ async function lr(e) {
735
735
  const {
736
736
  vaultProviderEthAddress: t,
737
737
  hintBtcPubkey: r,
@@ -740,9 +740,9 @@ async function or(e) {
740
740
  context: l
741
741
  } = e;
742
742
  if (!r) return;
743
- const s = R(r);
744
- if (s === R(o)) return;
745
- const i = R(
743
+ const s = C(r);
744
+ if (s === C(o)) return;
745
+ const i = C(
746
746
  await a()
747
747
  );
748
748
  if (s !== i)
@@ -750,11 +750,11 @@ async function or(e) {
750
750
  `Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${l ? ` ${l}` : ""}`
751
751
  );
752
752
  }
753
- function M(e, t, r) {
754
- const o = `${e} operation key (admin=${t.ethAddress})`, a = z(
753
+ function F(e, t, r) {
754
+ const o = `${e} operation key (admin=${t.ethAddress})`, a = Y(
755
755
  t.btcPubKey,
756
756
  `${e} roster key (admin=${t.ethAddress})`
757
- ), l = z(r, o);
757
+ ), l = Y(r, o);
758
758
  return {
759
759
  adminAddress: t.ethAddress,
760
760
  genesisBtcPubkey: a,
@@ -762,7 +762,7 @@ function M(e, t, r) {
762
762
  rotated: l !== a
763
763
  };
764
764
  }
765
- function bt(e) {
765
+ function Tt(e) {
766
766
  const t = /* @__PURE__ */ new Map();
767
767
  for (const r of e) {
768
768
  const o = t.get(r.operationBtcPubkey);
@@ -773,12 +773,12 @@ function bt(e) {
773
773
  t.set(r.operationBtcPubkey, r.adminAddress);
774
774
  }
775
775
  }
776
- function ve(e, t, r) {
776
+ function we(e, t, r) {
777
777
  if (t.vaultKeepers.length !== e.vaultKeepers.length || t.universalChallengers.length !== e.universalChallengers.length)
778
778
  throw new Error(
779
779
  `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`
780
780
  );
781
- const o = M(
781
+ const o = F(
782
782
  "vault provider",
783
783
  {
784
784
  ethAddress: e.vaultProviderEthAddress,
@@ -786,11 +786,11 @@ function ve(e, t, r) {
786
786
  },
787
787
  t.vaultProvider
788
788
  ), a = e.vaultKeepers.map(
789
- (s, i) => M("vault keeper", s, t.vaultKeepers[i])
789
+ (s, i) => F("vault keeper", s, t.vaultKeepers[i])
790
790
  ), l = e.universalChallengers.map(
791
- (s, i) => M("universal challenger", s, t.universalChallengers[i])
791
+ (s, i) => F("universal challenger", s, t.universalChallengers[i])
792
792
  );
793
- return bt([
793
+ return Tt([
794
794
  o,
795
795
  ...a,
796
796
  ...l
@@ -805,25 +805,33 @@ function ve(e, t, r) {
805
805
  query: e
806
806
  };
807
807
  }
808
- async function yt(e) {
808
+ async function At(e) {
809
809
  const t = await e.operationKeyReader.getCurrentOperationKeys(
810
810
  e.query,
811
811
  e.blockNumber
812
812
  );
813
- return ve(e.query, t, { mode: "current" });
813
+ return we(e.query, t, { mode: "current" });
814
814
  }
815
- async function wt(e) {
815
+ async function Ct(e) {
816
816
  const t = await e.operationKeyReader.getOperationKeysAtEpochs(
817
817
  e.query,
818
818
  e.epochs
819
819
  );
820
- return ve(e.query, t, {
820
+ return we(e.query, t, {
821
821
  mode: "epochs",
822
822
  epochs: e.epochs
823
823
  });
824
824
  }
825
- const J = (e) => e.map(R).sort();
826
- async function nr(e) {
825
+ class L extends Error {
826
+ constructor(t) {
827
+ super(t), this.name = "ApplicationEntryPointMismatchError";
828
+ }
829
+ }
830
+ function cr(e) {
831
+ return e instanceof L || e instanceof Error && e.name === "ApplicationEntryPointMismatchError";
832
+ }
833
+ const re = (e) => e.map(C).sort();
834
+ async function pr(e) {
827
835
  const {
828
836
  vaultRegistryReader: t,
829
837
  vaultKeeperReader: r,
@@ -834,99 +842,123 @@ async function nr(e) {
834
842
  expectedVaultKeeperBtcPubkeys: i,
835
843
  expectedUniversalChallengerBtcPubkeys: n,
836
844
  operationKeyReader: u,
837
- onIndexerServingOperationKeys: h,
845
+ onIndexerServingOperationKeys: p,
838
846
  onIndexerHintsInconsistent: c,
839
- blockNumber: d
847
+ blockNumber: h
840
848
  } = e, [
841
- p,
849
+ d,
842
850
  g,
843
- m
851
+ m,
852
+ P
844
853
  ] = await Promise.all([
845
- t.getVaultProviderGenesisBtcPubKey(
854
+ t.getVaultProviderApplication(
846
855
  a,
847
- d
856
+ h
848
857
  ),
849
- r.getCurrentVaultKeepersVersion(
850
- l,
851
- d
858
+ t.getVaultProviderGenesisBtcPubKey(
859
+ a,
860
+ h
852
861
  ),
853
- o.getLatestUniversalChallengersVersion(d)
854
- ]), [f, v] = await Promise.all([
862
+ o.getLatestUniversalChallengersVersion(h),
863
+ o.getCurrentUcKeyEpoch(h)
864
+ ]);
865
+ if (!Ne(l, { strict: !1 }))
866
+ throw new L(
867
+ `The application entry point this deposit was prepared for is not a valid address: ${l}`
868
+ );
869
+ if (!He(d, l))
870
+ throw new L(
871
+ `Vault provider ${a} is registered to application ${d}, but this deposit was prepared for ${l}. 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.`
872
+ );
873
+ const [f, x] = await Promise.all(
874
+ [
875
+ r.getCurrentVaultKeepersVersion(
876
+ d,
877
+ h
878
+ ),
879
+ r.getCurrentAppKeeperKeyEpoch(
880
+ d,
881
+ h
882
+ )
883
+ ]
884
+ ), [b, w] = await Promise.all([
855
885
  r.getVaultKeepersByVersion(
856
- l,
857
- g,
858
- d
886
+ d,
887
+ f,
888
+ h
859
889
  ),
860
890
  o.getUniversalChallengersByVersion(
861
891
  m,
862
- d
892
+ h
863
893
  )
864
- ]), w = {
865
- vaultProvider: R(p),
866
- vaultKeepers: J(f.map((E) => E.btcPubKey)),
867
- universalChallengers: J(v.map((E) => E.btcPubKey))
868
- }, k = await yt({
894
+ ]), E = {
895
+ vaultProvider: C(g),
896
+ vaultKeepers: re(b.map((k) => k.btcPubKey)),
897
+ universalChallengers: re(w.map((k) => k.btcPubKey))
898
+ }, T = await At({
869
899
  operationKeyReader: u,
870
900
  query: {
871
901
  vaultProviderEthAddress: a,
872
- vaultProviderGenesisBtcPubkey: `0x${p}`,
873
- applicationEntryPoint: l,
874
- vaultKeepers: f,
875
- universalChallengers: v
902
+ vaultProviderGenesisBtcPubkey: `0x${g}`,
903
+ applicationEntryPoint: d,
904
+ vaultKeepers: b,
905
+ universalChallengers: w
876
906
  },
877
- blockNumber: d
878
- }), b = {
879
- vaultProvider: k.vaultProvider.operationBtcPubkey,
880
- vaultKeepers: [...k.vaultKeeperOperationKeysSorted],
907
+ blockNumber: h
908
+ }), v = {
909
+ vaultProvider: T.vaultProvider.operationBtcPubkey,
910
+ vaultKeepers: [...T.vaultKeeperOperationKeysSorted],
881
911
  universalChallengers: [
882
- ...k.universalChallengerOperationKeysSorted
912
+ ...T.universalChallengerOperationKeysSorted
883
913
  ]
884
- }, x = Pt(
914
+ }, q = xt(
885
915
  s,
886
- w.vaultProvider,
887
- b.vaultProvider
888
- ), A = W(
916
+ E.vaultProvider,
917
+ v.vaultProvider
918
+ ), G = ee(
889
919
  i,
890
- w.vaultKeepers,
891
- b.vaultKeepers
892
- ), y = W(
920
+ E.vaultKeepers,
921
+ v.vaultKeepers
922
+ ), z = ee(
893
923
  n,
894
- w.universalChallengers,
895
- b.universalChallengers
924
+ E.universalChallengers,
925
+ v.universalChallengers
896
926
  );
897
- if (!D(x))
927
+ if (!D(q))
898
928
  throw new Error(
899
929
  `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${a}. Refresh and try again.`
900
930
  );
901
- if (!D(A))
931
+ if (!D(G))
902
932
  throw new Error(
903
- `Vault keeper BTC pubkeys (v${g}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
933
+ `Vault keeper BTC pubkeys (v${f}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
904
934
  );
905
- if (!D(y))
935
+ if (!D(z))
906
936
  throw new Error(
907
937
  `Universal challenger BTC pubkeys (v${m}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
908
938
  );
909
- const X = [x, A, y], Ee = X.some((E) => E.registration && !E.operation), G = X.some((E) => E.operation && !E.registration);
910
- if (Ee && G) {
911
- const E = `Indexer participant hints are internally inconsistent for vault provider ${a}: some roles match the registration keys while others match the rotated operation keys.`;
912
- throw c == null || c(E), new Error(`${E} Refresh and try again.`);
939
+ const j = [q, G, z], Ce = j.some((k) => k.registration && !k.operation), Q = j.some((k) => k.operation && !k.registration);
940
+ if (Ce && Q) {
941
+ const k = `Indexer participant hints are internally inconsistent for vault provider ${a}: some roles match the registration keys while others match the rotated operation keys.`;
942
+ throw c == null || c(k), new Error(`${k} Refresh and try again.`);
913
943
  }
914
- return G && (h == null || h(
944
+ return Q && (p == null || p(
915
945
  `Indexer is serving rotated operation keys for vault provider ${a}`
916
946
  )), {
917
- vaultProviderBtcPubkeyXOnly: b.vaultProvider,
918
- vaultKeeperBtcPubkeysSorted: b.vaultKeepers,
919
- universalChallengerBtcPubkeysSorted: b.universalChallengers,
920
- expectedAppVaultKeepersVersion: g,
947
+ vaultProviderBtcPubkeyXOnly: v.vaultProvider,
948
+ vaultKeeperBtcPubkeysSorted: v.vaultKeepers,
949
+ universalChallengerBtcPubkeysSorted: v.universalChallengers,
950
+ expectedAppVaultKeepersVersion: f,
921
951
  expectedUniversalChallengersVersion: m,
922
- registrationKeys: w,
923
- participantKeys: k
952
+ appKeeperKeyEpoch: x,
953
+ ucKeyEpoch: P,
954
+ registrationKeys: E,
955
+ participantKeys: T
924
956
  };
925
957
  }
926
- function kt(e) {
958
+ function Rt(e) {
927
959
  return /^[0-9a-fA-F]{64}$/.test(e);
928
960
  }
929
- function sr(e) {
961
+ function hr(e) {
930
962
  const {
931
963
  amountSats: t,
932
964
  minDeposit: r,
@@ -937,7 +969,7 @@ function sr(e) {
937
969
  } = e;
938
970
  return !(t <= 0n || t < r || o && o > 0n && t > o || l == null || s == null || t + l + s > a);
939
971
  }
940
- function ar(e, t, r) {
972
+ function dr(e, t, r) {
941
973
  return e <= 0n ? {
942
974
  valid: !1,
943
975
  error: "Deposit amount must be greater than zero"
@@ -949,7 +981,7 @@ function ar(e, t, r) {
949
981
  error: `Maximum deposit is ${_(r)} BTC`
950
982
  } : { valid: !0 };
951
983
  }
952
- function ir(e) {
984
+ function gr(e) {
953
985
  const { amount: t, effectiveRemaining: r } = e;
954
986
  return r === null ? { valid: !0 } : r === 0n ? {
955
987
  valid: !1,
@@ -959,7 +991,7 @@ function ir(e) {
959
991
  error: `Vault size exceeds remaining capacity (${_(r)} BTC)`
960
992
  } : { valid: !0 };
961
993
  }
962
- function ur(e, t) {
994
+ function fr(e, t) {
963
995
  if (!e || e.length === 0)
964
996
  return {
965
997
  valid: !1,
@@ -975,7 +1007,7 @@ function ur(e, t) {
975
1007
  error: "Invalid vault provider selected"
976
1008
  } : { valid: !0 };
977
1009
  }
978
- function Et(e, t, r) {
1010
+ function _t(e, t, r) {
979
1011
  if (!e || e.length === 0)
980
1012
  return {
981
1013
  valid: !1,
@@ -1001,30 +1033,30 @@ function Et(e, t, r) {
1001
1033
  }
1002
1034
  return { valid: !0 };
1003
1035
  }
1004
- function xt(e) {
1005
- const t = P(e);
1006
- return kt(t) ? { valid: !0 } : {
1036
+ function St(e) {
1037
+ const t = y(e);
1038
+ return Rt(t) ? { valid: !0 } : {
1007
1039
  valid: !1,
1008
1040
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
1009
1041
  };
1010
1042
  }
1011
- function Tt(e) {
1043
+ function $t(e) {
1012
1044
  if (!e || e.length === 0)
1013
1045
  throw new Error(
1014
1046
  "No vault keepers available. The system requires at least one vault keeper to create a deposit."
1015
1047
  );
1016
1048
  }
1017
- function Rt(e) {
1049
+ function Bt(e) {
1018
1050
  if (!e || e.length === 0)
1019
1051
  throw new Error(
1020
1052
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
1021
1053
  );
1022
1054
  }
1023
- function Ct(e) {
1055
+ function It(e) {
1024
1056
  if (e.length === 0)
1025
1057
  throw new Error("No spendable UTXOs available");
1026
1058
  }
1027
- function lr(e) {
1059
+ function mr(e) {
1028
1060
  const {
1029
1061
  vaultAmounts: t,
1030
1062
  confirmedUTXOs: r,
@@ -1033,78 +1065,78 @@ function lr(e) {
1033
1065
  universalChallengerBtcPubkeys: l,
1034
1066
  minDeposit: s,
1035
1067
  maxDeposit: i
1036
- } = e, n = Et(
1068
+ } = e, n = _t(
1037
1069
  t,
1038
1070
  s,
1039
1071
  i
1040
1072
  );
1041
1073
  if (!n.valid)
1042
1074
  throw new Error(n.error);
1043
- const u = xt(o);
1075
+ const u = St(o);
1044
1076
  if (!u.valid)
1045
1077
  throw new Error(u.error);
1046
- Tt(a), Rt(l), Ct(r);
1078
+ $t(a), Bt(l), It(r);
1047
1079
  }
1048
- class Pe extends Error {
1080
+ class Ee extends Error {
1049
1081
  constructor(t) {
1050
1082
  super(t), this.name = "ParticipantKeyDriftError";
1051
1083
  }
1052
1084
  }
1053
- function cr(e) {
1054
- return e instanceof Pe || e instanceof Error && e.name === "ParticipantKeyDriftError";
1085
+ function Pr(e) {
1086
+ return e instanceof Ee || e instanceof Error && e.name === "ParticipantKeyDriftError";
1055
1087
  }
1056
- function Z(e, t, r) {
1088
+ function oe(e, t, r) {
1057
1089
  return t.length === r.length && t.every((o, a) => o === r[a]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
1058
1090
  }
1059
- async function hr(e) {
1091
+ async function vr(e) {
1060
1092
  const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: o, expected: a } = e, l = a.query;
1061
1093
  if (o.length === 0) return;
1062
1094
  const s = await t.getVaultKeyEpochsBatch(o), i = [];
1063
1095
  for (const [n, u] of s.entries()) {
1064
- const h = o[n];
1096
+ const p = o[n];
1065
1097
  let c;
1066
1098
  try {
1067
- c = await wt({
1099
+ c = await Ct({
1068
1100
  operationKeyReader: r,
1069
1101
  query: l,
1070
1102
  epochs: u
1071
1103
  });
1072
1104
  } catch (g) {
1073
1105
  i.push(
1074
- `vault ${h}: could not resolve participants at frozen epochs (vp=${u.vpKeyEpoch}, keeper=${u.appKeeperKeyEpoch}, uc=${u.ucKeyEpoch}): ${g.message}`
1106
+ `vault ${p}: could not resolve participants at frozen epochs (vp=${u.vpKeyEpoch}, keeper=${u.appKeeperKeyEpoch}, uc=${u.ucKeyEpoch}): ${g.message}`
1075
1107
  );
1076
1108
  continue;
1077
1109
  }
1078
1110
  c.vaultProvider.operationBtcPubkey !== a.vaultProvider.operationBtcPubkey && i.push(
1079
- `vault ${h}: vault provider key expected ${a.vaultProvider.operationBtcPubkey}, got ${c.vaultProvider.operationBtcPubkey}`
1111
+ `vault ${p}: vault provider key expected ${a.vaultProvider.operationBtcPubkey}, got ${c.vaultProvider.operationBtcPubkey}`
1080
1112
  );
1081
- const d = Z(
1082
- `vault ${h}: vault keeper keys`,
1113
+ const h = oe(
1114
+ `vault ${p}: vault keeper keys`,
1083
1115
  a.vaultKeeperOperationKeysSorted,
1084
1116
  c.vaultKeeperOperationKeysSorted
1085
1117
  );
1086
- d && i.push(d);
1087
- const p = Z(
1088
- `vault ${h}: universal challenger keys`,
1118
+ h && i.push(h);
1119
+ const d = oe(
1120
+ `vault ${p}: universal challenger keys`,
1089
1121
  a.universalChallengerOperationKeysSorted,
1090
1122
  c.universalChallengerOperationKeysSorted
1091
1123
  );
1092
- p && i.push(p);
1124
+ d && i.push(d);
1093
1125
  }
1094
1126
  if (i.length > 0)
1095
- throw new Pe(
1127
+ throw new Ee(
1096
1128
  `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.`
1097
1129
  );
1098
1130
  }
1099
- class be extends Error {
1131
+ class ke extends Error {
1100
1132
  constructor(t) {
1101
1133
  super(t), this.name = "RegisteredVaultVersionMismatchError";
1102
1134
  }
1103
1135
  }
1104
- function dr(e) {
1105
- return e instanceof be || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
1136
+ function yr(e) {
1137
+ return e instanceof ke || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
1106
1138
  }
1107
- async function pr(e) {
1139
+ async function br(e) {
1108
1140
  const {
1109
1141
  vaultRegistryReader: t,
1110
1142
  vaultIds: r,
@@ -1113,8 +1145,8 @@ async function pr(e) {
1113
1145
  expectedUniversalChallengersVersion: l,
1114
1146
  expectedVaultCoreVersion: s
1115
1147
  } = e, i = await t.getProtocolInfoBatch(r), n = [];
1116
- if (i.forEach((u, h) => {
1117
- const c = r[h];
1148
+ if (i.forEach((u, p) => {
1149
+ const c = r[p];
1118
1150
  u.offchainParamsVersion !== o && n.push(
1119
1151
  `vault ${c}: offchainParams expected v${o}, got v${u.offchainParamsVersion}`
1120
1152
  ), u.appVaultKeepersVersion !== a && n.push(
@@ -1125,25 +1157,25 @@ async function pr(e) {
1125
1157
  `vault ${c}: vaultCoreVersion expected v${s} (build-time active), got v${u.vaultCoreVersion}`
1126
1158
  );
1127
1159
  }), n.length > 0)
1128
- throw new be(
1160
+ throw new ke(
1129
1161
  `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${n.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
1130
1162
  );
1131
1163
  }
1132
- var ye = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(ye || {});
1133
- const At = /* @__PURE__ */ new Set([
1164
+ var xe = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(xe || {});
1165
+ const Vt = /* @__PURE__ */ new Set([
1134
1166
  "PayoutBroadcast",
1135
1167
  "PayoutBlocked"
1136
1168
  /* PAYOUT_BLOCKED */
1137
1169
  ]);
1138
- function gr(e) {
1139
- return Object.values(ye).includes(
1170
+ function wr(e) {
1171
+ return Object.values(xe).includes(
1140
1172
  e
1141
1173
  );
1142
1174
  }
1143
- function fr(e) {
1144
- return !!e && At.has(e);
1175
+ function Er(e) {
1176
+ return !!e && Vt.has(e);
1145
1177
  }
1146
- class _t extends Error {
1178
+ class Kt extends Error {
1147
1179
  constructor(r, o) {
1148
1180
  super(`Refund not yet mature (BIP68 not final): ${o.message}`);
1149
1181
  S(this, "vaultId");
@@ -1151,31 +1183,31 @@ class _t extends Error {
1151
1183
  this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
1152
1184
  }
1153
1185
  }
1154
- const St = /^0x[0-9a-fA-F]{64}$/, $t = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, we = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, ke = 160, ee = 2e3, te = 10n, re = 100n;
1155
- function mr(e) {
1186
+ const Ot = /^0x[0-9a-fA-F]{64}$/, Nt = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Te = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Ae = 160, ne = 2e3, se = 10n, ae = 100n;
1187
+ function kr(e) {
1156
1188
  if (!Number.isFinite(e) || e <= 0)
1157
1189
  throw new Error(
1158
1190
  `feeRateSatsVb must be a positive finite number, got ${e}`
1159
1191
  );
1160
- return BigInt(Math.ceil(e * ke));
1192
+ return BigInt(Math.ceil(e * Ae));
1161
1193
  }
1162
- const Bt = 1, It = /non-BIP68-final/i;
1163
- function U(e, t) {
1194
+ const Ht = 1, Dt = /non-BIP68-final/i;
1195
+ function X(e, t) {
1164
1196
  if (e.length !== 66)
1165
1197
  throw new Error(
1166
1198
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
1167
1199
  );
1168
- if (!St.test(e))
1200
+ if (!Ot.test(e))
1169
1201
  throw new Error(
1170
1202
  `${t} must contain only hex characters after the 0x prefix`
1171
1203
  );
1172
1204
  }
1173
- function L(e, t) {
1205
+ function U(e, t) {
1174
1206
  if (!Number.isInteger(e) || e < 0)
1175
1207
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
1176
1208
  }
1177
- function Vt(e) {
1178
- if (U(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
1209
+ function Mt(e) {
1210
+ if (X(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
1179
1211
  throw new Error(
1180
1212
  `htlcVout must be a non-negative integer, got ${e.htlcVout}`
1181
1213
  );
@@ -1187,7 +1219,7 @@ function Vt(e) {
1187
1219
  );
1188
1220
  for (let r = 0; r < e.batch.length; r++) {
1189
1221
  const o = e.batch[r];
1190
- if (U(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
1222
+ if (X(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
1191
1223
  throw new Error(
1192
1224
  `batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${o.htlcVout}`
1193
1225
  );
@@ -1205,27 +1237,27 @@ function Vt(e) {
1205
1237
  throw new Error(
1206
1238
  `batch[${e.htlcVout}].amount (${t.amount}) does not match target amount (${e.amount})`
1207
1239
  );
1208
- if (L(e.offchainParamsVersion, "offchainParamsVersion"), L(e.appVaultKeepersVersion, "appVaultKeepersVersion"), L(
1240
+ if (U(e.offchainParamsVersion, "offchainParamsVersion"), U(e.appVaultKeepersVersion, "appVaultKeepersVersion"), U(
1209
1241
  e.universalChallengersVersion,
1210
1242
  "universalChallengersVersion"
1211
- ), Xe(
1243
+ ), We(
1212
1244
  e.vaultCoreVersion,
1213
1245
  "VaultRefundData.vaultCoreVersion"
1214
1246
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
1215
1247
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
1216
- if (!$t.test(e.unsignedPrePeginTxHex))
1248
+ if (!Nt.test(e.unsignedPrePeginTxHex))
1217
1249
  throw new Error(
1218
1250
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
1219
1251
  );
1220
- if (!e.depositorBtcPubkey || !we.test(e.depositorBtcPubkey))
1252
+ if (!e.depositorBtcPubkey || !Te.test(e.depositorBtcPubkey))
1221
1253
  throw new Error(
1222
1254
  "depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
1223
1255
  );
1224
1256
  if (typeof e.amount != "bigint" || e.amount <= 0n)
1225
1257
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
1226
1258
  }
1227
- function Kt(e) {
1228
- if (!e.vaultProviderPubkey || !we.test(e.vaultProviderPubkey))
1259
+ function Ft(e) {
1260
+ if (!e.vaultProviderPubkey || !Te.test(e.vaultProviderPubkey))
1229
1261
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
1230
1262
  if (e.vaultKeeperPubkeys.length === 0)
1231
1263
  throw new Error("vaultKeeperPubkeys must be non-empty");
@@ -1250,7 +1282,7 @@ function Kt(e) {
1250
1282
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
1251
1283
  );
1252
1284
  }
1253
- async function vr(e) {
1285
+ async function xr(e) {
1254
1286
  const {
1255
1287
  vaultId: t,
1256
1288
  readVault: r,
@@ -1260,50 +1292,50 @@ async function vr(e) {
1260
1292
  broadcastTx: s,
1261
1293
  signal: i
1262
1294
  } = e;
1263
- i == null || i.throwIfAborted(), U(t, "vaultId");
1295
+ i == null || i.throwIfAborted(), X(t, "vaultId");
1264
1296
  const n = await r();
1265
- Vt(n), i == null || i.throwIfAborted();
1297
+ Mt(n), i == null || i.throwIfAborted();
1266
1298
  const u = await o(n);
1267
- if (Kt(u), i == null || i.throwIfAborted(), !Number.isFinite(a) || a <= 0)
1299
+ if (Ft(u), i == null || i.throwIfAborted(), !Number.isFinite(a) || a <= 0)
1268
1300
  throw new Error(`feeRate must be a positive number, got ${a}`);
1269
- if (a > ee)
1301
+ if (a > ne)
1270
1302
  throw new Error(
1271
- `feeRate ${a} sat/vB exceeds refund safety cap ${ee} sat/vB; refusing to sign refund.`
1303
+ `feeRate ${a} sat/vB exceeds refund safety cap ${ne} sat/vB; refusing to sign refund.`
1272
1304
  );
1273
- const h = BigInt(Math.ceil(a * ke)), c = n.amount * te / re;
1274
- if (h > c)
1305
+ const p = BigInt(Math.ceil(a * Ae)), c = n.amount * se / ae;
1306
+ if (p > c)
1275
1307
  throw new Error(
1276
- `Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${te}/${re} of vault.amount=${n.amount}); refusing to sign refund.`
1308
+ `Refund fee ${p} sats exceeds the per-vault safety cap of ${c} sats (${se}/${ae} of vault.amount=${n.amount}); refusing to sign refund.`
1277
1309
  );
1278
1310
  i == null || i.throwIfAborted();
1279
- const d = O(
1311
+ const h = O(
1280
1312
  n.depositorBtcPubkey
1281
- ), p = P(n.unsignedPrePeginTxHex), g = $e(p);
1313
+ ), d = y(n.unsignedPrePeginTxHex), g = Ke(d);
1282
1314
  if (g !== void 0 && g.vout !== n.batch.length)
1283
1315
  throw new Error(
1284
1316
  `Auth-anchor OP_RETURN at vout ${g.vout} does not match batch size (${n.batch.length} HTLC outputs expect the anchor at vout ${n.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
1285
1317
  );
1286
1318
  const m = g == null ? void 0 : g.hash;
1287
- let f;
1319
+ let P;
1288
1320
  try {
1289
- f = $.fromHex(p);
1290
- } catch (y) {
1321
+ P = $.fromHex(d);
1322
+ } catch (v) {
1291
1323
  throw new Error(
1292
- `Failed to parse funded Pre-PegIn transaction hex: ${y instanceof Error ? y.message : String(y)}`
1324
+ `Failed to parse funded Pre-PegIn transaction hex: ${v instanceof Error ? v.message : String(v)}`
1293
1325
  );
1294
1326
  }
1295
- if (f.outs.length < n.batch.length)
1327
+ if (P.outs.length < n.batch.length)
1296
1328
  throw new Error(
1297
- `Funded Pre-PegIn tx has ${f.outs.length} outputs but batch requires at least ${n.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
1329
+ `Funded Pre-PegIn tx has ${P.outs.length} outputs but batch requires at least ${n.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
1298
1330
  );
1299
- const { psbtHex: v } = await Fe({
1331
+ const { psbtHex: f } = await Ge({
1300
1332
  prePeginParams: {
1301
1333
  vaultCoreVersion: n.vaultCoreVersion,
1302
- depositorPubkey: d,
1303
- vaultProviderPubkey: P(u.vaultProviderPubkey),
1304
- vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(P),
1305
- universalChallengerPubkeys: u.universalChallengerPubkeys.map(P),
1306
- hashlocks: n.batch.map((y) => P(y.hashlock)),
1334
+ depositorPubkey: h,
1335
+ vaultProviderPubkey: y(u.vaultProviderPubkey),
1336
+ vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(y),
1337
+ universalChallengerPubkeys: u.universalChallengerPubkeys.map(y),
1338
+ hashlocks: n.batch.map((v) => y(v.hashlock)),
1307
1339
  timelockRefund: u.timelockRefund,
1308
1340
  // `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
1309
1341
  // is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
@@ -1311,7 +1343,7 @@ async function vr(e) {
1311
1343
  // HTLC output. `buildRefundPsbt`'s value cross-check then binds the result
1312
1344
  // to the funded tx bytes, refusing the refund if the template's HTLC value
1313
1345
  // disagrees with the on-chain commitment.
1314
- pegInAmounts: n.batch.map((y) => y.amount),
1346
+ pegInAmounts: n.batch.map((v) => v.amount),
1315
1347
  feeRate: u.feeRate,
1316
1348
  minPeginFeeRate: u.minPeginFeeRate,
1317
1349
  numLocalChallengers: u.numLocalChallengers,
@@ -1320,48 +1352,48 @@ async function vr(e) {
1320
1352
  network: u.network,
1321
1353
  authAnchorHash: m
1322
1354
  },
1323
- fundedPrePeginTxHex: p,
1355
+ fundedPrePeginTxHex: d,
1324
1356
  htlcVout: n.htlcVout,
1325
- refundFee: h,
1357
+ refundFee: p,
1326
1358
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
1327
1359
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
1328
1360
  // value would derive the wrong refund script leaf and yield an
1329
1361
  // unspendable PSBT. Match the `hashlocks` array handling above.
1330
- hashlock: P(n.hashlock)
1362
+ hashlock: y(n.hashlock)
1331
1363
  });
1332
1364
  i == null || i.throwIfAborted();
1333
- const w = K(
1365
+ const x = K(
1334
1366
  n.depositorBtcPubkey,
1335
- Bt
1336
- ), k = await l(v, w);
1367
+ Ht
1368
+ ), b = await l(f, x);
1337
1369
  B({
1338
- requestedPsbtHex: v,
1339
- returnedPsbtHex: k
1370
+ requestedPsbtHex: f,
1371
+ returnedPsbtHex: b
1340
1372
  });
1341
- const b = 0, x = I(
1342
- k,
1343
- d,
1344
- b
1373
+ const w = 0, E = I(
1374
+ b,
1375
+ h,
1376
+ w
1345
1377
  );
1346
1378
  V({
1347
- requestedPsbtHex: v,
1348
- signatureHex: x,
1349
- signerXOnlyPubkeyHex: d,
1350
- inputIndex: b
1379
+ requestedPsbtHex: f,
1380
+ signatureHex: E,
1381
+ signerXOnlyPubkeyHex: h,
1382
+ inputIndex: w
1351
1383
  });
1352
- const A = he({
1353
- requestedPsbtHex: v,
1354
- signaturesHex: [x],
1355
- signerXOnlyPubkeyHex: d
1384
+ const T = fe({
1385
+ requestedPsbtHex: f,
1386
+ signaturesHex: [E],
1387
+ signerXOnlyPubkeyHex: h
1356
1388
  });
1357
1389
  i == null || i.throwIfAborted();
1358
1390
  try {
1359
- return await s(A);
1360
- } catch (y) {
1361
- throw y instanceof Error && It.test(y.message) ? new _t(t, y) : y;
1391
+ return await s(T);
1392
+ } catch (v) {
1393
+ throw v instanceof Error && Dt.test(v.message) ? new Kt(t, v) : v;
1362
1394
  }
1363
1395
  }
1364
- class oe extends Error {
1396
+ class ie extends Error {
1365
1397
  constructor(r, o, a) {
1366
1398
  super(r);
1367
1399
  /** Fee the reclaim would have paid, in satoshis. */
@@ -1371,13 +1403,13 @@ class oe extends Error {
1371
1403
  this.name = "ReclaimUneconomicalError", this.feeSats = o, this.sweptTotalSats = a;
1372
1404
  }
1373
1405
  }
1374
- const ne = 2e3, se = 25n, ae = 100n, Pr = 10n;
1375
- async function Ot(e, t, r) {
1406
+ const ue = 2e3, le = 25n, ce = 100n, Tr = 10n;
1407
+ async function Ut(e, t, r) {
1376
1408
  for (let o = 0; o < e.length; o++) {
1377
- const a = Ue(e[o].depositorSignedPeginTxHex), l = ue(
1378
- await Ge(
1379
- P(a),
1380
- P(r)
1409
+ const a = Qe(e[o].depositorSignedPeginTxHex), l = he(
1410
+ await Ye(
1411
+ y(a),
1412
+ y(r)
1381
1413
  )
1382
1414
  ).toLowerCase();
1383
1415
  if (l !== t[o].toLowerCase())
@@ -1386,7 +1418,7 @@ async function Ot(e, t, r) {
1386
1418
  );
1387
1419
  }
1388
1420
  }
1389
- async function br(e) {
1421
+ async function Ar(e) {
1390
1422
  const {
1391
1423
  vaultIds: t,
1392
1424
  depositorEthAddress: r,
@@ -1401,9 +1433,9 @@ async function br(e) {
1401
1433
  throw new Error("Reclaim requires at least one vault id; got none.");
1402
1434
  if (!Number.isFinite(l) || l <= 0)
1403
1435
  throw new Error(`feeRate must be a positive number, got ${l}`);
1404
- if (l > ne)
1405
- throw new oe(
1406
- `Fee rate ${l} sat/vB exceeds the reclaim safety cap of ${ne} sat/vB; refusing to sign.`,
1436
+ if (l > ue)
1437
+ throw new ie(
1438
+ `Fee rate ${l} sat/vB exceeds the reclaim safety cap of ${ue} sat/vB; refusing to sign.`,
1407
1439
  0n,
1408
1440
  0n
1409
1441
  );
@@ -1412,100 +1444,102 @@ async function br(e) {
1412
1444
  throw new Error(
1413
1445
  `readVaults returned ${u.length} reserves for ${t.length} vault id(s); refusing to sweep a set that does not match the request.`
1414
1446
  );
1415
- await Ot(u, t, r), n == null || n.throwIfAborted();
1416
- const h = O(o), c = u.map((b) => ({
1417
- depositorSignedPeginTxHex: b.depositorSignedPeginTxHex,
1418
- observed: b.observed,
1419
- expectedValue: b.expectedClaimValue
1420
- })), d = Me(l, c.length), p = c.reduce((b, x) => b + x.expectedValue, 0n), g = p * se / ae;
1421
- if (d > g)
1422
- throw new oe(
1423
- `Reclaim fee ${d} sats exceeds ${se}/${ae} of the swept total (${p} sats, cap ${g} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
1424
- d,
1425
- p
1447
+ await Ut(u, t, r), n == null || n.throwIfAborted();
1448
+ const p = O(o), c = u.map((w) => ({
1449
+ depositorSignedPeginTxHex: w.depositorSignedPeginTxHex,
1450
+ observed: w.observed,
1451
+ expectedValue: w.expectedClaimValue
1452
+ })), h = ze(l, c.length), d = c.reduce((w, E) => w + E.expectedValue, 0n), g = d * le / ce;
1453
+ if (h > g)
1454
+ throw new ie(
1455
+ `Reclaim fee ${h} sats exceeds ${le}/${ce} of the swept total (${d} sats, cap ${g} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
1456
+ h,
1457
+ d
1426
1458
  );
1427
1459
  n == null || n.throwIfAborted();
1428
- const { psbtHex: m } = Le({
1429
- depositorPubkey: h,
1460
+ const { psbtHex: m } = je({
1461
+ depositorPubkey: p,
1430
1462
  inputs: c,
1431
- feeSats: d
1463
+ feeSats: h
1432
1464
  });
1433
1465
  n == null || n.throwIfAborted();
1434
- const f = K(
1466
+ const P = K(
1435
1467
  o,
1436
1468
  c.length
1437
- ), v = await s(m, f);
1469
+ ), f = await s(m, P);
1438
1470
  B({
1439
1471
  requestedPsbtHex: m,
1440
- returnedPsbtHex: v
1472
+ returnedPsbtHex: f
1441
1473
  });
1442
- const w = c.map((b, x) => {
1443
- const A = I(
1444
- v,
1445
- h,
1446
- x
1474
+ const x = c.map((w, E) => {
1475
+ const T = I(
1476
+ f,
1477
+ p,
1478
+ E
1447
1479
  );
1448
1480
  return V({
1449
1481
  requestedPsbtHex: m,
1450
- signatureHex: A,
1451
- signerXOnlyPubkeyHex: h,
1452
- inputIndex: x
1453
- }), A;
1454
- }), k = he({
1482
+ signatureHex: T,
1483
+ signerXOnlyPubkeyHex: p,
1484
+ inputIndex: E
1485
+ }), T;
1486
+ }), b = fe({
1455
1487
  requestedPsbtHex: m,
1456
- signaturesHex: w,
1457
- signerXOnlyPubkeyHex: h
1488
+ signaturesHex: x,
1489
+ signerXOnlyPubkeyHex: p
1458
1490
  });
1459
- return n == null || n.throwIfAborted(), i(k);
1491
+ return n == null || n.throwIfAborted(), i(b);
1460
1492
  }
1461
1493
  export {
1462
- Pt as A,
1463
- W as B,
1464
- yt as C,
1465
- wt as D,
1466
- ye as E,
1467
- gr as F,
1468
- fr as G,
1469
- _t as H,
1470
- vr as I,
1471
- mr as J,
1472
- re as K,
1473
- te as L,
1474
- ee as M,
1475
- ke as N,
1476
- oe as O,
1477
- Ye as P,
1478
- br as Q,
1479
- be as R,
1480
- ae as S,
1481
- se as T,
1482
- ne as U,
1483
- Pr as V,
1484
- Yt as a,
1485
- Jt as b,
1486
- pe as c,
1487
- ge as d,
1488
- Zt as e,
1489
- rr as f,
1490
- sr as g,
1491
- ar as h,
1492
- tt as i,
1493
- lr as j,
1494
- ur as k,
1495
- ir as l,
1496
- Et as m,
1497
- xt as n,
1498
- Pe as o,
1499
- cr as p,
1500
- hr as q,
1501
- tr as r,
1502
- ut as s,
1503
- dr as t,
1504
- pr as u,
1505
- nr as v,
1506
- er as w,
1507
- fe as x,
1508
- or as y,
1509
- D as z
1494
+ L as A,
1495
+ D as B,
1496
+ xt as C,
1497
+ ee as D,
1498
+ At as E,
1499
+ Ct as F,
1500
+ xe as G,
1501
+ wr as H,
1502
+ Er as I,
1503
+ Kt as J,
1504
+ xr as K,
1505
+ kr as L,
1506
+ ae as M,
1507
+ se as N,
1508
+ ne as O,
1509
+ ot as P,
1510
+ Ae as Q,
1511
+ ke as R,
1512
+ ie as S,
1513
+ Ar as T,
1514
+ ce as U,
1515
+ le as V,
1516
+ ue as W,
1517
+ Tr as X,
1518
+ or as a,
1519
+ nr as b,
1520
+ Pe as c,
1521
+ ve as d,
1522
+ sr as e,
1523
+ ur as f,
1524
+ cr as g,
1525
+ hr as h,
1526
+ it as i,
1527
+ dr as j,
1528
+ mr as k,
1529
+ fr as l,
1530
+ gr as m,
1531
+ _t as n,
1532
+ St as o,
1533
+ Ee as p,
1534
+ Pr as q,
1535
+ ir as r,
1536
+ gt as s,
1537
+ vr as t,
1538
+ yr as u,
1539
+ pr as v,
1540
+ ar as w,
1541
+ br as x,
1542
+ ye as y,
1543
+ lr as z
1510
1544
  };
1511
- //# sourceMappingURL=buildAndBroadcastReclaim-DCGcupg7.js.map
1545
+ //# sourceMappingURL=buildAndBroadcastReclaim-O6z9kvc4.js.map