parse_subaddress_index added

pull/3/head
moneroexamples 5 years ago
parent 0741363499
commit f2f5f37fb9

@ -190,6 +190,8 @@ Output::identify(transaction const& tx,
i,
subaddress_spendkey);
// do same comparison as above depending of the
// avaliabity of the PrimaryAddress Account
if (!pacc)
{
mine_output = (pub_spend_key == subaddress_spendkey);

@ -220,4 +220,41 @@ nettype_based_on_address(string const& address)
return {determined_network_type, determined_address_type};
}
boost::optional<subaddress_index>
parse_subaddress_index(string idx_str)
{
vector<string> split_index;
boost::split(split_index, idx_str,
boost::is_any_of(",/"));
if (split_index.empty()
|| split_index.size() != 2)
{
cerr << "Incorrect subaddress index given: "
<< idx_str << '\n';
return {};
}
try
{
auto idx_major
= boost::lexical_cast<uint32_t>(split_index[0]);
auto idx_minor
= boost::lexical_cast<uint32_t>(split_index[1]);
return subaddress_index {idx_major, idx_minor};
}
catch (boost::bad_lexical_cast const& e)
{
cerr << e.what() << '\n';
}
return {};
}
}

@ -76,4 +76,7 @@ for_each_network_type(F f)
pair<network_type, address_type>
nettype_based_on_address(string const& address);
boost::optional<subaddress_index>
parse_subaddress_index(string idx_str);
}

Loading…
Cancel
Save