new Account(options)
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.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- 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 :RevMap
Account types by value.
Type:
- Source:
addSharedKey
Add a public account key to the account (multisig). Saves the key in the wallet database.
- Source:
createKey
Create a new address (increments depth).
- Source:
init
Attempt to intialize the account (generating the first addresses along with the lookahead addresses). Called automatically from the walletdb.
- Source:
initDepth
Initialize address depths (including lookahead).
- Source:
setLookahead
Allocate new lookahead addresses.
- Source:
syncDepth
Allocate new lookahead addresses if necessary.
- Source:
Methods
(static) fromOptions(db, options) → {Account}
Instantiate account from options.
Parameters:
Name | Type | Description |
---|---|---|
db |
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
(private) _hasDuplicate() → {Promise}
Ensure accounts are not sharing keys.
- Source:
Returns:
- Type
- Promise
createChange() → {WalletKey}
Create a new change address (increments receiveDepth).
- Source:
Returns:
- Type
- WalletKey
createNested() → {WalletKey}
Create a new change address (increments receiveDepth).
- Source:
Returns:
- Type
- WalletKey
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 | Whether the address on the change branch. |
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
getAddress(encnullable) → {Address|Base58Address}
Get current receive address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | Base58Address
getChange(encnullable) → {Address|Base58Address}
Get current change address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | Base58Address
getNested(encnullable) → {Address|Base58Address}
Get current nested address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | Base58Address
getReceive(encnullable) → {Address|Base58Address}
Get current receive address.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
enc |
String |
<nullable> |
|
- Source:
Returns:
- Type
- Address | Base58Address
getSize() → {Number}
Calculate serialization size.
- Source:
Returns:
- Type
- Number
inspect() → {Object}
Convert the account to a more inspection-friendly object.
- Source:
Returns:
- Type
- Object
open() → {Promise}
Open the account (done after retrieval).
- 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.
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
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.
toJSON() → {Object}
Convert the account to an object suitable for serialization.
- Source:
Returns:
- Type
- Object
toRaw() → {Buffer}
Serialize the account.
- Source:
Returns:
- Type
- Buffer