diff --git a/lib/bcoin/mempool.js b/lib/bcoin/mempool.js index f6f472ef..aa171e8b 100644 --- a/lib/bcoin/mempool.js +++ b/lib/bcoin/mempool.js @@ -296,6 +296,11 @@ Mempool.prototype.addTX = function addTX(tx, peer, callback, force) { callback = utils.wrap(callback, unlock); callback = utils.asyncify(callback); + if (!this.chain.segwitActive) { + if (tx.hasWitness()) + return callback(new VerifyError('nonstandard', 'no-witness-yet', 0)); + } + if (!this.checkTX(tx, peer)) return callback(new VerifyError('invalid', 'CheckTransaction failed', -1)); @@ -421,9 +426,6 @@ Mempool.prototype.verify = function verify(tx, callback) { if (this.chain.segwitActive) { flags |= constants.flags.VERIFY_WITNESS; mandatory |= constants.flags.VERIFY_WITNESS; - } else { - if (tx.hasWitness()) - return callback(new VerifyError('nonstandard', 'no-witness-yet', 0)); } if (this.requireStandard && !tx.isStandardInputs(flags)) { @@ -516,7 +518,7 @@ Mempool.prototype.verify = function verify(tx, callback) { 0)); } - this.freeCount += tx.getVirtualSize(); + this.freeCount += tx.getSize(); } if (this.rejectInsaneFees && fee.cmp(minFee.muln(10000)) > 0) @@ -543,16 +545,16 @@ Mempool.prototype.verify = function verify(tx, callback) { if (err) return callback(err); - if (!result) { + if (result) { return callback(new VerifyError( 'nonstandard', - 'mandatory-script-verify-flag', + 'non-mandatory-script-verify-flag', 0)); } return callback(new VerifyError( 'nonstandard', - 'non-mandatory-script-verify-flag', + 'mandatory-script-verify-flag', 0)); }); }