diff options
author | Thomas Winget <tewinget@gmail.com> | 2014-09-17 17:38:54 -0400 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-09-23 22:58:28 +0200 |
commit | c14c7e16839b6cfe32527f2b01a9a1507e3d419e (patch) | |
tree | 519980c3d1e09f7e29ae6002d30d0126f1b4a8c4 /src/wallet/wallet2.cpp | |
parent | Simplewallet should now resolve urls to addresses (diff) | |
download | monero-c14c7e16839b6cfe32527f2b01a9a1507e3d419e.tar.xz |
change to allow (at least a bit) for multiple TXT records
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet2.cpp | 21 |
1 files changed, 15 insertions, 6 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 |