mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Move parse_subaddress_lookahead() from simplewallet.cpp to util.cpp
This commit is contained in:
parent
fbdc30966b
commit
9e9cd108a3
3 changed files with 24 additions and 14 deletions
|
@ -757,4 +757,22 @@ std::string get_nix_version_display_string()
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::optional<std::pair<uint32_t, uint32_t>> parse_subaddress_lookahead(const std::string& str)
|
||||||
|
{
|
||||||
|
auto pos = str.find(":");
|
||||||
|
bool r = pos != std::string::npos;
|
||||||
|
uint32_t major;
|
||||||
|
r = r && epee::string_tools::get_xtype_from_string(major, str.substr(0, pos));
|
||||||
|
uint32_t minor;
|
||||||
|
r = r && epee::string_tools::get_xtype_from_string(minor, str.substr(pos + 1));
|
||||||
|
if (r)
|
||||||
|
{
|
||||||
|
return std::make_pair(major, minor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <boost/thread/locks.hpp>
|
#include <boost/thread/locks.hpp>
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
#include <boost/optional.hpp>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -212,4 +213,6 @@ namespace tools
|
||||||
|
|
||||||
bool sha256sum(const uint8_t *data, size_t len, crypto::hash &hash);
|
bool sha256sum(const uint8_t *data, size_t len, crypto::hash &hash);
|
||||||
bool sha256sum(const std::string &filename, crypto::hash &hash);
|
bool sha256sum(const std::string &filename, crypto::hash &hash);
|
||||||
|
|
||||||
|
boost::optional<std::pair<uint32_t, uint32_t>> parse_subaddress_lookahead(const std::string& str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,21 +381,10 @@ namespace
|
||||||
|
|
||||||
boost::optional<std::pair<uint32_t, uint32_t>> parse_subaddress_lookahead(const std::string& str)
|
boost::optional<std::pair<uint32_t, uint32_t>> parse_subaddress_lookahead(const std::string& str)
|
||||||
{
|
{
|
||||||
auto pos = str.find(":");
|
auto r = tools::parse_subaddress_lookahead(str);
|
||||||
bool r = pos != std::string::npos;
|
if (!r)
|
||||||
uint32_t major;
|
|
||||||
r = r && epee::string_tools::get_xtype_from_string(major, str.substr(0, pos));
|
|
||||||
uint32_t minor;
|
|
||||||
r = r && epee::string_tools::get_xtype_from_string(minor, str.substr(pos + 1));
|
|
||||||
if (r)
|
|
||||||
{
|
|
||||||
return std::make_pair(major, minor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fail_msg_writer() << tr("invalid format for subaddress lookahead; must be <major>:<minor>");
|
fail_msg_writer() << tr("invalid format for subaddress lookahead; must be <major>:<minor>");
|
||||||
return {};
|
return r;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_transfer_exception(const std::exception_ptr &e, bool trusted_daemon)
|
void handle_transfer_exception(const std::exception_ptr &e, bool trusted_daemon)
|
||||||
|
|
Loading…
Reference in a new issue