aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-05-20 21:43:09 +0000
committerSarang Noether <32460187+SarangNoether@users.noreply.github.com>2020-08-28 19:25:17 -0400
commit743608ec16e27a3c1ca2febd4e80391a32c23efd (patch)
treed8b4f65cc302f765f7fd97aca7ef6189065307e3 /src/wallet/wallet_rpc_server.cpp
parentMerge pull request #6787 (diff)
downloadmonero-743608ec16e27a3c1ca2febd4e80391a32c23efd.tar.xz
wallet: allow signing a message with spend or view key
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r--src/wallet/wallet_rpc_server.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 0ed749cb7..ae5b692df 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -2007,7 +2007,20 @@ 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 if (req.signature_type == "both")
+ signature_type = tools::wallet2::sign_with_both_keys;
+ 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 +2055,17 @@ 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;
+ case tools::wallet2::sign_with_both_keys: res.signature_type = "both"; break;
+ default: res.signature_type = "invalid"; break;
+ }
return true;
}
//------------------------------------------------------------------------------------------------------------------------------