@babylonlabs-io/ts-sdk 0.78.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 (105) hide show
  1. package/dist/{BTCVaultRegistry.abi-BT3eo60h.js → BTCVaultRegistry.abi-B0x9_Bza.js} +43 -1
  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-Cz0Ytdwo.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-DD50pVB1.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 +227 -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-7Vbtdypu.js → pegin-registration-client-pcczkzMg.js} +184 -143
  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.js +2 -2
  29. package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts +17 -0
  30. package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts.map +1 -1
  31. package/dist/tbv/core/clients/eth/signer-set-reader.d.ts +2 -0
  32. package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
  33. package/dist/tbv/core/clients/eth/types.d.ts +28 -0
  34. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  35. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +12 -0
  36. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  37. package/dist/tbv/core/clients/index.cjs +1 -1
  38. package/dist/tbv/core/clients/index.js +2 -2
  39. package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts +24 -0
  40. package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts.map +1 -0
  41. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +14 -0
  42. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
  43. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +38 -0
  44. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  45. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +10 -0
  46. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  47. package/dist/tbv/core/contracts/errors.d.ts +41 -4
  48. package/dist/tbv/core/contracts/errors.d.ts.map +1 -1
  49. package/dist/tbv/core/contracts/index.cjs +1 -1
  50. package/dist/tbv/core/contracts/index.cjs.map +1 -1
  51. package/dist/tbv/core/contracts/index.d.ts +1 -1
  52. package/dist/tbv/core/contracts/index.d.ts.map +1 -1
  53. package/dist/tbv/core/contracts/index.js +15 -492
  54. package/dist/tbv/core/contracts/index.js.map +1 -1
  55. package/dist/tbv/core/index.cjs +1 -1
  56. package/dist/tbv/core/index.js +222 -217
  57. package/dist/tbv/core/managers/PeginManager.d.ts +13 -25
  58. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  59. package/dist/tbv/core/managers/index.cjs +1 -1
  60. package/dist/tbv/core/managers/index.d.ts +2 -2
  61. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  62. package/dist/tbv/core/managers/index.js +4 -5
  63. package/dist/tbv/core/pegin-fingerprint/index.d.ts +1 -1
  64. package/dist/tbv/core/pegin-fingerprint/index.d.ts.map +1 -1
  65. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts +10 -0
  66. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts.map +1 -1
  67. package/dist/tbv/core/services/deposit/index.d.ts +1 -1
  68. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  69. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +50 -3
  70. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
  71. package/dist/tbv/core/services/index.cjs +1 -1
  72. package/dist/tbv/core/services/index.js +56 -54
  73. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -1
  74. package/dist/tbv/index.cjs +1 -1
  75. package/dist/tbv/index.js +222 -217
  76. package/dist/{toRefundInputs-D708M8MA.js → toRefundInputs-9inv4Ai4.js} +96 -92
  77. package/dist/toRefundInputs-9inv4Ai4.js.map +1 -0
  78. package/dist/toRefundInputs-DitGWAnz.cjs +2 -0
  79. package/dist/toRefundInputs-DitGWAnz.cjs.map +1 -0
  80. package/dist/{types-BwqkOoJ6.js → types-B9YhlXe8.js} +109 -83
  81. package/dist/types-B9YhlXe8.js.map +1 -0
  82. package/dist/types-C1tpDycc.cjs +2 -0
  83. package/dist/types-C1tpDycc.cjs.map +1 -0
  84. package/package.json +3 -3
  85. package/dist/BTCVaultRegistry.abi-BJnjzEWD.cjs +0 -2
  86. package/dist/BTCVaultRegistry.abi-BJnjzEWD.cjs.map +0 -1
  87. package/dist/BTCVaultRegistry.abi-BT3eo60h.js.map +0 -1
  88. package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs +0 -2
  89. package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs.map +0 -1
  90. package/dist/BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js.map +0 -1
  91. package/dist/PeginManager-Cz0Ytdwo.js.map +0 -1
  92. package/dist/PeginManager-DE2lTWMl.cjs +0 -2
  93. package/dist/PeginManager-DE2lTWMl.cjs.map +0 -1
  94. package/dist/buildAndBroadcastReclaim-CB5VPETy.cjs +0 -2
  95. package/dist/buildAndBroadcastReclaim-CB5VPETy.cjs.map +0 -1
  96. package/dist/buildAndBroadcastReclaim-DD50pVB1.js.map +0 -1
  97. package/dist/pegin-registration-client-7Vbtdypu.js.map +0 -1
  98. package/dist/pegin-registration-client-CSe1vOum.cjs +0 -2
  99. package/dist/pegin-registration-client-CSe1vOum.cjs.map +0 -1
  100. package/dist/toRefundInputs-BH3wkNC4.cjs +0 -2
  101. package/dist/toRefundInputs-BH3wkNC4.cjs.map +0 -1
  102. package/dist/toRefundInputs-D708M8MA.js.map +0 -1
  103. package/dist/types-BN0jOH8K.cjs +0 -2
  104. package/dist/types-BN0jOH8K.cjs.map +0 -1
  105. package/dist/types-BwqkOoJ6.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  var re = Object.defineProperty;
2
2
  var ne = (e, t, r) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var _ = (e, t, r) => ne(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { keccak256 as G, toHex as oe, encodeAbiParameters as se, isAddress as ae, zeroAddress as ie } from "viem";
4
+ import { keccak256 as G, toHex as oe, encodeAbiParameters as se, isAddress as ie, zeroAddress as ae } from "viem";
5
5
  import { s as ce } from "./sha2-CLpQd0Rd.js";
6
6
  import { a as M } from "./signPsbtsWithFallback-f7QLp0q8.js";
7
- import { b as ue, f as le } from "./PeginManager-Cz0Ytdwo.js";
8
- import { s as P, h as he, p as W, u as de, e as me } from "./bitcoin-C-TuHb-v.js";
9
- import { computeMinClaimValue as Q, computeMinPeginFee as X, peginP2aAnchorOutput as q, getPrePeginHtlcConnectorInfo as pe, expandAuthAnchor as ge } from "./tbv/core/wasm/index.js";
7
+ import { b as ue, a as le } from "./PeginManager-BXlh3ar0.js";
8
+ import { s as f, h as he, p as W, u as de, e as me } from "./bitcoin-C-TuHb-v.js";
9
+ import { computeMinClaimValue as Q, computeMinPeginFee as q, peginP2aAnchorOutput as X, getPrePeginHtlcConnectorInfo as pe, expandAuthAnchor as ge } from "./tbv/core/wasm/index.js";
10
10
  import { p as Pe, d as fe } from "./parseFundingOutpoints-BQWvINfm.js";
11
11
  import { Transaction as J } from "bitcoinjs-lib";
12
12
  import { o as ve, H as z } from "./verifyScriptPathSchnorrSignature-D_epga4j.js";
@@ -20,7 +20,7 @@ class be extends Error {
20
20
  this.name = Z, this.reason = n;
21
21
  }
22
22
  }
23
- function qe(e) {
23
+ function Xe(e) {
24
24
  if (e instanceof be) return !0;
25
25
  if (typeof e != "object" || e === null) return !1;
26
26
  const t = e;
@@ -41,7 +41,7 @@ async function ye(e) {
41
41
  throw new Error(
42
42
  `rebuildDepositTermsCore: prepeginMaxFee must be > 0, got ${e.prepeginMaxFee}`
43
43
  );
44
- const r = P(e.prepeginTxid).toLowerCase(), n = P(
44
+ const r = f(e.prepeginTxid).toLowerCase(), n = f(
45
45
  Y(e.fundedPrePeginTxHex)
46
46
  ).toLowerCase();
47
47
  if (n !== r)
@@ -49,7 +49,7 @@ async function ye(e) {
49
49
  `Funded Pre-PegIn tx hashes to ${n}, expected ${r} (on-chain prepeginTxid). Resume refused.`
50
50
  );
51
51
  const h = M(
52
- P(e.fundedPrePeginTxHex)
52
+ f(e.fundedPrePeginTxHex)
53
53
  );
54
54
  if (h === void 0)
55
55
  throw new Error(
@@ -66,31 +66,31 @@ async function ye(e) {
66
66
  e.councilQuorum,
67
67
  e.councilSize,
68
68
  e.protocolFeeRate
69
- ), i = await X(
69
+ ), a = await q(
70
70
  e.vaultCoreVersion,
71
71
  c,
72
72
  u,
73
73
  e.minPeginFeeRate
74
- ), d = await q(e.vaultCoreVersion), s = (d == null ? void 0 : d.value) ?? 0n;
74
+ ), d = await X(e.vaultCoreVersion), s = (d == null ? void 0 : d.value) ?? 0n;
75
75
  if (l <= 0n)
76
76
  throw new Error(
77
77
  `WASM returned non-positive depositorClaimValue ${l}; expected > 0. Resume refused.`
78
78
  );
79
- if (i <= 0n)
79
+ if (a <= 0n)
80
80
  throw new Error(
81
- `WASM returned non-positive peginMaxFee ${i}; expected > 0. Resume refused.`
81
+ `WASM returned non-positive peginMaxFee ${a}; expected > 0. Resume refused.`
82
82
  );
83
83
  if (s < 0n)
84
84
  throw new Error(
85
85
  `WASM returned negative P2A anchor value ${s}. Resume refused.`
86
86
  );
87
- const a = i + s, v = e.minPeginFeeRate * O;
88
- if (a <= 0n || a > v)
87
+ const i = a + s, v = e.minPeginFeeRate * O;
88
+ if (i <= 0n || i > v)
89
89
  throw new Error(
90
- `WASM implied PegIn reserve ${a} sat is outside (0, ${v}] (minPeginFeeRate=${e.minPeginFeeRate} × ${O} vbytes). Resume refused.`
90
+ `WASM implied PegIn reserve ${i} sat is outside (0, ${v}] (minPeginFeeRate=${e.minPeginFeeRate} × ${O} vbytes). Resume refused.`
91
91
  );
92
92
  const w = e.siblings.map(
93
- (o) => o.amount + l + i + s
93
+ (o) => o.amount + l + a + s
94
94
  ), C = await Promise.all(
95
95
  e.siblings.map(async (o) => (await pe({
96
96
  txGraphVersion: e.vaultCoreVersion,
@@ -98,12 +98,12 @@ async function ye(e) {
98
98
  vaultProviderPubkey: e.vaultProviderBtcPubkey,
99
99
  vaultKeeperPubkeys: [...e.vaultKeeperBtcPubkeys],
100
100
  universalChallengerPubkeys: [...e.universalChallengerBtcPubkeys],
101
- hashlock: P(o.hashlock),
101
+ hashlock: f(o.hashlock),
102
102
  timelockRefund: e.timelockRefund,
103
103
  network: e.network
104
104
  })).scriptPubKey)
105
105
  ), E = J.fromHex(
106
- P(e.fundedPrePeginTxHex)
106
+ f(e.fundedPrePeginTxHex)
107
107
  ).outs.map((o) => ({ value: o.value, script: o.script }));
108
108
  return ve(
109
109
  E,
@@ -123,7 +123,7 @@ async function ye(e) {
123
123
  maxAcceptableCommissionBps: e.maxAcceptableCommissionBps,
124
124
  peginAmounts: e.siblings.map((o) => o.amount),
125
125
  depositorClaimValue: l,
126
- peginMaxFee: i
126
+ peginMaxFee: a
127
127
  });
128
128
  }
129
129
  function Je(e) {
@@ -133,42 +133,45 @@ function Je(e) {
133
133
  const we = "TBV.PeginFingerprint.v1", Ee = G(
134
134
  oe(we)
135
135
  ), U = 65535, D = 2n ** 64n - 1n, Ce = 2n ** 256n - 1n, Re = /^0x[0-9a-fA-F]{64}$/, L = 1;
136
- class f extends Error {
136
+ class P extends Error {
137
137
  constructor(t) {
138
138
  super(t), this.name = "PeginFingerprintInputError";
139
139
  }
140
140
  }
141
- function B(e, t, r, n) {
141
+ function Ye(e) {
142
+ return e instanceof P || e instanceof Error && e.name === "PeginFingerprintInputError";
143
+ }
144
+ function F(e, t, r, n) {
142
145
  if (typeof t != "bigint")
143
- throw new f(
146
+ throw new P(
144
147
  `${e} must be a bigint (Solidity ${n}), got ${typeof t}`
145
148
  );
146
149
  if (t < 0n || t > r)
147
- throw new f(
150
+ throw new P(
148
151
  `${e} must fit Solidity ${n} (0..${r}), got ${t}`
149
152
  );
150
153
  }
151
154
  function $(e, t) {
152
155
  if (!Number.isInteger(t) || t < 0 || t > U)
153
- throw new f(
156
+ throw new P(
154
157
  `${e} must be an integer fitting Solidity uint16 (0..${U}), got ${t}`
155
158
  );
156
159
  }
157
160
  function ke(e, t) {
158
161
  if (!Re.test(t))
159
- throw new f(
162
+ throw new P(
160
163
  `${e} must be 32 bytes as 0x-prefixed hex (66 characters), got "${t}"`
161
164
  );
162
165
  return t.toLowerCase();
163
166
  }
164
167
  function xe(e) {
165
- if (!ae(e, { strict: !1 }))
166
- throw new f(
168
+ if (!ie(e, { strict: !1 }))
169
+ throw new P(
167
170
  `registryAddress must be a 20-byte 0x-prefixed address, got "${e}"`
168
171
  );
169
172
  const t = e.toLowerCase();
170
- if (t === ie)
171
- throw new f(
173
+ if (t === ae)
174
+ throw new P(
172
175
  "registryAddress must not be the zero address; a zero here means the registry address was never resolved"
173
176
  );
174
177
  return t;
@@ -186,24 +189,24 @@ const Ve = [
186
189
  { name: "vaultCoreVersion", type: "uint16" }
187
190
  ];
188
191
  function $e(e) {
189
- if (B("chainId", e.chainId, Ce, "uint256"), e.chainId === 0n)
190
- throw new f(
192
+ if (F("chainId", e.chainId, Ce, "uint256"), e.chainId === 0n)
193
+ throw new P(
191
194
  "chainId must not be 0; a zero here means the chain id was never resolved"
192
195
  );
193
196
  const t = xe(e.registryAddress), r = ke(
194
197
  "vaultProviderBtcKey",
195
198
  e.vaultProviderBtcKey
196
199
  );
197
- if (B(
200
+ if (F(
198
201
  "appKeeperKeyEpoch",
199
202
  e.appKeeperKeyEpoch,
200
203
  D,
201
204
  "uint64"
202
- ), B("ucKeyEpoch", e.ucKeyEpoch, D, "uint64"), $("appVaultKeepersVersion", e.appVaultKeepersVersion), $(
205
+ ), F("ucKeyEpoch", e.ucKeyEpoch, D, "uint64"), $("appVaultKeepersVersion", e.appVaultKeepersVersion), $(
203
206
  "universalChallengersVersion",
204
207
  e.universalChallengersVersion
205
208
  ), $("offchainParamsVersion", e.offchainParamsVersion), $("vaultCoreVersion", e.vaultCoreVersion), e.vaultCoreVersion < L)
206
- throw new f(
209
+ throw new P(
207
210
  `vaultCoreVersion must be at least ${L}; ${e.vaultCoreVersion} means the version was never resolved`
208
211
  );
209
212
  return se(Ve, [
@@ -219,7 +222,7 @@ function $e(e) {
219
222
  e.vaultCoreVersion
220
223
  ]);
221
224
  }
222
- function Ye(e) {
225
+ function Ze(e) {
223
226
  return G($e(e));
224
227
  }
225
228
  class Te extends Error {
@@ -248,7 +251,7 @@ class Ie extends Error {
248
251
  ), this.survivorLabels = t, this.name = "PeginParamsAmbiguousError";
249
252
  }
250
253
  }
251
- class Be extends Error {
254
+ class Fe extends Error {
252
255
  constructor(t, r) {
253
256
  super(
254
257
  `A candidate matched this Pre-PegIn (${t}), but ${r.length} version(s) could not be resolved, so the search space did not provably contain the true parameters: ${r.join(" | ")}. A version sharing the matched timelockRefund and participants is indistinguishable from the true one, so the match cannot be trusted. Reconstruction refused.`
@@ -260,8 +263,8 @@ class T extends Error {
260
263
  super(`${t}. Reconstruction refused.`), this.name = "PeginSizingIntegrityError";
261
264
  }
262
265
  }
263
- async function Ze(e) {
264
- const { wallet: t, depositorBtcPubkey: r, fundedPrePeginTxHex: n } = e, h = P(n), c = M(h);
266
+ async function et(e) {
267
+ const { wallet: t, depositorBtcPubkey: r, fundedPrePeginTxHex: n } = e, h = f(n), c = M(h);
265
268
  if (c === void 0)
266
269
  throw new K(
267
270
  "Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN, so the number of HTLC outputs it funds cannot be determined. Legacy pre-anchor deposits are not recoverable by this path."
@@ -271,7 +274,7 @@ async function Ze(e) {
271
274
  throw new K(
272
275
  "Pre-PegIn's auth-anchor OP_RETURN is at vout 0, implying zero HTLC outputs; there is nothing to recover."
273
276
  );
274
- const l = Pe(h), i = await fe(t, {
277
+ const l = Pe(h), a = await fe(t, {
275
278
  // The vault context takes the 32-byte x-only key; a wallet's compressed
276
279
  // key would otherwise fail a byte-length check deep in the encoder with
277
280
  // nothing pointing back at the caller.
@@ -281,22 +284,22 @@ async function Ze(e) {
281
284
  fundingOutpoints: l
282
285
  });
283
286
  try {
284
- const s = await ge(i);
285
- let a;
287
+ const s = await ge(a);
288
+ let i;
286
289
  try {
287
- a = de(ce(s));
290
+ i = de(ce(s));
288
291
  } finally {
289
292
  s.fill(0);
290
293
  }
291
- if (a !== c.hash)
292
- throw new Te(a, c.hash);
294
+ if (i !== c.hash)
295
+ throw new Te(i, c.hash);
293
296
  } catch (s) {
294
- throw i.fill(0), s;
297
+ throw a.fill(0), s;
295
298
  }
296
- const { hashlocks: d } = await le(i, u);
299
+ const { hashlocks: d } = await le(a, u);
297
300
  return { vaultCount: u, hashlocks: d, authAnchorHash: c.hash };
298
301
  }
299
- function et(e) {
302
+ function tt(e) {
300
303
  const { vaultCoreVersion: t, offchainParams: r, participantKeySets: n } = e;
301
304
  if (!Number.isInteger(t) || t < 1)
302
305
  throw new Error(
@@ -320,10 +323,10 @@ function et(e) {
320
323
  });
321
324
  return h;
322
325
  }
323
- function Fe(e) {
326
+ function Be(e) {
324
327
  return `${e.axis} v${e.version} (${e.reason})`;
325
328
  }
326
- function F(e) {
329
+ function B(e) {
327
330
  const { participants: t } = e;
328
331
  return `core=${e.vaultCoreVersion} offchain=${e.offchainParams.version} keepers=${t.appVaultKeepersVersion} challengers=${t.universalChallengersVersion} vp=${t.vaultProvider}`;
329
332
  }
@@ -356,14 +359,14 @@ async function Se(e) {
356
359
  t.councilSize,
357
360
  t.protocolFeeRate
358
361
  ),
359
- X(
362
+ q(
360
363
  e.vaultCoreVersion,
361
364
  n,
362
365
  h,
363
366
  t.minPeginFeeRate
364
367
  ),
365
- q(e.vaultCoreVersion)
366
- ]), i = (l == null ? void 0 : l.value) ?? 0n;
368
+ X(e.vaultCoreVersion)
369
+ ]), a = (l == null ? void 0 : l.value) ?? 0n;
367
370
  if (c <= 0n)
368
371
  throw new T(
369
372
  `WASM returned non-positive depositorClaimValue ${c} for graph version ${e.vaultCoreVersion}`
@@ -372,13 +375,13 @@ async function Se(e) {
372
375
  throw new T(
373
376
  `WASM returned non-positive peginMaxFee ${u} for graph version ${e.vaultCoreVersion}`
374
377
  );
375
- if (i < 0n)
378
+ if (a < 0n)
376
379
  throw new T(
377
- `WASM returned negative P2A anchor value ${i} for graph version ${e.vaultCoreVersion}`
380
+ `WASM returned negative P2A anchor value ${a} for graph version ${e.vaultCoreVersion}`
378
381
  );
379
- return { depositorClaimValue: c, peginMaxFee: u, p2aAnchorValue: i };
382
+ return { depositorClaimValue: c, peginMaxFee: u, p2aAnchorValue: a };
380
383
  }
381
- async function tt(e) {
384
+ async function rt(e) {
382
385
  const {
383
386
  hashlocks: t,
384
387
  fundedPrePeginTxHex: r,
@@ -387,7 +390,7 @@ async function tt(e) {
387
390
  maxAcceptableCommissionBps: c,
388
391
  network: u,
389
392
  candidates: l,
390
- unresolvedVersions: i
393
+ unresolvedVersions: a
391
394
  } = e;
392
395
  if (t.length === 0)
393
396
  throw new Error(
@@ -395,16 +398,16 @@ async function tt(e) {
395
398
  );
396
399
  if (l.length === 0)
397
400
  throw new Error("reconstructPeginParams: candidate space is empty");
398
- const d = W(n), s = P(r), a = M(s);
399
- if (a === void 0)
401
+ const d = W(n), s = f(r), i = M(s);
402
+ if (i === void 0)
400
403
  throw new K(
401
404
  "Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN; the sibling set cannot be proven complete. Reconstruction refused."
402
405
  );
403
- if (a.vout !== t.length)
406
+ if (i.vout !== t.length)
404
407
  throw new Error(
405
- `reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${a.vout}, so the transaction funds ${a.vout} HTLC output(s). Reconstruction refused.`
408
+ `reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${i.vout}, so the transaction funds ${i.vout} HTLC output(s). Reconstruction refused.`
406
409
  );
407
- const v = J.fromHex(s).outs, w = t.map((m, p) => BigInt(v[p].value)), C = P(
410
+ const v = J.fromHex(s).outs, w = t.map((m, p) => BigInt(v[p].value)), C = f(
408
411
  Y(s)
409
412
  ).toLowerCase(), E = /* @__PURE__ */ new Map(), o = [], b = [], A = [];
410
413
  let S = 0;
@@ -450,34 +453,34 @@ async function tt(e) {
450
453
  } catch (p) {
451
454
  if (p instanceof T)
452
455
  throw p;
453
- const g = F(m), R = p instanceof Error ? p.message : String(p);
456
+ const g = B(m), R = p instanceof Error ? p.message : String(p);
454
457
  p instanceof z ? b.length < j && b.push(`[${g}] ${R}`) : (S++, A.length < j && A.push(`${g} (${R})`));
455
458
  }
456
- const ee = i.length + S, H = [
457
- ...i.map(Fe),
459
+ const ee = a.length + S, H = [
460
+ ...a.map(Be),
458
461
  ...A
459
462
  ];
460
463
  if (o.length === 0)
461
464
  throw new Ae(l.length, b, H);
462
465
  if (new Set(o.map((m) => m.fingerprint)).size > 1)
463
466
  throw new Ie(
464
- o.map((m) => F(m.candidate))
467
+ o.map((m) => B(m.candidate))
465
468
  );
466
469
  if (ee > 0)
467
- throw new Be(
468
- F(o[0].candidate),
470
+ throw new Fe(
471
+ B(o[0].candidate),
469
472
  H
470
473
  );
471
474
  return {
472
475
  candidate: o[0].candidate,
473
476
  terms: o[0].terms,
474
477
  peginAmounts: o[0].peginAmounts,
475
- authAnchorHash: a.hash,
478
+ authAnchorHash: i.hash,
476
479
  candidatesTried: l.length,
477
480
  matchedCandidates: o.map((m) => m.candidate)
478
481
  };
479
482
  }
480
- function rt(e, t) {
483
+ function nt(e, t) {
481
484
  const {
482
485
  htlcVout: r,
483
486
  depositorBtcPubkey: n,
@@ -485,7 +488,7 @@ function rt(e, t) {
485
488
  fundedPrePeginTxHex: c,
486
489
  hashlocks: u,
487
490
  network: l
488
- } = t, { candidate: i, peginAmounts: d } = e, { offchainParams: s, participants: a } = i;
491
+ } = t, { candidate: a, peginAmounts: d } = e, { offchainParams: s, participants: i } = a;
489
492
  if (u.length !== d.length)
490
493
  throw new Error(
491
494
  `toRefundInputs: ${u.length} hashlock(s) but ${d.length} reconstructed amount(s); the reconstruction and the hashlock vector describe different transactions.`
@@ -499,28 +502,28 @@ function rt(e, t) {
499
502
  amount: E,
500
503
  htlcVout: o
501
504
  })), w = {
502
- vaultCoreVersion: i.vaultCoreVersion,
505
+ vaultCoreVersion: a.vaultCoreVersion,
503
506
  hashlock: v[r].hashlock,
504
507
  htlcVout: r,
505
508
  offchainParamsVersion: s.version,
506
- appVaultKeepersVersion: a.appVaultKeepersVersion,
507
- universalChallengersVersion: a.universalChallengersVersion,
508
- vaultProvider: a.vaultProvider,
509
+ appVaultKeepersVersion: i.appVaultKeepersVersion,
510
+ universalChallengersVersion: i.universalChallengersVersion,
511
+ vaultProvider: i.vaultProvider,
509
512
  applicationEntryPoint: h,
510
513
  amount: d[r],
511
514
  unsignedPrePeginTxHex: c,
512
515
  depositorBtcPubkey: n,
513
516
  batch: v
514
517
  }, C = {
515
- vaultProviderPubkey: a.vaultProviderBtcPubkey,
516
- vaultKeeperPubkeys: a.vaultKeeperBtcPubkeys,
517
- universalChallengerPubkeys: a.universalChallengerBtcPubkeys,
518
+ vaultProviderPubkey: i.vaultProviderBtcPubkey,
519
+ vaultKeeperPubkeys: i.vaultKeeperBtcPubkeys,
520
+ universalChallengerPubkeys: i.universalChallengerBtcPubkeys,
518
521
  timelockRefund: s.timelockRefund,
519
522
  feeRate: s.protocolFeeRate,
520
523
  minPeginFeeRate: s.minPeginFeeRate,
521
524
  // Depositor-as-claimer: the local-challenger count is the keeper count,
522
525
  // the vault provider excluded — btc-vault graph.rs derive_challengers.
523
- numLocalChallengers: a.vaultKeeperBtcPubkeys.length,
526
+ numLocalChallengers: i.vaultKeeperBtcPubkeys.length,
524
527
  councilQuorum: s.councilQuorum,
525
528
  councilSize: s.councilSize,
526
529
  network: l
@@ -533,22 +536,23 @@ export {
533
536
  K as U,
534
537
  Te as V,
535
538
  we as a,
536
- f as b,
537
- Ye as c,
538
- be as d,
539
+ P as b,
540
+ Ze as c,
541
+ Ye as d,
539
542
  $e as e,
540
- qe as f,
541
- Ze as g,
543
+ be as f,
544
+ Xe as g,
542
545
  et as h,
543
546
  Je as i,
544
- Fe as j,
545
- F as k,
546
- tt as l,
547
- Ae as m,
548
- Ie as n,
549
- Be as o,
550
- T as p,
547
+ tt as j,
548
+ Be as k,
549
+ B as l,
550
+ rt as m,
551
+ Ae as n,
552
+ Ie as o,
553
+ Fe as p,
554
+ T as q,
551
555
  ye as r,
552
- rt as t
556
+ nt as t
553
557
  };
554
- //# sourceMappingURL=toRefundInputs-D708M8MA.js.map
558
+ //# sourceMappingURL=toRefundInputs-9inv4Ai4.js.map