diff options
author | stoffu <stoffu@protonmail.ch> | 2018-11-05 12:13:15 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2018-11-05 12:13:15 +0900 |
commit | 7ae36e91f6ce75ec24b3a25478992b3a71f9ee35 (patch) | |
tree | 8fbae0cf055a85b0960cee50b55491597859aa9e | |
parent | Merge pull request #4702 (diff) | |
download | monero-7ae36e91f6ce75ec24b3a25478992b3a71f9ee35.tar.xz |
wallet_rpc_server: account for watch-only/non-deterministic/multisig when querying seed
Followup on #4653
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 5e6100dfd..bec0a3eeb 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1742,11 +1742,42 @@ namespace tools if (req.key_type.compare("mnemonic") == 0) { epee::wipeable_string seed; - if (!m_wallet->get_seed(seed)) + bool ready; + if (m_wallet->multisig(&ready)) { + if (!ready) + { + er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG; + er.message = "This wallet is multisig, but not yet finalized"; + return false; + } + if (!m_wallet->get_multisig_seed(seed)) + { + er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; + er.message = "Failed to get multisig seed."; + return false; + } + } + else + { + if (m_wallet->watch_only()) + { + er.code = WALLET_RPC_ERROR_CODE_WATCH_ONLY; + er.message = "The wallet is watch-only. Cannot display seed."; + return false; + } + if (!m_wallet->is_deterministic()) + { er.code = WALLET_RPC_ERROR_CODE_NON_DETERMINISTIC; er.message = "The wallet is non-deterministic. Cannot display seed."; return false; + } + if (!m_wallet->get_seed(seed)) + { + er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; + er.message = "Failed to get seed."; + return false; + } } res.key = std::string(seed.data(), seed.size()); // send to the network, then wipe RAM :D } |