@nawab_kibria/bitcoin-lib
Version:
A comprehensive Bitcoin HD wallet library with BIP84, BIP44, BIP49 support, mnemonic generation and restoration
101 lines (100 loc) • 3 kB
TypeScript
import * as bitcoin from "bitcoinjs-lib";
import { WalletKeys, AddressDetails, WalletOptions, AddressType } from "../types/wallet";
export declare class BitcoinWallet {
private mnemonic;
private seed;
private root;
private network;
private addressCount;
constructor(options?: WalletOptions);
/**
* Set the network dynamically
*/
setNetwork(network: bitcoin.Network): void;
/**
* Get current network
*/
getNetwork(): bitcoin.Network;
/**
* Get wallet keys including mnemonic, xpub, xpriv, and first P2WPKH address
* Now includes zpub/vpub for BIP84 Native SegWit
*/
getWalletKeys(network?: bitcoin.Network): WalletKeys;
/**
* Get BIP84-specific extended keys (zpub/vpub format)
*/
getBip84Keys(network?: bitcoin.Network): {
zpub: string;
zprv: string;
};
/**
* Generate P2WPKH (Native SegWit) addresses - BIP84
*/
generateNativeSegwitAddresses(count?: number, network?: bitcoin.Network): AddressDetails[];
/**
* Generate P2PKH (Legacy) addresses - BIP44
*/
generateLegacyAddresses(count?: number, network?: bitcoin.Network): AddressDetails[];
/**
* Generate P2SH-P2WPKH (SegWit) addresses - BIP49
*/
generateSegwitAddresses(count?: number, network?: bitcoin.Network): AddressDetails[];
/**
* Get address by specific derivation path
*/
getAddressByPath(path: string, addressType?: AddressType, network?: bitcoin.Network): AddressDetails;
/**
* Generate addresses for multiple networks at once
*/
generateMultiNetworkAddresses(addressCount?: number): {
mainnet: AddressDetails[];
testnet: AddressDetails[];
regtest: AddressDetails[];
};
/**
* Get wallet keys for all networks
*/
getAllNetworkKeys(): {
mainnet: WalletKeys;
testnet: WalletKeys;
regtest: WalletKeys;
};
/**
* Get the mnemonic phrase
*/
getMnemonic(): string;
/**
* Get the seed
*/
getSeed(): Buffer;
/**
* Get root extended private key
*/
getRootXPriv(network?: bitcoin.Network): string;
/**
* Get root extended public key
*/
getRootXPub(network?: bitcoin.Network): string;
/**
* Get root extended keys in BIP84 format (zpub/zprv for mainnet, vpub/vprv for testnet)
*/
getRootBip84Keys(network?: bitcoin.Network): {
zpub: string;
zprv: string;
};
/**
* Get account extended keys for specific purpose (44, 49, 84, or 86)
*/
getAccountKeys(purpose: 44 | 49 | 84 | 86, network?: bitcoin.Network): {
xpriv: string;
xpub: string;
};
/**
* Static method to restore wallet from mnemonic
*/
static fromMnemonic(mnemonic: string, network?: bitcoin.Network): BitcoinWallet;
/**
* Static method to generate new wallet
*/
static generate(network?: bitcoin.Network): BitcoinWallet;
}