@babylonlabs-io/ts-sdk 0.69.1 → 0.70.1

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