load

load(filename)
load(options)

This function locates and reads a keystore file, and instantiates a Keystore from it.

Arguments:
  • filename (string) – The keystore filename

  • options.name (string) – The keystore label or filename.

  • options.paths (string[]) – Override the default keystore directory search path (Node.js Only). This must be a complete pathname.

  • options.dir (string) – Override paths, equivalent to paths: [dir].

  • options.KeystoreConstructor (function) – Override the constructor to use for the keystore. Defaults to the base wallet.Keystore constructor (not AuthKeystore, despite this being the function most often used to load auth keys).

  • options.checkEmpty (boolean) – Try an empty password before prompting the user.

Return type:

Promise<LoadResult()>

class LoadResult()

Object returned by wallet.load

Arguments:
  • keystore (Keystore) – the instance of the keystore that was loaded

  • safe (boolean) – indicates that the keystore was read from a secure location.

Note

(NodeJS only) filename must be an absolute path, or begin with path.sep, '.' + path.sep, or '..' + path.sep – a bare relative name like 'foo.keystore' is treated as a keystore label to search for (see options.name/options.paths/options.dir, above), not a literal path.

Example:

/*
 * Example using load to get a keystore from a filename.
 * The return from load() is an object with a property 'keystore',
 * which can be used in deployment when the job is set to use it
 */

const wallet = require('dcp/wallet');

const job = compute.for(inputSet, workFn);

// If payment account is not set, the job will search .dcp/ by default
const ks = await wallet.load('../path/to/your.keystore');
job.setPaymentAccountKeystore(ks.keystore);