Class: Account

wallet~Account(options)

Account Represents a BIP44 Account belonging to a Wallet. Note that this object does not enforce locks. Any method that does a write is internal API only and will lead to race conditions if used elsewhere.

Constructor

new Account(options)

Create an account.

Parameters:
Name Type Description
options Object
Source:

Members

(static, constant) MAX_LOOKAHEAD :Number

Default address lookahead.

Type:
  • Number
Source:

(static) types :Number

Account types.

Type:
  • Number
Properties:
Name Type Description
PUBKEYHASH Number
MULTISIG Number
Default Value:
  • {"PUBKEYHASH":0,"MULTISIG":1}
Source:

(static, constant) typesByVal :Object

Account types by value.

Type:
  • Object
Source:

Methods

(static) fromOptions(wdb, options) → {Account}

Instantiate account from options.

Parameters:
Name Type Description
wdb WalletDB
options Object
Source:
Returns:
Type
Account

(static) fromRaw(data, data) → {Account}

Instantiate a account from serialized data.

Parameters:
Name Type Description
data WalletDB
data Buffer
Source:
Returns:
Type
Account

(static) isAccount(obj) → {Boolean}

Test an object to see if it is a Account.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

(async) addSharedKey(key) → {Promise}

Add a public account key to the account (multisig). Saves the key in the wallet database.

Parameters:
Name Type Description
key HDPublicKey
Source:
Returns:
Type
Promise

changeAddress() → {Address}

Get current change address.

Source:
Returns:
Type
Address

changeKey() → {WalletKey}

Get current change key.

Source:
Returns:
Type
WalletKey

createChange() → {Promise}

Create a new change address (increments receiveDepth).

Source:
Returns:
  • Returns WalletKey
Type
Promise

(async) createKey(change) → {Promise}

Create a new address (increments depth).

Parameters:
Name Type Description
change Boolean
Source:
Returns:
  • Returns WalletKey.
Type
Promise

createNested() → {Promise}

Create a new change address (increments receiveDepth).

Source:
Returns:
  • Returns WalletKey
Type
Promise

createReceive() → {Promise}

Create a new receiving address (increments receiveDepth).

Source:
Returns:
  • Returns WalletKey
Type
Promise

deriveChange(index) → {WalletKey}

Derive a change address at index. Do not increment depth.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
WalletKey

deriveKey(branch, index) → {WalletKey}

Derive an address at index. Do not increment depth.

Parameters:
Name Type Description
branch Number
index Number
Source:
Returns:
Type
WalletKey

deriveNested(index) → {WalletKey}

Derive a nested address at index. Do not increment depth.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
WalletKey

derivePath(path, master) → {WalletKey}

Derive an address from path object.

Parameters:
Name Type Description
path Path
master MasterKey
Source:
Returns:
Type
WalletKey

deriveReceive(index) → {WalletKey}

Derive a receiving address at index. Do not increment depth.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
WalletKey

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) fromRaw(data) → {Object}

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Object

getSize() → {Number}

Calculate serialization size.

Source:
Returns:
Type
Number

(async, private) hasDuplicate() → {Promise}

Ensure accounts are not sharing keys.

Source:
Returns:
Type
Promise

(async) init() → {Promise}

Attempt to intialize the account (generating the first addresses along with the lookahead addresses). Called automatically from the walletdb.

Source:
Returns:
Type
Promise

(async) initDepth() → {Promise}

Initialize address depths (including lookahead).

Source:
Returns:
Type
Promise

inspectSymbol() → {Object}

Convert the account to a more inspection-friendly object.

Source:
Returns:
Type
Object

nestedAddress() → {Address}

Get current nested address.

Source:
Returns:
Type
Address

nestedKey() → {WalletKey}

Get current nested key.

Source:
Returns:
Type
WalletKey

pushKey(key)

Add a public account key to the account (multisig). Does not update the database.

Parameters:
Name Type Description
key HDPublicKey

Account (bip44) key (can be in base58 form).

Source:
Throws:

Error on non-hdkey/non-accountkey.

receiveAddress() → {Address}

Get current receive address.

Source:
Returns:
Type
Address

receiveKey() → {WalletKey}

Get current receive key.

Source:
Returns:
Type
WalletKey

removeSharedKey(key) → {Promise}

Remove a public account key from the account (multisig). Remove the key from the wallet database.

Parameters:
Name Type Description
key HDPublicKey
Source:
Returns:
Type
Promise

save() → {Promise}

Save the account to the database. Necessary when address depth and keys change.

Source:
Returns:
Type
Promise

saveKey(rings) → {Promise}

Save addresses to path map.

Parameters:
Name Type Description
rings Array.<WalletKey>
Source:
Returns:
Type
Promise

savePath(rings) → {Promise}

Save paths to path map.

Parameters:
Name Type Description
rings Array.<Path>
Source:
Returns:
Type
Promise

(async) setLookahead(lookahead) → {Promise}

Allocate new lookahead addresses.

Parameters:
Name Type Description
lookahead Number
Source:
Returns:
Type
Promise

spliceKey(key)

Remove a public account key to the account (multisig). Does not update the database.

Parameters:
Name Type Description
key HDPublicKey

Account (bip44) key (can be in base58 form).

Source:
Throws:

Error on non-hdkey/non-accountkey.

(async) syncDepth(receiveDepth, changeDepth, nestedDepth) → {Promise}

Allocate new lookahead addresses if necessary.

Parameters:
Name Type Description
receiveDepth Number
changeDepth Number
nestedDepth Number
Source:
Returns:
  • Returns WalletKey.
Type
Promise

toJSON() → {Object}

Convert the account to an object suitable for serialization.

Source:
Returns:
Type
Object

toRaw() → {Buffer}

Serialize the account.

Source:
Returns:
Type
Buffer