import { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm'; import { DepositTerms } from '../deposit-terms/depositTerms'; import { PeginParamsCandidate, UnresolvedVersion } from './peginParamsCandidates'; export interface ReconstructPeginParamsInput { /** Hashlocks indexed by `htlcVout`, from `deriveHashlocksFromPrePegin`. */ hashlocks: readonly string[]; /** Funded (broadcast) Pre-PegIn transaction hex, `0x` optional. */ fundedPrePeginTxHex: string; /** Depositor x-only BTC pubkey hex, from the connected wallet. */ depositorBtcPubkey: string; /** * Funded-transaction fee, `Σin − Σout`. Not derivable from the transaction * alone — the input values live in the funding UTXOs — but those are * Bitcoin-keyed reads, which a reorg on Ethereum leaves intact. */ prepeginMaxFee: bigint; /** * Commission ceiling projected into the returned {@link DepositTerms}. Not a * search axis: it never reaches the HTLC scriptPubKey or value, so the * transaction carries no evidence of it and the caller must supply the bound * it is willing to accept. */ maxAcceptableCommissionBps: number; network: Network; /** The space to search, from `buildPeginParamsCandidates`. */ candidates: readonly PeginParamsCandidate[]; /** * Versions the caller enumerated over but could not resolve. Required, and * `[]` is the explicit claim that the enumeration was complete — so a caller * cannot arrive at a trusted answer by forgetting to mention its gaps. * * A non-empty list turns a sole match into a * {@link PeginParamsIncompleteSpaceError}: uniqueness only rules out a wrong * answer when the right answer was in the space to begin with. */ unresolvedVersions: readonly UnresolvedVersion[]; } export interface ReconstructPeginParamsResult { /** The single candidate whose rebuild matched the funded transaction. */ candidate: PeginParamsCandidate; /** * Terms projected from the matched candidate. * * The transaction pins the participant keys, `timelockRefund`, and each * HTLC's scriptPubKey and total value. It does NOT pin how that value splits * into `peginAmount`, `depositorClaimValue` and `peginMaxFee` — that split * follows from the matched candidate's fee-side parameters, which the * transaction carries no evidence of. */ terms: DepositTerms; /** * Per-vault `peginAmount`, inverted from the observed HTLC output values. * Only as sound as the matched candidate's reserve — see {@link terms}. */ peginAmounts: readonly bigint[]; /** The transaction's `SHA256(authAnchor)` commitment, for the refund rebuild. */ authAnchorHash: string; /** Size of the space actually trialled, for the recovery record. */ candidatesTried: number; /** * Every candidate that matched and projected identical terms. * * More than one is normal rather than suspicious: candidates differing only * in fields the transaction cannot express — version labels whose * script- and value-relevant content is the same — are indistinguishable by * construction and describe the same deposit. They are reported rather than * refused; refusal is reserved for survivors whose terms actually differ. */ matchedCandidates: readonly PeginParamsCandidate[]; } /** * Search the candidate space for the parameter set that reproduces the funded * Pre-PegIn, and project it back into {@link DepositTerms}. * * Per candidate: invert each vault's `peginAmount` from the observed HTLC * output value via the protocol identity `htlcValue = peginAmount + * depositorClaimValue + peginMaxFee + p2aAnchorValue`, then hand the result to * `rebuildDepositTermsCore`, which independently recomputes that same sizing * and byte-matches both the value and the scriptPubKey of every HTLC output. * * Because the amount is inverted from the value it is compared against, the * VALUE check cannot discriminate between candidates: it holds for any * candidate whose reserve leaves a positive amount. The scriptPubKey does all * the discriminating, and `getPrePeginHtlcConnectorInfo` accepts exactly one * offchain-params scalar — `timelockRefund`. So two offchain versions sharing * a `timelockRefund` are indistinguishable however much their fee rates or * council parameters differ, and that is precisely the ambiguity this function * refuses to guess through. The value check is still run, by the verifier, as * the bound that stops a candidate whose reserve exceeds the funded output. * * Every candidate is trialled; the loop does not stop at the first match, * because detecting ambiguity is the point. Matches are then COMPARED rather * than counted — several candidates matching is the ordinary case whenever * their differences cannot reach the transaction, and refusing on a count * alone would reject a deposit whose refund is fully determined. * * A candidate is only rejected on a Gate-1 byte mismatch, which is the * transaction positively disagreeing with it. Any other failure means the * candidate was never really evaluated, so it is recorded as unresolved and * feeds the same fail-closed path as a version that could not be read — * otherwise an incidental error on the TRUE candidate would remove it silently * and hand back a look-alike as a trusted unique answer. * * @throws {UnanchoredPrePeginError} If the transaction carries no single, * unambiguous auth-anchor OP_RETURN. * @throws {PeginParamsNotFoundError} If no candidate matched. * @throws {PeginParamsAmbiguousError} If matches disagree on the projected terms. * @throws {PeginParamsIncompleteSpaceError} If a match is found but the space * was known to be incomplete, or a candidate failed to evaluate. */ export declare function reconstructPeginParams(input: ReconstructPeginParamsInput): Promise; //# sourceMappingURL=reconstructPeginParams.d.ts.map