mirror of
https://github.com/monero-project/monero.git
synced 2024-12-14 04:16:32 +02:00
wallet2: fix subaddress expansion when receiving monero
This commit is contained in:
parent
378cdeaeae
commit
7a8c1eece9
@ -1521,6 +1521,18 @@ void wallet2::add_subaddress(uint32_t index_major, const std::string& label)
|
|||||||
m_subaddress_labels[index_major][index_minor] = label;
|
m_subaddress_labels[index_major][index_minor] = label;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
bool wallet2::should_expand(const cryptonote::subaddress_index &index) const
|
||||||
|
{
|
||||||
|
const uint32_t last_major = m_subaddress_labels.size() - 1 > (std::numeric_limits<uint32_t>::max() - m_subaddress_lookahead_major) ? std::numeric_limits<uint32_t>::max() : (m_subaddress_labels.size() + m_subaddress_lookahead_major - 1);
|
||||||
|
if (index.major > last_major)
|
||||||
|
return false;
|
||||||
|
const size_t nsub = index.major < m_subaddress_labels.size() ? m_subaddress_labels[index.major].size() : 0;
|
||||||
|
const uint32_t last_minor = nsub - 1 > (std::numeric_limits<uint32_t>::max() - m_subaddress_lookahead_minor) ? std::numeric_limits<uint32_t>::max() : (nsub + m_subaddress_lookahead_minor - 1);
|
||||||
|
if (index.minor > last_minor)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
|
void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
|
||||||
{
|
{
|
||||||
hw::device &hwdev = m_account.get_device();
|
hw::device &hwdev = m_account.get_device();
|
||||||
@ -2106,7 +2118,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
|||||||
td.m_amount = amount;
|
td.m_amount = amount;
|
||||||
td.m_pk_index = pk_index - 1;
|
td.m_pk_index = pk_index - 1;
|
||||||
td.m_subaddr_index = tx_scan_info[o].received->index;
|
td.m_subaddr_index = tx_scan_info[o].received->index;
|
||||||
if (tx_scan_info[o].received->index.major < m_subaddress_labels.size() && tx_scan_info[o].received->index.minor < m_subaddress_labels[tx_scan_info[o].received->index.major].size())
|
if (should_expand(tx_scan_info[o].received->index))
|
||||||
expand_subaddresses(tx_scan_info[o].received->index);
|
expand_subaddresses(tx_scan_info[o].received->index);
|
||||||
if (tx.vout[o].amount == 0)
|
if (tx.vout[o].amount == 0)
|
||||||
{
|
{
|
||||||
@ -2185,7 +2197,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
|||||||
td.m_amount = amount;
|
td.m_amount = amount;
|
||||||
td.m_pk_index = pk_index - 1;
|
td.m_pk_index = pk_index - 1;
|
||||||
td.m_subaddr_index = tx_scan_info[o].received->index;
|
td.m_subaddr_index = tx_scan_info[o].received->index;
|
||||||
if (tx_scan_info[o].received->index.major < m_subaddress_labels.size() && tx_scan_info[o].received->index.minor < m_subaddress_labels[tx_scan_info[o].received->index.major].size())
|
if (should_expand(tx_scan_info[o].received->index))
|
||||||
expand_subaddresses(tx_scan_info[o].received->index);
|
expand_subaddresses(tx_scan_info[o].received->index);
|
||||||
if (tx.vout[o].amount == 0)
|
if (tx.vout[o].amount == 0)
|
||||||
{
|
{
|
||||||
@ -12755,7 +12767,7 @@ process:
|
|||||||
const crypto::public_key& out_key = boost::get<cryptonote::txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key;
|
const crypto::public_key& out_key = boost::get<cryptonote::txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key;
|
||||||
bool r = cryptonote::generate_key_image_helper(m_account.get_keys(), m_subaddresses, out_key, tx_pub_key, additional_tx_pub_keys, td.m_internal_output_index, in_ephemeral, td.m_key_image, m_account.get_device());
|
bool r = cryptonote::generate_key_image_helper(m_account.get_keys(), m_subaddresses, out_key, tx_pub_key, additional_tx_pub_keys, td.m_internal_output_index, in_ephemeral, td.m_key_image, m_account.get_device());
|
||||||
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to generate key image");
|
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to generate key image");
|
||||||
if (td.m_subaddr_index.major < m_subaddress_labels.size() && td.m_subaddr_index.minor < m_subaddress_labels[td.m_subaddr_index.major].size())
|
if (should_expand(td.m_subaddr_index))
|
||||||
expand_subaddresses(td.m_subaddr_index);
|
expand_subaddresses(td.m_subaddr_index);
|
||||||
td.m_key_image_known = true;
|
td.m_key_image_known = true;
|
||||||
td.m_key_image_request = true;
|
td.m_key_image_request = true;
|
||||||
|
@ -1516,6 +1516,8 @@ private:
|
|||||||
std::string get_client_signature() const;
|
std::string get_client_signature() const;
|
||||||
void check_rpc_cost(const char *call, uint64_t post_call_credits, uint64_t pre_credits, double expected_cost);
|
void check_rpc_cost(const char *call, uint64_t post_call_credits, uint64_t pre_credits, double expected_cost);
|
||||||
|
|
||||||
|
bool should_expand(const cryptonote::subaddress_index &index) const;
|
||||||
|
|
||||||
cryptonote::account_base m_account;
|
cryptonote::account_base m_account;
|
||||||
boost::optional<epee::net_utils::http::login> m_daemon_login;
|
boost::optional<epee::net_utils::http::login> m_daemon_login;
|
||||||
std::string m_daemon_address;
|
std::string m_daemon_address;
|
||||||
|
Loading…
Reference in New Issue
Block a user