import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
import { Bip44Wallet, Blake2bWallet, LedgerWallet } from '#dist/main.js'\r
\r
-test('derive child accounts from the same seed', async () => {\r
+test('should derive the first account from the given BIP-44 seed', async () => {\r
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const accounts = await wallet.accounts()\r
\r
- test('should derive the first account from the given BIP-44 seed', async () => {\r
- const accounts = await wallet.accounts()\r
-\r
- assert.equals(accounts.length, 1)\r
- assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
- assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
- assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
- })\r
-\r
- test('should derive low indexed accounts from the given BIP-44 seed', async () => {\r
- const accounts = await wallet.accounts(1, 2)\r
-\r
- assert.equals(accounts.length, 2)\r
- assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_1)\r
- assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_1)\r
- assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_1)\r
- assert.equals(accounts[1].privateKey, NANO_TEST_VECTORS.PRIVATE_2)\r
- assert.equals(accounts[1].publicKey, NANO_TEST_VECTORS.PUBLIC_2)\r
- assert.equals(accounts[1].address, NANO_TEST_VECTORS.ADDRESS_2)\r
- })\r
-\r
- test('should derive high indexed accounts from the given seed', async () => {\r
- const accounts = await wallet.accounts(0x70000000, 0x700000ff)\r
-\r
- assert.equals(accounts.length, 0x100)\r
- for (const a of accounts) {\r
- assert.exists(a)\r
- assert.exists(a.address)\r
- assert.exists(a.publicKey)\r
- assert.exists(a.privateKey)\r
- assert.exists(a.index)\r
- }\r
- })\r
-\r
- test('should derive accounts for a BLAKE2b wallet', async () => {\r
- const bwallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)\r
- await bwallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const lowAccounts = await bwallet.accounts(0, 2)\r
+ assert.equals(accounts.length, 1)\r
+ assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
+ assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
+ assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
+})\r
\r
- assert.equals(lowAccounts.length, 3)\r
- for (const a of lowAccounts) {\r
- assert.exists(a)\r
- assert.exists(a.address)\r
- assert.exists(a.publicKey)\r
- assert.exists(a.privateKey)\r
- assert.exists(a.index)\r
- }\r
+test('should derive low indexed accounts from the given BIP-44 seed', async () => {\r
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const accounts = await wallet.accounts(1, 2)\r
+\r
+ assert.equals(accounts.length, 2)\r
+ assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_1)\r
+ assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_1)\r
+ assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_1)\r
+ assert.equals(accounts[1].privateKey, NANO_TEST_VECTORS.PRIVATE_2)\r
+ assert.equals(accounts[1].publicKey, NANO_TEST_VECTORS.PUBLIC_2)\r
+ assert.equals(accounts[1].address, NANO_TEST_VECTORS.ADDRESS_2)\r
+})\r
\r
- const highAccounts = await bwallet.accounts(0x70000000, 0x700000ff)\r
+test('should derive high indexed accounts from the given seed', async () => {\r
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ let accounts\r
+ try {\r
+ accounts = await wallet.accounts(0x70000000, 0x700000ff)\r
+ } catch (err) {\r
+ throw new Error(err.message)\r
+ }\r
+\r
+ assert.equals(accounts.length, 0x100)\r
+ for (const a of accounts) {\r
+ assert.exists(a)\r
+ assert.exists(a.address)\r
+ assert.exists(a.publicKey)\r
+ assert.exists(a.privateKey)\r
+ assert.exists(a.index)\r
+ }\r
+})\r
\r
- assert.equals(highAccounts.length, 0x100)\r
- for (const a of highAccounts) {\r
- assert.exists(a)\r
- assert.exists(a.address)\r
- assert.exists(a.publicKey)\r
- assert.exists(a.privateKey)\r
- assert.exists(a.index)\r
- }\r
- })\r
+test('should derive accounts for a BLAKE2b wallet', async () => {\r
+ const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const lowAccounts = await wallet.accounts(0, 2)\r
+\r
+ assert.equals(lowAccounts.length, 3)\r
+ for (const a of lowAccounts) {\r
+ assert.exists(a)\r
+ assert.exists(a.address)\r
+ assert.exists(a.publicKey)\r
+ assert.exists(a.privateKey)\r
+ assert.exists(a.index)\r
+ }\r
+\r
+ const highAccounts = await wallet.accounts(0x70000000, 0x700000ff)\r
+\r
+ assert.equals(highAccounts.length, 0x100)\r
+ for (const a of highAccounts) {\r
+ assert.exists(a)\r
+ assert.exists(a.address)\r
+ assert.exists(a.publicKey)\r
+ assert.exists(a.privateKey)\r
+ assert.exists(a.index)\r
+ }\r
})\r
\r
skip('Ledger device accounts', async () => {\r