@babylonlabs-io/ts-sdk 3.3.1 → 4.1.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/{BTCVaultRegistry.abi-BzNTa_EU.js → BTCVaultRegistry.abi-DnP4UkB5.js} +9 -140
- package/dist/BTCVaultRegistry.abi-DnP4UkB5.js.map +1 -0
- package/dist/{BTCVaultRegistry.abi-BH2-LHxN.cjs → BTCVaultRegistry.abi-DzbfZ9_s.cjs} +2 -2
- package/dist/BTCVaultRegistry.abi-DzbfZ9_s.cjs.map +1 -0
- package/dist/{PayoutManager-xEGvTbhL.js → PayoutManager-BUWP-H-q.js} +3 -3
- package/dist/PayoutManager-BUWP-H-q.js.map +1 -0
- package/dist/{PayoutManager-B1Ev0r7o.cjs → PayoutManager-Dopxq_Jv.cjs} +2 -2
- package/dist/PayoutManager-Dopxq_Jv.cjs.map +1 -0
- package/dist/{PeginManager-D2R4Q1bN.cjs → PeginManager-CMbRRTnr.cjs} +2 -2
- package/dist/PeginManager-CMbRRTnr.cjs.map +1 -0
- package/dist/{PeginManager-CQ9bVPR3.js → PeginManager-Cas6_j7t.js} +7 -7
- package/dist/PeginManager-Cas6_j7t.js.map +1 -0
- package/dist/{ProtocolParams.abi-Cv77fsUe.js → ProtocolParams.abi-CuDl7AuC.js} +3 -3
- package/dist/{ProtocolParams.abi-Cv77fsUe.js.map → ProtocolParams.abi-CuDl7AuC.js.map} +1 -1
- package/dist/{ProtocolParams.abi-BgEZaQ2I.cjs → ProtocolParams.abi-DWfIh6VH.cjs} +2 -2
- package/dist/{ProtocolParams.abi-BgEZaQ2I.cjs.map → ProtocolParams.abi-DWfIh6VH.cjs.map} +1 -1
- package/dist/VaultErrors.abi-Dc3UnB_h.js +5 -0
- package/dist/{VaultErrors.abi-Boz4w97c.js.map → VaultErrors.abi-Dc3UnB_h.js.map} +1 -1
- package/dist/VaultErrors.abi-Hjn1CdLs.cjs +2 -0
- package/dist/{VaultErrors.abi-DQ18kM0L.cjs.map → VaultErrors.abi-Hjn1CdLs.cjs.map} +1 -1
- package/dist/{buildAndBroadcastReclaim-CQANDXVJ.js → buildAndBroadcastReclaim-ByXYSUwj.js} +372 -337
- package/dist/buildAndBroadcastReclaim-ByXYSUwj.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-OBWjvzuC.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-OBWjvzuC.cjs.map +1 -0
- package/dist/challengeAssert-eUMgmpMk.cjs +2 -0
- package/dist/challengeAssert-eUMgmpMk.cjs.map +1 -0
- package/dist/{challengeAssert-B2otuf7y.js → challengeAssert-pJP7MKhG.js} +164 -164
- package/dist/challengeAssert-pJP7MKhG.js.map +1 -0
- package/dist/constants-BCg6O0PX.cjs +2 -0
- package/dist/constants-BCg6O0PX.cjs.map +1 -0
- package/dist/constants-CmDDuM3L.js +50 -0
- package/dist/constants-CmDDuM3L.js.map +1 -0
- package/dist/{index-BRsWXDlv.js → index-B-9aXMxk.js} +6 -6
- package/dist/{index-BRsWXDlv.js.map → index-B-9aXMxk.js.map} +1 -1
- package/dist/{index-C6avwx1s.cjs → index-Dn7RlsKK.cjs} +2 -2
- package/dist/{index-C6avwx1s.cjs.map → index-Dn7RlsKK.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +68 -67
- package/dist/pegin-registration-client-DLlaZbsZ.cjs +2 -0
- package/dist/pegin-registration-client-DLlaZbsZ.cjs.map +1 -0
- package/dist/{pegin-registration-client-Cvjk4ILq.js → pegin-registration-client-ZI0k10_3.js} +90 -96
- package/dist/pegin-registration-client-ZI0k10_3.js.map +1 -0
- package/dist/{primeVpAuth-D4UWXQ76.js → primeVpAuth-C-ET0XF4.js} +2 -2
- package/dist/{primeVpAuth-D4UWXQ76.js.map → primeVpAuth-C-ET0XF4.js.map} +1 -1
- package/dist/{primeVpAuth-CXNXYKrh.cjs → primeVpAuth-Ch-ig2My.cjs} +2 -2
- package/dist/{primeVpAuth-CXNXYKrh.cjs.map → primeVpAuth-Ch-ig2My.cjs.map} +1 -1
- package/dist/registration-records-CKc0OVuK.cjs +2 -0
- package/dist/registration-records-CKc0OVuK.cjs.map +1 -0
- package/dist/{registration-records-DJJC2NiO.js → registration-records-D39ApuHS.js} +141 -141
- package/dist/registration-records-D39ApuHS.js.map +1 -0
- package/dist/{signer-set-reader-GrFe_rsW.cjs → signer-set-reader-CJfV-GDz.cjs} +2 -2
- package/dist/signer-set-reader-CJfV-GDz.cjs.map +1 -0
- package/dist/{signer-set-reader-CSUe92zE.js → signer-set-reader-DiwLeqik.js} +3 -3
- package/dist/signer-set-reader-DiwLeqik.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +4 -4
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +5 -1
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/registration-logs-error.d.ts +6 -6
- package/dist/tbv/core/clients/eth/registration-records.d.ts +1 -1
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +32 -13
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.d.ts +4 -2
- package/dist/tbv/core/clients/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.js +6 -6
- 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/contracts/abis/BTCVaultRegistry.abi.d.ts +5 -111
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +2 -2
- package/dist/tbv/core/contracts/abis/vaultErrors.abi.json.d.ts +1 -1
- package/dist/tbv/core/contracts/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.js +3 -3
- package/dist/tbv/core/deposit-terms/__tests__/rebuildDepositTermsCore.test.d.ts +1 -1
- package/dist/tbv/core/deposit-terms/commissionCeiling.d.ts +1 -1
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts +11 -9
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -1
- package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +69 -68
- package/dist/tbv/core/managers/PayoutManager.d.ts +9 -3
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +13 -3
- 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 +2 -2
- package/dist/tbv/core/primitives/__tests__/vaultCoreVersion.test.d.ts +1 -1
- package/dist/tbv/core/primitives/challengers.d.ts +12 -5
- package/dist/tbv/core/primitives/challengers.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +1 -1
- package/dist/tbv/core/primitives/index.js +3 -3
- package/dist/tbv/core/primitives/psbt/__tests__/deriveExpectedPeginPayoutScriptPubKey.test.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/constants.d.ts +38 -13
- package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts +3 -6
- package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +29 -9
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
- package/dist/tbv/core/recovery/peginParamsCandidates.d.ts +1 -1
- package/dist/tbv/core/recovery/reconstructPeginParams.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/__tests__/realWasmWatchtowerArtifacts.test.d.ts +2 -2
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +2 -1
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts +3 -3
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts +1 -1
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts +2 -1
- package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/readDelegatedClaimVaultContext.d.ts +1 -1
- package/dist/tbv/core/services/delegated-claim/readDelegatedClaimVaultContext.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +3 -3
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/types.d.ts +8 -9
- package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/__tests__/signDepositorGraph.realGraph.test.d.ts +3 -3
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +19 -4
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +17 -3
- 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 +44 -43
- package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts +19 -7
- package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/services/refund/__tests__/readRefundPrePeginContext.test.d.ts +12 -0
- package/dist/tbv/core/services/refund/__tests__/readRefundPrePeginContext.test.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts +41 -12
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
- package/dist/tbv/core/services/refund/index.d.ts +1 -0
- package/dist/tbv/core/services/refund/index.d.ts.map +1 -1
- package/dist/tbv/core/services/refund/readRefundPrePeginContext.d.ts +41 -0
- package/dist/tbv/core/services/refund/readRefundPrePeginContext.d.ts.map +1 -0
- package/dist/tbv/core/wasm/index.cjs.map +1 -1
- package/dist/tbv/core/wasm/index.d.ts +8 -11
- package/dist/tbv/core/wasm/index.d.ts.map +1 -1
- package/dist/tbv/core/wasm/index.js.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +69 -68
- package/dist/toRefundInputs-BSQjDOK9.cjs +2 -0
- package/dist/toRefundInputs-BSQjDOK9.cjs.map +1 -0
- package/dist/{toRefundInputs-DH-1bRNY.js → toRefundInputs-BbbvPb2A.js} +175 -173
- package/dist/toRefundInputs-BbbvPb2A.js.map +1 -0
- package/dist/{types-BC2TGzcp.cjs → types-BnZIbDHb.cjs} +2 -2
- package/dist/types-BnZIbDHb.cjs.map +1 -0
- package/dist/{types-24A9Qoxb.js → types-K_aM5GZO.js} +39 -39
- package/dist/types-K_aM5GZO.js.map +1 -0
- package/dist/{verifyKeyPathSchnorrSignature-IIj3Z2se.js → verifyKeyPathSchnorrSignature-DPXOFOol.js} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-IIj3Z2se.js.map → verifyKeyPathSchnorrSignature-DPXOFOol.js.map} +1 -1
- package/dist/{verifyKeyPathSchnorrSignature-BRTpEH9X.cjs → verifyKeyPathSchnorrSignature-DcxCojp0.cjs} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-BRTpEH9X.cjs.map → verifyKeyPathSchnorrSignature-DcxCojp0.cjs.map} +1 -1
- package/dist/verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs.map +1 -0
- package/dist/{verifyScriptPathSchnorrSignature-owu3BfyT.js → verifyScriptPathSchnorrSignature-D-fdi-sG.js} +462 -459
- package/dist/verifyScriptPathSchnorrSignature-D-fdi-sG.js.map +1 -0
- package/package.json +3 -3
- package/dist/BTCVaultRegistry.abi-BH2-LHxN.cjs.map +0 -1
- package/dist/BTCVaultRegistry.abi-BzNTa_EU.js.map +0 -1
- package/dist/PayoutManager-B1Ev0r7o.cjs.map +0 -1
- package/dist/PayoutManager-xEGvTbhL.js.map +0 -1
- package/dist/PeginManager-CQ9bVPR3.js.map +0 -1
- package/dist/PeginManager-D2R4Q1bN.cjs.map +0 -1
- package/dist/VaultErrors.abi-Boz4w97c.js +0 -5
- package/dist/VaultErrors.abi-DQ18kM0L.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-CQANDXVJ.js.map +0 -1
- package/dist/buildAndBroadcastReclaim-DPk36Uhp.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-DPk36Uhp.cjs.map +0 -1
- package/dist/challengeAssert-B2otuf7y.js.map +0 -1
- package/dist/challengeAssert-C3eMcM5Y.cjs +0 -2
- package/dist/challengeAssert-C3eMcM5Y.cjs.map +0 -1
- package/dist/constants-CAm10Qwp.cjs +0 -2
- package/dist/constants-CAm10Qwp.cjs.map +0 -1
- package/dist/constants-CvQZuxKv.js +0 -48
- package/dist/constants-CvQZuxKv.js.map +0 -1
- package/dist/pegin-registration-client-CdRyXP3j.cjs +0 -2
- package/dist/pegin-registration-client-CdRyXP3j.cjs.map +0 -1
- package/dist/pegin-registration-client-Cvjk4ILq.js.map +0 -1
- package/dist/registration-records-DJJC2NiO.js.map +0 -1
- package/dist/registration-records-XQMIKjGV.cjs +0 -2
- package/dist/registration-records-XQMIKjGV.cjs.map +0 -1
- package/dist/signer-set-reader-CSUe92zE.js.map +0 -1
- package/dist/signer-set-reader-GrFe_rsW.cjs.map +0 -1
- package/dist/toRefundInputs-DH-1bRNY.js.map +0 -1
- package/dist/toRefundInputs-DRmK83fv.cjs +0 -2
- package/dist/toRefundInputs-DRmK83fv.cjs.map +0 -1
- package/dist/types-24A9Qoxb.js.map +0 -1
- package/dist/types-BC2TGzcp.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-CahYx5Td.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-CahYx5Td.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-owu3BfyT.js.map +0 -1
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var W = (e, t, r) =>
|
|
4
|
-
import { B as Be } from "./BTCVaultRegistry.abi-
|
|
5
|
-
import { e as Ie, s as
|
|
6
|
-
import { v as
|
|
7
|
-
import { verifyWatchtowerArtifacts as
|
|
8
|
-
import { m as
|
|
1
|
+
var er = Object.defineProperty;
|
|
2
|
+
var tr = (e, t, r) => t in e ? er(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var W = (e, t, r) => tr(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { B as Be } from "./BTCVaultRegistry.abi-DnP4UkB5.js";
|
|
5
|
+
import { e as Ie, s as P, i as rr, u as yt, c as _, v as or, g as sr, p as pe, f as N } from "./bitcoin-C-TuHb-v.js";
|
|
6
|
+
import { v as nr, s as vt, b as Pt, P as ir, d as ar } from "./PayoutManager-BUWP-H-q.js";
|
|
7
|
+
import { verifyWatchtowerArtifacts as ur, buildClaimPsbt as cr, buildAssertClaimerPsbt as lr, buildPayoutClaimerPsbt as dr, buildWronglyChallengedPsbts as hr, buildPayoutDepositorPsbt as pr, finalizeClaimTx as gr, buildWatchtowerArtifacts as fr, extractTapScriptSig as bt, expandWotsSeed as yr, wotsKeypairFromSeed as vr, validateWotsKeypairAgainstGraph as Pr, getChallengeAssertOutputScriptPubKey as br, deriveVaultId as mr } from "./tbv/core/wasm/index.js";
|
|
8
|
+
import { m as wr, d as mt, k as xr, a as _e, V as Le, i as Er, g as kr, f as $r, r as Cr, h as Tr } from "./registration-records-D39ApuHS.js";
|
|
9
9
|
import { Psbt as q, Transaction as S } from "bitcoinjs-lib";
|
|
10
|
-
import {
|
|
11
|
-
import { p as
|
|
10
|
+
import { F, G as A, H as re, I as J, A as G, z as Z, J as ge, v as Me, E as ee, K as Ve, w as Fe, x as Ue, y as qe, W as _r, D as Ge, C as Xe, L as Sr, O as Ar, Q as Br } from "./constants-CmDDuM3L.js";
|
|
11
|
+
import { p as Ir, q as Vr, r as wt, P as X, j as oe, f as Rr, i as ae, g as ue } from "./verifyScriptPathSchnorrSignature-D-fdi-sG.js";
|
|
12
12
|
import { Buffer as H } from "buffer";
|
|
13
13
|
import { C as xt, X as Et } from "./validation-OSC0xTHB.js";
|
|
14
14
|
import { a as kt, c as ce } from "./signing-C1rR4tqs.js";
|
|
15
15
|
import { d as $t } from "./deriveVaultRoot-BcvmER1E.js";
|
|
16
|
-
import { O as ze, d as
|
|
17
|
-
import { zeroAddress as
|
|
18
|
-
import { v as je, D as R, c as
|
|
19
|
-
import { h as We, b as
|
|
20
|
-
import { c as
|
|
16
|
+
import { O as ze, d as Kr } from "./types-K_aM5GZO.js";
|
|
17
|
+
import { zeroAddress as Hr, isAddress as Or, isAddressEqual as Nr } from "viem";
|
|
18
|
+
import { v as je, D as R, c as Dr, b as Lr, R as Mr, d as Ct } from "./state-CFn1rT74.js";
|
|
19
|
+
import { h as We, b as Fr, s as Ur, j as qr } from "./sha2-YqVHJiFj.js";
|
|
20
|
+
import { c as Gr, g as Xr, h as zr, i as jr, b as Wr, f as Tt, e as Yr, a as Qr } from "./challengeAssert-pJP7MKhG.js";
|
|
21
21
|
import { a as Jr } from "./secp256k1-BuxBFUHm.js";
|
|
22
|
-
import { c as
|
|
23
|
-
const
|
|
22
|
+
import { c as Zr } from "./btcTxHash-BRZ8_EZq.js";
|
|
23
|
+
const eo = /^0x[0-9a-fA-F]{64}$/, to = /^0x[0-9a-fA-F]{40}$/, ro = /^0x([0-9a-fA-F]{2})*$/;
|
|
24
24
|
function ye(e, t) {
|
|
25
25
|
if (e.length !== 66)
|
|
26
26
|
throw new Error(
|
|
27
27
|
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
28
28
|
);
|
|
29
|
-
if (!
|
|
29
|
+
if (!eo.test(e))
|
|
30
30
|
throw new Error(
|
|
31
31
|
`${t} must contain only hex characters after the 0x prefix`
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
if (!
|
|
34
|
+
function oo(e, t) {
|
|
35
|
+
if (!to.test(e))
|
|
36
36
|
throw new Error(
|
|
37
37
|
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
if (!
|
|
40
|
+
function so(e, t) {
|
|
41
|
+
if (!ro.test(e))
|
|
42
42
|
throw new Error(
|
|
43
43
|
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
function Re(e) {
|
|
47
|
-
|
|
47
|
+
oo(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), ye(e.vaultId, "vaultId");
|
|
48
48
|
const t = Ie(e.secret);
|
|
49
|
-
if (ye(t, "secret"), e.hashlock !== void 0 && (ye(e.hashlock, "hashlock"), !
|
|
49
|
+
if (ye(t, "secret"), e.hashlock !== void 0 && (ye(e.hashlock, "hashlock"), !nr(t, e.hashlock)))
|
|
50
50
|
throw new Error(
|
|
51
51
|
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
52
52
|
);
|
|
@@ -68,7 +68,7 @@ async function nn(e) {
|
|
|
68
68
|
secret: e.secret,
|
|
69
69
|
hashlock: o
|
|
70
70
|
});
|
|
71
|
-
return
|
|
71
|
+
return so(s, "activationMetadata"), n({
|
|
72
72
|
address: t,
|
|
73
73
|
abi: Be,
|
|
74
74
|
functionName: "activateVaultWithSecret",
|
|
@@ -120,7 +120,7 @@ function ve(e, t) {
|
|
|
120
120
|
throw new K(`${e} PSBT cannot be parsed.`, { cause: r });
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function no(e, t, r) {
|
|
124
124
|
const o = t.txInputs[r];
|
|
125
125
|
if (!o)
|
|
126
126
|
throw new K(`${e} PSBT has no input ${r}.`);
|
|
@@ -131,7 +131,7 @@ function Ye(e) {
|
|
|
131
131
|
e.data.globalMap.unsignedTx.toBuffer()
|
|
132
132
|
).getHash();
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function Pe(e, t, r, o, s, n) {
|
|
135
135
|
const a = t.txInputs[r];
|
|
136
136
|
if (!a)
|
|
137
137
|
throw new K(`${e} PSBT has no input ${r}.`);
|
|
@@ -140,60 +140,60 @@ function be(e, t, r, o, s, n) {
|
|
|
140
140
|
`${e} input ${r} does not spend ${n}: the graph pairs this ${e} with a different transaction.`
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function io(e, t) {
|
|
144
144
|
var s;
|
|
145
145
|
const r = (s = e.data.inputs[F]) == null ? void 0 : s.witnessUtxo;
|
|
146
146
|
if (r === void 0)
|
|
147
147
|
throw new K(
|
|
148
148
|
`Assert input ${F} carries no witnessUtxo, so the amount and script its signature commits to cannot be checked; refusing to sign assert.`
|
|
149
149
|
);
|
|
150
|
-
const o = t.txOutputs[
|
|
150
|
+
const o = t.txOutputs[J];
|
|
151
151
|
if (!o)
|
|
152
152
|
throw new K(
|
|
153
|
-
`Claim PSBT has no output ${
|
|
153
|
+
`Claim PSBT has no output ${J} for the Assert to spend; refusing to sign assert.`
|
|
154
154
|
);
|
|
155
155
|
if (r.value !== o.value)
|
|
156
156
|
throw new K(
|
|
157
|
-
`Assert input ${F} declares a prevout of ${r.value} sats but the Claim's output ${
|
|
157
|
+
`Assert input ${F} declares a prevout of ${r.value} sats but the Claim's output ${J} is worth ${o.value}; refusing to sign assert.`
|
|
158
158
|
);
|
|
159
159
|
if (!r.script.equals(o.script))
|
|
160
160
|
throw new K(
|
|
161
|
-
`Assert input ${F} declares a prevout script that is not the Claim's output ${
|
|
161
|
+
`Assert input ${F} declares a prevout script that is not the Claim's output ${J} script; refusing to sign assert.`
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function ao(e) {
|
|
165
165
|
const t = ve("Claim", e.claimPsbtBase64), r = ve("Assert", e.assertPsbtBase64), o = ve("Payout", e.payoutClaimerPsbtBase64);
|
|
166
|
-
|
|
166
|
+
Pe(
|
|
167
167
|
"Assert",
|
|
168
168
|
r,
|
|
169
169
|
F,
|
|
170
170
|
Ye(t),
|
|
171
|
-
|
|
171
|
+
J,
|
|
172
172
|
"Claim:0"
|
|
173
|
-
),
|
|
173
|
+
), io(r, t), Pe(
|
|
174
174
|
"Payout",
|
|
175
175
|
o,
|
|
176
176
|
A,
|
|
177
177
|
Ye(r),
|
|
178
178
|
G,
|
|
179
179
|
"Assert:0"
|
|
180
|
-
),
|
|
180
|
+
), Pe(
|
|
181
181
|
"Payout",
|
|
182
182
|
o,
|
|
183
183
|
re,
|
|
184
|
-
|
|
184
|
+
no("Claim", t, ge),
|
|
185
185
|
Z,
|
|
186
186
|
"this vault's PegIn:0"
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function be(e, t) {
|
|
190
190
|
try {
|
|
191
191
|
return q.fromBase64(t);
|
|
192
192
|
} catch (r) {
|
|
193
193
|
throw new Error(`${e} PSBT cannot be parsed.`, { cause: r });
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Qe(e, t, r, o) {
|
|
197
197
|
var a;
|
|
198
198
|
const s = [
|
|
199
199
|
{
|
|
@@ -224,7 +224,7 @@ function Je(e, t, r, o) {
|
|
|
224
224
|
`${e} Payout input ${A} declares a prevout script that is not the Assert's output ${G} script; refusing to sign payout.`
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
|
-
async function
|
|
227
|
+
async function uo(e) {
|
|
228
228
|
const { vault: t } = e, r = {
|
|
229
229
|
vaultCoreVersion: t.vaultCoreVersion,
|
|
230
230
|
numVaultKeepers: t.vaultKeeperBtcPubkeys.length,
|
|
@@ -232,11 +232,11 @@ async function ao(e) {
|
|
|
232
232
|
councilSize: t.councilSize,
|
|
233
233
|
protocolFeeRate: t.protocolFeeRate
|
|
234
234
|
};
|
|
235
|
-
|
|
236
|
-
const o =
|
|
235
|
+
Ir(r);
|
|
236
|
+
const o = be("Claimer Payout", e.payoutClaimerPsbtBase64), s = be(
|
|
237
237
|
"Depositor Payout",
|
|
238
238
|
e.payoutDepositorPsbtBase64
|
|
239
|
-
), n =
|
|
239
|
+
), n = be("Assert", e.assertPsbtBase64);
|
|
240
240
|
if (!s.data.globalMap.unsignedTx.toBuffer().equals(o.data.globalMap.unsignedTx.toBuffer()))
|
|
241
241
|
throw new Error(
|
|
242
242
|
"Depositor and claimer Payout PSBTs describe different transactions; refusing to sign payout."
|
|
@@ -260,12 +260,12 @@ async function ao(e) {
|
|
|
260
260
|
throw new Error(
|
|
261
261
|
`Payout input ${A} sequence ${u} must equal the Assert CSV timelock ${t.timelockAssert}; refusing to sign payout.`
|
|
262
262
|
);
|
|
263
|
-
|
|
263
|
+
Qe(
|
|
264
264
|
"Claimer",
|
|
265
265
|
o,
|
|
266
266
|
t.peginVaultOutputValueSats,
|
|
267
267
|
a
|
|
268
|
-
),
|
|
268
|
+
), Qe(
|
|
269
269
|
"Depositor",
|
|
270
270
|
s,
|
|
271
271
|
t.peginVaultOutputValueSats,
|
|
@@ -282,57 +282,57 @@ async function ao(e) {
|
|
|
282
282
|
throw new Error(
|
|
283
283
|
`Payout outputs (${h} sats) exceed inputs (${l} sats); invalid transaction.`
|
|
284
284
|
);
|
|
285
|
-
await
|
|
285
|
+
await Vr(r, {
|
|
286
286
|
implicitFeeSats: l - h,
|
|
287
287
|
out0Len: c[Ve].script.length,
|
|
288
288
|
out1Len: void 0
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
|
-
class
|
|
291
|
+
class co extends Error {
|
|
292
292
|
constructor(t, r) {
|
|
293
293
|
super(
|
|
294
294
|
"Transaction graph's challenger set does not match the vault's (local ∪ universal)" + (t.length > 0 ? ` (missing: ${t.join(", ")})` : "") + (r.length > 0 ? ` (unexpected: ${r.join(", ")})` : "") + ". Refusing to sign an incomplete or padded challenger set."
|
|
295
295
|
), this.missing = t, this.unexpected = r, this.name = "ChallengerSetMismatchError";
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function lo(e) {
|
|
299
299
|
const t = wt({
|
|
300
300
|
claimerBtcPubkey: e.depositorBtcPubkey,
|
|
301
301
|
depositorBtcPubkey: e.depositorBtcPubkey,
|
|
302
302
|
vaultProviderBtcPubkey: e.vaultProviderBtcPubkey,
|
|
303
303
|
vaultKeeperBtcPubkeys: e.vaultKeeperBtcPubkeys
|
|
304
|
-
}), r = e.universalChallengerBtcPubkeys.map(
|
|
304
|
+
}), r = e.universalChallengerBtcPubkeys.map(Je), o = t.filter((c) => r.includes(c));
|
|
305
305
|
if (o.length > 0)
|
|
306
306
|
throw new Error(
|
|
307
307
|
`Cannot check the challenger set: vault keepers and universal challengers overlap (${o.join(", ")}).`
|
|
308
308
|
);
|
|
309
|
-
const s = e.graphChallengerPubkeys.map(
|
|
309
|
+
const s = e.graphChallengerPubkeys.map(Je), n = new Set(s);
|
|
310
310
|
if (n.size !== s.length)
|
|
311
311
|
throw new Error(
|
|
312
312
|
"Transaction graph lists the same challenger more than once."
|
|
313
313
|
);
|
|
314
314
|
const a = [...t, ...r], i = new Set(a), u = a.filter((c) => !n.has(c)), l = s.filter((c) => !i.has(c));
|
|
315
315
|
if (u.length > 0 || l.length > 0)
|
|
316
|
-
throw new
|
|
316
|
+
throw new co(u, l);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
return
|
|
318
|
+
function Je(e) {
|
|
319
|
+
return P(e).toLowerCase();
|
|
320
320
|
}
|
|
321
|
-
class
|
|
321
|
+
class ho extends Error {
|
|
322
322
|
constructor(t, r) {
|
|
323
323
|
super(
|
|
324
324
|
`Payout transaction output ${Ve} pays ${r}, not the vault's registered payout script ${t}. Refusing to sign a payout to another destination.`
|
|
325
325
|
), this.expectedScriptHex = t, this.actualScriptHex = r, this.name = "PayoutDestinationError";
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function po(e) {
|
|
329
329
|
let t;
|
|
330
330
|
try {
|
|
331
331
|
t = q.fromBase64(e.payoutPsbtBase64);
|
|
332
332
|
} catch (c) {
|
|
333
333
|
throw new Error("Payout PSBT cannot be parsed.", { cause: c });
|
|
334
334
|
}
|
|
335
|
-
const { version: r, locktime: o, outs: s } =
|
|
335
|
+
const { version: r, locktime: o, outs: s } = go(t);
|
|
336
336
|
if (r !== Fe || o !== Ue)
|
|
337
337
|
throw new Error(
|
|
338
338
|
`Payout transaction has version ${r} and locktime ${o}, expected ${Fe} and ${Ue}.`
|
|
@@ -341,7 +341,7 @@ function ho(e) {
|
|
|
341
341
|
throw new Error(
|
|
342
342
|
`Payout transaction has ${s.length} output(s), expected exactly ${ee} for a depositor-as-claimer payout.`
|
|
343
343
|
);
|
|
344
|
-
const n =
|
|
344
|
+
const n = P(
|
|
345
345
|
e.registeredPayoutScriptPubKey
|
|
346
346
|
).toLowerCase();
|
|
347
347
|
if (n.length === 0)
|
|
@@ -350,21 +350,21 @@ function ho(e) {
|
|
|
350
350
|
);
|
|
351
351
|
const a = s[Ve].script.toString("hex").toLowerCase();
|
|
352
352
|
if (a !== n)
|
|
353
|
-
throw new
|
|
353
|
+
throw new ho(n, a);
|
|
354
354
|
const i = s[ee - 1];
|
|
355
355
|
if (i.value !== qe)
|
|
356
356
|
throw new Error(
|
|
357
357
|
`Payout CPFP anchor value ${i.value} sats must equal ${qe} sats.`
|
|
358
358
|
);
|
|
359
|
-
const u =
|
|
360
|
-
|
|
359
|
+
const u = P(
|
|
360
|
+
wr(P(e.depositorBtcPubkey).toLowerCase())
|
|
361
361
|
), l = i.script.toString("hex").toLowerCase();
|
|
362
362
|
if (l !== u)
|
|
363
363
|
throw new Error(
|
|
364
364
|
`Payout CPFP anchor pays ${l}, not the depositor's BIP-86 P2TR ${u}. Refusing to sign a payout whose fee-bump output is spendable by somebody else.`
|
|
365
365
|
);
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function go(e) {
|
|
368
368
|
return {
|
|
369
369
|
version: e.version,
|
|
370
370
|
locktime: e.locktime,
|
|
@@ -379,7 +379,7 @@ class ne extends Error {
|
|
|
379
379
|
super(t), this.name = "PayoutInputLeafError";
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function fo(e) {
|
|
383
383
|
const t = q.fromBase64(e.payoutDepositorPsbtBase64), r = q.fromBase64(e.payoutClaimerPsbtBase64), o = t.data.globalMap.unsignedTx.toBuffer(), s = r.data.globalMap.unsignedTx.toBuffer();
|
|
384
384
|
if (!o.equals(s))
|
|
385
385
|
throw new ne(
|
|
@@ -404,14 +404,14 @@ function go(e) {
|
|
|
404
404
|
...n.tapMerkleRoot ? { tapMerkleRoot: n.tapMerkleRoot } : {}
|
|
405
405
|
}), t.toBase64();
|
|
406
406
|
}
|
|
407
|
-
class
|
|
407
|
+
class yo extends Error {
|
|
408
408
|
constructor(t, r, o) {
|
|
409
409
|
super(
|
|
410
410
|
`Transaction graph does not belong to vault ${t}: its Claim spends PegIn ${o}, which derives vault ${r}. Refusing to sign for a graph served for another vault.`
|
|
411
411
|
), this.expectedVaultId = t, this.derivedVaultId = r, this.peginTxid = o, this.name = "VaultIdBindingError";
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function vo(e) {
|
|
415
415
|
let t;
|
|
416
416
|
try {
|
|
417
417
|
t = q.fromBase64(e);
|
|
@@ -427,7 +427,7 @@ function yo(e) {
|
|
|
427
427
|
r.index
|
|
428
428
|
), Ke(r.hash);
|
|
429
429
|
}
|
|
430
|
-
function
|
|
430
|
+
function Po(e) {
|
|
431
431
|
const t = e.ins[ge];
|
|
432
432
|
if (!t)
|
|
433
433
|
throw new Error(
|
|
@@ -447,10 +447,10 @@ function _t(e, t, r) {
|
|
|
447
447
|
}
|
|
448
448
|
function St(e) {
|
|
449
449
|
const t = z(
|
|
450
|
-
|
|
450
|
+
mt(e.peginTxid, e.depositorEthAddress)
|
|
451
451
|
), r = z(e.expectedVaultId);
|
|
452
452
|
if (t !== r)
|
|
453
|
-
throw new
|
|
453
|
+
throw new yo(r, t, e.peginTxid);
|
|
454
454
|
}
|
|
455
455
|
function z(e) {
|
|
456
456
|
return `0x${(e.startsWith("0x") ? e.slice(2) : e).toLowerCase()}`;
|
|
@@ -459,7 +459,7 @@ function Ke(e) {
|
|
|
459
459
|
return H.from(e).reverse().toString("hex");
|
|
460
460
|
}
|
|
461
461
|
function le(e, t) {
|
|
462
|
-
const r =
|
|
462
|
+
const r = P(e);
|
|
463
463
|
if (!/^(?:[0-9a-fA-F]{2})+$/.test(r))
|
|
464
464
|
throw new Error(`${t} must be non-empty, even-length hex.`);
|
|
465
465
|
return r.toLowerCase();
|
|
@@ -477,7 +477,7 @@ function At(e) {
|
|
|
477
477
|
`Vault provider served Groth16 verifying key ${t} but the trusted key for prover circuit version ${e.proverCircuitVersion} is ${r}; refusing to sign a claim whose proof would verify under a substituted key.`
|
|
478
478
|
);
|
|
479
479
|
}
|
|
480
|
-
const U =
|
|
480
|
+
const U = 1;
|
|
481
481
|
class bo extends Error {
|
|
482
482
|
constructor(t, r) {
|
|
483
483
|
super(
|
|
@@ -486,8 +486,8 @@ class bo extends Error {
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
const mo = /^(?:[0-9a-fA-F]{2})+$/;
|
|
489
|
-
function
|
|
490
|
-
const t =
|
|
489
|
+
function wo(e) {
|
|
490
|
+
const t = ko(e, "babe_sessions"), r = Object.keys(t);
|
|
491
491
|
if (r.length === 0)
|
|
492
492
|
return { joined: !1 };
|
|
493
493
|
for (const [o, s] of Object.entries(t)) {
|
|
@@ -499,38 +499,41 @@ function Po(e) {
|
|
|
499
499
|
}
|
|
500
500
|
return { joined: !0, challengerPubkeys: r };
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function xo(e) {
|
|
503
503
|
let t;
|
|
504
504
|
try {
|
|
505
505
|
t = JSON.parse(e);
|
|
506
506
|
} catch (a) {
|
|
507
507
|
throw new Error("Artifacts file is not valid JSON.", { cause: a });
|
|
508
508
|
}
|
|
509
|
-
const r =
|
|
509
|
+
const r = me(t.vault_id, "vault_id"), o = Eo(me(t.claim_tx, "claim_tx")), s = we(
|
|
510
510
|
t.prover_circuit_version,
|
|
511
511
|
"prover_circuit_version"
|
|
512
|
-
), n =
|
|
512
|
+
), n = BigInt(
|
|
513
513
|
we(
|
|
514
514
|
t.claimable_event_block_number,
|
|
515
515
|
"claimable_event_block_number"
|
|
516
516
|
)
|
|
517
517
|
);
|
|
518
518
|
return {
|
|
519
|
-
vaultCoreVersion:
|
|
519
|
+
vaultCoreVersion: we(
|
|
520
|
+
t.vault_core_version,
|
|
521
|
+
"vault_core_version"
|
|
522
|
+
),
|
|
520
523
|
vaultId: r,
|
|
521
524
|
claimTxid: o.getId(),
|
|
522
|
-
peginTxid:
|
|
525
|
+
peginTxid: Po(o),
|
|
523
526
|
proverCircuitVersion: s,
|
|
524
527
|
claimableEventBlockNumber: n,
|
|
525
528
|
// Required: btc-vault's builder always writes it
|
|
526
529
|
// (`delegated_claim.rs:874` @ b534ff9e), so an absent one is not a file
|
|
527
530
|
// this SDK or the CLI produced.
|
|
528
|
-
verifyingKeyHex:
|
|
529
|
-
babeSessions:
|
|
531
|
+
verifyingKeyHex: me(t.verifying_key, "verifying_key"),
|
|
532
|
+
babeSessions: wo(t.babe_sessions)
|
|
530
533
|
};
|
|
531
534
|
}
|
|
532
535
|
async function cn(e) {
|
|
533
|
-
const t =
|
|
536
|
+
const t = xo(e.artifactsJson), r = z(e.expectedVaultId), o = z(t.vaultId);
|
|
534
537
|
if (r !== o)
|
|
535
538
|
throw new bo(r, o);
|
|
536
539
|
St({
|
|
@@ -539,7 +542,7 @@ async function cn(e) {
|
|
|
539
542
|
expectedVaultId: r
|
|
540
543
|
});
|
|
541
544
|
const s = e.txGraphVersion ?? U;
|
|
542
|
-
if (t.vaultCoreVersion !==
|
|
545
|
+
if (t.vaultCoreVersion !== s)
|
|
543
546
|
throw new Error(
|
|
544
547
|
`Artifacts record vault core version ${t.vaultCoreVersion}, but verification was asked for version ${s}.`
|
|
545
548
|
);
|
|
@@ -566,9 +569,9 @@ async function cn(e) {
|
|
|
566
569
|
throw new Error(
|
|
567
570
|
`Artifacts carry Groth16 verifying key ${n} but the trusted key for prover circuit version ${e.expectedProverCircuitVersion} is ${a}; refusing a file whose proof would verify under a substituted key.`
|
|
568
571
|
);
|
|
569
|
-
return await
|
|
572
|
+
return await ur(s, e.artifactsJson), t;
|
|
570
573
|
}
|
|
571
|
-
function
|
|
574
|
+
function Eo(e) {
|
|
572
575
|
try {
|
|
573
576
|
return S.fromHex(e);
|
|
574
577
|
} catch (t) {
|
|
@@ -577,7 +580,7 @@ function xo(e) {
|
|
|
577
580
|
});
|
|
578
581
|
}
|
|
579
582
|
}
|
|
580
|
-
function
|
|
583
|
+
function me(e, t) {
|
|
581
584
|
if (typeof e != "string" || e.length === 0)
|
|
582
585
|
throw new Error(`Artifacts file is missing a usable "${t}".`);
|
|
583
586
|
return e;
|
|
@@ -587,8 +590,7 @@ function we(e, t) {
|
|
|
587
590
|
throw new Error(`Artifacts file is missing a usable "${t}".`);
|
|
588
591
|
return e;
|
|
589
592
|
}
|
|
590
|
-
function
|
|
591
|
-
if (e === void 0) return {};
|
|
593
|
+
function ko(e, t) {
|
|
592
594
|
if (typeof e != "object" || e === null || Array.isArray(e))
|
|
593
595
|
throw new Error(`Artifacts file is missing a usable "${t}".`);
|
|
594
596
|
return e;
|
|
@@ -629,16 +631,16 @@ function It(e) {
|
|
|
629
631
|
id: Bt(r, s),
|
|
630
632
|
kind: "wronglyChallenged",
|
|
631
633
|
psbtBase64: o,
|
|
632
|
-
inputIndex:
|
|
634
|
+
inputIndex: _r
|
|
633
635
|
});
|
|
634
636
|
});
|
|
635
637
|
return t;
|
|
636
638
|
}
|
|
637
|
-
const
|
|
639
|
+
const $o = "{}", Co = xt - Et;
|
|
638
640
|
function V(e) {
|
|
639
641
|
const t = e.replace(/^0x/, "").toLowerCase();
|
|
640
642
|
if (t.length === xt)
|
|
641
|
-
return t.slice(
|
|
643
|
+
return t.slice(Co);
|
|
642
644
|
if (t.length === Et) return t;
|
|
643
645
|
throw new Error(
|
|
644
646
|
`Public key must be 33-byte compressed or 32-byte x-only hex, got ${t.length / 2} bytes.`
|
|
@@ -651,7 +653,7 @@ async function Ze(e, t, r) {
|
|
|
651
653
|
"Connected wallet does not hold the vault's depositor key. Select the account that made the deposit, then try again."
|
|
652
654
|
);
|
|
653
655
|
const s = await e.getAddress();
|
|
654
|
-
if (!
|
|
656
|
+
if (!rr(s, o, r))
|
|
655
657
|
throw new Error(
|
|
656
658
|
`Connected wallet reports address "${s}", which is not derived from the vault's depositor key. Select the account that made the deposit, then try again.`
|
|
657
659
|
);
|
|
@@ -664,7 +666,7 @@ async function Vt(e, t, r, o) {
|
|
|
664
666
|
`Depositor key ${s} is not the vault's registered depositor key ${r.depositorBtcPubkey}; refusing to plan a claim for another key.`
|
|
665
667
|
);
|
|
666
668
|
try {
|
|
667
|
-
|
|
669
|
+
xr(
|
|
668
670
|
Ie(r.registeredPayoutScriptPubKey),
|
|
669
671
|
r.depositorBtcPubkey,
|
|
670
672
|
o
|
|
@@ -677,44 +679,44 @@ async function Vt(e, t, r, o) {
|
|
|
677
679
|
}
|
|
678
680
|
if (e !== U)
|
|
679
681
|
throw new Error(
|
|
680
|
-
`Graph version ${e} is not the delegated-claim graph version ${U}; vaults on
|
|
682
|
+
`Graph version ${e} is not the delegated-claim graph version ${U}; vaults on other graphs have no delegated-claim path.`
|
|
681
683
|
);
|
|
682
684
|
if (e !== r.vaultCoreVersion)
|
|
683
685
|
throw new Error(
|
|
684
686
|
`Graph version ${e} does not match the vault context's vault core version ${r.vaultCoreVersion}; they are one axis and must agree.`
|
|
685
687
|
);
|
|
686
688
|
const [n, a, i, u, l] = await Promise.all([
|
|
687
|
-
ur(e, t),
|
|
688
689
|
cr(e, t),
|
|
689
690
|
lr(e, t),
|
|
690
691
|
dr(e, t),
|
|
691
|
-
hr(e, t)
|
|
692
|
+
hr(e, t),
|
|
693
|
+
pr(e, t)
|
|
692
694
|
]);
|
|
693
695
|
St({
|
|
694
|
-
peginTxid:
|
|
696
|
+
peginTxid: vo(n),
|
|
695
697
|
depositorEthAddress: r.depositorEthAddress,
|
|
696
698
|
expectedVaultId: r.vaultId
|
|
697
|
-
}),
|
|
699
|
+
}), ao({
|
|
698
700
|
claimPsbtBase64: n,
|
|
699
701
|
assertPsbtBase64: a,
|
|
700
702
|
payoutClaimerPsbtBase64: i
|
|
701
703
|
});
|
|
702
704
|
for (const h of [i, l])
|
|
703
|
-
|
|
705
|
+
po({
|
|
704
706
|
payoutPsbtBase64: h,
|
|
705
707
|
registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
|
|
706
708
|
depositorBtcPubkey: r.depositorBtcPubkey
|
|
707
709
|
});
|
|
708
|
-
const c =
|
|
710
|
+
const c = fo({
|
|
709
711
|
payoutDepositorPsbtBase64: l,
|
|
710
712
|
payoutClaimerPsbtBase64: i
|
|
711
713
|
});
|
|
712
|
-
return await
|
|
714
|
+
return await uo({
|
|
713
715
|
payoutClaimerPsbtBase64: i,
|
|
714
716
|
payoutDepositorPsbtBase64: c,
|
|
715
717
|
assertPsbtBase64: a,
|
|
716
718
|
vault: r
|
|
717
|
-
}),
|
|
719
|
+
}), lo({
|
|
718
720
|
graphChallengerPubkeys: Object.keys(u),
|
|
719
721
|
depositorBtcPubkey: o,
|
|
720
722
|
vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
|
|
@@ -722,7 +724,7 @@ async function Vt(e, t, r, o) {
|
|
|
722
724
|
universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys
|
|
723
725
|
}), { claim: n, assert: a, payoutClaimer: i, payoutDepositor: c, wronglyChallenged: u };
|
|
724
726
|
}
|
|
725
|
-
async function
|
|
727
|
+
async function To(e) {
|
|
726
728
|
At({
|
|
727
729
|
servedVerifyingKeyHex: e.source.verifyingKeyHex,
|
|
728
730
|
trustedVerifyingKeyHex: e.trustedVerifyingKeyHex,
|
|
@@ -741,7 +743,7 @@ async function Co(e) {
|
|
|
741
743
|
source: e.source,
|
|
742
744
|
vault: e.vault,
|
|
743
745
|
// Omitted means unjoined: the browser cannot hold the real sessions.
|
|
744
|
-
babeSessionsJson: e.babeSessionsJson === void 0 ?
|
|
746
|
+
babeSessionsJson: e.babeSessionsJson === void 0 ? $o : e.babeSessionsJson,
|
|
745
747
|
requests: It(t)
|
|
746
748
|
};
|
|
747
749
|
}
|
|
@@ -764,7 +766,7 @@ class Y extends Error {
|
|
|
764
766
|
super(t), this.name = "SigningPlanMismatchError";
|
|
765
767
|
}
|
|
766
768
|
}
|
|
767
|
-
function
|
|
769
|
+
function _o(e, t) {
|
|
768
770
|
if (e.length !== t.length)
|
|
769
771
|
throw new Y(
|
|
770
772
|
`Plan has ${e.length} requests but the graph builds ${t.length}; the plan was altered after planning.`
|
|
@@ -789,7 +791,7 @@ function To(e, t) {
|
|
|
789
791
|
);
|
|
790
792
|
}
|
|
791
793
|
}
|
|
792
|
-
function
|
|
794
|
+
function So(e, t) {
|
|
793
795
|
const r = new Set(e.map((a) => a.id)), o = [...r].filter((a) => !t.has(a)), s = [...t.keys()].filter((a) => !r.has(a));
|
|
794
796
|
if (o.length === 0 && s.length === 0) return;
|
|
795
797
|
const n = (a) => a.map((i) => `"${i}"`).join(", ");
|
|
@@ -805,7 +807,7 @@ function L(e, t) {
|
|
|
805
807
|
);
|
|
806
808
|
return r;
|
|
807
809
|
}
|
|
808
|
-
async function
|
|
810
|
+
async function Ao(e) {
|
|
809
811
|
const { plan: t, signatures: r } = e, { txGraphVersion: o } = t.vault, s = t.source.txGraphJson, n = At({
|
|
810
812
|
servedVerifyingKeyHex: t.source.verifyingKeyHex,
|
|
811
813
|
trustedVerifyingKeyHex: t.trustedVerifyingKeyHex,
|
|
@@ -816,7 +818,7 @@ async function So(e) {
|
|
|
816
818
|
t.vault,
|
|
817
819
|
t.depositorPublicKey
|
|
818
820
|
), i = It(a);
|
|
819
|
-
|
|
821
|
+
_o(t.requests, i), So(i, r);
|
|
820
822
|
for (const c of i)
|
|
821
823
|
fe(
|
|
822
824
|
t,
|
|
@@ -831,12 +833,12 @@ async function So(e) {
|
|
|
831
833
|
Bt(c, d)
|
|
832
834
|
)
|
|
833
835
|
);
|
|
834
|
-
const l = await
|
|
836
|
+
const l = await gr(
|
|
835
837
|
o,
|
|
836
838
|
s,
|
|
837
839
|
L(r, "claim")
|
|
838
840
|
);
|
|
839
|
-
return
|
|
841
|
+
return fr({
|
|
840
842
|
txGraphVersion: o,
|
|
841
843
|
graphJson: s,
|
|
842
844
|
signedClaimTxHex: l,
|
|
@@ -852,10 +854,10 @@ async function So(e) {
|
|
|
852
854
|
expectedVaultCoreVersion: t.vault.vaultCoreVersion
|
|
853
855
|
});
|
|
854
856
|
}
|
|
855
|
-
function
|
|
857
|
+
function Bo(e) {
|
|
856
858
|
return typeof e.signDelegatedClaimPsbt == "function";
|
|
857
859
|
}
|
|
858
|
-
class
|
|
860
|
+
class Io extends Error {
|
|
859
861
|
constructor(t, r, o, s) {
|
|
860
862
|
super(t, s), this.signatures = r, this.failedRequestId = o, this.name = "DelegatedClaimSigningIncompleteError";
|
|
861
863
|
}
|
|
@@ -866,30 +868,30 @@ const Kt = {
|
|
|
866
868
|
payoutClaimer: "standalone",
|
|
867
869
|
claim: "standalone",
|
|
868
870
|
wronglyChallenged: "standalone"
|
|
869
|
-
},
|
|
871
|
+
}, Vo = [
|
|
870
872
|
"payoutClaimer",
|
|
871
873
|
"claim",
|
|
872
874
|
"wronglyChallenged"
|
|
873
875
|
];
|
|
874
|
-
async function
|
|
876
|
+
async function Ro(e, t, r = {}) {
|
|
875
877
|
var s;
|
|
876
|
-
if ((s = r.signal) == null || s.throwIfAborted(),
|
|
878
|
+
if ((s = r.signal) == null || s.throwIfAborted(), Ko(e), V(e.depositorPublicKey) !== e.vault.depositorBtcPubkey)
|
|
877
879
|
throw new Error(
|
|
878
880
|
`Plan depositor key ${V(e.depositorPublicKey)} is not the vault's registered depositor key ${e.vault.depositorBtcPubkey}; the plan was not built for this vault.`
|
|
879
881
|
);
|
|
880
882
|
if (vt(t)) {
|
|
881
|
-
if (!
|
|
883
|
+
if (!Bo(t))
|
|
882
884
|
throw new Error(
|
|
883
885
|
"Approval wallet does not implement signDelegatedClaimPsbt; the claim ceremony needs it because the device signs some claim PSBTs with no loaded intent and needs its own derivation fields on them."
|
|
884
886
|
);
|
|
885
|
-
const n =
|
|
886
|
-
|
|
887
|
-
const a =
|
|
887
|
+
const n = Oo(r, e);
|
|
888
|
+
No(n.depositTerms, e.vault);
|
|
889
|
+
const a = Ho(e), i = await Ze(
|
|
888
890
|
t,
|
|
889
891
|
e.depositorPublicKey,
|
|
890
892
|
e.btcNetwork
|
|
891
893
|
);
|
|
892
|
-
return
|
|
894
|
+
return Do(
|
|
893
895
|
e,
|
|
894
896
|
t,
|
|
895
897
|
i,
|
|
@@ -903,9 +905,9 @@ async function Vo(e, t, r = {}) {
|
|
|
903
905
|
e.depositorPublicKey,
|
|
904
906
|
e.btcNetwork
|
|
905
907
|
);
|
|
906
|
-
return
|
|
908
|
+
return Mo(e, t, o, r.signal);
|
|
907
909
|
}
|
|
908
|
-
function
|
|
910
|
+
function Ko(e) {
|
|
909
911
|
const t = /* @__PURE__ */ new Set();
|
|
910
912
|
for (const r of e.requests) {
|
|
911
913
|
if (t.has(r.id))
|
|
@@ -915,10 +917,10 @@ function Ro(e) {
|
|
|
915
917
|
t.add(r.id);
|
|
916
918
|
}
|
|
917
919
|
}
|
|
918
|
-
function
|
|
920
|
+
function Ho(e) {
|
|
919
921
|
const t = e.requests.filter(
|
|
920
922
|
(s) => Kt[s.kind] === "intentBound"
|
|
921
|
-
), r =
|
|
923
|
+
), r = Vo.flatMap(
|
|
922
924
|
(s) => e.requests.filter((n) => n.kind === s)
|
|
923
925
|
), o = t.length + r.length;
|
|
924
926
|
if (o !== e.requests.length)
|
|
@@ -933,7 +935,7 @@ function Ht(e, t) {
|
|
|
933
935
|
`Delegated-claim signing ended with ${t.size} signatures for ${e.requests.length} requests; the set is incomplete and must not be treated as signed.`
|
|
934
936
|
);
|
|
935
937
|
}
|
|
936
|
-
function
|
|
938
|
+
function Oo(e, t) {
|
|
937
939
|
if (e.depositTerms === void 0)
|
|
938
940
|
throw new Error(
|
|
939
941
|
"An approval wallet signs Assert and the depositor Payout only under this vault's loaded intent; pass depositTerms (rebuilt from on-chain state) so it can be approved."
|
|
@@ -949,7 +951,7 @@ function Ho(e, t) {
|
|
|
949
951
|
);
|
|
950
952
|
return { depositTerms: e.depositTerms, vaultContext: e.vaultContext };
|
|
951
953
|
}
|
|
952
|
-
function
|
|
954
|
+
function No(e, t) {
|
|
953
955
|
const r = (s) => s.map((n) => V(n)).sort().join(",");
|
|
954
956
|
if (r(e.vaultKeeperBtcPubkeys) !== r(t.vaultKeeperBtcPubkeys) || r(e.universalChallengerBtcPubkeys) !== r(t.universalChallengerBtcPubkeys))
|
|
955
957
|
throw new Error(
|
|
@@ -982,15 +984,15 @@ function Oo(e, t) {
|
|
|
982
984
|
`Deposit terms group at htlcVout ${s.htlcVout} names a different vault provider than the vault context this claim signs for; the device would bind the Assert to the wrong intent.`
|
|
983
985
|
);
|
|
984
986
|
}
|
|
985
|
-
async function
|
|
987
|
+
async function Do(e, t, r, o, { intentBound: s, standalone: n }, a) {
|
|
986
988
|
var g;
|
|
987
|
-
const i =
|
|
989
|
+
const i = Lo(e, a.resume), u = [...s, ...n];
|
|
988
990
|
let l = 0;
|
|
989
991
|
const c = {
|
|
990
992
|
phase: "clearing any loaded intent"
|
|
991
993
|
}, h = async (p) => {
|
|
992
|
-
var
|
|
993
|
-
c.phase = "signing", (
|
|
994
|
+
var b;
|
|
995
|
+
c.phase = "signing", (b = a.signal) == null || b.throwIfAborted();
|
|
994
996
|
const y = await t.signDelegatedClaimPsbt(
|
|
995
997
|
He(p.psbtBase64),
|
|
996
998
|
kt(
|
|
@@ -998,7 +1000,7 @@ async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
|
|
|
998
1000
|
p.inputIndex,
|
|
999
1001
|
r
|
|
1000
1002
|
)
|
|
1001
|
-
), f = await
|
|
1003
|
+
), f = await bt(
|
|
1002
1004
|
Rt(y),
|
|
1003
1005
|
p.inputIndex
|
|
1004
1006
|
);
|
|
@@ -1019,7 +1021,7 @@ async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
|
|
|
1019
1021
|
const y = u[l];
|
|
1020
1022
|
if (i.size === 0 || y === void 0) throw p;
|
|
1021
1023
|
const f = c.phase === "signing" ? `stopped at "${y.id}"` : `stopped before "${y.id}" while ${c.phase}`;
|
|
1022
|
-
throw new
|
|
1024
|
+
throw new Io(
|
|
1023
1025
|
`Delegated-claim signing ${f}; ${i.size} of ${e.requests.length} signatures were collected.`,
|
|
1024
1026
|
i,
|
|
1025
1027
|
y.id,
|
|
@@ -1028,7 +1030,7 @@ async function No(e, t, r, o, { intentBound: s, standalone: n }, a) {
|
|
|
1028
1030
|
}
|
|
1029
1031
|
return Ht(e, i), i;
|
|
1030
1032
|
}
|
|
1031
|
-
function
|
|
1033
|
+
function Lo(e, t) {
|
|
1032
1034
|
const r = /* @__PURE__ */ new Map();
|
|
1033
1035
|
if (!t) return r;
|
|
1034
1036
|
for (const o of e.requests) {
|
|
@@ -1044,8 +1046,8 @@ function Do(e, t) {
|
|
|
1044
1046
|
}
|
|
1045
1047
|
return r;
|
|
1046
1048
|
}
|
|
1047
|
-
async function
|
|
1048
|
-
const s = e.requests, n = await
|
|
1049
|
+
async function Mo(e, t, r, o) {
|
|
1050
|
+
const s = e.requests, n = await Pt(
|
|
1049
1051
|
t,
|
|
1050
1052
|
s.map((i) => He(i.psbtBase64)),
|
|
1051
1053
|
s.map(
|
|
@@ -1058,7 +1060,7 @@ async function Lo(e, t, r, o) {
|
|
|
1058
1060
|
o
|
|
1059
1061
|
), a = /* @__PURE__ */ new Map();
|
|
1060
1062
|
for (let i = 0; i < s.length; i++) {
|
|
1061
|
-
const u = await
|
|
1063
|
+
const u = await bt(
|
|
1062
1064
|
Rt(n[i]),
|
|
1063
1065
|
s[i].inputIndex
|
|
1064
1066
|
);
|
|
@@ -1067,34 +1069,34 @@ async function Lo(e, t, r, o) {
|
|
|
1067
1069
|
return Ht(e, a), a;
|
|
1068
1070
|
}
|
|
1069
1071
|
async function ln(e) {
|
|
1070
|
-
const t = await
|
|
1072
|
+
const t = await To({
|
|
1071
1073
|
depositorPublicKey: e.depositorPublicKey,
|
|
1072
1074
|
btcNetwork: e.btcNetwork,
|
|
1073
1075
|
source: e.source,
|
|
1074
1076
|
trustedVerifyingKeyHex: e.trustedVerifyingKeyHex,
|
|
1075
1077
|
vault: e.vault,
|
|
1076
1078
|
babeSessionsJson: e.babeSessionsJson
|
|
1077
|
-
}), r = await
|
|
1079
|
+
}), r = await Ro(t, e.btcWallet, {
|
|
1078
1080
|
depositTerms: e.depositTerms,
|
|
1079
1081
|
vaultContext: e.vaultContext
|
|
1080
1082
|
});
|
|
1081
|
-
return
|
|
1083
|
+
return Ao({ plan: t, signatures: r });
|
|
1082
1084
|
}
|
|
1083
1085
|
async function dn(e) {
|
|
1084
1086
|
const t = await $t(e.btcWallet, e.vaultContext);
|
|
1085
1087
|
let r;
|
|
1086
1088
|
try {
|
|
1087
|
-
r = await
|
|
1089
|
+
r = await yr(t, e.htlcVout);
|
|
1088
1090
|
} finally {
|
|
1089
1091
|
t.fill(0);
|
|
1090
1092
|
}
|
|
1091
1093
|
let o;
|
|
1092
1094
|
try {
|
|
1093
|
-
o = await
|
|
1095
|
+
o = await vr(r);
|
|
1094
1096
|
} finally {
|
|
1095
1097
|
r.fill(0);
|
|
1096
1098
|
}
|
|
1097
|
-
return
|
|
1099
|
+
return Fo(o.pk_hash, e.expectedWotsPkHash), await Pr(
|
|
1098
1100
|
e.txGraphVersion,
|
|
1099
1101
|
o.keypair,
|
|
1100
1102
|
e.txGraphJson
|
|
@@ -1103,7 +1105,7 @@ async function dn(e) {
|
|
|
1103
1105
|
pkHash: o.pk_hash
|
|
1104
1106
|
};
|
|
1105
1107
|
}
|
|
1106
|
-
function
|
|
1108
|
+
function Fo(e, t) {
|
|
1107
1109
|
if (ie(e) !== ie(t))
|
|
1108
1110
|
throw new Error(
|
|
1109
1111
|
`Derived WOTS public-key hash ${ie(e)} does not match the vault's on-chain depositorWotsPkHash ${ie(t)}. The wallet, the HTLC output index, or the derivation itself is not the one this vault was created with.`
|
|
@@ -1124,7 +1126,7 @@ function xe(e, t, r) {
|
|
|
1124
1126
|
rotated: n !== s
|
|
1125
1127
|
};
|
|
1126
1128
|
}
|
|
1127
|
-
function
|
|
1129
|
+
function Uo(e) {
|
|
1128
1130
|
const t = /* @__PURE__ */ new Map();
|
|
1129
1131
|
for (const r of e) {
|
|
1130
1132
|
const o = t.get(r.operationBtcPubkey);
|
|
@@ -1152,7 +1154,7 @@ function Ot(e, t, r) {
|
|
|
1152
1154
|
), n = e.universalChallengers.map(
|
|
1153
1155
|
(a, i) => xe("universal challenger", a, t.universalChallengers[i])
|
|
1154
1156
|
);
|
|
1155
|
-
return
|
|
1157
|
+
return Uo([
|
|
1156
1158
|
o,
|
|
1157
1159
|
...s,
|
|
1158
1160
|
...n
|
|
@@ -1167,7 +1169,7 @@ function Ot(e, t, r) {
|
|
|
1167
1169
|
query: e
|
|
1168
1170
|
};
|
|
1169
1171
|
}
|
|
1170
|
-
async function
|
|
1172
|
+
async function qo(e) {
|
|
1171
1173
|
const t = await e.operationKeyReader.getCurrentOperationKeys(
|
|
1172
1174
|
e.query,
|
|
1173
1175
|
e.blockNumber
|
|
@@ -1184,7 +1186,7 @@ async function Nt(e) {
|
|
|
1184
1186
|
epochs: e.epochs
|
|
1185
1187
|
});
|
|
1186
1188
|
}
|
|
1187
|
-
async function
|
|
1189
|
+
async function Dt(e) {
|
|
1188
1190
|
const { basic: t, protocol: r } = e.vault, {
|
|
1189
1191
|
registryReader: o,
|
|
1190
1192
|
vaultKeeperReader: s,
|
|
@@ -1245,10 +1247,10 @@ async function hn(e) {
|
|
|
1245
1247
|
`the vault's status is ${s.status}, not Redeemed (${ze.REDEEMED}); no scan was made`
|
|
1246
1248
|
);
|
|
1247
1249
|
const [i, u, l, c] = await Promise.all([
|
|
1248
|
-
|
|
1250
|
+
Dt({ vaultId: t, vault: o, readers: r }),
|
|
1249
1251
|
r.registryReader.getRegistrationRecordsAtBlock(s.createdAt),
|
|
1250
1252
|
r.registryReader.getVaultClaimableBy(t, s.depositorBtcPubKey, s.createdAt).catch((v) => {
|
|
1251
|
-
throw
|
|
1253
|
+
throw Er(v) ? new Le(
|
|
1252
1254
|
t,
|
|
1253
1255
|
s.depositorBtcPubKey,
|
|
1254
1256
|
v.fromBlock,
|
|
@@ -1260,9 +1262,9 @@ async function hn(e) {
|
|
|
1260
1262
|
r.protocolParamsReader.getOffchainParamsByVersion(
|
|
1261
1263
|
n.offchainParamsVersion
|
|
1262
1264
|
)
|
|
1263
|
-
]), h =
|
|
1264
|
-
|
|
1265
|
-
const g =
|
|
1265
|
+
]), h = Kr(c.timelockAssert), d = kr(u, t, s.createdAt);
|
|
1266
|
+
$r(d);
|
|
1267
|
+
const g = Cr(d);
|
|
1266
1268
|
if (g.toLowerCase() !== n.prePeginTxHash.toLowerCase())
|
|
1267
1269
|
throw new Error(
|
|
1268
1270
|
`Registration log of vault ${t} records prePeginTxHash ${g} but the vault record says ${n.prePeginTxHash}; refusing an inconsistent node.`
|
|
@@ -1295,7 +1297,7 @@ async function hn(e) {
|
|
|
1295
1297
|
throw new Error(
|
|
1296
1298
|
`Registration log of vault ${t} records proverCircuitVersion ${d.proverCircuitVersion} but the stamped offchain params say ${c.proverCircuitVersion}; refusing an inconsistent node.`
|
|
1297
1299
|
);
|
|
1298
|
-
const p =
|
|
1300
|
+
const p = Tr(n.depositorSignedPeginTx);
|
|
1299
1301
|
for (const [v, E] of [
|
|
1300
1302
|
["Registration", d.peginTxHash],
|
|
1301
1303
|
["Redemption", l.peginTxHash]
|
|
@@ -1305,7 +1307,7 @@ async function hn(e) {
|
|
|
1305
1307
|
`${v} log of vault ${t} records peginTxHash ${E} but the vault's depositor-signed PegIn hashes to ${p}; refusing an inconsistent node.`
|
|
1306
1308
|
);
|
|
1307
1309
|
const y = z(
|
|
1308
|
-
|
|
1310
|
+
mt(p, s.depositor)
|
|
1309
1311
|
);
|
|
1310
1312
|
if (y !== z(t))
|
|
1311
1313
|
throw new Error(
|
|
@@ -1326,16 +1328,16 @@ async function hn(e) {
|
|
|
1326
1328
|
);
|
|
1327
1329
|
}
|
|
1328
1330
|
const f = S.fromHex(
|
|
1329
|
-
|
|
1331
|
+
P(n.depositorSignedPeginTx)
|
|
1330
1332
|
);
|
|
1331
1333
|
if (f.ins.length !== 1)
|
|
1332
1334
|
throw new Error(
|
|
1333
1335
|
`Depositor-signed PegIn of vault ${t} has ${f.ins.length} inputs; it spends Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout} with exactly one; refusing an inconsistent node.`
|
|
1334
1336
|
);
|
|
1335
|
-
const
|
|
1336
|
-
if (
|
|
1337
|
+
const b = Ke(f.ins[0].hash), $ = f.ins[0].index;
|
|
1338
|
+
if (b !== P(n.prePeginTxHash).toLowerCase() || $ !== n.htlcVout)
|
|
1337
1339
|
throw new Error(
|
|
1338
|
-
`Depositor-signed PegIn of vault ${t} spends ${
|
|
1340
|
+
`Depositor-signed PegIn of vault ${t} spends ${b}:${$} but the vault record says Pre-PegIn ${n.prePeginTxHash} output ${n.htlcVout}; refusing an inconsistent node.`
|
|
1339
1341
|
);
|
|
1340
1342
|
const x = f.outs[Z];
|
|
1341
1343
|
if (x === void 0)
|
|
@@ -1351,7 +1353,7 @@ async function hn(e) {
|
|
|
1351
1353
|
vaultId: t,
|
|
1352
1354
|
depositorEthAddress: s.depositor,
|
|
1353
1355
|
depositorBtcPubkey: a,
|
|
1354
|
-
registeredPayoutScriptPubKey:
|
|
1356
|
+
registeredPayoutScriptPubKey: P(
|
|
1355
1357
|
d.depositorPayoutScriptPubKey
|
|
1356
1358
|
),
|
|
1357
1359
|
vaultProviderBtcPubkey: i.vaultProvider.operationBtcPubkey,
|
|
@@ -1385,21 +1387,21 @@ async function hn(e) {
|
|
|
1385
1387
|
};
|
|
1386
1388
|
}
|
|
1387
1389
|
const Go = 8, Xo = 6e3, zo = 10 * 6e4, jo = 10;
|
|
1388
|
-
class
|
|
1390
|
+
class Lt extends Error {
|
|
1389
1391
|
constructor(t) {
|
|
1390
1392
|
super(t), this.name = "PeginRegistrationMissingError";
|
|
1391
1393
|
}
|
|
1392
1394
|
}
|
|
1393
|
-
class
|
|
1395
|
+
class Mt extends Error {
|
|
1394
1396
|
constructor(t) {
|
|
1395
1397
|
super(t), this.name = "PeginRegistrationNotFinalError";
|
|
1396
1398
|
}
|
|
1397
1399
|
}
|
|
1398
1400
|
function Wo(e) {
|
|
1399
|
-
return e instanceof
|
|
1401
|
+
return e instanceof Lt || e instanceof Error && e.name === "PeginRegistrationMissingError";
|
|
1400
1402
|
}
|
|
1401
1403
|
function pn(e) {
|
|
1402
|
-
return e instanceof
|
|
1404
|
+
return e instanceof Mt || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
|
|
1403
1405
|
}
|
|
1404
1406
|
function et(e) {
|
|
1405
1407
|
const { currentBlock: t, createdAtBlock: r } = e, o = t - r + 1n;
|
|
@@ -1428,18 +1430,18 @@ async function gn(e) {
|
|
|
1428
1430
|
`Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
|
|
1429
1431
|
);
|
|
1430
1432
|
if (Date.now() - l >= a)
|
|
1431
|
-
throw new
|
|
1433
|
+
throw new Mt(
|
|
1432
1434
|
`Peg-in registration did not reach ${s} Ethereum confirmations within ${a}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.` + (d instanceof Error ? ` Last read error: ${d.message}` : "")
|
|
1433
1435
|
);
|
|
1434
1436
|
try {
|
|
1435
1437
|
const g = await r(), p = await Promise.all(
|
|
1436
1438
|
o.map((f) => t.getVaultBasicInfo(f))
|
|
1437
1439
|
), y = p.findIndex(
|
|
1438
|
-
(f) => f.depositor ===
|
|
1440
|
+
(f) => f.depositor === Hr || f.createdAt === 0n
|
|
1439
1441
|
);
|
|
1440
1442
|
if (y !== -1) {
|
|
1441
1443
|
if (h += 1, !c && h > jo)
|
|
1442
|
-
throw new
|
|
1444
|
+
throw new Lt(
|
|
1443
1445
|
`Vault ${o[y]} is still not visible on-chain after ${h} reads — the registration does not exist.`
|
|
1444
1446
|
);
|
|
1445
1447
|
console.warn(
|
|
@@ -1447,7 +1449,7 @@ async function gn(e) {
|
|
|
1447
1449
|
), u == null || u({ confirmations: 0, required: s });
|
|
1448
1450
|
} else {
|
|
1449
1451
|
c = !0, h = 0, d = void 0;
|
|
1450
|
-
let f = p[0],
|
|
1452
|
+
let f = p[0], b = et({
|
|
1451
1453
|
currentBlock: g,
|
|
1452
1454
|
createdAtBlock: p[0].createdAt
|
|
1453
1455
|
});
|
|
@@ -1456,10 +1458,10 @@ async function gn(e) {
|
|
|
1456
1458
|
currentBlock: g,
|
|
1457
1459
|
createdAtBlock: $.createdAt
|
|
1458
1460
|
});
|
|
1459
|
-
x <
|
|
1461
|
+
x < b && (b = x, f = $);
|
|
1460
1462
|
}
|
|
1461
|
-
if (u == null || u({ confirmations:
|
|
1462
|
-
return { confirmations:
|
|
1463
|
+
if (u == null || u({ confirmations: b, required: s }), b >= s)
|
|
1464
|
+
return { confirmations: b, basicInfo: f };
|
|
1463
1465
|
}
|
|
1464
1466
|
} catch (g) {
|
|
1465
1467
|
if (Wo(g))
|
|
@@ -1482,8 +1484,8 @@ async function gn(e) {
|
|
|
1482
1484
|
});
|
|
1483
1485
|
}
|
|
1484
1486
|
}
|
|
1485
|
-
const Yo = /^(?:[0-9a-f]{2})*$/,
|
|
1486
|
-
class
|
|
1487
|
+
const Yo = /^(?:[0-9a-f]{2})*$/, Qo = /^[0-9a-f]{64}$/, Jo = /^([0-9a-f]{64}):(0|[1-9][0-9]*)$/, Zo = -2147483648, es = 2147483647, Ee = 4294967295, tt = 2, rt = 2, de = 0;
|
|
1488
|
+
class m extends Error {
|
|
1487
1489
|
constructor(t) {
|
|
1488
1490
|
super(t), this.name = "GraphFingerprintError";
|
|
1489
1491
|
}
|
|
@@ -1491,63 +1493,63 @@ class P extends Error {
|
|
|
1491
1493
|
function k(e, t, r) {
|
|
1492
1494
|
const o = e[t];
|
|
1493
1495
|
if (o === void 0)
|
|
1494
|
-
throw new
|
|
1496
|
+
throw new m(`Graph tx ${r} is missing "${t}"`);
|
|
1495
1497
|
return o;
|
|
1496
1498
|
}
|
|
1497
1499
|
function te(e, t) {
|
|
1498
1500
|
if (!Array.isArray(e))
|
|
1499
|
-
throw new
|
|
1501
|
+
throw new m(`Graph tx ${t} is not an array`);
|
|
1500
1502
|
return e;
|
|
1501
1503
|
}
|
|
1502
1504
|
function B(e, t) {
|
|
1503
1505
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
1504
|
-
throw new
|
|
1506
|
+
throw new m(`Graph tx ${t} is not an object`);
|
|
1505
1507
|
return e;
|
|
1506
1508
|
}
|
|
1507
|
-
function
|
|
1509
|
+
function Q(e, t, r, o) {
|
|
1508
1510
|
if (typeof e != "number" || !Number.isSafeInteger(e) || e < r || e > o)
|
|
1509
|
-
throw new
|
|
1511
|
+
throw new m(
|
|
1510
1512
|
`Graph tx ${t} is not an integer in [${r}, ${o}]`
|
|
1511
1513
|
);
|
|
1512
1514
|
return e;
|
|
1513
1515
|
}
|
|
1514
1516
|
function ke(e, t) {
|
|
1515
1517
|
if (typeof e != "string" || !Yo.test(e))
|
|
1516
|
-
throw new
|
|
1518
|
+
throw new m(
|
|
1517
1519
|
`Graph tx ${t} is not lowercase hex without a prefix`
|
|
1518
1520
|
);
|
|
1519
1521
|
return H.from(e, "hex");
|
|
1520
1522
|
}
|
|
1521
1523
|
function he(e, t) {
|
|
1522
|
-
if (typeof e != "string" || !
|
|
1523
|
-
throw new
|
|
1524
|
+
if (typeof e != "string" || !Qo.test(e))
|
|
1525
|
+
throw new m(
|
|
1524
1526
|
`Graph ${t} is not 32 bytes of lowercase hex`
|
|
1525
1527
|
);
|
|
1526
1528
|
return e;
|
|
1527
1529
|
}
|
|
1528
1530
|
function ot(e, t) {
|
|
1529
1531
|
const r = B(e, t), o = new S();
|
|
1530
|
-
return o.version =
|
|
1532
|
+
return o.version = Q(
|
|
1531
1533
|
k(r, "version", t),
|
|
1532
1534
|
`${t}.version`,
|
|
1533
1535
|
Zo,
|
|
1534
1536
|
es
|
|
1535
|
-
), o.locktime =
|
|
1537
|
+
), o.locktime = Q(
|
|
1536
1538
|
k(r, "lock_time", t),
|
|
1537
1539
|
`${t}.lock_time`,
|
|
1538
1540
|
0,
|
|
1539
1541
|
Ee
|
|
1540
1542
|
), te(k(r, "input", t), `${t}.input`).forEach((s, n) => {
|
|
1541
|
-
const a = `${t}.input[${n}]`, i = B(s, a), u = k(i, "previous_output", a), l = typeof u == "string" &&
|
|
1543
|
+
const a = `${t}.input[${n}]`, i = B(s, a), u = k(i, "previous_output", a), l = typeof u == "string" && Jo.exec(u);
|
|
1542
1544
|
if (!l)
|
|
1543
|
-
throw new
|
|
1545
|
+
throw new m(
|
|
1544
1546
|
`Graph tx ${a}.previous_output is not "<txid>:<vout>"`
|
|
1545
1547
|
);
|
|
1546
|
-
const c =
|
|
1548
|
+
const c = Q(Number(l[2]), `${a}.previous_output vout`, 0, Ee);
|
|
1547
1549
|
o.addInput(
|
|
1548
1550
|
H.from(l[1], "hex").reverse(),
|
|
1549
1551
|
c,
|
|
1550
|
-
|
|
1552
|
+
Q(k(i, "sequence", a), `${a}.sequence`, 0, Ee),
|
|
1551
1553
|
ke(k(i, "script_sig", a), `${a}.script_sig`)
|
|
1552
1554
|
), o.ins[n].witness = te(
|
|
1553
1555
|
k(i, "witness", a),
|
|
@@ -1557,27 +1559,27 @@ function ot(e, t) {
|
|
|
1557
1559
|
const a = `${t}.output[${n}]`, i = B(s, a);
|
|
1558
1560
|
o.addOutput(
|
|
1559
1561
|
ke(k(i, "script_pubkey", a), `${a}.script_pubkey`),
|
|
1560
|
-
|
|
1562
|
+
Q(k(i, "value", a), `${a}.value`, 0, Number.MAX_SAFE_INTEGER)
|
|
1561
1563
|
);
|
|
1562
1564
|
}), new Uint8Array(o.toBuffer());
|
|
1563
1565
|
}
|
|
1564
1566
|
function D(e, t) {
|
|
1565
|
-
const r =
|
|
1567
|
+
const r = P(e).toLowerCase();
|
|
1566
1568
|
let o;
|
|
1567
1569
|
try {
|
|
1568
1570
|
o = S.fromHex(r);
|
|
1569
1571
|
} catch (s) {
|
|
1570
|
-
throw new
|
|
1572
|
+
throw new m(
|
|
1571
1573
|
`Presign ${t} is not one transaction: ${s instanceof Error ? s.message : String(s)}`
|
|
1572
1574
|
);
|
|
1573
1575
|
}
|
|
1574
1576
|
if (o.toHex() !== r)
|
|
1575
|
-
throw new
|
|
1577
|
+
throw new m(
|
|
1576
1578
|
`Presign ${t} is not a canonical transaction encoding`
|
|
1577
1579
|
);
|
|
1578
1580
|
return o;
|
|
1579
1581
|
}
|
|
1580
|
-
function
|
|
1582
|
+
function Ft(e, t) {
|
|
1581
1583
|
const r = e.ins[t];
|
|
1582
1584
|
if (r)
|
|
1583
1585
|
return {
|
|
@@ -1585,98 +1587,98 @@ function Mt(e, t) {
|
|
|
1585
1587
|
vout: r.index
|
|
1586
1588
|
};
|
|
1587
1589
|
}
|
|
1588
|
-
function
|
|
1590
|
+
function Ut(e, t) {
|
|
1589
1591
|
if (!e.outs[de])
|
|
1590
|
-
throw new
|
|
1592
|
+
throw new m(
|
|
1591
1593
|
`Presign ${t}.claim_tx must have output ${de}`
|
|
1592
1594
|
);
|
|
1593
1595
|
}
|
|
1594
1596
|
function ts(e, t, r) {
|
|
1595
1597
|
if (e.ins.length !== 1)
|
|
1596
|
-
throw new
|
|
1598
|
+
throw new m(
|
|
1597
1599
|
`Presign ${r}.claim_tx must have exactly one input, got ${e.ins.length}`
|
|
1598
1600
|
);
|
|
1599
|
-
|
|
1600
|
-
const o =
|
|
1601
|
+
Ut(e, r);
|
|
1602
|
+
const o = Ft(e, 0);
|
|
1601
1603
|
if ((o == null ? void 0 : o.txid) !== t || o.vout !== X) {
|
|
1602
1604
|
const s = o ? `${o.txid}:${o.vout}` : "no input";
|
|
1603
|
-
throw new
|
|
1605
|
+
throw new m(
|
|
1604
1606
|
`Presign ${r}.claim_tx must spend ${t}:${X}, got ${s}`
|
|
1605
1607
|
);
|
|
1606
1608
|
}
|
|
1607
1609
|
}
|
|
1608
1610
|
function Oe(e, t, r) {
|
|
1609
|
-
const o =
|
|
1611
|
+
const o = Ft(e, 0);
|
|
1610
1612
|
if ((o == null ? void 0 : o.txid) !== t || o.vout !== de) {
|
|
1611
1613
|
const s = o ? `${o.txid}:${o.vout}` : "no input";
|
|
1612
|
-
throw new
|
|
1614
|
+
throw new m(
|
|
1613
1615
|
`Presign ${r}.assert_tx input 0 must spend ${t}:${de}, got ${s}`
|
|
1614
1616
|
);
|
|
1615
1617
|
}
|
|
1616
1618
|
}
|
|
1617
|
-
function
|
|
1619
|
+
function qt(e) {
|
|
1618
1620
|
const t = D(e.peginTxHex, `${e.path}.pegin_tx`), r = D(e.claimTxHex, `${e.path}.claim_tx`), o = D(e.assertTxHex, `${e.path}.assert_tx`);
|
|
1619
1621
|
return { peginTx: t, claimTx: r, assertTx: o };
|
|
1620
1622
|
}
|
|
1621
1623
|
function rs(e) {
|
|
1622
1624
|
const t = D(e.claimTxHex, `${e.path}.claim_tx`), r = D(e.assertTxHex, `${e.path}.assert_tx`);
|
|
1623
|
-
|
|
1625
|
+
Ut(t, e.path), Oe(r, t.getId(), e.path);
|
|
1624
1626
|
}
|
|
1625
1627
|
function os(e) {
|
|
1626
|
-
const { peginTx: t, claimTx: r, assertTx: o } =
|
|
1628
|
+
const { peginTx: t, claimTx: r, assertTx: o } = qt(e);
|
|
1627
1629
|
ts(r, t.getId(), e.path), Oe(o, r.getId(), e.path);
|
|
1628
1630
|
}
|
|
1629
1631
|
function ss(e, t) {
|
|
1630
1632
|
const [r, ...o] = e.ins;
|
|
1631
1633
|
if (!r || o.length > 0)
|
|
1632
|
-
throw new
|
|
1634
|
+
throw new m(
|
|
1633
1635
|
`Presign claim_tx must have exactly one input, got ${e.ins.length}`
|
|
1634
1636
|
);
|
|
1635
1637
|
const s = H.from(r.hash).reverse().toString("hex");
|
|
1636
1638
|
if (s !== t || r.index !== X)
|
|
1637
|
-
throw new
|
|
1639
|
+
throw new m(
|
|
1638
1640
|
`Presign claim_tx must spend ${t}:${X}, got ${s}:${r.index}`
|
|
1639
1641
|
);
|
|
1640
1642
|
if (e.version !== tt)
|
|
1641
|
-
throw new
|
|
1643
|
+
throw new m(
|
|
1642
1644
|
`Presign claim_tx version must be ${tt}, got ${e.version}`
|
|
1643
1645
|
);
|
|
1644
1646
|
if (r.witness.length > 0)
|
|
1645
|
-
throw new
|
|
1647
|
+
throw new m(
|
|
1646
1648
|
`Presign claim_tx input must have an empty witness, got ${r.witness.length} item(s)`
|
|
1647
1649
|
);
|
|
1648
1650
|
if (e.outs.length !== rt)
|
|
1649
|
-
throw new
|
|
1651
|
+
throw new m(
|
|
1650
1652
|
`Presign claim_tx must have exactly ${rt} outputs, got ${e.outs.length}`
|
|
1651
1653
|
);
|
|
1652
1654
|
}
|
|
1653
|
-
function
|
|
1655
|
+
function Gt(e) {
|
|
1654
1656
|
const t = [...e.challengers].sort(
|
|
1655
1657
|
(o, s) => o.pubkey < s.pubkey ? -1 : o.pubkey > s.pubkey ? 1 : 0
|
|
1656
1658
|
), r = [e.peginTx, e.claimTx, e.assertTx, e.payoutTx];
|
|
1657
1659
|
return t.forEach((o, s) => {
|
|
1658
1660
|
const n = he(o.pubkey, "challenger pubkey");
|
|
1659
1661
|
if (s > 0 && t[s - 1].pubkey === n)
|
|
1660
|
-
throw new
|
|
1662
|
+
throw new m(`Graph lists challenger ${n} twice`);
|
|
1661
1663
|
r.push(We(n), o.nopayoutTx);
|
|
1662
1664
|
for (const a of o.outputLabelHashes)
|
|
1663
1665
|
r.push(We(he(a, "output_label_hashes entry")));
|
|
1664
|
-
}),
|
|
1666
|
+
}), Fr(Ur(qr(...r)));
|
|
1665
1667
|
}
|
|
1666
1668
|
function ns(e) {
|
|
1667
|
-
const t =
|
|
1669
|
+
const t = P(e.peginTxid).toLowerCase(), { peginTx: r, claimTx: o, assertTx: s } = qt({
|
|
1668
1670
|
peginTxHex: e.peginTxHex,
|
|
1669
1671
|
claimTxHex: e.claimTxHex,
|
|
1670
1672
|
assertTxHex: e.assertTxHex,
|
|
1671
1673
|
path: "depositor_graph"
|
|
1672
1674
|
});
|
|
1673
1675
|
if (r.getId() !== t)
|
|
1674
|
-
throw new
|
|
1676
|
+
throw new m(
|
|
1675
1677
|
`Presign pegin_tx hashes to ${r.getId()}, expected ${t}`
|
|
1676
1678
|
);
|
|
1677
1679
|
ss(o, t), Oe(s, o.getId(), "depositor_graph");
|
|
1678
1680
|
const n = (a) => new Uint8Array(a.toBuffer());
|
|
1679
|
-
return
|
|
1681
|
+
return Gt({
|
|
1680
1682
|
peginTx: n(r),
|
|
1681
1683
|
claimTx: n(o),
|
|
1682
1684
|
assertTx: n(s),
|
|
@@ -1685,7 +1687,7 @@ function ns(e) {
|
|
|
1685
1687
|
pubkey: _(a.challenger_pubkey),
|
|
1686
1688
|
nopayoutTx: n(D(a.nopayout_tx.tx_hex, "nopayout_tx")),
|
|
1687
1689
|
outputLabelHashes: a.output_label_hashes.map(
|
|
1688
|
-
(i) =>
|
|
1690
|
+
(i) => P(i).toLowerCase()
|
|
1689
1691
|
)
|
|
1690
1692
|
}))
|
|
1691
1693
|
});
|
|
@@ -1695,7 +1697,7 @@ function is(e) {
|
|
|
1695
1697
|
k(e, "challenger_subgraphs", "graph"),
|
|
1696
1698
|
"challenger_subgraphs"
|
|
1697
1699
|
);
|
|
1698
|
-
return
|
|
1700
|
+
return Gt({
|
|
1699
1701
|
peginTx: t("pegin_tx"),
|
|
1700
1702
|
claimTx: t("claim_tx"),
|
|
1701
1703
|
assertTx: t("assert_tx"),
|
|
@@ -1730,7 +1732,7 @@ function as(e) {
|
|
|
1730
1732
|
).forEach((s, n) => {
|
|
1731
1733
|
const a = he(s, `challenger_pubkeys.${o}[${n}]`);
|
|
1732
1734
|
if (r.has(a))
|
|
1733
|
-
throw new
|
|
1735
|
+
throw new m(
|
|
1734
1736
|
`Graph declares challenger ${a} more than once`
|
|
1735
1737
|
);
|
|
1736
1738
|
r.add(a);
|
|
@@ -1740,28 +1742,28 @@ function as(e) {
|
|
|
1740
1742
|
function fn(e, t) {
|
|
1741
1743
|
const r = is(e);
|
|
1742
1744
|
if (r !== t)
|
|
1743
|
-
throw new
|
|
1745
|
+
throw new m(
|
|
1744
1746
|
`Graph fingerprint ${r} does not match the presign fingerprint ${t}`
|
|
1745
1747
|
);
|
|
1746
1748
|
const o = Object.keys(
|
|
1747
1749
|
B(e.challenger_subgraphs, "challenger_subgraphs")
|
|
1748
1750
|
), s = as(e);
|
|
1749
1751
|
if (o.length !== s.size || o.some((n) => !s.has(n)))
|
|
1750
|
-
throw new
|
|
1752
|
+
throw new m(
|
|
1751
1753
|
`Graph challenger_subgraphs keys ${o.join(", ")} do not match challenger_pubkeys ${[...s].join(", ")}`
|
|
1752
1754
|
);
|
|
1753
1755
|
}
|
|
1754
1756
|
const us = 1;
|
|
1755
1757
|
function cs(e, t, r) {
|
|
1756
1758
|
const o = r.map(
|
|
1757
|
-
(h) =>
|
|
1759
|
+
(h) => P(h).toLowerCase()
|
|
1758
1760
|
), s = t.filter((h) => o.includes(h));
|
|
1759
1761
|
if (s.length > 0)
|
|
1760
1762
|
throw new Error(
|
|
1761
1763
|
`Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
|
|
1762
1764
|
);
|
|
1763
1765
|
const n = [...t, ...o], a = e.map(
|
|
1764
|
-
(h) =>
|
|
1766
|
+
(h) => P(h.challenger_pubkey).toLowerCase()
|
|
1765
1767
|
), i = new Set(a);
|
|
1766
1768
|
if (i.size !== a.length)
|
|
1767
1769
|
throw new Error(
|
|
@@ -1772,16 +1774,16 @@ function cs(e, t, r) {
|
|
|
1772
1774
|
throw new Error(
|
|
1773
1775
|
"Depositor graph challenger set does not match expected (local ∪ universal)" + (l.length > 0 ? ` (missing: ${l.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
|
|
1774
1776
|
);
|
|
1775
|
-
return
|
|
1777
|
+
return sr(n);
|
|
1776
1778
|
}
|
|
1777
|
-
function ls(e, t
|
|
1778
|
-
const
|
|
1779
|
-
if (e.outs.length !==
|
|
1779
|
+
function ls(e, t) {
|
|
1780
|
+
const r = Sr + Ar * t + Br;
|
|
1781
|
+
if (e.outs.length !== r)
|
|
1780
1782
|
throw new Error(
|
|
1781
|
-
`Assert must have ${
|
|
1783
|
+
`Assert must have ${r} outputs for ${t} challengers, got ${e.outs.length}`
|
|
1782
1784
|
);
|
|
1783
1785
|
}
|
|
1784
|
-
async function
|
|
1786
|
+
async function Xt(e, t) {
|
|
1785
1787
|
const r = wt({
|
|
1786
1788
|
claimerBtcPubkey: t.depositorBtcPubkey,
|
|
1787
1789
|
depositorBtcPubkey: t.depositorBtcPubkey,
|
|
@@ -1791,17 +1793,13 @@ async function Gt(e, t) {
|
|
|
1791
1793
|
e.challenger_presign_data,
|
|
1792
1794
|
r,
|
|
1793
1795
|
t.universalChallengerBtcPubkeys
|
|
1794
|
-
), s =
|
|
1795
|
-
|
|
1796
|
-
);
|
|
1797
|
-
ls(
|
|
1798
|
-
n,
|
|
1799
|
-
o.length,
|
|
1800
|
-
t.vaultCoreVersion
|
|
1796
|
+
), s = P(t.depositorBtcPubkey), n = S.fromHex(
|
|
1797
|
+
P(e.assert_tx.tx_hex)
|
|
1801
1798
|
);
|
|
1799
|
+
ls(n, o.length);
|
|
1802
1800
|
const a = [];
|
|
1803
1801
|
for (const i of e.challenger_presign_data) {
|
|
1804
|
-
const u =
|
|
1802
|
+
const u = P(i.challenger_pubkey), l = o.indexOf(
|
|
1805
1803
|
u.toLowerCase()
|
|
1806
1804
|
), c = await ds({
|
|
1807
1805
|
challenger: i,
|
|
@@ -1826,17 +1824,17 @@ async function ds(e) {
|
|
|
1826
1824
|
assertTx: a,
|
|
1827
1825
|
ctx: i
|
|
1828
1826
|
} = e;
|
|
1829
|
-
|
|
1827
|
+
Xr(
|
|
1830
1828
|
t.nopayout_tx.tx_hex,
|
|
1831
1829
|
r,
|
|
1832
1830
|
i.network
|
|
1833
1831
|
);
|
|
1834
1832
|
const u = S.fromHex(
|
|
1835
|
-
|
|
1833
|
+
P(t.nopayout_tx.tx_hex)
|
|
1836
1834
|
), l = S.fromHex(
|
|
1837
|
-
|
|
1835
|
+
P(t.challenge_assert_x_tx.tx_hex)
|
|
1838
1836
|
), c = S.fromHex(
|
|
1839
|
-
|
|
1837
|
+
P(t.challenge_assert_y_tx.tx_hex)
|
|
1840
1838
|
), h = await br({
|
|
1841
1839
|
txGraphVersion: i.vaultCoreVersion,
|
|
1842
1840
|
claimer: n,
|
|
@@ -1851,7 +1849,7 @@ async function ds(e) {
|
|
|
1851
1849
|
["X", l],
|
|
1852
1850
|
["Y", c]
|
|
1853
1851
|
])
|
|
1854
|
-
|
|
1852
|
+
zr({
|
|
1855
1853
|
challengeAssertTx: p,
|
|
1856
1854
|
assertTx: a,
|
|
1857
1855
|
half: g,
|
|
@@ -1865,7 +1863,7 @@ async function ds(e) {
|
|
|
1865
1863
|
l.outs[Xe],
|
|
1866
1864
|
c.outs[Xe]
|
|
1867
1865
|
];
|
|
1868
|
-
return
|
|
1866
|
+
return jr({
|
|
1869
1867
|
noPayoutTx: u,
|
|
1870
1868
|
assertTxid: a.getId(),
|
|
1871
1869
|
challengeAssertXTxid: l.getId(),
|
|
@@ -1882,7 +1880,7 @@ async function ds(e) {
|
|
|
1882
1880
|
}));
|
|
1883
1881
|
}
|
|
1884
1882
|
async function hs(e, t, r) {
|
|
1885
|
-
const o = [], s = [], n = [], { localChallengers: a, noPayouts: i } = await
|
|
1883
|
+
const o = [], s = [], n = [], { localChallengers: a, noPayouts: i } = await Xt(e, r), u = await Rr({
|
|
1886
1884
|
vaultCoreVersion: r.vaultCoreVersion,
|
|
1887
1885
|
vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
|
|
1888
1886
|
vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
|
|
@@ -1909,9 +1907,9 @@ async function hs(e, t, r) {
|
|
|
1909
1907
|
Ge
|
|
1910
1908
|
)
|
|
1911
1909
|
);
|
|
1912
|
-
const l =
|
|
1910
|
+
const l = P(r.depositorBtcPubkey);
|
|
1913
1911
|
for (const { challenger: c, challengerPubkey: h, prevouts: d } of i) {
|
|
1914
|
-
const g = o.length, p = await
|
|
1912
|
+
const g = o.length, p = await Gr({
|
|
1915
1913
|
noPayoutTxHex: c.nopayout_tx.tx_hex,
|
|
1916
1914
|
challengerPubkey: h,
|
|
1917
1915
|
prevouts: d,
|
|
@@ -1980,14 +1978,14 @@ async function gs(e) {
|
|
|
1980
1978
|
assertTxHex: t.assert_tx.tx_hex,
|
|
1981
1979
|
path: "depositor_graph"
|
|
1982
1980
|
});
|
|
1983
|
-
const s = await r.getPublicKeyHex(), { depositorPubkey: n } =
|
|
1981
|
+
const s = await r.getPublicKeyHex(), { depositorPubkey: n } = or(
|
|
1984
1982
|
s,
|
|
1985
|
-
|
|
1983
|
+
P(o.depositorBtcPubkey)
|
|
1986
1984
|
), { psbtHexes: a, signOptions: i, challengerEntries: u } = await hs(
|
|
1987
1985
|
t,
|
|
1988
1986
|
s,
|
|
1989
1987
|
o
|
|
1990
|
-
), l = await
|
|
1988
|
+
), l = await Pt(
|
|
1991
1989
|
r,
|
|
1992
1990
|
a,
|
|
1993
1991
|
i
|
|
@@ -2002,7 +2000,7 @@ async function gs(e) {
|
|
|
2002
2000
|
);
|
|
2003
2001
|
}
|
|
2004
2002
|
const fs = 1e4, M = 10;
|
|
2005
|
-
async function
|
|
2003
|
+
async function zt(e) {
|
|
2006
2004
|
const {
|
|
2007
2005
|
statusReader: t,
|
|
2008
2006
|
vaultId: r,
|
|
@@ -2037,12 +2035,12 @@ async function Xt(e) {
|
|
|
2037
2035
|
const c = l.status;
|
|
2038
2036
|
if (s.has(c) || c === R.ACTIVATED)
|
|
2039
2037
|
return c;
|
|
2040
|
-
if (c === R.EXPIRED ||
|
|
2038
|
+
if (c === R.EXPIRED || Dr.has(c))
|
|
2041
2039
|
throw new Error(
|
|
2042
2040
|
`Vault ${r.slice(0, M)}… reached terminal status "${c}" while waiting for ${[...s].join(", ")}`
|
|
2043
2041
|
);
|
|
2044
2042
|
} catch (l) {
|
|
2045
|
-
if (!(l instanceof
|
|
2043
|
+
if (!(l instanceof Lr && l.code === Mr.PEGIN_NOT_FOUND))
|
|
2046
2044
|
throw l;
|
|
2047
2045
|
}
|
|
2048
2046
|
await new Promise((l, c) => {
|
|
@@ -2059,16 +2057,16 @@ async function Xt(e) {
|
|
|
2059
2057
|
});
|
|
2060
2058
|
}
|
|
2061
2059
|
}
|
|
2062
|
-
const ys = 1200 * 1e3,
|
|
2060
|
+
const ys = 1200 * 1e3, jt = /* @__PURE__ */ new Set([
|
|
2063
2061
|
R.PENDING_ACKS,
|
|
2064
2062
|
R.PENDING_ACTIVATION,
|
|
2065
2063
|
R.ACTIVATED_PENDING_BROADCAST,
|
|
2066
2064
|
R.ACTIVATED
|
|
2067
2065
|
]), vs = /* @__PURE__ */ new Set([
|
|
2068
2066
|
R.PENDING_DEPOSITOR_SIGNATURES,
|
|
2069
|
-
...
|
|
2067
|
+
...jt
|
|
2070
2068
|
]);
|
|
2071
|
-
function
|
|
2069
|
+
function Ps(e) {
|
|
2072
2070
|
return e.map((t) => ({
|
|
2073
2071
|
claimerPubkeyXOnly: pe(t.claimer_pubkey),
|
|
2074
2072
|
payoutTxHex: t.payout_tx.tx_hex,
|
|
@@ -2078,7 +2076,7 @@ function bs(e) {
|
|
|
2078
2076
|
function I(e) {
|
|
2079
2077
|
return pe(e).toLowerCase();
|
|
2080
2078
|
}
|
|
2081
|
-
function
|
|
2079
|
+
function bs(e, t) {
|
|
2082
2080
|
const r = (u, l, c) => {
|
|
2083
2081
|
throw new Error(
|
|
2084
2082
|
`Deposit terms ${u} (${String(l)}) does not match the vault's version-locked signing context (${String(c)}); refusing to sign payouts against terms that describe a different graph.`
|
|
@@ -2116,7 +2114,7 @@ function ms(e, t) {
|
|
|
2116
2114
|
t.vaultProviderBtcPubkey
|
|
2117
2115
|
);
|
|
2118
2116
|
}
|
|
2119
|
-
function
|
|
2117
|
+
function ms(e, t, r, o) {
|
|
2120
2118
|
const s = I(o), n = [
|
|
2121
2119
|
I(t),
|
|
2122
2120
|
...r.map(I)
|
|
@@ -2163,7 +2161,7 @@ function st(e, t) {
|
|
|
2163
2161
|
};
|
|
2164
2162
|
}
|
|
2165
2163
|
async function ws(e, t, r, o) {
|
|
2166
|
-
const s = new
|
|
2164
|
+
const s = new ir({
|
|
2167
2165
|
network: t.network,
|
|
2168
2166
|
btcWallet: e
|
|
2169
2167
|
}), n = r.length;
|
|
@@ -2204,7 +2202,7 @@ async function yn(e) {
|
|
|
2204
2202
|
signal: c,
|
|
2205
2203
|
onProgress: h,
|
|
2206
2204
|
recordGraphFingerprint: d
|
|
2207
|
-
} = e, g = await
|
|
2205
|
+
} = e, g = await zt({
|
|
2208
2206
|
statusReader: t,
|
|
2209
2207
|
vaultId: s,
|
|
2210
2208
|
peginTxid: n,
|
|
@@ -2212,9 +2210,9 @@ async function yn(e) {
|
|
|
2212
2210
|
timeoutMs: l,
|
|
2213
2211
|
signal: c
|
|
2214
2212
|
});
|
|
2215
|
-
if (
|
|
2213
|
+
if (jt.has(g))
|
|
2216
2214
|
return;
|
|
2217
|
-
c == null || c.throwIfAborted(), u !== void 0 &&
|
|
2215
|
+
c == null || c.throwIfAborted(), u !== void 0 && bs(u, i);
|
|
2218
2216
|
const p = vt(o) ? o : void 0;
|
|
2219
2217
|
let y;
|
|
2220
2218
|
if (p) {
|
|
@@ -2238,7 +2236,7 @@ async function yn(e) {
|
|
|
2238
2236
|
path: `txs[${se}]`
|
|
2239
2237
|
});
|
|
2240
2238
|
});
|
|
2241
|
-
const
|
|
2239
|
+
const b = ns({
|
|
2242
2240
|
peginTxid: n,
|
|
2243
2241
|
peginTxHex: i.peginTxHex,
|
|
2244
2242
|
claimTxHex: f.depositor_graph.claim_tx.tx_hex,
|
|
@@ -2263,12 +2261,12 @@ async function yn(e) {
|
|
|
2263
2261
|
vkClaimerPayoutScriptPubKeys: i.vkClaimerPayoutScriptPubKeys,
|
|
2264
2262
|
vpCommissionScriptPubKey: i.vpCommissionScriptPubKey
|
|
2265
2263
|
};
|
|
2266
|
-
await
|
|
2264
|
+
await Xt(
|
|
2267
2265
|
f.depositor_graph,
|
|
2268
2266
|
$
|
|
2269
2267
|
), c == null || c.throwIfAborted();
|
|
2270
2268
|
const x = I(a);
|
|
2271
|
-
|
|
2269
|
+
ms(
|
|
2272
2270
|
f.txs,
|
|
2273
2271
|
i.vaultProviderBtcPubkey,
|
|
2274
2272
|
i.vaultKeeperBtcPubkeys,
|
|
@@ -2276,7 +2274,7 @@ async function yn(e) {
|
|
|
2276
2274
|
);
|
|
2277
2275
|
const v = f.txs.filter(
|
|
2278
2276
|
(O) => I(O.claimer_pubkey) !== x
|
|
2279
|
-
), E =
|
|
2277
|
+
), E = Ps(v);
|
|
2280
2278
|
p && y && (typeof p.validateDepositTerms == "function" && await p.validateDepositTerms(y), await p.approveDepositTerms(y)), c == null || c.throwIfAborted();
|
|
2281
2279
|
const T = await ws(
|
|
2282
2280
|
o,
|
|
@@ -2290,9 +2288,9 @@ async function yn(e) {
|
|
|
2290
2288
|
btcWallet: o,
|
|
2291
2289
|
signingContext: $
|
|
2292
2290
|
});
|
|
2293
|
-
c == null || c.throwIfAborted(), await d(
|
|
2291
|
+
c == null || c.throwIfAborted(), await d(b), c == null || c.throwIfAborted();
|
|
2294
2292
|
const j = { ...T };
|
|
2295
|
-
j[
|
|
2293
|
+
j[P(a)] = w.payout_signatures, await r.submitDepositorPresignatures(
|
|
2296
2294
|
{
|
|
2297
2295
|
pegin_txid: n,
|
|
2298
2296
|
depositor_pk: a,
|
|
@@ -2318,7 +2316,7 @@ async function vn(e) {
|
|
|
2318
2316
|
signal: u
|
|
2319
2317
|
} = e;
|
|
2320
2318
|
u == null || u.throwIfAborted();
|
|
2321
|
-
const l = await
|
|
2319
|
+
const l = await zt({
|
|
2322
2320
|
statusReader: t,
|
|
2323
2321
|
vaultId: o,
|
|
2324
2322
|
peginTxid: s,
|
|
@@ -2358,7 +2356,7 @@ function Ce(e) {
|
|
|
2358
2356
|
function it(e, t) {
|
|
2359
2357
|
return e.length === t.length && e.every((r, o) => r === t[o]);
|
|
2360
2358
|
}
|
|
2361
|
-
async function
|
|
2359
|
+
async function Pn(e) {
|
|
2362
2360
|
const {
|
|
2363
2361
|
vaultProviderEthAddress: t,
|
|
2364
2362
|
hintBtcPubkey: r,
|
|
@@ -2382,11 +2380,11 @@ class Se extends Error {
|
|
|
2382
2380
|
super(t), this.name = "ApplicationEntryPointMismatchError";
|
|
2383
2381
|
}
|
|
2384
2382
|
}
|
|
2385
|
-
function
|
|
2383
|
+
function bn(e) {
|
|
2386
2384
|
return e instanceof Se || e instanceof Error && e.name === "ApplicationEntryPointMismatchError";
|
|
2387
2385
|
}
|
|
2388
2386
|
const at = (e) => e.map(_).sort();
|
|
2389
|
-
async function
|
|
2387
|
+
async function mn(e) {
|
|
2390
2388
|
const {
|
|
2391
2389
|
vaultRegistryReader: t,
|
|
2392
2390
|
vaultKeeperReader: r,
|
|
@@ -2417,15 +2415,15 @@ async function Pn(e) {
|
|
|
2417
2415
|
o.getLatestUniversalChallengersVersion(d),
|
|
2418
2416
|
o.getCurrentUcKeyEpoch(d)
|
|
2419
2417
|
]);
|
|
2420
|
-
if (!
|
|
2418
|
+
if (!Or(n, { strict: !1 }))
|
|
2421
2419
|
throw new Se(
|
|
2422
2420
|
`The application entry point this deposit was prepared for is not a valid address: ${n}`
|
|
2423
2421
|
);
|
|
2424
|
-
if (!
|
|
2422
|
+
if (!Nr(g, n))
|
|
2425
2423
|
throw new Se(
|
|
2426
2424
|
`Vault provider ${s} is registered to application ${g}, but this deposit was prepared for ${n}. Refusing to build: the vault keeper roster, its version, and the keeper key epoch would all resolve against a different application than the one selected.`
|
|
2427
2425
|
);
|
|
2428
|
-
const [
|
|
2426
|
+
const [b, $] = await Promise.all(
|
|
2429
2427
|
[
|
|
2430
2428
|
r.getCurrentVaultKeepersVersion(
|
|
2431
2429
|
g,
|
|
@@ -2439,7 +2437,7 @@ async function Pn(e) {
|
|
|
2439
2437
|
), [x, v] = await Promise.all([
|
|
2440
2438
|
r.getVaultKeepersByVersion(
|
|
2441
2439
|
g,
|
|
2442
|
-
|
|
2440
|
+
b,
|
|
2443
2441
|
d
|
|
2444
2442
|
),
|
|
2445
2443
|
o.getUniversalChallengersByVersion(
|
|
@@ -2450,7 +2448,7 @@ async function Pn(e) {
|
|
|
2450
2448
|
vaultProvider: _(p),
|
|
2451
2449
|
vaultKeepers: at(x.map((C) => C.btcPubKey)),
|
|
2452
2450
|
universalChallengers: at(v.map((C) => C.btcPubKey))
|
|
2453
|
-
}, T = await
|
|
2451
|
+
}, T = await qo({
|
|
2454
2452
|
operationKeyReader: l,
|
|
2455
2453
|
query: {
|
|
2456
2454
|
vaultProviderEthAddress: s,
|
|
@@ -2485,14 +2483,14 @@ async function Pn(e) {
|
|
|
2485
2483
|
);
|
|
2486
2484
|
if (!$e(O))
|
|
2487
2485
|
throw new Error(
|
|
2488
|
-
`Vault keeper BTC pubkeys (v${
|
|
2486
|
+
`Vault keeper BTC pubkeys (v${b}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
2489
2487
|
);
|
|
2490
2488
|
if (!$e(se))
|
|
2491
2489
|
throw new Error(
|
|
2492
2490
|
`Universal challenger BTC pubkeys (v${y}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
2493
2491
|
);
|
|
2494
|
-
const Ne = [j, O, se],
|
|
2495
|
-
if (
|
|
2492
|
+
const Ne = [j, O, se], Zt = Ne.some((C) => C.registration && !C.operation), De = Ne.some((C) => C.operation && !C.registration);
|
|
2493
|
+
if (Zt && De) {
|
|
2496
2494
|
const C = `Indexer participant hints are internally inconsistent for vault provider ${s}: some roles match the registration keys while others match the rotated operation keys.`;
|
|
2497
2495
|
throw h == null || h(C), new Error(`${C} Refresh and try again.`);
|
|
2498
2496
|
}
|
|
@@ -2502,7 +2500,7 @@ async function Pn(e) {
|
|
|
2502
2500
|
vaultProviderBtcPubkeyXOnly: w.vaultProvider,
|
|
2503
2501
|
vaultKeeperBtcPubkeysSorted: w.vaultKeepers,
|
|
2504
2502
|
universalChallengerBtcPubkeysSorted: w.universalChallengers,
|
|
2505
|
-
expectedAppVaultKeepersVersion:
|
|
2503
|
+
expectedAppVaultKeepersVersion: b,
|
|
2506
2504
|
expectedUniversalChallengersVersion: y,
|
|
2507
2505
|
appKeeperKeyEpoch: $,
|
|
2508
2506
|
ucKeyEpoch: f,
|
|
@@ -2589,7 +2587,7 @@ function Cs(e, t, r) {
|
|
|
2589
2587
|
return { valid: !0 };
|
|
2590
2588
|
}
|
|
2591
2589
|
function Ts(e) {
|
|
2592
|
-
const t =
|
|
2590
|
+
const t = P(e);
|
|
2593
2591
|
return $s(t) ? { valid: !0 } : {
|
|
2594
2592
|
valid: !1,
|
|
2595
2593
|
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
@@ -2632,13 +2630,13 @@ function $n(e) {
|
|
|
2632
2630
|
throw new Error(l.error);
|
|
2633
2631
|
_s(s), Ss(n), As(r);
|
|
2634
2632
|
}
|
|
2635
|
-
class
|
|
2633
|
+
class Wt extends Error {
|
|
2636
2634
|
constructor(t) {
|
|
2637
2635
|
super(t), this.name = "ParticipantKeyDriftError";
|
|
2638
2636
|
}
|
|
2639
2637
|
}
|
|
2640
2638
|
function Cn(e) {
|
|
2641
|
-
return e instanceof
|
|
2639
|
+
return e instanceof Wt || e instanceof Error && e.name === "ParticipantKeyDriftError";
|
|
2642
2640
|
}
|
|
2643
2641
|
function ut(e, t, r) {
|
|
2644
2642
|
return t.length === r.length && t.every((o, s) => o === r[s]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
|
|
@@ -2679,17 +2677,17 @@ async function Tn(e) {
|
|
|
2679
2677
|
g && i.push(g);
|
|
2680
2678
|
}
|
|
2681
2679
|
if (i.length > 0)
|
|
2682
|
-
throw new
|
|
2680
|
+
throw new Wt(
|
|
2683
2681
|
`Aborting BTC broadcast: participant operation keys changed during registration (${i.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
|
|
2684
2682
|
);
|
|
2685
2683
|
}
|
|
2686
|
-
class
|
|
2684
|
+
class Yt extends Error {
|
|
2687
2685
|
constructor(t) {
|
|
2688
2686
|
super(t), this.name = "RegisteredVaultVersionMismatchError";
|
|
2689
2687
|
}
|
|
2690
2688
|
}
|
|
2691
2689
|
function _n(e) {
|
|
2692
|
-
return e instanceof
|
|
2690
|
+
return e instanceof Yt || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
|
|
2693
2691
|
}
|
|
2694
2692
|
async function Sn(e) {
|
|
2695
2693
|
const {
|
|
@@ -2712,7 +2710,7 @@ async function Sn(e) {
|
|
|
2712
2710
|
`vault ${h}: vaultCoreVersion expected v${a} (build-time active), got v${l.vaultCoreVersion}`
|
|
2713
2711
|
);
|
|
2714
2712
|
}), u.length > 0)
|
|
2715
|
-
throw new
|
|
2713
|
+
throw new Yt(
|
|
2716
2714
|
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${u.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
|
|
2717
2715
|
);
|
|
2718
2716
|
}
|
|
@@ -2724,7 +2722,7 @@ class Bs extends Error {
|
|
|
2724
2722
|
this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
|
|
2725
2723
|
}
|
|
2726
2724
|
}
|
|
2727
|
-
const Is = /^0x[0-9a-fA-F]{64}$/, Vs = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/,
|
|
2725
|
+
const Is = /^0x[0-9a-fA-F]{64}$/, Vs = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Qt = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Jt = 160, ct = 2e3, lt = 10n, dt = 100n;
|
|
2728
2726
|
function An(e) {
|
|
2729
2727
|
if (!Number.isFinite(e) || e <= 0)
|
|
2730
2728
|
throw new Error(
|
|
@@ -2790,7 +2788,7 @@ function Hs(e) {
|
|
|
2790
2788
|
throw new Error(
|
|
2791
2789
|
"unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
|
|
2792
2790
|
);
|
|
2793
|
-
if (!e.depositorBtcPubkey || !
|
|
2791
|
+
if (!e.depositorBtcPubkey || !Qt.test(e.depositorBtcPubkey))
|
|
2794
2792
|
throw new Error(
|
|
2795
2793
|
"depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
|
|
2796
2794
|
);
|
|
@@ -2798,7 +2796,7 @@ function Hs(e) {
|
|
|
2798
2796
|
throw new Error(`amount must be a positive bigint, got ${e.amount}`);
|
|
2799
2797
|
}
|
|
2800
2798
|
function Os(e) {
|
|
2801
|
-
if (!e.vaultProviderPubkey || !
|
|
2799
|
+
if (!e.vaultProviderPubkey || !Qt.test(e.vaultProviderPubkey))
|
|
2802
2800
|
throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
|
|
2803
2801
|
if (e.vaultKeeperPubkeys.length === 0)
|
|
2804
2802
|
throw new Error("vaultKeeperPubkeys must be non-empty");
|
|
@@ -2851,7 +2849,7 @@ async function Bn(e) {
|
|
|
2851
2849
|
i == null || i.throwIfAborted();
|
|
2852
2850
|
const d = pe(
|
|
2853
2851
|
u.depositorBtcPubkey
|
|
2854
|
-
), g =
|
|
2852
|
+
), g = P(u.unsignedPrePeginTxHex), p = ar(g);
|
|
2855
2853
|
if (p !== void 0 && p.vout !== u.batch.length)
|
|
2856
2854
|
throw new Error(
|
|
2857
2855
|
`Auth-anchor OP_RETURN at vout ${p.vout} does not match batch size (${u.batch.length} HTLC outputs expect the anchor at vout ${u.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
|
|
@@ -2869,14 +2867,14 @@ async function Bn(e) {
|
|
|
2869
2867
|
throw new Error(
|
|
2870
2868
|
`Funded Pre-PegIn tx has ${f.outs.length} outputs but batch requires at least ${u.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
|
|
2871
2869
|
);
|
|
2872
|
-
const { psbtHex:
|
|
2870
|
+
const { psbtHex: b } = await Wr({
|
|
2873
2871
|
prePeginParams: {
|
|
2874
2872
|
vaultCoreVersion: u.vaultCoreVersion,
|
|
2875
2873
|
depositorPubkey: d,
|
|
2876
|
-
vaultProviderPubkey:
|
|
2877
|
-
vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(
|
|
2878
|
-
universalChallengerPubkeys: l.universalChallengerPubkeys.map(
|
|
2879
|
-
hashlocks: u.batch.map((w) =>
|
|
2874
|
+
vaultProviderPubkey: P(l.vaultProviderPubkey),
|
|
2875
|
+
vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(P),
|
|
2876
|
+
universalChallengerPubkeys: l.universalChallengerPubkeys.map(P),
|
|
2877
|
+
hashlocks: u.batch.map((w) => P(w.hashlock)),
|
|
2880
2878
|
timelockRefund: l.timelockRefund,
|
|
2881
2879
|
// `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
|
|
2882
2880
|
// is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
|
|
@@ -2900,15 +2898,15 @@ async function Bn(e) {
|
|
|
2900
2898
|
// prefix" and flows into the WASM HTLC connector derivation; a prefixed
|
|
2901
2899
|
// value would derive the wrong refund script leaf and yield an
|
|
2902
2900
|
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
2903
|
-
hashlock:
|
|
2901
|
+
hashlock: P(u.hashlock)
|
|
2904
2902
|
});
|
|
2905
2903
|
i == null || i.throwIfAborted();
|
|
2906
2904
|
const $ = ce(
|
|
2907
2905
|
u.depositorBtcPubkey,
|
|
2908
2906
|
Rs
|
|
2909
|
-
), x = await n(
|
|
2907
|
+
), x = await n(b, $);
|
|
2910
2908
|
ae({
|
|
2911
|
-
requestedPsbtHex:
|
|
2909
|
+
requestedPsbtHex: b,
|
|
2912
2910
|
returnedPsbtHex: x
|
|
2913
2911
|
});
|
|
2914
2912
|
const v = 0, E = ue(
|
|
@@ -2917,13 +2915,13 @@ async function Bn(e) {
|
|
|
2917
2915
|
v
|
|
2918
2916
|
);
|
|
2919
2917
|
oe({
|
|
2920
|
-
requestedPsbtHex:
|
|
2918
|
+
requestedPsbtHex: b,
|
|
2921
2919
|
signatureHex: E,
|
|
2922
2920
|
signerXOnlyPubkeyHex: d,
|
|
2923
2921
|
inputIndex: v
|
|
2924
2922
|
});
|
|
2925
2923
|
const T = Tt({
|
|
2926
|
-
requestedPsbtHex:
|
|
2924
|
+
requestedPsbtHex: b,
|
|
2927
2925
|
signaturesHex: [E],
|
|
2928
2926
|
signerXOnlyPubkeyHex: d
|
|
2929
2927
|
});
|
|
@@ -2934,6 +2932,42 @@ async function Bn(e) {
|
|
|
2934
2932
|
throw w instanceof Error && Ks.test(w.message) ? new Bs(t, w) : w;
|
|
2935
2933
|
}
|
|
2936
2934
|
}
|
|
2935
|
+
async function In(e) {
|
|
2936
|
+
const { vaultId: t, vault: r, readers: o, network: s } = e, [n, a] = await Promise.all([
|
|
2937
|
+
Dt({
|
|
2938
|
+
vaultId: t,
|
|
2939
|
+
vault: {
|
|
2940
|
+
basic: {
|
|
2941
|
+
vaultProvider: r.vaultProvider,
|
|
2942
|
+
applicationEntryPoint: r.applicationEntryPoint
|
|
2943
|
+
},
|
|
2944
|
+
protocol: {
|
|
2945
|
+
appVaultKeepersVersion: r.appVaultKeepersVersion,
|
|
2946
|
+
universalChallengersVersion: r.universalChallengersVersion
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2949
|
+
readers: o
|
|
2950
|
+
}),
|
|
2951
|
+
o.protocolParamsReader.getOffchainParamsByVersion(
|
|
2952
|
+
r.offchainParamsVersion
|
|
2953
|
+
)
|
|
2954
|
+
]);
|
|
2955
|
+
return {
|
|
2956
|
+
vaultProviderPubkey: n.vaultProvider.operationBtcPubkey,
|
|
2957
|
+
vaultKeeperPubkeys: n.vaultKeeperOperationKeysSorted,
|
|
2958
|
+
universalChallengerPubkeys: n.universalChallengerOperationKeysSorted,
|
|
2959
|
+
timelockRefund: a.tRefund,
|
|
2960
|
+
feeRate: a.feeRate,
|
|
2961
|
+
minPeginFeeRate: a.minPeginFeeRate,
|
|
2962
|
+
// The local challengers of the depositor's own claim graph, which this
|
|
2963
|
+
// value sizes, are the vault keepers alone: the same count
|
|
2964
|
+
// `PeginManager.preparePegin` sized the HTLC with.
|
|
2965
|
+
numLocalChallengers: n.vaultKeeperOperationKeysSorted.length,
|
|
2966
|
+
councilQuorum: a.councilQuorum,
|
|
2967
|
+
councilSize: a.securityCouncilKeys.length,
|
|
2968
|
+
network: s
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2937
2971
|
class ht extends Error {
|
|
2938
2972
|
constructor(r, o, s) {
|
|
2939
2973
|
super(r);
|
|
@@ -2944,13 +2978,13 @@ class ht extends Error {
|
|
|
2944
2978
|
this.name = "ReclaimUneconomicalError", this.feeSats = o, this.sweptTotalSats = s;
|
|
2945
2979
|
}
|
|
2946
2980
|
}
|
|
2947
|
-
const pt = 2e3, gt = 25n, ft = 100n,
|
|
2981
|
+
const pt = 2e3, gt = 25n, ft = 100n, Vn = 10n;
|
|
2948
2982
|
async function Ns(e, t, r) {
|
|
2949
2983
|
for (let o = 0; o < e.length; o++) {
|
|
2950
|
-
const s =
|
|
2984
|
+
const s = Zr(e[o].depositorSignedPeginTxHex), n = Ie(
|
|
2951
2985
|
await mr(
|
|
2952
|
-
|
|
2953
|
-
|
|
2986
|
+
P(s),
|
|
2987
|
+
P(r)
|
|
2954
2988
|
)
|
|
2955
2989
|
).toLowerCase();
|
|
2956
2990
|
if (n !== t[o].toLowerCase())
|
|
@@ -2959,7 +2993,7 @@ async function Ns(e, t, r) {
|
|
|
2959
2993
|
);
|
|
2960
2994
|
}
|
|
2961
2995
|
}
|
|
2962
|
-
async function
|
|
2996
|
+
async function Rn(e) {
|
|
2963
2997
|
const {
|
|
2964
2998
|
vaultIds: t,
|
|
2965
2999
|
depositorEthAddress: r,
|
|
@@ -2990,7 +3024,7 @@ async function Vn(e) {
|
|
|
2990
3024
|
depositorSignedPeginTxHex: v.depositorSignedPeginTxHex,
|
|
2991
3025
|
observed: v.observed,
|
|
2992
3026
|
expectedValue: v.expectedClaimValue
|
|
2993
|
-
})), d =
|
|
3027
|
+
})), d = Yr(n, h.length), g = h.reduce((v, E) => v + E.expectedValue, 0n), p = g * gt / ft;
|
|
2994
3028
|
if (d > p)
|
|
2995
3029
|
throw new ht(
|
|
2996
3030
|
`Reclaim fee ${d} sats exceeds ${gt}/${ft} of the swept total (${g} sats, cap ${p} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
|
|
@@ -2998,7 +3032,7 @@ async function Vn(e) {
|
|
|
2998
3032
|
g
|
|
2999
3033
|
);
|
|
3000
3034
|
u == null || u.throwIfAborted();
|
|
3001
|
-
const { psbtHex: y } =
|
|
3035
|
+
const { psbtHex: y } = Qr({
|
|
3002
3036
|
depositorPubkey: c,
|
|
3003
3037
|
inputs: h,
|
|
3004
3038
|
feeSats: d
|
|
@@ -3007,14 +3041,14 @@ async function Vn(e) {
|
|
|
3007
3041
|
const f = ce(
|
|
3008
3042
|
o,
|
|
3009
3043
|
h.length
|
|
3010
|
-
),
|
|
3044
|
+
), b = await a(y, f);
|
|
3011
3045
|
ae({
|
|
3012
3046
|
requestedPsbtHex: y,
|
|
3013
|
-
returnedPsbtHex:
|
|
3047
|
+
returnedPsbtHex: b
|
|
3014
3048
|
});
|
|
3015
3049
|
const $ = h.map((v, E) => {
|
|
3016
3050
|
const T = ue(
|
|
3017
|
-
|
|
3051
|
+
b,
|
|
3018
3052
|
c,
|
|
3019
3053
|
E
|
|
3020
3054
|
);
|
|
@@ -3035,39 +3069,39 @@ export {
|
|
|
3035
3069
|
Sn as $,
|
|
3036
3070
|
K as A,
|
|
3037
3071
|
fn as B,
|
|
3038
|
-
|
|
3072
|
+
co as C,
|
|
3039
3073
|
U as D,
|
|
3040
3074
|
is as E,
|
|
3041
3075
|
yn as F,
|
|
3042
|
-
|
|
3076
|
+
m as G,
|
|
3043
3077
|
gs as H,
|
|
3044
3078
|
vn as I,
|
|
3045
3079
|
Se as J,
|
|
3046
|
-
|
|
3047
|
-
|
|
3080
|
+
bn as K,
|
|
3081
|
+
mn as L,
|
|
3048
3082
|
wn as M,
|
|
3049
3083
|
xn as N,
|
|
3050
3084
|
$n as O,
|
|
3051
|
-
|
|
3085
|
+
ho as P,
|
|
3052
3086
|
kn as Q,
|
|
3053
3087
|
En as R,
|
|
3054
3088
|
Y as S,
|
|
3055
3089
|
Cs as T,
|
|
3056
3090
|
Ts as U,
|
|
3057
|
-
|
|
3058
|
-
|
|
3091
|
+
yo as V,
|
|
3092
|
+
Wt as W,
|
|
3059
3093
|
Cn as X,
|
|
3060
3094
|
Tn as Y,
|
|
3061
|
-
|
|
3095
|
+
Yt as Z,
|
|
3062
3096
|
_n as _,
|
|
3063
3097
|
nn as a,
|
|
3064
|
-
|
|
3065
|
-
|
|
3098
|
+
zt as a0,
|
|
3099
|
+
Pn as a1,
|
|
3066
3100
|
$e as a2,
|
|
3067
3101
|
ks as a3,
|
|
3068
3102
|
nt as a4,
|
|
3069
|
-
|
|
3070
|
-
|
|
3103
|
+
Dt as a5,
|
|
3104
|
+
qo as a6,
|
|
3071
3105
|
Nt as a7,
|
|
3072
3106
|
Bs as a8,
|
|
3073
3107
|
Bn as a9,
|
|
@@ -3076,36 +3110,37 @@ export {
|
|
|
3076
3110
|
lt as ac,
|
|
3077
3111
|
ct as ad,
|
|
3078
3112
|
Jt as ae,
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3113
|
+
In as af,
|
|
3114
|
+
ht as ag,
|
|
3115
|
+
Rn as ah,
|
|
3116
|
+
ft as ai,
|
|
3117
|
+
gt as aj,
|
|
3118
|
+
pt as ak,
|
|
3119
|
+
Vn as al,
|
|
3085
3120
|
an as b,
|
|
3086
3121
|
un as c,
|
|
3087
3122
|
ln as d,
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3123
|
+
Ao as e,
|
|
3124
|
+
ao as f,
|
|
3125
|
+
lo as g,
|
|
3091
3126
|
dn as h,
|
|
3092
|
-
|
|
3127
|
+
po as i,
|
|
3093
3128
|
ne as j,
|
|
3094
|
-
|
|
3129
|
+
fo as k,
|
|
3095
3130
|
bo as l,
|
|
3096
3131
|
cn as m,
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3132
|
+
Io as n,
|
|
3133
|
+
No as o,
|
|
3134
|
+
To as p,
|
|
3135
|
+
Ro as q,
|
|
3101
3136
|
hn as r,
|
|
3102
|
-
|
|
3137
|
+
xo as s,
|
|
3103
3138
|
St as t,
|
|
3104
3139
|
Go as u,
|
|
3105
|
-
|
|
3106
|
-
|
|
3140
|
+
Lt as v,
|
|
3141
|
+
Mt as w,
|
|
3107
3142
|
Wo as x,
|
|
3108
3143
|
pn as y,
|
|
3109
3144
|
gn as z
|
|
3110
3145
|
};
|
|
3111
|
-
//# sourceMappingURL=buildAndBroadcastReclaim-
|
|
3146
|
+
//# sourceMappingURL=buildAndBroadcastReclaim-ByXYSUwj.js.map
|