@babylonlabs-io/ts-sdk 0.73.0 → 0.74.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PeginManager-E-UHA1un.cjs → PeginManager-DEByBX5R.cjs} +2 -2
- package/dist/{PeginManager-E-UHA1un.cjs.map → PeginManager-DEByBX5R.cjs.map} +1 -1
- package/dist/{PeginManager-C9RPOd0L.js → PeginManager-DNimKlmw.js} +11 -11
- package/dist/{PeginManager-C9RPOd0L.js.map → PeginManager-DNimKlmw.js.map} +1 -1
- package/dist/{bip322Verify-D6sBBUHE.js → bip322Verify-DSco3Yhl.js} +2 -2
- package/dist/{bip322Verify-D6sBBUHE.js.map → bip322Verify-DSco3Yhl.js.map} +1 -1
- package/dist/buildAndBroadcastReclaim-Cqc6Jiqk.cjs +2 -0
- package/dist/{buildAndBroadcastReclaim-U-PyFfDg.cjs.map → buildAndBroadcastReclaim-Cqc6Jiqk.cjs.map} +1 -1
- package/dist/{buildAndBroadcastReclaim-BXclIcu_.js → buildAndBroadcastReclaim-DCGcupg7.js} +6 -6
- package/dist/{buildAndBroadcastReclaim-BXclIcu_.js.map → buildAndBroadcastReclaim-DCGcupg7.js.map} +1 -1
- package/dist/constants-BTZdyOuk.cjs +2 -0
- package/dist/constants-BTZdyOuk.cjs.map +1 -0
- package/dist/constants-D5vORbQE.js +29 -0
- package/dist/constants-D5vORbQE.js.map +1 -0
- package/dist/fundPeginTransaction-54-Rwb2k.cjs +2 -0
- package/dist/fundPeginTransaction-54-Rwb2k.cjs.map +1 -0
- package/dist/fundPeginTransaction-CwhRbCQC.js +88 -0
- package/dist/fundPeginTransaction-CwhRbCQC.js.map +1 -0
- package/dist/{index-Cs7_Evtk.cjs → index-CK1Xvq4K.cjs} +2 -2
- package/dist/{index-Cs7_Evtk.cjs.map → index-CK1Xvq4K.cjs.map} +1 -1
- package/dist/{index-LgmJhdEN.js → index-DQ5bfoT3.js} +2 -2
- package/dist/{index-LgmJhdEN.js.map → index-DQ5bfoT3.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +166 -161
- package/dist/noPayout-4RZB2g1e.cjs +2 -0
- package/dist/noPayout-4RZB2g1e.cjs.map +1 -0
- package/dist/noPayout-DiGr4eas.js +361 -0
- package/dist/noPayout-DiGr4eas.js.map +1 -0
- package/dist/{parseFundingOutpoints-B67CoXpF.js → parseFundingOutpoints-BQWvINfm.js} +2 -2
- package/dist/{parseFundingOutpoints-B67CoXpF.js.map → parseFundingOutpoints-BQWvINfm.js.map} +1 -1
- package/dist/pegin-registration-client-CXK3B_D1.js +882 -0
- package/dist/pegin-registration-client-CXK3B_D1.js.map +1 -0
- package/dist/pegin-registration-client-DLsMNm8Z.cjs +2 -0
- package/dist/pegin-registration-client-DLsMNm8Z.cjs.map +1 -0
- package/dist/{primeVpAuth-DBHohVKM.cjs → primeVpAuth-BOGKniTl.cjs} +2 -2
- package/dist/{primeVpAuth-DBHohVKM.cjs.map → primeVpAuth-BOGKniTl.cjs.map} +1 -1
- package/dist/{primeVpAuth-DvaD45q_.js → primeVpAuth-DdfHSC53.js} +4 -4
- package/dist/{primeVpAuth-DvaD45q_.js.map → primeVpAuth-DdfHSC53.js.map} +1 -1
- package/dist/{psbtInputFields-BIxBpPj2.cjs → psbtInputFields-BrV_ZfL_.cjs} +2 -2
- package/dist/{psbtInputFields-BIxBpPj2.cjs.map → psbtInputFields-BrV_ZfL_.cjs.map} +1 -1
- package/dist/{psbtInputFields-B3e05Xe6.js → psbtInputFields-CCVyaQMi.js} +2 -2
- package/dist/{psbtInputFields-B3e05Xe6.js.map → psbtInputFields-CCVyaQMi.js.map} +1 -1
- package/dist/secp256k1-D-H9jmd7.js +1766 -0
- package/dist/secp256k1-D-H9jmd7.js.map +1 -0
- package/dist/secp256k1-DDHQ1_za.cjs +2 -0
- package/dist/secp256k1-DDHQ1_za.cjs.map +1 -0
- package/dist/{sha2-CrlWM5S8.js → sha2-CLpQd0Rd.js} +8 -8
- package/dist/{sha2-CrlWM5S8.js.map → sha2-CLpQd0Rd.js.map} +1 -1
- package/dist/{signPsbtsWithFallback-DMSpIQWH.cjs → signPsbtsWithFallback-DtwzL5AA.cjs} +2 -2
- package/dist/{signPsbtsWithFallback-DMSpIQWH.cjs.map → signPsbtsWithFallback-DtwzL5AA.cjs.map} +1 -1
- package/dist/{signPsbtsWithFallback-0VBALhjS.js → signPsbtsWithFallback-f7QLp0q8.js} +4 -4
- package/dist/{signPsbtsWithFallback-0VBALhjS.js.map → signPsbtsWithFallback-f7QLp0q8.js.map} +1 -1
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +3 -3
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +5 -5
- package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.js +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +3 -0
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +159 -154
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.golden.test.d.ts +62 -0
- package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.golden.test.d.ts.map +1 -0
- package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.test.d.ts +15 -0
- package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.test.d.ts.map +1 -0
- package/dist/tbv/core/pegin-fingerprint/index.d.ts +14 -0
- package/dist/tbv/core/pegin-fingerprint/index.d.ts.map +1 -0
- package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts +141 -0
- package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts.map +1 -0
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.js +4 -4
- package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +5 -6
- package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/__tests__/assertWasmPeginSizing.test.d.ts +2 -2
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +36 -14
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/constants.d.ts +39 -0
- package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +2 -2
- package/dist/tbv/core/utils/fee/constants.d.ts +4 -4
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +2 -2
- package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +159 -154
- package/dist/test/setup.browser.d.ts +2 -0
- package/dist/test/setup.browser.d.ts.map +1 -0
- package/dist/testing/index.js +1 -1
- package/dist/{toRefundInputs-BkcFhvDp.js → toRefundInputs-BNSXIymn.js} +238 -140
- package/dist/toRefundInputs-BNSXIymn.js.map +1 -0
- package/dist/toRefundInputs-meTyor7r.cjs +2 -0
- package/dist/toRefundInputs-meTyor7r.cjs.map +1 -0
- package/dist/{types-DSlcXtog.cjs → types-BzSOthHH.cjs} +2 -2
- package/dist/{types-DSlcXtog.cjs.map → types-BzSOthHH.cjs.map} +1 -1
- package/dist/{types-CPDLZm3l.js → types-C5DyrC8F.js} +2 -2
- package/dist/{types-CPDLZm3l.js.map → types-C5DyrC8F.js.map} +1 -1
- package/dist/verifyKeyPathSchnorrSignature-BVtNwgK6.js +360 -0
- package/dist/verifyKeyPathSchnorrSignature-BVtNwgK6.js.map +1 -0
- package/dist/verifyKeyPathSchnorrSignature-BjB8Znly.cjs +2 -0
- package/dist/verifyKeyPathSchnorrSignature-BjB8Znly.cjs.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-D_epga4j.js +1140 -0
- package/dist/verifyScriptPathSchnorrSignature-D_epga4j.js.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs.map +1 -0
- package/package.json +5 -2
- package/dist/buildAndBroadcastReclaim-U-PyFfDg.cjs +0 -2
- package/dist/constants-Bh38W9mq.cjs +0 -2
- package/dist/constants-Bh38W9mq.cjs.map +0 -1
- package/dist/constants-CPzppOdq.js +0 -17
- package/dist/constants-CPzppOdq.js.map +0 -1
- package/dist/fundPeginTransaction-B2wyjqp0.js +0 -83
- package/dist/fundPeginTransaction-B2wyjqp0.js.map +0 -1
- package/dist/fundPeginTransaction-BLD8FRL9.cjs +0 -2
- package/dist/fundPeginTransaction-BLD8FRL9.cjs.map +0 -1
- package/dist/noPayout-DpGRzidi.js +0 -353
- package/dist/noPayout-DpGRzidi.js.map +0 -1
- package/dist/noPayout-zEifyecV.cjs +0 -2
- package/dist/noPayout-zEifyecV.cjs.map +0 -1
- package/dist/pegin-registration-client-6vLk2itL.cjs +0 -2
- package/dist/pegin-registration-client-6vLk2itL.cjs.map +0 -1
- package/dist/pegin-registration-client-BdRiR8br.js +0 -2635
- package/dist/pegin-registration-client-BdRiR8br.js.map +0 -1
- package/dist/toRefundInputs-BkcFhvDp.js.map +0 -1
- package/dist/toRefundInputs-CatCKniS.cjs +0 -2
- package/dist/toRefundInputs-CatCKniS.cjs.map +0 -1
- package/dist/vaultCoreVersion-DYfw3qed.cjs +0 -2
- package/dist/vaultCoreVersion-DYfw3qed.cjs.map +0 -1
- package/dist/vaultCoreVersion-D_fP9P3C.js +0 -10
- package/dist/vaultCoreVersion-D_fP9P3C.js.map +0 -1
- package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs +0 -2
- package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs.map +0 -1
- package/dist/verifyKeyPathSchnorrSignature-BrgUJmV0.js +0 -372
- package/dist/verifyKeyPathSchnorrSignature-BrgUJmV0.js.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-Ciq_xZhw.js +0 -951
- package/dist/verifyScriptPathSchnorrSignature-Ciq_xZhw.js.map +0 -1
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { c as
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
var re = Object.defineProperty;
|
|
2
|
+
var ne = (e, t, r) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var _ = (e, t, r) => ne(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { keccak256 as G, toHex as oe, encodeAbiParameters as se, isAddress as ae, zeroAddress as ie } from "viem";
|
|
5
|
+
import { s as ce } from "./sha2-CLpQd0Rd.js";
|
|
6
|
+
import { a as M } from "./signPsbtsWithFallback-f7QLp0q8.js";
|
|
7
|
+
import { b as ue, f as le } from "./PeginManager-DNimKlmw.js";
|
|
8
|
+
import { s as P, h as he, p as W, u as de, e as me } from "./bitcoin-C-TuHb-v.js";
|
|
9
|
+
import { computeMinClaimValue as Q, computeMinPeginFee as X, peginP2aAnchorOutput as q, getPrePeginHtlcConnectorInfo as pe, expandAuthAnchor as ge } from "./tbv/core/wasm/index.js";
|
|
10
|
+
import { p as Pe, d as fe } from "./parseFundingOutpoints-BQWvINfm.js";
|
|
11
|
+
import { Transaction as J } from "bitcoinjs-lib";
|
|
12
|
+
import { o as ve, H as z } from "./verifyScriptPathSchnorrSignature-D_epga4j.js";
|
|
13
|
+
import { c as O } from "./fundPeginTransaction-CwhRbCQC.js";
|
|
14
|
+
import { c as Y } from "./signing-Cm-McVR2.js";
|
|
15
|
+
const Z = "DepositTermsRejectedError";
|
|
16
|
+
class be extends Error {
|
|
16
17
|
constructor(r, n = "device-envelope") {
|
|
17
18
|
super(r);
|
|
18
|
-
|
|
19
|
-
this.name =
|
|
19
|
+
_(this, "reason");
|
|
20
|
+
this.name = Z, this.reason = n;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
if (e instanceof
|
|
23
|
+
function qe(e) {
|
|
24
|
+
if (e instanceof be) return !0;
|
|
24
25
|
if (typeof e != "object" || e === null) return !1;
|
|
25
26
|
const t = e;
|
|
26
|
-
return t.name ===
|
|
27
|
+
return t.name === Z && t.reason === "device-envelope";
|
|
27
28
|
}
|
|
28
|
-
async function
|
|
29
|
+
async function ye(e) {
|
|
29
30
|
const t = e.siblings.length;
|
|
30
31
|
if (t === 0)
|
|
31
32
|
throw new Error(
|
|
32
33
|
"rebuildDepositTermsCore: at least one sibling is required"
|
|
33
34
|
);
|
|
34
|
-
for (const [o,
|
|
35
|
-
if (
|
|
35
|
+
for (const [o, b] of e.siblings.entries())
|
|
36
|
+
if (b.amount <= 0n)
|
|
36
37
|
throw new Error(
|
|
37
|
-
`rebuildDepositTermsCore: sibling[${o}] has non-positive on-chain pegin amount ${
|
|
38
|
+
`rebuildDepositTermsCore: sibling[${o}] has non-positive on-chain pegin amount ${b.amount}; the chain-read vault record is invalid. Resume refused.`
|
|
38
39
|
);
|
|
39
40
|
if (e.prepeginMaxFee <= 0n)
|
|
40
41
|
throw new Error(
|
|
41
42
|
`rebuildDepositTermsCore: prepeginMaxFee must be > 0, got ${e.prepeginMaxFee}`
|
|
42
43
|
);
|
|
43
44
|
const r = P(e.prepeginTxid).toLowerCase(), n = P(
|
|
44
|
-
|
|
45
|
+
Y(e.fundedPrePeginTxHex)
|
|
45
46
|
).toLowerCase();
|
|
46
47
|
if (n !== r)
|
|
47
48
|
throw new Error(
|
|
48
49
|
`Funded Pre-PegIn tx hashes to ${n}, expected ${r} (on-chain prepeginTxid). Resume refused.`
|
|
49
50
|
);
|
|
50
|
-
const h =
|
|
51
|
+
const h = M(
|
|
51
52
|
P(e.fundedPrePeginTxHex)
|
|
52
53
|
);
|
|
53
54
|
if (h === void 0)
|
|
@@ -58,19 +59,19 @@ async function ue(e) {
|
|
|
58
59
|
throw new Error(
|
|
59
60
|
`Auth-anchor OP_RETURN at vout ${h.vout} does not match the discovered sibling count ${t}; the discovered sibling set does not cover this transaction's HTLC outputs (a lagging index can cause this — retry later). Resume refused.`
|
|
60
61
|
);
|
|
61
|
-
const c = e.vaultKeeperBtcPubkeys.length, u = e.universalChallengerBtcPubkeys.length, l = await
|
|
62
|
+
const c = e.vaultKeeperBtcPubkeys.length, u = e.universalChallengerBtcPubkeys.length, l = await Q(
|
|
62
63
|
e.vaultCoreVersion,
|
|
63
64
|
c,
|
|
64
65
|
u,
|
|
65
66
|
e.councilQuorum,
|
|
66
67
|
e.councilSize,
|
|
67
68
|
e.protocolFeeRate
|
|
68
|
-
), i = await
|
|
69
|
+
), i = await X(
|
|
69
70
|
e.vaultCoreVersion,
|
|
70
71
|
c,
|
|
71
72
|
u,
|
|
72
73
|
e.minPeginFeeRate
|
|
73
|
-
), d = await
|
|
74
|
+
), d = await q(e.vaultCoreVersion), s = (d == null ? void 0 : d.value) ?? 0n;
|
|
74
75
|
if (l <= 0n)
|
|
75
76
|
throw new Error(
|
|
76
77
|
`WASM returned non-positive depositorClaimValue ${l}; expected > 0. Resume refused.`
|
|
@@ -83,15 +84,15 @@ async function ue(e) {
|
|
|
83
84
|
throw new Error(
|
|
84
85
|
`WASM returned negative P2A anchor value ${s}. Resume refused.`
|
|
85
86
|
);
|
|
86
|
-
const a = i + s,
|
|
87
|
-
if (a <= 0n || a >
|
|
87
|
+
const a = i + s, v = e.minPeginFeeRate * O;
|
|
88
|
+
if (a <= 0n || a > v)
|
|
88
89
|
throw new Error(
|
|
89
|
-
`WASM implied PegIn reserve ${a} sat is outside (0, ${
|
|
90
|
+
`WASM implied PegIn reserve ${a} sat is outside (0, ${v}] (minPeginFeeRate=${e.minPeginFeeRate} × ${O} vbytes). Resume refused.`
|
|
90
91
|
);
|
|
91
92
|
const w = e.siblings.map(
|
|
92
93
|
(o) => o.amount + l + i + s
|
|
93
|
-
),
|
|
94
|
-
e.siblings.map(async (o) => (await
|
|
94
|
+
), C = await Promise.all(
|
|
95
|
+
e.siblings.map(async (o) => (await pe({
|
|
95
96
|
txGraphVersion: e.vaultCoreVersion,
|
|
96
97
|
depositorPubkey: e.depositorBtcPubkey,
|
|
97
98
|
vaultProviderPubkey: e.vaultProviderBtcPubkey,
|
|
@@ -101,14 +102,14 @@ async function ue(e) {
|
|
|
101
102
|
timelockRefund: e.timelockRefund,
|
|
102
103
|
network: e.network
|
|
103
104
|
})).scriptPubKey)
|
|
104
|
-
),
|
|
105
|
+
), E = J.fromHex(
|
|
105
106
|
P(e.fundedPrePeginTxHex)
|
|
106
107
|
).outs.map((o) => ({ value: o.value, script: o.script }));
|
|
107
|
-
return
|
|
108
|
-
|
|
108
|
+
return ve(
|
|
109
|
+
E,
|
|
109
110
|
w,
|
|
110
|
-
|
|
111
|
-
),
|
|
111
|
+
C
|
|
112
|
+
), ue({
|
|
112
113
|
vaultCoreVersion: e.vaultCoreVersion,
|
|
113
114
|
protocolFeeRate: e.protocolFeeRate,
|
|
114
115
|
timelockPegin: e.timelockPegin,
|
|
@@ -125,85 +126,177 @@ async function ue(e) {
|
|
|
125
126
|
peginMaxFee: i
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function Je(e) {
|
|
129
130
|
const t = (e instanceof Error ? e.message : typeof e == "string" ? e : "").toLowerCase();
|
|
130
131
|
return t.includes("wots") && t.includes("hash") && t.includes("does not match");
|
|
131
132
|
}
|
|
132
|
-
|
|
133
|
+
const we = "TBV.PeginFingerprint.v1", Ee = G(
|
|
134
|
+
oe(we)
|
|
135
|
+
), U = 65535, D = 2n ** 64n - 1n, Ce = 2n ** 256n - 1n, Re = /^0x[0-9a-fA-F]{64}$/, L = 1;
|
|
136
|
+
class f extends Error {
|
|
137
|
+
constructor(t) {
|
|
138
|
+
super(t), this.name = "PeginFingerprintInputError";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function B(e, t, r, n) {
|
|
142
|
+
if (typeof t != "bigint")
|
|
143
|
+
throw new f(
|
|
144
|
+
`${e} must be a bigint (Solidity ${n}), got ${typeof t}`
|
|
145
|
+
);
|
|
146
|
+
if (t < 0n || t > r)
|
|
147
|
+
throw new f(
|
|
148
|
+
`${e} must fit Solidity ${n} (0..${r}), got ${t}`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
function $(e, t) {
|
|
152
|
+
if (!Number.isInteger(t) || t < 0 || t > U)
|
|
153
|
+
throw new f(
|
|
154
|
+
`${e} must be an integer fitting Solidity uint16 (0..${U}), got ${t}`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function ke(e, t) {
|
|
158
|
+
if (!Re.test(t))
|
|
159
|
+
throw new f(
|
|
160
|
+
`${e} must be 32 bytes as 0x-prefixed hex (66 characters), got "${t}"`
|
|
161
|
+
);
|
|
162
|
+
return t.toLowerCase();
|
|
163
|
+
}
|
|
164
|
+
function xe(e) {
|
|
165
|
+
if (!ae(e, { strict: !1 }))
|
|
166
|
+
throw new f(
|
|
167
|
+
`registryAddress must be a 20-byte 0x-prefixed address, got "${e}"`
|
|
168
|
+
);
|
|
169
|
+
const t = e.toLowerCase();
|
|
170
|
+
if (t === ie)
|
|
171
|
+
throw new f(
|
|
172
|
+
"registryAddress must not be the zero address; a zero here means the registry address was never resolved"
|
|
173
|
+
);
|
|
174
|
+
return t;
|
|
175
|
+
}
|
|
176
|
+
const Ve = [
|
|
177
|
+
{ name: "domain", type: "bytes32" },
|
|
178
|
+
{ name: "chainId", type: "uint256" },
|
|
179
|
+
{ name: "registry", type: "address" },
|
|
180
|
+
{ name: "vaultProviderBtcKey", type: "bytes32" },
|
|
181
|
+
{ name: "appKeeperKeyEpoch", type: "uint64" },
|
|
182
|
+
{ name: "ucKeyEpoch", type: "uint64" },
|
|
183
|
+
{ name: "appVaultKeepersVersion", type: "uint16" },
|
|
184
|
+
{ name: "universalChallengersVersion", type: "uint16" },
|
|
185
|
+
{ name: "offchainParamsVersion", type: "uint16" },
|
|
186
|
+
{ name: "vaultCoreVersion", type: "uint16" }
|
|
187
|
+
];
|
|
188
|
+
function $e(e) {
|
|
189
|
+
if (B("chainId", e.chainId, Ce, "uint256"), e.chainId === 0n)
|
|
190
|
+
throw new f(
|
|
191
|
+
"chainId must not be 0; a zero here means the chain id was never resolved"
|
|
192
|
+
);
|
|
193
|
+
const t = xe(e.registryAddress), r = ke(
|
|
194
|
+
"vaultProviderBtcKey",
|
|
195
|
+
e.vaultProviderBtcKey
|
|
196
|
+
);
|
|
197
|
+
if (B(
|
|
198
|
+
"appKeeperKeyEpoch",
|
|
199
|
+
e.appKeeperKeyEpoch,
|
|
200
|
+
D,
|
|
201
|
+
"uint64"
|
|
202
|
+
), B("ucKeyEpoch", e.ucKeyEpoch, D, "uint64"), $("appVaultKeepersVersion", e.appVaultKeepersVersion), $(
|
|
203
|
+
"universalChallengersVersion",
|
|
204
|
+
e.universalChallengersVersion
|
|
205
|
+
), $("offchainParamsVersion", e.offchainParamsVersion), $("vaultCoreVersion", e.vaultCoreVersion), e.vaultCoreVersion < L)
|
|
206
|
+
throw new f(
|
|
207
|
+
`vaultCoreVersion must be at least ${L}; ${e.vaultCoreVersion} means the version was never resolved`
|
|
208
|
+
);
|
|
209
|
+
return se(Ve, [
|
|
210
|
+
Ee,
|
|
211
|
+
e.chainId,
|
|
212
|
+
t,
|
|
213
|
+
r,
|
|
214
|
+
e.appKeeperKeyEpoch,
|
|
215
|
+
e.ucKeyEpoch,
|
|
216
|
+
e.appVaultKeepersVersion,
|
|
217
|
+
e.universalChallengersVersion,
|
|
218
|
+
e.offchainParamsVersion,
|
|
219
|
+
e.vaultCoreVersion
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
function Ye(e) {
|
|
223
|
+
return G($e(e));
|
|
224
|
+
}
|
|
225
|
+
class Te extends Error {
|
|
133
226
|
constructor(t, r) {
|
|
134
227
|
super(
|
|
135
228
|
`Re-derived vault root does not match this Pre-PegIn: derived auth-anchor hash ${t}, transaction commits to ${r}. Connect the same wallet, on the same account and the same network, that created the deposit.`
|
|
136
229
|
), this.derivedAuthAnchorHash = t, this.onChainAuthAnchorHash = r, this.name = "VaultRootMismatchError";
|
|
137
230
|
}
|
|
138
231
|
}
|
|
139
|
-
class
|
|
232
|
+
class K extends Error {
|
|
140
233
|
constructor(t) {
|
|
141
234
|
super(t), this.name = "UnanchoredPrePeginError";
|
|
142
235
|
}
|
|
143
236
|
}
|
|
144
|
-
class
|
|
237
|
+
class Ae extends Error {
|
|
145
238
|
constructor(t, r, n = []) {
|
|
146
239
|
super(
|
|
147
240
|
`No candidate parameter set reproduces this Pre-PegIn's HTLC outputs (${t} candidate(s) tried). ` + (n.length > 0 ? `${n.length} version(s) could not be resolved and may hold the answer: ${n.join(" | ")}. ` : "") + `Sample rejections: ${r.join(" | ")}`
|
|
148
241
|
), this.candidatesTried = t, this.sampleRejections = r, this.unresolvedLabels = n, this.name = "PeginParamsNotFoundError";
|
|
149
242
|
}
|
|
150
243
|
}
|
|
151
|
-
class
|
|
244
|
+
class Ie extends Error {
|
|
152
245
|
constructor(t) {
|
|
153
246
|
super(
|
|
154
247
|
`${t.length} candidate parameter sets reproduce this Pre-PegIn's HTLC outputs, so the vault's stamped versions cannot be determined: ${t.join(" | ")}. Reconstruction refused.`
|
|
155
248
|
), this.survivorLabels = t, this.name = "PeginParamsAmbiguousError";
|
|
156
249
|
}
|
|
157
250
|
}
|
|
158
|
-
class
|
|
251
|
+
class Be extends Error {
|
|
159
252
|
constructor(t, r) {
|
|
160
253
|
super(
|
|
161
254
|
`A candidate matched this Pre-PegIn (${t}), but ${r.length} version(s) could not be resolved, so the search space did not provably contain the true parameters: ${r.join(" | ")}. A version sharing the matched timelockRefund and participants is indistinguishable from the true one, so the match cannot be trusted. Reconstruction refused.`
|
|
162
255
|
), this.matchedLabel = t, this.unresolvedLabels = r, this.name = "PeginParamsIncompleteSpaceError";
|
|
163
256
|
}
|
|
164
257
|
}
|
|
165
|
-
class
|
|
258
|
+
class T extends Error {
|
|
166
259
|
constructor(t) {
|
|
167
260
|
super(`${t}. Reconstruction refused.`), this.name = "PeginSizingIntegrityError";
|
|
168
261
|
}
|
|
169
262
|
}
|
|
170
|
-
async function
|
|
171
|
-
const { wallet: t, depositorBtcPubkey: r, fundedPrePeginTxHex: n } = e, h = P(n), c =
|
|
263
|
+
async function Ze(e) {
|
|
264
|
+
const { wallet: t, depositorBtcPubkey: r, fundedPrePeginTxHex: n } = e, h = P(n), c = M(h);
|
|
172
265
|
if (c === void 0)
|
|
173
|
-
throw new
|
|
266
|
+
throw new K(
|
|
174
267
|
"Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN, so the number of HTLC outputs it funds cannot be determined. Legacy pre-anchor deposits are not recoverable by this path."
|
|
175
268
|
);
|
|
176
269
|
const u = c.vout;
|
|
177
270
|
if (u === 0)
|
|
178
|
-
throw new
|
|
271
|
+
throw new K(
|
|
179
272
|
"Pre-PegIn's auth-anchor OP_RETURN is at vout 0, implying zero HTLC outputs; there is nothing to recover."
|
|
180
273
|
);
|
|
181
|
-
const l =
|
|
274
|
+
const l = Pe(h), i = await fe(t, {
|
|
182
275
|
// The vault context takes the 32-byte x-only key; a wallet's compressed
|
|
183
276
|
// key would otherwise fail a byte-length check deep in the encoder with
|
|
184
277
|
// nothing pointing back at the caller.
|
|
185
|
-
depositorBtcPubkey:
|
|
186
|
-
|
|
278
|
+
depositorBtcPubkey: he(
|
|
279
|
+
W(r)
|
|
187
280
|
),
|
|
188
281
|
fundingOutpoints: l
|
|
189
282
|
});
|
|
190
283
|
try {
|
|
191
|
-
const s = await
|
|
284
|
+
const s = await ge(i);
|
|
192
285
|
let a;
|
|
193
286
|
try {
|
|
194
|
-
a =
|
|
287
|
+
a = de(ce(s));
|
|
195
288
|
} finally {
|
|
196
289
|
s.fill(0);
|
|
197
290
|
}
|
|
198
291
|
if (a !== c.hash)
|
|
199
|
-
throw new
|
|
292
|
+
throw new Te(a, c.hash);
|
|
200
293
|
} catch (s) {
|
|
201
294
|
throw i.fill(0), s;
|
|
202
295
|
}
|
|
203
|
-
const { hashlocks: d } = await
|
|
296
|
+
const { hashlocks: d } = await le(i, u);
|
|
204
297
|
return { vaultCount: u, hashlocks: d, authAnchorHash: c.hash };
|
|
205
298
|
}
|
|
206
|
-
function
|
|
299
|
+
function et(e) {
|
|
207
300
|
const { vaultCoreVersion: t, offchainParams: r, participantKeySets: n } = e;
|
|
208
301
|
if (!Number.isInteger(t) || t < 1)
|
|
209
302
|
throw new Error(
|
|
@@ -227,21 +320,21 @@ function He(e) {
|
|
|
227
320
|
});
|
|
228
321
|
return h;
|
|
229
322
|
}
|
|
230
|
-
function
|
|
323
|
+
function Fe(e) {
|
|
231
324
|
return `${e.axis} v${e.version} (${e.reason})`;
|
|
232
325
|
}
|
|
233
|
-
function
|
|
326
|
+
function F(e) {
|
|
234
327
|
const { participants: t } = e;
|
|
235
328
|
return `core=${e.vaultCoreVersion} offchain=${e.offchainParams.version} keepers=${t.appVaultKeepersVersion} challengers=${t.universalChallengersVersion} vp=${t.vaultProvider}`;
|
|
236
329
|
}
|
|
237
|
-
const
|
|
238
|
-
function
|
|
330
|
+
const j = 5;
|
|
331
|
+
function Ke(e, t) {
|
|
239
332
|
return JSON.stringify(
|
|
240
333
|
{ terms: e, peginAmounts: t },
|
|
241
334
|
(r, n) => typeof n == "bigint" ? `${n}` : n
|
|
242
335
|
);
|
|
243
336
|
}
|
|
244
|
-
function
|
|
337
|
+
function Me(e) {
|
|
245
338
|
const { offchainParams: t, participants: r } = e;
|
|
246
339
|
return [
|
|
247
340
|
e.vaultCoreVersion,
|
|
@@ -253,9 +346,9 @@ function Pe(e) {
|
|
|
253
346
|
t.minPeginFeeRate
|
|
254
347
|
].join("|");
|
|
255
348
|
}
|
|
256
|
-
async function
|
|
349
|
+
async function Se(e) {
|
|
257
350
|
const { offchainParams: t, participants: r } = e, n = r.vaultKeeperBtcPubkeys.length, h = r.universalChallengerBtcPubkeys.length, [c, u, l] = await Promise.all([
|
|
258
|
-
|
|
351
|
+
Q(
|
|
259
352
|
e.vaultCoreVersion,
|
|
260
353
|
n,
|
|
261
354
|
h,
|
|
@@ -263,29 +356,29 @@ async function fe(e) {
|
|
|
263
356
|
t.councilSize,
|
|
264
357
|
t.protocolFeeRate
|
|
265
358
|
),
|
|
266
|
-
|
|
359
|
+
X(
|
|
267
360
|
e.vaultCoreVersion,
|
|
268
361
|
n,
|
|
269
362
|
h,
|
|
270
363
|
t.minPeginFeeRate
|
|
271
364
|
),
|
|
272
|
-
|
|
365
|
+
q(e.vaultCoreVersion)
|
|
273
366
|
]), i = (l == null ? void 0 : l.value) ?? 0n;
|
|
274
367
|
if (c <= 0n)
|
|
275
|
-
throw new
|
|
368
|
+
throw new T(
|
|
276
369
|
`WASM returned non-positive depositorClaimValue ${c} for graph version ${e.vaultCoreVersion}`
|
|
277
370
|
);
|
|
278
371
|
if (u <= 0n)
|
|
279
|
-
throw new
|
|
372
|
+
throw new T(
|
|
280
373
|
`WASM returned non-positive peginMaxFee ${u} for graph version ${e.vaultCoreVersion}`
|
|
281
374
|
);
|
|
282
375
|
if (i < 0n)
|
|
283
|
-
throw new
|
|
376
|
+
throw new T(
|
|
284
377
|
`WASM returned negative P2A anchor value ${i} for graph version ${e.vaultCoreVersion}`
|
|
285
378
|
);
|
|
286
379
|
return { depositorClaimValue: c, peginMaxFee: u, p2aAnchorValue: i };
|
|
287
380
|
}
|
|
288
|
-
async function
|
|
381
|
+
async function tt(e) {
|
|
289
382
|
const {
|
|
290
383
|
hashlocks: t,
|
|
291
384
|
fundedPrePeginTxHex: r,
|
|
@@ -302,78 +395,78 @@ async function Se(e) {
|
|
|
302
395
|
);
|
|
303
396
|
if (l.length === 0)
|
|
304
397
|
throw new Error("reconstructPeginParams: candidate space is empty");
|
|
305
|
-
const d =
|
|
398
|
+
const d = W(n), s = P(r), a = M(s);
|
|
306
399
|
if (a === void 0)
|
|
307
|
-
throw new
|
|
400
|
+
throw new K(
|
|
308
401
|
"Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN; the sibling set cannot be proven complete. Reconstruction refused."
|
|
309
402
|
);
|
|
310
403
|
if (a.vout !== t.length)
|
|
311
404
|
throw new Error(
|
|
312
405
|
`reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${a.vout}, so the transaction funds ${a.vout} HTLC output(s). Reconstruction refused.`
|
|
313
406
|
);
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
).toLowerCase(),
|
|
317
|
-
let
|
|
407
|
+
const v = J.fromHex(s).outs, w = t.map((m, p) => BigInt(v[p].value)), C = P(
|
|
408
|
+
Y(s)
|
|
409
|
+
).toLowerCase(), E = /* @__PURE__ */ new Map(), o = [], b = [], A = [];
|
|
410
|
+
let S = 0;
|
|
318
411
|
for (const m of l)
|
|
319
412
|
try {
|
|
320
|
-
const p =
|
|
321
|
-
let g =
|
|
322
|
-
g === void 0 && (g = await
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
throw new
|
|
326
|
-
`HTLC output[${
|
|
413
|
+
const p = Me(m);
|
|
414
|
+
let g = E.get(p);
|
|
415
|
+
g === void 0 && (g = await Se(m), E.set(p, g));
|
|
416
|
+
const R = g.depositorClaimValue + g.peginMaxFee + g.p2aAnchorValue, k = w.map((x) => x - R), V = k.findIndex((x) => x <= 0n);
|
|
417
|
+
if (V !== -1)
|
|
418
|
+
throw new z(
|
|
419
|
+
`HTLC output[${V}] value ${w[V]} is not above this candidate's reserve ${R}, so it implies a non-positive pegin amount ${k[V]}.`
|
|
327
420
|
);
|
|
328
|
-
const { offchainParams:
|
|
421
|
+
const { offchainParams: y, participants: I } = m, N = await ye({
|
|
329
422
|
vaultCoreVersion: m.vaultCoreVersion,
|
|
330
|
-
siblings: t.map((x,
|
|
423
|
+
siblings: t.map((x, te) => ({
|
|
331
424
|
hashlock: x,
|
|
332
|
-
amount:
|
|
425
|
+
amount: k[te]
|
|
333
426
|
})),
|
|
334
427
|
fundedPrePeginTxHex: s,
|
|
335
428
|
depositorBtcPubkey: d,
|
|
336
|
-
vaultProviderBtcPubkey:
|
|
337
|
-
vaultKeeperBtcPubkeys:
|
|
338
|
-
universalChallengerBtcPubkeys:
|
|
339
|
-
protocolFeeRate:
|
|
340
|
-
minPeginFeeRate:
|
|
341
|
-
councilQuorum:
|
|
342
|
-
councilSize:
|
|
343
|
-
timelockPegin:
|
|
344
|
-
timelockAssert:
|
|
345
|
-
timelockRefund:
|
|
346
|
-
prepeginTxid:
|
|
429
|
+
vaultProviderBtcPubkey: I.vaultProviderBtcPubkey,
|
|
430
|
+
vaultKeeperBtcPubkeys: I.vaultKeeperBtcPubkeys,
|
|
431
|
+
universalChallengerBtcPubkeys: I.universalChallengerBtcPubkeys,
|
|
432
|
+
protocolFeeRate: y.protocolFeeRate,
|
|
433
|
+
minPeginFeeRate: y.minPeginFeeRate,
|
|
434
|
+
councilQuorum: y.councilQuorum,
|
|
435
|
+
councilSize: y.councilSize,
|
|
436
|
+
timelockPegin: y.timelockPegin,
|
|
437
|
+
timelockAssert: y.timelockAssert,
|
|
438
|
+
timelockRefund: y.timelockRefund,
|
|
439
|
+
prepeginTxid: C,
|
|
347
440
|
prepeginMaxFee: h,
|
|
348
441
|
maxAcceptableCommissionBps: c,
|
|
349
442
|
network: u
|
|
350
443
|
});
|
|
351
444
|
o.push({
|
|
352
445
|
candidate: m,
|
|
353
|
-
terms:
|
|
354
|
-
peginAmounts:
|
|
355
|
-
fingerprint:
|
|
446
|
+
terms: N,
|
|
447
|
+
peginAmounts: k,
|
|
448
|
+
fingerprint: Ke(N, k)
|
|
356
449
|
});
|
|
357
450
|
} catch (p) {
|
|
358
|
-
if (p instanceof
|
|
451
|
+
if (p instanceof T)
|
|
359
452
|
throw p;
|
|
360
|
-
const g =
|
|
361
|
-
p instanceof
|
|
453
|
+
const g = F(m), R = p instanceof Error ? p.message : String(p);
|
|
454
|
+
p instanceof z ? b.length < j && b.push(`[${g}] ${R}`) : (S++, A.length < j && A.push(`${g} (${R})`));
|
|
362
455
|
}
|
|
363
|
-
const
|
|
364
|
-
...i.map(
|
|
365
|
-
...
|
|
456
|
+
const ee = i.length + S, H = [
|
|
457
|
+
...i.map(Fe),
|
|
458
|
+
...A
|
|
366
459
|
];
|
|
367
460
|
if (o.length === 0)
|
|
368
|
-
throw new
|
|
461
|
+
throw new Ae(l.length, b, H);
|
|
369
462
|
if (new Set(o.map((m) => m.fingerprint)).size > 1)
|
|
370
|
-
throw new
|
|
371
|
-
o.map((m) =>
|
|
463
|
+
throw new Ie(
|
|
464
|
+
o.map((m) => F(m.candidate))
|
|
372
465
|
);
|
|
373
|
-
if (
|
|
374
|
-
throw new
|
|
375
|
-
|
|
376
|
-
|
|
466
|
+
if (ee > 0)
|
|
467
|
+
throw new Be(
|
|
468
|
+
F(o[0].candidate),
|
|
469
|
+
H
|
|
377
470
|
);
|
|
378
471
|
return {
|
|
379
472
|
candidate: o[0].candidate,
|
|
@@ -384,7 +477,7 @@ async function Se(e) {
|
|
|
384
477
|
matchedCandidates: o.map((m) => m.candidate)
|
|
385
478
|
};
|
|
386
479
|
}
|
|
387
|
-
function
|
|
480
|
+
function rt(e, t) {
|
|
388
481
|
const {
|
|
389
482
|
htlcVout: r,
|
|
390
483
|
depositorBtcPubkey: n,
|
|
@@ -401,13 +494,13 @@ function Me(e, t) {
|
|
|
401
494
|
throw new Error(
|
|
402
495
|
`toRefundInputs: htlcVout ${r} is outside the reconstructed batch of ${d.length} vault(s).`
|
|
403
496
|
);
|
|
404
|
-
const
|
|
405
|
-
hashlock:
|
|
406
|
-
amount:
|
|
497
|
+
const v = d.map((E, o) => ({
|
|
498
|
+
hashlock: me(u[o]),
|
|
499
|
+
amount: E,
|
|
407
500
|
htlcVout: o
|
|
408
501
|
})), w = {
|
|
409
502
|
vaultCoreVersion: i.vaultCoreVersion,
|
|
410
|
-
hashlock:
|
|
503
|
+
hashlock: v[r].hashlock,
|
|
411
504
|
htlcVout: r,
|
|
412
505
|
offchainParamsVersion: s.version,
|
|
413
506
|
appVaultKeepersVersion: a.appVaultKeepersVersion,
|
|
@@ -417,8 +510,8 @@ function Me(e, t) {
|
|
|
417
510
|
amount: d[r],
|
|
418
511
|
unsignedPrePeginTxHex: c,
|
|
419
512
|
depositorBtcPubkey: n,
|
|
420
|
-
batch:
|
|
421
|
-
},
|
|
513
|
+
batch: v
|
|
514
|
+
}, C = {
|
|
422
515
|
vaultProviderPubkey: a.vaultProviderBtcPubkey,
|
|
423
516
|
vaultKeeperPubkeys: a.vaultKeeperBtcPubkeys,
|
|
424
517
|
universalChallengerPubkeys: a.universalChallengerBtcPubkeys,
|
|
@@ -432,25 +525,30 @@ function Me(e, t) {
|
|
|
432
525
|
councilSize: s.councilSize,
|
|
433
526
|
network: l
|
|
434
527
|
};
|
|
435
|
-
return { vault: w, context:
|
|
528
|
+
return { vault: w, context: C };
|
|
436
529
|
}
|
|
437
530
|
export {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
531
|
+
Z as D,
|
|
532
|
+
Ee as P,
|
|
533
|
+
K as U,
|
|
534
|
+
Te as V,
|
|
535
|
+
we as a,
|
|
536
|
+
f as b,
|
|
537
|
+
Ye as c,
|
|
538
|
+
be as d,
|
|
539
|
+
$e as e,
|
|
540
|
+
qe as f,
|
|
541
|
+
Ze as g,
|
|
542
|
+
et as h,
|
|
543
|
+
Je as i,
|
|
544
|
+
Fe as j,
|
|
545
|
+
F as k,
|
|
546
|
+
tt as l,
|
|
547
|
+
Ae as m,
|
|
548
|
+
Ie as n,
|
|
549
|
+
Be as o,
|
|
550
|
+
T as p,
|
|
551
|
+
ye as r,
|
|
552
|
+
rt as t
|
|
455
553
|
};
|
|
456
|
-
//# sourceMappingURL=toRefundInputs-
|
|
554
|
+
//# sourceMappingURL=toRefundInputs-BNSXIymn.js.map
|