diff options
author | luigi1111 <luigi1111w@gmail.com> | 2022-04-06 00:16:20 -0400 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2022-04-06 00:16:20 -0400 |
commit | f096ac1349194c5155091d5474dd0f86ed6af617 (patch) | |
tree | c01cdb0b11adf1cde9722ea44347bd6f90a44605 /src/wallet/wallet_rpc_server.cpp | |
parent | Merge pull request #8213 (diff) | |
parent | wallet_rpc_server: support regex for get_accounts tag (diff) | |
download | monero-f096ac1349194c5155091d5474dd0f86ed6af617.tar.xz |
Merge pull request #8215
d1f1947 wallet_rpc_server: support regex for get_accounts tag (reemuru)
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index c99fcaca7..543caac1b 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -622,7 +622,7 @@ namespace tools res.total_unlocked_balance = 0; cryptonote::subaddress_index subaddr_index = {0,0}; const std::pair<std::map<std::string, std::string>, std::vector<std::string>> account_tags = m_wallet->get_account_tags(); - if (!req.tag.empty() && account_tags.first.count(req.tag) == 0) + if (!req.tag.empty() && account_tags.first.count(req.tag) == 0 && !req.regexp) { er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; er.message = (boost::format(tr("Tag %s is unregistered.")) % req.tag).str(); @@ -630,7 +630,9 @@ namespace tools } for (; subaddr_index.major < m_wallet->get_num_subaddress_accounts(); ++subaddr_index.major) { - if (!req.tag.empty() && req.tag != account_tags.second[subaddr_index.major]) + bool no_match = !req.regexp ? (!req.tag.empty() && req.tag != account_tags.second[subaddr_index.major]) + : (!req.tag.empty() && !boost::regex_match(account_tags.second[subaddr_index.major], boost::regex(req.tag))); + if (no_match) continue; wallet_rpc::COMMAND_RPC_GET_ACCOUNTS::subaddress_account_info info; info.account_index = subaddr_index.major; @@ -643,6 +645,12 @@ namespace tools res.total_balance += info.balance; res.total_unlocked_balance += info.unlocked_balance; } + if (res.subaddress_accounts.size() == 0 && req.regexp) + { + er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; + er.message = (boost::format(tr("No matches for regex filter %s .")) % req.tag).str(); + return false; + } } catch (const std::exception& e) { |