diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2019-11-22 17:17:29 +0100 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2020-02-14 10:45:40 +0100 |
commit | f8f0d9893d7969bdaa870fadb94ec5d0dfa8334d (patch) | |
tree | 21484d5e11ebf6cf1f707805ce766b397637beba /src/util/message.h | |
parent | 2ce3447eb1e25ec7aec4b300dabf6c1e394f1906 (diff) |
Deduplicate the message signing code
The logic of signing a message was duplicated in 3 places:
src/qt/signverifymessagedialog.cpp
SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
src/rpc/misc.cpp
signmessagewithprivkey()
src/wallet/rpcwallet.cpp
signmessage()
Move the logic into
src/util/message.cpp
MessageSign()
and call it from all the 3 places.
Diffstat (limited to 'src/util/message.h')
-rw-r--r-- | src/util/message.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/message.h b/src/util/message.h index 6adda5d3ff..1a1ba88daf 100644 --- a/src/util/message.h +++ b/src/util/message.h @@ -6,6 +6,8 @@ #ifndef BITCOIN_UTIL_MESSAGE_H #define BITCOIN_UTIL_MESSAGE_H +#include <key.h> // For CKey + #include <string> extern const std::string strMessageMagic; @@ -46,4 +48,14 @@ MessageVerificationResult MessageVerify( const std::string& signature, const std::string& message); +/** Sign a message. + * @param[in] privkey Private key to sign with. + * @param[in] message The message to sign. + * @param[out] signature Signature, base64 encoded, only set if true is returned. + * @return true if signing was successful. */ +bool MessageSign( + const CKey& privkey, + const std::string& message, + std::string& signature); + #endif // BITCOIN_UTIL_MESSAGE_H |