import { Script, Address, Transaction, Networks } from '../btc';
import { DlcInitTx, UTXO, OracleEvent, OracleCET, LoanConfig, LiquidationOutcome } from './types';
import { PubKey, Sighash, Signature } from '../crypto/types';
/**
 * Creates a DLC initialization transaction that locks funds in a 2-of-2 multisig output
 * @param collateralUtxos Array of collateral UTXOs controlled by the borrower
 * @param collateralAmount Amount of collateral to lock in the DLC
 * @param borrowerPubKey Borrower's public key for the DLC
 * @param lenderPubKey Lender's public key for the DLC
 * @param changeAddress Address to receive any change from the transaction
 * @param feeRate Fee rate in satoshis per vB
 * @param network Network to use for addresses
 * @param timelock Optional relative timelock in seconds (using OP_CHECKSEQUENCEVERIFY)
 * @param dataPayload Optional OP_RETURN payload in an additional (unspendable) output
 * @returns DLC init transaction object containing the transaction, multisig script and address
 */
export declare function createDlcInitTx(collateralUtxos: UTXO[], collateralAmount: number, borrowerDlcPubKey: PubKey, lenderDlcPubKey: PubKey, changeAddress: Address, feeRate?: number, network?: Networks.Network, timelock?: number, dataPayload?: string | Buffer): DlcInitTx;
/**
 * Creates a Contract Execution Transaction (CET) that distributes funds between borrower and lender
 * @param dlcUtxo The UTXO from the DLC initialization transaction
 * @param borrowerReceiveAmount Amount of satoshis the borrower should receive
 * @param lenderReceiveAmount Amount of satoshis the lender should receive
 * @param borrowerAddress Borrower's address to receive funds
 * @param lenderAddress Lender's address to receive funds
 * @param network Network to use for addresses
 * @returns The CET transaction
 */
export declare function createCet(dlcUtxo: UTXO, borrowerReceiveAmount: number, lenderReceiveAmount: number, borrowerAddress: Address, lenderAddress: Address): Transaction;
/**
 * Funds the fees for a Contract Execution Transaction (CET) by creating a separate funding transaction
 * that can be unlocked by the CET. Since the CET parties sign it using SIGHASH_ANYONECANPAY,
 * we can add an additional input without invalidating the signatures.
 * @param cet The Contract Execution Transaction to fund fees for
 * @param feeRate Fee rate in satoshis per vB
 * @param fundsUtxos Array of UTXOs to use for funding the fees
 * @param fundingAddress Address of the final funding output, which will be the CET input
 * @param changeAddress Address to receive any change from the funding transaction
 * @returns Object containing the updated CET and the funding transaction
 */
export declare function fundCetFees(cet: Transaction, fundsUtxos: UTXO[], fundingAddress: Address, changeAddress: Address, feeRate?: number): {
    cet: Transaction;
    fundingTx: Transaction;
};
/**
 * Returns the sighash for a transaction input.
 * @param tx The transaction object
 * @param sighash The sighash flag
 * @param inputIndex The index of the input to hash
 * @param prevScriptPubKey The previous scriptPubKey of the input
 * @param satoshis The amount of satoshis in the input
 * @returns The sighash
 */
export declare function getTxSigHash(tx: Transaction, sighash: number, inputIndex: number, prevScriptPubKey: Script, satoshis: number): Sighash;
/**
 * Selects the oracle outcome (price + signature point) that lies at or below the
 * given liquidation price threshold for a single oracle event.
 * @param event             The oracle event containing the full price grid.
 * @param liquidationPrice  Calculated liquidation-threshold price for this event.
 * @returns                 The selected price and its Schnorr signature point.
 */
export declare function selectLiquidationOutcome(event: OracleEvent, liquidationPrice: number): {
    price: number;
    pubKey: PubKey;
};
/**
 * Picks event outcomes for liquidation.
 * @param events  Array of oracle price events in chronological order (ascending timestamp)
 * @param config  Loan configuration parameters
 * @returns Array of event outcomes for liquidations
 */
export declare function selectLiquidationOutcomes(events: OracleEvent[], config: LoanConfig): LiquidationOutcome[];
/**
 * Creates Contract Execution Transactions (CETs) for liquidation events
 * @param config Configuration object containing loan parameters
 * @param dlcUtxo The UTXO from the DLC initialization transaction
 * @param borrowerAddress Borrower's address to receive funds
 * @param lenderAddress Lender's address to receive funds
 * @param outcomes Array of event outcomes for liquidations
 * @returns Array of OracleCET objects
 */
export declare function createLiquidationCets(config: LoanConfig, dlcUtxo: UTXO, borrower: Address, lender: Address, outcomes: LiquidationOutcome[]): OracleCET[];
/**
 * Creates Contract Execution Transactions (CETs) for the loan maturity event
 * @param event Liquidation event
 * @param grid Price grid
 * @param config Configuration object containing loan parameters
 * @param dlcUtxo The UTXO from the DLC initialization transaction
 * @param borrowerAddress Borrower's address to receive funds
 * @param lenderAddress Lender's address to receive funds
 * @returns Array of OracleCET objects
 */
export declare function createMaturityCets(event: OracleEvent, startTime: number, config: LoanConfig, dlcUtxo: UTXO, borrower: Address, lender: Address): OracleCET[];
/**
 * Creates a Contract Execution Transaction (CET) for repayment that returns the full collateral to the borrower
 * @param dlcUtxo The UTXO from the DLC initialization transaction
 * @param collateralAmount Amount of satoshis to return to the borrower
 * @param borrowerAddress Borrower's address to receive funds
 * @returns The CET transaction
 */
export declare function createRepaymentCet(dlcUtxo: UTXO, collateralAmount: number, borrowerAddress: Address): Transaction;
/**
 * Applies signatures to a CET
 * @param cet The CET to apply signatures to
 * @param witnessScript The witness script of the CET
 * @param sigBorrower The borrower's signature
 * @param sigLender The lender's signature
 * @param cBlock The cBlock of the CET
 */
export declare function applySignaturesCet(cet: Transaction, witnessScript: Script, sigBorrower: Signature, sigLender: Signature, cBlock: string, sighash?: number): Transaction;
