@xchainjs/xchain-bitcoin
Version:
Custom Bitcoin client and utilities used by XChainJS clients
52 lines (51 loc) • 2.27 kB
TypeScript
import { FeeRate, TxHash } from '@xchainjs/xchain-client';
import { Address } from '@xchainjs/xchain-util';
import { TxParams, UtxoClientParams } from '@xchainjs/xchain-utxo';
import { Client } from './client';
import { AddressFormat } from './types';
/**
* Custom Bitcoin client extended to support keystore functionality
*/
declare class ClientKeystore extends Client {
constructor(params?: UtxoClientParams & {
addressFormat?: AddressFormat;
});
/**
* @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.
* @throws {"Address not defined"} Thrown if failed to create the address from the phrase.
*/
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 Bitcoin 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 getBtcKeys;
/**
* Transfer BTC.
*
* @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 & {
feeRate?: FeeRate;
}): Promise<TxHash>;
}
export { ClientKeystore };