diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-01-11 11:06:35 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-01-11 12:11:43 +0000 |
commit | 24d500ce8e27eade6e591f83e1381be62134e151 (patch) | |
tree | 41c6c08075eb9dbfcab565f97f2744852a257ded /src/wallet/wallet_rpc_server.cpp | |
parent | Merge pull request #206 (diff) | |
download | monero-24d500ce8e27eade6e591f83e1381be62134e151.tar.xz |
Add a --restricted-rpc flag to simplewallet
It restricts RPC to a subset of "view only" commands. Kind of like
a poor man's view key replacement.
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index d7b3f8434..be20f05de 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -167,6 +167,13 @@ namespace tools std::vector<cryptonote::tx_destination_entry> dsts; std::vector<uint8_t> extra; + if (m_wallet.restricted()) + { + er.code = WALLET_RPC_ERROR_CODE_DENIED; + er.message = "Command unavailable in restricted mode."; + return false; + } + // validate the transfer requested and populate dsts & extra if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, er)) { @@ -218,6 +225,13 @@ namespace tools std::vector<cryptonote::tx_destination_entry> dsts; std::vector<uint8_t> extra; + if (m_wallet.restricted()) + { + er.code = WALLET_RPC_ERROR_CODE_DENIED; + er.message = "Command unavailable in restricted mode."; + return false; + } + // validate the transfer requested and populate dsts & extra; RPC_TRANSFER::request and RPC_TRANSFER_SPLIT::request are identical types. if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, er)) { @@ -261,6 +275,13 @@ namespace tools //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er, connection_context& cntx) { + if (m_wallet.restricted()) + { + er.code = WALLET_RPC_ERROR_CODE_DENIED; + er.message = "Command unavailable in restricted mode."; + return false; + } + try { m_wallet.store(); @@ -409,6 +430,13 @@ namespace tools //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_query_key(const wallet_rpc::COMMAND_RPC_QUERY_KEY::request& req, wallet_rpc::COMMAND_RPC_QUERY_KEY::response& res, epee::json_rpc::error& er, connection_context& cntx) { + if (m_wallet.restricted()) + { + er.code = WALLET_RPC_ERROR_CODE_DENIED; + er.message = "Command unavailable in restricted mode."; + return false; + } + if (req.key_type.compare("mnemonic") == 0) { if (!m_wallet.get_seed(res.key)) |