}\r
}\r
\r
+ /**\r
+ * USING THIS METHOD IS DISCOURAGED. This library works in its entirety without\r
+ * exposing the private keys of accounts.\r
+ *\r
+ * Retrieves and decrypts the private key of the Account. The same password\r
+ * used to lock it must be used to unlock it. If derived from a wallet, the\r
+ * password for the account is the wallet seed.\r
+ *\r
+ * @param {Key} password Used previously to lock the Account\r
+ * @returns Private key bytes as a Uint8Array\r
+ */\r
+ async export (password: Key): Promise<Uint8Array<ArrayBuffer>>\r
+ /**\r
+ * USING THIS METHOD IS DISCOURAGED. This library works in its entirety without\r
+ * exposing the private keys of accounts.\r
+ *\r
+ * Retrieves and decrypts the private key of the Account. The same password\r
+ * used to lock it must be used to unlock it. If derived from a wallet, the\r
+ * password for the account is the wallet seed.\r
+ *\r
+ * @param {Key} password Used previously to lock the Account\r
+ * @returns Private key bytes as a hexadecimal string\r
+ */\r
+ async export (password: Key, format: 'hex'): Promise<string>\r
+ async export (password: Key, format?: 'hex'): Promise<Key> {\r
+ if (typeof password === 'string') password = utf8.toBytes(password)\r
+ try {\r
+ const privateKey = await this.#export(password)\r
+ return format === 'hex'\r
+ ? bytes.toHex(privateKey)\r
+ : privateKey\r
+ } catch (err) {\r
+ console.log(err)\r
+ throw new Error('Failed to export Account private key')\r
+ } finally {\r
+ bytes.erase(password)\r
+ }\r
+ }\r
+\r
/**\r
* Refreshes the account from its current state on the network.\r
*\r
* Signs a block using the private key of the account. The signature is\r
* appended to the signature field of the block before being returned.\r
*\r
- * @param {Key} password - Required to decrypt the private key for signing\r
* @param {(ChangeBlock|ReceiveBlock|SendBlock)} block - The block data to be hashed and signed\r
+ * @param {Key} password - Required to decrypt the private key for signing\r
* @returns {Promise<string>} Hexadecimal-formatted 64-byte signature\r
*/\r
async sign (block: ChangeBlock | ReceiveBlock | SendBlock, password: Key): Promise<string> {\r
- const privateKey = await this.exportPrivateKey(password)\r
+ if (typeof password === 'string') password = utf8.toBytes(password)\r
try {\r
const headers = {\r
method: 'detached'\r
}\r
- const data = {\r
- privateKey: privateKey.buffer,\r
+ const result = await NanoNaClWorker.assign(headers, {\r
+ privateKey: (await this.#export(password)).buffer,\r
msg: hex.toBytes(block.hash).buffer\r
- }\r
- const result = await NanoNaClWorker.assign(headers, data)\r
+ })\r
block.signature = result\r
return result\r
} catch (err) {\r
throw new Error(`Failed to sign block`, { cause: err })\r
- } finally {\r
- bytes.erase(privateKey)\r
- }\r
- }\r
-\r
- /**\r
- * Retrieves and decryptes the private key of the Account. The same password\r
- * used to lock it must be used to unlock it.\r
- *\r
- * @param {Key} password Used previously to lock the Account\r
- * @returns Private key bytes as a Uint8Array\r
- */\r
- async exportPrivateKey (password: Key): Promise<Uint8Array<ArrayBuffer>>\r
- /**\r
- * Retrieves and decryptes the private key of the Account. The same password\r
- * used to lock it must be used to unlock it.\r
- *\r
- * @param {Key} password Used previously to lock the Account\r
- * @returns Private key bytes as a hexadecimal string\r
- */\r
- async exportPrivateKey (password: Key, format: 'hex'): Promise<string>\r
- async exportPrivateKey (password: Key, format?: 'hex'): Promise<Key> {\r
- if (typeof password === 'string') password = utf8.toBytes(password)\r
- if (password == null || !(password instanceof Uint8Array)) {\r
- throw new Error('Password must be string or bytes')\r
- }\r
- try {\r
- const headers = {\r
- method: 'get',\r
- name: this.publicKey,\r
- store: 'Account'\r
- }\r
- const data = {\r
- password: password.buffer\r
- }\r
- const response = await SafeWorker.assign(headers, data)\r
- const privateKey = new Uint8Array(response[this.publicKey] as ArrayBuffer)\r
- return format === 'hex'\r
- ? bytes.toHex(privateKey)\r
- : privateKey\r
- } catch (err) {\r
- throw new Error(`Failed to export private key for Account ${this.address}`, { cause: err })\r
} finally {\r
bytes.erase(password)\r
}\r
return publicKey\r
}\r
\r
+ /**\r
+ * Retrieves and decrypts the private key of the Account. The same password\r
+ * used to lock it must be used to unlock it.\r
+ *\r
+ * @param {Key} password Used previously to lock the Account\r
+ * @returns Private key bytes as a Uint8Array\r
+ */\r
+ async #export (password: Key): Promise<Uint8Array<ArrayBuffer>> {\r
+ if (typeof password === 'string') password = utf8.toBytes(password)\r
+ if (password == null || !(password instanceof Uint8Array)) {\r
+ throw new Error('Password must be string or bytes')\r
+ }\r
+ try {\r
+ const headers = {\r
+ method: 'get',\r
+ name: this.publicKey,\r
+ store: 'Account'\r
+ }\r
+ const response = await SafeWorker.assign(headers, {\r
+ password: password.buffer\r
+ })\r
+ return new Uint8Array(response[this.publicKey] as ArrayBuffer)\r
+ } catch (err) {\r
+ throw new Error(`Failed to export private key for Account ${this.address}`, { cause: err })\r
+ } finally {\r
+ bytes.erase(password)\r
+ }\r
+ }\r
+\r
/**\r
* Instantiates an Account object from its private key which is then encrypted\r
* and stored in IndexedDB. The corresponding public key will automatically be\r
const headers = {\r
method: 'convert'\r
}\r
- const data = {\r
+ const publicKey = await NanoNaClWorker.assign(headers, {\r
privateKey: new Uint8Array(privateKey).buffer\r
- }\r
- const publicKey = await NanoNaClWorker.assign(headers, data)\r
+ })\r
privateAccounts[publicKey] = privateKey.buffer\r
const address = this.#keyToAddress(hex.toBytes(publicKey))\r
this.#isInternal = true\r
this.work = result.work
}
+ /**
+ * Sends the block to a node for processing on the network.
+ *
+ * The block must already be signed (see `sign()` for more information).
+ * The block must also have a `work` value.
+ *
+ * @param {Rpc|string|URL} rpc - RPC node information required to call `process`
+ * @returns {Promise<string>} Hash of the processed block
+ */
+ async process (rpc: Rpc): Promise<string> {
+ if (!this.signature) {
+ throw new Error('Block is missing signature. Use sign() and try again.')
+ }
+ if (!this.work == null) {
+ throw new Error('Block is missing proof-of-work. Generate PoW and try again.')
+ }
+ const data = {
+ "subtype": this.subtype,
+ "json_block": "true",
+ "block": this.toJSON()
+ }
+ const res = await rpc.call('process', data)
+ if (res.hash == null) {
+ throw new Error('Block could not be processed', res)
+ }
+ return res.hash
+ }
+
/**
* Signs the block using a private key. If a key is not provided, the private
* key of the block's account will be used if it exists. If that fails, an
}
}
- /**
- * Sends the block to a node for processing on the network.
- *
- * The block must already be signed (see `sign()` for more information).
- * The block must also have a `work` value.
- *
- * @param {Rpc|string|URL} rpc - RPC node information required to call `process`
- * @returns {Promise<string>} Hash of the processed block
- */
- async process (rpc: Rpc): Promise<string> {
- if (!this.signature) {
- throw new Error('Block is missing signature. Use sign() and try again.')
- }
- if (!this.work == null) {
- throw new Error('Block is missing proof-of-work. Generate PoW and try again.')
- }
- const data = {
- "subtype": this.subtype,
- "json_block": "true",
- "block": this.toJSON()
- }
- const res = await rpc.call('process', data)
- if (res.hash == null) {
- throw new Error('Block could not be processed', res)
- }
- return res.hash
- }
-
/**
* Verifies the signature of the block. If a key is not provided, the public
* key of the block's account will be used if it exists.
const headers = {
method: 'verify'
}
- const data = {
+ return await NanoNaClWorker.assign(headers, {
msg: hex.toBytes(this.hash).buffer,
signature: hex.toBytes(this.signature ?? '').buffer,
publicKey: hex.toBytes(key).buffer
- }
- return await NanoNaClWorker.assign(headers, data)
+ })
} catch (err) {
throw new Error(`Failed to derive public key from private key`, { cause: err })
}
const headers = {
method: 'detached'
}
- const data = {
+ return await NanoNaClWorker.assign(headers, {
privateKey: key.buffer,
msg: (hash(input) as Uint8Array<ArrayBuffer>).buffer
- }
- return await NanoNaClWorker.assign(headers, data)
+ })
} catch (err) {
throw new Error(`Failed to sign message with private key`, { cause: err })
} finally {
const headers = {
method: 'verify'
}
- const data = {
+ return await NanoNaClWorker.assign(headers, {
msg: (hash(input) as Uint8Array<ArrayBuffer>).buffer,
signature: hex.toBytes(signature).buffer,
publicKey: new Uint8Array(key).buffer
- }
- return await NanoNaClWorker.assign(headers, data)
+ })
} catch (err) {
throw new Error('Failed to verify signature', { cause: err })
} finally {
const headers = {\r
indexes\r
}\r
- const data = {\r
+ const results = await Bip44CkdWorker.assign(headers, {\r
seed: hex.toBytes(this.seed).buffer\r
- }\r
- const results = await Bip44CkdWorker.assign(headers, data)\r
+ })\r
const privateKeys: KeyPair[] = []\r
for (const i of Object.keys(results)) {\r
if (results[i] == null || !(results[i] instanceof ArrayBuffer)) {\r
method: 'set',\r
store: 'Wallet'\r
}\r
- const data: Data = {\r
+ const success = await SafeWorker.assign(headers, {\r
[this.id]: encoded.buffer,\r
password: password.buffer\r
- }\r
- const success = await SafeWorker.assign(headers, data)\r
+ })\r
if (!success) {\r
throw null\r
}\r
name: this.id,\r
store: 'Wallet',\r
}\r
- const data = {\r
+ const response = await SafeWorker.assign(headers, {\r
password: password.buffer\r
- }\r
- const response = await SafeWorker.assign(headers, data)\r
+ })\r
const decoded = bytes.toUtf8(response[this.id])\r
const deserialized = JSON.parse(decoded)\r
let { id, mnemonic, seed } = deserialized\r
*/
export declare class Account {
get address (): string
+ get index (): number | undefined
get publicKey (): string
get balance (): bigint | undefined
get frontier (): string | undefined
* Instantiates an Account object from its Nano address.
*
* @param {string} addresses - Address of the account
- * @returns {Account} The instantiated Account object
+ * @returns {Account} A new Account object
*/
static import (address: string): Account
/**
* Instantiates Account objects from their Nano addresses.
*
* @param {string[]} addresses - Addresses of the accounts
- * @returns {Account[]} The instantiated Account objects
+ * @returns {Account[]} Array of new Account objects
*/
static import (addresses: string[]): Account[]
/**
* Instantiates an Account object from its public key. It is unable to sign
* blocks or messages since it has no private key.
*
- * @param {string} publicKey - Public key of the account
- * @returns {Account} The instantiated Account object
- */
- static import (publicKey: string): Account
- /**
- * Instantiates an Account object from its public key. It is unable to sign
- * blocks or messages since it has no private key.
- *
- * @param {Uint8Array} publicKey - Public key of the account
- * @returns {Account} The instantiated Account object
+ * @param {Key} publicKey - Public key of the account
+ * @returns {Account} A new Account object
*/
- static import (publicKey: Uint8Array<ArrayBuffer>): Account
+ static import (publicKey: Key): Account
/**
* Instantiates Account objects from their public keys. They are unable to sign
* blocks or messages since they have no private key.
*
- * @param {string[]} publicKeys - Public keys of the accounts
- * @returns {Account[]} The instantiated Account objects
+ * @param {Key[]} publicKeys - Public keys of the accounts
+ * @returns {Account[]} Array of new Account objects
*/
- static import (publicKeys: string[]): Account[]
+ static import (publicKeys: Key[]): Account[]
/**
- * Instantiates Account objects from their public keys. They are unable to sign
- * blocks or messages since they have no private key.
+ * Instantiates an Account object from its public key. It is unable to sign
+ * blocks or messages since it has no private key.
*
- * @param {Uint8Array[]} publicKeys - Public keys of the accounts
- * @returns {Account[]} The instantiated Account objects
+ * @param {KeyPair} keypair - Index and keys of the account
+ * @returns {Account} A new Account object
*/
- static import (publicKeys: Uint8Array<ArrayBuffer>[]): Account[]
+ static import (keypair: KeyPair): Account
/**
- * Instantiates an Account object from its private key which is then encrypted
- * and stored in IndexedDB. The corresponding public key will automatically be
- * derived and saved.
+ * Instantiates Account objects from their public keys. They are unable to sign
+ * blocks or messages since they have no private key.
*
- * @param {string} privateKey - Private key of the account
- * @param {Key} password - Used to encrypt the private key
- * @returns {Account} A new Account object
+ * @param {KeyPair[]} keypairs - Indexes and keys of the accounts
+ * @returns {Account[]} Array of new Account objects
*/
- static import (privateKey: string, password: Key): Promise<Account>
+ static import (keypairs: KeyPair[]): Account[]
/**
* Instantiates an Account object from its private key which is then encrypted
* and stored in IndexedDB. The corresponding public key will automatically be
* derived and saved.
*
- * @param {Uint8Array} privateKey - Private key of the account
+ * @param {KeyPair} keypair - Index and keys of the account
* @param {Key} password - Used to encrypt the private key
- * @returns {Account} A new Account object
+ * @returns {Promise<Account>} Promise for a new Account object
*/
- static import (privateKey: Uint8Array<ArrayBuffer>, password: Key): Promise<Account>
+ static import (keypair: KeyPair, password: Key): Promise<Account>
/**
* Instantiates Account objects from their private keys which are then
* encrypted and stored in IndexedDB. The corresponding public keys will
* automatically be derived and saved.
*
- * @param {string[]} privateKeys - Private keys of the account
+ * @param {KeyPair[]} keypairs - Indexes and keys of the accounts
* @param {Key} password - Used to encrypt the private keys
- * @returns {Account[]} The instantiated Account objects
+ * @returns {Promise<Account[]>} Promise for array of new Account objects
*/
- static import (privateKeys: string[], password: Key): Promise<Account[]>
+ static import (keypairs: KeyPair[], password: Key): Promise<Account[]>
/**
- * Instantiates Account objects from their private keys which are then
- * encrypted and stored in IndexedDB. The corresponding public keys will
- * automatically be derived and saved.
+ * USING THIS METHOD IS DISCOURAGED. This library works in its entirety without
+ * exposing the private keys of accounts.
*
- * @param {Uint8Array[]} privateKeys - Private keys of the account
- * @param {Key} password - Used to encrypt the private keys
- * @returns {Account[]} The instantiated Account objects
+ * Retrieves and decrypts the private key of the Account. The same password
+ * used to lock it must be used to unlock it. If derived from a wallet, the
+ * password for the account is the wallet seed.
+ *
+ * @param {Key} password Used previously to lock the Account
+ * @returns Private key bytes as a Uint8Array
+ */
+ export (password: Key): Promise<Uint8Array<ArrayBuffer>>
+ /**
+ * USING THIS METHOD IS DISCOURAGED. This library works in its entirety without
+ * exposing the private keys of accounts.
+ *
+ * Retrieves and decrypts the private key of the Account. The same password
+ * used to lock it must be used to unlock it. If derived from a wallet, the
+ * password for the account is the wallet seed.
+ *
+ * @param {Key} password Used previously to lock the Account
+ * @returns Private key bytes as a hexadecimal string
*/
- static import (privateKeys: Uint8Array<ArrayBuffer>[], password: Key): Promise<Account[]>
+ export (password: Key, format: 'hex'): Promise<string>
/**
* Refreshes the account from its current state on the network.
*
* Signs a block using the private key of the account. The signature is
* appended to the signature field of the block before being returned.
*
- * @param {Key} password - Required to decrypt the private key for signing
* @param {(ChangeBlock|ReceiveBlock|SendBlock)} block - The block data to be hashed and signed
+ * @param {Key} password - Required to decrypt the private key for signing
* @returns {Promise<string>} Hexadecimal-formatted 64-byte signature
*/
sign (block: ChangeBlock | ReceiveBlock | SendBlock, password: Key): Promise<string>
/**
- * Retrieves and decryptes the private key of the Account. The same password
- * used to lock it must be used to unlock it.
- *
- * @param {Key} password Used previously to lock the Account
- * @returns Private key bytes as a Uint8Array
- */
- exportPrivateKey (password: Key): Promise<Uint8Array<ArrayBuffer>>
- /**
- * Retrieves and decryptes the private key of the Account. The same password
- * used to lock it must be used to unlock it.
- *
- * @param {Key} password Used previously to lock the Account
- * @returns Private key bytes as a hexadecimal string
- */
- exportPrivateKey (password: Key, format: 'hex'): Promise<string>
- /**
* Validates a Nano address with 'nano' and 'xrb' prefixes
* Derived from https://github.com/alecrios/nano-address-validator
*
*/
static validate (address: unknown): asserts address is string
}
+export declare class AccountList extends Object {
+ [index: number]: Account
+ get length (): number;
+ [Symbol.iterator] (): Iterator<Account>
+}
/**
* Represents a block as defined by the Nano cryptocurrency protocol. The Block
*/
pow (): Promise<void>
/**
+ * Sends the block to a node for processing on the network.
+ *
+ * The block must already be signed (see `sign()` for more information).
+ * The block must also have a `work` value.
+ *
+ * @param {Rpc|string|URL} rpc - RPC node information required to call `process`
+ * @returns {Promise<string>} Hash of the processed block
+ */
+ process (rpc: Rpc): Promise<string>
+ /**
* Signs the block using a private key. If a key is not provided, the private
* key of the block's account will be used if it exists. If that fails, an
* error is thrown.
[key: string]: string
}): Promise<void>
/**
- * Sends the block to a node for processing on the network.
- *
- * The block must already be signed (see `sign()` for more information).
- * The block must also have a `work` value.
- *
- * @param {Rpc|string|URL} rpc - RPC node information required to call `process`
- * @returns {Promise<string>} Hash of the processed block
- */
- process (rpc: Rpc): Promise<string>
- /**
* Verifies the signature of the block. If a key is not provided, the public
* key of the block's account will be used if it exists.
*
*/
verify (key?: string): Promise<boolean>
}
-
/**
* Represents a block that sends funds from one address to another as defined by
* the Nano cryptocurrency protocol.
work?: string
constructor (sender: Account | string, balance: string, recipient: string, amount: string, representative: Account | string, frontier: string, work?: string)
}
-
/**
* Represents a block that receives funds sent to one address from another as
* defined by the Nano cryptocurrency protocol.
work?: string
constructor (recipient: Account | string, balance: string, origin: string, amount: string, representative: Account | string, frontier?: string, work?: string)
}
-
/**
* Represents a block that changes the representative account to which the user
* account delegates their vote weight using the the Open Representative Voting
constructor (account: Account | string, balance: string, representative: Account | string, frontier: string, work?: string)
}
-export declare class AccountList extends Object {
- [index: number]: Account
- get length (): number;
- [Symbol.iterator] (): Iterator<Account>
-}
-
export type Data = {
[key: string]: ArrayBuffer
}
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const account = await wallet.account()\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
\r
assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0)\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
- const privateKey1 = await accounts[1].exportPrivateKey(wallet.seed, 'hex')\r
- const privateKey2 = await accounts[2].exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey1 = await accounts[1].export(wallet.seed, 'hex')\r
+ const privateKey2 = await accounts[2].export(wallet.seed, 'hex')\r
\r
assert.equals(accounts.length, 2)\r
assert.equals(privateKey1, NANO_TEST_VECTORS.PRIVATE_1)\r
assert.equals(a.index, i)\r
assert.exists(a.address)\r
assert.exists(a.publicKey)\r
- const privateKey = await a.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await a.export(wallet.seed, 'hex')\r
assert.exists(privateKey)\r
}\r
\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const account = await wallet.account(1)\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
\r
assert.equals(privateKey, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_1)\r
// assert.equals(account.publicKey, NANO_TEST_VECTORS.BLAKE2B_PUBLIC_0)\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(1, 2)\r
- // const privateKey1 = await accounts[1].exportPrivateKey(wallet.seed, 'hex')\r
- // const privateKey2 = await accounts[2].exportPrivateKey(wallet.seed, 'hex')\r
+ // const privateKey1 = await accounts[1].export(wallet.seed, 'hex')\r
+ // const privateKey2 = await accounts[2].export(wallet.seed, 'hex')\r
\r
assert.equals(accounts.length, 2)\r
// assert.equals(privateKey1, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_1)\r
assert.equals(a.index, i)\r
assert.exists(a.address)\r
assert.exists(a.publicKey)\r
- const privateKey = await a.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await a.export(wallet.seed, 'hex')\r
assert.exists(privateKey)\r
}\r
\r
assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_0)\r
\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
\r
await wallet.destroy()\r
assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_0)\r
\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
\r
await wallet.destroy()\r
assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_0)\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0)\r
\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_0)\r
\r
await wallet.destroy()\r
assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_1)\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1)\r
\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_1)\r
\r
await wallet.destroy()\r
assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_2)\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2)\r
\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_2)\r
\r
await wallet.destroy()\r
assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_3)\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3)\r
\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_3)\r
\r
await wallet.destroy()\r
assert.exists(accounts[i])\r
assert.exists(accounts[i].address)\r
assert.exists(accounts[i].publicKey)\r
- const privateKey = await accounts[i].exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await accounts[i].export(wallet.seed, 'hex')\r
assert.exists(privateKey)\r
}\r
\r
assert.exists(accounts[i])\r
assert.exists(accounts[i].address)\r
assert.exists(accounts[i].publicKey)\r
- const privateKey = await accounts[i].exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await accounts[i].export(wallet.seed, 'hex')\r
assert.exists(privateKey)\r
}\r
\r
assert.ok(accounts[0] instanceof Account)\r
assert.equals(accounts[0].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_0)\r
assert.equals(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_0)\r
- const privateKey0 = await accounts[0].exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey0 = await accounts[0].export(wallet.seed, 'hex')\r
assert.equals(privateKey0, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_0)\r
\r
assert.ok(accounts[1] instanceof Account)\r
assert.equals(accounts[1].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_1)\r
assert.equals(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1)\r
- const privateKey1 = await accounts[1].exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey1 = await accounts[1].export(wallet.seed, 'hex')\r
assert.equals(privateKey1, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_1)\r
\r
await wallet.destroy()\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_2)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const walletAccount = await wallet.account()\r
- const walletAccountPrivateKey = await walletAccount.exportPrivateKey(wallet.seed, 'hex')\r
+ const walletAccountPrivateKey = await walletAccount.export(wallet.seed, 'hex')\r
\r
assert.ok('mnemonic' in wallet)\r
assert.ok('seed' in wallet)\r
const imported = await Blake2bWallet.fromMnemonic(TREZOR_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_2)\r
await imported.unlock(TREZOR_TEST_VECTORS.PASSWORD)\r
const importedAccount = await imported.account()\r
- const importedAccountPrivateKey = await importedAccount.exportPrivateKey(imported.seed, 'hex')\r
+ const importedAccountPrivateKey = await importedAccount.export(imported.seed, 'hex')\r
\r
assert.equals(imported.mnemonic, wallet.mnemonic)\r
assert.equals(imported.seed, wallet.seed)\r
assert.equals(account.publicKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PUBLIC_0)\r
assert.equals(account.address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0)\r
\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
assert.equals(privateKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PRIVATE_0)\r
\r
await wallet.destroy()\r
assert.equals(lockResult, true)\r
\r
const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
\r
assert.equals(unlockResult, true)\r
assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
assert.equals(lockResult, true)\r
\r
const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
\r
assert.equals(unlockResult, true)\r
assert.equals(privateKey, TREZOR_TEST_VECTORS.BLAKE2B_PRIVATE_0)\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 account = await wallet.account()\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
const sendBlock = new SendBlock(\r
account.address,\r
'5618869000000000000000000000000',\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 account = await wallet.account()\r
- const privateKey = await account.exportPrivateKey(wallet.seed, 'hex')\r
+ const privateKey = await account.export(wallet.seed, 'hex')\r
const sendBlock = new SendBlock(\r
account.address,\r
'5618869000000000000000000000000',\r