@babylonlabs-io/ts-sdk 0.35.0 → 0.36.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.
- package/dist/buildAndBroadcastRefund-D4YqqClN.js +872 -0
- package/dist/buildAndBroadcastRefund-D4YqqClN.js.map +1 -0
- package/dist/buildAndBroadcastRefund-DSELaUiR.cjs +2 -0
- package/dist/buildAndBroadcastRefund-DSELaUiR.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +73 -69
- package/dist/tbv/core/clients/eth/types.d.ts +1 -0
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +1 -0
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/gatedMethods.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +66 -62
- package/dist/tbv/core/services/deposit/__tests__/validateOnChainParticipantKeys.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/validateOnChainParticipantKeys.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredVaultVersions.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredVaultVersions.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +8 -12
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +21 -0
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.d.ts +15 -0
- package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +23 -19
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +66 -62
- package/dist/tbv/integrations/aave/constants.d.ts +15 -2
- package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.d.ts +1 -1
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +94 -93
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/vault-registry-reader-CLnhAUN4.cjs +2 -0
- package/dist/vault-registry-reader-CLnhAUN4.cjs.map +1 -0
- package/dist/{vault-registry-reader-BBk0p-u-.js → vault-registry-reader-CrLodprY.js} +228 -197
- package/dist/vault-registry-reader-CrLodprY.js.map +1 -0
- package/package.json +1 -1
- package/dist/buildAndBroadcastRefund-BQ0CaL6Q.cjs +0 -2
- package/dist/buildAndBroadcastRefund-BQ0CaL6Q.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-DzX11N9S.js +0 -785
- package/dist/buildAndBroadcastRefund-DzX11N9S.js.map +0 -1
- package/dist/vault-registry-reader-BBk0p-u-.js.map +0 -1
- package/dist/vault-registry-reader-DQgnZilV.cjs +0 -2
- package/dist/vault-registry-reader-DQgnZilV.cjs.map +0 -1
|
@@ -0,0 +1,872 @@
|
|
|
1
|
+
var G = Object.defineProperty;
|
|
2
|
+
var W = (e, t, r) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var B = (e, t, r) => W(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { B as Q } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
|
|
5
|
+
import { e as Y, v as j, s as c, u as N, p as T, f as m } from "./bitcoin-B0S8SHCX.js";
|
|
6
|
+
import { v as q, P as J } from "./PayoutManager-s_uH8Uuj.js";
|
|
7
|
+
import { c as Z, a as ee, R as te, d as H, D as x } from "./types-TiIjyo2b.js";
|
|
8
|
+
import * as re from "bitcoinjs-lib";
|
|
9
|
+
import { Transaction as k, Psbt as ne } from "bitcoinjs-lib";
|
|
10
|
+
import { Buffer as oe } from "buffer";
|
|
11
|
+
import { c as ae, a as se, b as ie } from "./noPayout-DBX6G96_.js";
|
|
12
|
+
import { a as ue, b as le, e as $ } from "./payout-BNFMBXS6.js";
|
|
13
|
+
import { c as R } from "./signing-DaLvGwQe.js";
|
|
14
|
+
const ce = /^0x[0-9a-fA-F]{64}$/, de = /^0x[0-9a-fA-F]{40}$/, pe = /^0x([0-9a-fA-F]{2})*$/;
|
|
15
|
+
function S(e, t) {
|
|
16
|
+
if (e.length !== 66)
|
|
17
|
+
throw new Error(
|
|
18
|
+
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
19
|
+
);
|
|
20
|
+
if (!ce.test(e))
|
|
21
|
+
throw new Error(
|
|
22
|
+
`${t} must contain only hex characters after the 0x prefix`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function he(e, t) {
|
|
26
|
+
if (!de.test(e))
|
|
27
|
+
throw new Error(
|
|
28
|
+
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function fe(e, t) {
|
|
32
|
+
if (!pe.test(e))
|
|
33
|
+
throw new Error(
|
|
34
|
+
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
async function rt(e) {
|
|
38
|
+
const {
|
|
39
|
+
btcVaultRegistryAddress: t,
|
|
40
|
+
vaultId: r,
|
|
41
|
+
hashlock: n,
|
|
42
|
+
activationMetadata: i,
|
|
43
|
+
writeContract: u,
|
|
44
|
+
signal: a
|
|
45
|
+
} = e;
|
|
46
|
+
a == null || a.throwIfAborted(), he(t, "btcVaultRegistryAddress"), S(r, "vaultId");
|
|
47
|
+
const s = Y(e.secret);
|
|
48
|
+
if (S(s, "secret"), n !== void 0 && (S(n, "hashlock"), !q(s, n)))
|
|
49
|
+
throw new Error(
|
|
50
|
+
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
51
|
+
);
|
|
52
|
+
return fe(i, "activationMetadata"), u({
|
|
53
|
+
address: t,
|
|
54
|
+
abi: Q,
|
|
55
|
+
functionName: "activateVaultWithSecret",
|
|
56
|
+
args: [r, s, i]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const ge = 1e4;
|
|
60
|
+
async function L(e) {
|
|
61
|
+
const {
|
|
62
|
+
statusReader: t,
|
|
63
|
+
peginTxid: r,
|
|
64
|
+
targetStatuses: n,
|
|
65
|
+
timeoutMs: i,
|
|
66
|
+
pollIntervalMs: u = ge,
|
|
67
|
+
signal: a
|
|
68
|
+
} = e, s = Date.now();
|
|
69
|
+
for (; ; ) {
|
|
70
|
+
if (a != null && a.aborted)
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
73
|
+
);
|
|
74
|
+
if (Date.now() - s >= i)
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Polling timeout after ${i}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
77
|
+
);
|
|
78
|
+
try {
|
|
79
|
+
const o = await t.getPeginStatus(
|
|
80
|
+
{ pegin_txid: r },
|
|
81
|
+
a
|
|
82
|
+
);
|
|
83
|
+
if (o.pegin_txid.toLowerCase() !== r.toLowerCase())
|
|
84
|
+
throw new Error(
|
|
85
|
+
`getPeginStatus returned status for pegin ${o.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
|
|
86
|
+
);
|
|
87
|
+
const l = o.status;
|
|
88
|
+
if (n.has(l))
|
|
89
|
+
return l;
|
|
90
|
+
if (Z.has(l) && !n.has(l))
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Pegin ${r.slice(0, 8)}… reached terminal status "${l}" while waiting for ${[...n].join(", ")}`
|
|
93
|
+
);
|
|
94
|
+
} catch (o) {
|
|
95
|
+
if (!(o instanceof ee && o.code === te.NOT_FOUND || o instanceof Error && o.message.includes("PegIn not found")))
|
|
96
|
+
throw o;
|
|
97
|
+
}
|
|
98
|
+
await new Promise((o, l) => {
|
|
99
|
+
const d = () => {
|
|
100
|
+
clearTimeout(p), l(
|
|
101
|
+
new Error(
|
|
102
|
+
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
}, p = setTimeout(() => {
|
|
106
|
+
a == null || a.removeEventListener("abort", d), o();
|
|
107
|
+
}, u);
|
|
108
|
+
a == null || a.addEventListener("abort", d, { once: !0 });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const Pe = 300 * 1e3, ye = /* @__PURE__ */ new Set([
|
|
113
|
+
x.PENDING_DEPOSITOR_WOTS_PK,
|
|
114
|
+
...H
|
|
115
|
+
]);
|
|
116
|
+
async function nt(e) {
|
|
117
|
+
const {
|
|
118
|
+
statusReader: t,
|
|
119
|
+
wotsSubmitter: r,
|
|
120
|
+
peginTxid: n,
|
|
121
|
+
depositorPk: i,
|
|
122
|
+
wotsPublicKeys: u,
|
|
123
|
+
timeoutMs: a = Pe,
|
|
124
|
+
signal: s
|
|
125
|
+
} = e;
|
|
126
|
+
s == null || s.throwIfAborted();
|
|
127
|
+
const o = await L({
|
|
128
|
+
statusReader: t,
|
|
129
|
+
peginTxid: n,
|
|
130
|
+
targetStatuses: ye,
|
|
131
|
+
timeoutMs: a,
|
|
132
|
+
signal: s
|
|
133
|
+
});
|
|
134
|
+
H.has(o) || (s == null || s.throwIfAborted(), await r.submitDepositorWotsKey(
|
|
135
|
+
{
|
|
136
|
+
pegin_txid: n,
|
|
137
|
+
depositor_pk: i,
|
|
138
|
+
wots_public_keys: u
|
|
139
|
+
},
|
|
140
|
+
s
|
|
141
|
+
));
|
|
142
|
+
}
|
|
143
|
+
const I = 1;
|
|
144
|
+
function me(e, t, r) {
|
|
145
|
+
const n = c(r).toLowerCase(), u = [e, ...t].map(
|
|
146
|
+
(a) => c(a).toLowerCase()
|
|
147
|
+
).filter((a) => a !== n);
|
|
148
|
+
if (u.length === 0)
|
|
149
|
+
throw new Error(
|
|
150
|
+
"Cannot derive localChallengers: removing depositor from {vaultProvider, vaultKeepers} left an empty set"
|
|
151
|
+
);
|
|
152
|
+
return u;
|
|
153
|
+
}
|
|
154
|
+
function be(e, t) {
|
|
155
|
+
const r = e.ins[t];
|
|
156
|
+
return N(new Uint8Array(r.hash).slice().reverse());
|
|
157
|
+
}
|
|
158
|
+
function C(e, t, r, n, i) {
|
|
159
|
+
const u = e.ins[t];
|
|
160
|
+
if (u.index !== 0)
|
|
161
|
+
throw new Error(
|
|
162
|
+
`NoPayout (challenger ${i}) input ${t} expected to spend ${n} vout 0, got vout ${u.index}`
|
|
163
|
+
);
|
|
164
|
+
const a = r.getId(), s = be(e, t);
|
|
165
|
+
if (s !== a)
|
|
166
|
+
throw new Error(
|
|
167
|
+
`NoPayout (challenger ${i}) input ${t} does not reference ${n} (expected txid ${a}, got ${s})`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
async function ve(e, t, r) {
|
|
171
|
+
const n = [], i = [], u = [];
|
|
172
|
+
ue(
|
|
173
|
+
e.payout_tx.tx_hex,
|
|
174
|
+
r.registeredPayoutScriptPubKey
|
|
175
|
+
);
|
|
176
|
+
const a = await le({
|
|
177
|
+
payoutTxHex: e.payout_tx.tx_hex,
|
|
178
|
+
peginTxHex: r.peginTxHex,
|
|
179
|
+
assertTxHex: e.assert_tx.tx_hex,
|
|
180
|
+
depositorBtcPubkey: r.depositorBtcPubkey,
|
|
181
|
+
vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
|
|
182
|
+
vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
|
|
183
|
+
universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
|
|
184
|
+
timelockPegin: r.timelockPegin,
|
|
185
|
+
network: r.network
|
|
186
|
+
});
|
|
187
|
+
n.push(a.psbtHex), i.push(
|
|
188
|
+
R(
|
|
189
|
+
t,
|
|
190
|
+
I
|
|
191
|
+
)
|
|
192
|
+
);
|
|
193
|
+
const s = me(
|
|
194
|
+
r.vaultProviderBtcPubkey,
|
|
195
|
+
r.vaultKeeperBtcPubkeys,
|
|
196
|
+
r.depositorBtcPubkey
|
|
197
|
+
), o = c(r.depositorBtcPubkey), l = k.fromHex(
|
|
198
|
+
c(e.assert_tx.tx_hex)
|
|
199
|
+
);
|
|
200
|
+
for (const d of e.challenger_presign_data) {
|
|
201
|
+
const p = c(d.challenger_pubkey), P = n.length, y = await we({
|
|
202
|
+
challenger: d,
|
|
203
|
+
challengerPubkey: p,
|
|
204
|
+
claimerPubkey: o,
|
|
205
|
+
localChallengers: s,
|
|
206
|
+
assertTxParsed: l,
|
|
207
|
+
ctx: r
|
|
208
|
+
});
|
|
209
|
+
n.push(y), i.push(
|
|
210
|
+
R(
|
|
211
|
+
t,
|
|
212
|
+
I
|
|
213
|
+
)
|
|
214
|
+
), u.push({
|
|
215
|
+
challengerPubkey: p,
|
|
216
|
+
noPayoutIdx: P
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return { psbtHexes: n, signOptions: i, challengerEntries: u };
|
|
220
|
+
}
|
|
221
|
+
async function we(e) {
|
|
222
|
+
const {
|
|
223
|
+
challenger: t,
|
|
224
|
+
challengerPubkey: r,
|
|
225
|
+
claimerPubkey: n,
|
|
226
|
+
localChallengers: i,
|
|
227
|
+
assertTxParsed: u,
|
|
228
|
+
ctx: a
|
|
229
|
+
} = e;
|
|
230
|
+
ae(
|
|
231
|
+
t.nopayout_tx.tx_hex,
|
|
232
|
+
r,
|
|
233
|
+
a.network
|
|
234
|
+
);
|
|
235
|
+
const s = k.fromHex(
|
|
236
|
+
c(t.nopayout_tx.tx_hex)
|
|
237
|
+
), o = k.fromHex(
|
|
238
|
+
c(t.challenge_assert_x_tx.tx_hex)
|
|
239
|
+
), l = k.fromHex(
|
|
240
|
+
c(t.challenge_assert_y_tx.tx_hex)
|
|
241
|
+
);
|
|
242
|
+
if (s.ins.length !== 3)
|
|
243
|
+
throw new Error(
|
|
244
|
+
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${s.ins.length}`
|
|
245
|
+
);
|
|
246
|
+
C(
|
|
247
|
+
s,
|
|
248
|
+
0,
|
|
249
|
+
u,
|
|
250
|
+
"Assert",
|
|
251
|
+
r
|
|
252
|
+
), C(
|
|
253
|
+
s,
|
|
254
|
+
1,
|
|
255
|
+
o,
|
|
256
|
+
"ChallengeAssertX",
|
|
257
|
+
r
|
|
258
|
+
), C(
|
|
259
|
+
s,
|
|
260
|
+
2,
|
|
261
|
+
l,
|
|
262
|
+
"ChallengeAssertY",
|
|
263
|
+
r
|
|
264
|
+
);
|
|
265
|
+
const d = [
|
|
266
|
+
u.outs[0],
|
|
267
|
+
o.outs[0],
|
|
268
|
+
l.outs[0]
|
|
269
|
+
].map((p) => ({
|
|
270
|
+
script_pubkey: N(new Uint8Array(p.script)),
|
|
271
|
+
value: p.value
|
|
272
|
+
}));
|
|
273
|
+
return se({
|
|
274
|
+
noPayoutTxHex: t.nopayout_tx.tx_hex,
|
|
275
|
+
challengerPubkey: r,
|
|
276
|
+
prevouts: d,
|
|
277
|
+
connectorParams: {
|
|
278
|
+
claimer: n,
|
|
279
|
+
localChallengers: i,
|
|
280
|
+
universalChallengers: a.universalChallengerBtcPubkeys,
|
|
281
|
+
timelockAssert: a.timelockAssert,
|
|
282
|
+
councilMembers: a.councilMembers,
|
|
283
|
+
councilQuorum: a.councilQuorum
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function xe(e, t, r) {
|
|
288
|
+
const n = $(
|
|
289
|
+
e[0],
|
|
290
|
+
r
|
|
291
|
+
), i = {};
|
|
292
|
+
for (const u of t)
|
|
293
|
+
i[u.challengerPubkey] = {
|
|
294
|
+
nopayout_signature: $(
|
|
295
|
+
e[u.noPayoutIdx],
|
|
296
|
+
r
|
|
297
|
+
)
|
|
298
|
+
};
|
|
299
|
+
return {
|
|
300
|
+
payout_signatures: {
|
|
301
|
+
payout_signature: n
|
|
302
|
+
},
|
|
303
|
+
per_challenger: i
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
async function Te(e, t, r) {
|
|
307
|
+
if (typeof e.signPsbts == "function")
|
|
308
|
+
return e.signPsbts(t, r);
|
|
309
|
+
const n = [];
|
|
310
|
+
for (let i = 0; i < t.length; i++)
|
|
311
|
+
n.push(await e.signPsbt(t[i], r == null ? void 0 : r[i]));
|
|
312
|
+
return n;
|
|
313
|
+
}
|
|
314
|
+
async function ke(e) {
|
|
315
|
+
const { depositorGraph: t, btcWallet: r, signingContext: n } = e, i = await r.getPublicKeyHex(), { depositorPubkey: u } = j(
|
|
316
|
+
i,
|
|
317
|
+
c(n.depositorBtcPubkey)
|
|
318
|
+
), { psbtHexes: a, signOptions: s, challengerEntries: o } = await ve(
|
|
319
|
+
t,
|
|
320
|
+
i,
|
|
321
|
+
n
|
|
322
|
+
), l = await Te(
|
|
323
|
+
r,
|
|
324
|
+
a,
|
|
325
|
+
s
|
|
326
|
+
);
|
|
327
|
+
if (l.length !== a.length)
|
|
328
|
+
throw new Error(
|
|
329
|
+
`Wallet returned ${l.length} signed PSBTs, expected ${a.length}`
|
|
330
|
+
);
|
|
331
|
+
return xe(
|
|
332
|
+
l,
|
|
333
|
+
o,
|
|
334
|
+
u
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
const Ee = 1200 * 1e3, D = /* @__PURE__ */ new Set([
|
|
338
|
+
x.PENDING_ACKS,
|
|
339
|
+
x.PENDING_ACTIVATION,
|
|
340
|
+
x.ACTIVATED
|
|
341
|
+
]), _e = /* @__PURE__ */ new Set([
|
|
342
|
+
x.PENDING_DEPOSITOR_SIGNATURES,
|
|
343
|
+
...D
|
|
344
|
+
]);
|
|
345
|
+
function Be(e) {
|
|
346
|
+
return e.map((t) => ({
|
|
347
|
+
claimerPubkeyXOnly: T(t.claimer_pubkey),
|
|
348
|
+
payoutTxHex: t.payout_tx.tx_hex,
|
|
349
|
+
assertTxHex: t.assert_tx.tx_hex
|
|
350
|
+
}));
|
|
351
|
+
}
|
|
352
|
+
function Se(e) {
|
|
353
|
+
const { output: t } = re.payments.p2tr({
|
|
354
|
+
internalPubkey: oe.from(e, "hex")
|
|
355
|
+
});
|
|
356
|
+
if (!t)
|
|
357
|
+
throw new Error("Failed to derive BIP-86 P2TR scriptPubKey");
|
|
358
|
+
return t.toString("hex");
|
|
359
|
+
}
|
|
360
|
+
function Ce(e, t) {
|
|
361
|
+
const r = c(e).toLowerCase(), n = c(
|
|
362
|
+
t.vaultProviderBtcPubkey
|
|
363
|
+
).toLowerCase(), i = c(
|
|
364
|
+
t.depositorBtcPubkey
|
|
365
|
+
).toLowerCase();
|
|
366
|
+
if (r === n || r === i)
|
|
367
|
+
return t.registeredPayoutScriptPubKey;
|
|
368
|
+
if (!t.vaultKeeperBtcPubkeys.some(
|
|
369
|
+
(s) => c(s).toLowerCase() === r
|
|
370
|
+
))
|
|
371
|
+
throw new Error(
|
|
372
|
+
`Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
|
|
373
|
+
);
|
|
374
|
+
return `0x${Se(r)}`;
|
|
375
|
+
}
|
|
376
|
+
function K(e, t) {
|
|
377
|
+
return {
|
|
378
|
+
payoutTxHex: e.payoutTxHex,
|
|
379
|
+
peginTxHex: t.peginTxHex,
|
|
380
|
+
assertTxHex: e.assertTxHex,
|
|
381
|
+
vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
|
|
382
|
+
vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
|
|
383
|
+
universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
|
|
384
|
+
depositorBtcPubkey: t.depositorBtcPubkey,
|
|
385
|
+
timelockPegin: t.timelockPegin,
|
|
386
|
+
registeredPayoutScriptPubKey: Ce(
|
|
387
|
+
e.claimerPubkeyXOnly,
|
|
388
|
+
t
|
|
389
|
+
)
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
async function Ae(e, t, r, n) {
|
|
393
|
+
const i = new J({
|
|
394
|
+
network: t.network,
|
|
395
|
+
btcWallet: e
|
|
396
|
+
}), u = r.length;
|
|
397
|
+
n == null || n(0, u);
|
|
398
|
+
let a;
|
|
399
|
+
if (i.supportsBatchSigning())
|
|
400
|
+
a = (await i.signPayoutTransactionsBatch(
|
|
401
|
+
r.map((l) => K(l, t))
|
|
402
|
+
)).map((l) => l.payoutSignature);
|
|
403
|
+
else {
|
|
404
|
+
a = [];
|
|
405
|
+
for (let o = 0; o < r.length; o++) {
|
|
406
|
+
n == null || n(o, u);
|
|
407
|
+
const l = await i.signPayoutTransaction(
|
|
408
|
+
K(r[o], t)
|
|
409
|
+
);
|
|
410
|
+
a.push(l.signature);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const s = {};
|
|
414
|
+
for (let o = 0; o < r.length; o++)
|
|
415
|
+
s[r[o].claimerPubkeyXOnly] = {
|
|
416
|
+
payout_signature: a[o]
|
|
417
|
+
};
|
|
418
|
+
return n == null || n(u, u), s;
|
|
419
|
+
}
|
|
420
|
+
async function ot(e) {
|
|
421
|
+
const {
|
|
422
|
+
statusReader: t,
|
|
423
|
+
presignClient: r,
|
|
424
|
+
btcWallet: n,
|
|
425
|
+
peginTxid: i,
|
|
426
|
+
depositorPk: u,
|
|
427
|
+
signingContext: a,
|
|
428
|
+
timeoutMs: s = Ee,
|
|
429
|
+
signal: o,
|
|
430
|
+
onProgress: l
|
|
431
|
+
} = e, d = await L({
|
|
432
|
+
statusReader: t,
|
|
433
|
+
peginTxid: i,
|
|
434
|
+
targetStatuses: _e,
|
|
435
|
+
timeoutMs: s,
|
|
436
|
+
signal: o
|
|
437
|
+
});
|
|
438
|
+
if (D.has(d))
|
|
439
|
+
return;
|
|
440
|
+
o == null || o.throwIfAborted();
|
|
441
|
+
const p = await r.requestDepositorPresignTransactions(
|
|
442
|
+
{
|
|
443
|
+
pegin_txid: i,
|
|
444
|
+
depositor_pk: u
|
|
445
|
+
},
|
|
446
|
+
o
|
|
447
|
+
);
|
|
448
|
+
o == null || o.throwIfAborted();
|
|
449
|
+
const P = T(u), y = p.txs.filter(
|
|
450
|
+
(w) => T(w.claimer_pubkey) !== P
|
|
451
|
+
), b = Be(y), f = await Ae(
|
|
452
|
+
n,
|
|
453
|
+
a,
|
|
454
|
+
b,
|
|
455
|
+
l
|
|
456
|
+
);
|
|
457
|
+
o == null || o.throwIfAborted();
|
|
458
|
+
const g = await ke({
|
|
459
|
+
depositorGraph: p.depositor_graph,
|
|
460
|
+
btcWallet: n,
|
|
461
|
+
signingContext: {
|
|
462
|
+
peginTxHex: a.peginTxHex,
|
|
463
|
+
depositorBtcPubkey: u,
|
|
464
|
+
vaultProviderBtcPubkey: a.vaultProviderBtcPubkey,
|
|
465
|
+
vaultKeeperBtcPubkeys: a.vaultKeeperBtcPubkeys,
|
|
466
|
+
universalChallengerBtcPubkeys: a.universalChallengerBtcPubkeys,
|
|
467
|
+
timelockPegin: a.timelockPegin,
|
|
468
|
+
timelockAssert: a.timelockAssert,
|
|
469
|
+
councilMembers: a.councilMembers,
|
|
470
|
+
councilQuorum: a.councilQuorum,
|
|
471
|
+
network: a.network,
|
|
472
|
+
registeredPayoutScriptPubKey: a.registeredPayoutScriptPubKey
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
o == null || o.throwIfAborted();
|
|
476
|
+
const v = { ...f };
|
|
477
|
+
v[c(u)] = g.payout_signatures, await r.submitDepositorPresignatures(
|
|
478
|
+
{
|
|
479
|
+
pegin_txid: i,
|
|
480
|
+
depositor_pk: u,
|
|
481
|
+
signatures: v,
|
|
482
|
+
depositor_claimer_presignatures: g
|
|
483
|
+
},
|
|
484
|
+
o
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
function Re(e) {
|
|
488
|
+
return /^[0-9a-fA-F]{64}$/.test(e);
|
|
489
|
+
}
|
|
490
|
+
function at(e) {
|
|
491
|
+
const {
|
|
492
|
+
amountSats: t,
|
|
493
|
+
minDeposit: r,
|
|
494
|
+
maxDeposit: n,
|
|
495
|
+
btcBalance: i,
|
|
496
|
+
estimatedFeeSats: u,
|
|
497
|
+
depositorClaimValue: a
|
|
498
|
+
} = e;
|
|
499
|
+
return !(t <= 0n || t < r || n && n > 0n && t > n || u == null || a == null || t + u + a > i);
|
|
500
|
+
}
|
|
501
|
+
function st(e, t, r) {
|
|
502
|
+
return e <= 0n ? {
|
|
503
|
+
valid: !1,
|
|
504
|
+
error: "Deposit amount must be greater than zero"
|
|
505
|
+
} : e < t ? {
|
|
506
|
+
valid: !1,
|
|
507
|
+
error: `Minimum deposit is ${m(t)} BTC`
|
|
508
|
+
} : r && r > 0n && e > r ? {
|
|
509
|
+
valid: !1,
|
|
510
|
+
error: `Maximum deposit is ${m(r)} BTC`
|
|
511
|
+
} : { valid: !0 };
|
|
512
|
+
}
|
|
513
|
+
function it(e) {
|
|
514
|
+
const { amount: t, effectiveRemaining: r } = e;
|
|
515
|
+
return r === null ? { valid: !0 } : r === 0n ? {
|
|
516
|
+
valid: !1,
|
|
517
|
+
error: "Supply cap reached — deposits temporarily paused"
|
|
518
|
+
} : t > r ? {
|
|
519
|
+
valid: !1,
|
|
520
|
+
error: `Vault size exceeds remaining capacity (${m(r)} BTC)`
|
|
521
|
+
} : { valid: !0 };
|
|
522
|
+
}
|
|
523
|
+
function ut(e, t) {
|
|
524
|
+
if (!e || e.length === 0)
|
|
525
|
+
return {
|
|
526
|
+
valid: !1,
|
|
527
|
+
error: "At least one vault provider must be selected"
|
|
528
|
+
};
|
|
529
|
+
const r = t.map(
|
|
530
|
+
(i) => i.toLowerCase()
|
|
531
|
+
);
|
|
532
|
+
return e.filter(
|
|
533
|
+
(i) => !r.includes(i.toLowerCase())
|
|
534
|
+
).length > 0 ? {
|
|
535
|
+
valid: !1,
|
|
536
|
+
error: "Invalid vault provider selected"
|
|
537
|
+
} : { valid: !0 };
|
|
538
|
+
}
|
|
539
|
+
function Ve(e, t, r) {
|
|
540
|
+
if (!e || e.length === 0)
|
|
541
|
+
return {
|
|
542
|
+
valid: !1,
|
|
543
|
+
error: "At least one vault amount required"
|
|
544
|
+
};
|
|
545
|
+
for (let n = 0; n < e.length; n++) {
|
|
546
|
+
const i = e[n];
|
|
547
|
+
if (i <= 0n)
|
|
548
|
+
return {
|
|
549
|
+
valid: !1,
|
|
550
|
+
error: `Vault ${n + 1} amount must be positive`
|
|
551
|
+
};
|
|
552
|
+
if (t && i < t)
|
|
553
|
+
return {
|
|
554
|
+
valid: !1,
|
|
555
|
+
error: `Vault ${n + 1} amount ${m(i)} BTC is below minimum deposit ${m(t)} BTC`
|
|
556
|
+
};
|
|
557
|
+
if (r && i > r)
|
|
558
|
+
return {
|
|
559
|
+
valid: !1,
|
|
560
|
+
error: `Vault ${n + 1} amount ${m(i)} BTC exceeds maximum deposit ${m(r)} BTC`
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
return { valid: !0 };
|
|
564
|
+
}
|
|
565
|
+
function $e(e) {
|
|
566
|
+
const t = c(e);
|
|
567
|
+
return Re(t) ? { valid: !0 } : {
|
|
568
|
+
valid: !1,
|
|
569
|
+
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function Ie(e) {
|
|
573
|
+
if (!e || e.length === 0)
|
|
574
|
+
throw new Error(
|
|
575
|
+
"No vault keepers available. The system requires at least one vault keeper to create a deposit."
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
function Ke(e) {
|
|
579
|
+
if (!e || e.length === 0)
|
|
580
|
+
throw new Error(
|
|
581
|
+
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
function Oe(e) {
|
|
585
|
+
if (e.length === 0)
|
|
586
|
+
throw new Error("No spendable UTXOs available");
|
|
587
|
+
}
|
|
588
|
+
function lt(e) {
|
|
589
|
+
const {
|
|
590
|
+
vaultAmounts: t,
|
|
591
|
+
confirmedUTXOs: r,
|
|
592
|
+
vaultProviderBtcPubkey: n,
|
|
593
|
+
vaultKeeperBtcPubkeys: i,
|
|
594
|
+
universalChallengerBtcPubkeys: u,
|
|
595
|
+
minDeposit: a,
|
|
596
|
+
maxDeposit: s
|
|
597
|
+
} = e, o = Ve(
|
|
598
|
+
t,
|
|
599
|
+
a,
|
|
600
|
+
s
|
|
601
|
+
);
|
|
602
|
+
if (!o.valid)
|
|
603
|
+
throw new Error(o.error);
|
|
604
|
+
const l = $e(n);
|
|
605
|
+
if (!l.valid)
|
|
606
|
+
throw new Error(l.error);
|
|
607
|
+
Ie(i), Ke(u), Oe(r);
|
|
608
|
+
}
|
|
609
|
+
async function ct(e) {
|
|
610
|
+
const {
|
|
611
|
+
vaultRegistryReader: t,
|
|
612
|
+
vaultKeeperReader: r,
|
|
613
|
+
universalChallengerReader: n,
|
|
614
|
+
vaultProviderEthAddress: i,
|
|
615
|
+
applicationEntryPoint: u,
|
|
616
|
+
expectedVaultProviderBtcPubkey: a,
|
|
617
|
+
expectedVaultKeeperBtcPubkeys: s,
|
|
618
|
+
expectedUniversalChallengerBtcPubkeys: o
|
|
619
|
+
} = e, [
|
|
620
|
+
l,
|
|
621
|
+
d,
|
|
622
|
+
p
|
|
623
|
+
] = await Promise.all([
|
|
624
|
+
t.getVaultProviderBtcPubKey(i),
|
|
625
|
+
r.getCurrentVaultKeepersVersion(u),
|
|
626
|
+
n.getLatestUniversalChallengersVersion()
|
|
627
|
+
]), [P, y] = await Promise.all([
|
|
628
|
+
r.getVaultKeepersByVersion(
|
|
629
|
+
u,
|
|
630
|
+
d
|
|
631
|
+
),
|
|
632
|
+
n.getUniversalChallengersByVersion(
|
|
633
|
+
p
|
|
634
|
+
)
|
|
635
|
+
]), b = (h) => T(h).toLowerCase(), f = (h) => h.map(b).sort();
|
|
636
|
+
if (b(a) !== l)
|
|
637
|
+
throw new Error(
|
|
638
|
+
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${i}. Refresh and try again.`
|
|
639
|
+
);
|
|
640
|
+
const v = f(s), w = f(
|
|
641
|
+
P.map((h) => h.btcPubKey)
|
|
642
|
+
);
|
|
643
|
+
if (v.length !== w.length || v.some((h, _) => h !== w[_]))
|
|
644
|
+
throw new Error(
|
|
645
|
+
`Vault keeper BTC pubkeys (v${d}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
646
|
+
);
|
|
647
|
+
const V = f(o), E = f(
|
|
648
|
+
y.map((h) => h.btcPubKey)
|
|
649
|
+
);
|
|
650
|
+
if (V.length !== E.length || V.some((h, _) => h !== E[_]))
|
|
651
|
+
throw new Error(
|
|
652
|
+
`Universal challenger BTC pubkeys (v${p}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
653
|
+
);
|
|
654
|
+
return {
|
|
655
|
+
vaultProviderBtcPubkeyXOnly: l,
|
|
656
|
+
vaultKeeperBtcPubkeysSorted: w,
|
|
657
|
+
universalChallengerBtcPubkeysSorted: E,
|
|
658
|
+
expectedAppVaultKeepersVersion: d,
|
|
659
|
+
expectedUniversalChallengersVersion: p
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
class M extends Error {
|
|
663
|
+
constructor(t) {
|
|
664
|
+
super(t), this.name = "RegisteredVaultVersionMismatchError";
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
function dt(e) {
|
|
668
|
+
return e instanceof M || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
|
|
669
|
+
}
|
|
670
|
+
async function pt(e) {
|
|
671
|
+
const {
|
|
672
|
+
vaultRegistryReader: t,
|
|
673
|
+
vaultIds: r,
|
|
674
|
+
expectedOffchainParamsVersion: n,
|
|
675
|
+
expectedAppVaultKeepersVersion: i,
|
|
676
|
+
expectedUniversalChallengersVersion: u
|
|
677
|
+
} = e, a = await t.getProtocolInfoBatch(r), s = [];
|
|
678
|
+
if (a.forEach((o, l) => {
|
|
679
|
+
const d = r[l];
|
|
680
|
+
o.offchainParamsVersion !== n && s.push(
|
|
681
|
+
`vault ${d}: offchainParams expected v${n}, got v${o.offchainParamsVersion}`
|
|
682
|
+
), o.appVaultKeepersVersion !== i && s.push(
|
|
683
|
+
`vault ${d}: appVaultKeepers expected v${i}, got v${o.appVaultKeepersVersion}`
|
|
684
|
+
), o.universalChallengersVersion !== u && s.push(
|
|
685
|
+
`vault ${d}: universalChallengers expected v${u}, got v${o.universalChallengersVersion}`
|
|
686
|
+
);
|
|
687
|
+
}), s.length > 0)
|
|
688
|
+
throw new M(
|
|
689
|
+
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${s.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
var U = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.CHALLENGE_ASSERT_OBSERVED = "ChallengeAssertObserved", e.WRONGLY_CHALLENGED_BROADCAST = "WronglyChallengedBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.FAILED = "Failed", e))(U || {});
|
|
693
|
+
const Ne = /* @__PURE__ */ new Set([
|
|
694
|
+
"PayoutBroadcast",
|
|
695
|
+
"Failed"
|
|
696
|
+
/* FAILED */
|
|
697
|
+
]);
|
|
698
|
+
function ht(e) {
|
|
699
|
+
return Object.values(U).includes(
|
|
700
|
+
e
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
function ft(e) {
|
|
704
|
+
return !!e && Ne.has(e);
|
|
705
|
+
}
|
|
706
|
+
class He extends Error {
|
|
707
|
+
constructor(r, n) {
|
|
708
|
+
super(`Refund not yet mature (BIP68 not final): ${n.message}`);
|
|
709
|
+
B(this, "vaultId");
|
|
710
|
+
B(this, "cause");
|
|
711
|
+
this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
const Le = /^0x[0-9a-fA-F]{64}$/, De = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, F = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, X = 160;
|
|
715
|
+
function gt(e) {
|
|
716
|
+
if (!Number.isFinite(e) || e <= 0)
|
|
717
|
+
throw new Error(
|
|
718
|
+
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
719
|
+
);
|
|
720
|
+
return BigInt(Math.ceil(e * X));
|
|
721
|
+
}
|
|
722
|
+
const Me = 1, O = 65535, Ue = /non-BIP68-final/i;
|
|
723
|
+
function z(e, t) {
|
|
724
|
+
if (e.length !== 66)
|
|
725
|
+
throw new Error(
|
|
726
|
+
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
727
|
+
);
|
|
728
|
+
if (!Le.test(e))
|
|
729
|
+
throw new Error(
|
|
730
|
+
`${t} must contain only hex characters after the 0x prefix`
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
function A(e, t) {
|
|
734
|
+
if (!Number.isInteger(e) || e < 0)
|
|
735
|
+
throw new Error(`${t} must be a non-negative integer, got ${e}`);
|
|
736
|
+
}
|
|
737
|
+
function Fe(e) {
|
|
738
|
+
if (z(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > O)
|
|
739
|
+
throw new Error(
|
|
740
|
+
`htlcVout must be an integer 0-${O}, got ${e.htlcVout}`
|
|
741
|
+
);
|
|
742
|
+
if (A(e.offchainParamsVersion, "offchainParamsVersion"), A(e.appVaultKeepersVersion, "appVaultKeepersVersion"), A(
|
|
743
|
+
e.universalChallengersVersion,
|
|
744
|
+
"universalChallengersVersion"
|
|
745
|
+
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
746
|
+
throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
|
|
747
|
+
if (!De.test(e.unsignedPrePeginTxHex))
|
|
748
|
+
throw new Error(
|
|
749
|
+
"unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
|
|
750
|
+
);
|
|
751
|
+
if (!e.depositorBtcPubkey || !F.test(e.depositorBtcPubkey))
|
|
752
|
+
throw new Error(
|
|
753
|
+
"depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
|
|
754
|
+
);
|
|
755
|
+
if (typeof e.amount != "bigint" || e.amount <= 0n)
|
|
756
|
+
throw new Error(`amount must be a positive bigint, got ${e.amount}`);
|
|
757
|
+
}
|
|
758
|
+
function Xe(e) {
|
|
759
|
+
if (!e.vaultProviderPubkey || !F.test(e.vaultProviderPubkey))
|
|
760
|
+
throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
|
|
761
|
+
if (e.vaultKeeperPubkeys.length === 0)
|
|
762
|
+
throw new Error("vaultKeeperPubkeys must be non-empty");
|
|
763
|
+
if (e.universalChallengerPubkeys.length === 0)
|
|
764
|
+
throw new Error("universalChallengerPubkeys must be non-empty");
|
|
765
|
+
if (!Number.isInteger(e.timelockRefund) || e.timelockRefund <= 0)
|
|
766
|
+
throw new Error(
|
|
767
|
+
`timelockRefund must be a positive integer, got ${e.timelockRefund}`
|
|
768
|
+
);
|
|
769
|
+
if (typeof e.feeRate != "bigint" || e.feeRate <= 0n)
|
|
770
|
+
throw new Error(
|
|
771
|
+
`protocol feeRate must be a positive bigint, got ${e.feeRate}`
|
|
772
|
+
);
|
|
773
|
+
if (!Number.isInteger(e.numLocalChallengers) || e.numLocalChallengers < 0)
|
|
774
|
+
throw new Error("numLocalChallengers must be a non-negative integer");
|
|
775
|
+
if (!Number.isInteger(e.councilQuorum) || !Number.isInteger(e.councilSize) || e.councilQuorum <= 0 || e.councilSize <= 0 || e.councilQuorum > e.councilSize)
|
|
776
|
+
throw new Error(
|
|
777
|
+
`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
function ze(e) {
|
|
781
|
+
const t = ne.fromHex(e);
|
|
782
|
+
try {
|
|
783
|
+
t.finalizeAllInputs();
|
|
784
|
+
} catch (r) {
|
|
785
|
+
const n = r instanceof Error ? r.message : String(r);
|
|
786
|
+
if (!n.includes("already finalized"))
|
|
787
|
+
throw new Error(`Failed to finalize refund PSBT: ${n}`);
|
|
788
|
+
}
|
|
789
|
+
return t.extractTransaction().toHex();
|
|
790
|
+
}
|
|
791
|
+
async function Pt(e) {
|
|
792
|
+
const {
|
|
793
|
+
vaultId: t,
|
|
794
|
+
readVault: r,
|
|
795
|
+
readPrePeginContext: n,
|
|
796
|
+
feeRate: i,
|
|
797
|
+
signPsbt: u,
|
|
798
|
+
broadcastTx: a,
|
|
799
|
+
signal: s
|
|
800
|
+
} = e;
|
|
801
|
+
s == null || s.throwIfAborted(), z(t, "vaultId");
|
|
802
|
+
const o = await r();
|
|
803
|
+
Fe(o), s == null || s.throwIfAborted();
|
|
804
|
+
const l = await n(o);
|
|
805
|
+
if (Xe(l), s == null || s.throwIfAborted(), !Number.isFinite(i) || i <= 0)
|
|
806
|
+
throw new Error(`feeRate must be a positive number, got ${i}`);
|
|
807
|
+
const d = BigInt(Math.ceil(i * X));
|
|
808
|
+
s == null || s.throwIfAborted();
|
|
809
|
+
const p = T(
|
|
810
|
+
o.depositorBtcPubkey
|
|
811
|
+
), { psbtHex: P } = await ie({
|
|
812
|
+
prePeginParams: {
|
|
813
|
+
depositorPubkey: p,
|
|
814
|
+
vaultProviderPubkey: c(l.vaultProviderPubkey),
|
|
815
|
+
vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(c),
|
|
816
|
+
universalChallengerPubkeys: l.universalChallengerPubkeys.map(c),
|
|
817
|
+
hashlocks: [c(o.hashlock)],
|
|
818
|
+
timelockRefund: l.timelockRefund,
|
|
819
|
+
pegInAmounts: [o.amount],
|
|
820
|
+
feeRate: l.feeRate,
|
|
821
|
+
numLocalChallengers: l.numLocalChallengers,
|
|
822
|
+
councilQuorum: l.councilQuorum,
|
|
823
|
+
councilSize: l.councilSize,
|
|
824
|
+
network: l.network
|
|
825
|
+
},
|
|
826
|
+
fundedPrePeginTxHex: c(o.unsignedPrePeginTxHex),
|
|
827
|
+
htlcVout: o.htlcVout,
|
|
828
|
+
refundFee: d,
|
|
829
|
+
// buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
|
|
830
|
+
// prefix" and flows into the WASM HTLC connector derivation; a prefixed
|
|
831
|
+
// value would derive the wrong refund script leaf and yield an
|
|
832
|
+
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
833
|
+
hashlock: c(o.hashlock)
|
|
834
|
+
});
|
|
835
|
+
s == null || s.throwIfAborted();
|
|
836
|
+
const y = R(
|
|
837
|
+
o.depositorBtcPubkey,
|
|
838
|
+
Me
|
|
839
|
+
), b = await u(P, y), f = ze(b);
|
|
840
|
+
s == null || s.throwIfAborted();
|
|
841
|
+
try {
|
|
842
|
+
return await a(f);
|
|
843
|
+
} catch (g) {
|
|
844
|
+
throw g instanceof Error && Ue.test(g.message) ? new He(t, g) : g;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
export {
|
|
848
|
+
He as B,
|
|
849
|
+
U as C,
|
|
850
|
+
M as R,
|
|
851
|
+
rt as a,
|
|
852
|
+
ke as b,
|
|
853
|
+
it as c,
|
|
854
|
+
ut as d,
|
|
855
|
+
Ve as e,
|
|
856
|
+
$e as f,
|
|
857
|
+
lt as g,
|
|
858
|
+
ct as h,
|
|
859
|
+
at as i,
|
|
860
|
+
dt as j,
|
|
861
|
+
pt as k,
|
|
862
|
+
ht as l,
|
|
863
|
+
ft as m,
|
|
864
|
+
Pt as n,
|
|
865
|
+
gt as o,
|
|
866
|
+
X as p,
|
|
867
|
+
ot as r,
|
|
868
|
+
nt as s,
|
|
869
|
+
st as v,
|
|
870
|
+
L as w
|
|
871
|
+
};
|
|
872
|
+
//# sourceMappingURL=buildAndBroadcastRefund-D4YqqClN.js.map
|