UNPKG

@xchainjs/xchain-zcash

Version:

Custom Zcash client and utilities used by XChainJS clients

73 lines (72 loc) 2.74 kB
import { AssetInfo, FeeEstimateOptions, FeeRate, FeeRates, Fees, FeesWithRates } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { Client as UTXOClient, PreparedTx, TxParams, UTXO, UtxoClientParams } from '@xchainjs/xchain-utxo'; export declare const defaultZECParams: UtxoClientParams; /** * Custom Zcash client (only support t-addresses) */ declare abstract class Client extends UTXOClient { /** * Constructor * Initializes the client with network type and other parameters. * @param {UtxoClientParams} params */ constructor(params?: UtxoClientParams); /** * Get ZEC asset info. * @returns {AssetInfo} ZEC asset information. */ getAssetInfo(): AssetInfo; /** * Validate the given Zcash address. * @param {string} address Zcash address to validate (only t-addresses). * @returns {boolean} `true` if the address is valid, `false` otherwise. */ validateAddress(address: string): boolean; /** * Compile memo into a buffer. * @param {string} memo Memo to compile. * @returns {Buffer} Compiled memo. */ protected compileMemo(memo: string): Buffer; /** * Get transaction fee from UTXOs. * @param {UTXO[]} inputs UTXOs to calculate fee from. * @param {FeeRate} feeRate Fee rate. * @param {Buffer | null} data Compiled memo (Optional). * @returns {number} Transaction fee. */ protected getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, _data?: Buffer | null): number; /** * Prepare transfer. * * @deprecated Use `prepareMaxTx` for sweep transactions. Zcash uses flat fees. * @param {TxParams&Address&FeeRate&boolean} params The transfer options. * @returns {PreparedTx} The raw unsigned transaction. */ prepareTx({ sender, memo, amount, recipient, feeRate: _feeRate, // Ignored: Zcash uses flat fees spendPendingUTXO, }: TxParams & { sender: Address; feeRate: FeeRate; spendPendingUTXO?: boolean; }): Promise<PreparedTx>; getFeesWithRates(): Promise<FeesWithRates>; getFeeRates(): Promise<FeeRates>; getFees(options?: FeeEstimateOptions): Promise<Fees>; /** * Prepare max send transaction (sweep) for Zcash. * Since Zcash uses flat fees, this calculates the maximum sendable amount * after deducting the required fee. */ prepareMaxTx({ sender, recipient, memo, spendPendingUTXO, selectedUtxos, }: { sender: Address; recipient: Address; memo?: string; spendPendingUTXO?: boolean; selectedUtxos?: UTXO[]; }): Promise<PreparedTx & { maxAmount: number; fee: number; }>; } export { Client };