add carrot subaddress derive type when inserting new subaddresses
This commit is contained in:
@@ -336,12 +336,10 @@ void carrot_and_legacy_account::set_carrot_keys(const AddressDeriveType default_
|
||||
generate_subaddress_map();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_account::insert_subaddresses(const std::unordered_map<crypto::public_key, cryptonote::subaddress_index>& subaddress_map_cn)
|
||||
void carrot_and_legacy_account::insert_subaddresses(const std::unordered_map<crypto::public_key, subaddress_index_extended>& subaddress_map_cn)
|
||||
{
|
||||
// if AddressDeriveType::Auto causing a problem, this function can take it as a parameter, you then have to update
|
||||
// all inserts to `subaddress_map`, and only use this function to insert into it with appropriate derive type.
|
||||
for (const auto &p : subaddress_map_cn)
|
||||
subaddress_map.insert({p.first, {{p.second.major, p.second.minor}, AddressDeriveType::Auto}});
|
||||
subaddress_map.insert({p.first, {{p.second.index.major, p.second.index.minor}, p.second.derive_type}});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace carrot
|
||||
);
|
||||
|
||||
void set_carrot_keys(const AddressDeriveType default_derive_type = AddressDeriveType::Carrot);
|
||||
void insert_subaddresses(const std::unordered_map<crypto::public_key, cryptonote::subaddress_index>& subaddress_map);
|
||||
void insert_subaddresses(const std::unordered_map<crypto::public_key, subaddress_index_extended>& subaddress_map);
|
||||
|
||||
AddressDeriveType resolve_derive_type(const AddressDeriveType derive_type) const;
|
||||
};
|
||||
|
||||
+19
-3
@@ -2841,10 +2841,17 @@ void wallet2::process_new_scanned_transaction(
|
||||
// from protocol or return txs
|
||||
for (const auto entry: tx_amounts_individual_outs[i->first]) {
|
||||
const crypto::public_key &onetime_address = std::get<1>(entry);
|
||||
m_account.insert_subaddresses({{onetime_address, {i->first.major, i->first.minor}}});
|
||||
carrot::AddressDeriveType derive_type;
|
||||
if (use_fork_rules(HF_VERSION_CARROT, 0)) {
|
||||
derive_type = carrot::AddressDeriveType::Carrot;
|
||||
} else {
|
||||
derive_type = carrot::AddressDeriveType::PreCarrot;
|
||||
}
|
||||
const carrot::subaddress_index_extended subaddr_ext = {i->first.major, i->first.minor, derive_type};
|
||||
m_account.insert_subaddresses({{onetime_address, subaddr_ext}});
|
||||
// save to m_subaddresses as well, so that we can populate account subaddress map
|
||||
// when we open the wallet first time.
|
||||
m_subaddresses[onetime_address] = i->first;
|
||||
m_subaddresses_extended[onetime_address] = subaddr_ext;
|
||||
|
||||
// update m_salvium_txs
|
||||
m_salvium_txs.insert({onetime_address, m_transfers.size()-1});
|
||||
@@ -6574,7 +6581,16 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
|
||||
|
||||
if (get_num_subaddress_accounts() == 0)
|
||||
add_subaddress_account(tr("Primary account"));
|
||||
m_account.insert_subaddresses(m_subaddresses);
|
||||
m_account.insert_subaddresses(m_subaddresses_extended);
|
||||
if (!m_subaddresses.empty())
|
||||
{
|
||||
// if we have subaddresses, we need to insert them into the account
|
||||
for (const auto &subaddress : m_subaddresses)
|
||||
m_account.insert_subaddresses(
|
||||
{{subaddress.first, {{subaddress.second.major, subaddress.second.minor}, carrot::AddressDeriveType::PreCarrot}}}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1402,6 +1402,7 @@ private:
|
||||
if (ver < 20)
|
||||
return;
|
||||
a & m_subaddresses.parent();
|
||||
a & m_subaddresses_extended.parent();
|
||||
std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
|
||||
a & dummy_subaddresses_inv;
|
||||
a & m_subaddress_labels;
|
||||
@@ -1468,6 +1469,7 @@ private:
|
||||
FIELD(m_scanned_pool_txs[0])
|
||||
FIELD(m_scanned_pool_txs[1])
|
||||
FIELD(m_subaddresses)
|
||||
FIELD(m_subaddresses_extended)
|
||||
FIELD(m_subaddress_labels)
|
||||
FIELD(m_additional_tx_keys)
|
||||
FIELD(m_attributes)
|
||||
@@ -2130,6 +2132,7 @@ private:
|
||||
serializable_unordered_map<crypto::public_key, size_t> m_pub_keys;
|
||||
cryptonote::account_public_address m_account_public_address;
|
||||
serializable_unordered_map<crypto::public_key, cryptonote::subaddress_index> m_subaddresses;
|
||||
serializable_unordered_map<crypto::public_key, carrot::subaddress_index_extended> m_subaddresses_extended;
|
||||
std::vector<std::vector<std::string>> m_subaddress_labels;
|
||||
serializable_unordered_map<crypto::hash, std::string> m_tx_notes;
|
||||
serializable_unordered_map<std::string, std::string> m_attributes;
|
||||
|
||||
Reference in New Issue
Block a user