* 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 {Blake2bWallet|Bip44Wallet|LedgerWallet} wallet - Wallet from which to sweep funds
+* @param {Wallet|LedgerWallet} wallet - Wallet from which to sweep funds
* @param {string} recipient - Destination address for all swept funds
* @param {number} from - Starting account index to sweep
* @param {number} to - Ending account index to sweep
* @returns An array of results including both successes and failures
*/
-export declare function sweep (rpc: Rpc | string | URL, wallet: Blake2bWallet | Bip44Wallet | LedgerWallet, recipient: string, from?: number, to?: number): Promise<SweepResult[]>
+export declare function sweep (rpc: Rpc | string | URL, wallet: Wallet | LedgerWallet, recipient: string, from?: number, to?: number): Promise<SweepResult[]>
/**
* Verifies the signature of arbitrary strings using a public key.
*
/**
* Represents a wallet containing numerous Nano accounts derived from a single
-* source, the form of which can vary based on the type of wallet. The Wallet
-* class itself is abstract and cannot be directly instantiated. Currently, three
-* types of wallets are supported, each as a derived class: Bip44Wallet,
-* Blake2bWallet, LedgerWallet.
+* source, the form of which can vary based on the type of wallet. Currently,
+* three types of wallets are supported: BIP-44, BLAKE2b, and Ledger.
*/
-export declare abstract class Wallet {
+export declare class Wallet {
#private
- abstract ckd (index: number[]): Promise<KeyPair[]>
/**
- * Retrieves all wallet IDs from the Safe.
+ * Creates a new HD wallet by using an entropy value generated using a
+ * cryptographically strong pseudorandom number generator.
+ *
+ * @param {string} password - Encrypts the wallet to lock and unlock it
+ * @param {string} [salt=''] - Used when generating the final seed
+ * @returns {Wallet} A newly instantiated Wallet
+ */
+ static create (name: string, type: 'BIP-44' | 'BLAKE2b', password: string, mnemonicSalt?: string): Promise<Wallet>
+ /**
+ * Retrieves an existing wallet from the database using its name.
*
- * @returns Array of hexadecimal-formatted wallet IDs
+ * @param {string} name - Entered by user when the wallet was initially created
+ * @returns {Wallet} Restored locked Wallet
*/
- static export (): Promise<string[]>
- get id (): string
- get isLocked (): boolean
- get isUnlocked (): boolean
- get mnemonic (): string
- get seed (): string
+ static restore (name: string): Promise<Wallet>
+ get name (): string
get type (): WalletType
- constructor (id: Entropy, seed?: Uint8Array<ArrayBuffer>, mnemonic?: Bip39Mnemonic)
+ constructor (name: string, type: WalletType)
/**
* Retrieves an account from a wallet using its child key derivation function.
* Defaults to the first account at index 0.
* Locks the wallet and all currently derived accounts with a password that
* will be needed to unlock it later.
*
- * @param {Key} password Used to lock the wallet
* @returns True if successfully locked
*/
- lock (password: Key): Promise<boolean>
+ lock (): Promise<boolean>
/**
* Refreshes wallet account balances, frontiers, and representatives from the
* current state on the network.
/**
* Unlocks the wallet using the same password as used prior to lock it.
*
- * @param {Key} password Used previously to lock the wallet
+ * @param {string} password Used previously to lock the wallet
* @returns True if successfully unlocked
*/
- unlock (password: Key): Promise<boolean>
+ unlock (password: string): Promise<boolean>
/**
* Fetches the lowest-indexed unopened account from a wallet in sequential
* order. An account is unopened if it has no frontier block.
unopened (rpc: Rpc, batchSize?: number, from?: number): Promise<Account>
}
-/**
-* Hierarchical deterministic (HD) wallet created by using a source of entropy to
-* derive a mnemonic phrase. The mnemonic phrase, in combination with an optional
-* salt, is used to generate a seed. A value can be provided as a parameter for
-* entropy, mnemonic + salt, or seed; if no argument is passed, a new entropy
-* value will be generated using a cryptographically strong pseudorandom number
-* generator.
-*
-* Importantly, the salt is not stored in the instantiated Wallet object. If a
-* salt is used, then losing it means losing the ability to regenerate the seed
-* from the mnemonic.
-*
-* Accounts are derived from the seed. Private keys are derived using a BIP-44
-* derivation path. The public key is derived from the private key using the
-* Ed25519 key algorithm. Account addresses are derived as described in the nano
-* documentation (https://docs.nano.org)
-*
-* A password must be provided when creating or importing the wallet and is used
-* to lock and unlock the wallet. The wallet will be initialized as locked. When
-* the wallet is unlocked, a new password can be specified using the lock()
-* method.
-*/
-export declare class Bip44Wallet extends Wallet {
- #private
- private constructor ()
- /**
- * Creates a new HD wallet by using an entropy value generated using a
- * cryptographically strong pseudorandom number generator.
- *
- * @param {string} password - Encrypts the wallet to lock and unlock it
- * @param {string} [salt=''] - Used when generating the final seed
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static create (password: string, salt?: string): Promise<Bip44Wallet>
- /**
- * Creates a new HD wallet by using an entropy value generated using a
- * cryptographically strong pseudorandom number generator.
- *
- * @param {Uint8Array} key - Encrypts the wallet to lock and unlock it
- * @param {string} [salt=''] - Used when generating the final seed
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static create (key: Uint8Array, salt?: string): Promise<Bip44Wallet>
- /**
- * Creates a new HD wallet by using a pregenerated entropy value. The user
- * must ensure that it is cryptographically strongly random.
- *
- * @param {string} password - Used to lock and unlock the wallet
- * @param {string} entropy - Used when generating the initial mnemonic phrase
- * @param {string} [salt=''] - Used when generating the final seed
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static fromEntropy (password: string, entropy: string, salt?: string): Promise<Bip44Wallet>
- /**
- * Creates a new HD wallet by using a pregenerated entropy value. The user
- * must ensure that it is cryptographically strongly random.
- *
- * @param {Uint8Array} key - Used to lock and unlock the wallet
- * @param {string} entropy - Used when generating the initial mnemonic phrase
- * @param {string} [salt=''] - Used when generating the final seed
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static fromEntropy (key: Uint8Array<ArrayBuffer>, entropy: string, salt?: string): Promise<Bip44Wallet>
- /**
- * Creates a new HD wallet by using a pregenerated mnemonic phrase.
- *
- * @param {string} password - Used to lock and unlock the wallet
- * @param {string} mnemonic - Used when generating the final seed
- * @param {string} [salt=''] - Used when generating the final seed
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static fromMnemonic (password: string, mnemonic: string, salt?: string): Promise<Bip44Wallet>
- /**
- * Creates a new HD wallet by using a pregenerated mnemonic phrase.
- *
- * @param {Uint8Array} key - Used to lock and unlock the wallet
- * @param {string} mnemonic - Used when generating the final seed
- * @param {string} [salt=''] - Used when generating the final seed
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static fromMnemonic (key: Uint8Array<ArrayBuffer>, mnemonic: string, salt?: string): Promise<Bip44Wallet>
- /**
- * Creates a new HD wallet by using a pregenerated seed value. This seed cannot
- * be used to regenerate any higher level randomness which includes entropy,
- * mnemonic phrase, and salt.
- *
- * @param {string} password - Used to lock and unlock the wallet
- * @param {string} seed - Hexadecimal 128-character string used to derive private-public key pairs
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static fromSeed (password: string, seed: string): Promise<Bip44Wallet>
- /**
- * Creates a new HD wallet by using a pregenerated seed value. This seed cannot
- * be used to regenerate any higher level randomness which includes entropy,
- * mnemonic phrase, and salt.
- *
- * @param {Uint8Array} key - Used to lock and unlock the wallet
- * @param {string} seed - Hexadecimal 128-character string used to derive private-public key pairs
- * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
- */
- static fromSeed (key: Uint8Array<ArrayBuffer>, seed: string): Promise<Bip44Wallet>
- /**
- * Retrieves an existing HD wallet from storage using its ID.
- *
- * @param {string} id - Generated when the wallet was initially created
- * @returns {Bip44Wallet} Restored locked Bip44Wallet
- */
- static restore (id: string): Promise<Bip44Wallet>
- /**
- * Derives BIP-44 Nano account private keys.
- *
- * @param {number[]} indexes - Indexes of the accounts
- * @returns {Promise<Account>}
- */
- ckd (indexes: number[]): Promise<KeyPair[]>
-}
-
-/**
-* BLAKE2b wallet created by deriving a mnemonic phrase from a seed or vice
-* versa. If no value is provided for either, a new BIP-39 seed and mnemonic will
-* be generated using a cryptographically strong pseudorandom number generator.
-*
-* Account private keys are derived on an ad hoc basis using the Blake2b hashing
-* function. Account public key are derived from the private key using the
-* Ed25519 key algorithm. Account addresses are derived from the public key as
-* described in the Nano documentation.
-* https://docs.nano.org/integration-guides/the-basics/
-*
-* A password must be provided when creating or importing the wallet and is used
-* to lock and unlock the wallet. The wallet will be initialized as locked. When
-* the wallet is unlocked, a new password can be specified using the lock()
-* method.
-*/
-export declare class Blake2bWallet extends Wallet {
- #private
- private constructor ()
- /**
- * Creates a new BLAKE2b wallet by using a seed generated using a
- * cryptographically strong pseudorandom number generator.
- *
- * @param {string} password - Encrypts the wallet to lock and unlock it
- * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
- */
- static create (password: string): Promise<Blake2bWallet>
- /**
- * Creates a new BLAKE2b wallet by using a seed generated using a
- * cryptographically strong pseudorandom number generator.
- *
- * @param {Uint8Array} key - Encrypts the wallet to lock and unlock it
- * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
- */
- static create (key: Uint8Array): Promise<Blake2bWallet>
- /**
- * Creates a new BLAKE2b wallet by using a pregenerated seed. The user must
- * ensure that it is cryptographically strongly random.
- *
- * @param {string} password - Used to lock and unlock the wallet
- * @param {string} seed - Hexadecimal 64-character string used to derive private-public key pairs
- * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
- */
- static fromSeed (password: string, seed: string): Promise<Blake2bWallet>
- /**
- * Creates a new BLAKE2b wallet by using a pregenerated seed. The user must
- * ensure that it is cryptographically strongly random.
- *
- * @param {Uint8Array} key - Used to lock and unlock the wallet
- * @param {string} seed - Hexadecimal 64-character string used to derive private-public key pairs
- * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
- */
- static fromSeed (key: Uint8Array<ArrayBuffer>, seed: string): Promise<Blake2bWallet>
- /**
- * Creates a new BLAKE2b wallet by using a pregenerated mnemonic phrase.
- *
- * @param {string} password - Used to lock and unlock the wallet
- * @param {string} mnemonic - Used when generating the final seed
- * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
- */
- static fromMnemonic (password: string, mnemonic: string): Promise<Blake2bWallet>
- /**
- * Creates a new BLAKE2b wallet by using a pregenerated mnemonic phrase.
- *
- * @param {Uint8Array} key - Used to lock and unlock the wallet
- * @param {string} mnemonic - Used when generating the final seed
- * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
- */
- static fromMnemonic (key: Uint8Array<ArrayBuffer>, mnemonic: string): Promise<Blake2bWallet>
- /**
- * Retrieves an existing BLAKE2b wallet from storage using its ID.
- *
- * @param {string} id - Generated when the wallet was initially created
- * @returns {Blake2bWallet} Restored locked Blake2bWallet
- */
- static restore (id: string): Promise<Blake2bWallet>
- /**
- * Derives BLAKE2b account private keys.
- *
- * @param {number[]} indexes - Indexes of the accounts
- * @returns {Promise<Account>}
- */
- ckd (indexes: number[]): Promise<KeyPair[]>
-}
-
type DeviceStatus = 'DISCONNECTED' | 'BUSY' | 'LOCKED' | 'CONNECTED'
interface LedgerResponse {