Bitcoin Core  0.19.99
P2P Digital Currency
validation.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2020 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include <util/validation.h>
7 
8 #include <consensus/validation.h>
9 #include <tinyformat.h>
10 
11 std::string FormatStateMessage(const ValidationState &state)
12 {
13  if (state.IsValid()) {
14  return "Valid";
15  }
16 
17  const std::string debug_message = state.GetDebugMessage();
18  if (!debug_message.empty()) {
19  return strprintf("%s, %s", state.GetRejectReason(), debug_message);
20  }
21 
22  return state.GetRejectReason();
23 }
24 
25 const std::string strMessageMagic = "Bitcoin Signed Message:\n";
bool IsValid() const
Definition: validation.h:106
Base class for capturing information about block/transaction validation.
Definition: validation.h:77
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
std::string GetRejectReason() const
Definition: validation.h:109
std::string FormatStateMessage(const ValidationState &state)
Convert ValidationState to a human-readable message for logging.
Definition: validation.cpp:11
std::string GetDebugMessage() const
Definition: validation.h:110
const std::string strMessageMagic
Definition: validation.cpp:25