new TXDB(db, optionsnullable)
TXDB
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
db |
LowlevelUp | ||||||||||||||||||||||
options |
Object |
<nullable> |
Properties
|
- Source:
Methods
(private) _addOrphan(key, hash, index, callback)
Add an orphan (tx hash + input index) to orphan list. Stored by its required coin ID.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Required coin hash + index. |
hash |
Hash | Orphan transaction hash. |
index |
Number | Orphan input index. |
callback |
function | Returns [Error, Buffer]. |
- Source:
(private) _confirm(tx, map, callback)
Attempt to confirm a transaction.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
map |
AddressMap | |
callback |
function | Returns [Error, Boolean]. |
- Source:
(private) _getOrphans(key, callback)
Retrieve orphan list by coin ID.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | |
callback |
function | Returns [Error, Orphan]. |
- Source:
(private) _remove(tx, map, callback)
Remove a transaction from the database. Disconnect inputs.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
map |
AddressMap | |
callback |
function | Returns [Error]. |
- Source:
(private) _removeConflict(hash, ref, callback)
Remove spenders that have not been confirmed. We do this in the odd case of stuck transactions or when a coin is double-spent by a newer transaction. All previously-spending transactions of that coin that are not confirmed will be removed from the database.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
ref |
TX | Reference tx, the tx that double-spent. |
callback |
function | Returns [Error, Boolean]. |
- Source:
(private) _removeRecursive(tx, callback)
Remove a transaction and recursively remove all of its spenders.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | Transaction to be removed. |
callback |
function | Returns [Error, Boolean]. |
- Source:
_unconfirm(hash, map, callback)
Unconfirm a transaction. This is usually necessary after a reorg.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
map |
AddressMap | |
callback |
function |
- Source:
add(tx, callback)
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 | |
callback |
function | Returns [Error]. |
- Source:
fillCoins(tx, callback)
Fill a transaction with coins.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, TX]. |
- Source:
fillHistory(tx, callback)
Fill a transaction with coins (all historical coins).
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, TX]. |
- Source:
getBalance(idnullable, callback)
Calculate balance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, Balance]. |
- Source:
getCoin(hash, index, callback)
Get coin.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
index |
Number | |
callback |
function | Returns [Error, Coin]. |
- Source:
getCoinHashes(idnullable, callback)
Get all coin hashes in the database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, Hash[]]. |
- Source:
getCoins(idnullable, callback)
Get coins.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, Coin[]]. |
- Source:
getHeightHashes(height, callback)
Get TX hashes by height.
Parameters:
Name | Type | Description |
---|---|---|
height |
Number | |
callback |
function | Returns [Error, Hash[]]. |
- Source:
getHeightRangeHashes(idnullable, options, callback)
Get TX hashes by height range.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
WalletID |
<nullable> |
|||||||||||||||||||||
options |
Object |
Properties
|
|||||||||||||||||||||
callback |
function | Returns [Error, Hash[]]. |
- Source:
getHistory(idnullable, callback)
Get all transactions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, TX[]]. |
- Source:
getHistoryHashes(idnullable, callback)
Get hashes of all transactions in the database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, Hash[]]. |
- Source:
getLast(idnullable, limit, callback)
Get last N transactions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
limit |
Number | Max number of transactions. |
|
callback |
function | Returns [Error, TX[]]. |
- Source:
getLastTime(idnullable, callback)
Get last active timestamp and height.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, Number(ts), Number(height)]. |
- Source:
getMap(tx, callback)
Map a transactions' addresses to wallet IDs.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, AddressMap]. |
- Source:
getRange(idnullable, options, callback)
Get transactions by timestamp range.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
WalletID |
<nullable> |
|||||||||||||||||||||
options |
Object |
Properties
|
|||||||||||||||||||||
callback |
function | Returns [Error, TX[]]. |
- Source:
getRangeHashes(idnullable, options, callback)
Get TX hashes by timestamp range.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
WalletID |
<nullable> |
|||||||||||||||||||||
options |
Object |
Properties
|
|||||||||||||||||||||
callback |
function | Returns [Error, Hash[]]. |
- Source:
getTX(hash, callback)
Get transaction.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function | Returns [Error, TX]. |
- Source:
getUnconfirmed(idnullable, callback)
Get unconfirmed transactions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, TX[]]. |
- Source:
getUnconfirmedHashes(idnullable, callback)
Get hashes of all unconfirmed transactions in the database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
callback |
function | Returns [Error, Hash[]]. |
- Source:
hasCoin(hash, callback)
Test whether the database has a transaction.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function | Returns [Error, Boolean]. |
- Source:
hasTX(hash, callback)
Test whether the database has a transaction.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function | Returns [Error, Boolean]. |
- Source:
isDoubleSpend(tx, callback)
Test an entire transaction to see if any of its outpoints are a double-spend.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, Boolean]. |
- Source:
isSpent(hash, index, callback)
Test a whether a coin has been spent.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
index |
Number | |
callback |
function | Returns [Error, Boolean]. |
- Source:
lazyRemove(tx, callback)
Remove a transaction from the database, but do not look up the transaction. Use the passed-in transaction to disconnect.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error]. |
- Source:
mapAddresses(address, callback)
Map address hashes to a wallet ID.
Parameters:
Name | Type | Description |
---|---|---|
address |
Array.<Hash> | Address hashes. |
callback |
function | Returns [Error, AddressTable]. |
- Source:
remove(hash, callback)
Remove a transaction from the database. Disconnect inputs.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function | Returns [Error]. |
- Source:
unconfirm(hash, callback)
Unconfirm a transaction. This is usually necessary after a reorg.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function |
- Source:
zap(idnullable, age, callback)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
WalletID |
<nullable> |
|
age |
Number | Age delta (delete transactions older than |
|
callback |
function |
- Source: