const wallet = await Wallet.load('BLAKE2b', password, mnemonic)
```
+Accounts in `libnemo` are guaranteed to be valid: if an account can be retrieved
+from a wallet or created _ad hoc_ without throwing an error, its public key and
+address can be considered correct for Nano protocol purposes.
+
+Wallet accounts are cached in an array-like numerically-indexed Map. This means
+that deriving an account any time after the first will be faster, and it also
+means that deriving a range of accounts will return an object that can be
+treated somewhat like a [sparse array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays).
+
```javascript
try {
await wallet.unlock(password);
const secondAccount = await wallet.account(1);
const multipleAccounts = await wallet.accounts(2, 3);
const thirdAccount = multipleAccounts[2];
-const { address, publicKey, index } = firstAccount;
+const { address, publicKey } = firstAccount;
const nodeUrl = "https://nano-node.example.com/";
await firstAccount.refresh(nodeUrl); // online
const account = await wallet.account(0);
const data = "johndoe@example.com";
-const signature = await wallet.sign(account.index, data);
+const signature = await wallet.sign(0, data);
const isValid = await Tools.verify(account.publicKey, signature, data);
console.log(isValid);
const isValid = await Tools.verify(publicKey, signature, ...randomData);
```
-#### Validate a Nano account address
-
-```javascript
-import { Tools } from "libnemo";
-
-const valid = Account.validate(
- "nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d"
-);
-```
-
## Tests
Test vectors were retrieved from the following publicly-available locations:
const blockRequest: Promise<void> = new Promise(async (resolve) => {
let block
try {
- if (index == null && account.index == null) {
+ if (index == null) {
throw new TypeError('Account index is required', { cause: account })
}
block = await new Block(account)
.send(recipientAccount, account.balance ?? 0n)
- .sign(wallet, account.index ?? index)
+ .sign(wallet, index)
await block.pow()
const hash = await block.process(rpc)
results.push({ status: 'success', address: block.account.address, message: hash })