@@ -4118,6 +4118,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4118
4118
4119
4119
epee::wipeable_string multisig_keys;
4120
4120
epee::wipeable_string password;
4121
+ epee::wipeable_string seed_pass;
4121
4122
4122
4123
if (!handle_command_line (vm))
4123
4124
return false ;
@@ -4224,19 +4225,9 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4224
4225
auto pwd_container = password_prompter (tr (" Enter seed offset passphrase, empty if none" ), false );
4225
4226
if (std::cin.eof () || !pwd_container)
4226
4227
return false ;
4227
- epee::wipeable_string seed_pass = pwd_container->password ();
4228
- if (!seed_pass.empty ())
4229
- {
4230
- if (m_restore_multisig_wallet)
4231
- {
4232
- crypto::secret_key key;
4233
- crypto::cn_slow_hash (seed_pass.data (), seed_pass.size (), (crypto::hash&)key);
4234
- sc_reduce32 ((unsigned char *)key.data );
4235
- multisig_keys = m_wallet->decrypt <epee::wipeable_string>(std::string (multisig_keys.data (), multisig_keys.size ()), key, true );
4236
- }
4237
- else
4238
- m_recovery_key = cryptonote::decrypt_key (m_recovery_key, seed_pass);
4239
- }
4228
+ seed_pass = pwd_container->password ();
4229
+ if (!seed_pass.empty () && !m_restore_multisig_wallet)
4230
+ m_recovery_key = cryptonote::decrypt_key (m_recovery_key, seed_pass);
4240
4231
}
4241
4232
if (!m_generate_from_view_key.empty ())
4242
4233
{
@@ -4579,7 +4570,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4579
4570
m_wallet_file = m_generate_new;
4580
4571
boost::optional<epee::wipeable_string> r;
4581
4572
if (m_restore_multisig_wallet)
4582
- r = new_wallet (vm, multisig_keys, old_language);
4573
+ r = new_wallet (vm, multisig_keys, seed_pass, old_language);
4583
4574
else
4584
4575
r = new_wallet (vm, m_recovery_key, m_restore_deterministic_wallet, m_non_deterministic, old_language);
4585
4576
CHECK_AND_ASSERT_MES (r, false , tr (" account creation failed" ));
@@ -5070,7 +5061,7 @@ boost::optional<epee::wipeable_string> simple_wallet::new_wallet(const boost::pr
5070
5061
}
5071
5062
// ----------------------------------------------------------------------------------------------------
5072
5063
boost::optional<epee::wipeable_string> simple_wallet::new_wallet (const boost::program_options::variables_map& vm,
5073
- const epee::wipeable_string &multisig_keys, const std::string &old_language)
5064
+ const epee::wipeable_string &multisig_keys, const epee::wipeable_string &seed_pass, const std::string &old_language)
5074
5065
{
5075
5066
std::pair<std::unique_ptr<tools::wallet2>, tools::password_container> rc;
5076
5067
try { rc = tools::wallet2::make_new (vm, false , password_prompter); }
@@ -5104,7 +5095,16 @@ boost::optional<epee::wipeable_string> simple_wallet::new_wallet(const boost::pr
5104
5095
5105
5096
try
5106
5097
{
5107
- m_wallet->generate (m_wallet_file, std::move (rc.second ).password (), multisig_keys, create_address_file);
5098
+ if (seed_pass.empty ())
5099
+ m_wallet->generate (m_wallet_file, std::move (rc.second ).password (), multisig_keys, create_address_file);
5100
+ else
5101
+ {
5102
+ crypto::secret_key key;
5103
+ crypto::cn_slow_hash (seed_pass.data (), seed_pass.size (), (crypto::hash&)key);
5104
+ sc_reduce32 ((unsigned char *)key.data );
5105
+ const epee::wipeable_string &msig_keys = m_wallet->decrypt <epee::wipeable_string>(std::string (multisig_keys.data (), multisig_keys.size ()), key, true );
5106
+ m_wallet->generate (m_wallet_file, std::move (rc.second ).password (), msig_keys, create_address_file);
5107
+ }
5108
5108
bool ready;
5109
5109
uint32_t threshold, total;
5110
5110
if (!m_wallet->multisig (&ready, &threshold, &total) || !ready)
0 commit comments