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) 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) decode(wdb, data) → {Account}

Decode account.

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

(private, static) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(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() → {WalletKey}

Create a new change address (increments changeDepth).

Source:
Returns:
Type
WalletKey

(async) createKey(change) → {Promise}

Create a new address (increments depth).

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

createReceive() → {WalletKey}

Create a new receiving address (increments receiveDepth).

Source:
Returns:
Type
WalletKey

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

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

format() → {Object}

Convert the account to a more inspection-friendly object.

Source:
Returns:
Type
Object

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

getJSON() → {Object}

Convert the account to an object suitable for serialization.

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

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.

(private) read(data) → {Object}

Inject properties from serialized data.

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

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) → {Promise}

Allocate new lookahead addresses if necessary.

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

write() → {Buffer}

Serialize the account.

Source:
Returns:
Type
Buffer