Class: Coin

primitives~Coin(options)

Coin Represents an unspent output.

Constructor

new Coin(options)

Create a coin.

Extends:
  • Output
Parameters:
Name Type Description
options Object
Properties:
Name Type Description
version Number
height Number
value Amount
script Script
coinbase Boolean
hash Hash
index Number
Source:

Extends

  • Output

Methods

(static) fromJSON(json) → {Coin}

Instantiate an Coin from a jsonified coin object.

Parameters:
Name Type Description
json Object

The jsonified coin object.

Source:
Returns:
Type
Coin

(static) fromKey(key) → {Coin}

Instantiate coin from hash table key.

Parameters:
Name Type Description
key String
Source:
Returns:
Type
Coin

(private, static) fromOptions(options)

Instantiate Coin from options object.

Parameters:
Name Type Description
options Object
Source:

(static) fromRaw(data, encnullable) → {Coin}

Instantiate a coin from a serialized Buffer.

Parameters:
Name Type Attributes Description
data Buffer
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
Coin

(static) fromReader(br) → {Coin}

Instantiate a coin from a buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:
Returns:
Type
Coin

(static) fromTX(tx, index) → {Coin}

Instantiate a coin from a TX

Parameters:
Name Type Description
tx TX
index Number

Output index.

Source:
Returns:
Type
Coin

(static) isCoin(obj) → {Boolean}

Test an object to see if it is a Coin.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

(private) clone() → {Coin}

Clone the coin.

Source:
Returns:
Type
Coin

(private) fromJSON(json)

Inject JSON properties into coin.

Parameters:
Name Type Description
json Object
Source:

(private) fromKey(key) → {Coin}

Inject properties from hash table key.

Parameters:
Name Type Description
key String
Source:
Returns:
Type
Coin

(private) fromOptions(options)

Inject options into coin.

Parameters:
Name Type Description
options Object
Source:

(private) fromRaw(data)

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

(private) fromReader(br)

Inject properties from serialized buffer writer.

Parameters:
Name Type Description
br BufferReader
Source:

fromTX(tx, index)

Inject properties from TX.

Parameters:
Name Type Description
tx TX
index Number
Source:

getDepth(heightnullable) → {Number}

Calculate number of confirmations since coin was created.

Parameters:
Name Type Attributes Description
height Number <nullable>

Current chain height. Network height is used if not passed in.

Source:
Returns:
Type
Number

getJSON(network, minimal) → {Object}

Convert the coin to an object suitable for JSON serialization. Note that the hash will be reversed to abide by bitcoind's legacy of little-endian uint256s.

Parameters:
Name Type Description
network Network
minimal Boolean
Source:
Returns:
Type
Object

getSize() → {Number}

Calculate size of coin.

Source:
Returns:
Type
Number

inspectSymbol() → {Object}

Convert the coin to a more user-friendly object.

Source:
Returns:
Type
Object

rhash() → {Hash}

Get little-endian hash.

Source:
Returns:
Type
Hash

toJSON() → {Object}

Convert the coin to an object suitable for JSON serialization.

Source:
Returns:
Type
Object

toKey() → {String}

Serialize coin to a key suitable for a hash table.

Source:
Returns:
Type
String

toRaw() → {Buffer|String}

Serialize the coin.

Source:
Returns:
Type
Buffer | String

toWriter(bw)

Write the coin to a buffer writer.

Parameters:
Name Type Description
bw BufferWriter
Source:

txid() → {Hash}

Get little-endian hash.

Source:
Returns:
Type
Hash