@babylonlabs-io/ts-sdk 0.55.1 → 0.56.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 (160) hide show
  1. package/README.md +0 -1
  2. package/dist/{PayoutManager-BJmPnyRP.js → PayoutManager-BVgmuKuK.js} +117 -105
  3. package/dist/PayoutManager-BVgmuKuK.js.map +1 -0
  4. package/dist/PayoutManager-Cu4_l-_Y.cjs +2 -0
  5. package/dist/PayoutManager-Cu4_l-_Y.cjs.map +1 -0
  6. package/dist/PeginManager-BkWdZI7P.cjs +2 -0
  7. package/dist/PeginManager-BkWdZI7P.cjs.map +1 -0
  8. package/dist/PeginManager-aYBkb-Qx.js +1289 -0
  9. package/dist/PeginManager-aYBkb-Qx.js.map +1 -0
  10. package/dist/{buildAndBroadcastRefund-BiSO4zg2.js → buildAndBroadcastRefund-BtXUqBkb.js} +444 -430
  11. package/dist/buildAndBroadcastRefund-BtXUqBkb.js.map +1 -0
  12. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs +2 -0
  13. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs.map +1 -0
  14. package/dist/challengeAssert-BVQq50su.js +75 -0
  15. package/dist/challengeAssert-BVQq50su.js.map +1 -0
  16. package/dist/challengeAssert-Cu-PtJ1g.cjs +2 -0
  17. package/dist/challengeAssert-Cu-PtJ1g.cjs.map +1 -0
  18. package/dist/constants-BqU1Uz15.cjs +2 -0
  19. package/dist/{constants-CvbARMl-.cjs.map → constants-BqU1Uz15.cjs.map} +1 -1
  20. package/dist/{constants-BhclpREj.js → constants-CDQE812z.js} +8 -6
  21. package/dist/{constants-BhclpREj.js.map → constants-CDQE812z.js.map} +1 -1
  22. package/dist/deriveVaultRoot-B_gEOTD6.js +72 -0
  23. package/dist/deriveVaultRoot-B_gEOTD6.js.map +1 -0
  24. package/dist/deriveVaultRoot-CebLadyJ.cjs +2 -0
  25. package/dist/deriveVaultRoot-CebLadyJ.cjs.map +1 -0
  26. package/dist/errors-B-H0seUG.js +8 -0
  27. package/dist/errors-B-H0seUG.js.map +1 -0
  28. package/dist/errors-Bfjxg_iJ.cjs +2 -0
  29. package/dist/errors-Bfjxg_iJ.cjs.map +1 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.js +197 -193
  32. package/dist/index.js.map +1 -1
  33. package/dist/{mempoolApi-CB7bHuwi.js → mempoolApi-P_ApODLd.js} +2 -2
  34. package/dist/{mempoolApi-CB7bHuwi.js.map → mempoolApi-P_ApODLd.js.map} +1 -1
  35. package/dist/{mempoolApi-DqJByvqR.cjs → mempoolApi-emec8bHK.cjs} +2 -2
  36. package/dist/{mempoolApi-DqJByvqR.cjs.map → mempoolApi-emec8bHK.cjs.map} +1 -1
  37. package/dist/{noPayout-CNMqNNpc.cjs → noPayout-Cb8vFrkY.cjs} +2 -2
  38. package/dist/{noPayout-CNMqNNpc.cjs.map → noPayout-Cb8vFrkY.cjs.map} +1 -1
  39. package/dist/{noPayout-CfBg3HzC.js → noPayout-CihCk1HE.js} +2 -2
  40. package/dist/{noPayout-CfBg3HzC.js.map → noPayout-CihCk1HE.js.map} +1 -1
  41. package/dist/parseFundingOutpoints-C_-PT9BT.cjs +2 -0
  42. package/dist/parseFundingOutpoints-C_-PT9BT.cjs.map +1 -0
  43. package/dist/parseFundingOutpoints-GSM-IaaK.js +17 -0
  44. package/dist/parseFundingOutpoints-GSM-IaaK.js.map +1 -0
  45. package/dist/{primeVpAuth-l-5x_2UV.js → primeVpAuth-DZOaC_Ui.js} +3 -3
  46. package/dist/{primeVpAuth-l-5x_2UV.js.map → primeVpAuth-DZOaC_Ui.js.map} +1 -1
  47. package/dist/{primeVpAuth-CF4cH5_e.cjs → primeVpAuth-j2getl3f.cjs} +2 -2
  48. package/dist/{primeVpAuth-CF4cH5_e.cjs.map → primeVpAuth-j2getl3f.cjs.map} +1 -1
  49. package/dist/tbv/core/clients/index.cjs +1 -1
  50. package/dist/tbv/core/clients/index.js +2 -2
  51. package/dist/tbv/core/deposit-terms/__tests__/buildDepositTerms.test.d.ts +2 -0
  52. package/dist/tbv/core/deposit-terms/__tests__/buildDepositTerms.test.d.ts.map +1 -0
  53. package/dist/tbv/core/deposit-terms/buildDepositTerms.d.ts +8 -0
  54. package/dist/tbv/core/deposit-terms/buildDepositTerms.d.ts.map +1 -0
  55. package/dist/tbv/core/deposit-terms/depositTerms.d.ts +92 -0
  56. package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -0
  57. package/dist/tbv/core/deposit-terms/index.d.ts +12 -0
  58. package/dist/tbv/core/deposit-terms/index.d.ts.map +1 -0
  59. package/dist/tbv/core/index.cjs +1 -1
  60. package/dist/tbv/core/index.d.ts +1 -0
  61. package/dist/tbv/core/index.d.ts.map +1 -1
  62. package/dist/tbv/core/index.js +195 -191
  63. package/dist/tbv/core/index.js.map +1 -1
  64. package/dist/tbv/core/managers/PayoutManager.d.ts +7 -0
  65. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  66. package/dist/tbv/core/managers/PeginManager.d.ts +13 -0
  67. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  68. package/dist/tbv/core/managers/index.cjs +1 -1
  69. package/dist/tbv/core/managers/index.js +2 -2
  70. package/dist/tbv/core/primitives/index.cjs +1 -1
  71. package/dist/tbv/core/primitives/index.d.ts +0 -3
  72. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  73. package/dist/tbv/core/primitives/index.js +37 -38
  74. package/dist/tbv/core/primitives/psbt/__tests__/assertPayoutFeeBand.test.d.ts +7 -0
  75. package/dist/tbv/core/primitives/psbt/__tests__/assertPayoutFeeBand.test.d.ts.map +1 -0
  76. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts +63 -0
  77. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts.map +1 -0
  78. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +4 -1
  79. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  80. package/dist/tbv/core/primitives/psbt/constants.d.ts +18 -4
  81. package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
  82. package/dist/tbv/core/primitives/psbt/payout.d.ts +21 -2
  83. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  84. package/dist/tbv/core/primitives/psbt/pegin.d.ts +6 -0
  85. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  86. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +12 -0
  87. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  88. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +5 -0
  89. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  90. package/dist/tbv/core/services/index.cjs +1 -1
  91. package/dist/tbv/core/services/index.js +2 -2
  92. package/dist/tbv/core/vault-secrets/index.cjs +2 -0
  93. package/dist/tbv/core/vault-secrets/index.cjs.map +1 -0
  94. package/dist/tbv/core/vault-secrets/index.js +14 -0
  95. package/dist/tbv/core/vault-secrets/index.js.map +1 -0
  96. package/dist/tbv/index.cjs +1 -1
  97. package/dist/tbv/index.js +195 -191
  98. package/dist/tbv/index.js.map +1 -1
  99. package/dist/tbv/integrations/aave/clients/index.d.ts +1 -1
  100. package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
  101. package/dist/tbv/integrations/aave/clients/spoke.d.ts +0 -20
  102. package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
  103. package/dist/tbv/integrations/aave/constants.d.ts +0 -22
  104. package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
  105. package/dist/tbv/integrations/aave/index.cjs +1 -1
  106. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  107. package/dist/tbv/integrations/aave/index.d.ts +5 -6
  108. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  109. package/dist/tbv/integrations/aave/index.js +236 -339
  110. package/dist/tbv/integrations/aave/index.js.map +1 -1
  111. package/dist/tbv/integrations/aave/types.d.ts +0 -7
  112. package/dist/tbv/integrations/aave/types.d.ts.map +1 -1
  113. package/dist/tbv/integrations/aave/utils/healthFactor.d.ts +0 -7
  114. package/dist/tbv/integrations/aave/utils/healthFactor.d.ts.map +1 -1
  115. package/dist/tbv/integrations/aave/utils/index.d.ts +3 -8
  116. package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -1
  117. package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts +0 -65
  118. package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts.map +1 -1
  119. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs +2 -0
  120. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs.map +1 -0
  121. package/dist/verifyScriptPathSchnorrSignature-CgrnAjMW.js +724 -0
  122. package/dist/verifyScriptPathSchnorrSignature-CgrnAjMW.js.map +1 -0
  123. package/package.json +4 -4
  124. package/dist/PayoutManager-BJmPnyRP.js.map +0 -1
  125. package/dist/PayoutManager-aqtsj60t.cjs +0 -2
  126. package/dist/PayoutManager-aqtsj60t.cjs.map +0 -1
  127. package/dist/PeginManager-D22MLWfM.js +0 -1295
  128. package/dist/PeginManager-D22MLWfM.js.map +0 -1
  129. package/dist/PeginManager-vUUfZCzj.cjs +0 -2
  130. package/dist/PeginManager-vUUfZCzj.cjs.map +0 -1
  131. package/dist/buildAndBroadcastRefund-BiSO4zg2.js.map +0 -1
  132. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs +0 -2
  133. package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs.map +0 -1
  134. package/dist/challengeAssert-DLQfNcfU.cjs +0 -2
  135. package/dist/challengeAssert-DLQfNcfU.cjs.map +0 -1
  136. package/dist/challengeAssert-DvdbpEDY.js +0 -128
  137. package/dist/challengeAssert-DvdbpEDY.js.map +0 -1
  138. package/dist/constants-CvbARMl-.cjs +0 -2
  139. package/dist/errors-9AkghWyk.js +0 -22
  140. package/dist/errors-9AkghWyk.js.map +0 -1
  141. package/dist/errors-Bu0H-dZD.cjs +0 -2
  142. package/dist/errors-Bu0H-dZD.cjs.map +0 -1
  143. package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts +0 -34
  144. package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts.map +0 -1
  145. package/dist/tbv/integrations/aave/utils/__tests__/borrowRatio.test.d.ts +0 -5
  146. package/dist/tbv/integrations/aave/utils/__tests__/borrowRatio.test.d.ts.map +0 -1
  147. package/dist/tbv/integrations/aave/utils/__tests__/seizureSimulation.test.d.ts +0 -5
  148. package/dist/tbv/integrations/aave/utils/__tests__/seizureSimulation.test.d.ts.map +0 -1
  149. package/dist/tbv/integrations/aave/utils/__tests__/vaultSelection.test.d.ts +0 -2
  150. package/dist/tbv/integrations/aave/utils/__tests__/vaultSelection.test.d.ts.map +0 -1
  151. package/dist/tbv/integrations/aave/utils/borrowRatio.d.ts +0 -15
  152. package/dist/tbv/integrations/aave/utils/borrowRatio.d.ts.map +0 -1
  153. package/dist/tbv/integrations/aave/utils/seizureSimulation.d.ts +0 -109
  154. package/dist/tbv/integrations/aave/utils/seizureSimulation.d.ts.map +0 -1
  155. package/dist/tbv/integrations/aave/utils/vaultSelection.d.ts +0 -33
  156. package/dist/tbv/integrations/aave/utils/vaultSelection.d.ts.map +0 -1
  157. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs +0 -2
  158. package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs.map +0 -1
  159. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js +0 -658
  160. package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js.map +0 -1
@@ -1,58 +1,58 @@
1
1
  var J = Object.defineProperty;
2
2
  var Z = (e, t, r) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var $ = (e, t, r) => Z(e, typeof t != "symbol" ? t + "" : t, r);
3
+ var A = (e, t, r) => Z(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { B as ee } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
5
- import { e as te, v as re, s as p, u as X, p as A, f as E } from "./bitcoin-B5aNKtsk.js";
6
- import { v as ne, s as oe, P as ae, f as se } from "./PayoutManager-BJmPnyRP.js";
7
- import { D as w, c as ie, a as ue, R as le, d as z } from "./types-CQDRQvV-.js";
8
- import { Transaction as S, Psbt as ce } from "bitcoinjs-lib";
9
- import { c as he, d as I, e as N, f as H } from "./verifyScriptPathSchnorrSignature-DA4Z4yZ3.js";
10
- import { c as de, a as pe, b as ge } from "./noPayout-CfBg3HzC.js";
5
+ import { e as te, v as re, s as d, u as X, p as R, f as E } from "./bitcoin-B5aNKtsk.js";
6
+ import { v as oe, b as ne, s as se, P as ae, d as ie } from "./PayoutManager-BVgmuKuK.js";
7
+ import { D as x, c as ue, a as le, R as ce, d as z } from "./types-CQDRQvV-.js";
8
+ import { Transaction as S, Psbt as he } from "bitcoinjs-lib";
9
+ import { c as pe, d as I, e as N, f as H } from "./verifyScriptPathSchnorrSignature-CgrnAjMW.js";
10
+ import { c as de, a as ge, b as fe } from "./noPayout-CihCk1HE.js";
11
11
  import { c as O } from "./signing-DaLvGwQe.js";
12
- import { a as fe } from "./constants-BhclpREj.js";
13
- const me = /^0x[0-9a-fA-F]{64}$/, Pe = /^0x[0-9a-fA-F]{40}$/, be = /^0x([0-9a-fA-F]{2})*$/;
14
- function V(e, t) {
12
+ import { a as me } from "./constants-CDQE812z.js";
13
+ const be = /^0x[0-9a-fA-F]{64}$/, Pe = /^0x[0-9a-fA-F]{40}$/, ye = /^0x([0-9a-fA-F]{2})*$/;
14
+ function $(e, t) {
15
15
  if (e.length !== 66)
16
16
  throw new Error(
17
17
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
18
18
  );
19
- if (!me.test(e))
19
+ if (!be.test(e))
20
20
  throw new Error(
21
21
  `${t} must contain only hex characters after the 0x prefix`
22
22
  );
23
23
  }
24
- function ye(e, t) {
24
+ function we(e, t) {
25
25
  if (!Pe.test(e))
26
26
  throw new Error(
27
27
  `${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
28
28
  );
29
29
  }
30
- function we(e, t) {
31
- if (!be.test(e))
30
+ function ve(e, t) {
31
+ if (!ye.test(e))
32
32
  throw new Error(
33
33
  `${t} must be a 0x-prefixed hex string with an even number of hex chars`
34
34
  );
35
35
  }
36
- async function ut(e) {
36
+ async function lt(e) {
37
37
  const {
38
38
  btcVaultRegistryAddress: t,
39
39
  vaultId: r,
40
- hashlock: n,
41
- activationMetadata: s,
40
+ hashlock: o,
41
+ activationMetadata: i,
42
42
  writeContract: l,
43
- signal: a
43
+ signal: n
44
44
  } = e;
45
- a == null || a.throwIfAborted(), ye(t, "btcVaultRegistryAddress"), V(r, "vaultId");
46
- const i = te(e.secret);
47
- if (V(i, "secret"), n !== void 0 && (V(n, "hashlock"), !ne(i, n)))
45
+ n == null || n.throwIfAborted(), we(t, "btcVaultRegistryAddress"), $(r, "vaultId");
46
+ const s = te(e.secret);
47
+ if ($(s, "secret"), o !== void 0 && ($(o, "hashlock"), !oe(s, o)))
48
48
  throw new Error(
49
49
  "Invalid secret: SHA256(secret) does not match the provided hashlock"
50
50
  );
51
- return we(s, "activationMetadata"), l({
51
+ return ve(i, "activationMetadata"), l({
52
52
  address: t,
53
53
  abi: ee,
54
54
  functionName: "activateVaultWithSecret",
55
- args: [r, i, s]
55
+ args: [r, s, i]
56
56
  });
57
57
  }
58
58
  const xe = 1e4;
@@ -60,146 +60,146 @@ async function G(e) {
60
60
  const {
61
61
  statusReader: t,
62
62
  peginTxid: r,
63
- targetStatuses: n,
64
- timeoutMs: s,
63
+ targetStatuses: o,
64
+ timeoutMs: i,
65
65
  pollIntervalMs: l = xe,
66
- signal: a
67
- } = e, i = Date.now();
66
+ signal: n
67
+ } = e, s = Date.now();
68
68
  for (; ; ) {
69
- if (a != null && a.aborted)
69
+ if (n != null && n.aborted)
70
70
  throw new Error(
71
- `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
71
+ `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
72
72
  );
73
- if (Date.now() - i >= s)
73
+ if (Date.now() - s >= i)
74
74
  throw new Error(
75
- `Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
75
+ `Polling timeout after ${i}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
76
76
  );
77
77
  try {
78
- const o = await t.getPeginStatus(
78
+ const u = await t.getPeginStatus(
79
79
  { pegin_txid: r },
80
- a
80
+ n
81
81
  );
82
- if (o.pegin_txid.toLowerCase() !== r.toLowerCase())
82
+ if (u.pegin_txid.toLowerCase() !== r.toLowerCase())
83
83
  throw new Error(
84
- `getPeginStatus returned status for pegin ${o.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
84
+ `getPeginStatus returned status for pegin ${u.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
85
85
  );
86
- const u = o.status;
87
- if (n.has(u) || u === w.ACTIVATED)
88
- return u;
89
- if (u === w.EXPIRED || ie.has(u))
86
+ const a = u.status;
87
+ if (o.has(a) || a === x.ACTIVATED)
88
+ return a;
89
+ if (a === x.EXPIRED || ue.has(a))
90
90
  throw new Error(
91
- `Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...n].join(", ")}`
91
+ `Pegin ${r.slice(0, 8)}… reached terminal status "${a}" while waiting for ${[...o].join(", ")}`
92
92
  );
93
- } catch (o) {
94
- if (!(o instanceof ue && o.code === le.PEGIN_NOT_FOUND))
95
- throw o;
93
+ } catch (u) {
94
+ if (!(u instanceof le && u.code === ce.PEGIN_NOT_FOUND))
95
+ throw u;
96
96
  }
97
- await new Promise((o, u) => {
97
+ await new Promise((u, a) => {
98
98
  const h = () => {
99
- clearTimeout(c), u(
99
+ clearTimeout(c), a(
100
100
  new Error(
101
- `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
101
+ `Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
102
102
  )
103
103
  );
104
104
  }, c = setTimeout(() => {
105
- a == null || a.removeEventListener("abort", h), o();
105
+ n == null || n.removeEventListener("abort", h), u();
106
106
  }, l);
107
- a == null || a.addEventListener("abort", h, { once: !0 });
107
+ n == null || n.addEventListener("abort", h, { once: !0 });
108
108
  });
109
109
  }
110
110
  }
111
- const ve = 300 * 1e3, Ee = /* @__PURE__ */ new Set([
112
- w.PENDING_DEPOSITOR_WOTS_PK,
111
+ const Ee = 300 * 1e3, Te = /* @__PURE__ */ new Set([
112
+ x.PENDING_DEPOSITOR_WOTS_PK,
113
113
  ...z
114
114
  ]);
115
- async function lt(e) {
115
+ async function ct(e) {
116
116
  const {
117
117
  statusReader: t,
118
118
  wotsSubmitter: r,
119
- peginTxid: n,
120
- depositorPk: s,
119
+ peginTxid: o,
120
+ depositorPk: i,
121
121
  wotsPublicKeys: l,
122
- timeoutMs: a = ve,
123
- signal: i
122
+ timeoutMs: n = Ee,
123
+ signal: s
124
124
  } = e;
125
- i == null || i.throwIfAborted();
126
- const o = await G({
125
+ s == null || s.throwIfAborted();
126
+ const u = await G({
127
127
  statusReader: t,
128
- peginTxid: n,
129
- targetStatuses: Ee,
130
- timeoutMs: a,
131
- signal: i
128
+ peginTxid: o,
129
+ targetStatuses: Te,
130
+ timeoutMs: n,
131
+ signal: s
132
132
  });
133
- z.has(o) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
133
+ z.has(u) || (s == null || s.throwIfAborted(), await r.submitDepositorWotsKey(
134
134
  {
135
- pegin_txid: n,
136
- depositor_pk: s,
135
+ pegin_txid: o,
136
+ depositor_pk: i,
137
137
  wots_public_keys: l
138
138
  },
139
- i
139
+ s
140
140
  ));
141
141
  }
142
- const K = 1, Te = 1;
143
- function ke(e, t) {
144
- const r = p(t).toLowerCase(), s = e.map((l) => p(l).toLowerCase()).filter((l) => l !== r);
145
- if (s.length === 0)
142
+ const F = 1, ke = 1;
143
+ function _e(e, t) {
144
+ const r = d(t).toLowerCase(), i = e.map((l) => d(l).toLowerCase()).filter((l) => l !== r);
145
+ if (i.length === 0)
146
146
  throw new Error(
147
147
  "Cannot derive localChallengers: vault keeper set is empty (or contains only the depositor)"
148
148
  );
149
- if (new Set(s).size !== s.length)
149
+ if (new Set(i).size !== i.length)
150
150
  throw new Error(
151
151
  "Cannot derive localChallengers: duplicate vaultKeeper key — signing context is misconfigured"
152
152
  );
153
- return s;
153
+ return i;
154
154
  }
155
- function _e(e, t, r) {
156
- const n = r.map(
157
- (c) => p(c).toLowerCase()
158
- ), s = t.filter((c) => n.includes(c));
159
- if (s.length > 0)
155
+ function Ce(e, t, r) {
156
+ const o = r.map(
157
+ (c) => d(c).toLowerCase()
158
+ ), i = t.filter((c) => o.includes(c));
159
+ if (i.length > 0)
160
160
  throw new Error(
161
- `Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
161
+ `Cannot validate challenger set: vault keepers and universal challengers overlap (${i.join(", ")})`
162
162
  );
163
- const l = [...t, ...n], a = e.map(
164
- (c) => p(c.challenger_pubkey).toLowerCase()
165
- ), i = new Set(a);
166
- if (i.size !== a.length)
163
+ const l = [...t, ...o], n = e.map(
164
+ (c) => d(c.challenger_pubkey).toLowerCase()
165
+ ), s = new Set(n);
166
+ if (s.size !== n.length)
167
167
  throw new Error(
168
168
  "Depositor graph contains duplicate challenger entries in challenger_presign_data"
169
169
  );
170
- const o = new Set(l), u = l.filter((c) => !i.has(c)), h = a.filter((c) => !o.has(c));
171
- if (u.length > 0 || h.length > 0)
170
+ const u = new Set(l), a = l.filter((c) => !s.has(c)), h = n.filter((c) => !u.has(c));
171
+ if (a.length > 0 || h.length > 0)
172
172
  throw new Error(
173
- "Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
173
+ "Depositor graph challenger set does not match expected (local ∪ universal)" + (a.length > 0 ? ` (missing: ${a.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
174
174
  );
175
175
  }
176
- function Ce(e, t) {
176
+ function Se(e, t) {
177
177
  const r = e.ins[t];
178
178
  return X(new Uint8Array(r.hash).slice().reverse());
179
179
  }
180
- function R(e, t, r, n, s) {
180
+ function V(e, t, r, o, i) {
181
181
  const l = e.ins[t];
182
182
  if (l.index !== 0)
183
183
  throw new Error(
184
- `NoPayout (challenger ${s}) input ${t} expected to spend ${n} vout 0, got vout ${l.index}`
184
+ `NoPayout (challenger ${i}) input ${t} expected to spend ${o} vout 0, got vout ${l.index}`
185
185
  );
186
- const a = r.getId(), i = Ce(e, t);
187
- if (i !== a)
186
+ const n = r.getId(), s = Se(e, t);
187
+ if (s !== n)
188
188
  throw new Error(
189
- `NoPayout (challenger ${s}) input ${t} does not reference ${n} (expected txid ${a}, got ${i})`
189
+ `NoPayout (challenger ${i}) input ${t} does not reference ${o} (expected txid ${n}, got ${s})`
190
190
  );
191
191
  }
192
- async function Se(e, t, r) {
193
- const n = [], s = [], l = [], a = ke(
192
+ async function Re(e, t, r) {
193
+ const o = [], i = [], l = [], n = _e(
194
194
  r.vaultKeeperBtcPubkeys,
195
195
  r.depositorBtcPubkey
196
196
  );
197
- _e(
197
+ Ce(
198
198
  e.challenger_presign_data,
199
- a,
199
+ n,
200
200
  r.universalChallengerBtcPubkeys
201
201
  );
202
- const i = await he({
202
+ const s = await pe({
203
203
  vaultCoreVersion: r.vaultCoreVersion,
204
204
  payoutTxHex: e.payout_tx.tx_hex,
205
205
  peginTxHex: r.peginTxHex,
@@ -212,208 +212,208 @@ async function Se(e, t, r) {
212
212
  network: r.network,
213
213
  claimerBtcPubkey: r.depositorBtcPubkey,
214
214
  registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
215
- commissionBps: Te
215
+ commissionBps: ke,
216
+ protocolFeeRate: r.protocolFeeRate,
217
+ councilSize: r.councilMembers.length
216
218
  });
217
- n.push(i.psbtHex), s.push(
219
+ o.push(s.psbtHex), i.push(
218
220
  O(
219
221
  t,
220
- K
222
+ F
221
223
  )
222
224
  );
223
- const o = p(r.depositorBtcPubkey), u = S.fromHex(
224
- p(e.assert_tx.tx_hex)
225
+ const u = d(r.depositorBtcPubkey), a = S.fromHex(
226
+ d(e.assert_tx.tx_hex)
225
227
  );
226
228
  for (const h of e.challenger_presign_data) {
227
- const c = p(h.challenger_pubkey), d = n.length, P = await Ae({
229
+ const c = d(h.challenger_pubkey), p = o.length, b = await Ae({
228
230
  challenger: h,
229
231
  challengerPubkey: c,
230
- claimerPubkey: o,
231
- localChallengers: a,
232
- assertTxParsed: u,
232
+ claimerPubkey: u,
233
+ localChallengers: n,
234
+ assertTxParsed: a,
233
235
  ctx: r
234
236
  });
235
- n.push(P), s.push(
237
+ o.push(b), i.push(
236
238
  O(
237
239
  t,
238
- K
240
+ F
239
241
  )
240
242
  ), l.push({
241
243
  challengerPubkey: c,
242
- noPayoutIdx: d
244
+ noPayoutIdx: p
243
245
  });
244
246
  }
245
- return { psbtHexes: n, signOptions: s, challengerEntries: l };
247
+ return { psbtHexes: o, signOptions: i, challengerEntries: l };
246
248
  }
247
249
  async function Ae(e) {
248
250
  const {
249
251
  challenger: t,
250
252
  challengerPubkey: r,
251
- claimerPubkey: n,
252
- localChallengers: s,
253
+ claimerPubkey: o,
254
+ localChallengers: i,
253
255
  assertTxParsed: l,
254
- ctx: a
256
+ ctx: n
255
257
  } = e;
256
258
  de(
257
259
  t.nopayout_tx.tx_hex,
258
260
  r,
259
- a.network
261
+ n.network
260
262
  );
261
- const i = S.fromHex(
262
- p(t.nopayout_tx.tx_hex)
263
- ), o = S.fromHex(
264
- p(t.challenge_assert_x_tx.tx_hex)
263
+ const s = S.fromHex(
264
+ d(t.nopayout_tx.tx_hex)
265
265
  ), u = S.fromHex(
266
- p(t.challenge_assert_y_tx.tx_hex)
266
+ d(t.challenge_assert_x_tx.tx_hex)
267
+ ), a = S.fromHex(
268
+ d(t.challenge_assert_y_tx.tx_hex)
267
269
  );
268
- if (i.ins.length !== 3)
270
+ if (s.ins.length !== 3)
269
271
  throw new Error(
270
- `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
272
+ `NoPayout (challenger ${r}) must have exactly 3 inputs, got ${s.ins.length}`
271
273
  );
272
- R(
273
- i,
274
+ V(
275
+ s,
274
276
  0,
275
277
  l,
276
278
  "Assert",
277
279
  r
278
- ), R(
279
- i,
280
+ ), V(
281
+ s,
280
282
  1,
281
- o,
283
+ u,
282
284
  "ChallengeAssertX",
283
285
  r
284
- ), R(
285
- i,
286
+ ), V(
287
+ s,
286
288
  2,
287
- u,
289
+ a,
288
290
  "ChallengeAssertY",
289
291
  r
290
292
  );
291
293
  const h = [
292
294
  l.outs[0],
293
- o.outs[0],
294
- u.outs[0]
295
+ u.outs[0],
296
+ a.outs[0]
295
297
  ].map((c) => ({
296
298
  script_pubkey: X(new Uint8Array(c.script)),
297
299
  value: c.value
298
300
  }));
299
- return pe({
301
+ return ge({
300
302
  noPayoutTxHex: t.nopayout_tx.tx_hex,
301
303
  challengerPubkey: r,
302
304
  prevouts: h,
303
305
  connectorParams: {
304
- txGraphVersion: a.vaultCoreVersion,
305
- claimer: n,
306
- localChallengers: s,
307
- universalChallengers: a.universalChallengerBtcPubkeys,
308
- timelockAssert: a.timelockAssert,
309
- councilMembers: a.councilMembers,
310
- councilQuorum: a.councilQuorum
306
+ txGraphVersion: n.vaultCoreVersion,
307
+ claimer: o,
308
+ localChallengers: i,
309
+ universalChallengers: n.universalChallengerBtcPubkeys,
310
+ timelockAssert: n.timelockAssert,
311
+ councilMembers: n.councilMembers,
312
+ councilQuorum: n.councilQuorum
311
313
  }
312
314
  });
313
315
  }
314
316
  function $e(e, t, r) {
315
317
  I(e[0]);
316
- const s = N(
318
+ const i = N(
317
319
  e[0].returnedPsbtHex,
318
320
  r
319
321
  );
320
322
  H({
321
323
  requestedPsbtHex: e[0].requestedPsbtHex,
322
- signatureHex: s,
324
+ signatureHex: i,
323
325
  signerXOnlyPubkeyHex: r,
324
326
  inputIndex: 0
325
327
  });
326
328
  const l = {};
327
- for (const a of t) {
328
- I(e[a.noPayoutIdx]);
329
- const i = N(
330
- e[a.noPayoutIdx].returnedPsbtHex,
329
+ for (const n of t) {
330
+ I(e[n.noPayoutIdx]);
331
+ const s = N(
332
+ e[n.noPayoutIdx].returnedPsbtHex,
331
333
  r
332
334
  );
333
335
  H({
334
- requestedPsbtHex: e[a.noPayoutIdx].requestedPsbtHex,
335
- signatureHex: i,
336
+ requestedPsbtHex: e[n.noPayoutIdx].requestedPsbtHex,
337
+ signatureHex: s,
336
338
  signerXOnlyPubkeyHex: r,
337
339
  inputIndex: 0
338
- }), l[a.challengerPubkey] = {
339
- nopayout_signature: i
340
+ }), l[n.challengerPubkey] = {
341
+ nopayout_signature: s
340
342
  };
341
343
  }
342
344
  return {
343
345
  payout_signatures: {
344
- payout_signature: s
346
+ payout_signature: i
345
347
  },
346
348
  per_challenger: l
347
349
  };
348
350
  }
349
351
  async function Ve(e) {
350
- const { depositorGraph: t, btcWallet: r, signingContext: n } = e, s = await r.getPublicKeyHex(), { depositorPubkey: l } = re(
351
- s,
352
- p(n.depositorBtcPubkey)
353
- ), { psbtHexes: a, signOptions: i, challengerEntries: o } = await Se(
352
+ const { depositorGraph: t, btcWallet: r, signingContext: o } = e, i = await r.getPublicKeyHex(), { depositorPubkey: l } = re(
353
+ i,
354
+ d(o.depositorBtcPubkey)
355
+ ), { psbtHexes: n, signOptions: s, challengerEntries: u } = await Re(
354
356
  t,
355
- s,
356
- n
357
- ), u = await oe(
357
+ i,
358
+ o
359
+ ), a = await ne(
358
360
  r,
359
- a,
360
- i
361
- ), h = a.map((c, d) => ({
361
+ n,
362
+ s
363
+ ), h = n.map((c, p) => ({
362
364
  requestedPsbtHex: c,
363
- returnedPsbtHex: u[d]
365
+ returnedPsbtHex: a[p]
364
366
  }));
365
367
  return $e(
366
368
  h,
367
- o,
369
+ u,
368
370
  l
369
371
  );
370
372
  }
371
- const Re = 1200 * 1e3, q = /* @__PURE__ */ new Set([
372
- w.PENDING_ACKS,
373
- w.PENDING_ACTIVATION,
374
- w.ACTIVATED_PENDING_BROADCAST,
375
- w.ACTIVATED
376
- ]), Be = /* @__PURE__ */ new Set([
377
- w.PENDING_DEPOSITOR_SIGNATURES,
373
+ const Be = 1200 * 1e3, q = /* @__PURE__ */ new Set([
374
+ x.PENDING_ACKS,
375
+ x.PENDING_ACTIVATION,
376
+ x.ACTIVATED_PENDING_BROADCAST,
377
+ x.ACTIVATED
378
+ ]), Ie = /* @__PURE__ */ new Set([
379
+ x.PENDING_DEPOSITOR_SIGNATURES,
378
380
  ...q
379
381
  ]);
380
- function Ie(e) {
382
+ function Ne(e) {
381
383
  return e.map((t) => ({
382
- claimerPubkeyXOnly: A(t.claimer_pubkey),
384
+ claimerPubkeyXOnly: R(t.claimer_pubkey),
383
385
  payoutTxHex: t.payout_tx.tx_hex,
384
386
  assertTxHex: t.assert_tx.tx_hex
385
387
  }));
386
388
  }
387
389
  function _(e) {
388
- return A(e).toLowerCase();
390
+ return R(e).toLowerCase();
389
391
  }
390
- function Ne(e, t, r, n) {
391
- const s = _(n), l = [
392
+ function He(e, t, r, o) {
393
+ const i = _(o), l = [
392
394
  _(t),
393
395
  ...r.map(_)
394
- ], a = new Set(l);
395
- if (a.size !== l.length)
396
+ ], n = new Set(l);
397
+ if (n.size !== l.length)
396
398
  throw new Error(
397
399
  "Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
398
400
  );
399
- if (a.has(s))
401
+ if (n.has(i))
400
402
  throw new Error(
401
403
  "Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
402
404
  );
403
- const i = e.map(
404
- (d) => _(d.claimer_pubkey)
405
+ const s = e.map(
406
+ (p) => _(p.claimer_pubkey)
405
407
  );
406
- if (new Set(i).size !== i.length)
407
- throw new Error(
408
- "Presign response contains duplicate claimer entries"
409
- );
410
- const o = i.filter((d) => d !== s), u = new Set(o), h = l.filter((d) => !u.has(d)), c = o.filter((d) => !a.has(d));
408
+ if (new Set(s).size !== s.length)
409
+ throw new Error("Presign response contains duplicate claimer entries");
410
+ const u = s.filter((p) => p !== i), a = new Set(u), h = l.filter((p) => !a.has(p)), c = u.filter((p) => !n.has(p));
411
411
  if (h.length > 0 || c.length > 0)
412
412
  throw new Error(
413
413
  "Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (h.length > 0 ? ` (missing: ${h.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
414
414
  );
415
415
  }
416
- function U(e, t) {
416
+ function K(e, t) {
417
417
  return {
418
418
  vaultCoreVersion: t.vaultCoreVersion,
419
419
  payoutTxHex: e.payoutTxHex,
@@ -426,125 +426,139 @@ function U(e, t) {
426
426
  timelockPegin: t.timelockPegin,
427
427
  registeredPayoutScriptPubKey: t.registeredPayoutScriptPubKey,
428
428
  claimerBtcPubkey: e.claimerPubkeyXOnly,
429
- commissionBps: t.commissionBps
429
+ commissionBps: t.commissionBps,
430
+ protocolFeeRate: t.protocolFeeRate,
431
+ councilSize: t.councilMembers.length
430
432
  };
431
433
  }
432
- async function He(e, t, r, n) {
433
- const s = new ae({
434
+ async function Oe(e, t, r, o) {
435
+ const i = new ae({
434
436
  network: t.network,
435
437
  btcWallet: e
436
438
  }), l = r.length;
437
- n == null || n(0, l);
438
- let a;
439
- if (s.supportsBatchSigning())
440
- a = (await s.signPayoutTransactionsBatch(
441
- r.map((u) => U(u, t))
442
- )).map((u) => u.payoutSignature);
439
+ o == null || o(0, l);
440
+ let n;
441
+ if (i.supportsBatchSigning())
442
+ n = (await i.signPayoutTransactionsBatch(
443
+ r.map((a) => K(a, t))
444
+ )).map((a) => a.payoutSignature);
443
445
  else {
444
- a = [];
445
- for (let o = 0; o < r.length; o++) {
446
- n == null || n(o, l);
447
- const u = await s.signPayoutTransaction(
448
- U(r[o], t)
446
+ n = [];
447
+ for (let u = 0; u < r.length; u++) {
448
+ o == null || o(u, l);
449
+ const a = await i.signPayoutTransaction(
450
+ K(r[u], t)
449
451
  );
450
- a.push(u.signature);
452
+ n.push(a.signature);
451
453
  }
452
454
  }
453
- const i = {};
454
- for (let o = 0; o < r.length; o++)
455
- i[r[o].claimerPubkeyXOnly] = {
456
- payout_signature: a[o]
455
+ const s = {};
456
+ for (let u = 0; u < r.length; u++)
457
+ s[r[u].claimerPubkeyXOnly] = {
458
+ payout_signature: n[u]
457
459
  };
458
- return n == null || n(l, l), i;
460
+ return o == null || o(l, l), s;
459
461
  }
460
- async function ct(e) {
462
+ async function ht(e) {
461
463
  const {
462
464
  statusReader: t,
463
465
  presignClient: r,
464
- btcWallet: n,
465
- peginTxid: s,
466
+ btcWallet: o,
467
+ peginTxid: i,
466
468
  depositorPk: l,
467
- signingContext: a,
468
- timeoutMs: i = Re,
469
- signal: o,
470
- onProgress: u
471
- } = e, h = await G({
469
+ signingContext: n,
470
+ depositTerms: s,
471
+ timeoutMs: u = Be,
472
+ signal: a,
473
+ onProgress: h
474
+ } = e, c = await G({
472
475
  statusReader: t,
473
- peginTxid: s,
474
- targetStatuses: Be,
475
- timeoutMs: i,
476
- signal: o
476
+ peginTxid: i,
477
+ targetStatuses: Ie,
478
+ timeoutMs: u,
479
+ signal: a
477
480
  });
478
- if (q.has(h))
481
+ if (q.has(c))
479
482
  return;
480
- o == null || o.throwIfAborted();
481
- const c = await r.requestDepositorPresignTransactions(
483
+ if (a == null || a.throwIfAborted(), s !== void 0 && s.baseFeeRate !== n.protocolFeeRate)
484
+ throw new Error(
485
+ `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.`
486
+ );
487
+ if (se(o)) {
488
+ if (!s)
489
+ throw new Error(
490
+ "runDepositorPresignFlow: this wallet requires approved deposit terms but none were provided. Fresh deposits must pass PreparePeginResult.depositTerms; resume-path rebuild is not wired yet."
491
+ );
492
+ await o.approveDepositTerms(s);
493
+ }
494
+ const p = await r.requestDepositorPresignTransactions(
482
495
  {
483
- pegin_txid: s,
496
+ pegin_txid: i,
484
497
  depositor_pk: l
485
498
  },
486
- o
499
+ a
487
500
  );
488
- o == null || o.throwIfAborted();
489
- const d = _(l);
490
- Ne(
491
- c.txs,
492
- a.vaultProviderBtcPubkey,
493
- a.vaultKeeperBtcPubkeys,
501
+ a == null || a.throwIfAborted();
502
+ const b = _(l);
503
+ He(
504
+ p.txs,
505
+ n.vaultProviderBtcPubkey,
506
+ n.vaultKeeperBtcPubkeys,
494
507
  l
495
508
  );
496
- const P = c.txs.filter(
497
- (v) => _(v.claimer_pubkey) !== d
498
- ), m = Ie(P), y = await He(
509
+ const m = p.txs.filter(
510
+ (v) => _(v.claimer_pubkey) !== b
511
+ ), y = Ne(m), T = await Oe(
512
+ o,
499
513
  n,
500
- a,
501
- m,
502
- u
514
+ y,
515
+ h
503
516
  );
504
- o == null || o.throwIfAborted();
505
- const x = await Ve({
506
- depositorGraph: c.depositor_graph,
507
- btcWallet: n,
517
+ a == null || a.throwIfAborted();
518
+ const P = await Ve({
519
+ depositorGraph: p.depositor_graph,
520
+ btcWallet: o,
508
521
  signingContext: {
509
- vaultCoreVersion: a.vaultCoreVersion,
510
- peginTxHex: a.peginTxHex,
522
+ vaultCoreVersion: n.vaultCoreVersion,
523
+ peginTxHex: n.peginTxHex,
511
524
  depositorBtcPubkey: l,
512
- vaultProviderBtcPubkey: a.vaultProviderBtcPubkey,
513
- vaultKeeperBtcPubkeys: a.vaultKeeperBtcPubkeys,
514
- universalChallengerBtcPubkeys: a.universalChallengerBtcPubkeys,
515
- timelockPegin: a.timelockPegin,
516
- timelockAssert: a.timelockAssert,
517
- councilMembers: a.councilMembers,
518
- councilQuorum: a.councilQuorum,
519
- network: a.network,
520
- registeredPayoutScriptPubKey: a.registeredPayoutScriptPubKey
525
+ vaultProviderBtcPubkey: n.vaultProviderBtcPubkey,
526
+ vaultKeeperBtcPubkeys: n.vaultKeeperBtcPubkeys,
527
+ universalChallengerBtcPubkeys: n.universalChallengerBtcPubkeys,
528
+ timelockPegin: n.timelockPegin,
529
+ timelockAssert: n.timelockAssert,
530
+ councilMembers: n.councilMembers,
531
+ councilQuorum: n.councilQuorum,
532
+ network: n.network,
533
+ registeredPayoutScriptPubKey: n.registeredPayoutScriptPubKey,
534
+ protocolFeeRate: n.protocolFeeRate
521
535
  }
522
536
  });
523
- o == null || o.throwIfAborted();
524
- const b = { ...y };
525
- b[p(l)] = x.payout_signatures, await r.submitDepositorPresignatures(
537
+ a == null || a.throwIfAborted();
538
+ const w = { ...T };
539
+ w[d(l)] = P.payout_signatures, await r.submitDepositorPresignatures(
526
540
  {
527
- pegin_txid: s,
541
+ pegin_txid: i,
528
542
  depositor_pk: l,
529
- signatures: b,
530
- depositor_claimer_presignatures: x
543
+ signatures: w,
544
+ depositor_claimer_presignatures: P
531
545
  },
532
- o
546
+ a
533
547
  );
534
548
  }
535
- function Oe(e) {
549
+ function De(e) {
536
550
  return /^[0-9a-fA-F]{64}$/.test(e);
537
551
  }
538
- function ht(e) {
552
+ function pt(e) {
539
553
  const {
540
554
  amountSats: t,
541
555
  minDeposit: r,
542
- maxDeposit: n,
543
- btcBalance: s,
556
+ maxDeposit: o,
557
+ btcBalance: i,
544
558
  estimatedFeeSats: l,
545
- depositorClaimValue: a
559
+ depositorClaimValue: n
546
560
  } = e;
547
- return !(t <= 0n || t < r || n && n > 0n && t > n || l == null || a == null || t + l + a > s);
561
+ return !(t <= 0n || t < r || o && o > 0n && t > o || l == null || n == null || t + l + n > i);
548
562
  }
549
563
  function dt(e, t, r) {
550
564
  return e <= 0n ? {
@@ -558,7 +572,7 @@ function dt(e, t, r) {
558
572
  error: `Maximum deposit is ${E(r)} BTC`
559
573
  } : { valid: !0 };
560
574
  }
561
- function pt(e) {
575
+ function gt(e) {
562
576
  const { amount: t, effectiveRemaining: r } = e;
563
577
  return r === null ? { valid: !0 } : r === 0n ? {
564
578
  valid: !1,
@@ -568,51 +582,51 @@ function pt(e) {
568
582
  error: `Vault size exceeds remaining capacity (${E(r)} BTC)`
569
583
  } : { valid: !0 };
570
584
  }
571
- function gt(e, t) {
585
+ function ft(e, t) {
572
586
  if (!e || e.length === 0)
573
587
  return {
574
588
  valid: !1,
575
589
  error: "At least one vault provider must be selected"
576
590
  };
577
591
  const r = t.map(
578
- (s) => s.toLowerCase()
592
+ (i) => i.toLowerCase()
579
593
  );
580
594
  return e.filter(
581
- (s) => !r.includes(s.toLowerCase())
595
+ (i) => !r.includes(i.toLowerCase())
582
596
  ).length > 0 ? {
583
597
  valid: !1,
584
598
  error: "Invalid vault provider selected"
585
599
  } : { valid: !0 };
586
600
  }
587
- function De(e, t, r) {
601
+ function Fe(e, t, r) {
588
602
  if (!e || e.length === 0)
589
603
  return {
590
604
  valid: !1,
591
605
  error: "At least one vault amount required"
592
606
  };
593
- for (let n = 0; n < e.length; n++) {
594
- const s = e[n];
595
- if (s <= 0n)
607
+ for (let o = 0; o < e.length; o++) {
608
+ const i = e[o];
609
+ if (i <= 0n)
596
610
  return {
597
611
  valid: !1,
598
- error: `Vault ${n + 1} amount must be positive`
612
+ error: `Vault ${o + 1} amount must be positive`
599
613
  };
600
- if (t && s < t)
614
+ if (t && i < t)
601
615
  return {
602
616
  valid: !1,
603
- error: `Vault ${n + 1} amount ${E(s)} BTC is below minimum deposit ${E(t)} BTC`
617
+ error: `Vault ${o + 1} amount ${E(i)} BTC is below minimum deposit ${E(t)} BTC`
604
618
  };
605
- if (r && s > r)
619
+ if (r && i > r)
606
620
  return {
607
621
  valid: !1,
608
- error: `Vault ${n + 1} amount ${E(s)} BTC exceeds maximum deposit ${E(r)} BTC`
622
+ error: `Vault ${o + 1} amount ${E(i)} BTC exceeds maximum deposit ${E(r)} BTC`
609
623
  };
610
624
  }
611
625
  return { valid: !0 };
612
626
  }
613
627
  function Ke(e) {
614
- const t = p(e);
615
- return Oe(t) ? { valid: !0 } : {
628
+ const t = d(e);
629
+ return De(t) ? { valid: !0 } : {
616
630
  valid: !1,
617
631
  error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
618
632
  };
@@ -623,85 +637,85 @@ function Ue(e) {
623
637
  "No vault keepers available. The system requires at least one vault keeper to create a deposit."
624
638
  );
625
639
  }
626
- function Fe(e) {
640
+ function Me(e) {
627
641
  if (!e || e.length === 0)
628
642
  throw new Error(
629
643
  "No universal challengers available. The system requires at least one universal challenger to create a deposit."
630
644
  );
631
645
  }
632
- function Me(e) {
646
+ function Le(e) {
633
647
  if (e.length === 0)
634
648
  throw new Error("No spendable UTXOs available");
635
649
  }
636
- function ft(e) {
650
+ function mt(e) {
637
651
  const {
638
652
  vaultAmounts: t,
639
653
  confirmedUTXOs: r,
640
- vaultProviderBtcPubkey: n,
641
- vaultKeeperBtcPubkeys: s,
654
+ vaultProviderBtcPubkey: o,
655
+ vaultKeeperBtcPubkeys: i,
642
656
  universalChallengerBtcPubkeys: l,
643
- minDeposit: a,
644
- maxDeposit: i
645
- } = e, o = De(
657
+ minDeposit: n,
658
+ maxDeposit: s
659
+ } = e, u = Fe(
646
660
  t,
647
- a,
648
- i
661
+ n,
662
+ s
649
663
  );
650
- if (!o.valid)
651
- throw new Error(o.error);
652
- const u = Ke(n);
653
664
  if (!u.valid)
654
665
  throw new Error(u.error);
655
- Ue(s), Fe(l), Me(r);
666
+ const a = Ke(o);
667
+ if (!a.valid)
668
+ throw new Error(a.error);
669
+ Ue(i), Me(l), Le(r);
656
670
  }
657
- async function mt(e) {
671
+ async function bt(e) {
658
672
  const {
659
673
  vaultRegistryReader: t,
660
674
  vaultKeeperReader: r,
661
- universalChallengerReader: n,
662
- vaultProviderEthAddress: s,
675
+ universalChallengerReader: o,
676
+ vaultProviderEthAddress: i,
663
677
  applicationEntryPoint: l,
664
- expectedVaultProviderBtcPubkey: a,
665
- expectedVaultKeeperBtcPubkeys: i,
666
- expectedUniversalChallengerBtcPubkeys: o
678
+ expectedVaultProviderBtcPubkey: n,
679
+ expectedVaultKeeperBtcPubkeys: s,
680
+ expectedUniversalChallengerBtcPubkeys: u
667
681
  } = e, [
668
- u,
682
+ a,
669
683
  h,
670
684
  c
671
685
  ] = await Promise.all([
672
- t.getVaultProviderBtcPubKey(s),
686
+ t.getVaultProviderBtcPubKey(i),
673
687
  r.getCurrentVaultKeepersVersion(l),
674
- n.getLatestUniversalChallengersVersion()
675
- ]), [d, P] = await Promise.all([
688
+ o.getLatestUniversalChallengersVersion()
689
+ ]), [p, b] = await Promise.all([
676
690
  r.getVaultKeepersByVersion(
677
691
  l,
678
692
  h
679
693
  ),
680
- n.getUniversalChallengersByVersion(
694
+ o.getUniversalChallengersByVersion(
681
695
  c
682
696
  )
683
- ]), m = (g) => A(g).toLowerCase(), y = (g) => g.map(m).sort();
684
- if (m(a) !== u)
697
+ ]), m = (g) => R(g).toLowerCase(), y = (g) => g.map(m).sort();
698
+ if (m(n) !== a)
685
699
  throw new Error(
686
- `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
700
+ `Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${i}. Refresh and try again.`
687
701
  );
688
- const b = y(i), v = y(
689
- d.map((g) => g.btcPubKey)
702
+ const P = y(s), w = y(
703
+ p.map((g) => g.btcPubKey)
690
704
  );
691
- if (b.length !== v.length || b.some((g, C) => g !== v[C]))
705
+ if (P.length !== w.length || P.some((g, C) => g !== w[C]))
692
706
  throw new Error(
693
707
  `Vault keeper BTC pubkeys (v${h}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
694
708
  );
695
- const T = y(o), k = y(
696
- P.map((g) => g.btcPubKey)
709
+ const v = y(u), k = y(
710
+ b.map((g) => g.btcPubKey)
697
711
  );
698
- if (T.length !== k.length || T.some((g, C) => g !== k[C]))
712
+ if (v.length !== k.length || v.some((g, C) => g !== k[C]))
699
713
  throw new Error(
700
714
  `Universal challenger BTC pubkeys (v${c}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
701
715
  );
702
716
  return {
703
- vaultProviderBtcPubkeyXOnly: u,
704
- vaultKeeperBtcPubkeysSorted: v,
717
+ vaultProviderBtcPubkeyXOnly: a,
718
+ vaultKeeperBtcPubkeysSorted: w,
705
719
  universalChallengerBtcPubkeysSorted: k,
706
720
  expectedAppVaultKeepersVersion: h,
707
721
  expectedUniversalChallengersVersion: c
@@ -715,54 +729,54 @@ class j extends Error {
715
729
  function Pt(e) {
716
730
  return e instanceof j || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
717
731
  }
718
- async function bt(e) {
732
+ async function yt(e) {
719
733
  const {
720
734
  vaultRegistryReader: t,
721
735
  vaultIds: r,
722
- expectedOffchainParamsVersion: n,
723
- expectedAppVaultKeepersVersion: s,
736
+ expectedOffchainParamsVersion: o,
737
+ expectedAppVaultKeepersVersion: i,
724
738
  expectedUniversalChallengersVersion: l,
725
- expectedVaultCoreVersion: a
726
- } = e, i = await t.getProtocolInfoBatch(r), o = [];
727
- if (i.forEach((u, h) => {
739
+ expectedVaultCoreVersion: n
740
+ } = e, s = await t.getProtocolInfoBatch(r), u = [];
741
+ if (s.forEach((a, h) => {
728
742
  const c = r[h];
729
- u.offchainParamsVersion !== n && o.push(
730
- `vault ${c}: offchainParams expected v${n}, got v${u.offchainParamsVersion}`
731
- ), u.appVaultKeepersVersion !== s && o.push(
732
- `vault ${c}: appVaultKeepers expected v${s}, got v${u.appVaultKeepersVersion}`
733
- ), u.universalChallengersVersion !== l && o.push(
734
- `vault ${c}: universalChallengers expected v${l}, got v${u.universalChallengersVersion}`
735
- ), u.vaultCoreVersion !== a && o.push(
736
- `vault ${c}: vaultCoreVersion expected v${a} (build-time active), got v${u.vaultCoreVersion}`
737
- );
738
- }), o.length > 0)
743
+ a.offchainParamsVersion !== o && u.push(
744
+ `vault ${c}: offchainParams expected v${o}, got v${a.offchainParamsVersion}`
745
+ ), a.appVaultKeepersVersion !== i && u.push(
746
+ `vault ${c}: appVaultKeepers expected v${i}, got v${a.appVaultKeepersVersion}`
747
+ ), a.universalChallengersVersion !== l && u.push(
748
+ `vault ${c}: universalChallengers expected v${l}, got v${a.universalChallengersVersion}`
749
+ ), a.vaultCoreVersion !== n && u.push(
750
+ `vault ${c}: vaultCoreVersion expected v${n} (build-time active), got v${a.vaultCoreVersion}`
751
+ );
752
+ }), u.length > 0)
739
753
  throw new j(
740
- `Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${o.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
754
+ `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.`
741
755
  );
742
756
  }
743
757
  var Q = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(Q || {});
744
- const Le = /* @__PURE__ */ new Set([
758
+ const Xe = /* @__PURE__ */ new Set([
745
759
  "PayoutBroadcast",
746
760
  "PayoutBlocked"
747
761
  /* PAYOUT_BLOCKED */
748
762
  ]);
749
- function yt(e) {
763
+ function wt(e) {
750
764
  return Object.values(Q).includes(
751
765
  e
752
766
  );
753
767
  }
754
- function wt(e) {
755
- return !!e && Le.has(e);
756
- }
757
- class Xe extends Error {
758
- constructor(r, n) {
759
- super(`Refund not yet mature (BIP68 not final): ${n.message}`);
760
- $(this, "vaultId");
761
- $(this, "cause");
762
- this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
768
+ function vt(e) {
769
+ return !!e && Xe.has(e);
770
+ }
771
+ class ze extends Error {
772
+ constructor(r, o) {
773
+ super(`Refund not yet mature (BIP68 not final): ${o.message}`);
774
+ A(this, "vaultId");
775
+ A(this, "cause");
776
+ this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
763
777
  }
764
778
  }
765
- const ze = /^0x[0-9a-fA-F]{64}$/, Ge = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Y = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, W = 160, F = 2e3, M = 10n, L = 100n;
779
+ const Ge = /^0x[0-9a-fA-F]{64}$/, qe = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Y = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, W = 160, U = 2e3, M = 10n, L = 100n;
766
780
  function xt(e) {
767
781
  if (!Number.isFinite(e) || e <= 0)
768
782
  throw new Error(
@@ -770,13 +784,13 @@ function xt(e) {
770
784
  );
771
785
  return BigInt(Math.ceil(e * W));
772
786
  }
773
- const qe = 1, je = /non-BIP68-final/i;
787
+ const je = 1, Qe = /non-BIP68-final/i;
774
788
  function D(e, t) {
775
789
  if (e.length !== 66)
776
790
  throw new Error(
777
791
  `${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
778
792
  );
779
- if (!ze.test(e))
793
+ if (!Ge.test(e))
780
794
  throw new Error(
781
795
  `${t} must contain only hex characters after the 0x prefix`
782
796
  );
@@ -785,7 +799,7 @@ function B(e, t) {
785
799
  if (!Number.isInteger(e) || e < 0)
786
800
  throw new Error(`${t} must be a non-negative integer, got ${e}`);
787
801
  }
788
- function Qe(e) {
802
+ function Ye(e) {
789
803
  if (D(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
790
804
  throw new Error(
791
805
  `htlcVout must be a non-negative integer, got ${e.htlcVout}`
@@ -797,14 +811,14 @@ function Qe(e) {
797
811
  `htlcVout ${e.htlcVout} is out of range for batch of size ${e.batch.length}`
798
812
  );
799
813
  for (let r = 0; r < e.batch.length; r++) {
800
- const n = e.batch[r];
801
- if (D(n.hashlock, `batch[${r}].hashlock`), !Number.isInteger(n.htlcVout) || n.htlcVout !== r)
814
+ const o = e.batch[r];
815
+ if (D(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
802
816
  throw new Error(
803
- `batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${n.htlcVout}`
817
+ `batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${o.htlcVout}`
804
818
  );
805
- if (typeof n.amount != "bigint" || n.amount <= 0n)
819
+ if (typeof o.amount != "bigint" || o.amount <= 0n)
806
820
  throw new Error(
807
- `batch[${r}].amount must be a positive bigint, got ${n.amount}`
821
+ `batch[${r}].amount must be a positive bigint, got ${o.amount}`
808
822
  );
809
823
  }
810
824
  const t = e.batch[e.htlcVout];
@@ -819,12 +833,12 @@ function Qe(e) {
819
833
  if (B(e.offchainParamsVersion, "offchainParamsVersion"), B(e.appVaultKeepersVersion, "appVaultKeepersVersion"), B(
820
834
  e.universalChallengersVersion,
821
835
  "universalChallengersVersion"
822
- ), fe(
836
+ ), me(
823
837
  e.vaultCoreVersion,
824
838
  "VaultRefundData.vaultCoreVersion"
825
839
  ), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
826
840
  throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
827
- if (!Ge.test(e.unsignedPrePeginTxHex))
841
+ if (!qe.test(e.unsignedPrePeginTxHex))
828
842
  throw new Error(
829
843
  "unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
830
844
  );
@@ -835,7 +849,7 @@ function Qe(e) {
835
849
  if (typeof e.amount != "bigint" || e.amount <= 0n)
836
850
  throw new Error(`amount must be a positive bigint, got ${e.amount}`);
837
851
  }
838
- function Ye(e) {
852
+ function We(e) {
839
853
  if (!e.vaultProviderPubkey || !Y.test(e.vaultProviderPubkey))
840
854
  throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
841
855
  if (e.vaultKeeperPubkeys.length === 0)
@@ -861,150 +875,150 @@ function Ye(e) {
861
875
  `councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
862
876
  );
863
877
  }
864
- function We(e) {
865
- const t = ce.fromHex(e);
878
+ function Je(e) {
879
+ const t = he.fromHex(e);
866
880
  try {
867
881
  t.finalizeAllInputs();
868
882
  } catch (r) {
869
- const n = r instanceof Error ? r.message : String(r);
870
- if (!n.includes("already finalized"))
871
- throw new Error(`Failed to finalize refund PSBT: ${n}`);
883
+ const o = r instanceof Error ? r.message : String(r);
884
+ if (!o.includes("already finalized"))
885
+ throw new Error(`Failed to finalize refund PSBT: ${o}`);
872
886
  }
873
887
  return t.extractTransaction().toHex();
874
888
  }
875
- async function vt(e) {
889
+ async function Et(e) {
876
890
  const {
877
891
  vaultId: t,
878
892
  readVault: r,
879
- readPrePeginContext: n,
880
- feeRate: s,
893
+ readPrePeginContext: o,
894
+ feeRate: i,
881
895
  signPsbt: l,
882
- broadcastTx: a,
883
- signal: i
896
+ broadcastTx: n,
897
+ signal: s
884
898
  } = e;
885
- i == null || i.throwIfAborted(), D(t, "vaultId");
886
- const o = await r();
887
- Qe(o), i == null || i.throwIfAborted();
888
- const u = await n(o);
889
- if (Ye(u), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
890
- throw new Error(`feeRate must be a positive number, got ${s}`);
891
- if (s > F)
899
+ s == null || s.throwIfAborted(), D(t, "vaultId");
900
+ const u = await r();
901
+ Ye(u), s == null || s.throwIfAborted();
902
+ const a = await o(u);
903
+ if (We(a), s == null || s.throwIfAborted(), !Number.isFinite(i) || i <= 0)
904
+ throw new Error(`feeRate must be a positive number, got ${i}`);
905
+ if (i > U)
892
906
  throw new Error(
893
- `feeRate ${s} sat/vB exceeds refund safety cap ${F} sat/vB; refusing to sign refund.`
907
+ `feeRate ${i} sat/vB exceeds refund safety cap ${U} sat/vB; refusing to sign refund.`
894
908
  );
895
- const h = BigInt(Math.ceil(s * W)), c = o.amount * M / L;
909
+ const h = BigInt(Math.ceil(i * W)), c = u.amount * M / L;
896
910
  if (h > c)
897
911
  throw new Error(
898
- `Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${M}/${L} of vault.amount=${o.amount}); refusing to sign refund.`
912
+ `Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${M}/${L} of vault.amount=${u.amount}); refusing to sign refund.`
899
913
  );
900
- i == null || i.throwIfAborted();
901
- const d = A(
902
- o.depositorBtcPubkey
903
- ), P = p(o.unsignedPrePeginTxHex), m = se(P);
904
- if (m !== void 0 && m.vout !== o.batch.length)
914
+ s == null || s.throwIfAborted();
915
+ const p = R(
916
+ u.depositorBtcPubkey
917
+ ), b = d(u.unsignedPrePeginTxHex), m = ie(b);
918
+ if (m !== void 0 && m.vout !== u.batch.length)
905
919
  throw new Error(
906
- `Auth-anchor OP_RETURN at vout ${m.vout} does not match batch size (${o.batch.length} HTLC outputs expect the anchor at vout ${o.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
920
+ `Auth-anchor OP_RETURN at vout ${m.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.`
907
921
  );
908
922
  const y = m == null ? void 0 : m.hash;
909
- let x;
923
+ let T;
910
924
  try {
911
- x = S.fromHex(P);
925
+ T = S.fromHex(b);
912
926
  } catch (f) {
913
927
  throw new Error(
914
928
  `Failed to parse funded Pre-PegIn transaction hex: ${f instanceof Error ? f.message : String(f)}`
915
929
  );
916
930
  }
917
- if (x.outs.length < o.batch.length)
931
+ if (T.outs.length < u.batch.length)
918
932
  throw new Error(
919
- `Funded Pre-PegIn tx has ${x.outs.length} outputs but batch requires at least ${o.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
933
+ `Funded Pre-PegIn tx has ${T.outs.length} outputs but batch requires at least ${u.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
920
934
  );
921
- const { psbtHex: b } = await ge({
935
+ const { psbtHex: P } = await fe({
922
936
  prePeginParams: {
923
- vaultCoreVersion: o.vaultCoreVersion,
924
- depositorPubkey: d,
925
- vaultProviderPubkey: p(u.vaultProviderPubkey),
926
- vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(p),
927
- universalChallengerPubkeys: u.universalChallengerPubkeys.map(p),
928
- hashlocks: o.batch.map((f) => p(f.hashlock)),
929
- timelockRefund: u.timelockRefund,
937
+ vaultCoreVersion: u.vaultCoreVersion,
938
+ depositorPubkey: p,
939
+ vaultProviderPubkey: d(a.vaultProviderPubkey),
940
+ vaultKeeperPubkeys: a.vaultKeeperPubkeys.map(d),
941
+ universalChallengerPubkeys: a.universalChallengerPubkeys.map(d),
942
+ hashlocks: u.batch.map((f) => d(f.hashlock)),
943
+ timelockRefund: a.timelockRefund,
930
944
  // `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
931
945
  // is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
932
946
  // reserve (`depositorClaimValue + minPeginFee`) internally when sizing the
933
947
  // HTLC output. `buildRefundPsbt`'s value cross-check then binds the result
934
948
  // to the funded tx bytes, refusing the refund if the template's HTLC value
935
949
  // disagrees with the on-chain commitment.
936
- pegInAmounts: o.batch.map((f) => f.amount),
937
- feeRate: u.feeRate,
938
- minPeginFeeRate: u.minPeginFeeRate,
939
- numLocalChallengers: u.numLocalChallengers,
940
- councilQuorum: u.councilQuorum,
941
- councilSize: u.councilSize,
942
- network: u.network,
950
+ pegInAmounts: u.batch.map((f) => f.amount),
951
+ feeRate: a.feeRate,
952
+ minPeginFeeRate: a.minPeginFeeRate,
953
+ numLocalChallengers: a.numLocalChallengers,
954
+ councilQuorum: a.councilQuorum,
955
+ councilSize: a.councilSize,
956
+ network: a.network,
943
957
  authAnchorHash: y
944
958
  },
945
- fundedPrePeginTxHex: P,
946
- htlcVout: o.htlcVout,
959
+ fundedPrePeginTxHex: b,
960
+ htlcVout: u.htlcVout,
947
961
  refundFee: h,
948
962
  // buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
949
963
  // prefix" and flows into the WASM HTLC connector derivation; a prefixed
950
964
  // value would derive the wrong refund script leaf and yield an
951
965
  // unspendable PSBT. Match the `hashlocks` array handling above.
952
- hashlock: p(o.hashlock)
966
+ hashlock: d(u.hashlock)
953
967
  });
954
- i == null || i.throwIfAborted();
955
- const v = O(
956
- o.depositorBtcPubkey,
957
- qe
958
- ), T = await l(b, v);
968
+ s == null || s.throwIfAborted();
969
+ const w = O(
970
+ u.depositorBtcPubkey,
971
+ je
972
+ ), v = await l(P, w);
959
973
  I({
960
- requestedPsbtHex: b,
961
- returnedPsbtHex: T
974
+ requestedPsbtHex: P,
975
+ returnedPsbtHex: v
962
976
  });
963
977
  const k = 0, g = N(
964
- T,
965
- d,
978
+ v,
979
+ p,
966
980
  k
967
981
  );
968
982
  H({
969
- requestedPsbtHex: b,
983
+ requestedPsbtHex: P,
970
984
  signatureHex: g,
971
- signerXOnlyPubkeyHex: d,
985
+ signerXOnlyPubkeyHex: p,
972
986
  inputIndex: k
973
987
  });
974
- const C = We(T);
975
- i == null || i.throwIfAborted();
988
+ const C = Je(v);
989
+ s == null || s.throwIfAborted();
976
990
  try {
977
- return await a(C);
991
+ return await n(C);
978
992
  } catch (f) {
979
- throw f instanceof Error && je.test(f.message) ? new Xe(t, f) : f;
993
+ throw f instanceof Error && Qe.test(f.message) ? new ze(t, f) : f;
980
994
  }
981
995
  }
982
996
  export {
983
- Xe as B,
997
+ ze as B,
984
998
  Q as C,
985
999
  j as R,
986
- ut as a,
1000
+ lt as a,
987
1001
  Ve as b,
988
- pt as c,
989
- gt as d,
990
- De as e,
1002
+ gt as c,
1003
+ ft as d,
1004
+ Fe as e,
991
1005
  Ke as f,
992
- ft as g,
993
- mt as h,
994
- ht as i,
1006
+ mt as g,
1007
+ bt as h,
1008
+ pt as i,
995
1009
  Pt as j,
996
- bt as k,
997
- yt as l,
998
- wt as m,
999
- vt as n,
1010
+ yt as k,
1011
+ wt as l,
1012
+ vt as m,
1013
+ Et as n,
1000
1014
  xt as o,
1001
1015
  L as p,
1002
1016
  M as q,
1003
- ct as r,
1004
- lt as s,
1005
- F as t,
1017
+ ht as r,
1018
+ ct as s,
1019
+ U as t,
1006
1020
  W as u,
1007
1021
  dt as v,
1008
1022
  G as w
1009
1023
  };
1010
- //# sourceMappingURL=buildAndBroadcastRefund-BiSO4zg2.js.map
1024
+ //# sourceMappingURL=buildAndBroadcastRefund-BtXUqBkb.js.map