@babylonlabs-io/ts-sdk 3.3.0 → 4.0.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-CMbRRTnr.cjs +2 -0
- package/dist/{PeginManager-Co43rW_x.cjs.map → PeginManager-CMbRRTnr.cjs.map} +1 -1
- package/dist/{PeginManager-BJnUgW8C.js → PeginManager-Cas6_j7t.js} +118 -107
- package/dist/{PeginManager-BJnUgW8C.js.map → PeginManager-Cas6_j7t.js.map} +1 -1
- 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-CVmG3ldA.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-CVmG3ldA.cjs.map +1 -0
- package/dist/{buildAndBroadcastReclaim-CQANDXVJ.js → buildAndBroadcastReclaim-XRWuJWVL.js} +48 -50
- package/dist/buildAndBroadcastReclaim-XRWuJWVL.js.map +1 -0
- package/dist/{challengeAssert-C3eMcM5Y.cjs → challengeAssert-BE6Wm4x1.cjs} +2 -2
- package/dist/challengeAssert-BE6Wm4x1.cjs.map +1 -0
- package/dist/{challengeAssert-B2otuf7y.js → challengeAssert-DUKSjirl.js} +3 -3
- package/dist/challengeAssert-DUKSjirl.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 +16 -16
- 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/shared/index.cjs.map +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +5 -0
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -1
- package/dist/{signer-set-reader-GrFe_rsW.cjs → signer-set-reader-CJfV-GDz.cjs} +2 -2
- package/dist/{signer-set-reader-GrFe_rsW.cjs.map → signer-set-reader-CJfV-GDz.cjs.map} +1 -1
- package/dist/{signer-set-reader-CSUe92zE.js → signer-set-reader-DiwLeqik.js} +3 -3
- package/dist/{signer-set-reader-CSUe92zE.js.map → signer-set-reader-DiwLeqik.js.map} +1 -1
- 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/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/types.d.ts +12 -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.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 +5 -5
- 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 +16 -16
- package/dist/tbv/core/managers/PeginManager.d.ts +2 -1
- 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/index.cjs +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 +3 -5
- package/dist/tbv/core/primitives/psbt/pegin.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/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 +5 -6
- 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/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +2 -2
- package/dist/tbv/core/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 +16 -16
- package/dist/toRefundInputs-BSQjDOK9.cjs +2 -0
- package/dist/toRefundInputs-BSQjDOK9.cjs.map +1 -0
- package/dist/{toRefundInputs-Dzw1cteD.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-Co43rW_x.cjs +0 -2
- 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.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/toRefundInputs-DTuWi--u.cjs +0 -2
- package/dist/toRefundInputs-DTuWi--u.cjs.map +0 -1
- package/dist/toRefundInputs-Dzw1cteD.js.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,8 +1,8 @@
|
|
|
1
1
|
var se = Object.defineProperty;
|
|
2
2
|
var ie = (e, t, o) => t in e ? se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
3
|
var z = (e, t, o) => ie(e, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
-
import { r as S } from "./registration-records-
|
|
5
|
-
import { s as
|
|
4
|
+
import { r as S } from "./registration-records-D39ApuHS.js";
|
|
5
|
+
import { s as f, c as ae, h as ce, p as q, u as ue, e as le } from "./bitcoin-C-TuHb-v.js";
|
|
6
6
|
import { c as H } from "./btcTxHash-BRZ8_EZq.js";
|
|
7
7
|
import { Transaction as M } from "bitcoinjs-lib";
|
|
8
8
|
import { Buffer as he } from "buffer";
|
|
@@ -10,12 +10,12 @@ import { getUtxoInfo as de } from "./tbv/core/clients/mempool/index.js";
|
|
|
10
10
|
import { M as D } from "./validation-OSC0xTHB.js";
|
|
11
11
|
import { keccak256 as J, toHex as me, encodeAbiParameters as pe, isAddress as ge, zeroAddress as fe } from "viem";
|
|
12
12
|
import { s as Pe } from "./sha2-YqVHJiFj.js";
|
|
13
|
-
import { d as _ } from "./PayoutManager-
|
|
14
|
-
import { b as ve, a as be } from "./PeginManager-
|
|
13
|
+
import { d as _ } from "./PayoutManager-BUWP-H-q.js";
|
|
14
|
+
import { b as ve, a as be } from "./PeginManager-Cas6_j7t.js";
|
|
15
15
|
import { computeMinClaimValue as Y, computeMinPeginFee as Z, peginP2aAnchorOutput as ee, getPrePeginHtlcConnectorInfo as we, expandAuthAnchor as ye } from "./tbv/core/wasm/index.js";
|
|
16
16
|
import { d as Ce } from "./deriveVaultRoot-BcvmER1E.js";
|
|
17
17
|
import { p as xe } from "./parseFundingOutpoints-GSM-IaaK.js";
|
|
18
|
-
import { o as Ee, H as U } from "./verifyScriptPathSchnorrSignature-
|
|
18
|
+
import { o as Ee, H as U } from "./verifyScriptPathSchnorrSignature-D-fdi-sG.js";
|
|
19
19
|
import { c as j } from "./fundPeginTransaction-CwhRbCQC.js";
|
|
20
20
|
const Re = [
|
|
21
21
|
"vaultCoreVersion",
|
|
@@ -79,18 +79,18 @@ function dt(e) {
|
|
|
79
79
|
return t.name === te && t.reason === "device-envelope";
|
|
80
80
|
}
|
|
81
81
|
async function Be(e, t) {
|
|
82
|
-
const o = M.fromHex(
|
|
82
|
+
const o = M.fromHex(f(e)), n = (await Promise.all(
|
|
83
83
|
o.ins.map(
|
|
84
|
-
(
|
|
84
|
+
(a) => (
|
|
85
85
|
// Bitcoin stores the prev-txid in reverse (internal) byte order.
|
|
86
86
|
de(
|
|
87
|
-
he.from(
|
|
88
|
-
|
|
87
|
+
he.from(a.hash).reverse().toString("hex"),
|
|
88
|
+
a.index,
|
|
89
89
|
t
|
|
90
90
|
)
|
|
91
91
|
)
|
|
92
92
|
)
|
|
93
|
-
)).reduce((
|
|
93
|
+
)).reduce((a, i) => a + BigInt(i.value), 0n), c = o.outs.reduce((a, i) => a + BigInt(i.value), 0n), s = n - c;
|
|
94
94
|
if (s <= 0n)
|
|
95
95
|
throw new Error(
|
|
96
96
|
`The funded Pre-PegIn transaction's inputs do not cover its outputs plus a fee (computed fee: ${s} sats).`
|
|
@@ -107,16 +107,16 @@ async function oe(e) {
|
|
|
107
107
|
throw new Error(
|
|
108
108
|
"rebuildDepositTermsCore: at least one sibling is required"
|
|
109
109
|
);
|
|
110
|
-
for (const [
|
|
111
|
-
if (
|
|
110
|
+
for (const [m, d] of e.siblings.entries())
|
|
111
|
+
if (d.amount <= 0n)
|
|
112
112
|
throw new Error(
|
|
113
|
-
`rebuildDepositTermsCore: sibling[${
|
|
113
|
+
`rebuildDepositTermsCore: sibling[${m}] has non-positive on-chain pegin amount ${d.amount}; the chain-read vault record is invalid. Resume refused.`
|
|
114
114
|
);
|
|
115
115
|
if (e.prepeginMaxFee <= 0n)
|
|
116
116
|
throw new Error(
|
|
117
117
|
`rebuildDepositTermsCore: prepeginMaxFee must be > 0, got ${e.prepeginMaxFee}`
|
|
118
118
|
);
|
|
119
|
-
const o =
|
|
119
|
+
const o = f(e.prepeginTxid).toLowerCase(), r = f(
|
|
120
120
|
H(e.fundedPrePeginTxHex)
|
|
121
121
|
).toLowerCase();
|
|
122
122
|
if (r !== o)
|
|
@@ -124,7 +124,7 @@ async function oe(e) {
|
|
|
124
124
|
`Funded Pre-PegIn tx hashes to ${r}, expected ${o} (on-chain prepeginTxid). Resume refused.`
|
|
125
125
|
);
|
|
126
126
|
const n = _(
|
|
127
|
-
|
|
127
|
+
f(e.fundedPrePeginTxHex)
|
|
128
128
|
);
|
|
129
129
|
if (n === void 0)
|
|
130
130
|
throw new Error(
|
|
@@ -134,56 +134,58 @@ async function oe(e) {
|
|
|
134
134
|
throw new Error(
|
|
135
135
|
`Auth-anchor OP_RETURN at vout ${n.vout} does not match the discovered sibling count ${t}; the discovered sibling set does not cover this transaction's HTLC outputs (a lagging index can cause this — retry later). Resume refused.`
|
|
136
136
|
);
|
|
137
|
-
const
|
|
137
|
+
const c = e.vaultKeeperBtcPubkeys.length, s = e.universalChallengerBtcPubkeys.length, a = await Y(
|
|
138
138
|
e.vaultCoreVersion,
|
|
139
|
-
|
|
139
|
+
c,
|
|
140
140
|
s,
|
|
141
141
|
e.councilQuorum,
|
|
142
142
|
e.councilSize,
|
|
143
143
|
e.protocolFeeRate
|
|
144
|
-
),
|
|
144
|
+
), i = await Z(
|
|
145
145
|
e.vaultCoreVersion,
|
|
146
|
-
|
|
146
|
+
c,
|
|
147
147
|
s,
|
|
148
148
|
e.minPeginFeeRate
|
|
149
|
-
),
|
|
150
|
-
|
|
149
|
+
), { value: l } = await ee(
|
|
150
|
+
e.vaultCoreVersion
|
|
151
|
+
);
|
|
152
|
+
if (a <= 0n)
|
|
151
153
|
throw new Error(
|
|
152
|
-
`WASM returned non-positive depositorClaimValue ${
|
|
154
|
+
`WASM returned non-positive depositorClaimValue ${a}; expected > 0. Resume refused.`
|
|
153
155
|
);
|
|
154
|
-
if (
|
|
156
|
+
if (i <= 0n)
|
|
155
157
|
throw new Error(
|
|
156
|
-
`WASM returned non-positive peginMaxFee ${
|
|
158
|
+
`WASM returned non-positive peginMaxFee ${i}; expected > 0. Resume refused.`
|
|
157
159
|
);
|
|
158
|
-
if (
|
|
160
|
+
if (l < 0n)
|
|
159
161
|
throw new Error(
|
|
160
|
-
`WASM returned negative P2A anchor value ${
|
|
162
|
+
`WASM returned negative P2A anchor value ${l}. Resume refused.`
|
|
161
163
|
);
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
+
const u = i + l, h = e.minPeginFeeRate * j;
|
|
165
|
+
if (u <= 0n || u > h)
|
|
164
166
|
throw new Error(
|
|
165
|
-
`WASM implied PegIn reserve ${
|
|
167
|
+
`WASM implied PegIn reserve ${u} sat is outside (0, ${h}] (minPeginFeeRate=${e.minPeginFeeRate} × ${j} vbytes). Resume refused.`
|
|
166
168
|
);
|
|
167
|
-
const
|
|
168
|
-
(
|
|
169
|
-
),
|
|
170
|
-
e.siblings.map(async (
|
|
169
|
+
const w = e.siblings.map(
|
|
170
|
+
(m) => m.amount + a + i + l
|
|
171
|
+
), y = await Promise.all(
|
|
172
|
+
e.siblings.map(async (m) => (await we({
|
|
171
173
|
txGraphVersion: e.vaultCoreVersion,
|
|
172
174
|
depositorPubkey: e.depositorBtcPubkey,
|
|
173
175
|
vaultProviderPubkey: e.vaultProviderBtcPubkey,
|
|
174
176
|
vaultKeeperPubkeys: [...e.vaultKeeperBtcPubkeys],
|
|
175
177
|
universalChallengerPubkeys: [...e.universalChallengerBtcPubkeys],
|
|
176
|
-
hashlock:
|
|
178
|
+
hashlock: f(m.hashlock),
|
|
177
179
|
timelockRefund: e.timelockRefund,
|
|
178
180
|
network: e.network
|
|
179
181
|
})).scriptPubKey)
|
|
180
182
|
), C = M.fromHex(
|
|
181
|
-
|
|
182
|
-
).outs.map((
|
|
183
|
+
f(e.fundedPrePeginTxHex)
|
|
184
|
+
).outs.map((m) => ({ value: m.value, script: m.script }));
|
|
183
185
|
return Ee(
|
|
184
186
|
C,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
w,
|
|
188
|
+
y
|
|
187
189
|
), ve({
|
|
188
190
|
vaultCoreVersion: e.vaultCoreVersion,
|
|
189
191
|
protocolFeeRate: e.protocolFeeRate,
|
|
@@ -196,9 +198,9 @@ async function oe(e) {
|
|
|
196
198
|
vaultKeeperBtcPubkeys: e.vaultKeeperBtcPubkeys,
|
|
197
199
|
universalChallengerBtcPubkeys: e.universalChallengerBtcPubkeys,
|
|
198
200
|
maxAcceptableCommissionBps: e.maxAcceptableCommissionBps,
|
|
199
|
-
peginAmounts: e.siblings.map((
|
|
200
|
-
depositorClaimValue:
|
|
201
|
-
peginMaxFee:
|
|
201
|
+
peginAmounts: e.siblings.map((m) => m.amount),
|
|
202
|
+
depositorClaimValue: a,
|
|
203
|
+
peginMaxFee: i
|
|
202
204
|
});
|
|
203
205
|
}
|
|
204
206
|
async function mt(e) {
|
|
@@ -207,40 +209,40 @@ async function mt(e) {
|
|
|
207
209
|
throw new Error(
|
|
208
210
|
"Connected wallet key is not the vault's depositor key; select the account that made the deposit."
|
|
209
211
|
);
|
|
210
|
-
const r =
|
|
212
|
+
const r = f(t.prePeginTxHash).toLowerCase(), n = f(
|
|
211
213
|
H(e.fundedPrePeginTxHex)
|
|
212
214
|
).toLowerCase();
|
|
213
215
|
if (n !== r)
|
|
214
216
|
throw new Error(
|
|
215
217
|
`Funded Pre-PegIn tx hashes to ${n}, expected ${r} (on-chain prePeginTxHash).`
|
|
216
218
|
);
|
|
217
|
-
const
|
|
219
|
+
const c = await Promise.all(
|
|
218
220
|
Ve(
|
|
219
221
|
t.registrationRecords,
|
|
220
222
|
t.registrationRecord
|
|
221
|
-
).map(async (
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
223
|
+
).map(async (l) => {
|
|
224
|
+
const u = await e.siblingReader.getVaultData(l.vaultId);
|
|
225
|
+
if (u.protocol.prePeginTxHash.toLowerCase() !== S(l).toLowerCase())
|
|
224
226
|
throw new Error(
|
|
225
|
-
`Sibling ${
|
|
227
|
+
`Sibling ${l.vaultId} is registered against a different Pre-PegIn on chain than its registration log records; refusing an inconsistent node.`
|
|
226
228
|
);
|
|
227
229
|
return {
|
|
228
|
-
vault:
|
|
229
|
-
maxAcceptableCommissionBps:
|
|
230
|
+
vault: u,
|
|
231
|
+
maxAcceptableCommissionBps: l.maxAcceptableCommissionBps
|
|
230
232
|
};
|
|
231
233
|
})
|
|
232
234
|
), s = {
|
|
233
235
|
vault: t.vault,
|
|
234
236
|
maxAcceptableCommissionBps: t.registrationRecord.maxAcceptableCommissionBps
|
|
235
237
|
};
|
|
236
|
-
$e(s,
|
|
237
|
-
const
|
|
238
|
+
$e(s, c);
|
|
239
|
+
const a = Ae([s, ...c]), i = await Be(
|
|
238
240
|
e.fundedPrePeginTxHex,
|
|
239
241
|
e.mempoolApiUrl
|
|
240
242
|
);
|
|
241
243
|
return oe({
|
|
242
244
|
vaultCoreVersion: t.vault.protocol.vaultCoreVersion,
|
|
243
|
-
siblings:
|
|
245
|
+
siblings: a,
|
|
244
246
|
fundedPrePeginTxHex: e.fundedPrePeginTxHex,
|
|
245
247
|
depositorBtcPubkey: o,
|
|
246
248
|
vaultProviderBtcPubkey: t.participantKeys.vaultProvider.operationBtcPubkey,
|
|
@@ -254,7 +256,7 @@ async function mt(e) {
|
|
|
254
256
|
timelockAssert: t.context.timelockAssert,
|
|
255
257
|
timelockRefund: t.offchainParams.tRefund,
|
|
256
258
|
prepeginTxid: r,
|
|
257
|
-
prepeginMaxFee:
|
|
259
|
+
prepeginMaxFee: i,
|
|
258
260
|
// The submitted ceiling, verbatim: the device must see the terms the
|
|
259
261
|
// depositor originally approved.
|
|
260
262
|
maxAcceptableCommissionBps: t.registrationRecord.maxAcceptableCommissionBps,
|
|
@@ -268,45 +270,45 @@ function pt(e) {
|
|
|
268
270
|
const Ie = "TBV.PeginFingerprint.v1", Fe = J(
|
|
269
271
|
me(Ie)
|
|
270
272
|
), G = 65535, Q = 2n ** 64n - 1n, Se = 2n ** 256n - 1n, Ke = /^0x[0-9a-fA-F]{64}$/, W = 1;
|
|
271
|
-
class
|
|
273
|
+
class v extends Error {
|
|
272
274
|
constructor(t) {
|
|
273
275
|
super(t), this.name = "PeginFingerprintInputError";
|
|
274
276
|
}
|
|
275
277
|
}
|
|
276
278
|
function gt(e) {
|
|
277
|
-
return e instanceof
|
|
279
|
+
return e instanceof v || e instanceof Error && e.name === "PeginFingerprintInputError";
|
|
278
280
|
}
|
|
279
281
|
function I(e, t, o, r) {
|
|
280
282
|
if (typeof t != "bigint")
|
|
281
|
-
throw new
|
|
283
|
+
throw new v(
|
|
282
284
|
`${e} must be a bigint (Solidity ${r}), got ${typeof t}`
|
|
283
285
|
);
|
|
284
286
|
if (t < 0n || t > o)
|
|
285
|
-
throw new
|
|
287
|
+
throw new v(
|
|
286
288
|
`${e} must fit Solidity ${r} (0..${o}), got ${t}`
|
|
287
289
|
);
|
|
288
290
|
}
|
|
289
|
-
function
|
|
291
|
+
function V(e, t) {
|
|
290
292
|
if (!Number.isInteger(t) || t < 0 || t > G)
|
|
291
|
-
throw new
|
|
293
|
+
throw new v(
|
|
292
294
|
`${e} must be an integer fitting Solidity uint16 (0..${G}), got ${t}`
|
|
293
295
|
);
|
|
294
296
|
}
|
|
295
297
|
function He(e, t) {
|
|
296
298
|
if (!Ke.test(t))
|
|
297
|
-
throw new
|
|
299
|
+
throw new v(
|
|
298
300
|
`${e} must be 32 bytes as 0x-prefixed hex (66 characters), got "${t}"`
|
|
299
301
|
);
|
|
300
302
|
return t.toLowerCase();
|
|
301
303
|
}
|
|
302
304
|
function Me(e) {
|
|
303
305
|
if (!ge(e, { strict: !1 }))
|
|
304
|
-
throw new
|
|
306
|
+
throw new v(
|
|
305
307
|
`registryAddress must be a 20-byte 0x-prefixed address, got "${e}"`
|
|
306
308
|
);
|
|
307
309
|
const t = e.toLowerCase();
|
|
308
310
|
if (t === fe)
|
|
309
|
-
throw new
|
|
311
|
+
throw new v(
|
|
310
312
|
"registryAddress must not be the zero address; a zero here means the registry address was never resolved"
|
|
311
313
|
);
|
|
312
314
|
return t;
|
|
@@ -325,7 +327,7 @@ const _e = [
|
|
|
325
327
|
];
|
|
326
328
|
function Ne(e) {
|
|
327
329
|
if (I("chainId", e.chainId, Se, "uint256"), e.chainId === 0n)
|
|
328
|
-
throw new
|
|
330
|
+
throw new v(
|
|
329
331
|
"chainId must not be 0; a zero here means the chain id was never resolved"
|
|
330
332
|
);
|
|
331
333
|
const t = Me(e.registryAddress), o = He(
|
|
@@ -337,11 +339,11 @@ function Ne(e) {
|
|
|
337
339
|
e.appKeeperKeyEpoch,
|
|
338
340
|
Q,
|
|
339
341
|
"uint64"
|
|
340
|
-
), I("ucKeyEpoch", e.ucKeyEpoch, Q, "uint64"),
|
|
342
|
+
), I("ucKeyEpoch", e.ucKeyEpoch, Q, "uint64"), V("appVaultKeepersVersion", e.appVaultKeepersVersion), V(
|
|
341
343
|
"universalChallengersVersion",
|
|
342
344
|
e.universalChallengersVersion
|
|
343
|
-
),
|
|
344
|
-
throw new
|
|
345
|
+
), V("offchainParamsVersion", e.offchainParamsVersion), V("vaultCoreVersion", e.vaultCoreVersion), e.vaultCoreVersion < W)
|
|
346
|
+
throw new v(
|
|
345
347
|
`vaultCoreVersion must be at least ${W}; ${e.vaultCoreVersion} means the version was never resolved`
|
|
346
348
|
);
|
|
347
349
|
return pe(_e, [
|
|
@@ -393,46 +395,46 @@ class De extends Error {
|
|
|
393
395
|
), this.matchedLabel = t, this.unresolvedLabels = o, this.name = "PeginParamsIncompleteSpaceError";
|
|
394
396
|
}
|
|
395
397
|
}
|
|
396
|
-
class
|
|
398
|
+
class $ extends Error {
|
|
397
399
|
constructor(t) {
|
|
398
400
|
super(`${t}. Reconstruction refused.`), this.name = "PeginSizingIntegrityError";
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
403
|
async function Pt(e) {
|
|
402
|
-
const { wallet: t, depositorBtcPubkey: o, fundedPrePeginTxHex: r } = e, n =
|
|
403
|
-
if (
|
|
404
|
+
const { wallet: t, depositorBtcPubkey: o, fundedPrePeginTxHex: r } = e, n = f(r), c = _(n);
|
|
405
|
+
if (c === void 0)
|
|
404
406
|
throw new K(
|
|
405
407
|
"Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN, so the number of HTLC outputs it funds cannot be determined. Legacy pre-anchor deposits are not recoverable by this path."
|
|
406
408
|
);
|
|
407
|
-
const s =
|
|
409
|
+
const s = c.vout;
|
|
408
410
|
if (s === 0)
|
|
409
411
|
throw new K(
|
|
410
412
|
"Pre-PegIn's auth-anchor OP_RETURN is at vout 0, implying zero HTLC outputs; there is nothing to recover."
|
|
411
413
|
);
|
|
412
|
-
const
|
|
414
|
+
const a = xe(n), i = await Ce(t, {
|
|
413
415
|
// The vault context takes the 32-byte x-only key; a wallet's compressed
|
|
414
416
|
// key would otherwise fail a byte-length check deep in the encoder with
|
|
415
417
|
// nothing pointing back at the caller.
|
|
416
418
|
depositorBtcPubkey: ce(
|
|
417
419
|
q(o)
|
|
418
420
|
),
|
|
419
|
-
fundingOutpoints:
|
|
421
|
+
fundingOutpoints: a
|
|
420
422
|
});
|
|
421
423
|
try {
|
|
422
|
-
const
|
|
424
|
+
const u = await ye(i);
|
|
423
425
|
let h;
|
|
424
426
|
try {
|
|
425
|
-
h = ue(Pe(
|
|
427
|
+
h = ue(Pe(u));
|
|
426
428
|
} finally {
|
|
427
|
-
|
|
429
|
+
u.fill(0);
|
|
428
430
|
}
|
|
429
|
-
if (h !==
|
|
430
|
-
throw new Oe(h,
|
|
431
|
-
} catch (
|
|
432
|
-
throw
|
|
431
|
+
if (h !== c.hash)
|
|
432
|
+
throw new Oe(h, c.hash);
|
|
433
|
+
} catch (u) {
|
|
434
|
+
throw i.fill(0), u;
|
|
433
435
|
}
|
|
434
|
-
const { hashlocks:
|
|
435
|
-
return { vaultCount: s, hashlocks:
|
|
436
|
+
const { hashlocks: l } = await be(i, s);
|
|
437
|
+
return { vaultCount: s, hashlocks: l, authAnchorHash: c.hash };
|
|
436
438
|
}
|
|
437
439
|
function vt(e) {
|
|
438
440
|
const { vaultCoreVersion: t, offchainParams: o, participantKeySets: r } = e;
|
|
@@ -449,11 +451,11 @@ function vt(e) {
|
|
|
449
451
|
"buildPeginParamsCandidates: at least one participant key set is required"
|
|
450
452
|
);
|
|
451
453
|
const n = [];
|
|
452
|
-
for (const
|
|
454
|
+
for (const c of o)
|
|
453
455
|
for (const s of r)
|
|
454
456
|
n.push({
|
|
455
457
|
vaultCoreVersion: t,
|
|
456
|
-
offchainParams:
|
|
458
|
+
offchainParams: c,
|
|
457
459
|
participants: s
|
|
458
460
|
});
|
|
459
461
|
return n;
|
|
@@ -485,7 +487,7 @@ function Ge(e) {
|
|
|
485
487
|
].join("|");
|
|
486
488
|
}
|
|
487
489
|
async function Qe(e) {
|
|
488
|
-
const { offchainParams: t, participants: o } = e, r = o.vaultKeeperBtcPubkeys.length, n = o.universalChallengerBtcPubkeys.length, [
|
|
490
|
+
const { offchainParams: t, participants: o } = e, r = o.vaultKeeperBtcPubkeys.length, n = o.universalChallengerBtcPubkeys.length, [c, s, a] = await Promise.all([
|
|
489
491
|
Y(
|
|
490
492
|
e.vaultCoreVersion,
|
|
491
493
|
r,
|
|
@@ -501,20 +503,20 @@ async function Qe(e) {
|
|
|
501
503
|
t.minPeginFeeRate
|
|
502
504
|
),
|
|
503
505
|
ee(e.vaultCoreVersion)
|
|
504
|
-
]),
|
|
505
|
-
if (
|
|
506
|
-
throw new
|
|
507
|
-
`WASM returned non-positive depositorClaimValue ${
|
|
506
|
+
]), i = a.value;
|
|
507
|
+
if (c <= 0n)
|
|
508
|
+
throw new $(
|
|
509
|
+
`WASM returned non-positive depositorClaimValue ${c} for graph version ${e.vaultCoreVersion}`
|
|
508
510
|
);
|
|
509
511
|
if (s <= 0n)
|
|
510
|
-
throw new
|
|
512
|
+
throw new $(
|
|
511
513
|
`WASM returned non-positive peginMaxFee ${s} for graph version ${e.vaultCoreVersion}`
|
|
512
514
|
);
|
|
513
|
-
if (
|
|
514
|
-
throw new
|
|
515
|
-
`WASM returned negative P2A anchor value ${
|
|
515
|
+
if (i < 0n)
|
|
516
|
+
throw new $(
|
|
517
|
+
`WASM returned negative P2A anchor value ${i} for graph version ${e.vaultCoreVersion}`
|
|
516
518
|
);
|
|
517
|
-
return { depositorClaimValue:
|
|
519
|
+
return { depositorClaimValue: c, peginMaxFee: s, p2aAnchorValue: i };
|
|
518
520
|
}
|
|
519
521
|
async function bt(e) {
|
|
520
522
|
const {
|
|
@@ -522,18 +524,18 @@ async function bt(e) {
|
|
|
522
524
|
fundedPrePeginTxHex: o,
|
|
523
525
|
depositorBtcPubkey: r,
|
|
524
526
|
prepeginMaxFee: n,
|
|
525
|
-
maxAcceptableCommissionBps:
|
|
527
|
+
maxAcceptableCommissionBps: c,
|
|
526
528
|
network: s,
|
|
527
|
-
candidates:
|
|
528
|
-
unresolvedVersions:
|
|
529
|
+
candidates: a,
|
|
530
|
+
unresolvedVersions: i
|
|
529
531
|
} = e;
|
|
530
532
|
if (t.length === 0)
|
|
531
533
|
throw new Error(
|
|
532
534
|
"reconstructPeginParams: at least one hashlock is required"
|
|
533
535
|
);
|
|
534
|
-
if (
|
|
536
|
+
if (a.length === 0)
|
|
535
537
|
throw new Error("reconstructPeginParams: candidate space is empty");
|
|
536
|
-
const
|
|
538
|
+
const l = q(r), u = f(o), h = _(u);
|
|
537
539
|
if (h === void 0)
|
|
538
540
|
throw new K(
|
|
539
541
|
"Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN; the sibling set cannot be proven complete. Reconstruction refused."
|
|
@@ -542,77 +544,77 @@ async function bt(e) {
|
|
|
542
544
|
throw new Error(
|
|
543
545
|
`reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${h.vout}, so the transaction funds ${h.vout} HTLC output(s). Reconstruction refused.`
|
|
544
546
|
);
|
|
545
|
-
const
|
|
546
|
-
H(
|
|
547
|
-
).toLowerCase(),
|
|
547
|
+
const w = M.fromHex(u).outs, y = t.map((p, g) => BigInt(w[g].value)), C = f(
|
|
548
|
+
H(u)
|
|
549
|
+
).toLowerCase(), m = /* @__PURE__ */ new Map(), d = [], A = [], T = [];
|
|
548
550
|
let N = 0;
|
|
549
|
-
for (const
|
|
551
|
+
for (const p of a)
|
|
550
552
|
try {
|
|
551
|
-
const
|
|
552
|
-
let
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
553
|
+
const g = Ge(p);
|
|
554
|
+
let P = m.get(g);
|
|
555
|
+
P === void 0 && (P = await Qe(p), m.set(g, P));
|
|
556
|
+
const x = P.depositorClaimValue + P.peginMaxFee + P.p2aAnchorValue, E = y.map((R) => R - x), k = E.findIndex((R) => R <= 0n);
|
|
557
|
+
if (k !== -1)
|
|
556
558
|
throw new U(
|
|
557
|
-
`HTLC output[${
|
|
559
|
+
`HTLC output[${k}] value ${y[k]} is not above this candidate's reserve ${x}, so it implies a non-positive pegin amount ${E[k]}.`
|
|
558
560
|
);
|
|
559
|
-
const { offchainParams:
|
|
560
|
-
vaultCoreVersion:
|
|
561
|
-
siblings: t.map((
|
|
562
|
-
hashlock:
|
|
563
|
-
amount:
|
|
561
|
+
const { offchainParams: b, participants: B } = p, L = await oe({
|
|
562
|
+
vaultCoreVersion: p.vaultCoreVersion,
|
|
563
|
+
siblings: t.map((R, ne) => ({
|
|
564
|
+
hashlock: R,
|
|
565
|
+
amount: E[ne]
|
|
564
566
|
})),
|
|
565
|
-
fundedPrePeginTxHex:
|
|
566
|
-
depositorBtcPubkey:
|
|
567
|
+
fundedPrePeginTxHex: u,
|
|
568
|
+
depositorBtcPubkey: l,
|
|
567
569
|
vaultProviderBtcPubkey: B.vaultProviderBtcPubkey,
|
|
568
570
|
vaultKeeperBtcPubkeys: B.vaultKeeperBtcPubkeys,
|
|
569
571
|
universalChallengerBtcPubkeys: B.universalChallengerBtcPubkeys,
|
|
570
|
-
protocolFeeRate:
|
|
571
|
-
minPeginFeeRate:
|
|
572
|
-
councilQuorum:
|
|
573
|
-
councilSize:
|
|
574
|
-
timelockPegin:
|
|
575
|
-
timelockAssert:
|
|
576
|
-
timelockRefund:
|
|
577
|
-
prepeginTxid:
|
|
572
|
+
protocolFeeRate: b.protocolFeeRate,
|
|
573
|
+
minPeginFeeRate: b.minPeginFeeRate,
|
|
574
|
+
councilQuorum: b.councilQuorum,
|
|
575
|
+
councilSize: b.councilSize,
|
|
576
|
+
timelockPegin: b.timelockPegin,
|
|
577
|
+
timelockAssert: b.timelockAssert,
|
|
578
|
+
timelockRefund: b.timelockRefund,
|
|
579
|
+
prepeginTxid: C,
|
|
578
580
|
prepeginMaxFee: n,
|
|
579
|
-
maxAcceptableCommissionBps:
|
|
581
|
+
maxAcceptableCommissionBps: c,
|
|
580
582
|
network: s
|
|
581
583
|
});
|
|
582
|
-
|
|
583
|
-
candidate:
|
|
584
|
+
d.push({
|
|
585
|
+
candidate: p,
|
|
584
586
|
terms: L,
|
|
585
|
-
peginAmounts:
|
|
586
|
-
fingerprint: je(L,
|
|
587
|
+
peginAmounts: E,
|
|
588
|
+
fingerprint: je(L, E)
|
|
587
589
|
});
|
|
588
|
-
} catch (
|
|
589
|
-
if (
|
|
590
|
-
throw
|
|
591
|
-
const
|
|
592
|
-
|
|
590
|
+
} catch (g) {
|
|
591
|
+
if (g instanceof $)
|
|
592
|
+
throw g;
|
|
593
|
+
const P = F(p), x = g instanceof Error ? g.message : String(g);
|
|
594
|
+
g instanceof U ? A.length < X && A.push(`[${P}] ${x}`) : (N++, T.length < X && T.push(`${P} (${x})`));
|
|
593
595
|
}
|
|
594
|
-
const re =
|
|
595
|
-
...
|
|
596
|
+
const re = i.length + N, O = [
|
|
597
|
+
...i.map(Ue),
|
|
596
598
|
...T
|
|
597
599
|
];
|
|
598
|
-
if (
|
|
599
|
-
throw new Le(
|
|
600
|
-
if (new Set(
|
|
600
|
+
if (d.length === 0)
|
|
601
|
+
throw new Le(a.length, A, O);
|
|
602
|
+
if (new Set(d.map((p) => p.fingerprint)).size > 1)
|
|
601
603
|
throw new ze(
|
|
602
|
-
|
|
604
|
+
d.map((p) => F(p.candidate))
|
|
603
605
|
);
|
|
604
606
|
if (re > 0)
|
|
605
607
|
throw new De(
|
|
606
|
-
F(
|
|
608
|
+
F(d[0].candidate),
|
|
607
609
|
O
|
|
608
610
|
);
|
|
609
611
|
return {
|
|
610
|
-
candidate:
|
|
611
|
-
terms:
|
|
612
|
-
peginAmounts:
|
|
612
|
+
candidate: d[0].candidate,
|
|
613
|
+
terms: d[0].terms,
|
|
614
|
+
peginAmounts: d[0].peginAmounts,
|
|
613
615
|
authAnchorHash: h.hash,
|
|
614
|
-
candidatesTried:
|
|
615
|
-
matchedCandidates:
|
|
616
|
+
candidatesTried: a.length,
|
|
617
|
+
matchedCandidates: d.map((p) => p.candidate)
|
|
616
618
|
};
|
|
617
619
|
}
|
|
618
620
|
function wt(e, t) {
|
|
@@ -620,50 +622,50 @@ function wt(e, t) {
|
|
|
620
622
|
htlcVout: o,
|
|
621
623
|
depositorBtcPubkey: r,
|
|
622
624
|
applicationEntryPoint: n,
|
|
623
|
-
fundedPrePeginTxHex:
|
|
625
|
+
fundedPrePeginTxHex: c,
|
|
624
626
|
hashlocks: s,
|
|
625
|
-
network:
|
|
626
|
-
} = t, { candidate:
|
|
627
|
-
if (s.length !==
|
|
627
|
+
network: a
|
|
628
|
+
} = t, { candidate: i, peginAmounts: l } = e, { offchainParams: u, participants: h } = i;
|
|
629
|
+
if (s.length !== l.length)
|
|
628
630
|
throw new Error(
|
|
629
|
-
`toRefundInputs: ${s.length} hashlock(s) but ${
|
|
631
|
+
`toRefundInputs: ${s.length} hashlock(s) but ${l.length} reconstructed amount(s); the reconstruction and the hashlock vector describe different transactions.`
|
|
630
632
|
);
|
|
631
|
-
if (!Number.isInteger(o) || o < 0 || o >=
|
|
633
|
+
if (!Number.isInteger(o) || o < 0 || o >= l.length)
|
|
632
634
|
throw new Error(
|
|
633
|
-
`toRefundInputs: htlcVout ${o} is outside the reconstructed batch of ${
|
|
635
|
+
`toRefundInputs: htlcVout ${o} is outside the reconstructed batch of ${l.length} vault(s).`
|
|
634
636
|
);
|
|
635
|
-
const
|
|
636
|
-
hashlock: le(s[
|
|
637
|
-
amount:
|
|
638
|
-
htlcVout:
|
|
637
|
+
const w = l.map((m, d) => ({
|
|
638
|
+
hashlock: le(s[d]),
|
|
639
|
+
amount: m,
|
|
640
|
+
htlcVout: d
|
|
639
641
|
})), y = {
|
|
640
|
-
vaultCoreVersion:
|
|
641
|
-
hashlock:
|
|
642
|
+
vaultCoreVersion: i.vaultCoreVersion,
|
|
643
|
+
hashlock: w[o].hashlock,
|
|
642
644
|
htlcVout: o,
|
|
643
|
-
offchainParamsVersion:
|
|
645
|
+
offchainParamsVersion: u.version,
|
|
644
646
|
appVaultKeepersVersion: h.appVaultKeepersVersion,
|
|
645
647
|
universalChallengersVersion: h.universalChallengersVersion,
|
|
646
648
|
vaultProvider: h.vaultProvider,
|
|
647
649
|
applicationEntryPoint: n,
|
|
648
|
-
amount:
|
|
649
|
-
unsignedPrePeginTxHex:
|
|
650
|
+
amount: l[o],
|
|
651
|
+
unsignedPrePeginTxHex: c,
|
|
650
652
|
depositorBtcPubkey: r,
|
|
651
|
-
batch:
|
|
652
|
-
},
|
|
653
|
+
batch: w
|
|
654
|
+
}, C = {
|
|
653
655
|
vaultProviderPubkey: h.vaultProviderBtcPubkey,
|
|
654
656
|
vaultKeeperPubkeys: h.vaultKeeperBtcPubkeys,
|
|
655
657
|
universalChallengerPubkeys: h.universalChallengerBtcPubkeys,
|
|
656
|
-
timelockRefund:
|
|
657
|
-
feeRate:
|
|
658
|
-
minPeginFeeRate:
|
|
658
|
+
timelockRefund: u.timelockRefund,
|
|
659
|
+
feeRate: u.protocolFeeRate,
|
|
660
|
+
minPeginFeeRate: u.minPeginFeeRate,
|
|
659
661
|
// Depositor-as-claimer: the local-challenger count is the keeper count,
|
|
660
662
|
// the vault provider excluded — btc-vault graph.rs derive_challengers.
|
|
661
663
|
numLocalChallengers: h.vaultKeeperBtcPubkeys.length,
|
|
662
|
-
councilQuorum:
|
|
663
|
-
councilSize:
|
|
664
|
-
network:
|
|
664
|
+
councilQuorum: u.councilQuorum,
|
|
665
|
+
councilSize: u.councilSize,
|
|
666
|
+
network: a
|
|
665
667
|
};
|
|
666
|
-
return { vault: y, context:
|
|
668
|
+
return { vault: y, context: C };
|
|
667
669
|
}
|
|
668
670
|
export {
|
|
669
671
|
te as D,
|
|
@@ -671,7 +673,7 @@ export {
|
|
|
671
673
|
K as U,
|
|
672
674
|
Oe as V,
|
|
673
675
|
Ie as a,
|
|
674
|
-
|
|
676
|
+
v as b,
|
|
675
677
|
ft as c,
|
|
676
678
|
gt as d,
|
|
677
679
|
Ne as e,
|
|
@@ -692,7 +694,7 @@ export {
|
|
|
692
694
|
Le as t,
|
|
693
695
|
ze as u,
|
|
694
696
|
De as v,
|
|
695
|
-
|
|
697
|
+
$ as w,
|
|
696
698
|
wt as x
|
|
697
699
|
};
|
|
698
|
-
//# sourceMappingURL=toRefundInputs-
|
|
700
|
+
//# sourceMappingURL=toRefundInputs-BbbvPb2A.js.map
|