import { AccountStoreWithAddress, AddressType, BitcoinAddress, IBitcoinMultiKeyWallet } from './interface'; import { Network } from 'bitcoinjs-lib'; import { IBitcoinWallet } from '../wallet.interface'; import { IWalletStore } from './store'; import { IBitcoinProvider } from '../provider.interface'; /** * A wallet implementation which manages multiple keys and their addresses according * to their bip standards. * * A mapping, address to IBitcoinWallet is maintained internally. These IBitcoinWallets are created * from various private keys following bip44, bip49, and bip84. These are called * internal keys or internal wallets too. * */ export declare class BitcoinMultiKeyWallet implements IBitcoinMultiKeyWallet { #private; private constructor(); /** * Returns all the accounts generated using this wallet. * * It includes accounts generated by * - `nextAccount()` * - `fromMnemonic()` * - `fromDisk()` */ getAccounts(): Promise; getMnemonic(): Promise; get provider(): IBitcoinProvider; wallets(): IBitcoinWallet[]; walletByAddress(address: string): IBitcoinWallet; walletByType(type: AddressType): IBitcoinWallet | undefined; getNetwork(): Network; getAddresses(): Promise; getBalance(): Promise; /** * Returns the next account of the current wallet. * This changes the account in the path and returns the new wallet. * * Note: If the current wallet has account 2, this will create 3rd account. * But if the 3rd account already exists, it will create 4th account. Also, if account number * is manually passed, it will create that account number (X). Now calling nextAccount * on this wallet will create X+1 account. */ nextAccount(accountNumber?: number): Promise; /** * Creates a new multi-key wallet with random mnemonic. * * It contains the following accounts: * - p2pkh * - p2wpkh * - p2wpkh-p2sh * * NOTE: store will be encrypted with the mnemonic. */ static createRandom(provider: IBitcoinProvider, store: IWalletStore): Promise; /** * Creates a new multi-key wallet from the mnemonic stored in the store. * * If the accountNumber is not generated via `nextAccount(...), it generates the accounts and stores them in the store. */ static fromDisk(provider: IBitcoinProvider, store: IWalletStore, accountNumber?: number): Promise; /** * Creates a new multi-key wallet from the mnemonic. * * Accounts are discovered from the mnemonic and if no accounts are found, it creates * the following accounts: * - p2pkh * - p2wpkh * - p2wpkh-p2sh * * NOTE: This should only be used only once when importing a wallet from mnemonic initially. * Use `fromDisk` for subsequent uses. */ static fromMnemonic(mnemonic: string, provider: IBitcoinProvider, store: IWalletStore): Promise; /** * Creates a new multi-key wallet from the private keys. * @param keys - Array of private keys * @param provider - Bitcoin provider * * This sets the derivation paths to `unknown` string and uses the MemoryStore. */ static fromPrivateKeys(privateKeys: string[], provider: IBitcoinProvider): Promise; private sanityChecksBeforeSend; private getUTXOs; /** * Returns how much each wallet should pay to satisfy the send amount. */ private getPayouts; /** * Adds the payouts to the transaction a.k.a adding inputs to the transaction and * returns inputs used. * * This is a helper function for the `send` method. */ private addPayoutsToTx; /** * Attaches witness to the transaction for p2wpkh address type. */ private handleP2wpkh; /** * Attaches the input scriptSig and signature to the transaction for p2pkh address type. */ private handleP2pkh; private handleP2wpkhP2sh; /** * Sends the amount to the given address. This is a high level function that * constructs the transaction and broadcasts it. It uses multiple keys internally * to satisfy the send amount. * * * @param toAddress an address to send the amount to * @param amt amount to send * @param fee fee to pay for the transaction (if not passed, calculated internally) * @returns txId of the transaction */ send(toAddress: string, amt: number, fee?: number | undefined): Promise; }