import { Transaction } from "@interlay/esplora-btc-api";
import { AxiosResponse } from "axios";
import { Bytes } from "@polkadot/types";
import { BitcoinAmount } from "@interlay/monetary-js";
export declare const MAINNET_ESPLORA_BASE_PATH = "https://btc-mainnet.interlay.io";
export declare const TESTNET_ESPLORA_BASE_PATH = "https://btc-testnet.interlay.io";
export declare const REGTEST_ESPLORA_BASE_PATH = "http://localhost:3002";
export declare type TxStatus = {
    confirmed: boolean;
    confirmations: number;
    blockHeight?: number;
    blockHash?: string;
};
export declare type TxOutput = {
    scriptpubkey: string;
    scriptpubkeyAsm: string;
    scriptpubkeyType: string;
    scriptpubkeyAddress: string;
    value: number;
};
export declare type TxInput = {
    txId: string;
    vout: number;
    isCoinbase: boolean;
    scriptsig: string;
    scriptsigAsm: string;
    innerRedeemscriptAsm: string;
    innerWitnessscriptAsm: string;
    sequence: number;
    witness: string[];
    prevout: TxOutput;
};
/**
 * Bitcoin Core API
 * @category Bitcoin Core
 */
export interface ElectrsAPI {
    /**
     * @returns The block hash of the latest Bitcoin block
     */
    getLatestBlock(): Promise<string>;
    /**
     * @returns The height of the latest Bitcoin block
     */
    getLatestBlockHeight(): Promise<number>;
    /**
     * @param txid The ID of a Bitcoin transaction
     * @returns The merkle inclusion proof for the transaction using bitcoind's merkleblock format.
     */
    getMerkleProof(txid: string): Promise<string>;
    /**
     * @param txid The ID of a Bitcoin transaction
     * @returns A TxStatus object, containing the confirmation status and number of confirmations, plus block height if
     * the tx is included in the blockchain
     */
    getTransactionStatus(txid: string): Promise<TxStatus>;
    /**
     * @param txid The ID of a Bitcoin transaction
     * @returns The height of the block the transaction was included in. If the block has not been confirmed, returns undefined.
     */
    getTransactionBlockHeight(txid: string): Promise<number | undefined>;
    /**
     * @param txid The ID of a Bitcoin transaction
     * @returns The raw transaction data, represented as a hex string
     */
    getRawTransaction(txid: string): Promise<string>;
    /**
     * Fetch the first bitcoin transaction ID based on the OP_RETURN field, recipient and amount.
     * Throw an error unless there is exactly one transaction with the given opcode.
     *
     * @remarks
     * Performs the lookup using an external service, Esplora. Requires the input string to be a hex
     *
     * @param opReturn Data string used for matching the OP_CODE of Bitcoin transactions
     * @param recipientAddress Match the receiving address of a transaction that contains said op_return
     * @param amount Match the amount (in BTC) of a transaction that contains said op_return and recipientAddress.
     * This parameter is only considered if `recipientAddress` is defined.
     *
     * @returns A Bitcoin transaction ID
     */
    getTxIdByOpReturn(opReturn: string, recipientAddress?: string, amount?: BitcoinAmount): Promise<string>;
    /**
     * Fetch the earliest bitcoin transaction ID based on the recipient address and amount.
     * Throw an error if no such transaction is found.
     *
     * @remarks
     * Performs the lookup using an external service, Esplora
     *
     * @param recipientAddress Match the receiving address of a transaction output
     * @param amount Match the amount (in BTC) of a transaction output that contains said recipientAddress.
     *
     * @returns A Bitcoin transaction ID
     */
    getEarliestPaymentToRecipientAddressTxId(recipientAddress: string, amount?: BitcoinAmount): Promise<string>;
    /**
     * Fetch the Bitcoin transaction that matches the given TxId
     *
     * @remarks
     * Performs the lookup using an external service, Esplora
     *
     * @param txid A Bitcoin transaction ID
     *
     * @returns A Bitcoin Transaction object
     */
    getTx(txid: string): Promise<Transaction>;
    /**
     * Fetch the Bitcoin UTXO amount that matches the given TxId and recipient
     *
     * @remarks
     * Performs the lookup using an external service, Esplora
     *
     * @param txid A Bitcoin transaction ID
     * @param recipient A Bitcoin scriptpubkey address
     *
     * @returns A UTXO amount if found, 0 otherwise
     */
    getUtxoAmount(txid: string, recipient: string): Promise<number>;
    /**
     * Get the parsed (as Bytes) merkle proof and raw transaction
     *
     * @remarks
     * Performs the lookup using an external service, Esplora
     *
     * @param txid A Bitcoin transaction ID
     *
     * @returns A tuple of Bytes object, representing [merkleProof, rawTx]
     */
    getParsedExecutionParameters(txid: string): Promise<[Bytes, Bytes]>;
    /**
     * Return a promise that either resolves to the first txid with the given opreturn `data`,
     * or rejects if the `timeout` has elapsed.
     *
     * @remarks
     * Every 5 seconds, performs the lookup using an external service, Esplora
     *
     * @param data The opReturn of the bitcoin transaction
     * @param timeoutMs The duration until the Promise times out (in milliseconds)
     * @param retryIntervalMs The time to wait (in milliseconds) between retries
     *
     * @returns The Bitcoin txid
     */
    waitForOpreturn(data: string, timeoutMs: number, retryIntervalMs: number): Promise<string>;
    /**
     * @param txid The ID of a Bitcoin transaction
     * @returns A TxStatus object, containing the confirmation status and number of confirmations, plus block height if
     * the tx is included in the blockchain
     */
    waitForTxInclusion(txid: string, timeoutMs: number, retryIntervalMs: number): Promise<TxStatus>;
}
export declare class DefaultElectrsAPI implements ElectrsAPI {
    private blockApi;
    private txApi;
    private scripthashApi;
    private addressApi;
    constructor(network?: string);
    getLatestBlock(): Promise<string>;
    getLatestBlockHeight(): Promise<number>;
    getMerkleProof(txid: string): Promise<string>;
    getTx(txid: string): Promise<Transaction>;
    getUtxoAmount(txid: string, recipient: string): Promise<number>;
    getEarliestPaymentToRecipientAddressTxId(recipientAddress: string, amount?: BitcoinAmount): Promise<string>;
    /**
     * Check if a given UTXO has at least `amountAsBTC`
     *
     * @param vout UTXO object
     * @param amountAsBTC (Optional) Amount the recipient must receive
     * @returns Boolean value
     */
    private txoHasAtLeastAmount;
    getTxIdByOpReturn(opReturn: string, recipientAddress?: string, amount?: BitcoinAmount): Promise<string>;
    waitForOpreturn(data: string, timeoutMs: number, retryIntervalMs: number): Promise<string>;
    waitForTxInclusion(txid: string, timeoutMs: number, retryIntervalMs: number): Promise<TxStatus>;
    /**
     * Check if a given UTXO sends at least `amountAsBTC` to a certain `recipientAddress`
     *
     * @param vout UTXO object
     * @param recipientAddress (Optional) Address of recipient
     * @param amountAsBTC (Optional) Amount the recipient must receive. This parameter is only considered if the
     * `recipientAddress` is defined too
     * @returns Boolean value
     */
    private txOutputHasRecipientAndAmount;
    /**
     * Broadcasts a transaction to the Bitcoin network configured in the constructor
     * @param hex A hex-encoded raw transaction to be broadcast to the Bitcoin blockchain
     * @returns The txid of the transaction
     */
    broadcastRawTransaction(hex: string): Promise<AxiosResponse<string>>;
    getTransactionStatus(txid: string): Promise<TxStatus>;
    getTransactionBlockHeight(txid: string): Promise<number | undefined>;
    getParsedExecutionParameters(txid: string): Promise<[Bytes, Bytes]>;
    getRawTransaction(txid: string): Promise<string>;
    /**
     * Use the TxAPI to get the confirmationation
     * @param txid The ID of a Bitcoin transaction
     * @returns A Status object, containing transaction settlement information
     */
    private getTxStatus;
    /**
     * Parse an AxiosResponse Promise
     * @param response A generic AxiosResponse Promise
     * @returns The data in the response
     */
    getData<T>(response: Promise<AxiosResponse<T>>): Promise<T>;
}
