diff options
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet2.cpp | 21 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 2 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index adc9c1f61..3161f3b16 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -831,21 +831,30 @@ std::vector<std::vector<cryptonote::tx_destination_entry>> split_amounts( * * @return a monero address (as a string) or an empty string */ -std::string wallet2::address_from_url(const std::string& url, bool& dnssec_valid) +std::vector<std::string> wallet2::addresses_from_url(const std::string& url, bool& dnssec_valid) { // TODO: update this correctly once DNSResolver::get_txt_record() supports it. dnssec_valid = false; - // get txt record - std::string txt = tools::DNSResolver::instance().get_txt_record(url); - if (txt.size()) + std::vector<std::string> addresses; + // get txt records + auto records = tools::DNSResolver::instance().get_txt_record(url); + + // for each txt record, try to find a monero address in it. + for (auto& rec : records) { - return address_from_txt_record(txt); + std::string addr = address_from_txt_record(rec); + if (addr.size()) + { + addresses.push_back(addr); + } } - return std::string(); + + return addresses; } //---------------------------------------------------------------------------------------------------- +// TODO: parse the string in a less stupid way, probably with regex std::string wallet2::address_from_txt_record(const std::string& s) { // make sure the txt record has "oa1:xmr" and find it diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 6e6d7cafb..90918677e 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -196,7 +196,7 @@ namespace tools static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id); - static std::string address_from_url(const std::string& url, bool& dnssec_valid); + static std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec_valid); static std::string address_from_txt_record(const std::string& s); private: |