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