@imikailoby/sats
Version:
Tiny non-custodial Bitcoin SDK (TS) — keys, addresses, PSBT, provider chain
56 lines (55 loc) • 1.75 kB
TypeScript
import type { Derivation, ReceiveAddress } from "../types";
export type Wallet = {
testnet: boolean;
account: number;
nextIndex: number;
mnemonic?: string;
getKeyAt: (index: number, change?: 0 | 1) => {
priv: Buffer;
pub: Buffer;
path: string;
};
nextReceive: () => ReceiveAddress;
toWIF: (index: number, change?: 0 | 1) => string;
};
/**
* Generate BIP39 mnemonic.
*/
/**
* Generate BIP39 mnemonic phrase.
* @param strength - Entropy bits (128..256)
* @returns mnemonic words string
* @example
* const m = generateMnemonic();
*/
export declare function generateMnemonic(strength?: 128 | 160 | 192 | 224 | 256): string;
/**
* Derive BIP84 keypair for path m/84'/coin'/account'/change/index.
* coin: 0 mainnet, 1 testnet
*/
/**
* Derive a keypair by BIP84 path m/84'/coin'/account'/change/index.
* @param mnemonic - BIP39 mnemonic
* @param d - derivation params
* @param testnet - if true, coin=1; else coin=0
* @returns private/public key buffers and path
*/
export declare function deriveKeypair(mnemonic: string, d: Derivation, testnet?: boolean): {
priv: Buffer<ArrayBufferLike>;
pub: Buffer<ArrayBufferLike>;
path: string;
};
/**
* Construct wallet helper from mnemonic with BIP84 derivation (P2WPKH, bech32).
* @param opts.testnet When true, uses coin=1 and bitcoin testnet network
*/
/**
* Create a simple wallet helper using BIP84 (bech32 P2WPKH).
* @param opts.testnet - use testnet derivation and network
* @param opts.account - BIP84 account index (default 0)
* @returns Wallet helper with `nextReceive()` and `toWIF()`
*/
export declare function fromMnemonic(mnemonic: string, opts?: {
testnet?: boolean;
account?: number;
}): Wallet;