diff --git a/lib/bcoin/protocol/framer.js b/lib/bcoin/protocol/framer.js index d75b80c0..1f9ca4ff 100644 --- a/lib/bcoin/protocol/framer.js +++ b/lib/bcoin/protocol/framer.js @@ -303,11 +303,11 @@ Framer.block = function _block(block, type) { assert.equal(off, 76); off += writeU32(p, block.nonce, off); - // txn_count (spec says this is a varint for some reason) assert.equal(off, 80); - off += writeU32(p, block.totalTX, off); if (type === 'merkleblock') { + // txn_count + off += writeU32(p, block.totalTX, off); // hash count assert.equal(off, 84); off += varint(p, block.hashes.length, off); @@ -323,6 +323,15 @@ Framer.block = function _block(block, type) { block.flags.forEach(function(flag) { p[off++] = flag; }); + } else if (type === 'block') { + // txn_count + off += varint(p, block.totalTX, off); + // txs + block.txs.forEach(function(tx) { + tx._raw.forEach(function(ch) { + p[off++] = ch; + }); + }); } return p;