@babylonlabs-io/ts-sdk 0.64.0 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{buildAndBroadcastRefund-C2fP3Rva.js → buildAndBroadcastRefund-C4LiPATK.js} +201 -201
- package/dist/buildAndBroadcastRefund-C4LiPATK.js.map +1 -0
- package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs +2 -0
- package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +1 -1
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +3 -2
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +1 -1
- package/package.json +1 -1
- package/dist/buildAndBroadcastRefund-C2fP3Rva.js.map +0 -1
- package/dist/buildAndBroadcastRefund-CYtnT0D_.cjs +0 -2
- package/dist/buildAndBroadcastRefund-CYtnT0D_.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var $ = (e, t, r) =>
|
|
1
|
+
var me = Object.defineProperty;
|
|
2
|
+
var Pe = (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) => Pe(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { B as re } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
|
|
5
5
|
import { e as ye, v as be, s as f, u as ne, p as U, c as x, f as C } from "./bitcoin-d9eaaZB_.js";
|
|
6
6
|
import { v as we, d as ke, s as Ee, P as xe, a as Te } from "./signPsbtsWithFallback-Bb66DfY5.js";
|
|
@@ -35,7 +35,7 @@ function Fe(e, t) {
|
|
|
35
35
|
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function se(e) {
|
|
39
39
|
De(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), B(e.vaultId, "vaultId");
|
|
40
40
|
const t = ye(e.secret);
|
|
41
41
|
if (B(t, "secret"), e.hashlock !== void 0 && (B(e.hashlock, "hashlock"), !we(t, e.hashlock)))
|
|
@@ -49,34 +49,34 @@ async function Ft(e) {
|
|
|
49
49
|
btcVaultRegistryAddress: t,
|
|
50
50
|
vaultId: r,
|
|
51
51
|
hashlock: n,
|
|
52
|
-
activationMetadata:
|
|
52
|
+
activationMetadata: s,
|
|
53
53
|
writeContract: l,
|
|
54
54
|
signal: o
|
|
55
55
|
} = e;
|
|
56
56
|
o == null || o.throwIfAborted();
|
|
57
|
-
const
|
|
57
|
+
const a = se({
|
|
58
58
|
btcVaultRegistryAddress: t,
|
|
59
59
|
vaultId: r,
|
|
60
60
|
secret: e.secret,
|
|
61
61
|
hashlock: n
|
|
62
62
|
});
|
|
63
|
-
return Fe(
|
|
63
|
+
return Fe(s, "activationMetadata"), l({
|
|
64
64
|
address: t,
|
|
65
65
|
abi: re,
|
|
66
66
|
functionName: "activateVaultWithSecret",
|
|
67
|
-
args: [r,
|
|
67
|
+
args: [r, a, s]
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
async function Mt(e) {
|
|
71
|
-
const { btcVaultRegistryAddress: t, vaultId: r, hashlock: n, writeContract:
|
|
71
|
+
const { btcVaultRegistryAddress: t, vaultId: r, hashlock: n, writeContract: s, signal: l } = e;
|
|
72
72
|
l == null || l.throwIfAborted();
|
|
73
|
-
const o =
|
|
73
|
+
const o = se({
|
|
74
74
|
btcVaultRegistryAddress: t,
|
|
75
75
|
vaultId: r,
|
|
76
76
|
secret: e.secret,
|
|
77
77
|
hashlock: n
|
|
78
78
|
});
|
|
79
|
-
return
|
|
79
|
+
return s({
|
|
80
80
|
address: t,
|
|
81
81
|
abi: re,
|
|
82
82
|
functionName: "activateVaultWithSecretAndRedeem",
|
|
@@ -84,7 +84,7 @@ async function Mt(e) {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
const Me = 8, Le = 6e3, Ue = 10 * 6e4, ze = 10;
|
|
87
|
-
class
|
|
87
|
+
class ae extends Error {
|
|
88
88
|
constructor(t) {
|
|
89
89
|
super(t), this.name = "PeginRegistrationMissingError";
|
|
90
90
|
}
|
|
@@ -95,7 +95,7 @@ class ie extends Error {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
function Xe(e) {
|
|
98
|
-
return e instanceof
|
|
98
|
+
return e instanceof ae || e instanceof Error && e.name === "PeginRegistrationMissingError";
|
|
99
99
|
}
|
|
100
100
|
function Lt(e) {
|
|
101
101
|
return e instanceof ie || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
|
|
@@ -109,10 +109,10 @@ async function Ut(e) {
|
|
|
109
109
|
vaultRegistryReader: t,
|
|
110
110
|
getBlockNumber: r,
|
|
111
111
|
vaultIds: n,
|
|
112
|
-
required:
|
|
112
|
+
required: s = Me,
|
|
113
113
|
pollIntervalMs: l = Le,
|
|
114
114
|
timeoutMs: o = Ue,
|
|
115
|
-
signal:
|
|
115
|
+
signal: a,
|
|
116
116
|
onProgress: i
|
|
117
117
|
} = e;
|
|
118
118
|
if (n.length === 0)
|
|
@@ -122,13 +122,13 @@ async function Ut(e) {
|
|
|
122
122
|
const u = Date.now();
|
|
123
123
|
let h = !1, c = 0, p;
|
|
124
124
|
for (; ; ) {
|
|
125
|
-
if (
|
|
125
|
+
if (a != null && a.aborted)
|
|
126
126
|
throw new Error(
|
|
127
127
|
`Aborted while waiting for peg-in registration depth (${n.length} vault(s))`
|
|
128
128
|
);
|
|
129
129
|
if (Date.now() - u >= o)
|
|
130
130
|
throw new ie(
|
|
131
|
-
`Peg-in registration did not reach ${
|
|
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}` : "")
|
|
132
132
|
);
|
|
133
133
|
try {
|
|
134
134
|
const d = await r(), g = await Promise.all(
|
|
@@ -138,27 +138,27 @@ async function Ut(e) {
|
|
|
138
138
|
);
|
|
139
139
|
if (b !== -1) {
|
|
140
140
|
if (c += 1, !h && c > ze)
|
|
141
|
-
throw new
|
|
141
|
+
throw new ae(
|
|
142
142
|
`Vault ${n[b]} is still not visible on-chain after ${c} reads — the registration does not exist.`
|
|
143
143
|
);
|
|
144
144
|
console.warn(
|
|
145
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:
|
|
146
|
+
), i == null || i({ confirmations: 0, required: s });
|
|
147
147
|
} else {
|
|
148
148
|
h = !0, c = 0, p = void 0;
|
|
149
|
-
let v = g[0],
|
|
149
|
+
let v = g[0], m = G({
|
|
150
150
|
currentBlock: d,
|
|
151
151
|
createdAtBlock: g[0].createdAt
|
|
152
152
|
});
|
|
153
153
|
for (const w of g.slice(1)) {
|
|
154
|
-
const
|
|
154
|
+
const P = G({
|
|
155
155
|
currentBlock: d,
|
|
156
156
|
createdAtBlock: w.createdAt
|
|
157
157
|
});
|
|
158
|
-
|
|
158
|
+
P < m && (m = P, v = w);
|
|
159
159
|
}
|
|
160
|
-
if (i == null || i({ confirmations:
|
|
161
|
-
return { confirmations:
|
|
160
|
+
if (i == null || i({ confirmations: m, required: s }), m >= s)
|
|
161
|
+
return { confirmations: m, basicInfo: v };
|
|
162
162
|
}
|
|
163
163
|
} catch (d) {
|
|
164
164
|
if (Xe(d))
|
|
@@ -175,41 +175,41 @@ async function Ut(e) {
|
|
|
175
175
|
)
|
|
176
176
|
);
|
|
177
177
|
}, v = setTimeout(() => {
|
|
178
|
-
|
|
178
|
+
a == null || a.removeEventListener("abort", b), d();
|
|
179
179
|
}, l);
|
|
180
|
-
|
|
180
|
+
a == null || a.addEventListener("abort", b, { once: !0 });
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
const j = 1, Ge = 1;
|
|
185
185
|
function je(e, t) {
|
|
186
|
-
const r = f(t).toLowerCase(),
|
|
187
|
-
if (
|
|
186
|
+
const r = f(t).toLowerCase(), s = e.map((l) => f(l).toLowerCase()).filter((l) => l !== r);
|
|
187
|
+
if (s.length === 0)
|
|
188
188
|
throw new Error(
|
|
189
189
|
"Cannot derive localChallengers: vault keeper set is empty (or contains only the depositor)"
|
|
190
190
|
);
|
|
191
|
-
if (new Set(
|
|
191
|
+
if (new Set(s).size !== s.length)
|
|
192
192
|
throw new Error(
|
|
193
193
|
"Cannot derive localChallengers: duplicate vaultKeeper key — signing context is misconfigured"
|
|
194
194
|
);
|
|
195
|
-
return
|
|
195
|
+
return s;
|
|
196
196
|
}
|
|
197
197
|
function qe(e, t, r) {
|
|
198
198
|
const n = r.map(
|
|
199
199
|
(c) => f(c).toLowerCase()
|
|
200
|
-
),
|
|
201
|
-
if (
|
|
200
|
+
), s = t.filter((c) => n.includes(c));
|
|
201
|
+
if (s.length > 0)
|
|
202
202
|
throw new Error(
|
|
203
|
-
`Cannot validate challenger set: vault keepers and universal challengers overlap (${
|
|
203
|
+
`Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
|
|
204
204
|
);
|
|
205
205
|
const l = [...t, ...n], o = e.map(
|
|
206
206
|
(c) => f(c.challenger_pubkey).toLowerCase()
|
|
207
|
-
),
|
|
208
|
-
if (
|
|
207
|
+
), a = new Set(o);
|
|
208
|
+
if (a.size !== o.length)
|
|
209
209
|
throw new Error(
|
|
210
210
|
"Depositor graph contains duplicate challenger entries in challenger_presign_data"
|
|
211
211
|
);
|
|
212
|
-
const i = new Set(l), u = l.filter((c) => !
|
|
212
|
+
const i = new Set(l), u = l.filter((c) => !a.has(c)), h = o.filter((c) => !i.has(c));
|
|
213
213
|
if (u.length > 0 || h.length > 0)
|
|
214
214
|
throw new Error(
|
|
215
215
|
"Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
|
|
@@ -219,20 +219,20 @@ function Qe(e, t) {
|
|
|
219
219
|
const r = e.ins[t];
|
|
220
220
|
return ne(new Uint8Array(r.hash).slice().reverse());
|
|
221
221
|
}
|
|
222
|
-
function I(e, t, r, n,
|
|
222
|
+
function I(e, t, r, n, s) {
|
|
223
223
|
const l = e.ins[t];
|
|
224
224
|
if (l.index !== 0)
|
|
225
225
|
throw new Error(
|
|
226
|
-
`NoPayout (challenger ${
|
|
226
|
+
`NoPayout (challenger ${s}) input ${t} expected to spend ${n} vout 0, got vout ${l.index}`
|
|
227
227
|
);
|
|
228
|
-
const o = r.getId(),
|
|
229
|
-
if (
|
|
228
|
+
const o = r.getId(), a = Qe(e, t);
|
|
229
|
+
if (a !== o)
|
|
230
230
|
throw new Error(
|
|
231
|
-
`NoPayout (challenger ${
|
|
231
|
+
`NoPayout (challenger ${s}) input ${t} does not reference ${n} (expected txid ${o}, got ${a})`
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
234
|
async function We(e, t, r) {
|
|
235
|
-
const n = [],
|
|
235
|
+
const n = [], s = [], l = [], o = je(
|
|
236
236
|
r.vaultKeeperBtcPubkeys,
|
|
237
237
|
r.depositorBtcPubkey
|
|
238
238
|
);
|
|
@@ -241,7 +241,7 @@ async function We(e, t, r) {
|
|
|
241
241
|
o,
|
|
242
242
|
r.universalChallengerBtcPubkeys
|
|
243
243
|
);
|
|
244
|
-
const
|
|
244
|
+
const a = await $e({
|
|
245
245
|
vaultCoreVersion: r.vaultCoreVersion,
|
|
246
246
|
vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
|
|
247
247
|
vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
|
|
@@ -261,7 +261,7 @@ async function We(e, t, r) {
|
|
|
261
261
|
protocolFeeRate: r.protocolFeeRate,
|
|
262
262
|
councilSize: r.councilMembers.length
|
|
263
263
|
});
|
|
264
|
-
n.push(
|
|
264
|
+
n.push(a.psbtHex), s.push(
|
|
265
265
|
M(
|
|
266
266
|
t,
|
|
267
267
|
j
|
|
@@ -279,7 +279,7 @@ async function We(e, t, r) {
|
|
|
279
279
|
assertTxParsed: u,
|
|
280
280
|
ctx: r
|
|
281
281
|
});
|
|
282
|
-
n.push(d),
|
|
282
|
+
n.push(d), s.push(
|
|
283
283
|
M(
|
|
284
284
|
t,
|
|
285
285
|
j
|
|
@@ -289,14 +289,14 @@ async function We(e, t, r) {
|
|
|
289
289
|
noPayoutIdx: p
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
return { psbtHexes: n, signOptions:
|
|
292
|
+
return { psbtHexes: n, signOptions: s, challengerEntries: l };
|
|
293
293
|
}
|
|
294
294
|
async function Ye(e) {
|
|
295
295
|
const {
|
|
296
296
|
challenger: t,
|
|
297
297
|
challengerPubkey: r,
|
|
298
298
|
claimerPubkey: n,
|
|
299
|
-
localChallengers:
|
|
299
|
+
localChallengers: s,
|
|
300
300
|
assertTxParsed: l,
|
|
301
301
|
ctx: o
|
|
302
302
|
} = e;
|
|
@@ -305,31 +305,31 @@ async function Ye(e) {
|
|
|
305
305
|
r,
|
|
306
306
|
o.network
|
|
307
307
|
);
|
|
308
|
-
const
|
|
308
|
+
const a = A.fromHex(
|
|
309
309
|
f(t.nopayout_tx.tx_hex)
|
|
310
310
|
), i = A.fromHex(
|
|
311
311
|
f(t.challenge_assert_x_tx.tx_hex)
|
|
312
312
|
), u = A.fromHex(
|
|
313
313
|
f(t.challenge_assert_y_tx.tx_hex)
|
|
314
314
|
);
|
|
315
|
-
if (
|
|
315
|
+
if (a.ins.length !== 3)
|
|
316
316
|
throw new Error(
|
|
317
|
-
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${
|
|
317
|
+
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${a.ins.length}`
|
|
318
318
|
);
|
|
319
319
|
I(
|
|
320
|
-
|
|
320
|
+
a,
|
|
321
321
|
0,
|
|
322
322
|
l,
|
|
323
323
|
"Assert",
|
|
324
324
|
r
|
|
325
325
|
), I(
|
|
326
|
-
|
|
326
|
+
a,
|
|
327
327
|
1,
|
|
328
328
|
i,
|
|
329
329
|
"ChallengeAssertX",
|
|
330
330
|
r
|
|
331
331
|
), I(
|
|
332
|
-
|
|
332
|
+
a,
|
|
333
333
|
2,
|
|
334
334
|
u,
|
|
335
335
|
"ChallengeAssertY",
|
|
@@ -350,7 +350,7 @@ async function Ye(e) {
|
|
|
350
350
|
connectorParams: {
|
|
351
351
|
txGraphVersion: o.vaultCoreVersion,
|
|
352
352
|
claimer: n,
|
|
353
|
-
localChallengers:
|
|
353
|
+
localChallengers: s,
|
|
354
354
|
universalChallengers: o.universalChallengerBtcPubkeys,
|
|
355
355
|
timelockAssert: o.timelockAssert,
|
|
356
356
|
councilMembers: o.councilMembers,
|
|
@@ -360,51 +360,51 @@ async function Ye(e) {
|
|
|
360
360
|
}
|
|
361
361
|
function Je(e, t, r) {
|
|
362
362
|
H(e[0]);
|
|
363
|
-
const
|
|
363
|
+
const s = D(
|
|
364
364
|
e[0].returnedPsbtHex,
|
|
365
365
|
r
|
|
366
366
|
);
|
|
367
367
|
F({
|
|
368
368
|
requestedPsbtHex: e[0].requestedPsbtHex,
|
|
369
|
-
signatureHex:
|
|
369
|
+
signatureHex: s,
|
|
370
370
|
signerXOnlyPubkeyHex: r,
|
|
371
371
|
inputIndex: 0
|
|
372
372
|
});
|
|
373
373
|
const l = {};
|
|
374
374
|
for (const o of t) {
|
|
375
375
|
H(e[o.noPayoutIdx]);
|
|
376
|
-
const
|
|
376
|
+
const a = D(
|
|
377
377
|
e[o.noPayoutIdx].returnedPsbtHex,
|
|
378
378
|
r
|
|
379
379
|
);
|
|
380
380
|
F({
|
|
381
381
|
requestedPsbtHex: e[o.noPayoutIdx].requestedPsbtHex,
|
|
382
|
-
signatureHex:
|
|
382
|
+
signatureHex: a,
|
|
383
383
|
signerXOnlyPubkeyHex: r,
|
|
384
384
|
inputIndex: 0
|
|
385
385
|
}), l[o.challengerPubkey] = {
|
|
386
|
-
nopayout_signature:
|
|
386
|
+
nopayout_signature: a
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
389
|
return {
|
|
390
390
|
payout_signatures: {
|
|
391
|
-
payout_signature:
|
|
391
|
+
payout_signature: s
|
|
392
392
|
},
|
|
393
393
|
per_challenger: l
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
396
|
async function Ze(e) {
|
|
397
|
-
const { depositorGraph: t, btcWallet: r, signingContext: n } = e,
|
|
398
|
-
|
|
397
|
+
const { depositorGraph: t, btcWallet: r, signingContext: n } = e, s = await r.getPublicKeyHex(), { depositorPubkey: l } = be(
|
|
398
|
+
s,
|
|
399
399
|
f(n.depositorBtcPubkey)
|
|
400
|
-
), { psbtHexes: o, signOptions:
|
|
400
|
+
), { psbtHexes: o, signOptions: a, challengerEntries: i } = await We(
|
|
401
401
|
t,
|
|
402
|
-
|
|
402
|
+
s,
|
|
403
403
|
n
|
|
404
404
|
), u = await ke(
|
|
405
405
|
r,
|
|
406
406
|
o,
|
|
407
|
-
|
|
407
|
+
a
|
|
408
408
|
), h = o.map((c, p) => ({
|
|
409
409
|
requestedPsbtHex: c,
|
|
410
410
|
returnedPsbtHex: u[p]
|
|
@@ -421,18 +421,18 @@ async function ue(e) {
|
|
|
421
421
|
statusReader: t,
|
|
422
422
|
peginTxid: r,
|
|
423
423
|
targetStatuses: n,
|
|
424
|
-
timeoutMs:
|
|
424
|
+
timeoutMs: s,
|
|
425
425
|
pollIntervalMs: l = et,
|
|
426
426
|
signal: o
|
|
427
|
-
} = e,
|
|
427
|
+
} = e, a = Date.now();
|
|
428
428
|
for (; ; ) {
|
|
429
429
|
if (o != null && o.aborted)
|
|
430
430
|
throw new Error(
|
|
431
431
|
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
432
432
|
);
|
|
433
|
-
if (Date.now() -
|
|
433
|
+
if (Date.now() - a >= s)
|
|
434
434
|
throw new Error(
|
|
435
|
-
`Polling timeout after ${
|
|
435
|
+
`Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
436
436
|
);
|
|
437
437
|
try {
|
|
438
438
|
const i = await t.getPeginStatus(
|
|
@@ -500,8 +500,8 @@ function ot(e, t) {
|
|
|
500
500
|
];
|
|
501
501
|
for (const [i, u, h] of n)
|
|
502
502
|
u !== h && r(i, u, h);
|
|
503
|
-
const
|
|
504
|
-
const h =
|
|
503
|
+
const s = (i) => i.map(E).sort(), l = (i, u) => {
|
|
504
|
+
const h = s(i), c = s(u);
|
|
505
505
|
return h.length === c.length && h.every((p, d) => p === c[d]);
|
|
506
506
|
};
|
|
507
507
|
l(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
|
|
@@ -516,17 +516,17 @@ function ot(e, t) {
|
|
|
516
516
|
e.universalChallengerBtcPubkeys.join(","),
|
|
517
517
|
t.universalChallengerBtcPubkeys.join(",")
|
|
518
518
|
);
|
|
519
|
-
const o = E(t.vaultProviderBtcPubkey),
|
|
519
|
+
const o = E(t.vaultProviderBtcPubkey), a = e.vaults.map(
|
|
520
520
|
(i) => E(i.vaultProviderBtcPubkey)
|
|
521
521
|
);
|
|
522
|
-
|
|
522
|
+
a.includes(o) || r(
|
|
523
523
|
"vaults[].vaultProviderBtcPubkey",
|
|
524
|
-
|
|
524
|
+
a.join(",") || "<no vaults>",
|
|
525
525
|
t.vaultProviderBtcPubkey
|
|
526
526
|
);
|
|
527
527
|
}
|
|
528
|
-
function
|
|
529
|
-
const
|
|
528
|
+
function st(e, t, r, n) {
|
|
529
|
+
const s = E(n), l = [
|
|
530
530
|
E(t),
|
|
531
531
|
...r.map(E)
|
|
532
532
|
], o = new Set(l);
|
|
@@ -534,16 +534,16 @@ function at(e, t, r, n) {
|
|
|
534
534
|
throw new Error(
|
|
535
535
|
"Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
|
|
536
536
|
);
|
|
537
|
-
if (o.has(
|
|
537
|
+
if (o.has(s))
|
|
538
538
|
throw new Error(
|
|
539
539
|
"Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
|
|
540
540
|
);
|
|
541
|
-
const
|
|
541
|
+
const a = e.map(
|
|
542
542
|
(p) => E(p.claimer_pubkey)
|
|
543
543
|
);
|
|
544
|
-
if (new Set(
|
|
544
|
+
if (new Set(a).size !== a.length)
|
|
545
545
|
throw new Error("Presign response contains duplicate claimer entries");
|
|
546
|
-
const i =
|
|
546
|
+
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));
|
|
547
547
|
if (h.length > 0 || c.length > 0)
|
|
548
548
|
throw new Error(
|
|
549
549
|
"Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (h.length > 0 ? ` (missing: ${h.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
|
|
@@ -570,87 +570,87 @@ function q(e, t) {
|
|
|
570
570
|
vpCommissionScriptPubKey: t.vpCommissionScriptPubKey
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
|
-
async function
|
|
574
|
-
const
|
|
573
|
+
async function at(e, t, r, n) {
|
|
574
|
+
const s = new xe({
|
|
575
575
|
network: t.network,
|
|
576
576
|
btcWallet: e
|
|
577
577
|
}), l = r.length;
|
|
578
578
|
n == null || n(0, l);
|
|
579
579
|
let o;
|
|
580
|
-
if (
|
|
581
|
-
o = (await
|
|
580
|
+
if (s.supportsBatchSigning())
|
|
581
|
+
o = (await s.signPayoutTransactionsBatch(
|
|
582
582
|
r.map((u) => q(u, t))
|
|
583
583
|
)).map((u) => u.payoutSignature);
|
|
584
584
|
else {
|
|
585
585
|
o = [];
|
|
586
586
|
for (let i = 0; i < r.length; i++) {
|
|
587
587
|
n == null || n(i, l);
|
|
588
|
-
const u = await
|
|
588
|
+
const u = await s.signPayoutTransaction(
|
|
589
589
|
q(r[i], t)
|
|
590
590
|
);
|
|
591
591
|
o.push(u.signature);
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
|
-
const
|
|
594
|
+
const a = {};
|
|
595
595
|
for (let i = 0; i < r.length; i++)
|
|
596
|
-
|
|
596
|
+
a[r[i].claimerPubkeyXOnly] = {
|
|
597
597
|
payout_signature: o[i]
|
|
598
598
|
};
|
|
599
|
-
return n == null || n(l, l),
|
|
599
|
+
return n == null || n(l, l), a;
|
|
600
600
|
}
|
|
601
601
|
async function zt(e) {
|
|
602
602
|
const {
|
|
603
603
|
statusReader: t,
|
|
604
604
|
presignClient: r,
|
|
605
605
|
btcWallet: n,
|
|
606
|
-
peginTxid:
|
|
606
|
+
peginTxid: s,
|
|
607
607
|
depositorPk: l,
|
|
608
608
|
signingContext: o,
|
|
609
|
-
depositTerms:
|
|
609
|
+
depositTerms: a,
|
|
610
610
|
timeoutMs: i = tt,
|
|
611
611
|
signal: u,
|
|
612
612
|
onProgress: h
|
|
613
613
|
} = e, c = await ue({
|
|
614
614
|
statusReader: t,
|
|
615
|
-
peginTxid:
|
|
615
|
+
peginTxid: s,
|
|
616
616
|
targetStatuses: rt,
|
|
617
617
|
timeoutMs: i,
|
|
618
618
|
signal: u
|
|
619
619
|
});
|
|
620
620
|
if (le.has(c))
|
|
621
621
|
return;
|
|
622
|
-
if (u == null || u.throwIfAborted(),
|
|
623
|
-
if (!
|
|
622
|
+
if (u == null || u.throwIfAborted(), a !== void 0 && ot(a, o), Ee(n)) {
|
|
623
|
+
if (!a)
|
|
624
624
|
throw new Error(
|
|
625
|
-
"runDepositorPresignFlow: this wallet requires approved deposit terms but none were provided. Fresh deposits must pass PreparePeginResult.depositTerms; resume
|
|
625
|
+
"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)."
|
|
626
626
|
);
|
|
627
|
-
await n.approveDepositTerms(
|
|
627
|
+
await n.approveDepositTerms(a);
|
|
628
628
|
}
|
|
629
629
|
const p = await r.requestDepositorPresignTransactions(
|
|
630
630
|
{
|
|
631
|
-
pegin_txid:
|
|
631
|
+
pegin_txid: s,
|
|
632
632
|
depositor_pk: l
|
|
633
633
|
},
|
|
634
634
|
u
|
|
635
635
|
);
|
|
636
636
|
u == null || u.throwIfAborted();
|
|
637
637
|
const d = E(l);
|
|
638
|
-
|
|
638
|
+
st(
|
|
639
639
|
p.txs,
|
|
640
640
|
o.vaultProviderBtcPubkey,
|
|
641
641
|
o.vaultKeeperBtcPubkeys,
|
|
642
642
|
l
|
|
643
643
|
);
|
|
644
644
|
const g = p.txs.filter(
|
|
645
|
-
(
|
|
646
|
-
), b = nt(g), v = await
|
|
645
|
+
(P) => E(P.claimer_pubkey) !== d
|
|
646
|
+
), b = nt(g), v = await at(
|
|
647
647
|
n,
|
|
648
648
|
o,
|
|
649
649
|
b,
|
|
650
650
|
h
|
|
651
651
|
);
|
|
652
652
|
u == null || u.throwIfAborted();
|
|
653
|
-
const
|
|
653
|
+
const m = await Ze({
|
|
654
654
|
depositorGraph: p.depositor_graph,
|
|
655
655
|
btcWallet: n,
|
|
656
656
|
signingContext: {
|
|
@@ -673,12 +673,12 @@ async function zt(e) {
|
|
|
673
673
|
});
|
|
674
674
|
u == null || u.throwIfAborted();
|
|
675
675
|
const w = { ...v };
|
|
676
|
-
w[f(l)] =
|
|
676
|
+
w[f(l)] = m.payout_signatures, await r.submitDepositorPresignatures(
|
|
677
677
|
{
|
|
678
|
-
pegin_txid:
|
|
678
|
+
pegin_txid: s,
|
|
679
679
|
depositor_pk: l,
|
|
680
680
|
signatures: w,
|
|
681
|
-
depositor_claimer_presignatures:
|
|
681
|
+
depositor_claimer_presignatures: m
|
|
682
682
|
},
|
|
683
683
|
u
|
|
684
684
|
);
|
|
@@ -692,26 +692,26 @@ async function Xt(e) {
|
|
|
692
692
|
statusReader: t,
|
|
693
693
|
wotsSubmitter: r,
|
|
694
694
|
peginTxid: n,
|
|
695
|
-
depositorPk:
|
|
695
|
+
depositorPk: s,
|
|
696
696
|
wotsPublicKeys: l,
|
|
697
697
|
timeoutMs: o = it,
|
|
698
|
-
signal:
|
|
698
|
+
signal: a
|
|
699
699
|
} = e;
|
|
700
|
-
|
|
700
|
+
a == null || a.throwIfAborted();
|
|
701
701
|
const i = await ue({
|
|
702
702
|
statusReader: t,
|
|
703
703
|
peginTxid: n,
|
|
704
704
|
targetStatuses: ut,
|
|
705
705
|
timeoutMs: o,
|
|
706
|
-
signal:
|
|
706
|
+
signal: a
|
|
707
707
|
});
|
|
708
|
-
oe.has(i) || (
|
|
708
|
+
oe.has(i) || (a == null || a.throwIfAborted(), await r.submitDepositorWotsKey(
|
|
709
709
|
{
|
|
710
710
|
pegin_txid: n,
|
|
711
|
-
depositor_pk:
|
|
711
|
+
depositor_pk: s,
|
|
712
712
|
wots_public_keys: l
|
|
713
713
|
},
|
|
714
|
-
|
|
714
|
+
a
|
|
715
715
|
));
|
|
716
716
|
}
|
|
717
717
|
function V(e) {
|
|
@@ -742,30 +742,30 @@ async function Gt(e) {
|
|
|
742
742
|
vaultProviderEthAddress: t,
|
|
743
743
|
hintBtcPubkey: r,
|
|
744
744
|
registrationBtcPubkey: n,
|
|
745
|
-
readCurrentOperationBtcPubkey:
|
|
745
|
+
readCurrentOperationBtcPubkey: s,
|
|
746
746
|
context: l
|
|
747
747
|
} = e;
|
|
748
748
|
if (!r) return;
|
|
749
749
|
const o = x(r);
|
|
750
750
|
if (o === x(n)) return;
|
|
751
|
-
const
|
|
752
|
-
await
|
|
751
|
+
const a = x(
|
|
752
|
+
await s()
|
|
753
753
|
);
|
|
754
|
-
if (o !==
|
|
754
|
+
if (o !== a)
|
|
755
755
|
throw new Error(
|
|
756
756
|
`Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${l ? ` ${l}` : ""}`
|
|
757
757
|
);
|
|
758
758
|
}
|
|
759
759
|
function N(e, t, r) {
|
|
760
|
-
const n = `${e} operation key (admin=${t.ethAddress})`,
|
|
760
|
+
const n = `${e} operation key (admin=${t.ethAddress})`, s = X(
|
|
761
761
|
t.btcPubKey,
|
|
762
762
|
`${e} roster key (admin=${t.ethAddress})`
|
|
763
763
|
), l = X(r, n);
|
|
764
764
|
return {
|
|
765
765
|
adminAddress: t.ethAddress,
|
|
766
|
-
genesisBtcPubkey:
|
|
766
|
+
genesisBtcPubkey: s,
|
|
767
767
|
operationBtcPubkey: l,
|
|
768
|
-
rotated: l !==
|
|
768
|
+
rotated: l !== s
|
|
769
769
|
};
|
|
770
770
|
}
|
|
771
771
|
function ct(e) {
|
|
@@ -791,21 +791,21 @@ function ce(e, t, r) {
|
|
|
791
791
|
btcPubKey: e.vaultProviderGenesisBtcPubkey
|
|
792
792
|
},
|
|
793
793
|
t.vaultProvider
|
|
794
|
-
),
|
|
795
|
-
(o,
|
|
794
|
+
), s = e.vaultKeepers.map(
|
|
795
|
+
(o, a) => N("vault keeper", o, t.vaultKeepers[a])
|
|
796
796
|
), l = e.universalChallengers.map(
|
|
797
|
-
(o,
|
|
797
|
+
(o, a) => N("universal challenger", o, t.universalChallengers[a])
|
|
798
798
|
);
|
|
799
799
|
return ct([
|
|
800
800
|
n,
|
|
801
|
-
...
|
|
801
|
+
...s,
|
|
802
802
|
...l
|
|
803
803
|
]), {
|
|
804
804
|
vaultProvider: n,
|
|
805
|
-
vaultKeepers:
|
|
805
|
+
vaultKeepers: s,
|
|
806
806
|
universalChallengers: l,
|
|
807
807
|
// Derived from the pairs, never the reverse — see ParticipantKeySet.
|
|
808
|
-
vaultKeeperOperationKeysSorted:
|
|
808
|
+
vaultKeeperOperationKeysSorted: s.map((o) => o.operationBtcPubkey).sort(),
|
|
809
809
|
universalChallengerOperationKeysSorted: l.map((o) => o.operationBtcPubkey).sort(),
|
|
810
810
|
resolvedAt: r,
|
|
811
811
|
query: e
|
|
@@ -833,10 +833,10 @@ async function jt(e) {
|
|
|
833
833
|
vaultRegistryReader: t,
|
|
834
834
|
vaultKeeperReader: r,
|
|
835
835
|
universalChallengerReader: n,
|
|
836
|
-
vaultProviderEthAddress:
|
|
836
|
+
vaultProviderEthAddress: s,
|
|
837
837
|
applicationEntryPoint: l,
|
|
838
838
|
expectedVaultProviderBtcPubkey: o,
|
|
839
|
-
expectedVaultKeeperBtcPubkeys:
|
|
839
|
+
expectedVaultKeeperBtcPubkeys: a,
|
|
840
840
|
expectedUniversalChallengerBtcPubkeys: i,
|
|
841
841
|
operationKeyReader: u,
|
|
842
842
|
onIndexerServingOperationKeys: h,
|
|
@@ -847,7 +847,7 @@ async function jt(e) {
|
|
|
847
847
|
g
|
|
848
848
|
] = await Promise.all([
|
|
849
849
|
t.getVaultProviderGenesisBtcPubKey(
|
|
850
|
-
|
|
850
|
+
s
|
|
851
851
|
),
|
|
852
852
|
r.getCurrentVaultKeepersVersion(l),
|
|
853
853
|
n.getLatestUniversalChallengersVersion()
|
|
@@ -859,20 +859,20 @@ async function jt(e) {
|
|
|
859
859
|
n.getUniversalChallengersByVersion(
|
|
860
860
|
g
|
|
861
861
|
)
|
|
862
|
-
]),
|
|
862
|
+
]), m = {
|
|
863
863
|
vaultProvider: x(p),
|
|
864
864
|
vaultKeepers: Y(b.map((k) => k.btcPubKey)),
|
|
865
865
|
universalChallengers: Y(v.map((k) => k.btcPubKey))
|
|
866
866
|
}, w = await ht({
|
|
867
867
|
operationKeyReader: u,
|
|
868
868
|
query: {
|
|
869
|
-
vaultProviderEthAddress:
|
|
869
|
+
vaultProviderEthAddress: s,
|
|
870
870
|
vaultProviderGenesisBtcPubkey: `0x${p}`,
|
|
871
871
|
applicationEntryPoint: l,
|
|
872
872
|
vaultKeepers: b,
|
|
873
873
|
universalChallengers: v
|
|
874
874
|
}
|
|
875
|
-
}),
|
|
875
|
+
}), P = {
|
|
876
876
|
vaultProvider: w.vaultProvider.operationBtcPubkey,
|
|
877
877
|
vaultKeepers: [...w.vaultKeeperOperationKeysSorted],
|
|
878
878
|
universalChallengers: [
|
|
@@ -880,20 +880,20 @@ async function jt(e) {
|
|
|
880
880
|
]
|
|
881
881
|
}, S = lt(
|
|
882
882
|
o,
|
|
883
|
-
|
|
884
|
-
|
|
883
|
+
m.vaultProvider,
|
|
884
|
+
P.vaultProvider
|
|
885
885
|
), R = Q(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
886
|
+
a,
|
|
887
|
+
m.vaultKeepers,
|
|
888
|
+
P.vaultKeepers
|
|
889
889
|
), _ = Q(
|
|
890
890
|
i,
|
|
891
|
-
|
|
892
|
-
|
|
891
|
+
m.universalChallengers,
|
|
892
|
+
P.universalChallengers
|
|
893
893
|
);
|
|
894
894
|
if (!V(S))
|
|
895
895
|
throw new Error(
|
|
896
|
-
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${
|
|
896
|
+
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
|
|
897
897
|
);
|
|
898
898
|
if (!V(R))
|
|
899
899
|
throw new Error(
|
|
@@ -905,18 +905,18 @@ async function jt(e) {
|
|
|
905
905
|
);
|
|
906
906
|
const y = [S, R, _], ve = y.some((k) => k.registration && !k.operation), z = y.some((k) => k.operation && !k.registration);
|
|
907
907
|
if (ve && z) {
|
|
908
|
-
const k = `Indexer participant hints are internally inconsistent for vault provider ${
|
|
908
|
+
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.`;
|
|
909
909
|
throw c == null || c(k), new Error(`${k} Refresh and try again.`);
|
|
910
910
|
}
|
|
911
911
|
return z && (h == null || h(
|
|
912
|
-
`Indexer is serving rotated operation keys for vault provider ${
|
|
912
|
+
`Indexer is serving rotated operation keys for vault provider ${s}`
|
|
913
913
|
)), {
|
|
914
|
-
vaultProviderBtcPubkeyXOnly:
|
|
915
|
-
vaultKeeperBtcPubkeysSorted:
|
|
916
|
-
universalChallengerBtcPubkeysSorted:
|
|
914
|
+
vaultProviderBtcPubkeyXOnly: P.vaultProvider,
|
|
915
|
+
vaultKeeperBtcPubkeysSorted: P.vaultKeepers,
|
|
916
|
+
universalChallengerBtcPubkeysSorted: P.universalChallengers,
|
|
917
917
|
expectedAppVaultKeepersVersion: d,
|
|
918
918
|
expectedUniversalChallengersVersion: g,
|
|
919
|
-
registrationKeys:
|
|
919
|
+
registrationKeys: m,
|
|
920
920
|
participantKeys: w
|
|
921
921
|
};
|
|
922
922
|
}
|
|
@@ -928,11 +928,11 @@ function qt(e) {
|
|
|
928
928
|
amountSats: t,
|
|
929
929
|
minDeposit: r,
|
|
930
930
|
maxDeposit: n,
|
|
931
|
-
btcBalance:
|
|
931
|
+
btcBalance: s,
|
|
932
932
|
estimatedFeeSats: l,
|
|
933
933
|
depositorClaimValue: o
|
|
934
934
|
} = e;
|
|
935
|
-
return !(t <= 0n || t < r || n && n > 0n && t > n || l == null || o == null || t + l + o >
|
|
935
|
+
return !(t <= 0n || t < r || n && n > 0n && t > n || l == null || o == null || t + l + o > s);
|
|
936
936
|
}
|
|
937
937
|
function Qt(e, t, r) {
|
|
938
938
|
return e <= 0n ? {
|
|
@@ -963,10 +963,10 @@ function Yt(e, t) {
|
|
|
963
963
|
error: "At least one vault provider must be selected"
|
|
964
964
|
};
|
|
965
965
|
const r = t.map(
|
|
966
|
-
(
|
|
966
|
+
(s) => s.toLowerCase()
|
|
967
967
|
);
|
|
968
968
|
return e.filter(
|
|
969
|
-
(
|
|
969
|
+
(s) => !r.includes(s.toLowerCase())
|
|
970
970
|
).length > 0 ? {
|
|
971
971
|
valid: !1,
|
|
972
972
|
error: "Invalid vault provider selected"
|
|
@@ -979,21 +979,21 @@ function gt(e, t, r) {
|
|
|
979
979
|
error: "At least one vault amount required"
|
|
980
980
|
};
|
|
981
981
|
for (let n = 0; n < e.length; n++) {
|
|
982
|
-
const
|
|
983
|
-
if (
|
|
982
|
+
const s = e[n];
|
|
983
|
+
if (s <= 0n)
|
|
984
984
|
return {
|
|
985
985
|
valid: !1,
|
|
986
986
|
error: `Vault ${n + 1} amount must be positive`
|
|
987
987
|
};
|
|
988
|
-
if (t &&
|
|
988
|
+
if (t && s < t)
|
|
989
989
|
return {
|
|
990
990
|
valid: !1,
|
|
991
|
-
error: `Vault ${n + 1} amount ${C(
|
|
991
|
+
error: `Vault ${n + 1} amount ${C(s)} BTC is below minimum deposit ${C(t)} BTC`
|
|
992
992
|
};
|
|
993
|
-
if (r &&
|
|
993
|
+
if (r && s > r)
|
|
994
994
|
return {
|
|
995
995
|
valid: !1,
|
|
996
|
-
error: `Vault ${n + 1} amount ${C(
|
|
996
|
+
error: `Vault ${n + 1} amount ${C(s)} BTC exceeds maximum deposit ${C(r)} BTC`
|
|
997
997
|
};
|
|
998
998
|
}
|
|
999
999
|
return { valid: !0 };
|
|
@@ -1011,13 +1011,13 @@ function vt(e) {
|
|
|
1011
1011
|
"No vault keepers available. The system requires at least one vault keeper to create a deposit."
|
|
1012
1012
|
);
|
|
1013
1013
|
}
|
|
1014
|
-
function
|
|
1014
|
+
function mt(e) {
|
|
1015
1015
|
if (!e || e.length === 0)
|
|
1016
1016
|
throw new Error(
|
|
1017
1017
|
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
1018
1018
|
);
|
|
1019
1019
|
}
|
|
1020
|
-
function
|
|
1020
|
+
function Pt(e) {
|
|
1021
1021
|
if (e.length === 0)
|
|
1022
1022
|
throw new Error("No spendable UTXOs available");
|
|
1023
1023
|
}
|
|
@@ -1026,21 +1026,21 @@ function Jt(e) {
|
|
|
1026
1026
|
vaultAmounts: t,
|
|
1027
1027
|
confirmedUTXOs: r,
|
|
1028
1028
|
vaultProviderBtcPubkey: n,
|
|
1029
|
-
vaultKeeperBtcPubkeys:
|
|
1029
|
+
vaultKeeperBtcPubkeys: s,
|
|
1030
1030
|
universalChallengerBtcPubkeys: l,
|
|
1031
1031
|
minDeposit: o,
|
|
1032
|
-
maxDeposit:
|
|
1032
|
+
maxDeposit: a
|
|
1033
1033
|
} = e, i = gt(
|
|
1034
1034
|
t,
|
|
1035
1035
|
o,
|
|
1036
|
-
|
|
1036
|
+
a
|
|
1037
1037
|
);
|
|
1038
1038
|
if (!i.valid)
|
|
1039
1039
|
throw new Error(i.error);
|
|
1040
1040
|
const u = ft(n);
|
|
1041
1041
|
if (!u.valid)
|
|
1042
1042
|
throw new Error(u.error);
|
|
1043
|
-
vt(
|
|
1043
|
+
vt(s), mt(l), Pt(r);
|
|
1044
1044
|
}
|
|
1045
1045
|
class he extends Error {
|
|
1046
1046
|
constructor(t) {
|
|
@@ -1051,12 +1051,12 @@ function Zt(e) {
|
|
|
1051
1051
|
return e instanceof he || e instanceof Error && e.name === "ParticipantKeyDriftError";
|
|
1052
1052
|
}
|
|
1053
1053
|
function J(e, t, r) {
|
|
1054
|
-
return t.length === r.length && t.every((n,
|
|
1054
|
+
return t.length === r.length && t.every((n, s) => n === r[s]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
|
|
1055
1055
|
}
|
|
1056
1056
|
async function er(e) {
|
|
1057
|
-
const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: n, expected:
|
|
1057
|
+
const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: n, expected: s } = e, l = s.query;
|
|
1058
1058
|
if (n.length === 0) return;
|
|
1059
|
-
const o = await t.getVaultKeyEpochsBatch(n),
|
|
1059
|
+
const o = await t.getVaultKeyEpochsBatch(n), a = [];
|
|
1060
1060
|
for (const [i, u] of o.entries()) {
|
|
1061
1061
|
const h = n[i];
|
|
1062
1062
|
let c;
|
|
@@ -1067,30 +1067,30 @@ async function er(e) {
|
|
|
1067
1067
|
epochs: u
|
|
1068
1068
|
});
|
|
1069
1069
|
} catch (g) {
|
|
1070
|
-
|
|
1070
|
+
a.push(
|
|
1071
1071
|
`vault ${h}: could not resolve participants at frozen epochs (vp=${u.vpKeyEpoch}, keeper=${u.appKeeperKeyEpoch}, uc=${u.ucKeyEpoch}): ${g.message}`
|
|
1072
1072
|
);
|
|
1073
1073
|
continue;
|
|
1074
1074
|
}
|
|
1075
|
-
c.vaultProvider.operationBtcPubkey !==
|
|
1076
|
-
`vault ${h}: vault provider key expected ${
|
|
1075
|
+
c.vaultProvider.operationBtcPubkey !== s.vaultProvider.operationBtcPubkey && a.push(
|
|
1076
|
+
`vault ${h}: vault provider key expected ${s.vaultProvider.operationBtcPubkey}, got ${c.vaultProvider.operationBtcPubkey}`
|
|
1077
1077
|
);
|
|
1078
1078
|
const p = J(
|
|
1079
1079
|
`vault ${h}: vault keeper keys`,
|
|
1080
|
-
|
|
1080
|
+
s.vaultKeeperOperationKeysSorted,
|
|
1081
1081
|
c.vaultKeeperOperationKeysSorted
|
|
1082
1082
|
);
|
|
1083
|
-
p &&
|
|
1083
|
+
p && a.push(p);
|
|
1084
1084
|
const d = J(
|
|
1085
1085
|
`vault ${h}: universal challenger keys`,
|
|
1086
|
-
|
|
1086
|
+
s.universalChallengerOperationKeysSorted,
|
|
1087
1087
|
c.universalChallengerOperationKeysSorted
|
|
1088
1088
|
);
|
|
1089
|
-
d &&
|
|
1089
|
+
d && a.push(d);
|
|
1090
1090
|
}
|
|
1091
|
-
if (
|
|
1091
|
+
if (a.length > 0)
|
|
1092
1092
|
throw new he(
|
|
1093
|
-
`Aborting BTC broadcast: participant operation keys changed during registration (${
|
|
1093
|
+
`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.`
|
|
1094
1094
|
);
|
|
1095
1095
|
}
|
|
1096
1096
|
class pe extends Error {
|
|
@@ -1106,16 +1106,16 @@ async function rr(e) {
|
|
|
1106
1106
|
vaultRegistryReader: t,
|
|
1107
1107
|
vaultIds: r,
|
|
1108
1108
|
expectedOffchainParamsVersion: n,
|
|
1109
|
-
expectedAppVaultKeepersVersion:
|
|
1109
|
+
expectedAppVaultKeepersVersion: s,
|
|
1110
1110
|
expectedUniversalChallengersVersion: l,
|
|
1111
1111
|
expectedVaultCoreVersion: o
|
|
1112
|
-
} = e,
|
|
1113
|
-
if (
|
|
1112
|
+
} = e, a = await t.getProtocolInfoBatch(r), i = [];
|
|
1113
|
+
if (a.forEach((u, h) => {
|
|
1114
1114
|
const c = r[h];
|
|
1115
1115
|
u.offchainParamsVersion !== n && i.push(
|
|
1116
1116
|
`vault ${c}: offchainParams expected v${n}, got v${u.offchainParamsVersion}`
|
|
1117
|
-
), u.appVaultKeepersVersion !==
|
|
1118
|
-
`vault ${c}: appVaultKeepers expected v${
|
|
1117
|
+
), u.appVaultKeepersVersion !== s && i.push(
|
|
1118
|
+
`vault ${c}: appVaultKeepers expected v${s}, got v${u.appVaultKeepersVersion}`
|
|
1119
1119
|
), u.universalChallengersVersion !== l && i.push(
|
|
1120
1120
|
`vault ${c}: universalChallengers expected v${l}, got v${u.universalChallengersVersion}`
|
|
1121
1121
|
), u.vaultCoreVersion !== o && i.push(
|
|
@@ -1149,7 +1149,7 @@ class bt extends Error {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
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;
|
|
1152
|
-
function
|
|
1152
|
+
function sr(e) {
|
|
1153
1153
|
if (!Number.isFinite(e) || e <= 0)
|
|
1154
1154
|
throw new Error(
|
|
1155
1155
|
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
@@ -1258,32 +1258,32 @@ function St(e) {
|
|
|
1258
1258
|
}
|
|
1259
1259
|
return t.extractTransaction().toHex();
|
|
1260
1260
|
}
|
|
1261
|
-
async function
|
|
1261
|
+
async function ar(e) {
|
|
1262
1262
|
const {
|
|
1263
1263
|
vaultId: t,
|
|
1264
1264
|
readVault: r,
|
|
1265
1265
|
readPrePeginContext: n,
|
|
1266
|
-
feeRate:
|
|
1266
|
+
feeRate: s,
|
|
1267
1267
|
signPsbt: l,
|
|
1268
1268
|
broadcastTx: o,
|
|
1269
|
-
signal:
|
|
1269
|
+
signal: a
|
|
1270
1270
|
} = e;
|
|
1271
|
-
|
|
1271
|
+
a == null || a.throwIfAborted(), L(t, "vaultId");
|
|
1272
1272
|
const i = await r();
|
|
1273
|
-
Tt(i),
|
|
1273
|
+
Tt(i), a == null || a.throwIfAborted();
|
|
1274
1274
|
const u = await n(i);
|
|
1275
|
-
if (Ct(u),
|
|
1276
|
-
throw new Error(`feeRate must be a positive number, got ${
|
|
1277
|
-
if (
|
|
1275
|
+
if (Ct(u), a == null || a.throwIfAborted(), !Number.isFinite(s) || s <= 0)
|
|
1276
|
+
throw new Error(`feeRate must be a positive number, got ${s}`);
|
|
1277
|
+
if (s > Z)
|
|
1278
1278
|
throw new Error(
|
|
1279
|
-
`feeRate ${
|
|
1279
|
+
`feeRate ${s} sat/vB exceeds refund safety cap ${Z} sat/vB; refusing to sign refund.`
|
|
1280
1280
|
);
|
|
1281
|
-
const h = BigInt(Math.ceil(
|
|
1281
|
+
const h = BigInt(Math.ceil(s * fe)), c = i.amount * ee / te;
|
|
1282
1282
|
if (h > c)
|
|
1283
1283
|
throw new Error(
|
|
1284
1284
|
`Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${ee}/${te} of vault.amount=${i.amount}); refusing to sign refund.`
|
|
1285
1285
|
);
|
|
1286
|
-
|
|
1286
|
+
a == null || a.throwIfAborted();
|
|
1287
1287
|
const p = U(
|
|
1288
1288
|
i.depositorBtcPubkey
|
|
1289
1289
|
), d = f(i.unsignedPrePeginTxHex), g = Te(d);
|
|
@@ -1304,7 +1304,7 @@ async function sr(e) {
|
|
|
1304
1304
|
throw new Error(
|
|
1305
1305
|
`Funded Pre-PegIn tx has ${v.outs.length} outputs but batch requires at least ${i.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
|
|
1306
1306
|
);
|
|
1307
|
-
const { psbtHex:
|
|
1307
|
+
const { psbtHex: m } = await Ve({
|
|
1308
1308
|
prePeginParams: {
|
|
1309
1309
|
vaultCoreVersion: i.vaultCoreVersion,
|
|
1310
1310
|
depositorPubkey: p,
|
|
@@ -1337,28 +1337,28 @@ async function sr(e) {
|
|
|
1337
1337
|
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
1338
1338
|
hashlock: f(i.hashlock)
|
|
1339
1339
|
});
|
|
1340
|
-
|
|
1340
|
+
a == null || a.throwIfAborted();
|
|
1341
1341
|
const w = M(
|
|
1342
1342
|
i.depositorBtcPubkey,
|
|
1343
1343
|
Et
|
|
1344
|
-
),
|
|
1344
|
+
), P = await l(m, w);
|
|
1345
1345
|
H({
|
|
1346
|
-
requestedPsbtHex:
|
|
1347
|
-
returnedPsbtHex:
|
|
1346
|
+
requestedPsbtHex: m,
|
|
1347
|
+
returnedPsbtHex: P
|
|
1348
1348
|
});
|
|
1349
1349
|
const S = 0, R = D(
|
|
1350
|
-
|
|
1350
|
+
P,
|
|
1351
1351
|
p,
|
|
1352
1352
|
S
|
|
1353
1353
|
);
|
|
1354
1354
|
F({
|
|
1355
|
-
requestedPsbtHex:
|
|
1355
|
+
requestedPsbtHex: m,
|
|
1356
1356
|
signatureHex: R,
|
|
1357
1357
|
signerXOnlyPubkeyHex: p,
|
|
1358
1358
|
inputIndex: S
|
|
1359
1359
|
});
|
|
1360
|
-
const _ = St(
|
|
1361
|
-
|
|
1360
|
+
const _ = St(P);
|
|
1361
|
+
a == null || a.throwIfAborted();
|
|
1362
1362
|
try {
|
|
1363
1363
|
return await o(_);
|
|
1364
1364
|
} catch (y) {
|
|
@@ -1374,8 +1374,8 @@ export {
|
|
|
1374
1374
|
nr as F,
|
|
1375
1375
|
or as G,
|
|
1376
1376
|
bt as H,
|
|
1377
|
-
|
|
1378
|
-
|
|
1377
|
+
ar as I,
|
|
1378
|
+
sr as J,
|
|
1379
1379
|
te as K,
|
|
1380
1380
|
ee as L,
|
|
1381
1381
|
Z as M,
|
|
@@ -1384,7 +1384,7 @@ export {
|
|
|
1384
1384
|
pe as R,
|
|
1385
1385
|
Ft as a,
|
|
1386
1386
|
Mt as b,
|
|
1387
|
-
|
|
1387
|
+
ae as c,
|
|
1388
1388
|
ie as d,
|
|
1389
1389
|
Lt as e,
|
|
1390
1390
|
Xt as f,
|
|
@@ -1409,4 +1409,4 @@ export {
|
|
|
1409
1409
|
Gt as y,
|
|
1410
1410
|
V as z
|
|
1411
1411
|
};
|
|
1412
|
-
//# sourceMappingURL=buildAndBroadcastRefund-
|
|
1412
|
+
//# sourceMappingURL=buildAndBroadcastRefund-C4LiPATK.js.map
|