20 "Verify a signed message.",
30 "\nUnlock the wallet for 30 seconds\n"
32 "\nCreate the signature\n"
33 +
HelpExampleCli(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
34 "\nVerify the signature\n"
35 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
36 "\nAs a JSON-RPC call\n"
37 +
HelpExampleRpc(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"signature\", \"my message\"")
41 std::string strAddress = self.
Arg<std::string>(
"address");
42 std::string strSign = self.
Arg<std::string>(
"signature");
43 std::string strMessage = self.
Arg<std::string>(
"message");
67 "\nSign a message with the private key of an address\n",
76 "\nCreate the signature\n"
77 +
HelpExampleCli(
"signmessagewithprivkey",
"\"privkey\" \"my message\"") +
78 "\nVerify the signature\n"
79 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
80 "\nAs a JSON-RPC call\n"
81 +
HelpExampleRpc(
"signmessagewithprivkey",
"\"privkey\", \"my message\"")
85 std::string strPrivkey = request.params[0].
get_str();
86 std::string strMessage = request.params[1].get_str();
93 std::string signature;
110 for (
const auto& c : commands) {
111 t.appendCommand(c.name, &c);
An encapsulated private key.
bool IsValid() const
Check whether this private key is valid.
auto Arg(std::string_view key) const
Helper to get a required or default-valued request argument.
const std::string & get_str() const
bool MessageSign(const CKey &privkey, const std::string &message, std::string &signature)
Sign a message.
MessageVerificationResult MessageVerify(const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
CKey DecodeSecret(const std::string &str)
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
void RegisterSignMessageRPCCommands(CRPCTable &t)
static RPCHelpMan signmessagewithprivkey()
static RPCHelpMan verifymessage()
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
@ ERR_MALFORMED_SIGNATURE
The provided signature couldn't be parsed (maybe invalid base64).
@ ERR_INVALID_ADDRESS
The provided address is invalid.
@ ERR_ADDRESS_NO_KEY
The provided address is valid but does not refer to a public key.
@ ERR_NOT_SIGNED
The message was not signed with the private key of the provided address.
@ OK
The message verification was successful.
@ ERR_PUBKEY_NOT_RECOVERED
A public key could not be recovered from the provided signature and message.