Skip to content

Commit a651403

Browse files
committed
Add absurdly high fee message to validation state (for RPC propagation)
1 parent da77a6f commit a651403

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/consensus/validation.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class CValidationState {
2828
} mode;
2929
int nDoS;
3030
std::string strRejectReason;
31-
unsigned char chRejectCode;
31+
unsigned int chRejectCode;
3232
bool corruptionPossible;
3333
public:
3434
CValidationState() : mode(MODE_VALID), nDoS(0), chRejectCode(0), corruptionPossible(false) {}
3535
bool DoS(int level, bool ret = false,
36-
unsigned char chRejectCodeIn=0, std::string strRejectReasonIn="",
36+
unsigned int chRejectCodeIn=0, std::string strRejectReasonIn="",
3737
bool corruptionIn=false) {
3838
chRejectCode = chRejectCodeIn;
3939
strRejectReason = strRejectReasonIn;
@@ -45,7 +45,7 @@ class CValidationState {
4545
return ret;
4646
}
4747
bool Invalid(bool ret = false,
48-
unsigned char _chRejectCode=0, std::string _strRejectReason="") {
48+
unsigned int _chRejectCode=0, std::string _strRejectReason="") {
4949
return DoS(0, ret, _chRejectCode, _strRejectReason);
5050
}
5151
bool Error(const std::string& strRejectReasonIn) {
@@ -73,7 +73,7 @@ class CValidationState {
7373
bool CorruptionPossible() const {
7474
return corruptionPossible;
7575
}
76-
unsigned char GetRejectCode() const { return chRejectCode; }
76+
unsigned int GetRejectCode() const { return chRejectCode; }
7777
std::string GetRejectReason() const { return strRejectReason; }
7878
};
7979

src/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
10311031
}
10321032

10331033
if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000)
1034-
return error("AcceptToMemoryPool: absurdly high fees %s, %d > %d",
1035-
hash.ToString(),
1036-
nFees, ::minRelayTxFee.GetFee(nSize) * 10000);
1034+
return state.Invalid(error("AcceptToMemoryPool: absurdly high fees %s, %d > %d",
1035+
hash.ToString(),
1036+
nFees, ::minRelayTxFee.GetFee(nSize) * 10000),
1037+
REJECT_HIGHFEE, "absurdly-high-fee");
10371038

10381039
// Check against previous transactions
10391040
// This is done last to help prevent CPU exhaustion denial-of-service attacks.

src/main.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,7 @@ extern CBlockTreeDB *pblocktree;
497497
*/
498498
int GetSpendHeight(const CCoinsViewCache& inputs);
499499

500+
/** local "reject" message codes for RPC which can not be triggered by p2p trasactions */
501+
static const unsigned int REJECT_HIGHFEE = 0x100;
502+
500503
#endif // BITCOIN_MAIN_H

0 commit comments

Comments
 (0)