Constructor
new Account(wdb, options)
Create an account.
Parameters:
Name | Type | Description |
---|---|---|
wdb |
WalletDB | |
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:
accountKey :HDPublicKey|null
Type:
- HDPublicKey | null
- Source:
id :String|null
Type:
- String | null
- Source:
keys :Array.<HDPublicKey>
Type:
- Array.<HDPublicKey>
- Source:
name :String|null
Type:
- String | null
- Source:
type :Account.types
Type:
- Account.types
- Source:
wdb :WalletDB
Type:
- Source:
Methods
(static) decode(wdb, data) → {Account}
Decode account.
Parameters:
Name | Type | Description |
---|---|---|
wdb |
WalletDB | |
data |
Buffer |
- Source:
Returns:
- Type
- Account
(static) fromOptions(wdb, options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
wdb |
WalletDB | |
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(b, key) → {Promise.<Boolean>}
Add a public account key to the account (multisig). Saves the key in the wallet database.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
key |
HDPublicKey |
- Source:
Returns:
- Type
- Promise.<Boolean>
changeAddress() → (nullable) {Address}
Get current change address.
- Source:
Returns:
- Type
- Address
changeKey() → (nullable) {WalletKey}
Get current change key.
- Source:
Returns:
- Type
- WalletKey
createChange(b) → {Promise.<WalletKey>}
Create a new change address (increments changeDepth).
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch |
- Source:
Returns:
- Type
- Promise.<WalletKey>
(async) createKey(b, branch) → {Promise.<WalletKey>}
Create a new address (increments depth).
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
branch |
Number |
- Source:
Returns:
- Returns WalletKey.
- Type
- Promise.<WalletKey>
createReceive(b) → {Promise.<WalletKey>}
Create a new receiving address (increments receiveDepth).
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch |
- Source:
Returns:
- Type
- Promise.<WalletKey>
deriveChange(index, masteropt) → {WalletKey}
Derive a change address at index
. Do not increment depth.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
index |
Number | ||
master |
MasterKey |
<optional> |
- Source:
Returns:
- Type
- WalletKey
deriveKey(branch, index, masteropt) → {WalletKey}
Derive an address at index
. Do not increment depth.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
branch |
Number | ||
index |
Number | ||
master |
MasterKey |
<optional> |
- Source:
Returns:
- Type
- WalletKey
derivePath(path, master) → (nullable) {WalletKey}
Derive an address from path
object.
Parameters:
Name | Type | Description |
---|---|---|
path |
Path | |
master |
MasterKey |
- Source:
Returns:
- Type
- WalletKey
deriveReceive(index, masteropt) → {WalletKey}
Derive a receiving address at index
. Do not increment depth.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
index |
Number | ||
master |
MasterKey |
<optional> |
- Source:
Returns:
- Type
- WalletKey
format() → {Object}
Convert the account to a more inspection-friendly object.
- Source:
Returns:
- Type
- Object
fromOptions(options) → {this}
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Returns:
- Type
- this
getJSON(balanceopt) → {Object}
Convert the account to an object suitable for serialization.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
balance |
Object |
<optional> |
null |
- Source:
Returns:
- Type
- Object
getSize() → {Number}
Calculate serialization size.
- Source:
Returns:
- Type
- Number
(async, private) hasDuplicate() → {Promise.<Boolean>}
Ensure accounts are not sharing keys.
- Source:
Returns:
- Type
- Promise.<Boolean>
(async) init(b) → {Promise}
Attempt to intialize the account (generating the first addresses along with the lookahead addresses). Called automatically from the walletdb.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch |
- Source:
Returns:
- Type
- Promise
(async) initDepth(b) → {Promise}
Initialize address depths (including lookahead).
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch |
- Source:
Returns:
- Type
- Promise
pushKey(key) → {Boolean}
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.
Returns:
- Whether the key was added.
- Type
- Boolean
read(br)
Inject properties from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
br |
bio.BufferReader |
- Source:
receiveAddress() → (nullable) {Address}
Get current receive address.
- Source:
Returns:
- Type
- Address
receiveKey() → (nullable) {WalletKey}
Get current receive key.
- Source:
Returns:
- Type
- WalletKey
removeSharedKey(b, key) → {Boolean}
Remove a public account key from the account (multisig). Remove the key from the wallet database.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
key |
HDPublicKey |
- Source:
Returns:
- Type
- Boolean
save(b) → {void}
Save the account to the database. Necessary when address depth and keys change.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch |
- Source:
Returns:
- Type
- void
saveKey(b, ring) → {Promise}
Save addresses to path map.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
ring |
WalletKey |
- Source:
Returns:
- Type
- Promise
savePath(b, path) → {Promise}
Save paths to path map.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
path |
Path |
- Source:
Returns:
- Type
- Promise
(async) setLookahead(b, lookahead) → {Promise}
Allocate new lookahead addresses.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
lookahead |
Number |
- Source:
Returns:
- Type
- Promise
spliceKey(key) → {Boolean}
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.
Returns:
- Whether the key was removed.
- Type
- Boolean
(async) syncDepth(b, receive, change) → {Promise.<?WalletKey>}
Allocate new lookahead addresses if necessary.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
receive |
Number | |
change |
Number |
- Source:
Returns:
- Type
- Promise.<?WalletKey>
write(bw) → {BufioWriter}
Serialize the account.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufioWriter |
- Source:
Returns:
- Type
- BufioWriter