@xchainjs/xchain-zcash
Version:
Custom Zcash client and utilities used by XChainJS clients
69 lines (68 loc) • 2.93 kB
TypeScript
import { TxHash } from '@xchainjs/xchain-client';
import { Address } from '@xchainjs/xchain-util';
import { TxParams, UTXO, UtxoClientParams } from '@xchainjs/xchain-utxo';
import { Client } from './client';
/**
* Custom Bitcoin client extended to support keystore functionality
*/
declare class ClientKeystore extends Client {
constructor(params?: UtxoClientParams);
/**
* @deprecated This function eventually will be removed. Use getAddressAsync instead.
* Get the address associated with the given index.
* @param {number} index The index of the address.
* @returns {Address} The Bitcoin address.
* @throws {"index must be greater than zero"} Thrown if the index is less than zero.
* @throws {"Phrase must be provided"} Thrown if the phrase has not been set before.
*/
getAddress(index?: number): Address;
/**
* Get the current address asynchronously.
* @param {number} index The index of the address.
* @returns {Promise<Address>} A promise that resolves to the Bitcoin address.
* @throws {"Phrase must be provided"} Thrown if the phrase has not been set before.
*/
getAddressAsync(index?: number): Promise<string>;
/**
* @private
* Get the keys derived from the given phrase.
*
* @param {string} phrase The phrase to be used for generating the keys.
* @param {number} index The index of the address.
* @returns {Bitcoin.ECPair.ECPairInterface} The Bitcoin key pair.
* @throws {"Could not get private key from phrase"} Thrown if failed to create BTC keys from the given phrase.
*/
private getZecKeys;
/**
* Transfer ZEC.
*
* @param {TxParams&FeeRate} params The transfer options including the fee rate.
* @returns {Promise<TxHash|string>} A promise that resolves to the transaction hash or an error message.
* @throws {"memo too long"} Thrown if the memo is longer than 80 characters.
*/
transfer(params: TxParams & {
selectedUtxos?: UTXO[];
}): Promise<TxHash>;
/**
* Transfer the maximum amount of ZEC (sweep).
*
* Calculates the maximum sendable amount after fees, signs, and broadcasts the transaction.
* Note: Zcash uses flat fees, so feeRate is ignored.
* @param {Object} params The transfer parameters.
* @param {string} params.recipient The recipient address.
* @param {string} [params.memo] Optional memo for the transaction.
* @param {number} [params.walletIndex] Optional wallet index. Defaults to 0.
* @returns {Promise<{ hash: TxHash; maxAmount: number; fee: number }>} The transaction hash, amount sent, and fee.
*/
transferMax(params: {
recipient: Address;
memo?: string;
walletIndex?: number;
selectedUtxos?: UTXO[];
}): Promise<{
hash: TxHash;
maxAmount: number;
fee: number;
}>;
}
export { ClientKeystore };