UNPKG

@xchainjs/xchain-bitcoincash

Version:

Custom bitcoincash client and utilities used by XChainJS clients

72 lines (71 loc) 2.54 kB
/** * Module importing and providing utilities for Bitcoin Cash (BCH) transactions and addresses. */ import { Network } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { Tx } from '@xchainjs/xchain-utxo'; import bitcore from 'bitcore-lib-cash'; import { Transaction } from './types'; /** * Size constants for BCH transactions. */ export declare const TX_EMPTY_SIZE: number; export declare const TX_INPUT_BASE: number; export declare const TX_INPUT_PUBKEYHASH = 107; export declare const TX_OUTPUT_BASE: number; export declare const TX_OUTPUT_PUBKEYHASH = 25; /** * Retrieves the BCH network to be used with bitcore-lib. * @param {Network} network The network type. * @returns {BCHNetwork} The BCH network. */ export declare const bchNetwork: (network: Network) => bitcore.Networks.Network; /** * Retrieves the BCH address prefix. * * @returns {string} The BCH address prefix. */ export declare const getPrefix: () => string; /** * Strips the BCH address prefix. * @param {Address} address The BCH address. * @returns {Address} The address with the prefix removed. */ export declare const stripPrefix: (address: Address) => Address; /** * Converts the BCH address to a legacy address format. * @param {Address} address The BCH address. * @returns {Address} The legacy address. */ export declare const toLegacyAddress: (address: Address) => Address; /** * Converts the BCH address to a cash address format. * @param {Address} address The BCH address. * @returns {Address} The cash address. */ export declare const toCashAddress: (address: Address) => Address; /** * Checks whether the address is a cash address. * @param {Address} address The BCH address. * @returns {boolean} Whether the address is a cash address. */ export declare const isCashAddress: (address: Address) => boolean; /** * Parses a BCH transaction. * @param {Transaction} tx The BCH transaction. * @returns {Tx} The parsed transaction. */ export declare const parseTransaction: (tx: Transaction) => Tx; /** * Converts the XChain network to a BCH address network. * @param {Network} network The XChain network. * @returns {string} The BCH address network. */ export declare const toBCHAddressNetwork: (network: Network) => string; /** * Validates the BCH address. * @param {string} address The BCH address. * @param {Network} network The XChain network. * @returns {boolean} Whether the address is valid. */ export declare const validateAddress: (address: string, network: Network) => boolean;