Constructor
new Block(options)
Create a block.
Extends:
- AbstractBlock
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Extends
- AbstractBlock
Methods
(static) isBlock(obj) → {Boolean}
Test whether an object is a Block.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object |
- Source:
Returns:
- Type
- Boolean
checkBody() → {Array}
Do non-contextual verification on the block. Including checking the block size, the coinbase and the merkle root. This is consensus-critical.
- Source:
Returns:
[valid, reason, score]
- Type
- Array
createMerkleRoot() → {Hash}
Calculate merkle root.
- Source:
Returns:
- Type
- Hash
createWitnessRoot() → {Hash}
Calculate witness root.
- Source:
Returns:
- Type
- Hash
format(view, height) → {Object}
Inspect the block and return a more user-friendly representation of the data.
Parameters:
Name | Type | Description |
---|---|---|
view |
CoinView | |
height |
Number |
- Source:
Returns:
- Type
- Object
(private) fromJSON(json)
Inject properties from json object.
Parameters:
Name | Type | Description |
---|---|---|
json |
Object |
- Source:
(private) fromOptions(options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
getBaseSize() → {Number}
Get base block size (without witness).
- Source:
Returns:
size
- Type
- Number
getClaimed() → {Amount}
Get the "claimed" reward by the coinbase.
- Source:
Returns:
claimed
- Type
- Amount
getCoinbaseHeight() → {Number}
Retrieve the coinbase height from the coinbase input script.
- Source:
Returns:
height (-1 if not present).
- Type
- Number
getJSON(network, view, height, depth) → {Object}
Convert the block to an object suitable for JSON serialization.
Parameters:
Name | Type | Description |
---|---|---|
network |
Network | |
view |
CoinView | |
height |
Number | |
depth |
Number |
- Source:
Returns:
- Type
- Object
getMerkleRoot() → {Hash}
Retrieve the merkle root from the block header.
- Source:
Returns:
- Type
- Hash
getPrevout() → {Array.<Hash>}
Get all unique outpoint hashes in the block. Coinbases are ignored.
- Source:
Returns:
Outpoint hashes.
- Type
- Array.<Hash>
getSize() → {Number}
Get real block size.
- Source:
Returns:
size
- Type
- Number
getSizes() → {RawBlock}
Get real block size with witness.
- Source:
Returns:
- Type
- RawBlock
getVirtualSize() → {Number}
Calculate virtual block size.
- Source:
Returns:
Virtual size.
- Type
- Number
getWeight() → {Number}
Calculate block weight.
- Source:
Returns:
weight
- Type
- Number
hasTX(hash) → {Boolean}
Test the block's transaction vector against a hash.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
- Type
- Boolean
hasWitness() → {Boolean}
Test whether the block contains a transaction with a non-empty witness.
- Source:
Returns:
- Type
- Boolean
indexOf(hash) → {Number}
Find the index of a transaction in the block.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
index (-1 if not present).
- Type
- Number
(private) read(data)
Inject properties from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
refresh(allnullable)
Clear any cached values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
all |
Boolean |
<nullable> |
Clear transactions. |
- Source:
toHeaders() → {Headers}
Convert the block to a headers object.
- Source:
Returns:
- Type
- Headers
toMerkle(filter) → {MerkleBlock}
Convert the Block to a MerkleBlock.
Parameters:
Name | Type | Description |
---|---|---|
filter |
Bloom | Bloom filter for transactions to match. The merkle block will contain only the matched transactions. |
- Source:
Returns:
- Type
- MerkleBlock
verifyBody() → {Boolean}
Do non-contextual verification on the block. Including checking the block size, the coinbase and the merkle root. This is consensus-critical.
- Source:
Returns:
- Type
- Boolean