@@ -4116,6 +4116,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4116
4116
4117
4117
epee::wipeable_string multisig_keys;
4118
4118
epee::wipeable_string password;
4119
+ epee::wipeable_string seed_pass;
4119
4120
4120
4121
if (!handle_command_line (vm))
4121
4122
return false ;
@@ -4132,6 +4133,17 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4132
4133
if (!ask_wallet_create_if_needed ()) return false ;
4133
4134
}
4134
4135
4136
+ bool enable_multisig = false ;
4137
+ if (m_restore_multisig_wallet) {
4138
+ fail_msg_writer () << tr (" Multisig is disabled." );
4139
+ fail_msg_writer () << tr (" Multisig is an experimental feature and may have bugs. Things that could go wrong include: funds sent to a multisig wallet can't be spent at all, can only be spent with the participation of a malicious group member, or can be stolen by a malicious group member." );
4140
+ if (!command_line::is_yes (input_line (" Do you want to continue restoring a multisig wallet?" , true ))) {
4141
+ message_writer () << tr (" You have canceled restoring a multisig wallet." );
4142
+ return false ;
4143
+ }
4144
+ enable_multisig = true ;
4145
+ }
4146
+
4135
4147
if (!m_generate_new.empty () || m_restoring)
4136
4148
{
4137
4149
if (!m_subaddress_lookahead.empty () && !parse_subaddress_lookahead (m_subaddress_lookahead))
@@ -4211,19 +4223,9 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4211
4223
auto pwd_container = password_prompter (tr (" Enter seed offset passphrase, empty if none" ), false );
4212
4224
if (std::cin.eof () || !pwd_container)
4213
4225
return false ;
4214
- epee::wipeable_string seed_pass = pwd_container->password ();
4215
- if (!seed_pass.empty ())
4216
- {
4217
- if (m_restore_multisig_wallet)
4218
- {
4219
- crypto::secret_key key;
4220
- crypto::cn_slow_hash (seed_pass.data (), seed_pass.size (), (crypto::hash&)key);
4221
- sc_reduce32 ((unsigned char *)key.data );
4222
- multisig_keys = m_wallet->decrypt <epee::wipeable_string>(std::string (multisig_keys.data (), multisig_keys.size ()), key, true );
4223
- }
4224
- else
4225
- m_recovery_key = cryptonote::decrypt_key (m_recovery_key, seed_pass);
4226
- }
4226
+ seed_pass = pwd_container->password ();
4227
+ if (!seed_pass.empty () && !m_restore_multisig_wallet)
4228
+ m_recovery_key = cryptonote::decrypt_key (m_recovery_key, seed_pass);
4227
4229
}
4228
4230
if (!m_generate_from_view_key.empty ())
4229
4231
{
@@ -4566,7 +4568,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4566
4568
m_wallet_file = m_generate_new;
4567
4569
boost::optional<epee::wipeable_string> r;
4568
4570
if (m_restore_multisig_wallet)
4569
- r = new_wallet (vm, multisig_keys, old_language);
4571
+ r = new_wallet (vm, multisig_keys, seed_pass, old_language);
4570
4572
else
4571
4573
r = new_wallet (vm, m_recovery_key, m_restore_deterministic_wallet, m_non_deterministic, old_language);
4572
4574
CHECK_AND_ASSERT_MES (r, false , tr (" account creation failed" ));
@@ -4665,6 +4667,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
4665
4667
}
4666
4668
m_wallet->set_refresh_from_block_height (m_restore_height);
4667
4669
}
4670
+ if (enable_multisig)
4671
+ m_wallet->enable_multisig (true );
4668
4672
m_wallet->rewrite (m_wallet_file, password);
4669
4673
}
4670
4674
else
@@ -5062,7 +5066,7 @@ boost::optional<epee::wipeable_string> simple_wallet::new_wallet(const boost::pr
5062
5066
}
5063
5067
// ----------------------------------------------------------------------------------------------------
5064
5068
boost::optional<epee::wipeable_string> simple_wallet::new_wallet (const boost::program_options::variables_map& vm,
5065
- const epee::wipeable_string &multisig_keys, const std::string &old_language)
5069
+ const epee::wipeable_string &multisig_keys, const epee::wipeable_string &seed_pass, const std::string &old_language)
5066
5070
{
5067
5071
std::pair<std::unique_ptr<tools::wallet2>, tools::password_container> rc;
5068
5072
try { rc = tools::wallet2::make_new (vm, false , password_prompter); }
@@ -5096,7 +5100,16 @@ boost::optional<epee::wipeable_string> simple_wallet::new_wallet(const boost::pr
5096
5100
5097
5101
try
5098
5102
{
5099
- m_wallet->generate (m_wallet_file, std::move (rc.second ).password (), multisig_keys, create_address_file);
5103
+ if (seed_pass.empty ())
5104
+ m_wallet->generate (m_wallet_file, std::move (rc.second ).password (), multisig_keys, create_address_file);
5105
+ else
5106
+ {
5107
+ crypto::secret_key key;
5108
+ crypto::cn_slow_hash (seed_pass.data (), seed_pass.size (), (crypto::hash&)key);
5109
+ sc_reduce32 ((unsigned char *)key.data );
5110
+ const epee::wipeable_string &msig_keys = m_wallet->decrypt <epee::wipeable_string>(std::string (multisig_keys.data (), multisig_keys.size ()), key, true );
5111
+ m_wallet->generate (m_wallet_file, std::move (rc.second ).password (), msig_keys, create_address_file);
5112
+ }
5100
5113
bool ready;
5101
5114
uint32_t threshold, total;
5102
5115
if (!m_wallet->multisig (&ready, &threshold, &total) || !ready)
0 commit comments