fix commitment hash checking.

This commit is contained in:
Christopher Jeffrey 2016-07-10 02:09:11 -07:00
parent 799c4a8d6e
commit 4f715d86c7
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -353,18 +353,19 @@ Block.prototype.__defineGetter__('commitmentHash', function() {
if (!coinbase) if (!coinbase)
return; return;
for (i = 0; i < coinbase.outputs.length; i++) { for (i = coinbase.outputs.length - 1; i >= 0; i--) {
commitment = coinbase.outputs[i].script; commitment = coinbase.outputs[i].script;
if (commitment.isCommitment()) { if (commitment.isCommitment()) {
commitmentHash = commitment.getCommitmentHash(); commitmentHash = commitment.getCommitmentHash();
commitmentHash = commitmentHash.toString('hex'); commitmentHash = commitmentHash.toString('hex');
if (!this.mutable)
this._commitmentHash = commitmentHash;
break; break;
} }
} }
if (!this.mutable)
this._commitmentHash = commitmentHash;
return commitmentHash; return commitmentHash;
}); });