diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp index b2b003f666..fd856fc148 100644 --- a/src/merkleblock.cpp +++ b/src/merkleblock.cpp @@ -71,6 +71,9 @@ CMerkleBlock::CMerkleBlock(const CBlock& block, const std::set& txids) } uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::vector &vTxid) { + //we can never have zero txs in a merkle block, we always need the coinbase tx + //if we do not have this assert, we can hit a memory access violation when indexing into vTxid + assert(vTxid.size() != 0); if (height == 0) { // hash at height 0 is the txids themself return vTxid[pos]; diff --git a/src/merkleblock.h b/src/merkleblock.h index 68fac71a93..8a974d4aaa 100644 --- a/src/merkleblock.h +++ b/src/merkleblock.h @@ -121,6 +121,8 @@ public: /** * Used to relay blocks as header + vector * to filtered nodes. + * + * NOTE: The class assumes that the given CBlock has *at least* 1 transaction. If the CBlock has 0 txs, it will hit an assertion. */ class CMerkleBlock {