import { PrePeginResult } from '@babylonlabs-io/babylon-tbv-rust-wasm'; import { ParsedOutput } from '../../utils/transaction/fundPeginTransaction'; import { PrePeginParams } from './pegin'; /** * Assert the WASM Pre-PegIn sizing result is internally consistent and * matches what the caller requested. * * Two layers of checks. Pure-JS, binary-INDEPENDENT: the per-HTLC * `peginAmount` must echo the requested amount, array lengths must match, * every value must be positive, and the implied per-HTLC reserve * (`htlcValue - peginAmount - depositorClaimValue`) must be strictly * positive and under the plausibility cap * ({@link MAX_REASONABLE_PEGIN_VBYTES}). WASM-vs-WASM consistency: the * reserve must also EXACTLY equal `computeMinPeginFee(version, …) + * p2aAnchorValue(version)` (like the `computeMinClaimValue` check) — * exact, but both sides come from the same binary, which is why the * independent bounds above are kept alongside it. * * The resume rebuild (`deposit-terms/rebuildDepositTermsCore.ts`) mirrors these * bounds (positivity + reserve band) — keep the two in sync when editing. * * @param result - The result returned by `createPrePeginTransaction`. * @param params - The parameters that were passed to build it. * @returns The independently computed `minPeginFee` this function already * asserted against `result`'s implied reserve — callers that need the * value should reuse this instead of recomputing it. * @throws If any value is missing, non-positive, mismatched against the * request, or outside the protocol formula. */ export declare function assertWasmPeginSizing(result: PrePeginResult, params: PrePeginParams): Promise; /** * A funded Pre-PegIn's HTLC outputs disagree with the expected value or * scriptPubKey. * * Typed so a caller trialling several parameter sets can tell "the transaction * definitively does not match these parameters" — a genuine, informative * rejection — from "evaluating this parameter set failed", which says nothing * about the transaction and must not be counted as a rejection. Without the * distinction an incidental failure on the true parameter set silently removes * it from consideration and a look-alike wins. */ export declare class HtlcOutputMismatchError extends Error { constructor(message: string); } /** * Bind the validated metadata to the bytes that actually get funded and * signed. * * `assertWasmPeginSizing` proves the WASM *metadata* (`htlcValues`, * `htlcScriptPubKeys`) matches the request and the protocol formula — but the * transaction the depositor funds and signs is `result.txHex`. If the encoded * tx carried a different HTLC output value or script than the metadata, the * depositor would fund a transaction whose real outputs differ from the values * that were cross-checked. This closes that final link: the encoded HTLC * outputs must equal the validated metadata. * * The WASM lays out HTLC outputs first (vouts `0..N-1`), then the optional * auth-anchor OP_RETURN, then the CPFP anchor — so we only compare the first * `htlcValues.length` outputs. * * @param outputs - Outputs parsed from the unfunded Pre-PegIn tx hex. * @param htlcValues - The (already value-validated) per-HTLC values. * @param htlcScriptPubKeys - The per-HTLC scriptPubKeys (hex). * @throws {HtlcOutputMismatchError} If the encoded outputs are too few, or any * HTLC output's value or scriptPubKey disagrees with the validated metadata. */ export declare function assertEncodedHtlcOutputsMatch(outputs: readonly ParsedOutput[], htlcValues: readonly bigint[], htlcScriptPubKeys: readonly string[]): void; //# sourceMappingURL=assertWasmPeginSizing.d.ts.map