async destroy (): Promise<void> {\r
await SafeWorker.assign({\r
method: 'destroy',\r
- name: this.publicKey,\r
+ [this.publicKey]: this.publicKey,\r
store: 'Account'\r
})\r
this.#frontier = undefined\r
get isLocked () { return this.#locked }\r
get isUnlocked () { return !this.#locked }\r
get mnemonic () { return this.#m instanceof Bip39Mnemonic ? this.#m.phrase : null }\r
- get seed () { return bytes.toHex(this.#s) }\r
+ get seed () { return 0 === +(bytes.toHex(this.#s)) ? null : bytes.toHex(this.#s) }\r
\r
constructor (id: Entropy, seed?: Uint8Array<ArrayBuffer>, mnemonic?: Bip39Mnemonic) {\r
if (this.constructor === Wallet) {\r
* @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts\r
*/\r
async accounts (from: number = 0, to: number = from): Promise<AccountList> {\r
+ console.log(this.seed)\r
+ if (this.seed == null) {\r
+ throw new Error('wallet must be unlocked to derive accounts')\r
+ }\r
if (from > to) {\r
const swap = from\r
from = to\r
await Promise.all([\r
suite('Create wallets', async () => {\r
\r
+ await test('destroy BIP-44 wallet before unlocking', async () => {\r
+ const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD)\r
+ await assert.resolves(wallet.destroy())\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.nullish(wallet.mnemonic)\r
+ assert.nullish(wallet.seed)\r
+ await assert.rejects(wallet.unlock(NANO_TEST_VECTORS.PASSWORD))\r
+ })\r
+\r
await test('BIP-44 wallet with random entropy', async () => {\r
const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r