mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00

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.
24 lines
667 B
C++
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();
|
|
}
|