aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/message.cpp14
-rw-r--r--src/util/message.h8
2 files changed, 22 insertions, 0 deletions
diff --git a/src/util/message.cpp b/src/util/message.cpp
index 17603a43d2..1e7128d225 100644
--- a/src/util/message.cpp
+++ b/src/util/message.cpp
@@ -76,3 +76,17 @@ uint256 MessageHash(const std::string& message)
return hasher.GetHash();
}
+
+std::string SigningResultString(const SigningResult res)
+{
+ switch (res) {
+ case SigningResult::OK:
+ return "No error";
+ case SigningResult::PRIVATE_KEY_NOT_AVAILABLE:
+ return "Private key not available";
+ case SigningResult::SIGNING_FAILED:
+ return "Sign failed";
+ // no default case, so the compiler can warn about missing cases
+ }
+ assert(false);
+}
diff --git a/src/util/message.h b/src/util/message.h
index 01fd14ce2d..b31c5f5761 100644
--- a/src/util/message.h
+++ b/src/util/message.h
@@ -39,6 +39,12 @@ enum class MessageVerificationResult {
OK
};
+enum class SigningResult {
+ OK, //!< No error
+ PRIVATE_KEY_NOT_AVAILABLE,
+ SIGNING_FAILED,
+};
+
/** Verify a signed message.
* @param[in] address Signer's bitcoin address, it must refer to a public key.
* @param[in] signature The signature in base64 format.
@@ -65,4 +71,6 @@ bool MessageSign(
*/
uint256 MessageHash(const std::string& message);
+std::string SigningResultString(const SigningResult res);
+
#endif // BITCOIN_UTIL_MESSAGE_H