Module

dcp/wallet

Wallet API - perform operations related to Addresses, Keystores, Key Pairs

Author:
  • Wes Garland - wes@kingsds.network
  • Duncan Mays - duncan@kingsds.network
  • Badrdine Sabhi - badr@kingsds.network
  • Ryan Rossiter - ryan@kingsds.network

Classes

Address
AuthKeystore
IdKeystore
Keystore
Keystore
Keystore
Keystore
Keystore
Keystore
Keystore
PrivateKey

Methods

# static add(keystore, nameopt, contextIdopt)

Add a temporary Keystore (in RAM) to the current wallet, which can be retrieved later by get.

Parameters:
Name Type Attributes Default Description
keystore Promise

A promise which resolves to the keystore to add

name string <optional>
'default'

The name of the keystore

contextId string <optional>

An optional identifier for caching keystores. See job.contextId in the compute-api spec.

# static addId(keystore, nameopt, contextIdopt)

Same as add, except for retrieval by getId

Parameters:
Name Type Attributes Default Description
keystore module:dcp/wallet.Keystore

The keystore to add

name string <optional>
'default'

The name of the keystore

contextId string <optional>

An optional identifier for caching keystores. See job.contextId in the compute-api spec.

# static clear()

Removes all keystore entries from the cache.

# async static get(array, name) → {module:dcp/wallet.AuthKeystore}

Form 6

This form is equivalent to wallet.get(array, {name: string}).

Parameters:
Name Type Description
array Array.<string>

Array-like object, formatted like process.argv. (See Form 4)

name string

Override the default keystore name.

Return an authorization keystore.

# async static get(options) → {module:dcp/wallet.AuthKeystore}

Form 1

This form loads a Keystore File via load. The options object is used to override default parameters which help to identify and locate the Keystore File.

On NodeJS: The options object is passed directly to wallet.load.

On Web: The options object is primarily used to provide context to the user for showing a modal;

Parameters:
Name Type Attributes Default Description
options object
name string <optional>
'default'

Override the default keystore name.

contextId string <optional>

An optional, user-defined identifier used for caching keystores. See job.contextId in the compute-api spec.

jobName string <optional>

Optional name of the job that the keystore is being requested for.

checkEmpty boolean <optional>
true

Try an empty password before prompting user

KeystoreConstructor function <optional>

Override the constructor to use for the keystore.

Return an authorization keystore.

# async static get(array) → {module:dcp/wallet.AuthKeystore}

Form 4

This form accepts an Array-like object, formatted like process.argv, to specify options for invoking Form 1. Its purpose is to unify Keystore, PrivateKey, and Address-related options for programs written in NodeJS.

Parameters:
Name Type Description
array Array.<string>

Array-like object, formatted like process.argv

Argument Behaviour
--private-key Generate a keystore corresponding to the specified private key, ignoring all other considerations
-i name Override the name option for getId
-k name Override the name option for get
-p Set the checkEmpty option to false

Return an authorization keystore.

# async static get(array, options) → {module:dcp/wallet.AuthKeystore}

Form 5

This form accepts an Array-like object, as described in form 4, and an options object as described in form 1. Its behaviour is to generate an options object from the array, merge the passed options object into this options object, and invoke form 1. To be clear, the options argument has a higher precedence than the array argument.

Parameters:
Name Type Description
array Array.<string>

Array-like object, formatted like process.argv. (See Form 4)

options object

Options object, see Form 1.

Return an authorization keystore.

# async static get(name) → {module:dcp/wallet.AuthKeystore}

Form 3

This form is equivalent to wallet.get({name: string})

Parameters:
Name Type Description
name string

Override the default keystore name.

Return an authorization keystore.

# async static get() → {module:dcp/wallet.AuthKeystore}

Form 2

This form is equivalent to wallet.get({}).

Return an authorization keystore.

# async static getId() → {module:dcp/wallet.AuthKeystore}

Return an identity keystore. See get.

# async static load(options) → {module:dcp/wallet~LoadResult}

Form 2

This function locates and reads a keystore or private key file, and instantiates a keystore from it.

Parameters:
Name Type Attributes Default Description
options object

An options object

name string <optional>
'default'

The keystore label, or filename

paths Array.<string> <optional>

Override default keystore directory search path, normally the application data directory, followed by the .dcp directory in the home directory belonging to the user invoking the program (NodeJS only). Note that the search path is never used when name specifies a complete pathname.

dir string <optional>

Overrides paths, equivalent to paths: [dir]

KeystoreConstructor KeystoreConstructor <optional>

Constructor to use when creating the keystore

# async static load(filename) → {module:dcp/wallet~LoadResult}

Form 1

This function locates and reads a keystore or private key file, and instantiates a keystore from it.

NodeJS only: filename must be an absolute path, or begin withgin with path.sep, '.' + path.sep, or '..' + path.sep. The safe flag is set to true to indicate that the Keystore file was stored safely; this happens if and only if the following conditions are true:

  1. The containing directory and all its ancestors, up to and including the root directory, is not world-writable.
  2. The Keystore File is neither world-writable nor world-readable.
Parameters:
Name Type Description
filename string

The keystore filename

Type Definitions

object

# LoadResult

Object returned by wallet.load

Properties:
Name Type Description
keystore Keystore

the instance of the keystore that was loaded

safe boolean

indicates that the keystore was read from a secure location.