UNPKG

@xchainjs/xchain-dash

Version:

Custom Dash client and utilities used by XChainJS clients

89 lines (88 loc) 3.63 kB
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 { DashPreparedTx, NodeAuth, NodeUrls } from './types'; /** * Default parameters for the DASH client. */ export declare const defaultDashParams: UtxoClientParams & { nodeUrls: NodeUrls; nodeAuth?: NodeAuth; }; /** * DASH client class extending UTXOClient. */ declare abstract class Client extends UTXOClient { protected readonly nodeUrls: NodeUrls; protected readonly nodeAuth?: NodeAuth; constructor(params?: import("@xchainjs/xchain-client").XChainClientParams & { explorerProviders: import("@xchainjs/xchain-client").ExplorerProviders; dataProviders: import("@xchainjs/xchain-utxo/lib/types/types").UtxoOnlineDataProviders[]; } & { nodeUrls: NodeUrls; nodeAuth?: NodeAuth; }); /** * Get the asset info for DASH. * @returns {AssetInfo} The asset info for DASH. */ getAssetInfo(): AssetInfo; /** * Validate a DASH address. * @param {string} address The DASH address to validate. * @returns {boolean} True if the address is valid, false otherwise. */ validateAddress(address: string): boolean; /** * Asynchronously prepares a transaction for sending assets. * @deprecated Use `prepareTxEnhanced` instead for better UTXO selection and error handling. * @param {TxParams&Address&FeeRate} params - Parameters for the transaction preparation. * @returns {string} A promise resolving to the prepared transaction data. */ prepareTx({ sender, memo, amount, recipient, feeRate, }: TxParams & { sender: Address; feeRate: FeeRate; }): Promise<DashPreparedTx>; /** * Compiles a memo into a buffer. * @param {string} memo - The memo to be compiled. * @returns {Buffer} The compiled memo as a buffer. */ protected compileMemo(memo: string): Buffer; /** * Calculates the transaction fee based on the provided UTXOs, fee rate, and optional compiled memo. * @param {UTXO[]} inputs - The UTXOs used as inputs for the transaction. * @param {FeeRate} feeRate - The fee rate for the transaction. * @param {Buffer | null} data - The compiled memo as a buffer (optional). * @returns {number} The calculated transaction fee amount. */ protected getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data?: Buffer | null): number; private getUtxoScriptHex; /** * Prepare transaction with enhanced UTXO selection. * Uses base class UTXO selection logic with dashcore-lib transaction building. */ prepareTxEnhanced({ sender, memo, amount, recipient, feeRate, spendPendingUTXO, 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 };