import { ApiPromise } from "@polkadot/api"; import { H256, AccountId } from "@polkadot/types/interfaces"; import { BlockNumber } from "@polkadot/types/interfaces/runtime"; import { AddressOrPair } from "@polkadot/api/types"; import Big from "big.js"; import { Network } from "bitcoinjs-lib"; import { Bytes } from "@polkadot/types"; import { ReplaceRequest } from "../interfaces/default"; import { DefaultTransactionAPI, TransactionAPI } from "./transaction"; import { ElectrsAPI } from ".."; export interface ReplaceRequestExt extends Omit { btc_address: string; new_vault: string; } export declare function encodeReplaceRequest(req: ReplaceRequest, network: Network): ReplaceRequestExt; /** * @category PolkaBTC Bridge * The type Big represents DOT or PolkaBTC denominations, * while the type BN represents Planck or Satoshi denominations. */ export interface ReplaceAPI extends TransactionAPI { /** * @returns The minimum amount of btc that is accepted for replace requests; any lower values would * risk the bitcoin client to reject the payment */ getBtcDustValue(): Promise; /** * @returns The time difference in number of blocks between when a replace request is created * and required completion time by a vault. The replace period has an upper limit * to prevent griefing of vault collateral. */ getReplacePeriod(): Promise; /** * @returns An array containing the replace requests */ list(): Promise; /** * @returns A mapping from the replace request ID to the replace request object */ map(): Promise>; /** * @param amount Amount issued, denoted in Bitcoin, to have replaced by another vault * @returns The request id */ request(amount: Big): Promise; /** * Set an account to use when sending transactions from this API * @param account Keyring account */ setAccount(account: AddressOrPair): void; /** * Wihdraw a replace request * @param amount The amount of wrapped tokens to withdraw from the amount * requested to have replaced. */ withdraw(amount: Big): Promise; /** * Accept a replace request * @param oldVault ID of the old vault that to be (possibly partially) replaced * @param amount Amount of issued tokens to be replaced * @param collateral The collateral for replacement * @param btcAddress The address that old-vault should transfer the btc to */ accept(oldVault: AccountId, amountSat: Big, collateral: Big, btcAddress: string): Promise; /** * Execute a replace request * @remarks If `txId` is not set, the `merkleProof` and `rawTx` must both be set. * * @param replaceId The ID generated by the replace request transaction * @param txId (Optional) The ID of the Bitcoin transaction that sends funds from the old vault to the new vault * @param merkleProof (Optional) The merkle inclusion proof of the Bitcoin transaction. * @param rawTx (Optional) The raw bytes of the Bitcoin transaction */ execute(replaceId: string, btcTxId?: string, merkleProof?: Bytes, rawTx?: Bytes): Promise; } export declare class DefaultReplaceAPI extends DefaultTransactionAPI implements ReplaceAPI { private electrsAPI; private btcNetwork; private feeAPI; constructor(api: ApiPromise, btcNetwork: Network, electrsAPI: ElectrsAPI, account?: AddressOrPair); /** * @param events The EventRecord array returned after sending a replace request transaction * @returns The id associated with the replace request. If the EventRecord array does not * contain replace request events, the function throws an error. */ private getRequestIdFromEvents; request(amount: Big): Promise; withdraw(amount: Big): Promise; accept(oldVault: AccountId, amount: Big, collateral: Big, btcAddress: string): Promise; execute(requestId: string, btcTxId?: string, merkleProof?: Bytes, rawTx?: Bytes): Promise; getBtcDustValue(): Promise; getGriefingCollateral(amount: Big): Promise; getReplacePeriod(): Promise; list(): Promise; map(): Promise>; }