@babylonlabs-io/ts-sdk 0.33.4 → 0.33.5
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-B332dykQ.cjs +2 -0
- package/dist/buildAndBroadcastRefund-B332dykQ.cjs.map +1 -0
- package/dist/{buildAndBroadcastRefund-D_QlvCsw.js → buildAndBroadcastRefund-CPjXNaMi.js} +126 -121
- package/dist/buildAndBroadcastRefund-CPjXNaMi.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +89 -87
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +23 -21
- package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/api.d.ts +13 -4
- package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts +45 -0
- package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts +55 -0
- package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/index.d.ts +2 -0
- package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +3 -3
- package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/types.d.ts +68 -24
- package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/validators.d.ts +12 -2
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +73 -71
- package/dist/tbv/core/services/deposit/waitForPeginStatus.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/core/services/pegout/state.d.ts +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +73 -71
- package/dist/types-DnyyBNcC.cjs +2 -0
- package/dist/types-DnyyBNcC.cjs.map +1 -0
- package/dist/{types-ByW6nSLj.js → types-TiIjyo2b.js} +32 -30
- package/dist/types-TiIjyo2b.js.map +1 -0
- package/dist/{vault-registry-reader-WiNVOsnD.js → vault-registry-reader-BDFpXeH7.js} +425 -263
- package/dist/vault-registry-reader-BDFpXeH7.js.map +1 -0
- package/dist/vault-registry-reader-ejm2UYzk.cjs +2 -0
- package/dist/vault-registry-reader-ejm2UYzk.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/buildAndBroadcastRefund-CIPPpchL.cjs +0 -2
- package/dist/buildAndBroadcastRefund-CIPPpchL.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-D_QlvCsw.js.map +0 -1
- package/dist/types-ByW6nSLj.js.map +0 -1
- package/dist/types-CfCZyfid.cjs +0 -2
- package/dist/types-CfCZyfid.cjs.map +0 -1
- package/dist/vault-registry-reader-OK2V08tk.cjs +0 -2
- package/dist/vault-registry-reader-OK2V08tk.cjs.map +0 -1
- package/dist/vault-registry-reader-WiNVOsnD.js.map +0 -1
|
@@ -2,16 +2,16 @@ var M = Object.defineProperty;
|
|
|
2
2
|
var U = (e, t, r) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var v = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { B as F } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
|
|
5
|
-
import { e as X, s as c, u as R, p as m, f as
|
|
5
|
+
import { e as X, s as c, u as R, p as m, f as h } from "./bitcoin-B0S8SHCX.js";
|
|
6
6
|
import { v as z, P as G } from "./PayoutManager-C9XHKZ5j.js";
|
|
7
|
-
import { c as Q, a as W, R as Y, d as $, D as b } from "./types-
|
|
8
|
-
import * as
|
|
9
|
-
import { Transaction as y, Psbt as
|
|
7
|
+
import { c as Q, a as W, R as Y, d as $, D as b } from "./types-TiIjyo2b.js";
|
|
8
|
+
import * as q from "bitcoinjs-lib";
|
|
9
|
+
import { Transaction as y, Psbt as j } from "bitcoinjs-lib";
|
|
10
10
|
import { Buffer as J } from "buffer";
|
|
11
11
|
import { c as Z, a as ee, b as te } from "./noPayout-DBX6G96_.js";
|
|
12
12
|
import { a as re, b as oe, e as A } from "./payout-BNFMBXS6.js";
|
|
13
13
|
import { c as _ } from "./signing-DaLvGwQe.js";
|
|
14
|
-
const ne = /^0x[0-9a-fA-F]{64}$/,
|
|
14
|
+
const ne = /^0x[0-9a-fA-F]{64}$/, ie = /^0x[0-9a-fA-F]{40}$/, se = /^0x([0-9a-fA-F]{2})*$/;
|
|
15
15
|
function T(e, t) {
|
|
16
16
|
if (e.length !== 66)
|
|
17
17
|
throw new Error(
|
|
@@ -22,8 +22,8 @@ function T(e, t) {
|
|
|
22
22
|
`${t} must contain only hex characters after the 0x prefix`
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (!
|
|
25
|
+
function ae(e, t) {
|
|
26
|
+
if (!ie.test(e))
|
|
27
27
|
throw new Error(
|
|
28
28
|
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
29
29
|
);
|
|
@@ -34,7 +34,7 @@ function ue(e, t) {
|
|
|
34
34
|
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
37
|
+
async function qe(e) {
|
|
38
38
|
const {
|
|
39
39
|
btcVaultRegistryAddress: t,
|
|
40
40
|
vaultId: r,
|
|
@@ -43,9 +43,9 @@ async function je(e) {
|
|
|
43
43
|
writeContract: u,
|
|
44
44
|
signal: n
|
|
45
45
|
} = e;
|
|
46
|
-
n == null || n.throwIfAborted(),
|
|
47
|
-
const
|
|
48
|
-
if (T(
|
|
46
|
+
n == null || n.throwIfAborted(), ae(t, "btcVaultRegistryAddress"), T(r, "vaultId");
|
|
47
|
+
const a = X(e.secret);
|
|
48
|
+
if (T(a, "secret"), o !== void 0 && (T(o, "hashlock"), !z(a, o)))
|
|
49
49
|
throw new Error(
|
|
50
50
|
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
51
51
|
);
|
|
@@ -53,7 +53,7 @@ async function je(e) {
|
|
|
53
53
|
address: t,
|
|
54
54
|
abi: F,
|
|
55
55
|
functionName: "activateVaultWithSecret",
|
|
56
|
-
args: [r,
|
|
56
|
+
args: [r, a, s]
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
const le = 1e4;
|
|
@@ -65,32 +65,37 @@ async function N(e) {
|
|
|
65
65
|
timeoutMs: s,
|
|
66
66
|
pollIntervalMs: u = le,
|
|
67
67
|
signal: n
|
|
68
|
-
} = e,
|
|
68
|
+
} = e, a = Date.now();
|
|
69
69
|
for (; ; ) {
|
|
70
70
|
if (n != null && n.aborted)
|
|
71
71
|
throw new Error(
|
|
72
72
|
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
73
73
|
);
|
|
74
|
-
if (Date.now() -
|
|
74
|
+
if (Date.now() - a >= s)
|
|
75
75
|
throw new Error(
|
|
76
76
|
`Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
77
77
|
);
|
|
78
78
|
try {
|
|
79
|
-
const
|
|
79
|
+
const i = await t.getPeginStatus(
|
|
80
80
|
{ pegin_txid: r },
|
|
81
81
|
n
|
|
82
|
-
)
|
|
82
|
+
);
|
|
83
|
+
if (i.pegin_txid.toLowerCase() !== r.toLowerCase())
|
|
84
|
+
throw new Error(
|
|
85
|
+
`getPeginStatus returned status for pegin ${i.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
|
|
86
|
+
);
|
|
87
|
+
const l = i.status;
|
|
83
88
|
if (o.has(l))
|
|
84
89
|
return l;
|
|
85
90
|
if (Q.has(l) && !o.has(l))
|
|
86
91
|
throw new Error(
|
|
87
92
|
`Pegin ${r.slice(0, 8)}… reached terminal status "${l}" while waiting for ${[...o].join(", ")}`
|
|
88
93
|
);
|
|
89
|
-
} catch (
|
|
90
|
-
if (!(
|
|
91
|
-
throw
|
|
94
|
+
} catch (i) {
|
|
95
|
+
if (!(i instanceof W && i.code === Y.NOT_FOUND || i instanceof Error && i.message.includes("PegIn not found")))
|
|
96
|
+
throw i;
|
|
92
97
|
}
|
|
93
|
-
await new Promise((
|
|
98
|
+
await new Promise((i, l) => {
|
|
94
99
|
const f = () => {
|
|
95
100
|
clearTimeout(d), l(
|
|
96
101
|
new Error(
|
|
@@ -98,7 +103,7 @@ async function N(e) {
|
|
|
98
103
|
)
|
|
99
104
|
);
|
|
100
105
|
}, d = setTimeout(() => {
|
|
101
|
-
n == null || n.removeEventListener("abort", f),
|
|
106
|
+
n == null || n.removeEventListener("abort", f), i();
|
|
102
107
|
}, u);
|
|
103
108
|
n == null || n.addEventListener("abort", f, { once: !0 });
|
|
104
109
|
});
|
|
@@ -108,7 +113,7 @@ const ce = 300 * 1e3, de = /* @__PURE__ */ new Set([
|
|
|
108
113
|
b.PENDING_DEPOSITOR_WOTS_PK,
|
|
109
114
|
...$
|
|
110
115
|
]);
|
|
111
|
-
async function
|
|
116
|
+
async function je(e) {
|
|
112
117
|
const {
|
|
113
118
|
statusReader: t,
|
|
114
119
|
wotsSubmitter: r,
|
|
@@ -116,23 +121,23 @@ async function qe(e) {
|
|
|
116
121
|
depositorPk: s,
|
|
117
122
|
wotsPublicKeys: u,
|
|
118
123
|
timeoutMs: n = ce,
|
|
119
|
-
signal:
|
|
124
|
+
signal: a
|
|
120
125
|
} = e;
|
|
121
|
-
|
|
122
|
-
const
|
|
126
|
+
a == null || a.throwIfAborted();
|
|
127
|
+
const i = await N({
|
|
123
128
|
statusReader: t,
|
|
124
129
|
peginTxid: o,
|
|
125
130
|
targetStatuses: de,
|
|
126
131
|
timeoutMs: n,
|
|
127
|
-
signal:
|
|
132
|
+
signal: a
|
|
128
133
|
});
|
|
129
|
-
$.has(
|
|
134
|
+
$.has(i) || (a == null || a.throwIfAborted(), await r.submitDepositorWotsKey(
|
|
130
135
|
{
|
|
131
136
|
pegin_txid: o,
|
|
132
137
|
depositor_pk: s,
|
|
133
138
|
wots_public_keys: u
|
|
134
139
|
},
|
|
135
|
-
|
|
140
|
+
a
|
|
136
141
|
));
|
|
137
142
|
}
|
|
138
143
|
const B = 1;
|
|
@@ -146,7 +151,7 @@ function fe(e, t, r) {
|
|
|
146
151
|
);
|
|
147
152
|
return u;
|
|
148
153
|
}
|
|
149
|
-
function
|
|
154
|
+
function pe(e, t) {
|
|
150
155
|
const r = e.ins[t];
|
|
151
156
|
return R(new Uint8Array(r.hash).slice().reverse());
|
|
152
157
|
}
|
|
@@ -156,13 +161,13 @@ function k(e, t, r, o, s) {
|
|
|
156
161
|
throw new Error(
|
|
157
162
|
`NoPayout (challenger ${s}) input ${t} expected to spend ${o} vout 0, got vout ${u.index}`
|
|
158
163
|
);
|
|
159
|
-
const n = r.getId(),
|
|
160
|
-
if (
|
|
164
|
+
const n = r.getId(), a = pe(e, t);
|
|
165
|
+
if (a !== n)
|
|
161
166
|
throw new Error(
|
|
162
|
-
`NoPayout (challenger ${s}) input ${t} does not reference ${o} (expected txid ${n}, got ${
|
|
167
|
+
`NoPayout (challenger ${s}) input ${t} does not reference ${o} (expected txid ${n}, got ${a})`
|
|
163
168
|
);
|
|
164
169
|
}
|
|
165
|
-
async function
|
|
170
|
+
async function he(e, t, r) {
|
|
166
171
|
const o = [], s = [], u = [];
|
|
167
172
|
re(
|
|
168
173
|
e.payout_tx.tx_hex,
|
|
@@ -185,19 +190,19 @@ async function pe(e, t, r) {
|
|
|
185
190
|
B
|
|
186
191
|
)
|
|
187
192
|
);
|
|
188
|
-
const
|
|
193
|
+
const a = fe(
|
|
189
194
|
r.vaultProviderBtcPubkey,
|
|
190
195
|
r.vaultKeeperBtcPubkeys,
|
|
191
196
|
r.depositorBtcPubkey
|
|
192
|
-
),
|
|
197
|
+
), i = c(r.depositorBtcPubkey), l = y.fromHex(
|
|
193
198
|
c(e.assert_tx.tx_hex)
|
|
194
199
|
);
|
|
195
200
|
for (const f of e.challenger_presign_data) {
|
|
196
201
|
const d = c(f.challenger_pubkey), g = o.length, P = await ge({
|
|
197
202
|
challenger: f,
|
|
198
203
|
challengerPubkey: d,
|
|
199
|
-
claimerPubkey:
|
|
200
|
-
localChallengers:
|
|
204
|
+
claimerPubkey: i,
|
|
205
|
+
localChallengers: a,
|
|
201
206
|
assertTxParsed: l,
|
|
202
207
|
ctx: r
|
|
203
208
|
});
|
|
@@ -227,31 +232,31 @@ async function ge(e) {
|
|
|
227
232
|
r,
|
|
228
233
|
n.network
|
|
229
234
|
);
|
|
230
|
-
const
|
|
235
|
+
const a = y.fromHex(
|
|
231
236
|
c(t.nopayout_tx.tx_hex)
|
|
232
|
-
),
|
|
237
|
+
), i = y.fromHex(
|
|
233
238
|
c(t.challenge_assert_x_tx.tx_hex)
|
|
234
239
|
), l = y.fromHex(
|
|
235
240
|
c(t.challenge_assert_y_tx.tx_hex)
|
|
236
241
|
);
|
|
237
|
-
if (
|
|
242
|
+
if (a.ins.length !== 3)
|
|
238
243
|
throw new Error(
|
|
239
|
-
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${
|
|
244
|
+
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${a.ins.length}`
|
|
240
245
|
);
|
|
241
246
|
k(
|
|
242
|
-
|
|
247
|
+
a,
|
|
243
248
|
0,
|
|
244
249
|
u,
|
|
245
250
|
"Assert",
|
|
246
251
|
r
|
|
247
252
|
), k(
|
|
248
|
-
i,
|
|
249
|
-
1,
|
|
250
253
|
a,
|
|
254
|
+
1,
|
|
255
|
+
i,
|
|
251
256
|
"ChallengeAssertX",
|
|
252
257
|
r
|
|
253
258
|
), k(
|
|
254
|
-
|
|
259
|
+
a,
|
|
255
260
|
2,
|
|
256
261
|
l,
|
|
257
262
|
"ChallengeAssertY",
|
|
@@ -259,7 +264,7 @@ async function ge(e) {
|
|
|
259
264
|
);
|
|
260
265
|
const f = [
|
|
261
266
|
u.outs[0],
|
|
262
|
-
|
|
267
|
+
i.outs[0],
|
|
263
268
|
l.outs[0]
|
|
264
269
|
].map((d) => ({
|
|
265
270
|
script_pubkey: R(new Uint8Array(d.script)),
|
|
@@ -307,14 +312,14 @@ async function be(e, t, r) {
|
|
|
307
312
|
return o;
|
|
308
313
|
}
|
|
309
314
|
async function ye(e) {
|
|
310
|
-
const { depositorGraph: t, btcWallet: r, signingContext: o } = e, s = c(o.depositorBtcPubkey), u = await r.getPublicKeyHex(), { psbtHexes: n, signOptions:
|
|
315
|
+
const { depositorGraph: t, btcWallet: r, signingContext: o } = e, s = c(o.depositorBtcPubkey), u = await r.getPublicKeyHex(), { psbtHexes: n, signOptions: a, challengerEntries: i } = await he(
|
|
311
316
|
t,
|
|
312
317
|
u,
|
|
313
318
|
o
|
|
314
319
|
), l = await be(
|
|
315
320
|
r,
|
|
316
321
|
n,
|
|
317
|
-
|
|
322
|
+
a
|
|
318
323
|
);
|
|
319
324
|
if (l.length !== n.length)
|
|
320
325
|
throw new Error(
|
|
@@ -322,7 +327,7 @@ async function ye(e) {
|
|
|
322
327
|
);
|
|
323
328
|
return Pe(
|
|
324
329
|
l,
|
|
325
|
-
|
|
330
|
+
i,
|
|
326
331
|
s
|
|
327
332
|
);
|
|
328
333
|
}
|
|
@@ -342,7 +347,7 @@ function xe(e) {
|
|
|
342
347
|
}));
|
|
343
348
|
}
|
|
344
349
|
function ve(e) {
|
|
345
|
-
const { output: t } =
|
|
350
|
+
const { output: t } = q.payments.p2tr({
|
|
346
351
|
internalPubkey: J.from(e, "hex")
|
|
347
352
|
});
|
|
348
353
|
if (!t)
|
|
@@ -358,14 +363,14 @@ function Te(e, t) {
|
|
|
358
363
|
if (r === o || r === s)
|
|
359
364
|
return t.registeredPayoutScriptPubKey;
|
|
360
365
|
if (!t.vaultKeeperBtcPubkeys.some(
|
|
361
|
-
(
|
|
366
|
+
(a) => c(a).toLowerCase() === r
|
|
362
367
|
))
|
|
363
368
|
throw new Error(
|
|
364
369
|
`Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
|
|
365
370
|
);
|
|
366
371
|
return `0x${ve(r)}`;
|
|
367
372
|
}
|
|
368
|
-
function
|
|
373
|
+
function C(e, t) {
|
|
369
374
|
return {
|
|
370
375
|
payoutTxHex: e.payoutTxHex,
|
|
371
376
|
peginTxHex: t.peginTxHex,
|
|
@@ -390,24 +395,24 @@ async function ke(e, t, r, o) {
|
|
|
390
395
|
let n;
|
|
391
396
|
if (s.supportsBatchSigning())
|
|
392
397
|
n = (await s.signPayoutTransactionsBatch(
|
|
393
|
-
r.map((l) =>
|
|
398
|
+
r.map((l) => C(l, t))
|
|
394
399
|
)).map((l) => l.payoutSignature);
|
|
395
400
|
else {
|
|
396
401
|
n = [];
|
|
397
|
-
for (let
|
|
398
|
-
o == null || o(
|
|
402
|
+
for (let i = 0; i < r.length; i++) {
|
|
403
|
+
o == null || o(i, u);
|
|
399
404
|
const l = await s.signPayoutTransaction(
|
|
400
|
-
|
|
405
|
+
C(r[i], t)
|
|
401
406
|
);
|
|
402
407
|
n.push(l.signature);
|
|
403
408
|
}
|
|
404
409
|
}
|
|
405
|
-
const
|
|
406
|
-
for (let
|
|
407
|
-
|
|
408
|
-
payout_signature: n[
|
|
410
|
+
const a = {};
|
|
411
|
+
for (let i = 0; i < r.length; i++)
|
|
412
|
+
a[r[i].claimerPubkeyXOnly] = {
|
|
413
|
+
payout_signature: n[i]
|
|
409
414
|
};
|
|
410
|
-
return o == null || o(u, u),
|
|
415
|
+
return o == null || o(u, u), a;
|
|
411
416
|
}
|
|
412
417
|
async function Je(e) {
|
|
413
418
|
const {
|
|
@@ -417,37 +422,37 @@ async function Je(e) {
|
|
|
417
422
|
peginTxid: s,
|
|
418
423
|
depositorPk: u,
|
|
419
424
|
signingContext: n,
|
|
420
|
-
timeoutMs:
|
|
421
|
-
signal:
|
|
425
|
+
timeoutMs: a = me,
|
|
426
|
+
signal: i,
|
|
422
427
|
onProgress: l
|
|
423
428
|
} = e, f = await N({
|
|
424
429
|
statusReader: t,
|
|
425
430
|
peginTxid: s,
|
|
426
431
|
targetStatuses: we,
|
|
427
|
-
timeoutMs:
|
|
428
|
-
signal:
|
|
432
|
+
timeoutMs: a,
|
|
433
|
+
signal: i
|
|
429
434
|
});
|
|
430
435
|
if (H.has(f))
|
|
431
436
|
return;
|
|
432
|
-
|
|
437
|
+
i == null || i.throwIfAborted();
|
|
433
438
|
const d = await r.requestDepositorPresignTransactions(
|
|
434
439
|
{
|
|
435
440
|
pegin_txid: s,
|
|
436
441
|
depositor_pk: u
|
|
437
442
|
},
|
|
438
|
-
|
|
443
|
+
i
|
|
439
444
|
);
|
|
440
|
-
|
|
445
|
+
i == null || i.throwIfAborted();
|
|
441
446
|
const g = m(u), P = d.txs.filter(
|
|
442
|
-
(
|
|
447
|
+
(K) => m(K.claimer_pubkey) !== g
|
|
443
448
|
), w = xe(P), x = await ke(
|
|
444
449
|
o,
|
|
445
450
|
n,
|
|
446
451
|
w,
|
|
447
452
|
l
|
|
448
453
|
);
|
|
449
|
-
|
|
450
|
-
const
|
|
454
|
+
i == null || i.throwIfAborted();
|
|
455
|
+
const p = await ye({
|
|
451
456
|
depositorGraph: d.depositor_graph,
|
|
452
457
|
btcWallet: o,
|
|
453
458
|
signingContext: {
|
|
@@ -464,16 +469,16 @@ async function Je(e) {
|
|
|
464
469
|
registeredPayoutScriptPubKey: n.registeredPayoutScriptPubKey
|
|
465
470
|
}
|
|
466
471
|
});
|
|
467
|
-
|
|
472
|
+
i == null || i.throwIfAborted();
|
|
468
473
|
const S = { ...x };
|
|
469
|
-
S[c(u)] =
|
|
474
|
+
S[c(u)] = p.payout_signatures, await r.submitDepositorPresignatures(
|
|
470
475
|
{
|
|
471
476
|
pegin_txid: s,
|
|
472
477
|
depositor_pk: u,
|
|
473
478
|
signatures: S,
|
|
474
|
-
depositor_claimer_presignatures:
|
|
479
|
+
depositor_claimer_presignatures: p
|
|
475
480
|
},
|
|
476
|
-
|
|
481
|
+
i
|
|
477
482
|
);
|
|
478
483
|
}
|
|
479
484
|
function Ee(e) {
|
|
@@ -496,10 +501,10 @@ function et(e, t, r) {
|
|
|
496
501
|
error: "Deposit amount must be greater than zero"
|
|
497
502
|
} : e < t ? {
|
|
498
503
|
valid: !1,
|
|
499
|
-
error: `Minimum deposit is ${
|
|
504
|
+
error: `Minimum deposit is ${h(t)} BTC`
|
|
500
505
|
} : r && r > 0n && e > r ? {
|
|
501
506
|
valid: !1,
|
|
502
|
-
error: `Maximum deposit is ${
|
|
507
|
+
error: `Maximum deposit is ${h(r)} BTC`
|
|
503
508
|
} : { valid: !0 };
|
|
504
509
|
}
|
|
505
510
|
function tt(e) {
|
|
@@ -509,7 +514,7 @@ function tt(e) {
|
|
|
509
514
|
error: "Supply cap reached — deposits temporarily paused"
|
|
510
515
|
} : t > r ? {
|
|
511
516
|
valid: !1,
|
|
512
|
-
error: `Vault size exceeds remaining capacity (${
|
|
517
|
+
error: `Vault size exceeds remaining capacity (${h(r)} BTC)`
|
|
513
518
|
} : { valid: !0 };
|
|
514
519
|
}
|
|
515
520
|
function rt(e, t) {
|
|
@@ -544,12 +549,12 @@ function _e(e, t, r) {
|
|
|
544
549
|
if (t && s < t)
|
|
545
550
|
return {
|
|
546
551
|
valid: !1,
|
|
547
|
-
error: `Vault ${o + 1} amount ${
|
|
552
|
+
error: `Vault ${o + 1} amount ${h(s)} BTC is below minimum deposit ${h(t)} BTC`
|
|
548
553
|
};
|
|
549
554
|
if (r && s > r)
|
|
550
555
|
return {
|
|
551
556
|
valid: !1,
|
|
552
|
-
error: `Vault ${o + 1} amount ${
|
|
557
|
+
error: `Vault ${o + 1} amount ${h(s)} BTC exceeds maximum deposit ${h(r)} BTC`
|
|
553
558
|
};
|
|
554
559
|
}
|
|
555
560
|
return { valid: !0 };
|
|
@@ -573,7 +578,7 @@ function Be(e) {
|
|
|
573
578
|
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
574
579
|
);
|
|
575
580
|
}
|
|
576
|
-
function
|
|
581
|
+
function Ce(e) {
|
|
577
582
|
if (e.length === 0)
|
|
578
583
|
throw new Error("No spendable UTXOs available");
|
|
579
584
|
}
|
|
@@ -585,21 +590,21 @@ function ot(e) {
|
|
|
585
590
|
vaultKeeperBtcPubkeys: s,
|
|
586
591
|
universalChallengerBtcPubkeys: u,
|
|
587
592
|
minDeposit: n,
|
|
588
|
-
maxDeposit:
|
|
589
|
-
} = e,
|
|
593
|
+
maxDeposit: a
|
|
594
|
+
} = e, i = _e(
|
|
590
595
|
t,
|
|
591
596
|
n,
|
|
592
|
-
|
|
597
|
+
a
|
|
593
598
|
);
|
|
594
|
-
if (!
|
|
595
|
-
throw new Error(
|
|
599
|
+
if (!i.valid)
|
|
600
|
+
throw new Error(i.error);
|
|
596
601
|
const l = Se(o);
|
|
597
602
|
if (!l.valid)
|
|
598
603
|
throw new Error(l.error);
|
|
599
|
-
Ae(s), Be(u),
|
|
604
|
+
Ae(s), Be(u), Ce(r);
|
|
600
605
|
}
|
|
601
606
|
var O = /* @__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))(O || {});
|
|
602
|
-
const
|
|
607
|
+
const Ie = /* @__PURE__ */ new Set([
|
|
603
608
|
"PayoutBroadcast",
|
|
604
609
|
"Failed"
|
|
605
610
|
/* FAILED */
|
|
@@ -609,8 +614,8 @@ function nt(e) {
|
|
|
609
614
|
e
|
|
610
615
|
);
|
|
611
616
|
}
|
|
612
|
-
function
|
|
613
|
-
return !!e &&
|
|
617
|
+
function it(e) {
|
|
618
|
+
return !!e && Ie.has(e);
|
|
614
619
|
}
|
|
615
620
|
class Re extends Error {
|
|
616
621
|
constructor(r, o) {
|
|
@@ -628,8 +633,8 @@ function st(e) {
|
|
|
628
633
|
);
|
|
629
634
|
return BigInt(Math.ceil(e * D));
|
|
630
635
|
}
|
|
631
|
-
const He = 1,
|
|
632
|
-
function
|
|
636
|
+
const He = 1, I = 65535, Oe = /non-BIP68-final/i;
|
|
637
|
+
function L(e, t) {
|
|
633
638
|
if (e.length !== 66)
|
|
634
639
|
throw new Error(
|
|
635
640
|
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
@@ -644,9 +649,9 @@ function E(e, t) {
|
|
|
644
649
|
throw new Error(`${t} must be a non-negative integer, got ${e}`);
|
|
645
650
|
}
|
|
646
651
|
function Ve(e) {
|
|
647
|
-
if (
|
|
652
|
+
if (L(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > I)
|
|
648
653
|
throw new Error(
|
|
649
|
-
`htlcVout must be an integer 0-${
|
|
654
|
+
`htlcVout must be an integer 0-${I}, got ${e.htlcVout}`
|
|
650
655
|
);
|
|
651
656
|
if (E(e.offchainParamsVersion, "offchainParamsVersion"), E(e.appVaultKeepersVersion, "appVaultKeepersVersion"), E(
|
|
652
657
|
e.universalChallengersVersion,
|
|
@@ -686,8 +691,8 @@ function De(e) {
|
|
|
686
691
|
`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
|
|
687
692
|
);
|
|
688
693
|
}
|
|
689
|
-
function
|
|
690
|
-
const t =
|
|
694
|
+
function Le(e) {
|
|
695
|
+
const t = j.fromHex(e);
|
|
691
696
|
try {
|
|
692
697
|
t.finalizeAllInputs();
|
|
693
698
|
} catch (r) {
|
|
@@ -697,7 +702,7 @@ function Ke(e) {
|
|
|
697
702
|
}
|
|
698
703
|
return t.extractTransaction().toHex();
|
|
699
704
|
}
|
|
700
|
-
async function
|
|
705
|
+
async function at(e) {
|
|
701
706
|
const {
|
|
702
707
|
vaultId: t,
|
|
703
708
|
readVault: r,
|
|
@@ -705,59 +710,59 @@ async function it(e) {
|
|
|
705
710
|
feeRate: s,
|
|
706
711
|
signPsbt: u,
|
|
707
712
|
broadcastTx: n,
|
|
708
|
-
signal:
|
|
713
|
+
signal: a
|
|
709
714
|
} = e;
|
|
710
|
-
|
|
711
|
-
const
|
|
712
|
-
Ve(
|
|
713
|
-
const l = await o(
|
|
714
|
-
if (De(l),
|
|
715
|
+
a == null || a.throwIfAborted(), L(t, "vaultId");
|
|
716
|
+
const i = await r();
|
|
717
|
+
Ve(i), a == null || a.throwIfAborted();
|
|
718
|
+
const l = await o(i);
|
|
719
|
+
if (De(l), a == null || a.throwIfAborted(), !Number.isFinite(s) || s <= 0)
|
|
715
720
|
throw new Error(`feeRate must be a positive number, got ${s}`);
|
|
716
721
|
const f = BigInt(Math.ceil(s * D));
|
|
717
|
-
|
|
722
|
+
a == null || a.throwIfAborted();
|
|
718
723
|
const d = m(
|
|
719
|
-
|
|
724
|
+
i.depositorBtcPubkey
|
|
720
725
|
), { psbtHex: g } = await te({
|
|
721
726
|
prePeginParams: {
|
|
722
727
|
depositorPubkey: d,
|
|
723
728
|
vaultProviderPubkey: c(l.vaultProviderPubkey),
|
|
724
729
|
vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(c),
|
|
725
730
|
universalChallengerPubkeys: l.universalChallengerPubkeys.map(c),
|
|
726
|
-
hashlocks: [c(
|
|
731
|
+
hashlocks: [c(i.hashlock)],
|
|
727
732
|
timelockRefund: l.timelockRefund,
|
|
728
|
-
pegInAmounts: [
|
|
733
|
+
pegInAmounts: [i.amount],
|
|
729
734
|
feeRate: l.feeRate,
|
|
730
735
|
numLocalChallengers: l.numLocalChallengers,
|
|
731
736
|
councilQuorum: l.councilQuorum,
|
|
732
737
|
councilSize: l.councilSize,
|
|
733
738
|
network: l.network
|
|
734
739
|
},
|
|
735
|
-
fundedPrePeginTxHex: c(
|
|
736
|
-
htlcVout:
|
|
740
|
+
fundedPrePeginTxHex: c(i.unsignedPrePeginTxHex),
|
|
741
|
+
htlcVout: i.htlcVout,
|
|
737
742
|
refundFee: f,
|
|
738
743
|
// buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
|
|
739
744
|
// prefix" and flows into the WASM HTLC connector derivation; a prefixed
|
|
740
745
|
// value would derive the wrong refund script leaf and yield an
|
|
741
746
|
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
742
|
-
hashlock: c(
|
|
747
|
+
hashlock: c(i.hashlock)
|
|
743
748
|
});
|
|
744
|
-
|
|
749
|
+
a == null || a.throwIfAborted();
|
|
745
750
|
const P = _(
|
|
746
|
-
|
|
751
|
+
i.depositorBtcPubkey,
|
|
747
752
|
He
|
|
748
|
-
), w = await u(g, P), x =
|
|
749
|
-
|
|
753
|
+
), w = await u(g, P), x = Le(w);
|
|
754
|
+
a == null || a.throwIfAborted();
|
|
750
755
|
try {
|
|
751
756
|
return await n(x);
|
|
752
|
-
} catch (
|
|
753
|
-
throw
|
|
757
|
+
} catch (p) {
|
|
758
|
+
throw p instanceof Error && Oe.test(p.message) ? new Re(t, p) : p;
|
|
754
759
|
}
|
|
755
760
|
}
|
|
756
761
|
export {
|
|
757
762
|
Re as B,
|
|
758
763
|
O as C,
|
|
759
764
|
D as R,
|
|
760
|
-
|
|
765
|
+
qe as a,
|
|
761
766
|
ye as b,
|
|
762
767
|
tt as c,
|
|
763
768
|
rt as d,
|
|
@@ -766,12 +771,12 @@ export {
|
|
|
766
771
|
ot as g,
|
|
767
772
|
nt as h,
|
|
768
773
|
Ze as i,
|
|
769
|
-
|
|
770
|
-
|
|
774
|
+
it as j,
|
|
775
|
+
at as k,
|
|
771
776
|
st as l,
|
|
772
777
|
Je as r,
|
|
773
|
-
|
|
778
|
+
je as s,
|
|
774
779
|
et as v,
|
|
775
780
|
N as w
|
|
776
781
|
};
|
|
777
|
-
//# sourceMappingURL=buildAndBroadcastRefund-
|
|
782
|
+
//# sourceMappingURL=buildAndBroadcastRefund-CPjXNaMi.js.map
|