@babylonlabs-io/ts-sdk 0.36.1 → 0.36.3
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/PeginManager-BPXVXu8t.cjs +2 -0
- package/dist/{PeginManager-cPQuJTB9.cjs.map → PeginManager-BPXVXu8t.cjs.map} +1 -1
- package/dist/{PeginManager-DF1oinIQ.js → PeginManager-CB-dVkT2.js} +387 -369
- package/dist/{PeginManager-DF1oinIQ.js.map → PeginManager-CB-dVkT2.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-D4YqqClN.js → buildAndBroadcastRefund-C2VqXiOx.js} +241 -220
- package/dist/buildAndBroadcastRefund-C2VqXiOx.js.map +1 -0
- package/dist/buildAndBroadcastRefund-CBIfcF47.cjs +2 -0
- package/dist/buildAndBroadcastRefund-CBIfcF47.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/reservation-DF0uiCUC.cjs +2 -0
- package/dist/reservation-DF0uiCUC.cjs.map +1 -0
- package/dist/{reservation-CHUGW0F_.js → reservation-fZUvejYK.js} +36 -35
- package/dist/reservation-fZUvejYK.js.map +1 -0
- 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/validators.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +4 -4
- package/dist/tbv/core/managers/PeginManager.d.ts +22 -4
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +1 -1
- package/dist/tbv/core/services/deposit/signDepositorGraph.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/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +1 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts +4 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/index.d.ts +1 -0
- package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +4 -4
- package/dist/vault-registry-reader-Br9m8bHF.cjs +2 -0
- package/dist/vault-registry-reader-Br9m8bHF.cjs.map +1 -0
- package/dist/{vault-registry-reader-CrLodprY.js → vault-registry-reader-CohvzvoH.js} +129 -124
- package/dist/vault-registry-reader-CohvzvoH.js.map +1 -0
- package/package.json +1 -1
- package/dist/PeginManager-cPQuJTB9.cjs +0 -2
- package/dist/buildAndBroadcastRefund-D4YqqClN.js.map +0 -1
- package/dist/buildAndBroadcastRefund-DSELaUiR.cjs +0 -2
- package/dist/buildAndBroadcastRefund-DSELaUiR.cjs.map +0 -1
- package/dist/reservation-CHUGW0F_.js.map +0 -1
- package/dist/reservation-ho7mjW3X.cjs +0 -2
- package/dist/reservation-ho7mjW3X.cjs.map +0 -1
- package/dist/vault-registry-reader-CLnhAUN4.cjs +0 -2
- package/dist/vault-registry-reader-CLnhAUN4.cjs.map +0 -1
- package/dist/vault-registry-reader-CrLodprY.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var fe = Object.defineProperty;
|
|
2
2
|
var me = (t, e, n) => e in t ? fe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
3
|
var p = (t, e, n) => me(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { D as be, J as
|
|
4
|
+
import { D as be, J as se, e as _e } from "./types-TiIjyo2b.js";
|
|
5
5
|
import { X as R, C as L, s as C, S as ye, h as Pe } from "./bitcoin-B0S8SHCX.js";
|
|
6
6
|
import { H as T } from "./validation-CxqROCno.js";
|
|
7
7
|
import * as j from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
8
|
import { payments as we, Transaction as U } from "bitcoinjs-lib";
|
|
9
9
|
import { Buffer as A } from "buffer";
|
|
10
|
-
import { s as
|
|
10
|
+
import { s as W } from "./sha2-BYVxyZzX.js";
|
|
11
11
|
import { B as w } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
|
|
12
12
|
import { P as _, A as F } from "./ProtocolParams.abi-DXu8L0Fn.js";
|
|
13
|
-
const
|
|
13
|
+
const Q = new Set(Object.values(be)), ve = 200;
|
|
14
14
|
function l(t) {
|
|
15
15
|
var e;
|
|
16
16
|
return ((e = JSON.stringify(t)) == null ? void 0 : e.slice(0, ve)) ?? "undefined";
|
|
@@ -30,7 +30,7 @@ function v(t) {
|
|
|
30
30
|
function ie(t) {
|
|
31
31
|
return typeof t == "string" && t.length > 0;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function oe(t, e) {
|
|
34
34
|
if (!v(t))
|
|
35
35
|
throw new o(
|
|
36
36
|
`VP response validation failed: "${e}" must be a non-empty hex string, got ${l(t)}`
|
|
@@ -42,7 +42,7 @@ function m(t, e) {
|
|
|
42
42
|
`VP response validation failed: "${e}" must be a non-empty string, got ${l(t)}`
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function q(t, e) {
|
|
46
46
|
if (!v(t) || t.length !== R && t.length !== L)
|
|
47
47
|
throw new o(
|
|
48
48
|
`VP response validation failed: "${e}" must be a ${R} or ${L}-char hex string (BTC pubkey), got ${l(t)}`
|
|
@@ -83,9 +83,9 @@ function ae(t) {
|
|
|
83
83
|
throw new o(
|
|
84
84
|
'VP response validation failed: "status" must be a string'
|
|
85
85
|
);
|
|
86
|
-
if (!
|
|
86
|
+
if (!Q.has(e.status))
|
|
87
87
|
throw new o(
|
|
88
|
-
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...
|
|
88
|
+
`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...Q].join(", ")}`
|
|
89
89
|
);
|
|
90
90
|
if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
|
|
91
91
|
throw new o(
|
|
@@ -125,7 +125,7 @@ function y(t, e) {
|
|
|
125
125
|
throw new o(
|
|
126
126
|
`VP response validation failed: "${e}" must be an object`
|
|
127
127
|
);
|
|
128
|
-
|
|
128
|
+
oe(t.tx_hex, `${e}.tx_hex`);
|
|
129
129
|
}
|
|
130
130
|
function $e(t, e) {
|
|
131
131
|
if (t === null || typeof t != "object")
|
|
@@ -133,7 +133,7 @@ function $e(t, e) {
|
|
|
133
133
|
`VP response validation failed: "${e}" must be an object`
|
|
134
134
|
);
|
|
135
135
|
const n = t;
|
|
136
|
-
|
|
136
|
+
q(n.claimer_pubkey, `${e}.claimer_pubkey`), y(n.claim_tx, `${e}.claim_tx`), y(n.assert_tx, `${e}.assert_tx`), y(n.payout_tx, `${e}.payout_tx`), m(n.payout_psbt, `${e}.payout_psbt`);
|
|
137
137
|
}
|
|
138
138
|
function Te(t, e) {
|
|
139
139
|
if (t === null || typeof t != "object")
|
|
@@ -149,7 +149,7 @@ function Se(t, e) {
|
|
|
149
149
|
`VP response validation failed: "${e}" must be an object`
|
|
150
150
|
);
|
|
151
151
|
const n = t;
|
|
152
|
-
if (
|
|
152
|
+
if (q(n.challenger_pubkey, `${e}.challenger_pubkey`), y(
|
|
153
153
|
n.challenge_assert_x_tx,
|
|
154
154
|
`${e}.challenge_assert_x_tx`
|
|
155
155
|
), y(
|
|
@@ -169,7 +169,7 @@ function Se(t, e) {
|
|
|
169
169
|
`VP response validation failed: "${e}.output_label_hashes" must be an array`
|
|
170
170
|
);
|
|
171
171
|
for (let r = 0; r < n.output_label_hashes.length; r++)
|
|
172
|
-
|
|
172
|
+
oe(
|
|
173
173
|
n.output_label_hashes[r],
|
|
174
174
|
`${e}.output_label_hashes[${r}]`
|
|
175
175
|
);
|
|
@@ -188,21 +188,26 @@ function ke(t) {
|
|
|
188
188
|
throw new o(
|
|
189
189
|
`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${l(e.verifying_key_hex)}`
|
|
190
190
|
);
|
|
191
|
-
if (e.babe_sessions === null || typeof e.babe_sessions != "object")
|
|
191
|
+
if (e.babe_sessions === null || typeof e.babe_sessions != "object" || Array.isArray(e.babe_sessions))
|
|
192
192
|
throw new o(
|
|
193
193
|
'VP response validation failed: "babe_sessions" must be an object'
|
|
194
194
|
);
|
|
195
|
-
|
|
195
|
+
const n = Object.entries(
|
|
196
196
|
e.babe_sessions
|
|
197
|
-
)
|
|
198
|
-
|
|
197
|
+
);
|
|
198
|
+
if (n.length === 0)
|
|
199
|
+
throw new o(
|
|
200
|
+
'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
|
|
201
|
+
);
|
|
202
|
+
for (const [r, i] of n) {
|
|
203
|
+
if (q(r, `babe_sessions["${r}"]`), i === null || typeof i != "object")
|
|
199
204
|
throw new o(
|
|
200
|
-
`VP response validation failed: "babe_sessions.${
|
|
205
|
+
`VP response validation failed: "babe_sessions.${r}" must be an object`
|
|
201
206
|
);
|
|
202
|
-
const s =
|
|
207
|
+
const s = i;
|
|
203
208
|
if (!v(s.decryptor_artifacts_hex))
|
|
204
209
|
throw new o(
|
|
205
|
-
`VP response validation failed: "babe_sessions.${
|
|
210
|
+
`VP response validation failed: "babe_sessions.${r}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(s.decryptor_artifacts_hex)}`
|
|
206
211
|
);
|
|
207
212
|
}
|
|
208
213
|
}
|
|
@@ -299,30 +304,30 @@ function ce(t, e, n) {
|
|
|
299
304
|
throw new o(
|
|
300
305
|
`VP response validation failed: "${e}.results" must be an array, got ${l(r.results)}`
|
|
301
306
|
);
|
|
302
|
-
for (let
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
307
|
+
for (let i = 0; i < r.results.length; i++) {
|
|
308
|
+
const s = r.results[i];
|
|
309
|
+
if (s === null || typeof s != "object")
|
|
305
310
|
throw new o(
|
|
306
|
-
`VP response validation failed: "${e}.results[${
|
|
311
|
+
`VP response validation failed: "${e}.results[${i}]" must be an object, got ${l(s)}`
|
|
307
312
|
);
|
|
308
|
-
const a =
|
|
313
|
+
const a = s;
|
|
309
314
|
if (!v(a.pegin_txid) || a.pegin_txid.length !== $)
|
|
310
315
|
throw new o(
|
|
311
|
-
`VP response validation failed: "${e}.results[${
|
|
316
|
+
`VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${$}-char hex string, got ${l(a.pegin_txid)}`
|
|
312
317
|
);
|
|
313
318
|
if (a.error !== null && typeof a.error != "string")
|
|
314
319
|
throw new o(
|
|
315
|
-
`VP response validation failed: "${e}.results[${
|
|
320
|
+
`VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${l(a.error)}`
|
|
316
321
|
);
|
|
317
322
|
if (a.result === null && a.error === null)
|
|
318
323
|
throw new o(
|
|
319
|
-
`VP response validation failed: "${e}.results[${
|
|
324
|
+
`VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
|
|
320
325
|
);
|
|
321
326
|
if (a.result !== null && a.error !== null)
|
|
322
327
|
throw new o(
|
|
323
|
-
`VP response validation failed: "${e}.results[${
|
|
328
|
+
`VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
|
|
324
329
|
);
|
|
325
|
-
n(a,
|
|
330
|
+
n(a, i);
|
|
326
331
|
}
|
|
327
332
|
}
|
|
328
333
|
function Re(t) {
|
|
@@ -354,7 +359,7 @@ class Oe {
|
|
|
354
359
|
tokenProvider: n == null ? void 0 : n.tokenProvider,
|
|
355
360
|
maxResponseBytes: n == null ? void 0 : n.maxResponseBytes
|
|
356
361
|
};
|
|
357
|
-
this.client = new
|
|
362
|
+
this.client = new se(r);
|
|
358
363
|
}
|
|
359
364
|
/**
|
|
360
365
|
* Request the payout/claim/assert transactions that the depositor
|
|
@@ -426,31 +431,31 @@ function De(t, e) {
|
|
|
426
431
|
const n = /* @__PURE__ */ new Set();
|
|
427
432
|
for (const u of t)
|
|
428
433
|
n.add(u.toLowerCase());
|
|
429
|
-
const r = /* @__PURE__ */ new Map(),
|
|
434
|
+
const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
|
|
430
435
|
for (const u of e) {
|
|
431
436
|
const h = u.pegin_txid.toLowerCase();
|
|
432
437
|
if (!n.has(h)) {
|
|
433
438
|
a.push(h);
|
|
434
439
|
continue;
|
|
435
440
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
441
|
+
if (i.has(h)) {
|
|
442
|
+
s.push(h);
|
|
438
443
|
continue;
|
|
439
444
|
}
|
|
440
|
-
|
|
445
|
+
i.add(h), r.set(h, { result: u.result, error: u.error });
|
|
441
446
|
}
|
|
442
447
|
const c = [];
|
|
443
448
|
for (const u of n)
|
|
444
|
-
|
|
445
|
-
return { byTxid: r, missing: c, unexpected: a, duplicate:
|
|
449
|
+
i.has(u) || c.push(u);
|
|
450
|
+
return { byTxid: r, missing: c, unexpected: a, duplicate: s };
|
|
446
451
|
}
|
|
447
452
|
async function lt(t) {
|
|
448
453
|
const {
|
|
449
454
|
items: e,
|
|
450
455
|
getTxid: n,
|
|
451
456
|
batchCall: r,
|
|
452
|
-
onItem:
|
|
453
|
-
onMissing:
|
|
457
|
+
onItem: i,
|
|
458
|
+
onMissing: s,
|
|
454
459
|
onDuplicate: a,
|
|
455
460
|
onDuplicateBatch: c,
|
|
456
461
|
onWholeBatchError: u,
|
|
@@ -484,12 +489,12 @@ async function lt(t) {
|
|
|
484
489
|
c && k.size > 0 && c(k.size);
|
|
485
490
|
for (const d of V.missing) {
|
|
486
491
|
const b = S.get(d);
|
|
487
|
-
b &&
|
|
492
|
+
b && s(b);
|
|
488
493
|
}
|
|
489
494
|
for (const [d, b] of V.byTxid) {
|
|
490
495
|
if (k.has(d)) continue;
|
|
491
|
-
const
|
|
492
|
-
|
|
496
|
+
const z = S.get(d);
|
|
497
|
+
z && i(z, {
|
|
493
498
|
pegin_txid: d,
|
|
494
499
|
result: b.result,
|
|
495
500
|
error: b.error
|
|
@@ -499,8 +504,8 @@ async function lt(t) {
|
|
|
499
504
|
}
|
|
500
505
|
const je = "BIP0322-signed-message", Ke = "TapTweak", le = 32, Ue = 64;
|
|
501
506
|
function ue(t, e) {
|
|
502
|
-
const n = new TextEncoder().encode(t), r =
|
|
503
|
-
return
|
|
507
|
+
const n = new TextEncoder().encode(t), r = W(n), i = new Uint8Array(r.length * 2 + e.length);
|
|
508
|
+
return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2), W(i);
|
|
504
509
|
}
|
|
505
510
|
function Fe(t) {
|
|
506
511
|
if (t.length !== le) return null;
|
|
@@ -510,11 +515,11 @@ function Fe(t) {
|
|
|
510
515
|
function Me(t, e, n) {
|
|
511
516
|
if (e.length !== le || n.length !== Ue) return !1;
|
|
512
517
|
try {
|
|
513
|
-
const r = ue(je, t),
|
|
518
|
+
const r = ue(je, t), i = we.p2tr({
|
|
514
519
|
internalPubkey: A.from(e)
|
|
515
520
|
});
|
|
516
|
-
if (!
|
|
517
|
-
const
|
|
521
|
+
if (!i.output) return !1;
|
|
522
|
+
const s = i.output, a = 0, c = new U();
|
|
518
523
|
c.version = 0, c.locktime = 0;
|
|
519
524
|
const u = A.concat([
|
|
520
525
|
A.from([0, 32]),
|
|
@@ -528,14 +533,14 @@ function Me(t, e, n) {
|
|
|
528
533
|
0,
|
|
529
534
|
// sequence = 0
|
|
530
535
|
u
|
|
531
|
-
), c.addOutput(
|
|
536
|
+
), c.addOutput(s, a);
|
|
532
537
|
const h = new U();
|
|
533
538
|
h.version = 0, h.locktime = 0;
|
|
534
539
|
const f = c.getHash();
|
|
535
540
|
h.addInput(f, 0, 0), h.addOutput(A.from([106]), a);
|
|
536
541
|
const P = h.hashForWitnessV1(
|
|
537
542
|
0,
|
|
538
|
-
[
|
|
543
|
+
[s],
|
|
539
544
|
[a],
|
|
540
545
|
U.SIGHASH_DEFAULT
|
|
541
546
|
), x = Fe(e);
|
|
@@ -550,33 +555,33 @@ function H(t, e) {
|
|
|
550
555
|
if (r < 24n) return new Uint8Array([n | Number(r)]);
|
|
551
556
|
if (r < 0x100n) return new Uint8Array([n | 24, Number(r)]);
|
|
552
557
|
if (r < 0x10000n) {
|
|
553
|
-
const
|
|
554
|
-
return new Uint8Array([n | 25,
|
|
558
|
+
const s = Number(r);
|
|
559
|
+
return new Uint8Array([n | 25, s >>> 8 & 255, s & 255]);
|
|
555
560
|
}
|
|
556
561
|
if (r < 0x100000000n) {
|
|
557
|
-
const
|
|
562
|
+
const s = Number(r);
|
|
558
563
|
return new Uint8Array([
|
|
559
564
|
n | 26,
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
565
|
+
s >>> 24 & 255,
|
|
566
|
+
s >>> 16 & 255,
|
|
567
|
+
s >>> 8 & 255,
|
|
568
|
+
s & 255
|
|
564
569
|
]);
|
|
565
570
|
}
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
for (let
|
|
569
|
-
|
|
570
|
-
return
|
|
571
|
+
const i = new Uint8Array(9);
|
|
572
|
+
i[0] = n | 27;
|
|
573
|
+
for (let s = 7; s >= 0; s--)
|
|
574
|
+
i[1 + s] = Number(r >> BigInt((7 - s) * 8)) & 255;
|
|
575
|
+
return i;
|
|
571
576
|
}
|
|
572
577
|
function he(...t) {
|
|
573
|
-
const e = t.reduce((
|
|
578
|
+
const e = t.reduce((i, s) => i + s.length, 0), n = new Uint8Array(e);
|
|
574
579
|
let r = 0;
|
|
575
|
-
for (const
|
|
576
|
-
n.set(
|
|
580
|
+
for (const i of t)
|
|
581
|
+
n.set(i, r), r += i.length;
|
|
577
582
|
return n;
|
|
578
583
|
}
|
|
579
|
-
function
|
|
584
|
+
function J(t) {
|
|
580
585
|
const n = [H(4, t.length)];
|
|
581
586
|
for (const r of t)
|
|
582
587
|
n.push(H(0, r));
|
|
@@ -587,8 +592,8 @@ function Le(t, e, n) {
|
|
|
587
592
|
throw new Error(
|
|
588
593
|
`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${n}`
|
|
589
594
|
);
|
|
590
|
-
const r = H(4, 3),
|
|
591
|
-
return he(r,
|
|
595
|
+
const r = H(4, 3), i = J(t), s = J(e), a = H(0, n);
|
|
596
|
+
return he(r, i, s, a);
|
|
592
597
|
}
|
|
593
598
|
const Ge = new TextEncoder().encode(
|
|
594
599
|
"btc-auth.server-identity.v1"
|
|
@@ -605,10 +610,10 @@ function E(t) {
|
|
|
605
610
|
return e;
|
|
606
611
|
}
|
|
607
612
|
function qe(t) {
|
|
608
|
-
const { proof: e, pinnedServerPubkey: n, now: r } = t,
|
|
609
|
-
if (
|
|
613
|
+
const { proof: e, pinnedServerPubkey: n, now: r } = t, i = t.maxLifetimeSecs ?? Xe, s = C(n).toLowerCase();
|
|
614
|
+
if (s.length !== R || !T.test(s))
|
|
610
615
|
throw new g(
|
|
611
|
-
`pinnedServerPubkey must be 32-byte hex; got ${
|
|
616
|
+
`pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
|
|
612
617
|
"invalid_pubkey_encoding"
|
|
613
618
|
);
|
|
614
619
|
const a = C(e.server_pubkey).toLowerCase();
|
|
@@ -617,9 +622,9 @@ function qe(t) {
|
|
|
617
622
|
`server_pubkey must be 32-byte hex; got ${a.length} chars`,
|
|
618
623
|
"invalid_pubkey_encoding"
|
|
619
624
|
);
|
|
620
|
-
if (a !==
|
|
625
|
+
if (a !== s)
|
|
621
626
|
throw new g(
|
|
622
|
-
`server_pubkey does not match pinned value: expected ${
|
|
627
|
+
`server_pubkey does not match pinned value: expected ${s}, got ${a}`,
|
|
623
628
|
"pinned_pubkey_mismatch"
|
|
624
629
|
);
|
|
625
630
|
if (!Number.isSafeInteger(e.expires_at))
|
|
@@ -637,14 +642,14 @@ function qe(t) {
|
|
|
637
642
|
`server identity proof expired at ${e.expires_at}, now ${r}`,
|
|
638
643
|
"expired"
|
|
639
644
|
);
|
|
640
|
-
if (!Number.isSafeInteger(
|
|
645
|
+
if (!Number.isSafeInteger(i) || i <= 0)
|
|
641
646
|
throw new g(
|
|
642
|
-
`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(
|
|
647
|
+
`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
|
|
643
648
|
"invalid_max_lifetime"
|
|
644
649
|
);
|
|
645
|
-
if (e.expires_at - r >
|
|
650
|
+
if (e.expires_at - r > i)
|
|
646
651
|
throw new g(
|
|
647
|
-
`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${
|
|
652
|
+
`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${i}s`,
|
|
648
653
|
"expires_too_far"
|
|
649
654
|
);
|
|
650
655
|
const c = C(e.ephemeral_pubkey).toLowerCase();
|
|
@@ -689,14 +694,14 @@ const ze = /* @__PURE__ */ new Set([
|
|
|
689
694
|
"vaultProvider_requestDepositorClaimerArtifacts"
|
|
690
695
|
]), We = 6e4, G = "auth_createDepositorToken";
|
|
691
696
|
function de(t, e) {
|
|
692
|
-
return new
|
|
697
|
+
return new se({
|
|
693
698
|
baseUrl: t,
|
|
694
699
|
timeout: We,
|
|
695
700
|
headers: e,
|
|
696
701
|
retryableFor: (n) => n === G
|
|
697
702
|
});
|
|
698
703
|
}
|
|
699
|
-
const
|
|
704
|
+
const Y = 4102444800, Qe = 30;
|
|
700
705
|
class Je {
|
|
701
706
|
constructor(e) {
|
|
702
707
|
// `client` is the only mutable field — see `setClient`. The
|
|
@@ -766,16 +771,16 @@ class Je {
|
|
|
766
771
|
throw new Error(
|
|
767
772
|
`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
|
|
768
773
|
);
|
|
769
|
-
const
|
|
770
|
-
if (!Number.isSafeInteger(r.expires_at) || r.expires_at <=
|
|
774
|
+
const i = this.now();
|
|
775
|
+
if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= i || r.expires_at > Y)
|
|
771
776
|
throw new Error(
|
|
772
|
-
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${
|
|
777
|
+
`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${i}, ${Y}])`
|
|
773
778
|
);
|
|
774
|
-
const
|
|
779
|
+
const s = {
|
|
775
780
|
token: r.token,
|
|
776
781
|
expiresAt: r.expires_at
|
|
777
782
|
};
|
|
778
|
-
return this.cached =
|
|
783
|
+
return this.cached = s, s;
|
|
779
784
|
} finally {
|
|
780
785
|
this.inFlight = null;
|
|
781
786
|
}
|
|
@@ -892,7 +897,7 @@ async function dt(t, e) {
|
|
|
892
897
|
applicationRegistry: r
|
|
893
898
|
};
|
|
894
899
|
}
|
|
895
|
-
const M = 65535,
|
|
900
|
+
const M = 65535, Z = 1e4, O = 4294967295, ee = 255;
|
|
896
901
|
function X(t) {
|
|
897
902
|
if (!Number.isInteger(t) || t < 0 || t > O)
|
|
898
903
|
throw new Error(
|
|
@@ -921,8 +926,8 @@ function N(t) {
|
|
|
921
926
|
`babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`
|
|
922
927
|
), t.babeInstancesToFinalize > t.babeTotalInstances && e.push(
|
|
923
928
|
`babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`
|
|
924
|
-
), (t.minVpCommissionBps < 0 || t.minVpCommissionBps >
|
|
925
|
-
`minVpCommissionBps must be in [0, ${
|
|
929
|
+
), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > Z) && e.push(
|
|
930
|
+
`minVpCommissionBps must be in [0, ${Z}], got ${t.minVpCommissionBps}`
|
|
926
931
|
), e.length > 0)
|
|
927
932
|
throw new Error(
|
|
928
933
|
`Invalid offchain protocol parameters: ${e.join("; ")}`
|
|
@@ -938,8 +943,8 @@ function ge(t) {
|
|
|
938
943
|
`pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`
|
|
939
944
|
), t.pegInActivationTimeout <= 0n && e.push(
|
|
940
945
|
`pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`
|
|
941
|
-
), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount >
|
|
942
|
-
`maxHtlcOutputCount must be an integer in [1, ${
|
|
946
|
+
), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > ee) && e.push(
|
|
947
|
+
`maxHtlcOutputCount must be an integer in [1, ${ee}], got ${t.maxHtlcOutputCount}`
|
|
943
948
|
), e.length > 0)
|
|
944
949
|
throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`);
|
|
945
950
|
}
|
|
@@ -949,7 +954,7 @@ function Ze(t) {
|
|
|
949
954
|
`Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`
|
|
950
955
|
);
|
|
951
956
|
}
|
|
952
|
-
const
|
|
957
|
+
const te = 65535;
|
|
953
958
|
function B(t) {
|
|
954
959
|
return {
|
|
955
960
|
timelockAssert: t.timelockAssert,
|
|
@@ -967,7 +972,7 @@ function B(t) {
|
|
|
967
972
|
minPrepeginDepth: t.minPrepeginDepth
|
|
968
973
|
};
|
|
969
974
|
}
|
|
970
|
-
function
|
|
975
|
+
function ne(t) {
|
|
971
976
|
return {
|
|
972
977
|
minimumPegInAmount: t.minimumPegInAmount,
|
|
973
978
|
maxPegInAmount: t.maxPegInAmount,
|
|
@@ -976,10 +981,10 @@ function te(t) {
|
|
|
976
981
|
maxHtlcOutputCount: t.maxHtlcOutputCount
|
|
977
982
|
};
|
|
978
983
|
}
|
|
979
|
-
function
|
|
980
|
-
if (t > BigInt(
|
|
984
|
+
function re(t) {
|
|
985
|
+
if (t > BigInt(te))
|
|
981
986
|
throw new Error(
|
|
982
|
-
`timelockAssert value ${t} exceeds uint16 max (${
|
|
987
|
+
`timelockAssert value ${t} exceeds uint16 max (${te})`
|
|
983
988
|
);
|
|
984
989
|
return Number(t);
|
|
985
990
|
}
|
|
@@ -992,7 +997,7 @@ class pt {
|
|
|
992
997
|
address: this.contractAddress,
|
|
993
998
|
abi: _,
|
|
994
999
|
functionName: "getTBVProtocolParams"
|
|
995
|
-
}), n =
|
|
1000
|
+
}), n = ne(e);
|
|
996
1001
|
return ge(n), n;
|
|
997
1002
|
}
|
|
998
1003
|
async getLatestOffchainParams() {
|
|
@@ -1022,7 +1027,7 @@ class pt {
|
|
|
1022
1027
|
}
|
|
1023
1028
|
async getTimelockPeginByVersion(e) {
|
|
1024
1029
|
const n = await this.getOffchainParamsByVersion(e);
|
|
1025
|
-
return
|
|
1030
|
+
return re(n.timelockAssert);
|
|
1026
1031
|
}
|
|
1027
1032
|
/**
|
|
1028
1033
|
* Read TBV protocol params, latest offchain params, and the latest version
|
|
@@ -1051,19 +1056,19 @@ class pt {
|
|
|
1051
1056
|
}
|
|
1052
1057
|
],
|
|
1053
1058
|
allowFailure: !1
|
|
1054
|
-
}), n =
|
|
1059
|
+
}), n = ne(e[0]), r = B(e[1]), i = Number(e[2]), s = {
|
|
1055
1060
|
minimumPegInAmount: n.minimumPegInAmount,
|
|
1056
1061
|
maxPegInAmount: n.maxPegInAmount,
|
|
1057
1062
|
pegInAckTimeout: n.pegInAckTimeout,
|
|
1058
1063
|
pegInActivationTimeout: n.pegInActivationTimeout,
|
|
1059
1064
|
maxHtlcOutputCount: n.maxHtlcOutputCount,
|
|
1060
|
-
timelockPegin:
|
|
1065
|
+
timelockPegin: re(r.timelockAssert),
|
|
1061
1066
|
timelockRefund: r.tRefund,
|
|
1062
1067
|
minVpCommissionBps: r.minVpCommissionBps,
|
|
1063
1068
|
offchainParams: r,
|
|
1064
|
-
offchainParamsVersion:
|
|
1069
|
+
offchainParamsVersion: i
|
|
1065
1070
|
};
|
|
1066
|
-
return Ze(
|
|
1071
|
+
return Ze(s), s;
|
|
1067
1072
|
}
|
|
1068
1073
|
/**
|
|
1069
1074
|
* Fetch every historical offchain params version in a single multicall.
|
|
@@ -1079,17 +1084,17 @@ class pt {
|
|
|
1079
1084
|
const n = await this.getLatestOffchainParamsVersion();
|
|
1080
1085
|
if (n === 0)
|
|
1081
1086
|
return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
|
|
1082
|
-
const r = Array.from({ length: n }, (c, u) => u + 1),
|
|
1087
|
+
const r = Array.from({ length: n }, (c, u) => u + 1), i = r.map((c) => ({
|
|
1083
1088
|
address: this.contractAddress,
|
|
1084
1089
|
abi: _,
|
|
1085
1090
|
functionName: "getOffchainParamsByVersion",
|
|
1086
1091
|
args: [c]
|
|
1087
|
-
})),
|
|
1088
|
-
contracts:
|
|
1092
|
+
})), s = await this.publicClient.multicall({
|
|
1093
|
+
contracts: i,
|
|
1089
1094
|
allowFailure: !1
|
|
1090
1095
|
}), a = /* @__PURE__ */ new Map();
|
|
1091
1096
|
for (let c = 0; c < r.length; c++) {
|
|
1092
|
-
const u = B(
|
|
1097
|
+
const u = B(s[c]);
|
|
1093
1098
|
try {
|
|
1094
1099
|
N(u), a.set(r[c], u);
|
|
1095
1100
|
} catch (h) {
|
|
@@ -1189,12 +1194,12 @@ class mt {
|
|
|
1189
1194
|
throw new Error(
|
|
1190
1195
|
`getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0, 2)}")`
|
|
1191
1196
|
);
|
|
1192
|
-
const
|
|
1193
|
-
if (!j.isXOnlyPoint(Pe(
|
|
1197
|
+
const i = r.slice(2);
|
|
1198
|
+
if (!j.isXOnlyPoint(Pe(i)))
|
|
1194
1199
|
throw new Error(
|
|
1195
1200
|
`getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`
|
|
1196
1201
|
);
|
|
1197
|
-
return
|
|
1202
|
+
return i;
|
|
1198
1203
|
}
|
|
1199
1204
|
async getVaultBasicInfo(e) {
|
|
1200
1205
|
const n = await this.publicClient.readContract({
|
|
@@ -1243,24 +1248,24 @@ class mt {
|
|
|
1243
1248
|
args: [r]
|
|
1244
1249
|
})),
|
|
1245
1250
|
allowFailure: !1
|
|
1246
|
-
})).map((r,
|
|
1247
|
-
const
|
|
1248
|
-
if (!
|
|
1251
|
+
})).map((r, i) => {
|
|
1252
|
+
const s = r;
|
|
1253
|
+
if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
|
|
1249
1254
|
throw new Error(
|
|
1250
|
-
`Vault ${e[
|
|
1255
|
+
`Vault ${e[i]} not found on-chain or has no pegin transaction`
|
|
1251
1256
|
);
|
|
1252
1257
|
return {
|
|
1253
|
-
depositorSignedPeginTx:
|
|
1254
|
-
universalChallengersVersion:
|
|
1255
|
-
appVaultKeepersVersion:
|
|
1256
|
-
offchainParamsVersion:
|
|
1257
|
-
verifiedAt:
|
|
1258
|
-
depositorWotsPkHash:
|
|
1259
|
-
hashlock:
|
|
1260
|
-
htlcVout:
|
|
1261
|
-
depositorPopSignature:
|
|
1262
|
-
prePeginTxHash:
|
|
1263
|
-
vaultProviderCommissionBps:
|
|
1258
|
+
depositorSignedPeginTx: s.depositorSignedPeginTx,
|
|
1259
|
+
universalChallengersVersion: s.universalChallengersVersion,
|
|
1260
|
+
appVaultKeepersVersion: s.appVaultKeepersVersion,
|
|
1261
|
+
offchainParamsVersion: s.offchainParamsVersion,
|
|
1262
|
+
verifiedAt: s.verifiedAt,
|
|
1263
|
+
depositorWotsPkHash: s.depositorWotsPkHash,
|
|
1264
|
+
hashlock: s.hashlock,
|
|
1265
|
+
htlcVout: s.htlcVout,
|
|
1266
|
+
depositorPopSignature: s.depositorPopSignature,
|
|
1267
|
+
prePeginTxHash: s.prePeginTxHash,
|
|
1268
|
+
vaultProviderCommissionBps: s.vaultProviderCommissionBps
|
|
1264
1269
|
};
|
|
1265
1270
|
});
|
|
1266
1271
|
}
|
|
@@ -1290,13 +1295,13 @@ class mt {
|
|
|
1290
1295
|
})),
|
|
1291
1296
|
allowFailure: !1
|
|
1292
1297
|
})).map((r) => {
|
|
1293
|
-
const
|
|
1294
|
-
if (!
|
|
1298
|
+
const i = r;
|
|
1299
|
+
if (!i.depositorSignedPeginTx || i.depositorSignedPeginTx === "0x")
|
|
1295
1300
|
throw new Error(
|
|
1296
1301
|
"Vault not found on-chain or has no pegin transaction while reading offchain params version"
|
|
1297
1302
|
);
|
|
1298
|
-
const
|
|
1299
|
-
return X(
|
|
1303
|
+
const s = Number(i.offchainParamsVersion);
|
|
1304
|
+
return X(s), s;
|
|
1300
1305
|
});
|
|
1301
1306
|
}
|
|
1302
1307
|
}
|
|
@@ -1320,4 +1325,4 @@ export {
|
|
|
1320
1325
|
dt as r,
|
|
1321
1326
|
ke as v
|
|
1322
1327
|
};
|
|
1323
|
-
//# sourceMappingURL=vault-registry-reader-
|
|
1328
|
+
//# sourceMappingURL=vault-registry-reader-CohvzvoH.js.map
|