Constructor
new CoinView()
Create a coin view.
Properties:
Name | Type | Description |
---|---|---|
map |
Object | |
undo |
UndoCoins |
- Source:
Methods
(static) fromReader(br, tx) → {CoinView}
Read serialized view data from a buffer reader as it pertains to a transaction.
Parameters:
Name | Type | Description |
---|---|---|
br |
BufferReader | |
tx |
TX |
- Source:
Returns:
- Type
- CoinView
add(hash, coins) → {Coins}
Add coins to the collection.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
coins |
Coins |
- Source:
Returns:
- Type
- Coins
addCoin(coin) → {CoinEntry|null}
Add a coin to the collection.
Parameters:
Name | Type | Description |
---|---|---|
coin |
Coin |
- Source:
Returns:
- Type
- CoinEntry | null
addEntry(prevout, coin) → {CoinEntry|null}
Add an entry to the collection.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint | |
coin |
CoinEntry |
- Source:
Returns:
- Type
- CoinEntry | null
addIndex(tx, index, height) → {CoinEntry|null}
Add an output to the collection by output index.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
index |
Number | |
height |
Number |
- Source:
Returns:
- Type
- CoinEntry | null
addOutput(prevout, output) → {CoinEntry|null}
Add an output to the collection.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint | |
output |
Output |
- Source:
Returns:
- Type
- CoinEntry | null
addTX(tx, height) → {Coins}
Add a tx to the collection.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
height |
Number |
- Source:
Returns:
- Type
- Coins
ensure(hash) → {Coins}
Ensure existence of coins object in the collection.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
- Type
- Coins
(private) fromReader(br, tx)
Read serialized view data from a buffer reader as it pertains to a transaction.
Parameters:
Name | Type | Description |
---|---|---|
br |
BufferReader | |
tx |
TX |
- Source:
get(hash) → {Coins}
Get coins.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
coins
- Type
- Coins
getCoin(prevout) → {Coin|null}
Get a single coin by prevout.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- Coin | null
getCoinFor(input) → {Coin|null}
Get a single coin by input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Input |
- Source:
Returns:
- Type
- Coin | null
getEntry(prevout) → {CoinEntry|null}
Get a single entry by prevout.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- CoinEntry | null
getEntryFor(input) → {CoinEntry|null}
Get a single entry by input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Input |
- Source:
Returns:
- Type
- CoinEntry | null
getHeight(prevout) → {Number}
Get coins height by prevout.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- Number
getHeightFor(input) → {Number}
Get coins height by input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Input |
- Source:
Returns:
- Type
- Number
getOutput(prevout) → {Output|null}
Get a single output by prevout.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- Output | null
getOutputFor(input) → {Output|null}
Get a single output by input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Input |
- Source:
Returns:
- Type
- Output | null
getSize() → {Number}
Calculate serialization size.
- Source:
Returns:
- Type
- Number
has(hash) → {Boolean}
Test whether the view has an entry.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
- Type
- Boolean
hasEntry(prevout) → {Boolean}
Test whether the view has an entry by prevout.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- Boolean
hasEntryFor(input) → {Boolean}
Test whether the view has an entry by input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Input |
- Source:
Returns:
- Type
- Boolean
isCoinbase(prevout) → {Boolean}
Get coins coinbase flag by prevout.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- Boolean
isCoinbaseFor(input) → {Boolean}
Get coins coinbase flag by input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Input |
- Source:
Returns:
- Type
- Boolean
isUnspent(prevout) → {Boolean}
Test whether an entry has been spent by prevout.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- Boolean
isUnspentFor(input) → {Boolean}
Test whether an entry has been spent by input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Input |
- Source:
Returns:
- Type
- Boolean
(async) readCoin(db, prevout) → {Promise}
Retrieve coins from database.
Parameters:
Name | Type | Description |
---|---|---|
db |
ChainDB | |
prevout |
Outpoint |
- Source:
Returns:
- Returns CoinEntry.
- Type
- Promise
(async) readInputs(db, tx) → {Promise}
Read all input coins into unspent map.
Parameters:
Name | Type | Description |
---|---|---|
db |
ChainDB | |
tx |
TX |
- Source:
Returns:
- Returns {Boolean}.
- Type
- Promise
remove(coins) → {Coins|null}
Remove coins from the collection.
Parameters:
Name | Type | Description |
---|---|---|
coins |
Coins |
- Source:
Returns:
- Type
- Coins | null
removeEntry(prevout) → {CoinEntry|null}
Remove an output.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- CoinEntry | null
removeTX(tx, height) → {Coins}
Remove a tx from the collection.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
height |
Number |
- Source:
Returns:
- Type
- Coins
spendEntry(prevout) → {CoinEntry|null}
Spend an output.
Parameters:
Name | Type | Description |
---|---|---|
prevout |
Outpoint |
- Source:
Returns:
- Type
- CoinEntry | null
(async) spendInputs(db, tx) → {Promise}
Spend coins for transaction.
Parameters:
Name | Type | Description |
---|---|---|
db |
ChainDB | |
tx |
TX |
- Source:
Returns:
- Returns {Boolean}.
- Type
- Promise
toWriter(bw, tx)
Write coin data to buffer writer as it pertains to a transaction.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufferWriter | |
tx |
TX |
- Source: