UNPKG

@xchainjs/xchain-bitcoincash

Version:

Custom bitcoincash client and utilities used by XChainJS clients

68 lines (67 loc) 2.37 kB
import bitcore from 'bitcore-lib-cash'; import { AssetInfo, FeeRate } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { Client as UTXOClient, TxParams, UtxoClientParams, UTXO } from '@xchainjs/xchain-utxo'; import { BchPreparedTx } from './types'; export declare const defaultBchParams: UtxoClientParams; /** * Custom Bitcoin Cash client class. */ declare abstract class Client extends UTXOClient { /** * Constructor for the Client class. * * @param {UtxoClientParams} params - Parameters for initializing the client. */ constructor(params?: UtxoClientParams); /** * Get information about the BCH asset. * @returns Information about the BCH asset. */ getAssetInfo(): AssetInfo; /** * Validate the given address. * * @param {Address} address * @returns {boolean} `true` or `false` */ validateAddress(address: string): boolean; /** * Build a BCH transaction. * @param {BuildParams} params - The transaction build options. * @returns {Transaction} A promise that resolves with the transaction builder, UTXOs, and inputs. * @deprecated */ buildTx({ amount, recipient, memo, feeRate, sender, }: TxParams & { feeRate: FeeRate; sender: Address; }): Promise<{ builder: bitcore.Transaction; utxos: UTXO[]; inputs: UTXO[]; }>; /** * Prepare a BCH transaction. * @param {TxParams&Address&FeeRate} params - The transaction preparation options. * @returns {PreparedTx} A promise that resolves with the prepared transaction and UTXOs. */ prepareTx({ sender, memo, amount, recipient, feeRate, }: TxParams & { sender: Address; feeRate: FeeRate; }): Promise<BchPreparedTx>; /** * Compile a memo. * @param {string} memo - The memo to be compiled. * @returns {Buffer} - The compiled memo. */ protected compileMemo(memo: string): Buffer; /** * Calculate the transaction fee. * @param {UTXO[]} inputs - The UTXOs. * @param {FeeRate} feeRate - The fee rate. * @param {Buffer | null} data - The compiled memo (optional). * @returns {number} - The fee amount. */ protected getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data?: Buffer | null): number; } export { Client };