|
21 | 21 | #include <script/descriptor.h>
|
22 | 22 | #include <univalue.h>
|
23 | 23 | #include <util/check.h>
|
24 |
| -#include <util/message.h> // For MessageSign(), MessageVerify() |
25 | 24 | #include <util/strencodings.h>
|
26 | 25 | #include <util/syscall_sandbox.h>
|
27 | 26 | #include <util/system.h>
|
@@ -309,93 +308,6 @@ static RPCHelpMan deriveaddresses()
|
309 | 308 | };
|
310 | 309 | }
|
311 | 310 |
|
312 |
| -static RPCHelpMan verifymessage() |
313 |
| -{ |
314 |
| - return RPCHelpMan{"verifymessage", |
315 |
| - "Verify a signed message.", |
316 |
| - { |
317 |
| - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to use for the signature."}, |
318 |
| - {"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature provided by the signer in base 64 encoding (see signmessage)."}, |
319 |
| - {"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message that was signed."}, |
320 |
| - }, |
321 |
| - RPCResult{ |
322 |
| - RPCResult::Type::BOOL, "", "If the signature is verified or not." |
323 |
| - }, |
324 |
| - RPCExamples{ |
325 |
| - "\nUnlock the wallet for 30 seconds\n" |
326 |
| - + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + |
327 |
| - "\nCreate the signature\n" |
328 |
| - + HelpExampleCli("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + |
329 |
| - "\nVerify the signature\n" |
330 |
| - + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") + |
331 |
| - "\nAs a JSON-RPC call\n" |
332 |
| - + HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"signature\", \"my message\"") |
333 |
| - }, |
334 |
| - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
335 |
| -{ |
336 |
| - std::string strAddress = request.params[0].get_str(); |
337 |
| - std::string strSign = request.params[1].get_str(); |
338 |
| - std::string strMessage = request.params[2].get_str(); |
339 |
| - |
340 |
| - switch (MessageVerify(strAddress, strSign, strMessage)) { |
341 |
| - case MessageVerificationResult::ERR_INVALID_ADDRESS: |
342 |
| - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); |
343 |
| - case MessageVerificationResult::ERR_ADDRESS_NO_KEY: |
344 |
| - throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); |
345 |
| - case MessageVerificationResult::ERR_MALFORMED_SIGNATURE: |
346 |
| - throw JSONRPCError(RPC_TYPE_ERROR, "Malformed base64 encoding"); |
347 |
| - case MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED: |
348 |
| - case MessageVerificationResult::ERR_NOT_SIGNED: |
349 |
| - return false; |
350 |
| - case MessageVerificationResult::OK: |
351 |
| - return true; |
352 |
| - } |
353 |
| - |
354 |
| - return false; |
355 |
| -}, |
356 |
| - }; |
357 |
| -} |
358 |
| - |
359 |
| -static RPCHelpMan signmessagewithprivkey() |
360 |
| -{ |
361 |
| - return RPCHelpMan{"signmessagewithprivkey", |
362 |
| - "\nSign a message with the private key of an address\n", |
363 |
| - { |
364 |
| - {"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The private key to sign the message with."}, |
365 |
| - {"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."}, |
366 |
| - }, |
367 |
| - RPCResult{ |
368 |
| - RPCResult::Type::STR, "signature", "The signature of the message encoded in base 64" |
369 |
| - }, |
370 |
| - RPCExamples{ |
371 |
| - "\nCreate the signature\n" |
372 |
| - + HelpExampleCli("signmessagewithprivkey", "\"privkey\" \"my message\"") + |
373 |
| - "\nVerify the signature\n" |
374 |
| - + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") + |
375 |
| - "\nAs a JSON-RPC call\n" |
376 |
| - + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"") |
377 |
| - }, |
378 |
| - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
379 |
| -{ |
380 |
| - std::string strPrivkey = request.params[0].get_str(); |
381 |
| - std::string strMessage = request.params[1].get_str(); |
382 |
| - |
383 |
| - CKey key = DecodeSecret(strPrivkey); |
384 |
| - if (!key.IsValid()) { |
385 |
| - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); |
386 |
| - } |
387 |
| - |
388 |
| - std::string signature; |
389 |
| - |
390 |
| - if (!MessageSign(key, strMessage, signature)) { |
391 |
| - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed"); |
392 |
| - } |
393 |
| - |
394 |
| - return signature; |
395 |
| -}, |
396 |
| - }; |
397 |
| -} |
398 |
| - |
399 | 311 | static RPCHelpMan setmocktime()
|
400 | 312 | {
|
401 | 313 | return RPCHelpMan{"setmocktime",
|
@@ -795,8 +707,6 @@ void RegisterMiscRPCCommands(CRPCTable& t)
|
795 | 707 | {"util", &createmultisig},
|
796 | 708 | {"util", &deriveaddresses},
|
797 | 709 | {"util", &getdescriptorinfo},
|
798 |
| - {"util", &verifymessage}, |
799 |
| - {"util", &signmessagewithprivkey}, |
800 | 710 | {"util", &getindexinfo},
|
801 | 711 | {"hidden", &setmocktime},
|
802 | 712 | {"hidden", &mockscheduler},
|
|
0 commit comments