new WalletDB(options)
Create a wallet db.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Methods
(async, private) _addBlock(entry, txs) → {Promise.<?AddBlockResult>}
Add a block's transactions without a lock.
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry | |
txs |
Array.<TX> |
- Source:
Returns:
- Type
- Promise.<?AddBlockResult>
(async, private) _addTX(tx, blockopt, extraopt) → {Promise.<?AddTXResult>}
Add a transaction to the database without a lock.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tx |
TX | ||
block |
BlockMeta |
<optional> |
|
extra |
BlockExtraInfo |
<optional> |
- Source:
Returns:
- Type
- Promise.<?AddTXResult>
(private) _bind()
Bind to node events.
- Source:
(async, private) _create(options) → {Promise.<Wallet>}
Create a new wallet, save to database without a lock.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | See Wallet. |
- Source:
Returns:
- Type
- Promise.<Wallet>
(async) _deepClean() → {Promise}
Deep Clean (without locks): Keep all keys, account data, wallet maps (name and path). Dump all TX history and balance state. A rescan will be required but is not initiated automatically.
- Source:
Returns:
- Type
- Promise
(async, private) _get(wid) → {Promise.<?Wallet>}
Get a wallet from the database without a lock.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number |
- Source:
Returns:
- Type
- Promise.<?Wallet>
(async) _recalculateBalances() → {Promise}
Recalculate balances from the coins (without a lock).
- Source:
Returns:
- Type
- Promise
(async, private) _remove(wid) → {Promise}
Remove a wallet (without a lock).
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number |
- Source:
Returns:
- Type
- Promise
(async, private) _removeBlock(entry) → {Promise.<Number>}
Unconfirm a block's transactions.
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry |
- Source:
Returns:
- number of txs removed.
- Type
- Promise.<Number>
(async, private) _rename(wallet, id) → {Promise}
Rename a wallet without a lock.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
id |
String |
- Source:
Returns:
- Type
- Promise
(async, private) _rescan(height) → {Promise}
Force a rescan (without a lock).
Parameters:
Name | Type | Description |
---|---|---|
height |
Number |
- Source:
Returns:
- Type
- Promise
(async, private) _resetChain(entry) → {Promise}
Handle a chain reset without a lock.
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry |
- Source:
Returns:
- Type
- Promise
(async) addBlock(entry, txs) → {Promise.<?AddBlockResult>}
Add a block's transactions and write the new best hash.
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry | |
txs |
Array.<TX> |
- Source:
Returns:
- Type
- Promise.<?AddBlockResult>
(async) addBlockMap(wallet, key, wid)
Add wid to a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(private) addFilter(data) → {Promise}
Add data to remote filter.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
Returns:
- Type
- Promise
(private) addHash(hash)
Add hash to local and remote filters.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
(async) addMap(wallet, key, wid)
Add wid to a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(private) addName(nameHash)
Add hash to local and remote filters.
Parameters:
Name | Type | Description |
---|---|---|
nameHash |
Hash |
- Source:
(async) addNameMap(wallet, key, wid)
Add wid to a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(private) addOutpoint(hash, index)
Add outpoint to local filter.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
index |
Number |
- Source:
(async) addOutpointMap(wallet, key, wid)
Add wid to a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) addPathMap(wallet, key, wid)
Add wid to a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) addTX(tx) → {Promise.<?AddTXResult>}
Add a transaction to the database, map addresses to wallet IDs, potentially store orphans, resolve orphans, or confirm a transaction.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX |
- Source:
Returns:
- Type
- Promise.<?AddTXResult>
(async) addTXMap(wallet, key, wid)
Add wid to a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) auth(id, token) → {Promise}
Get a wallet with token auth first.
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | String | |
token |
Buffer |
- Source:
Returns:
- Returns Wallet.
- Type
- Promise
backup(path) → {Promise}
Backup the wallet db.
Parameters:
Name | Type | Description |
---|---|---|
path |
String |
- Source:
Returns:
- Type
- Promise
(async) close() → {Promise}
Close the walletdb, wait for the database to close.
- Source:
Returns:
- Type
- Promise
(async) connect() → {Promise}
Connect to the node server (client required).
- Source:
Returns:
- Type
- Promise
(async) create(options) → {Promise.<Wallet>}
Create a new wallet, save to database, setup watcher.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | See Wallet. |
- Source:
Returns:
- Type
- Promise.<Wallet>
(async) decryptKeys(wid, key) → {Promise}
Decrypt all imported keys for a wallet.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) deepClean() → {Promise}
Deep Clean: Keep all keys, account data, wallet maps (name and path). Dump all TX history and balance state. A rescan will be required but is not initiated automatically.
- Source:
Returns:
- Type
- Promise
(async) disconnect() → {Promise}
Disconnect from node server (client required).
- Source:
Returns:
- Type
- Promise
dump() → {Promise}
Dump database (for debugging).
- Source:
Returns:
- Returns Object.
- Type
- Promise
(async) encryptKeys(wid, key) → {Promise}
Encrypt all imported keys for a wallet.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) ensure(options) → {Promise}
Attempt to create wallet, return wallet if already exists.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | See Wallet. |
- Source:
Returns:
- Type
- Promise
(async) ensureWID(id) → {Promise.<Number>}
Map wallet id to wid.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | Number |
- Source:
Returns:
- Type
- Promise.<Number>
(async) estimateFee(blocks) → {Promise}
Estimate smart fee from chain server.
Parameters:
Name | Type | Description |
---|---|---|
blocks |
Number |
- Source:
Returns:
- Type
- Promise
(async) get(id) → {Promise.<?Wallet>}
Get a wallet from the database, setup watcher.
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | String |
- Source:
Returns:
- Type
- Promise.<?Wallet>
(async, private) getAccount(wid, index) → {Promise}
Get an account from the database by wid.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
index |
Number | Account index. |
- Source:
Returns:
- Returns Wallet.
- Type
- Promise
(async) getAccountHashes(wid, account) → {Promise}
Get all account address hashes.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
account |
Number |
- Source:
Returns:
- Type
- Promise
(async) getAccountIndex(wid, name) → {Promise}
Lookup the corresponding account name's index.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
name |
String | Account name/index. |
- Source:
Returns:
- Returns Number.
- Type
- Promise
(async) getAccountName(wid, index) → {Promise}
Lookup the corresponding account index's name.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
index |
Number |
- Source:
Returns:
- Returns Number.
- Type
- Promise
(async) getAccounts(wid) → {Promise}
List account names and indexes from the db.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number |
- Source:
Returns:
- Returns Array.
- Type
- Promise
(async) getBlock(height) → {Promise.<?BlockMeta>}
Get a wallet block meta.
Parameters:
Name | Type | Description |
---|---|---|
height |
Number |
- Source:
Returns:
- Type
- Promise.<?BlockMeta>
(async) getBlockMap(key) → {Promise}
Get a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) getBlockTime(height) → {Promise.<?Number>}
Get block time.
Parameters:
Name | Type | Description |
---|---|---|
height |
Number |
- Source:
Returns:
- Type
- Promise.<?Number>
(async) getCoin(hash, index) → {Object}
Get UTXO from node.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
index |
Number |
- Source:
Returns:
- Type
- Object
(async, private) getDepth() → {Promise}
Get current wallet wid depth.
- Source:
Returns:
- Type
- Promise
(async) getHashes() → {Promise}
Get all address hashes.
- Source:
Returns:
- Type
- Promise
(async) getID(wid) → {Promise.<?String>}
Map wallet wid to id.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number |
- Source:
Returns:
- Type
- Promise.<?String>
(async) getMap(key) → {Promise}
Get a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) getMedianTime(height, timeopt) → {Promise.<Number>}
Calculate median time past.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
height |
Number | ||
time |
Number |
<optional> |
- Source:
Returns:
- Type
- Promise.<Number>
(async) getNameMap(key) → {Promise}
Get a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) getNameStatus(nameHash) → {Object}
Get name state.
Parameters:
Name | Type | Description |
---|---|---|
nameHash |
Buffer |
- Source:
Returns:
- Type
- Object
(async) getOutpointMap(key) → {Promise}
Get a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) getOutpoints() → {Promise}
Get all outpoints.
- Source:
Returns:
- Type
- Promise
(async) getPath(wid, hash) → {Promise}
Retrieve path by hash.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
hash |
Hash |
- Source:
Returns:
- Type
- Promise
(async) getPathMap(key) → {Promise}
Get a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) getRenewalBlock() → {Buffer}
Get renewal block hash.
- Source:
Returns:
- Type
- Buffer
(async) getState() → {Promise}
Get the best block hash.
- Source:
Returns:
- Type
- Promise
(async) getTip(hash) → {Promise.<BlockMeta>}
Get wallet tip.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
- Type
- Promise.<BlockMeta>
(async) getTXMap(key) → {Promise}
Get a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Promise
(async) getWalletHashes(wid) → {Promise}
Get all address hashes.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number |
- Source:
Returns:
- Type
- Promise
(async) getWalletPaths(wid) → {Promise}
Get all paths for a wallet.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number |
- Source:
Returns:
- Type
- Promise
(async) getWallets() → {Promise.<Array.<String>>}
Get all wallet names.
- Source:
Returns:
- Type
- Promise.<Array.<String>>
(async) getWalletsByTX(hashes) → {Promise}
Get all wallet ids by output addresses and outpoints.
Parameters:
Name | Type | Description |
---|---|---|
hashes |
Array.<Hash> |
- Source:
Returns:
- Type
- Promise
(async) getWID(id) → {Promise.<Number>}
Map wallet id to wid.
Parameters:
Name | Type | Description |
---|---|---|
id |
String |
- Source:
Returns:
- Type
- Promise.<Number>
(async) has(id) → {Promise}
Test for the existence of a wallet.
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | String |
- Source:
Returns:
- Type
- Promise
(async) hasAccount(wid, acct) → {Promise}
Test for the existence of an account.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
acct |
String | Number |
- Source:
Returns:
- Returns Boolean.
- Type
- Promise
(async) hasMap(key, wid) → {Promise.<Boolean>}
Does wdb have wallet map.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer | |
wid |
Number |
- Source:
Returns:
- Type
- Promise.<Boolean>
(async) hasNameMap(nameHash, wid) → {Promise.<Boolean>}
Has wid in the wallet map.
Parameters:
Name | Type | Description |
---|---|---|
nameHash |
Buffer | |
wid |
Number |
- Source:
Returns:
- Type
- Promise.<Boolean>
(async) hasPath(wid, hash) → {Promise}
Test whether a wallet contains a path.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
hash |
Hash |
- Source:
Returns:
- Type
- Promise
increment(b, wid)
Increment the wid depth.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
wid |
Number |
- Source:
(private) init()
Initialize walletdb.
- Source:
(async) isAvailable(nameHash) → {Boolean}
Test whether name is available for CLAIM.
Parameters:
Name | Type | Description |
---|---|---|
nameHash |
Buffer |
- Source:
Returns:
- Type
- Boolean
liveHeight() → {Number}
Will return the current height and will increment to the current height of a block currently being added to the wallet.
- Source:
Returns:
- Type
- Number
(async) loadState() → {Promise}
Recover state from the cache.
- Source:
Returns:
- Type
- Promise
(async) open() → {Promise}
Open the walletdb, wait for the database to load.
- Source:
Returns:
- Type
- Promise
(async) preloadAll() → {Promise}
Preload all wallets.
- Source:
Returns:
- Type
- Promise
(async) readPath(wid, hash) → {Promise}
Retrieve path by hash.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number | |
hash |
Hash |
- Source:
Returns:
- Type
- Promise
(async) recalculateBalances() → {Promise}
Recalculate balances from the coins.
- Source:
Returns:
- Type
- Promise
register(object)
Register an object with the walletdb.
Parameters:
Name | Type | Description |
---|---|---|
object |
Object |
- Source:
(async) remove(id) → {Promise}
Remove a wallet.
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | String |
- Source:
Returns:
- Type
- Promise
(async) removeBlock(entry) → {Promise.<Number>}
Unconfirm a block's transactions and write the new best hash (SPV version).
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry |
- Source:
Returns:
- number of txs removed.
- Type
- Promise.<Number>
(async) removeBlockMap(wallet, key, wid)
Remove wid from a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) removeMap(wallet, key, wid)
Remove wid from a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) removeNameMap(wallet, key, wid)
Remove wid from a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) removeOutpointMap(wallet, key, wid)
Remove wid from a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) removePathMap(wallet, key, wid)
Remove wid from a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) removeTXMap(wallet, key, wid)
Remove wid from a wallet map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
key |
Buffer | |
wid |
Number |
- Source:
(async) rename(wallet, id) → {Promise}
Rename a wallet.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
id |
String |
- Source:
Returns:
- Type
- Promise
renameAccount(account, name)
Rename an account.
Parameters:
Name | Type | Description |
---|---|---|
account |
Account | |
name |
String |
- Source:
(async) rescan(height) → {Promise}
Force a rescan.
Parameters:
Name | Type | Description |
---|---|---|
height |
Number |
- Source:
Returns:
- Type
- Promise
(async, private) rescanBlock(entry, txs) → {Promise}
Rescan a block.
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry | |
txs |
Array.<TX> |
- Source:
Returns:
- Type
- Promise
(async) rescanBlockInteractive(entry, txs) → {Promise.<ScanAction>}
Rescan a block interactively.
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry | |
txs |
Array.<TX> |
- Source:
Returns:
- interactive action
- Type
- Promise.<ScanAction>
(async) resend() → {Promise}
Resend all pending transactions.
- Source:
Returns:
- Type
- Promise
(async, private) resendPending(wid) → {Promise}
Resend all pending transactions for a specific wallet.
Parameters:
Name | Type | Description |
---|---|---|
wid |
Number |
- Source:
Returns:
- Type
- Promise
(async) resetChain(entry) → {Promise}
Handle a chain reset.
Parameters:
Name | Type | Description |
---|---|---|
entry |
ChainEntry |
- Source:
Returns:
- Type
- Promise
(private) resetFilter() → {Promise}
Reset remote filter.
- Source:
Returns:
- Type
- Promise
(async) revert(target) → {Promise.<Number>}
Revert TXDB to an older state.
Parameters:
Name | Type | Description |
---|---|---|
target |
Number |
- Source:
Returns:
- Type
- Promise.<Number>
(async) rollback(height) → {Promise}
Sync with chain height.
Parameters:
Name | Type | Description |
---|---|---|
height |
Number |
- Source:
Returns:
- Type
- Promise
save(wallet)
Save a wallet to the database.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet |
- Source:
saveAccount(account) → {Promise}
Save an account to the database.
Parameters:
Name | Type | Description |
---|---|---|
account |
Account |
- Source:
Returns:
- Type
- Promise
(async) saveGenesis() → {Promise}
Add genesis block.
- Source:
Returns:
- Type
- Promise
(async) saveKey(wallet, ring) → {Promise}
Save an address to the path map.
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
ring |
WalletKey |
- Source:
Returns:
- Type
- Promise
(async) savePath(wallet, path) → {Promise}
Save a path to the path map.
The path map exists in the form of:
p[address-hash] -> wid map
P[wid][address-hash] -> path data
r[wid][account-index][address-hash] -> dummy
Parameters:
Name | Type | Description |
---|---|---|
wallet |
Wallet | |
path |
Path |
- Source:
Returns:
- Type
- Promise
(async, private) scan(heightopt) → {Promise}
Rescan blockchain from a given height. Needs this.rescanning = true to be set from the caller.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
height |
Number |
<optional> |
this.state.startHeight |
- Source:
Returns:
- Type
- Promise
(async, private) scanInteractive(heightopt, fullLockopt) → {Promise}
Interactive scan blockchain from a given height. Expect this.rescanning to be set to true.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
height |
Number |
<optional> |
this.state.startHeight | |
fullLock |
Boolean |
<optional> |
true |
- Source:
Returns:
- Type
- Promise
(async) send(tx) → {Promise}
Broadcast a transaction via chain server.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX |
- Source:
Returns:
- Type
- Promise
(async) sendClaim(claim) → {Promise}
Broadcast a claim via chain server.
Parameters:
Name | Type | Description |
---|---|---|
claim |
Claim |
- Source:
Returns:
- Type
- Promise
(async) setTip(tip, checkMark) → {Promise}
Sync the current chain state to tip.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
tip |
BlockMeta | ||
checkMark |
Boolean | false | should we check startHeight/mark. This should only happen if we are progressing forward in history and have txs. |
- Source:
Returns:
- Type
- Promise
(async, private) syncChain() → {Promise}
Connect and sync with the chain server. Part of syncNode.
- Source:
Returns:
- Type
- Promise
(private) syncFilter() → {Promise}
Send filter to the remote node.
- Source:
Returns:
- Type
- Promise
(async) syncInitState() → {Promise}
Initialize and write initial sync state.
- Source:
Returns:
- Type
- Promise
(async) syncNode() → {Promise}
Sync state with server on every connect.
- Source:
Returns:
- Type
- Promise
(private) testFilter(hash) → {Boolean}
Test the bloom filter against a tx or address hash.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
- Type
- Boolean
unregister(object) → {Boolean}
Unregister a object with the walletdb.
Parameters:
Name | Type | Description |
---|---|---|
object |
Object |
- Source:
Returns:
- Type
- Boolean
(async) verifyNetwork() → {Promise}
Verify network.
- Source:
Returns:
- Type
- Promise
(async, private) watch() → {Promise}
Watch addresses and outpoints.
- Source:
Returns:
- Type
- Promise
(async) wipe() → {Promise}
Wipe the txdb - NEVER USE.
- Source:
Returns:
- Type
- Promise
writeVersion(b, version)
Write chaindb version.
Parameters:
Name | Type | Description |
---|---|---|
b |
Batch | |
version |
Number |
- Source: