@xchainjs/xchain-doge
Version:
Custom Doge client and utilities used by XChain clients
97 lines (96 loc) • 4.22 kB
TypeScript
/// <reference types="node" />
import { AssetInfo, FeeRate } from '@xchainjs/xchain-client';
import { Address } from '@xchainjs/xchain-util';
import { Client as UTXOClient, PreparedTx, TxParams, UTXO, UtxoClientParams } from '@xchainjs/xchain-utxo';
import * as Dogecoin from 'bitcoinjs-lib';
import { LedgerTxInfo, LedgerTxInfoParams } from './types/ledger';
/**
* Default parameters for Dogecoin UTXO client.
* Contains default values for network, phrase, explorer providers, data providers, root derivation paths, and fee bounds.
*/
export declare const defaultDogeParams: UtxoClientParams;
/**
* Custom Dogecoin client extending UTXOClient.
* Implements methods for Dogecoin-specific functionality.
*/
declare abstract class Client extends UTXOClient {
/**
* Constructor for initializing the Dogecoin client.
* Initializes the client with the provided parameters.
*
* @param {DogecoinClientParams} params Parameters for initializing the Dogecoin client.
*/
constructor(params?: UtxoClientParams);
/**
* Get Dogecoin asset information.
*
* @returns {AssetInfo} Dogecoin asset information.
*/
getAssetInfo(): AssetInfo;
/**
* Validate the given address.
*
* @param {Address} address The Dogecoin address to validate.
* @returns {boolean} `true` if the address is valid, otherwise `false`.
*/
validateAddress(address: string): boolean;
/**
* Builds a Dogecoin transaction (PSBT).
*
* Builds a Partially Signed Bitcoin Transaction (PSBT) with the specified parameters.
* @param {BuildParams} params The transaction build options including sender, recipient, amount, memo, and fee rate.
* @returns {Transaction} A promise that resolves to the built PSBT and the unspent transaction outputs (UTXOs) used in the transaction.
* @deprecated This method is deprecated. Use the `transfer` method instead.
*/
buildTx: ({ amount, recipient, memo, feeRate, sender, }: import("@xchainjs/xchain-client").TxParams & {
asset?: import("@xchainjs/xchain-util").Asset | undefined;
} & {
feeRate: FeeRate;
sender: Address;
}) => Promise<{
psbt: Dogecoin.Psbt;
utxos: UTXO[];
inputs: UTXO[];
}>;
/**
* Asynchronously creates transaction information for ledger sign.
*
* Builds a transaction (PSBT) and prepares necessary information for ledger signing.
*
* @param {LedgerTxInfoParams} params The parameters for creating transaction information.
* @returns {LedgerTxInfo} A promise that resolves to the transaction information used for ledger sign.
*/
createTxInfo(params: LedgerTxInfoParams): Promise<LedgerTxInfo>;
/**
* Asynchronously prepares a transaction for transfer.
*
* Builds a transaction (PSBT) with the specified transfer options.
* @param {TxParams & { sender: Address; feeRate: FeeRate; spendPendingUTXO?: boolean }} params The transfer options including sender address, fee rate, and optional flag for spending pending UTXOs.
* @returns {Promise<PreparedTx>} A promise that resolves to the raw unsigned transaction (PSBT).
*/
prepareTx({ sender, memo, amount, recipient, feeRate, }: TxParams & {
sender: Address;
feeRate: FeeRate;
spendPendingUTXO?: boolean;
}): Promise<PreparedTx & {
utxos: UTXO[];
inputs: UTXO[];
}>;
/**
* Compiles the memo into a buffer for inclusion in a Dogecoin transaction.
*
* @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 data.
*
* @param {UTXO[]} inputs The unspent transaction outputs (UTXOs) used as inputs.
* @param {FeeRate} feeRate The fee rate for the transaction.
* @param {Buffer | null} data The compiled memo (optional).
* @returns {number} The calculated transaction fee.
*/
protected getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data?: Buffer | null): number;
}
export { Client };