UNPKG

libnemo

Version:

Nano cryptocurrency wallet library.

60 lines (59 loc) 3.15 kB
import { Rpc } from './rpc'; import { Wallet } from './wallet'; type SweepResult = { status: "success" | "error"; address: string; message: string; }; export declare class Tools { /** * Converts a decimal amount of nano from one unit divider to another. * * @param {(bigint|number|string)} amount - Decimal amount to convert * @param {string} inputUnit - Current denomination * @param {string} outputUnit - Desired denomination * @param {string} [format] - Data type of output */ static convert(amount: bigint | number | string, inputUnit: string, outputUnit: string): string; static convert(amount: bigint | number | string, inputUnit: string, outputUnit: string, format: 'bigint'): bigint; static convert(amount: bigint | number | string, inputUnit: string, outputUnit: string, format: 'number'): number; static convert(amount: bigint | number | string, inputUnit: string, outputUnit: string, format: 'string'): string; /** * Hashes one or more arbitrary strings to a 32-byte value using BLAKE2b. * * @param {(string|string[])} data String(s) to hash * @param {string} [encoding] Interprets input strings as hexadecimal values if 'hex' is passed, else UTF-8 */ static hash(data: string | string[], encoding?: 'hex'): Uint8Array<ArrayBuffer>; /** * Signs arbitrary strings with a private key using the Ed25519 signature scheme. * The strings are first hashed to a 32-byte value using BLAKE2b. * * @param {string | Uint8Array<ArrayBuffer>} key - Hexadecimal-formatted private key to use for signing * @param {...string} input - Data to be signed * @returns {Promise<string>} Hexadecimal-formatted signature */ static sign(key: string | Uint8Array<ArrayBuffer>, ...input: string[]): Promise<string>; /** * Collects the funds from a specified range of accounts in a wallet and sends * them all to a single recipient address. Hardware wallets are unsupported. * * @param {(Rpc | string | URL)} rpc - RPC node information required to refresh accounts, calculate PoW, and process blocks * @param {Wallet} wallet - Wallet from which to sweep funds * @param {string} recipient - Destination address for all swept funds * @param {number} [from=0] - Starting account index to sweep * @param {number} [to=from] - Ending account index to sweep * @returns An array of results including both successes and failures */ static sweep(rpc: Rpc | string | URL, wallet: Wallet, recipient: string, from?: number, to?: number): Promise<SweepResult[]>; /** * Verifies the signature of arbitrary strings using a public key. * * @param {string | Uint8Array<ArrayBuffer>} key - Hexadecimal-formatted public key to use for verification * @param {string} signature - Hexadcimal-formatted signature * @param {...string} input - Data to be verified * @returns {Promise<boolean>} True if the data was signed by the public key's matching private key */ static verify(key: string | Uint8Array<ArrayBuffer>, signature: string, ...input: string[]): Promise<boolean>; } export {};