From 307f7d48d4733da016bf73676f6ebff9144365c1 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 29 Nov 2014 16:01:37 +0100 Subject: Report script evaluation failures in log and reject messages --- src/main.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/main.h') diff --git a/src/main.h b/src/main.h index caf8331ee1..b04692bb54 100644 --- a/src/main.h +++ b/src/main.h @@ -96,6 +96,8 @@ static const unsigned int MAX_HEADERS_RESULTS = 2000; static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; /** Time to wait (in seconds) between writing blockchain state to disk. */ static const unsigned int DATABASE_WRITE_INTERVAL = 3600; +/** Maximum length of reject messages. */ +static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111; /** "reject" message codes **/ static const unsigned char REJECT_MALFORMED = 0x01; @@ -325,14 +327,15 @@ private: unsigned int nIn; unsigned int nFlags; bool cacheStore; + ScriptError error; public: - CScriptCheck(): ptxTo(0), nIn(0), nFlags(0), cacheStore(false) {} + CScriptCheck(): ptxTo(0), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR) {} CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn) : scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey), - ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn) { } + ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR) { } - bool operator()() const; + bool operator()(); void swap(CScriptCheck &check) { scriptPubKey.swap(check.scriptPubKey); @@ -340,7 +343,10 @@ public: std::swap(nIn, check.nIn); std::swap(nFlags, check.nFlags); std::swap(cacheStore, check.cacheStore); + std::swap(error, check.error); } + + ScriptError GetScriptError() const { return error; } }; /** Data structure that represents a partial merkle tree. -- cgit v1.2.3