fix checkinputs.
This commit is contained in:
parent
2677b0eecd
commit
58d2f66a70
@ -668,6 +668,23 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac
|
|||||||
tx = block.txs[i];
|
tx = block.txs[i];
|
||||||
hash = tx.hash('hex');
|
hash = tx.hash('hex');
|
||||||
|
|
||||||
|
// Check for block sigops limits
|
||||||
|
// Start counting P2SH sigops once block
|
||||||
|
// timestamps reach March 31st, 2012.
|
||||||
|
if (block.ts >= constants.block.bip16time)
|
||||||
|
sigops += tx.getSigops(true);
|
||||||
|
else
|
||||||
|
sigops += tx.getSigops();
|
||||||
|
|
||||||
|
if (sigops > constants.script.maxBlockSigops) {
|
||||||
|
utils.debug('Block has too many sigops: %s', block.rhash);
|
||||||
|
return callback(null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Coinbases do not have prevouts
|
||||||
|
if (tx.isCoinbase())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (tx.getOutputValue().cmp(tx.getInputValue()) > 0) {
|
if (tx.getOutputValue().cmp(tx.getInputValue()) > 0) {
|
||||||
utils.debug('TX is spending funds it does not have: %s', tx.rhash);
|
utils.debug('TX is spending funds it does not have: %s', tx.rhash);
|
||||||
return false;
|
return false;
|
||||||
@ -676,10 +693,6 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac
|
|||||||
for (j = 0; j < tx.inputs.length; j++) {
|
for (j = 0; j < tx.inputs.length; j++) {
|
||||||
input = tx.inputs[j];
|
input = tx.inputs[j];
|
||||||
|
|
||||||
// Coinbases do not have prevouts
|
|
||||||
if (tx.isCoinbase())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Ensure tx is not double spending an output
|
// Ensure tx is not double spending an output
|
||||||
if (!input.output) {
|
if (!input.output) {
|
||||||
utils.debug('Block is using spent inputs: %s (tx: %s, output: %s)',
|
utils.debug('Block is using spent inputs: %s (tx: %s, output: %s)',
|
||||||
@ -711,22 +724,6 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac
|
|||||||
return callback(null, false);
|
return callback(null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scriptCheck)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Check for block sigops limits
|
|
||||||
// Start counting P2SH sigops once block
|
|
||||||
// timestamps reach March 31st, 2012.
|
|
||||||
if (block.ts >= constants.block.bip16time)
|
|
||||||
sigops += tx.getSigops(true);
|
|
||||||
else
|
|
||||||
sigops += tx.getSigops();
|
|
||||||
|
|
||||||
if (sigops > constants.script.maxBlockSigops) {
|
|
||||||
utils.debug('Block has too many sigops: %s', block.rhash);
|
|
||||||
return callback(null, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user