UNPKG

@xchainjs/xchain-litecoin

Version:

Custom Litecoin client and utilities used by XChainJS clients

96 lines (95 loc) 3.46 kB
/// <reference types="node" /> import { AssetInfo, FeeRate, Network } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { Client as UTXOClient, PreparedTx, TxParams, UTXO, UtxoClientParams } from '@xchainjs/xchain-utxo'; import * as Litecoin from 'bitcoinjs-lib'; import { NodeAuth } from './types'; /** * Defines a mapping of node URLs for different networks. */ export type NodeUrls = Record<Network, string>; /** * Default parameters for the Litecoin client. */ export declare const defaultLtcParams: UtxoClientParams & { nodeUrls: NodeUrls; nodeAuth?: NodeAuth; }; /** * Custom Litecoin client. */ declare abstract class Client extends UTXOClient { protected nodeUrls: NodeUrls; protected nodeAuth?: NodeAuth; /** * Constructs a new `Client` with the provided parameters. * * @param {UtxoClientParams} params The parameters for initializing the client. */ constructor(params?: import("@xchainjs/xchain-client").XChainClientParams & { explorerProviders: import("@xchainjs/xchain-client").ExplorerProviders; dataProviders: import("@xchainjs/xchain-utxo/lib/types/types").UtxoOnlineDataProviders[]; } & { nodeUrls: NodeUrls; nodeAuth?: NodeAuth | undefined; }); /** * Returns information about the asset used by the client. * * @returns {AssetInfo} Information about the asset. */ getAssetInfo(): AssetInfo; /** * Validates the given Litecoin address. * * @param {string} address The Litecoin address to validate. * @returns {boolean} `true` if the address is valid, `false` otherwise. */ validateAddress(address: string): boolean; /** * Builds a Litecoin (LTC) transaction. * * @param {BuildParams} params The transaction build options. * @returns {Transaction} A promise that resolves to the PSBT (Partially Signed Bitcoin Transaction) and UTXOs (Unspent Transaction Outputs). * @deprecated This function will eventually be removed. Use `prepareTx` instead. */ buildTx({ amount, recipient, memo, feeRate, sender, }: TxParams & { feeRate: FeeRate; sender: Address; }): Promise<{ psbt: Litecoin.Psbt; utxos: UTXO[]; inputs: UTXO[]; }>; /** * Prepares a Litecoin (LTC) transaction. * * @param {TxParams&Address&FeeRate&boolean} params The transfer options. * @returns {PreparedTx} A promise that resolves to the raw unsigned transaction. */ prepareTx({ sender, memo, amount, recipient, feeRate, }: TxParams & { sender: Address; feeRate: FeeRate; spendPendingUTXO?: boolean; }): Promise<PreparedTx & { utxos: UTXO[]; inputs: UTXO[]; }>; /** * Compile memo. * * @param {string} memo The memo to be compiled. * @returns {Buffer} The compiled memo. */ protected compileMemo(memo: string): Buffer; /** * Calculates the transaction fee based on the provided UTXOs, fee rate, and optional compiled memo. * * @param {UTXO[]} inputs The The UTXOs used as inputs in the transaction. * @param {FeeRate} feeRate The fee rate. * @param {Buffer} data The compiled memo (Optional). * @returns {number} The calculated fee amount. */ protected getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data?: Buffer | null): number; } export { Client };