From 26d3003a9d9506ab16d868fe306b0cdbe626a61f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 22 May 2016 16:43:23 -0700 Subject: [PATCH] parse errors. --- lib/bcoin/protocol/parser.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/bcoin/protocol/parser.js b/lib/bcoin/protocol/parser.js index 18df2923..ba084e28 100644 --- a/lib/bcoin/protocol/parser.js +++ b/lib/bcoin/protocol/parser.js @@ -850,9 +850,8 @@ Parser.parseBlockCompact = function parseBlockCompact(p) { inCount = p.readVarint(); if (inCount === 0) { - if (p.readU8() === 0) - throw new Error('Invalid witness tx (flag == 0)'); - inCount = p.readVarint(); + if (p.readU8() !== 0) + inCount = p.readVarint(); } if (inCount > 0) @@ -1055,12 +1054,11 @@ Parser.parseWitnessTX = function parseWitnessTX(p) { version = p.readU32(); // Technically signed marker = p.readU8(); + flag = p.readU8(); if (marker !== 0) throw new Error('Invalid witness tx (marker != 0)'); - flag = p.readU8(); - if (flag === 0) throw new Error('Invalid witness tx (flag == 0)'); @@ -1085,7 +1083,8 @@ Parser.parseWitnessTX = function parseWitnessTX(p) { hasWitness = true; } - assert(hasWitness, 'Serialized wtx has an empty witness.'); + if (!hasWitness) + throw new Error('Witness tx has an empty witness.'); witnessSize = p.end() + 2;