more tx method refactoring.
This commit is contained in:
parent
9e4e6c8242
commit
727dc66252
@ -691,11 +691,11 @@ Mempool.prototype.addTX = function addTX(tx, callback, force) {
|
||||
}
|
||||
|
||||
if (this.requireStandard) {
|
||||
if (!tx.isStandard(flags, ret)) {
|
||||
if (!tx.isStandard(ret)) {
|
||||
return callback(new VerifyError(tx,
|
||||
'nonstandard',
|
||||
ret.reason,
|
||||
0));
|
||||
ret.score));
|
||||
}
|
||||
|
||||
if (!this.chain.csvActive && tx.version >= 2) {
|
||||
@ -981,7 +981,7 @@ Mempool.prototype.verify = function verify(entry, callback) {
|
||||
0));
|
||||
}
|
||||
|
||||
if (self.requireStandard && !tx.hasStandardInputs(flags)) {
|
||||
if (self.requireStandard && !tx.hasStandardInputs()) {
|
||||
return callback(new VerifyError(tx,
|
||||
'nonstandard',
|
||||
'bad-txns-nonstandard-inputs',
|
||||
|
||||
@ -1300,23 +1300,22 @@ TX.prototype.isSane = function isSane(ret) {
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
TX.prototype.isStandard = function isStandard(flags, ret) {
|
||||
TX.prototype.isStandard = function isStandard(ret) {
|
||||
var i, input, output;
|
||||
var nulldata = 0;
|
||||
|
||||
if (!ret)
|
||||
ret = {};
|
||||
|
||||
if (flags == null)
|
||||
flags = constants.flags.STANDARD_VERIFY_FLAGS;
|
||||
|
||||
if (this.version < 1 || this.version > constants.tx.MAX_VERSION) {
|
||||
ret.reason = 'version';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.getCost() > constants.tx.MAX_COST) {
|
||||
if (this.getCost() >= constants.tx.MAX_COST) {
|
||||
ret.reason = 'tx-size';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1325,14 +1324,14 @@ TX.prototype.isStandard = function isStandard(flags, ret) {
|
||||
|
||||
if (input.script.getSize() > 1650) {
|
||||
ret.reason = 'scriptsig-size';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flags & constants.flags.VERIFY_SIGPUSHONLY) {
|
||||
if (!input.script.isPushOnly()) {
|
||||
ret.reason = 'scriptsig-not-pushonly';
|
||||
return false;
|
||||
}
|
||||
if (!input.script.isPushOnly()) {
|
||||
ret.reason = 'scriptsig-not-pushonly';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1341,6 +1340,7 @@ TX.prototype.isStandard = function isStandard(flags, ret) {
|
||||
|
||||
if (!output.script.isStandard()) {
|
||||
ret.reason = 'scriptpubkey';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1351,17 +1351,20 @@ TX.prototype.isStandard = function isStandard(flags, ret) {
|
||||
|
||||
if (output.script.isMultisig() && !constants.tx.BARE_MULTISIG) {
|
||||
ret.reason = 'bare-multisig';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (output.isDust(constants.tx.MIN_RELAY)) {
|
||||
ret.reason = 'dust';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (nulldata > 1) {
|
||||
ret.reason = 'multi-op-return';
|
||||
ret.score = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1372,18 +1375,15 @@ TX.prototype.isStandard = function isStandard(flags, ret) {
|
||||
* Perform contextual checks to verify coin and input
|
||||
* script standardness (including the redeem script).
|
||||
* @see AreInputsStandard()
|
||||
* @param {VerifyFlags?}
|
||||
* @param {VerifyFlags?} flags
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
TX.prototype.hasStandardInputs = function hasStandardInputs(flags) {
|
||||
TX.prototype.hasStandardInputs = function hasStandardInputs() {
|
||||
var maxSigops = constants.script.MAX_SCRIPTHASH_SIGOPS;
|
||||
var VERIFY_NONE = constants.flags.VERIFY_NONE;
|
||||
var i, input, stack, redeem;
|
||||
|
||||
if (flags == null)
|
||||
flags = constants.flags.STANDARD_VERIFY_FLAGS;
|
||||
|
||||
if (this.isCoinbase())
|
||||
return true;
|
||||
|
||||
@ -1396,8 +1396,7 @@ TX.prototype.hasStandardInputs = function hasStandardInputs(flags) {
|
||||
if (input.coin.script.isUnknown())
|
||||
return false;
|
||||
|
||||
if ((flags & constants.flags.VERIFY_P2SH)
|
||||
&& input.coin.script.isScripthash()) {
|
||||
if (input.coin.script.isScripthash()) {
|
||||
stack = new Stack();
|
||||
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user