/// import Decimal from 'decimal.js'; import { networks } from 'bitcoinjs-lib'; import { helper, IKeypair, IBTCUnspent, binStr, bigNumber, IBTCTransactionAddress } from '@onechain/core'; export declare const generateMnemonic: typeof helper.generateMnemonic, mnemonicToSeed: typeof helper.mnemonicToSeed, mnemonicToSeedSync: typeof helper.mnemonicToSeedSync, deriveFromMnemonic: typeof helper.deriveFromMnemonic, deriveFromMnemonicSync: typeof helper.deriveFromMnemonicSync; /** * 移除 hex 字符串前缀 * * @export * @param {string} str * @returns */ export declare function stripHexPrefix(str: string): string; /** * 根据 chainID 获取当前网络 * * @param {string} chainId */ export declare function getNetworkByChainId(chainId: string): networks.Network; /** * sat 转 btc * * @export * @param {bigNumber} sat * @returns {Decimal} */ export declare function fromSat(sat: bigNumber): Decimal; /** * btc 转 sat * * @export * @param {bigNumber} btcOriginal * @returns {Decimal} */ export declare function toSat(btcOriginal: bigNumber): Decimal; /** * 生成密钥对 * * @param {string} chainId */ export declare function generateKeypair(chainId: string): { address: string; publicKey: string; privateKey: string; wif: string; }; export declare function deriveFromSeed(seed: Buffer | string, path: string): IKeypair; /** * 是否是有效的 WIF * * 详见 http://learnmeabitcoin.com/glossary/wif * * @param {string} wif * @param {string} chainId */ export declare function isValidWIF(wif: string, chainId: string): boolean; /** * 是否是有效的公钥 * * 详见 https://github.com/bitcoinjs/bitcoinjs-lib/blob/c5da44ce9526fa3b5c5ca635c263bdfab2c68862/src/payments/p2pkh.js#L29 * * @param {string} publicKeyStr */ export declare function isValidPublicKey(publicKeyStr: string): any; /** * 是否是有效的私钥 * * @param {string} privateKeyStr */ export declare function isValidPrivateKey(privateKeyStr: string): boolean; /** * 私钥推地址 * * 支持多种私钥和 WIF 格式 * * @param {string} privateKey * @param {string} chainId */ export declare function privateKeyToAddress(privateKey: string, chainId: string): { address: string; publicKey: string; privateKey: string; wif: string; }; /** * 是否是有效的地址 * * 这种检测算法可以检测 p2sh, p2pkh 等地址,详见 http://learnmeabitcoin.com/glossary/address * * @param {string} addressStr */ export declare function isValidAddress(addressStr: string): boolean; /** * 解析原始的交易数据 * * TODO 转为通用数据结构,将自定义结构分装到其他库中 * * @export * @param {string} hex * @returns */ export declare function parseRawTransaction(hex: string, unspents?: IBTCUnspent[]): { txid: string; iscoinbase: boolean; fee: string; block_height: number; blockhash: string; blocktime: string; confirmations: number; inputs: { from_address: string; from_txid: string; vin_index: number; value: string; sequence: number; }[]; outputs: { to_address: string; vout_index: number; value: string; type: any; asm: string; hex: any; }[]; }; /** * 验证 memo 参数 * * 当 memo 不为空时检查其 byte 长度 * * @protected * @param {binStr[]} [memos=[]] * @returns * @memberof Transaction */ export declare function validateMemo(memos?: binStr[]): boolean; /** * 验证转账地址相关参数 * * @protected * @param {IBTCTransactionAddress[]} addresses * @param {string} [type='from'] * @memberof Transaction */ export declare function validateAddressParams(addresses: IBTCTransactionAddress[], type?: string): boolean; /** * 验证转账金额 * * @protected * @param {IBTCTransactionAddress[]} addresses * @memberof Transaction */ export declare function validateAddressValues(addresses: IBTCTransactionAddress[]): boolean; /** * 验证手续费费率 * * @protected * @param {*} feeRate * @memberof Transaction */ export declare function validateFeeRate(feeRate: any): boolean;