Account Store

Class Name AccountStore
Implements KeyStoreInterface
Extends Logger
Extends account-store.ts
Source account-store.ts

The DApp Browser AccountStore is a adaption to the original blockchain-core AccountStore and overwrites the Keystore function, to handle private keys loaded from the lightwallet browser instance. Initially no keys are provided into the KeyProvider. When privateKeys are requested, the user must insert his password to unlock its lightwallet account to handle the privateKeys for signing.

The original DApp Browser AccountStore implements the KeyStoreInterface and is a wrapper for a storage, where evan.network account ids are stored. The default AccountStore takes an account –> private key mapping as a pojo as its arguments and uses this to perform lookups, when the getPrivateKey function is called. This lookup needs to be done, when transactions are signed by the InternalSigner (see Signer).

Note that the return value of the getPrivateKey function is a promise. This may not be required in the default DBCP AccountStore, but this allows you to implement own implementations of the KeyStoreInterface, which may enforce a more strict security behavior or are able to access other sources for private keys.


constructor

new AccountStore(vault?: any);

Creates a new AccountStore instance.

Parameters

  1. vault - AccountStoreOptions (optional): overwrite the global vault with an specific one

Returns

AccountStore instance

Example

const accountStore = new AccountStore();

getPrivateKey

accountStore.getPrivateKey(accountId);

get private key for given account

Parameters

  1. accountId - string: eth accountId

Returns

Promise resolves to string: private key for this account

Example

const privateKey = await runtime.accountStore.getPrivateKey('0x0000000000000000000000000000000000000002');