@ -33,7 +33,6 @@
*
* \ brief Source file that defines simple_wallet class .
*/
# include <thread>
# include <iostream>
# include <sstream>
@ -348,7 +347,8 @@ bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = s
fail_msg_writer ( ) < < tr ( " wallet is non-deterministic and has no seed " ) ;
return true ;
}
tools : : password_container pwd_container ;
tools : : password_container pwd_container ( m_wallet_file . empty ( ) ) ;
success = pwd_container . read_password ( ) ;
if ( ! success )
{
@ -380,7 +380,7 @@ bool simple_wallet::set_always_confirm_transfers(const std::vector<std::string>
fail_msg_writer ( ) < < tr ( " wallet is watch-only and cannot transfer " ) ;
return true ;
}
tools : : password_container pwd_container ;
tools : : password_container pwd_container (m_wallet_file . empty ( ) ) ;
success = pwd_container . read_password ( ) ;
if ( ! success )
{
@ -409,7 +409,8 @@ bool simple_wallet::set_store_tx_info(const std::vector<std::string> &args/* = s
fail_msg_writer ( ) < < tr ( " wallet is watch-only and cannot transfer " ) ;
return true ;
}
tools : : password_container pwd_container ;
tools : : password_container pwd_container ( m_wallet_file . empty ( ) ) ;
success = pwd_container . read_password ( ) ;
if ( ! success )
{
@ -453,8 +454,9 @@ bool simple_wallet::set_default_mixin(const std::vector<std::string> &args/* = s
}
if ( mixin = = 0 )
mixin = DEFAULT_MIX ;
tools : : password_container pwd_container ( m_wallet_file . empty ( ) ) ;
tools : : password_container pwd_container ;
success = pwd_container . read_password ( ) ;
if ( ! success )
{
@ -515,8 +517,8 @@ bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &a
return true ;
}
}
tools : : password_container pwd_container ;
tools : : password_container pwd_container (m_wallet_file . empty ( ) ) ;
success = pwd_container . read_password ( ) ;
if ( ! success )
{
@ -550,9 +552,10 @@ bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &a
bool simple_wallet : : set_auto_refresh ( const std : : vector < std : : string > & args /* = std::vector<std::string>()*/ )
{
bool success = false ;
tools : : password_container pwd_container ;
success = pwd_container . read_password ( ) ;
tools : : password_container pwd_container ( m_wallet_file . empty ( ) ) ;
bool success = pwd_container . read_password ( ) ;
if ( ! success )
{
fail_msg_writer ( ) < < tr ( " failed to read wallet password " ) ;
@ -594,8 +597,8 @@ bool simple_wallet::set_refresh_type(const std::vector<std::string> &args/* = st
{
return true ;
}
tools : : password_container pwd_container ;
tools : : password_container pwd_container (m_wallet_file . empty ( ) ) ;
success = pwd_container . read_password ( ) ;
if ( ! success )
{
@ -861,7 +864,7 @@ bool simple_wallet::ask_wallet_create_if_needed()
bool r ;
if ( keys_file_exists )
{
m_wallet_file = wallet_path ;
m_wallet_file = wallet_path ;
r = true ;
} else
{
@ -896,7 +899,7 @@ void simple_wallet::print_seed(std::string seed)
}
//----------------------------------------------------------------------------------------------------
static bool get_password ( const boost : : program_options : : variables_map & vm , bool allow_entry , tools : : password_container & pwd_container )
bool simple_wallet : : get_password ( const boost : : program_options : : variables_map & vm , bool allow_entry , tools : : password_container & pwd_container )
{
// has_arg returns true even when the parameter is not passed ??
const std : : string gfj = command_line : : get_arg ( vm , arg_generate_from_json ) ;
@ -937,6 +940,8 @@ static bool get_password(const boost::program_options::variables_map& vm, bool a
if ( allow_entry )
{
//vm is already part of the password container class. just need to check vm for an already existing wallet
//here need to pass in variable map. This will indicate if the wallet already exists to the read password function
bool r = pwd_container . read_password ( ) ;
if ( ! r )
{
@ -1084,7 +1089,7 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m
}
}
m_wallet_file = field_filename ;
m_wallet_file = field_filename ;
bool was_deprecated_wallet = m_restore_deterministic_wallet & & ( ( old_language = = crypto : : ElectrumWords : : old_language_name ) | |
crypto : : ElectrumWords : : get_is_old_style_seed ( m_electrum_seed ) ) ;
@ -1222,9 +1227,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
}
}
catch ( const std : : exception & e ) { }
tools : : password_container pwd_container ;
if ( ! get_password ( vm , true , pwd_container ) )
tools : : password_container pwd_container ( m_wallet_file . empty ( ) ) ; //m_wallet_file will be empty at this point for new wallets
if ( ! cryptonote : : simple_wallet : : get_password ( vm , true , pwd_container ) )
return false ;
if ( ! m_generate_new . empty ( ) | | m_restore_deterministic_wallet | | ! m_generate_from_view_key . empty ( ) | | ! m_generate_from_keys . empty ( ) | | ! m_generate_from_json . empty ( ) )
@ -1310,7 +1314,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
}
crypto : : secret_key viewkey = * reinterpret_cast < const crypto : : secret_key * > ( viewkey_data . data ( ) ) ;
m_wallet_file = m_generate_from_view_key ;
m_wallet_file = m_generate_from_view_key ;
// check the view key matches the given address
crypto : : public_key pkey ;
@ -1377,7 +1381,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
}
crypto : : secret_key viewkey = * reinterpret_cast < const crypto : : secret_key * > ( viewkey_data . data ( ) ) ;
m_wallet_file = m_generate_from_keys ;
m_wallet_file = m_generate_from_keys ;
// check the spend and view keys match the given address
crypto : : public_key pkey ;
@ -1539,7 +1543,8 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
return false ;
}
m_wallet_file = wallet_file ;
m_wallet_file = wallet_file ;
m_wallet . reset ( new tools : : wallet2 ( testnet ) ) ;
m_wallet - > callback ( this ) ;
@ -1598,7 +1603,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
bool simple_wallet : : new_wallet ( const std : : string & wallet_file , const std : : string & password , const cryptonote : : account_public_address & address ,
const crypto : : secret_key & viewkey , bool testnet )
{
m_wallet_file = wallet_file ;
m_wallet_file = wallet_file ;
m_wallet . reset ( new tools : : wallet2 ( testnet ) ) ;
m_wallet - > callback ( this ) ;
@ -1626,7 +1631,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
bool simple_wallet : : new_wallet ( const std : : string & wallet_file , const std : : string & password , const cryptonote : : account_public_address & address ,
const crypto : : secret_key & spendkey , const crypto : : secret_key & viewkey , bool testnet )
{
m_wallet_file = wallet_file ;
m_wallet_file = wallet_file ;
m_wallet . reset ( new tools : : wallet2 ( testnet ) ) ;
m_wallet - > callback ( this ) ;
@ -1658,7 +1663,7 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa
return false ;
}
m_wallet_file = wallet_file ;
m_wallet_file = wallet_file ;
m_wallet . reset ( new tools : : wallet2 ( testnet ) ) ;
m_wallet - > callback ( this ) ;
@ -1764,7 +1769,7 @@ bool simple_wallet::save(const std::vector<std::string> &args)
bool simple_wallet : : save_watch_only ( const std : : vector < std : : string > & args /* = std::vector<std::string>()*/ )
{
bool success = false ;
tools : : password_container pwd_container ;
tools : : password_container pwd_container (m_wallet_file . empty ( ) ) ;
success = pwd_container . read_password ( tr ( " Password for the new watch-only wallet " ) ) ;
if ( ! success )
@ -3753,8 +3758,9 @@ int main(int argc, char* argv[])
bool testnet = command_line : : get_arg ( vm , arg_testnet ) ;
bool restricted = command_line : : get_arg ( vm , arg_restricted ) ;
std : : string wallet_file = command_line : : get_arg ( vm , arg_wallet_file ) ;
tools : : password_container pwd_container ;
if ( ! get_password ( vm , false , pwd_container ) )
tools : : password_container pwd_container ( wallet_file . empty ( ) ) ;
if ( ! cryptonote : : simple_wallet : : get_password ( vm , false , pwd_container ) )
return 1 ;
std : : string daemon_address = command_line : : get_arg ( vm , arg_daemon_address ) ;
std : : string daemon_host = command_line : : get_arg ( vm , arg_daemon_host ) ;