@babylonlabs-io/ts-sdk 0.57.0 → 0.57.2

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