Class: Coins

coins.Coins

new Coins(optionsnullable)

Represents the outputs for a single transaction.

Parameters:
Name Type Attributes Description
options Object <nullable>

Options object.

Properties:
Name Type Description
hash Hash

Transaction hash.

version Number

Transaction version.

height Number

Transaction height (-1 if unconfirmed).

coinbase Boolean

Whether the containing transaction is a coinbase.

outputs Array:.<CoinEntry:>

Coins.

Source:

Methods

(static) fromOptions(options) → {Coins}

Instantiate coins from options object.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
Coins

(static) fromRaw(data, hash) → {Coins}

Instantiate coins from a buffer.

Parameters:
Name Type Description
data Buffer
hash Hash

Transaction hash.

Source:
Returns:
Type
Coins

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

Instantiate a coins object from a transaction.

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

(static) parseCoin(data, hash, index) → {Coin}

Parse a single serialized coin.

Parameters:
Name Type Description
data Buffer
hash Hash
index Number
Source:
Returns:
Type
Coin

add(index, entry)

Add a single entry to the collection.

Parameters:
Name Type Description
index Number
entry CoinEntry
Source:

addCoin(coin)

Add a single coin to the collection.

Parameters:
Name Type Description
coin Coin
Source:

addOutput(index, output)

Add a single output to the collection.

Parameters:
Name Type Description
index Number
output Output
Source:

cleanup()

Cleanup spent outputs (remove pruned).

Source:

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) fromRaw(data, hash) → {Coins}

Inject data from serialized coins.

Parameters:
Name Type Description
data Buffer
hash Hash
Source:
Returns:
Type
Coins

(private) fromTX(tx, height)

Inject properties from tx.

Parameters:
Name Type Description
tx TX
height Number
Source:

get(index) → {CoinEntry}

Get a coin entry.

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

getCoin(index) → {Coin}

Get a coin.

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

getOutput(index) → {Output}

Get an output.

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

getSize(code, size, len) → {Number}

Calculate coins size.

Parameters:
Name Type Description
code Number
size Number
len Number
Source:
Returns:
Type
Number

has(index) → {Boolean}

Test whether the collection has a coin.

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

Calculate header code.

Parameters:
Name Type Description
len Number
size Number
Source:
Returns:
Type
Number

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

length() → {Number}

Calculate unspent length of coins.

Source:
Returns:
Type
Number

remove(index) → {CoinEntry}

Remove a coin entry and return it.

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

spend(index) → {CoinEntry}

Spend a coin entry and return it.

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

toRaw() → {Buffer}

Serialize the coins object.

Source:
Returns:
Type
Buffer