@xchainjs/xchain-bitcoincash
Version:
Custom bitcoincash client and utilities used by XChainJS clients
108 lines (107 loc) • 3.92 kB
TypeScript
import bitcore from 'bitcore-lib-cash';
import { AssetInfo, FeeRate } from '@xchainjs/xchain-client';
import { Address } from '@xchainjs/xchain-util';
import { Client as UTXOClient, PreparedTx, TxParams, UTXO, UtxoClientParams, UtxoSelectionPreferences } 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.
* @deprecated Use `prepareTxEnhanced` instead for better UTXO selection and error handling.
* @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;
/**
* Build transaction with enhanced UTXO selection
*/
buildTxEnhanced({ amount, recipient, memo, feeRate, sender, spendPendingUTXO, utxoSelectionPreferences, selectedUtxos, }: TxParams & {
feeRate: FeeRate;
sender: Address;
spendPendingUTXO?: boolean;
utxoSelectionPreferences?: UtxoSelectionPreferences;
selectedUtxos?: UTXO[];
}): Promise<{
builder: bitcore.Transaction;
utxos: UTXO[];
inputs: UTXO[];
}>;
/**
* Prepare transaction with enhanced UTXO selection
*/
prepareTxEnhanced({ sender, memo, amount, recipient, spendPendingUTXO, feeRate, utxoSelectionPreferences, selectedUtxos, }: TxParams & {
sender: Address;
feeRate: FeeRate;
spendPendingUTXO?: boolean;
utxoSelectionPreferences?: UtxoSelectionPreferences;
selectedUtxos?: UTXO[];
}): Promise<PreparedTx>;
/**
* Prepare max send transaction
*/
prepareMaxTx({ sender, recipient, memo, feeRate, spendPendingUTXO, utxoSelectionPreferences, selectedUtxos, }: {
sender: Address;
recipient: Address;
memo?: string;
feeRate: FeeRate;
spendPendingUTXO?: boolean;
utxoSelectionPreferences?: UtxoSelectionPreferences;
selectedUtxos?: UTXO[];
}): Promise<PreparedTx & {
maxAmount: number;
fee: number;
}>;
}
export { Client };