blockdb, segwit, and input fixes.

This commit is contained in:
Christopher Jeffrey 2016-02-26 04:32:31 -08:00
parent 4c653683b7
commit 5d1f6089ed
3 changed files with 9 additions and 8 deletions

View File

@ -520,7 +520,7 @@ BlockDB.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, opti
}); });
} }
if (!key) { if (key === undefined) {
return iter.end(function(err) { return iter.end(function(err) {
if (err) if (err)
return done(err); return done(err);
@ -543,7 +543,7 @@ BlockDB.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, opti
} }
if (!data) if (!data)
return done(); return next();
try { try {
data = bcoin.protocol.parser.parseOutput(data); data = bcoin.protocol.parser.parseOutput(data);
@ -658,7 +658,7 @@ BlockDB.prototype.getTXByAddress = function getTXByAddress(addresses, options, c
}); });
} }
if (!key) { if (key === undefined) {
return iter.end(function(err) { return iter.end(function(err) {
if (err) if (err)
return done(err); return done(err);
@ -812,7 +812,7 @@ BlockDB.prototype.getBlock = function getBlock(hash, callback) {
if (data) { if (data) {
try { try {
block = bcoin.protocol.parser.parseBlock(data); block = bcoin.protocol.parser.parseBlock(data);
block = new bcoin.block(block, 'block'); block = new bcoin.block(block);
} catch (e) { } catch (e) {
return callback(e); return callback(e);
} }
@ -977,7 +977,7 @@ BlockDB.prototype.getHeight = function getHeight(callback) {
}); });
} }
if (!key) { if (key === undefined) {
return iter.end(function(err) { return iter.end(function(err) {
if (err) if (err)
return callback(err); return callback(err);

View File

@ -60,7 +60,7 @@ Input.prototype.getType = function getType() {
if (this.witness.length > 0) if (this.witness.length > 0)
type = bcoin.script.getInputType(this.witness, null, true); type = bcoin.script.getInputType(this.witness, null, true);
if (type === 'unknown') if (!type || type === 'unknown')
type = bcoin.script.getInputType(this.script); type = bcoin.script.getInputType(this.script);
if (!this._mutable) if (!this._mutable)

View File

@ -316,6 +316,7 @@ script.verify = function verify(input, witness, output, tx, i, flags) {
if ((flags & constants.flags.VERIFY_WITNESS) && script.isWitnessProgram(output)) { if ((flags & constants.flags.VERIFY_WITNESS) && script.isWitnessProgram(output)) {
if (!script.verifyProgram(input, witness, output, tx, i, flags)) if (!script.verifyProgram(input, witness, output, tx, i, flags))
return false; return false;
// TODO: FIX STACK HERE
} }
// If the script is P2SH, execute the real output script // If the script is P2SH, execute the real output script
@ -433,7 +434,7 @@ script.verifyProgram = function verifyProgram(input, witness, output, tx, i, fla
return false; return false;
} }
res = script.execute(output, stack, tx, i, flags); res = script.execute(script, stack, tx, i, flags);
// Verify the script did not fail as well as the stack values // Verify the script did not fail as well as the stack values
if (!res || stack.length === 0 || !script.bool(stack.pop())) if (!res || stack.length === 0 || !script.bool(stack.pop()))
@ -1328,7 +1329,7 @@ script.checkPush = function checkPush(op, value, flags) {
if (value.length === 1 && value[0] >= 1 && value[0] <= 16) if (value.length === 1 && value[0] >= 1 && value[0] <= 16)
return +op >= 1 && +op <= 16; return +op >= 1 && +op <= 16;
if (value.length === 1 && value[0] === -1) if (value.length === 1 && value[0] === 0xff)
return op === '1negate'; return op === '1negate';
if (value.length <= 75) if (value.length <= 75)