mempool: do not accept replace by fee.

This commit is contained in:
Christopher Jeffrey 2016-10-18 06:39:00 -07:00
parent da6a575469
commit acaf0600e7
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 40 additions and 0 deletions

View File

@ -644,6 +644,12 @@ Mempool.prototype._addTX = co(function* _addTX(tx) {
ret.reason,
ret.score);
}
if (tx.isRBF()) {
throw new VerifyError(tx,
'nonstandard',
'replace-by-fee',
0);
}
}
result = yield this.chain.checkFinal(this.chain.tip, tx, lockFlags);

View File

@ -221,6 +221,15 @@ Input.prototype.isFinal = function isFinal() {
return this.sequence === 0xffffffff;
};
/**
* Test to see if nSequence is less than 0xfffffffe.
* @returns {Boolean}
*/
Input.prototype.isRBF = function isRBF() {
return this.sequence < 0xfffffffe;
};
/**
* Test to see if outpoint is null.
* @returns {Boolean}

View File

@ -782,6 +782,31 @@ TX.prototype.isCoinbase = function isCoinbase() {
return this.inputs.length === 1 && this.inputs[0].prevout.isNull();
};
/**
* Test whether the transaction is a replacement.
* @returns {Boolean}
*/
TX.prototype.isRBF = function isRBF() {
var i, input;
for (i = 0; i < this.inputs.length; i++) {
input = this.inputs[i];
if (!input.isRBF())
continue;
if (this.version === 2) {
if (!(input.sequence & constants.sequence.DISABLE_FLAG))
continue;
}
return true;
}
return false;
};
/**
* Calculate the fee for the transaction.
* @returns {Amount} fee (zero if not all coins are available).