try {\r
const headers = {\r
method: 'set',\r
- name: this.#pub,\r
- id: this.#pub\r
+ name: this.#pub\r
}\r
const data = {\r
- privateKey: this.#prv.buffer,\r
- password: password.buffer\r
+ password: password.buffer,\r
+ id: hex.toBytes(this.#pub).buffer,\r
+ privateKey: this.#prv.buffer\r
}\r
const response = await SafeWorker.add(headers, data)\r
- const success = response?.result[0]\r
+ const success = response[0].result\r
if (!success) {\r
throw null\r
}\r
password: password.buffer\r
}\r
const response = await SafeWorker.add(headers, data)\r
- const { id, privateKey } = response?.result[0]\r
- if (id == null || id !== this.#pub) {\r
+ let { id, privateKey } = response[0].result\r
+ if (id == null) {\r
+ throw null\r
+ }\r
+ id = bytes.toHex(new Uint8Array(id))\r
+ if (id !== this.publicKey) {\r
throw null\r
}\r
- debugger\r
- this.#prv.set(obj.toBytes(privateKey))\r
+ this.#prv = new Uint8Array(privateKey as ArrayBuffer)\r
} catch (err) {\r
console.error(`Failed to unlock account ${this.address}`, err)\r
return false\r
assert.equals(lockResult, true)\r
assert.ok(account.isLocked)\r
assert.ok('privateKey' in account)\r
- assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000')\r
+ assert.equals(account.privateKey, '')\r
\r
const unlockResult = await account.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.equals(lockResult, true)\r
assert.ok(account.isLocked)\r
assert.ok('privateKey' in account)\r
- assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000')\r
+ assert.equals(account.privateKey, '')\r
\r
const unlockResult = await account.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r