UNPKG

@xchainjs/xchain-litecoin

Version:

Custom Litecoin client and utilities used by XChainJS clients

89 lines (88 loc) 2.96 kB
import { Balance, Network, TxHash } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { UTXO } from '@xchainjs/xchain-utxo'; import * as Litecoin from 'bitcoinjs-lib'; import { BroadcastTxParams } from './types/common'; import { ScanUTXOParam } from './types/sochain-api-types'; /** * Size of an empty transaction in bytes. */ export declare const TX_EMPTY_SIZE: number; /** * Base size of a transaction input in bytes. */ export declare const TX_INPUT_BASE: number; /** * Size of a transaction input with a pubkey hash in bytes. */ export declare const TX_INPUT_PUBKEYHASH = 107; /** * Base size of a transaction output in bytes. */ export declare const TX_OUTPUT_BASE: number; /** * Size of a transaction output with a pubkey hash in bytes. */ export declare const TX_OUTPUT_PUBKEYHASH = 25; /** * Calculate the size of a transaction input in bytes. * * @param {UTXO} input The UTXO. * @returns {number} The size of the transaction input. */ export declare function inputBytes(input: UTXO): number; /** * Calculate the average value of an array. * * @param {number[]} array The array of numbers. * @returns {number} The average value of the array. */ export declare function arrayAverage(array: number[]): number; /** * Get the Litecoin network to be used with bitcoinjs. * * @param {Network} network The network identifier. * @returns {Litecoin.Network} The Litecoin network. */ export declare const ltcNetwork: (network: Network) => Litecoin.Network; /** * Get the balance of an address. * * @param {AddressParams} params The parameters for fetching the balance. * @returns {Balance[]} The balance of the address. */ export declare const getBalance: (params: { apiKey: string; sochainUrl: string; network: Network; address: string; }) => Promise<Balance[]>; /** * Validate a Litecoin address. * * @param {Address} address The Litecoin address to validate. * @param {Network} network The network identifier. * @returns {boolean} `true` if the address is valid, `false` otherwise. */ export declare const validateAddress: (address: Address, network: Network) => boolean; /** * Scan UTXOs from the Sochain API. * * @param {ScanUTXOParam} params The parameters for scanning UTXOs. * @returns {Promise<UTXO[]>} The UTXOs of the address. */ export declare const scanUTXOs: ({ apiKey, sochainUrl, network, address }: ScanUTXOParam) => Promise<UTXO[]>; /** * Broadcast a transaction. * * @param {BroadcastTxParams} params The parameters for broadcasting the transaction. * @returns {Promise<TxHash>} The hash of the broadcasted transaction. */ export declare const broadcastTx: (params: BroadcastTxParams) => Promise<TxHash>; /** * Get the address prefix based on the network. * * @param {Network} network The network identifier. * @returns {string} The address prefix based on the network. **/ export declare const getPrefix: (network: Network) => string;