block: minor.

This commit is contained in:
Christopher Jeffrey 2017-02-28 10:13:48 -08:00
parent e9d87dcd98
commit 60ff33bdb2
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -366,12 +366,13 @@ Block.prototype.getMerkleRoot = function getMerkleRoot(enc) {
*/
Block.prototype.getWitnessNonce = function getWitnessNonce() {
var coinbase = this.txs[0];
var input;
var coinbase, input;
if (!coinbase)
if (this.txs.length === 0)
return null;
coinbase = this.txs[0];
if (coinbase.inputs.length !== 1)
return null;
@ -394,12 +395,13 @@ Block.prototype.getWitnessNonce = function getWitnessNonce() {
*/
Block.prototype.getCommitmentHash = function getCommitmentHash(enc) {
var coinbase = this.txs[0];
var i, hash, output;
var i, coinbase, hash, output;
if (!coinbase)
if (this.txs.length === 0)
return null;
coinbase = this.txs[0];
for (i = coinbase.outputs.length - 1; i >= 0; i--) {
output = coinbase.outputs[i];
if (output.script.isCommitment()) {