\r
import { Blake2b } from './blake2b'\r
import { ACCOUNT_KEY_BYTE_LENGTH, ACCOUNT_KEY_HEX_LENGTH, ALPHABET, PREFIX, PREFIX_LEGACY } from './constants'\r
-import { base32, bytes, hex, utf8 } from './convert'\r
+import { base32, bytes, hex, obj, utf8 } from './convert'\r
import { Pool } from './pool'\r
import { Rpc } from './rpc'\r
import { NanoNaCl, SafeWorker } from '#workers'\r
\r
get address () { return `${PREFIX}${this.#address}` }\r
get isLocked () { return this.#locked }\r
- get isUnLocked () { return !this.#locked }\r
+ get isUnlocked () { return !this.#locked }\r
get publicKey () { return this.#pub }\r
get privateKey () { return bytes.toHex(this.#prv) }\r
\r
password = utf8.toBytes(password)\r
}\r
if (password == null || password.constructor.name !== 'Uint8Array') {\r
- throw new Error('Failed to unlock wallet')\r
+ throw new Error('Failed to lock account')\r
}\r
try {\r
const data: { id: string, privateKey: Uint8Array } = {\r
password = utf8.toBytes(password)\r
}\r
if (password == null || password.constructor.name !== 'Uint8Array') {\r
- throw new Error('Failed to unlock wallet')\r
+ throw new Error('Failed to unlock account')\r
}\r
try {\r
const response = (await Account.#poolSafe.assign({\r
if (id == null || id !== this.#pub) {\r
throw null\r
}\r
- this.#prv.set(privateKey)\r
+ this.#prv.set(obj.toBytes(privateKey))\r
} catch (err) {\r
console.error(`Failed to unlock account ${this.address}`, err)\r
return false\r
const lockResult = await account.lock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.equals(lockResult, true)\r
+ assert.ok(account.isLocked)\r
assert.ok('privateKey' in account)\r
- assert.nullish(account.privateKey)\r
+ assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000')\r
\r
const unlockResult = await account.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.equals(unlockResult, true)\r
+ assert.ok(account.isUnlocked)\r
assert.ok('privateKey' in account)\r
assert.equals(account.privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
\r
const lockResult = await account.lock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.equals(lockResult, true)\r
+ assert.ok(account.isLocked)\r
assert.ok('privateKey' in account)\r
- assert.nullish(account.privateKey)\r
+ assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000')\r
\r
const unlockResult = await account.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.equals(unlockResult, true)\r
+ assert.ok(account.isUnlocked)\r
assert.ok('privateKey' in account)\r
assert.equals(account.privateKey, TREZOR_TEST_VECTORS.BLAKE2B_PRIVATE_0)\r
\r