parse errors.

This commit is contained in:
Christopher Jeffrey 2016-05-22 16:43:23 -07:00
parent d605af7ed8
commit 26d3003a9d
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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;