This guide will walk you through the process of managing the lock state of your wallets using the
As mentioned earlier, a
WalletManager instance begins in a locked state. Before usage, you need to unlock it by providing a password via the unlock method.
const walletManager = new WalletManager();
const password = 'my-password';
When you lock the
WalletManager using the
lock method, all its vaults and associated accounts (wallets) are cleared. This clearance is possible due to the encryption and saving of all data by the storage system.
WalletManager frequently uses the storage system to preserve its state. Consequently, sensitive operations including exporting vaults, private keys, accessing wallets, and saving/loading the
WalletManager state are not possible when it is locked.
Remember, it's crucial to lock your
WalletManager when it's not in use to ensure the safety of your funds.
unlock method requires the previously set password to unlock the
WalletManager and all its vaults. The password decrypts the stored vaults, allowing
WalletManager to load its saved data.
Providing an incorrect password will result in an error. However, when unlocked successfully,
WalletManager is ready for use again.
You can confirm the current lock state of the
WalletManager by using the
const isLocked = walletManager.isLocked;
console.log(isLocked); // Outputs true if locked, false if unlocked
To change the current password, invoke the
updatePassphrase method, and provide both the old and new passwords:
const newPassword = 'my-new-password';
await walletManager.updatePassphrase(password, newPassword);
Always ensure you lock the
WalletManager after completing operations. This step is critical for securing your wallets.
// perform your tasks...
walletManager.lock(); // Always lock your WalletManager when you're done
WalletManager to manage lock and unlock states, you introduce an additional layer of security. Never forget to lock your
WalletManager when it's not in use.