diff options
author | Joel <joel@truelevel.io> | 2019-03-02 22:32:02 +0100 |
---|---|---|
committer | Joel <joel@truelevel.io> | 2019-03-02 23:14:35 +0100 |
commit | 364516975a3269e6c99aaaa8eb7f0b2da6894a89 (patch) | |
tree | 0241e76728ff6808c9b82439279c17584b05ea6c /src/wallet/wallet_rpc_server.cpp | |
parent | Remove code duplication (diff) | |
download | monero-364516975a3269e6c99aaaa8eb7f0b2da6894a89.tar.xz |
Simplify RPC endpoint, emoving second RPC endpoint generate_from_view_key
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 86ca13416..6451e5ce3 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -3129,7 +3129,7 @@ namespace tools } } //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_generate_from_view_key(const wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::request &req, wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::response &res, epee::json_rpc::error &er, const connection_context *ctx) + bool wallet_rpc_server::on_generate_from_keys(const wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::request &req, wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::response &res, epee::json_rpc::error &er, const connection_context *ctx) { if (m_wallet_dir.empty()) { @@ -3245,12 +3245,14 @@ namespace tools return false; } wal->generate(wallet_file, std::move(rc.second).password(), info.address, spendkey, viewkey, false); + res.info = "Wallet has been generated successfully."; } else { wal->generate(wallet_file, std::move(rc.second).password(), info.address, viewkey, false); + res.info = "Watch-only wallet has been generated successfully."; } - MINFO("Wallet has been restored.\n"); + MINFO("Wallet has been generated.\n"); } catch (const std::exception &e) { @@ -3292,22 +3294,9 @@ namespace tools } m_wallet = wal.release(); res.address = m_wallet->get_account().get_public_address_str(m_wallet->nettype()); - res.info = "Wallet has been restored successfully."; return true; } //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_generate_from_keys(const wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::request &req, wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::response &res, epee::json_rpc::error &er, const connection_context *ctx) - { - // early check for mandatory fields - if (req.spendkey.empty()) - { - er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; - er.message = "field 'spendkey' is mandatory. Please provide a spend key you want to restore from."; - return false; - } - return wallet_rpc_server::on_generate_from_view_key(req, res, er, ctx); - } - //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_restore_deterministic_wallet(const wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::request &req, wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::response &res, epee::json_rpc::error &er, const connection_context *ctx) { if (m_wallet_dir.empty()) |