You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

5200 lines
58 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Block</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Block</h1>
<section>
<header>
<h2>Block</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Block"><span class="type-signature"></span>new Block<span class="signature">(data)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Represents a full block.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type"><a href="global.html#NakedBlock">NakedBlock</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>&quot;block&quot; (inv type).</p></td>
</tr>
<tr>
<td class="name"><code>version</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Block version. Note
that BCoin reads versions as unsigned despite
them being signed on the protocol level. This
number will never be negative.</p></td>
</tr>
<tr>
<td class="name"><code>prevBlock</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Previous block hash.</p></td>
</tr>
<tr>
<td class="name"><code>merkleRoot</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Merkle root hash.</p></td>
</tr>
<tr>
<td class="name"><code>ts</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Timestamp.</p></td>
</tr>
<tr>
<td class="name"><code>bits</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>nonce</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>totalTX</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Transaction count.</p></td>
</tr>
<tr>
<td class="name"><code>height</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Block height (-1 if not in the chain).</p></td>
</tr>
<tr>
<td class="name"><code>txs</code></td>
<td class="type">
<span class="param-type">Array.&lt;<a href="TX.html">TX</a>></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Transaction vector.</p></td>
</tr>
<tr>
<td class="name"><code>commitmentHash</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Commitment hash for segwit.</p></td>
</tr>
<tr>
<td class="name"><code>witnessNonce</code></td>
<td class="type">
<span class="param-type">Buffer</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Witness nonce for segwit.</p></td>
</tr>
<tr>
<td class="name"><code>rhash</code></td>
<td class="type">
<span class="param-type"><a href="global.html#ReversedHash">ReversedHash</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Reversed block hash (uint256le).</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line37">line 37</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li><a href="AbstractBlock.html">AbstractBlock</a></li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".fromJSON"><span class="type-signature">(static) </span>fromJSON<span class="signature">(json)</span><span class="type-signature"> &rarr; {<a href="Block.html">Block</a>}</span></h4>
<div class="description">
<p>Instantiate a block from a jsonified block object.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>json</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>The jsonified block object.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line631">line 631</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Block.html">Block</a></span>
</dd>
</dl>
<h4 class="name" id=".fromRaw"><span class="type-signature">(static) </span>fromRaw<span class="signature">(data, enc<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {<a href="Block.html">Block</a>}</span></h4>
<div class="description">
<p>Instantiate a block from a serialized Buffer.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Buffer</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>enc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Encoding, can be <code>'hex'</code> or null.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line672">line 672</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Block.html">Block</a></span>
</dd>
</dl>
<h4 class="name" id=".isBlock"><span class="type-signature">(static) </span>isBlock<span class="signature">(obj)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<div class="description">
<p>Test whether an object is a Block.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>obj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line694">line 694</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id=".parseJSON"><span class="type-signature">(static) </span>parseJSON<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<div class="description">
<p>Handle a deserialized JSON transaction object.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line615">line 615</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>A &quot;naked&quot; block (a
plain javascript object which is suitable
for passing to the Block constructor).</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id=".parseRaw"><span class="type-signature">(static) </span>parseRaw<span class="signature">(data, enc<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
<div class="description">
<p>Parse a serialized block.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Buffer</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>enc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Encoding, can be <code>'hex'</code> or null.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line658">line 658</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>A &quot;naked&quot; block object.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id=".reward"><span class="type-signature">(static) </span>reward<span class="signature">(height)</span><span class="type-signature"> &rarr; {<a href="global.html#Amount">Amount</a>}</span></h4>
<div class="description">
<p>Calculate block subsidy.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>height</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last"><p>Reward era by height.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line506">line 506</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#Amount">Amount</a></span>
</dd>
</dl>
<h4 class="name" id="abbr"><span class="type-signature"></span>abbr<span class="signature">()</span><span class="type-signature"> &rarr; {Buffer}</span></h4>
<div class="description">
<p>Serialize the block headers.</p>
</div>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="AbstractBlock.html#abbr">AbstractBlock#abbr</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_abstractblock.js.html">bcoin/abstractblock.js</a>, <a href="bcoin_abstractblock.js.html#line87">line 87</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
</dd>
</dl>
<h4 class="name" id="addTX"><span class="type-signature"></span>addTX<span class="signature">(tx)</span><span class="type-signature"> &rarr; {<a href="TX.html">TX</a>}</span></h4>
<div class="description">
<p>Add a transaction to the block's tx vector.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>tx</code></td>
<td class="type">
<span class="param-type"><a href="TX.html">TX</a></span>
|
<span class="param-type"><a href="global.html#NakedTX">NakedTX</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line212">line 212</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="TX.html">TX</a></span>
</dd>
</dl>
<h4 class="name" id="getBaseSize"><span class="type-signature"></span>getBaseSize<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4>
<div class="description">
<p>Get base block size (without witness).</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line181">line 181</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>size</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="getClaimed"><span class="type-signature"></span>getClaimed<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#Amount">Amount</a>}</span></h4>
<div class="description">
<p>Get the &quot;claimed&quot; reward by the coinbase.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line494">line 494</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>claimed</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#Amount">Amount</a></span>
</dd>
</dl>
<h4 class="name" id="getCoinbaseHeight"><span class="type-signature"></span>getCoinbaseHeight<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4>
<div class="description">
<p>Retrieve the coinbase height from the coinbase input script.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line436">line 436</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>height (-1 if not present).</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="getCommitmentHash"><span class="type-signature"></span>getCommitmentHash<span class="signature">(enc<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {Buffer|<a href="global.html#Hash">Hash</a>}</span></h4>
<div class="description">
<p>Calculate commitment hash (the root of the
witness merkle tree hashed with the witnessNonce).</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>enc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Encoding, can be <code>'hex'</code> or null.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line285">line 285</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>hash</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
|
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
</dd>
</dl>
<h4 class="name" id="getCost"><span class="type-signature"></span>getCost<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4>
<div class="description">
<p>Calculate block cost.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line161">line 161</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>cost</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="getMerkleRoot"><span class="type-signature"></span>getMerkleRoot<span class="signature">(enc<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {Buffer|<a href="global.html#Hash">Hash</a>}</span></h4>
<div class="description">
<p>Calculate merkle root.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>enc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Encoding, can be <code>'hex'</code> or null.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line261">line 261</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>hash</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
|
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
</dd>
</dl>
<h4 class="name" id="getPrevout"><span class="type-signature"></span>getPrevout<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="global.html#Hash">Hash</a>>}</span></h4>
<div class="description">
<p>Get all unique outpoint hashes in the
block. Coinbases are ignored.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line536">line 536</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Outpoint hashes.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;<a href="global.html#Hash">Hash</a>></span>
</dd>
</dl>
<h4 class="name" id="getRaw"><span class="type-signature"></span>getRaw<span class="signature">()</span><span class="type-signature"> &rarr; {Buffer}</span></h4>
<div class="description">
<p>Get the raw block serialization.
Include witnesses if present.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line99">line 99</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
</dd>
</dl>
<h4 class="name" id="getReward"><span class="type-signature"></span>getReward<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#Amount">Amount</a>}</span></h4>
<div class="description">
<p>Calculate the block reward.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line463">line 463</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>reward</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#Amount">Amount</a></span>
</dd>
</dl>
<h4 class="name" id="getSize"><span class="type-signature"></span>getSize<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4>
<div class="description">
<p>Get real block size.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line172">line 172</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>size</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="getSizes"><span class="type-signature"></span>getSizes<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<div class="description">
<p>Calculate real size and size of the witness bytes.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line127">line 127</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Contains <code>size</code> and <code>witnessSize</code>.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="getVirtualSize"><span class="type-signature"></span>getVirtualSize<span class="signature">()</span><span class="type-signature"> &rarr; {Number}</span></h4>
<div class="description">
<p>Calculate virtual block size.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line151">line 151</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Virtual size.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="hash"><span class="type-signature"></span>hash<span class="signature">(enc<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {<a href="global.html#Hash">Hash</a>|Buffer}</span></h4>
<div class="description">
<p>Hash the block headers.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>enc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Can be <code>'hex'</code> or <code>null</code>.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="AbstractBlock.html#hash">AbstractBlock#hash</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_abstractblock.js.html">bcoin/abstractblock.js</a>, <a href="bcoin_abstractblock.js.html#line70">line 70</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>hash</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
|
<span class="param-type">Buffer</span>
</dd>
</dl>
<h4 class="name" id="hasTX"><span class="type-signature"></span>hasTX<span class="signature">(hash)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<div class="description">
<p>Test the block's transaction vector against a hash.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>hash</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
|
<span class="param-type"><a href="TX.html">TX</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line231">line 231</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="hasWitness"><span class="type-signature"></span>hasWitness<span class="signature">()</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<div class="description">
<p>Test whether the block contains a
transaction with a non-empty witness.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line192">line 192</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="indexOf"><span class="type-signature"></span>indexOf<span class="signature">(hash)</span><span class="type-signature"> &rarr; {Number}</span></h4>
<div class="description">
<p>Find the index of a transaction in the block.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>hash</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Hash">Hash</a></span>
|
<span class="param-type"><a href="TX.html">TX</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line241">line 241</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>index (-1 if not present).</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="inspect"><span class="type-signature"></span>inspect<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<div class="description">
<p>Inspect the block and return a more
user-friendly representation of the data.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line561">line 561</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="render"><span class="type-signature"></span>render<span class="signature">()</span><span class="type-signature"> &rarr; {Buffer}</span></h4>
<div class="description">
<p>Serialize the block. Include witnesses if present.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line67">line 67</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
</dd>
</dl>
<h4 class="name" id="renderNormal"><span class="type-signature"></span>renderNormal<span class="signature">()</span><span class="type-signature"> &rarr; {Buffer}</span></h4>
<div class="description">
<p>Serialize the block, do not include witnesses.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line76">line 76</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
</dd>
</dl>
<h4 class="name" id="renderWitness"><span class="type-signature"></span>renderWitness<span class="signature">()</span><span class="type-signature"> &rarr; {Buffer}</span></h4>
<div class="description">
<p>Serialize the block. Include witnesses if present.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line87">line 87</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
</dd>
</dl>
<h4 class="name" id="setHeight"><span class="type-signature"></span>setHeight<span class="signature">(height)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Set the <code>height</code> property and the <code>height</code>
property of all transactions within the block.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>height</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="AbstractBlock.html#setHeight">AbstractBlock#setHeight</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_abstractblock.js.html">bcoin/abstractblock.js</a>, <a href="bcoin_abstractblock.js.html#line145">line 145</a>
</li></ul></dd>
</dl>
<h4 class="name" id="toInv"><span class="type-signature"></span>toInv<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#InvItem">InvItem</a>}</span></h4>
<div class="description">
<p>Convert the block to an inv item.</p>
</div>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="AbstractBlock.html#toInv">AbstractBlock#toInv</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_abstractblock.js.html">bcoin/abstractblock.js</a>, <a href="bcoin_abstractblock.js.html#line166">line 166</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#InvItem">InvItem</a></span>
</dd>
</dl>
<h4 class="name" id="toJSON"><span class="type-signature"></span>toJSON<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
<div class="description">
<p>Convert the block to an object suitable
for JSON serialization. Note that the hashes
will be reversed to abide by bitcoind's legacy
of little-endian uint256s.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line590">line 590</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="toMerkle"><span class="type-signature"></span>toMerkle<span class="signature">(filter)</span><span class="type-signature"> &rarr; {<a href="MerkleBlock.html">MerkleBlock</a>}</span></h4>
<div class="description">
<p>Convert the Block to a MerkleBlock.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filter</code></td>
<td class="type">
<span class="param-type"><a href="Bloom.html">Bloom</a></span>
</td>
<td class="description last"><p>Bloom filter for transactions
to match. The merkle block will contain only the
matched transactions.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line684">line 684</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="MerkleBlock.html">MerkleBlock</a></span>
</dd>
</dl>
<h4 class="name" id="toRaw"><span class="type-signature"></span>toRaw<span class="signature">(enc<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {Buffer|String}</span></h4>
<div class="description">
<p>Serialize the block.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>enc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Encoding, can be <code>'hex'</code> or null.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line642">line 642</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li>{<a href="Block.html#render">Block#render</a>}</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Buffer</span>
|
<span class="param-type">String</span>
</dd>
</dl>
<h4 class="name" id="verify"><span class="type-signature"></span>verify<span class="signature">(ret<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<div class="description">
<p>Do non-contextual verification on the block. Including checking the block
size, the coinbase and the merkle root. This is consensus-critical.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>ret</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Return object, may be
set with properties <code>reason</code> and <code>score</code>.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="AbstractBlock.html#verify">AbstractBlock#verify</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_block.js.html">bcoin/block.js</a>, <a href="bcoin_block.js.html#line361">line 361</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="verifyHeaders"><span class="type-signature"></span>verifyHeaders<span class="signature">(ret<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<div class="description">
<p>Verify the block headers (called by <code>verify()</code> in
all objects which inherit from AbstractBlock).</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>ret</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Return object, may be
set with properties <code>reason</code> and <code>score</code>.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="AbstractBlock.html#verifyHeaders">AbstractBlock#verifyHeaders</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bcoin_abstractblock.js.html">bcoin/abstractblock.js</a>, <a href="bcoin_abstractblock.js.html#line118">line 118</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-bcoin.html">bcoin</a></li><li><a href="module-constants.html">constants</a></li><li><a href="module-ec.html">ec</a></li><li><a href="module-ldb.html">ldb</a></li><li><a href="module-network.html">network</a></li><li><a href="module-profiler.html">profiler</a></li><li><a href="module-request.html">request</a></li><li><a href="module-uri.html">uri</a></li><li><a href="module-utils.html">utils</a></li></ul><h3>Classes</h3><ul><li><a href="AbstractBlock.html">AbstractBlock</a></li><li><a href="Account.html">Account</a></li><li><a href="Address.html">Address</a></li><li><a href="AES.html">AES</a></li><li><a href="Block.html">Block</a></li><li><a href="Bloom.html">Bloom</a></li><li><a href="BroadcastItem.html">BroadcastItem</a></li><li><a href="BST.html">BST</a></li><li><a href="BufferReader.html">BufferReader</a></li><li><a href="BufferWriter.html">BufferWriter</a></li><li><a href="Chain.html">Chain</a></li><li><a href="ChainDB.html">ChainDB</a></li><li><a href="ChainEntry.html">ChainEntry</a></li><li><a href="Coin.html">Coin</a></li><li><a href="Coins.html">Coins</a></li><li><a href="CoinView.html">CoinView</a></li><li><a href="CompactBlock.html">CompactBlock</a></li><li><a href="Environment.html">Environment</a></li><li><a href="Framer.html">Framer</a></li><li><a href="Fullnode.html">Fullnode</a></li><li><a href="HD.html">HD</a></li><li><a href="HDPrivateKey.html">HDPrivateKey</a></li><li><a href="HDPublicKey.html">HDPublicKey</a></li><li><a href="Headers.html">Headers</a></li><li><a href="HTTPBase.html">HTTPBase</a></li><li><a href="HTTPClient.html">HTTPClient</a></li><li><a href="HTTPServer.html">HTTPServer</a></li><li><a href="HTTPWallet.html">HTTPWallet</a></li><li><a href="Input.html">Input</a></li><li><a href="KeyPair.html">KeyPair</a></li><li><a href="KeyRing.html">KeyRing</a></li><li><a href="LoadRequest.html">LoadRequest</a></li><li><a href="Locker.html">Locker</a></li><li><a href="LowlevelUp.html">LowlevelUp</a></li><li><a href="LRU.html">LRU</a></li><li><a href="Master.html">Master</a></li><li><a href="Mempool.html">Mempool</a></li><li><a href="MempoolEntry.html">MempoolEntry</a></li><li><a href="MerkleBlock.html">MerkleBlock</a></li><li><a href="Miner.html">Miner</a></li><li><a href="MinerBlock.html">MinerBlock</a></li><li><a href="Mnemonic.html">Mnemonic</a></li><li><a href="MTX.html">MTX</a></li><li><a href="Network.html">Network</a></li><li><a href="NetworkAddress.html">NetworkAddress</a></li><li><a href="Node.html">Node</a></li><li><a href="NullCache.html">NullCache</a></li><li><a href="Output.html">Output</a></li><li><a href="Parser.html">Parser</a></li><li><a href="Peer.html">Peer</a></li><li><a href="Pool.html">Pool</a></li><li><a href="Profile.html">Profile</a></li><li><a href="RollingFilter.html">RollingFilter</a></li><li><a href="Script.html">Script</a></li><li><a href="ScriptError.html">ScriptError</a></li><li><a href="Snapshot.html">Snapshot</a></li><li><a href="SPVNode.html">SPVNode</a></li><li><a href="Stack.html">Stack</a></li><li><a href="TimeData.html">TimeData</a></li><li><a href="TX.html">TX</a></li><li><a href="TXDB.html">TXDB</a></li><li><a href="VerifyError.html">VerifyError</a></li><li><a href="Wallet.html">Wallet</a></li><li><a href="WalletDB.html">WalletDB</a></li><li><a href="Witness.html">Witness</a></li><li><a href="Worker.html">Worker</a></li><li><a href="Workers.html">Workers</a></li></ul><h3>Global</h3><ul><li><a href="global.html#hostname">hostname</a></li><li><a href="global.html#isMapped">isMapped</a></li><li><a href="global.html#mkdirp">mkdirp</a></li><li><a href="global.html#normalize">normalize</a></li><li><a href="global.html#parseHost">parseHost</a></li><li><a href="global.html#scrypt">scrypt</a></li><li><a href="global.html#toBuffer">toBuffer</a></li><li><a href="global.html#toString">toString</a></li><li><a href="global.html#version">version</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun Jun 05 2016 20:46:56 GMT-0700 (PDT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>