Key Manager¶
-
class
KeyManager
(wallet)¶ exported from
managers/key-manager
- Extends:
TypedEventEmitter
KeyManager manages keys for accounts.
Arguments: - wallet (wallet.Wallet) –
-
KeyManager.
unlocked
¶ type: boolean
True if keystore is currently unlocked, i.e. a master passphrase is saved in memory.
-
KeyManager.
wallet
¶ type: wallet.Wallet
-
KeyManager.
addKey
(account, privateKey)¶ Adds a private key for an account to the keystore
Arguments: - account (models/account.Account) –
- privateKey (Uint8Array|number[]) –
Returns: models/key.Key –
-
KeyManager.
clearKeys
()¶ Removes all keys stored in keystore.
Returns: Promise<void> –
-
KeyManager.
getKey
(account)¶ Arguments: - account (models/account.Account) –
Returns: Promise<models/key.Key> –
-
KeyManager.
getUnlockedKey
(account)¶ Arguments: - account (models/account.Account) –
Returns: Promise<models/key.Key> –
-
KeyManager.
importKey
(importSpec)¶ Imports a raw or encrypted private key and add it to the keystore.
Arguments: - importSpec (managers/key-manager.ImportSpec) –
Returns: Promise<models/key.Key> –
-
KeyManager.
isSetup
()¶ Checks if wallet is setup with a master passphrase
Returns: Promise<boolean> –
-
KeyManager.
lock
()¶ Locks keystore by removing master passphrase from memory.
-
KeyManager.
removeKey
(address)¶ Removes key for address from keystore
Arguments: - address (string) –
Returns: Promise<void> –
-
KeyManager.
setupAndUnlock
(appId, passphrase)¶ Sets up keystore passphrase for the first time.
Arguments: - appId (string) – string to be saved encrypted with passphrase for later validity check
- passphrase (string) –
Returns: Promise<void> –
-
KeyManager.
signMessage
(account, message, enc)¶ Signs a message using key saved for account
Arguments: - account (models/account.Account) –
- message (Buffer) –
- enc (managers/key-manager.Encoding) –
Returns: Promise<string> –
-
KeyManager.
signTransaction
(account, transaction)¶ Signs a transaction using key saved for account
Arguments: - account (models/account.Account) –
- transaction (models/transaction.Transaction) –
Returns: Promise<models/transaction.SignedTransaction> –
-
KeyManager.
unlock
(passphrase)¶ Unlocks keystore by saving passphrase in memory.
Arguments: - passphrase (string) –
Returns: Promise<void> –