Constructor
new Coin(optionsopt, nullable)
Create a coin.
Extends:
- Output
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> <nullable> |
Properties:
Name | Type | Description |
---|---|---|
version |
Number | |
height |
Number | |
value |
Amount | |
script |
Script | |
coinbase |
Boolean | |
hash |
Hash | |
index |
Number |
- Source:
Extends
- Output
Methods
(static) fromKey(key) → {Coin}
Instantiate coin from hash table key.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Coin
(static) fromTX(tx, index, height) → {Coin}
Instantiate a coin from a TX
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
index |
Number | Output index. |
height |
Number | Chain height. |
- 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
clone() → {this}
Clone the coin.
- Source:
Returns:
- Type
- this
format() → {Object}
Convert the coin to a more user-friendly object.
- Source:
Returns:
- Type
- Object
fromJSON(json, networkopt, nullable)
Inject JSON properties into coin.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
json |
Object | ||
network |
NetworkType | Network |
<optional> <nullable> |
- Source:
fromKey(key) → {Coin}
Inject properties from hash table key.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer |
- Source:
Returns:
- Type
- Coin
fromOptions(optionsopt)
Inject options into coin.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
- Source:
fromTX(tx, index, height)
Inject properties from TX.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
index |
Number | |
height |
Number |
- Source:
getDepth(height) → {Number}
Calculate number of confirmations since coin was created.
Parameters:
Name | Type | Description |
---|---|---|
height |
Number | Current chain height. Network height is used if not passed in. |
- Source:
Returns:
- Type
- Number
getJSON(networkopt, minimalopt) → {Object}
Convert the coin to an object suitable for JSON serialization.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
network |
Network |
<optional> |
|
minimal |
Boolean |
<optional> |
- Source:
Returns:
- Type
- Object
getSize() → {Number}
Calculate size of coin.
- Source:
Returns:
- Type
- Number
read(br)
Inject properties from serialized buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
br |
BufferReader |
- Source:
toKey() → {Buffer}
Serialize coin to a key suitable for a hash table.
- Source:
Returns:
- Type
- Buffer
txid() → (nullable) {HexHash}
Get little-endian hash.
- Source:
Returns:
- Type
- HexHash
write(bw) → {BufioWriter}
Write the coin to a buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufioWriter |
- Source:
Returns:
- Type
- BufioWriter