UNPKG

@xchainjs/xchain-bitcoin

Version:

Custom Bitcoin client and utilities used by XChainJS clients

49 lines (48 loc) 2.06 kB
/// <reference types="node" /> import { Network } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { UTXO } from '@xchainjs/xchain-utxo'; import * as Bitcoin from 'bitcoinjs-lib'; 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; /** * Function to calculate the size of an input in a transaction. * @param {UTXO} input - The UTXO (Unspent Transaction Output) for which to calculate the size. * @returns {number} The size of the input. */ export declare const inputBytes: (input: UTXO) => number; /** * Function to calculate the average value of an array of numbers. * @param {number[]} array - The array of numbers. * @returns {number} The average value of the array. */ export declare const arrayAverage: (array: number[]) => number; /** * Function to get the Bitcoin network to be used with bitcoinjs. * * @param {Network} network - The network type (Mainnet, Testnet, or Stagenet). * @returns {Bitcoin.Network} The Bitcoin network. */ export declare const btcNetwork: (network: Network) => Bitcoin.Network; /** * Function to validate a Bitcoin address. * @param {Address} address - The Bitcoin address to validate. * @param {Network} network - The network type (Mainnet, Testnet, or Stagenet). * @returns {boolean} `true` if the address is valid, `false` otherwise. */ export declare const validateAddress: (address: Address, network: Network) => boolean; /** * Function to get the address prefix based on the network. * @param {Network} network - The network type (Mainnet, Testnet, or Stagenet). * @returns {string} The address prefix based on the network. */ export declare const getPrefix: (network: Network) => string; /** * Converts a public key to an X-only public key. * @param pubKey The public key to convert. * @returns The X-only public key. */ export declare const toXOnly: (pubKey: Buffer) => Buffer;