bitcoin/src/util/validation.cpp
Vasil Dimov 2ce3447eb1
Deduplicate the message verifying code
The logic of verifying a message was duplicated in 2 places:

src/qt/signverifymessagedialog.cpp
  SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked()

src/rpc/misc.cpp
  verifymessage()

with the only difference being the result handling. Move the logic into
a dedicated

src/util/message.cpp
  MessageVerify()

which returns a set of result codes, call it from the 2 places and just
handle the results differently in the callers.
2020-02-14 10:45:40 +01:00

24 lines
667 B
C++

// Copyright (c) 2009-2010 Satoshi Nakamoto
// 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.
#include <util/validation.h>
#include <consensus/validation.h>
#include <tinyformat.h>
std::string FormatStateMessage(const ValidationState &state)
{
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();
}