diff options
author | stoffu <stoffu@protonmail.ch> | 2018-07-23 23:45:11 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2018-07-31 21:36:12 +0900 |
commit | 1c6cfd34f4ad5939ebeb29a9776faf2f29c8b04f (patch) | |
tree | b7c3f8598f2f975b1deb98ef3288f4ec16f5d681 /src/wallet/wallet_rpc_server.cpp | |
parent | Merge pull request #4088 (diff) | |
download | monero-1c6cfd34f4ad5939ebeb29a9776faf2f29c8b04f.tar.xz |
wallet-rpc: add get_address_index command
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index b9cf99635..f34534198 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -416,6 +416,27 @@ namespace tools return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool wallet_rpc_server::on_getaddress_index(const wallet_rpc::COMMAND_RPC_GET_ADDRESS_INDEX::request& req, wallet_rpc::COMMAND_RPC_GET_ADDRESS_INDEX::response& res, epee::json_rpc::error& er) + { + if (!m_wallet) return not_open(er); + cryptonote::address_parse_info info; + if(!get_account_address_from_str(info, m_wallet->nettype(), req.address)) + { + er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS; + er.message = "Invalid address"; + return false; + } + auto index = m_wallet->get_subaddress_index(info.address); + if (!index) + { + er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS; + er.message = "Address doesn't belong to the wallet"; + return false; + } + res.index = *index; + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_create_address(const wallet_rpc::COMMAND_RPC_CREATE_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_CREATE_ADDRESS::response& res, epee::json_rpc::error& er) { if (!m_wallet) return not_open(er); |