diff options
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r-- | src/wallet/wallet2.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 4bcc0b24a..87577d2fd 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -888,14 +888,12 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index) cryptonote::subaddress_index index2; for (index2.major = m_subaddress_labels.size(); index2.major < index.major + m_subaddress_lookahead_major; ++index2.major) { - for (index2.minor = 0; index2.minor < (index2.major == index.major ? index.minor : 0) + m_subaddress_lookahead_minor; ++index2.minor) + const uint32_t end = (index2.major == index.major ? index.minor : 0) + m_subaddress_lookahead_minor; + const std::vector<crypto::public_key> pkeys = cryptonote::get_subaddress_spend_public_keys(m_account.get_keys(), index2.major, 0, end); + for (index2.minor = 0; index2.minor < end; ++index2.minor) { - if (m_subaddresses_inv.count(index2) == 0) - { - crypto::public_key D = get_subaddress_spend_public_key(index2); - m_subaddresses[D] = index2; - m_subaddresses_inv[index2] = D; - } + const crypto::public_key &D = pkeys[index2.minor]; + m_subaddresses[D] = index2; } } m_subaddress_labels.resize(index.major + 1, {"Untitled account"}); @@ -904,15 +902,14 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index) else if (m_subaddress_labels[index.major].size() <= index.minor) { // add new subaddresses - cryptonote::subaddress_index index2 = index; - for (index2.minor = m_subaddress_labels[index.major].size(); index2.minor < index.minor + m_subaddress_lookahead_minor; ++index2.minor) + const uint32_t end = index.minor + m_subaddress_lookahead_minor; + const uint32_t begin = m_subaddress_labels[index.major].size(); + cryptonote::subaddress_index index2 = {index.major, begin}; + const std::vector<crypto::public_key> pkeys = cryptonote::get_subaddress_spend_public_keys(m_account.get_keys(), index2.major, index2.minor, end); + for (; index2.minor < end; ++index2.minor) { - if (m_subaddresses_inv.count(index2) == 0) - { - crypto::public_key D = get_subaddress_spend_public_key(index2); - m_subaddresses[D] = index2; - m_subaddresses_inv[index2] = D; - } + const crypto::public_key &D = pkeys[index2.minor - begin]; + m_subaddresses[D] = index2; } m_subaddress_labels[index.major].resize(index.minor + 1); } @@ -2352,7 +2349,6 @@ bool wallet2::clear() m_address_book.clear(); m_local_bc_height = 1; m_subaddresses.clear(); - m_subaddresses_inv.clear(); m_subaddress_labels.clear(); return true; } @@ -3194,7 +3190,6 @@ bool wallet2::finalize_multisig(const epee::wipeable_string &password, std::unor } m_subaddresses.clear(); - m_subaddresses_inv.clear(); m_subaddress_labels.clear(); add_subaddress_account(tr("Primary account")); |