aboutsummaryrefslogtreecommitdiff
path: root/src/util/validation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/validation.cpp')
-rw-r--r--src/util/validation.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/util/validation.cpp b/src/util/validation.cpp
index fe1f5a277e..89bc6665a4 100644
--- a/src/util/validation.cpp
+++ b/src/util/validation.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2019 The Bitcoin Core developers
+// Copyright (c) 2009-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -8,13 +8,18 @@
#include <consensus/validation.h>
#include <tinyformat.h>
-/** Convert CValidationState to a human-readable message for logging */
-std::string FormatStateMessage(const CValidationState &state)
+std::string FormatStateMessage(const ValidationState &state)
{
- return strprintf("%s%s (code %i)",
- state.GetRejectReason(),
- state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage(),
- state.GetRejectCode());
+ if (state.IsValid()) {
+ return "Valid";
+ }
+
+ const std::string debug_message = state.GetDebugMessage();
+ if (!debug_message.empty()) {
+ return strprintf("%s, %s", state.GetRejectReason(), debug_message);
+ }
+
+ return state.GetRejectReason();
}
const std::string strMessageMagic = "Bitcoin Signed Message:\n";