|
20 | 20 | #include <key_io.h> |
21 | 21 | #include <net.h> |
22 | 22 | #include <node/context.h> |
23 | | -#include <rpc/blockchain.h> |
24 | 23 | #include <rpc/index_util.h> |
25 | 24 | #include <rpc/server.h> |
26 | 25 | #include <rpc/server_util.h> |
27 | 26 | #include <rpc/util.h> |
28 | 27 | #include <scheduler.h> |
29 | 28 | #include <script/descriptor.h> |
30 | 29 | #include <txmempool.h> |
| 30 | +#include <univalue.h> |
31 | 31 | #include <util/check.h> |
32 | | -#include <util/message.h> // For MessageSign(), MessageVerify() |
33 | 32 | #include <util/strencodings.h> |
34 | 33 | #include <util/system.h> |
35 | 34 | #include <validation.h> |
|
42 | 41 | #include <malloc.h> |
43 | 42 | #endif |
44 | 43 |
|
45 | | -#include <univalue.h> |
46 | | - |
47 | 44 | static RPCHelpMan debug() |
48 | 45 | { |
49 | 46 | return RPCHelpMan{"debug", |
@@ -475,97 +472,6 @@ static RPCHelpMan deriveaddresses() |
475 | 472 | }; |
476 | 473 | } |
477 | 474 |
|
478 | | -static RPCHelpMan verifymessage() |
479 | | -{ |
480 | | - return RPCHelpMan{"verifymessage", |
481 | | - "\nVerify a signed message\n", |
482 | | - { |
483 | | - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The Dash address to use for the signature."}, |
484 | | - {"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature provided by the signer in base 64 encoding (see signmessage)."}, |
485 | | - {"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message that was signed."}, |
486 | | - }, |
487 | | - RPCResult{ |
488 | | - RPCResult::Type::BOOL, "", "If the signature is verified or not." |
489 | | - }, |
490 | | - RPCExamples{ |
491 | | - "\nUnlock the wallet for 30 seconds\n" |
492 | | - + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + |
493 | | - "\nCreate the signature\n" |
494 | | - + HelpExampleCli("signmessage", "\"" + EXAMPLE_ADDRESS[0] + "\" \"my message\"") + |
495 | | - "\nVerify the signature\n" |
496 | | - + HelpExampleCli("verifymessage", "\"" + EXAMPLE_ADDRESS[0] + "\" \"signature\" \"my message\"") + |
497 | | - "\nAs a JSON-RPC call\n" |
498 | | - + HelpExampleRpc("verifymessage", "\"" + EXAMPLE_ADDRESS[0] + "\", \"signature\", \"my message\"") |
499 | | - }, |
500 | | - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
501 | | -{ |
502 | | - |
503 | | - LOCK(cs_main); |
504 | | - |
505 | | - std::string strAddress = request.params[0].get_str(); |
506 | | - std::string strSign = request.params[1].get_str(); |
507 | | - std::string strMessage = request.params[2].get_str(); |
508 | | - |
509 | | - switch (MessageVerify(strAddress, strSign, strMessage)) { |
510 | | - case MessageVerificationResult::ERR_INVALID_ADDRESS: |
511 | | - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); |
512 | | - case MessageVerificationResult::ERR_ADDRESS_NO_KEY: |
513 | | - throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); |
514 | | - case MessageVerificationResult::ERR_MALFORMED_SIGNATURE: |
515 | | - throw JSONRPCError(RPC_TYPE_ERROR, "Malformed base64 encoding"); |
516 | | - case MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED: |
517 | | - case MessageVerificationResult::ERR_NOT_SIGNED: |
518 | | - return false; |
519 | | - case MessageVerificationResult::OK: |
520 | | - return true; |
521 | | - } |
522 | | - |
523 | | - return false; |
524 | | -}, |
525 | | - }; |
526 | | -} |
527 | | - |
528 | | -static RPCHelpMan signmessagewithprivkey() |
529 | | -{ |
530 | | - return RPCHelpMan{"signmessagewithprivkey", |
531 | | - "\nSign a message with the private key of an address\n", |
532 | | - { |
533 | | - {"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The private key to sign the message with."}, |
534 | | - {"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."}, |
535 | | - }, |
536 | | - RPCResult{ |
537 | | - RPCResult::Type::STR, "signature", "The signature of the message encoded in base 64" |
538 | | - }, |
539 | | - RPCExamples{ |
540 | | - "\nCreate the signature\n" |
541 | | - + HelpExampleCli("signmessagewithprivkey", "\"privkey\" \"my message\"") + |
542 | | - "\nVerify the signature\n" |
543 | | - + HelpExampleCli("verifymessage", "\"" + EXAMPLE_ADDRESS[0] + "\" \"signature\" \"my message\"") + |
544 | | - "\nAs a JSON-RPC call\n" |
545 | | - + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"") |
546 | | - }, |
547 | | - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
548 | | -{ |
549 | | - |
550 | | - std::string strPrivkey = request.params[0].get_str(); |
551 | | - std::string strMessage = request.params[1].get_str(); |
552 | | - |
553 | | - CKey key = DecodeSecret(strPrivkey); |
554 | | - if (!key.IsValid()) { |
555 | | - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); |
556 | | - } |
557 | | - |
558 | | - std::string signature; |
559 | | - |
560 | | - if (!MessageSign(key, strMessage, signature)) { |
561 | | - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed"); |
562 | | - } |
563 | | - |
564 | | - return signature; |
565 | | -}, |
566 | | - }; |
567 | | -} |
568 | | - |
569 | 475 | static RPCHelpMan setmocktime() |
570 | 476 | { |
571 | 477 | return RPCHelpMan{"setmocktime", |
@@ -1512,8 +1418,6 @@ static const CRPCCommand commands[] = |
1512 | 1418 | { "util", &createmultisig, }, |
1513 | 1419 | { "util", &deriveaddresses, }, |
1514 | 1420 | { "util", &getdescriptorinfo, }, |
1515 | | - { "util", &verifymessage, }, |
1516 | | - { "util", &signmessagewithprivkey, }, |
1517 | 1421 | { "util", &getindexinfo, }, |
1518 | 1422 | { "blockchain", &getspentinfo, }, |
1519 | 1423 |
|
|
0 commit comments