diff options
author | luigi1111 <luigi1111w@gmail.com> | 2020-08-31 16:49:03 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2020-08-31 16:49:03 -0500 |
commit | 61dd04b68121b4057b4b88356761fbfb3fa73c90 (patch) | |
tree | ce191c3d6f23869e1250f7d77d0746cfafa645c1 /src/wallet/wallet_rpc_server.cpp | |
parent | Merge pull request #6787 (diff) | |
parent | Bind signature to full address and signing mode (diff) | |
download | monero-61dd04b68121b4057b4b88356761fbfb3fa73c90.tar.xz |
Merge pull request #6600
fa06c39 Bind signature to full address and signing mode (SarangNoether)
743608e wallet: allow signing a message with spend or view key (moneromooo-monero)
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 0ed749cb7..03db8b70f 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -2007,7 +2007,18 @@ namespace tools return false; } - res.signature = m_wallet->sign(req.data, {req.account_index, req.address_index}); + tools::wallet2::message_signature_type_t signature_type = tools::wallet2::sign_with_spend_key; + if (req.signature_type == "spend" || req.signature_type == "") + signature_type = tools::wallet2::sign_with_spend_key; + else if (req.signature_type == "view") + signature_type = tools::wallet2::sign_with_view_key; + else + { + er.code = WALLET_RPC_ERROR_CODE_INVALID_SIGNATURE_TYPE; + er.message = "Invalid signature type requested"; + return false; + } + res.signature = m_wallet->sign(req.data, signature_type, {req.account_index, req.address_index}); return true; } //------------------------------------------------------------------------------------------------------------------------------ @@ -2042,7 +2053,16 @@ namespace tools return false; } - res.good = m_wallet->verify(req.data, info.address, req.signature); + const auto result = m_wallet->verify(req.data, info.address, req.signature); + res.good = result.valid; + res.version = result.version; + res.old = result.old; + switch (result.type) + { + case tools::wallet2::sign_with_spend_key: res.signature_type = "spend"; break; + case tools::wallet2::sign_with_view_key: res.signature_type = "view"; break; + default: res.signature_type = "invalid"; break; + } return true; } //------------------------------------------------------------------------------------------------------------------------------ |