mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
wallet2: factor the watchonly/multisig/etc fields on creation
There's half a dozen calls, and it's easy to miss some when adding a new field.
This commit is contained in:
parent
e4b049da05
commit
050bb337d7
@ -4004,6 +4004,17 @@ bool wallet2::query_device(hw::device::device_type& device_type, const std::stri
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wallet2::init_type(hw::device::device_type device_type)
|
||||||
|
{
|
||||||
|
m_account_public_address = m_account.get_keys().m_account_address;
|
||||||
|
m_watch_only = false;
|
||||||
|
m_multisig = false;
|
||||||
|
m_multisig_threshold = 0;
|
||||||
|
m_multisig_signers.clear();
|
||||||
|
m_original_keys_available = false;
|
||||||
|
m_key_device_type = device_type;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Generates a wallet or restores one.
|
* \brief Generates a wallet or restores one.
|
||||||
* \param wallet_ Name of wallet file
|
* \param wallet_ Name of wallet file
|
||||||
@ -4073,18 +4084,15 @@ void wallet2::generate(const std::string& wallet_, const epee::wipeable_string&
|
|||||||
m_account.make_multisig(view_secret_key, spend_secret_key, spend_public_key, multisig_keys);
|
m_account.make_multisig(view_secret_key, spend_secret_key, spend_public_key, multisig_keys);
|
||||||
m_account.finalize_multisig(spend_public_key);
|
m_account.finalize_multisig(spend_public_key);
|
||||||
|
|
||||||
m_account_public_address = m_account.get_keys().m_account_address;
|
// Not possible to restore a multisig wallet that is able to activate the MMS
|
||||||
m_watch_only = false;
|
// (because the original keys are not (yet) part of the restore info), so
|
||||||
|
// keep m_original_keys_available to false
|
||||||
|
init_type(hw::device::device_type::SOFTWARE);
|
||||||
m_multisig = true;
|
m_multisig = true;
|
||||||
m_multisig_threshold = threshold;
|
m_multisig_threshold = threshold;
|
||||||
m_multisig_signers = multisig_signers;
|
m_multisig_signers = multisig_signers;
|
||||||
m_key_device_type = hw::device::device_type::SOFTWARE;
|
|
||||||
setup_keys(password);
|
setup_keys(password);
|
||||||
|
|
||||||
// Not possible to restore a multisig wallet that is able to activate the MMS
|
|
||||||
// (because the original keys are not (yet) part of the restore info)
|
|
||||||
m_original_keys_available = false;
|
|
||||||
|
|
||||||
create_keys_file(wallet_, false, password, m_nettype != MAINNET || create_address_file);
|
create_keys_file(wallet_, false, password, m_nettype != MAINNET || create_address_file);
|
||||||
setup_new_blockchain();
|
setup_new_blockchain();
|
||||||
|
|
||||||
@ -4117,13 +4125,7 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const epee::wip
|
|||||||
|
|
||||||
crypto::secret_key retval = m_account.generate(recovery_param, recover, two_random);
|
crypto::secret_key retval = m_account.generate(recovery_param, recover, two_random);
|
||||||
|
|
||||||
m_account_public_address = m_account.get_keys().m_account_address;
|
init_type(hw::device::device_type::SOFTWARE);
|
||||||
m_watch_only = false;
|
|
||||||
m_multisig = false;
|
|
||||||
m_multisig_threshold = 0;
|
|
||||||
m_multisig_signers.clear();
|
|
||||||
m_original_keys_available = false;
|
|
||||||
m_key_device_type = hw::device::device_type::SOFTWARE;
|
|
||||||
setup_keys(password);
|
setup_keys(password);
|
||||||
|
|
||||||
// calculate a starting refresh height
|
// calculate a starting refresh height
|
||||||
@ -4206,13 +4208,9 @@ void wallet2::generate(const std::string& wallet_, const epee::wipeable_string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_account.create_from_viewkey(account_public_address, viewkey);
|
m_account.create_from_viewkey(account_public_address, viewkey);
|
||||||
m_account_public_address = account_public_address;
|
init_type(hw::device::device_type::SOFTWARE);
|
||||||
m_watch_only = true;
|
m_watch_only = true;
|
||||||
m_multisig = false;
|
m_account_public_address = account_public_address;
|
||||||
m_multisig_threshold = 0;
|
|
||||||
m_multisig_signers.clear();
|
|
||||||
m_original_keys_available = false;
|
|
||||||
m_key_device_type = hw::device::device_type::SOFTWARE;
|
|
||||||
setup_keys(password);
|
setup_keys(password);
|
||||||
|
|
||||||
create_keys_file(wallet_, true, password, m_nettype != MAINNET || create_address_file);
|
create_keys_file(wallet_, true, password, m_nettype != MAINNET || create_address_file);
|
||||||
@ -4247,13 +4245,8 @@ void wallet2::generate(const std::string& wallet_, const epee::wipeable_string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_account.create_from_keys(account_public_address, spendkey, viewkey);
|
m_account.create_from_keys(account_public_address, spendkey, viewkey);
|
||||||
|
init_type(hw::device::device_type::SOFTWARE);
|
||||||
m_account_public_address = account_public_address;
|
m_account_public_address = account_public_address;
|
||||||
m_watch_only = false;
|
|
||||||
m_multisig = false;
|
|
||||||
m_multisig_threshold = 0;
|
|
||||||
m_multisig_signers.clear();
|
|
||||||
m_original_keys_available = false;
|
|
||||||
m_key_device_type = hw::device::device_type::SOFTWARE;
|
|
||||||
setup_keys(password);
|
setup_keys(password);
|
||||||
|
|
||||||
create_keys_file(wallet_, false, password, create_address_file);
|
create_keys_file(wallet_, false, password, create_address_file);
|
||||||
@ -4288,13 +4281,7 @@ void wallet2::restore(const std::string& wallet_, const epee::wipeable_string& p
|
|||||||
hwdev.set_callback(get_device_callback());
|
hwdev.set_callback(get_device_callback());
|
||||||
|
|
||||||
m_account.create_from_device(hwdev);
|
m_account.create_from_device(hwdev);
|
||||||
m_key_device_type = m_account.get_device().get_type();
|
init_type(m_account.get_device().get_type());
|
||||||
m_account_public_address = m_account.get_keys().m_account_address;
|
|
||||||
m_watch_only = false;
|
|
||||||
m_multisig = false;
|
|
||||||
m_multisig_threshold = 0;
|
|
||||||
m_multisig_signers.clear();
|
|
||||||
m_original_keys_available = false;
|
|
||||||
setup_keys(password);
|
setup_keys(password);
|
||||||
m_device_name = device_name;
|
m_device_name = device_name;
|
||||||
|
|
||||||
@ -4426,10 +4413,9 @@ std::string wallet2::make_multisig(const epee::wipeable_string &password,
|
|||||||
"Failed to create multisig wallet due to bad keys");
|
"Failed to create multisig wallet due to bad keys");
|
||||||
memwipe(&spend_skey, sizeof(rct::key));
|
memwipe(&spend_skey, sizeof(rct::key));
|
||||||
|
|
||||||
m_account_public_address = m_account.get_keys().m_account_address;
|
init_type(hw::device::device_type::SOFTWARE);
|
||||||
m_watch_only = false;
|
m_original_keys_available = true;
|
||||||
m_multisig = true;
|
m_multisig = true;
|
||||||
m_key_device_type = hw::device::device_type::SOFTWARE;
|
|
||||||
m_multisig_threshold = threshold;
|
m_multisig_threshold = threshold;
|
||||||
m_multisig_signers = multisig_signers;
|
m_multisig_signers = multisig_signers;
|
||||||
++m_multisig_rounds_passed;
|
++m_multisig_rounds_passed;
|
||||||
|
@ -1342,6 +1342,7 @@ namespace tools
|
|||||||
void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const;
|
void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const;
|
||||||
std::shared_ptr<std::map<std::pair<uint64_t, uint64_t>, size_t>> create_output_tracker_cache() const;
|
std::shared_ptr<std::map<std::pair<uint64_t, uint64_t>, size_t>> create_output_tracker_cache() const;
|
||||||
|
|
||||||
|
void init_type(hw::device::device_type device_type);
|
||||||
void setup_new_blockchain();
|
void setup_new_blockchain();
|
||||||
void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file);
|
void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user