Class: Coins

coins~Coins()

Coins Represents the outputs for a single transaction.

Constructor

new Coins()

Create coins.

Properties:
Name Type Description
outputs Array.<Map>

Coins.

Source:

Methods

(static) fromTX(tx, height) → {Coins}

Instantiate a coins object from a transaction.

Parameters:
Name Type Description
tx TX
height Number
Source:
Returns:
Type
Coins

add(index, coin) → {CoinEntry}

Add a single entry to the collection.

Parameters:
Name Type Description
index Number
coin CoinEntry
Source:
Returns:
Type
CoinEntry

addCoin(coin) → {CoinEntry}

Add a single coin to the collection.

Parameters:
Name Type Description
coin Coin
Source:
Returns:
Type
CoinEntry

addIndex(tx, index, height) → {CoinEntry}

Add an output to the collection by output index.

Parameters:
Name Type Description
tx TX
index Number
height Number
Source:
Returns:
Type
CoinEntry

addOutput(index, output) → {CoinEntry}

Add a single output to the collection.

Parameters:
Name Type Description
index Number
output Output
Source:
Returns:
Type
CoinEntry

(private) fromTX(tx, height) → {Coins}

Inject properties from tx.

Parameters:
Name Type Description
tx TX
height Number
Source:
Returns:
Type
Coins

get(index) → {CoinEntry|null}

Get a coin entry.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
CoinEntry | null

getCoin(prevout) → {Coin|null}

Get a coin.

Parameters:
Name Type Description
prevout Outpoint
Source:
Returns:
Type
Coin | null

getOutput(index) → {Output|null}

Get an output.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
Output | null

has(index) → {Boolean}

Test whether the collection has a coin.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
Boolean

isEmpty() → {Boolean}

Test whether the coins are fully spent.

Source:
Returns:
Type
Boolean

isUnspent(index) → {Boolean}

Test whether the collection has an unspent coin.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
Boolean

remove(index) → {CoinEntry|null}

Remove a coin entry and return it.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
CoinEntry | null

spend(index) → {CoinEntry|null}

Spend a coin entry and return it.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
CoinEntry | null