UNPKG

@xchainjs/xchain-doge

Version:

Custom Doge client and utilities used by XChain clients

82 lines (81 loc) 3.47 kB
import { FeeRate, TxHash } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { TxParams, UTXO, UtxoSelectionPreferences } from '@xchainjs/xchain-utxo'; import { Client } from './client'; /** * Custom Doge client extended to support keystore functionality */ declare class ClientKeystore extends Client { /** * Get the Dogecoin address. * * Generates a Dogecoin address using the provided phrase and index. * @param {number} index The index of the address to retrieve. Default is 0. * @returns {Address} The Dogecoin 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 is not provided. * @throws {"Address not defined"} Thrown if failed to create the address from the phrase. */ getAddress(index?: number): Address; /** * @private * Get private key. * * Private function to get keyPair from the this.phrase * * @param {string} phrase The phrase to be used for generating privkey * @returns {ECPairInterface} The privkey generated from the given phrase * * @throws {"Could not get private key from phrase"} Throws an error if failed creating Doge keys from the given phrase * */ private getDogeKeys; /** * Get the current address. * Asynchronous version of getAddress method. * Generates a network-specific key-pair by first converting the buffer to a Wallet-Import-Format (WIF) * The address is then decoded into type P2WPKH and returned. * @returns {Address} The current address. * * @throws {"Phrase must be provided"} Thrown if phrase has not been set before. * @throws {"Address not defined"} Thrown if failed creating account from phrase. */ getAddressAsync(index?: number): Promise<string>; /** * Asynchronously transfers Dogecoin. * * Builds, signs, and broadcasts a Dogecoin transaction with the specified parameters. * * @param {Object} params The transfer parameters. * @returns {Promise<TxHash>} The transaction hash. */ transfer(params: TxParams & { feeRate?: FeeRate; utxoSelectionPreferences?: UtxoSelectionPreferences; selectedUtxos?: UTXO[]; }): Promise<TxHash>; /** * Transfer the maximum amount of Dogecoin (sweep). * * Calculates the maximum sendable amount after fees, signs, and broadcasts the transaction. * @param {Object} params The transfer parameters. * @param {string} params.recipient The recipient address. * @param {string} [params.memo] Optional memo for the transaction. * @param {FeeRate} [params.feeRate] Optional fee rate. Defaults to 'fast' rate. * @param {number} [params.walletIndex] Optional wallet index. Defaults to 0. * @param {UtxoSelectionPreferences} [params.utxoSelectionPreferences] Optional UTXO selection preferences. * @returns {Promise<{ hash: TxHash; maxAmount: number; fee: number }>} The transaction hash, amount sent, and fee. */ transferMax(params: { recipient: Address; memo?: string; feeRate?: FeeRate; walletIndex?: number; utxoSelectionPreferences?: UtxoSelectionPreferences; selectedUtxos?: UTXO[]; }): Promise<{ hash: TxHash; maxAmount: number; fee: number; }>; } export { ClientKeystore };