Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit 528f07f

Browse files
committed
fixed filteredTxsHash If there is only one hash the filter do not match any txs in the block and should return a void aray
1 parent 906b255 commit 528f07f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/block/merkleblock.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ MerkleBlock.prototype.validMerkleTree = function validMerkleTree() {
155155
* Return a list of all the txs hash that match the filter
156156
* @returns {Array} - txs hash that match the filter
157157
*/
158-
MerkleBlock.prototype.filterdTxsHash = function validMerkleTree() {
158+
MerkleBlock.prototype.filterdTxsHash = function filterdTxsHash() {
159159
$.checkState(_.isArray(this.flags), 'MerkleBlock flags is not an array');
160160
$.checkState(_.isArray(this.hashes), 'MerkleBlock hashes is not an array');
161161

@@ -169,6 +169,11 @@ MerkleBlock.prototype.filterdTxsHash = function validMerkleTree() {
169169
throw new errors.MerkleBlock.InvalidMerkleTree();
170170
}
171171

172+
// If there is only one hash the filter do not match any txs in the block
173+
if(this.hashes.length === 1) {
174+
return [];
175+
};
176+
172177
var height = this._calcTreeHeight();
173178
var opts = { hashesUsed: 0, flagBitsUsed: 0 };
174179
var txs = this._traverseMerkleTree(height, 0, opts, true);

0 commit comments

Comments
 (0)