From 2ce3447eb1e25ec7aec4b300dabf6c1e394f1906 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 19 Nov 2019 15:49:35 +0100 Subject: 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. --- src/util/message.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ src/util/message.h | 49 +++++++++++++++++++++++++++++++++++++++++++++ src/util/validation.cpp | 2 -- src/util/validation.h | 2 -- 4 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 src/util/message.cpp create mode 100644 src/util/message.h (limited to 'src/util') diff --git a/src/util/message.cpp b/src/util/message.cpp new file mode 100644 index 0000000000..33e9c3384b --- /dev/null +++ b/src/util/message.cpp @@ -0,0 +1,53 @@ +// 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 // For CHashWriter +#include // For DecodeDestination() +#include // For CPubKey +#include