Merge pull request #4792

5d4f3df8 simplewallet: reorganize SCOPED_WALLET_UNLOCK a bit more (stoffu)
This commit is contained in:
Riccardo Spagni 2018-11-16 11:09:41 +02:00
commit 40bb7a304a
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -581,12 +581,12 @@ std::string simple_wallet::get_command_usage(const std::vector<std::string> &arg
bool simple_wallet::viewkey(const std::vector<std::string> &args/* = std::vector<std::string>()*/) bool simple_wallet::viewkey(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{ {
SCOPED_WALLET_UNLOCK();
// don't log // don't log
PAUSE_READLINE(); PAUSE_READLINE();
if (m_wallet->key_on_device()) { if (m_wallet->key_on_device()) {
std::cout << "secret: On device. Not available" << std::endl; std::cout << "secret: On device. Not available" << std::endl;
} else { } else {
SCOPED_WALLET_UNLOCK();
printf("secret: "); printf("secret: ");
print_secret_key(m_wallet->get_account().get_keys().m_view_secret_key); print_secret_key(m_wallet->get_account().get_keys().m_view_secret_key);
putchar('\n'); putchar('\n');
@ -603,12 +603,12 @@ bool simple_wallet::spendkey(const std::vector<std::string> &args/* = std::vecto
fail_msg_writer() << tr("wallet is watch-only and has no spend key"); fail_msg_writer() << tr("wallet is watch-only and has no spend key");
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
// don't log // don't log
PAUSE_READLINE(); PAUSE_READLINE();
if (m_wallet->key_on_device()) { if (m_wallet->key_on_device()) {
std::cout << "secret: On device. Not available" << std::endl; std::cout << "secret: On device. Not available" << std::endl;
} else { } else {
SCOPED_WALLET_UNLOCK();
printf("secret: "); printf("secret: ");
print_secret_key(m_wallet->get_account().get_keys().m_spend_secret_key); print_secret_key(m_wallet->get_account().get_keys().m_spend_secret_key);
putchar('\n'); putchar('\n');
@ -635,8 +635,6 @@ bool simple_wallet::print_seed(bool encrypted)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
multisig = m_wallet->multisig(&ready); multisig = m_wallet->multisig(&ready);
if (multisig) if (multisig)
{ {
@ -646,7 +644,10 @@ bool simple_wallet::print_seed(bool encrypted)
return true; return true;
} }
} }
else if (!m_wallet->is_deterministic())
SCOPED_WALLET_UNLOCK();
if (!multisig && !m_wallet->is_deterministic())
{ {
fail_msg_writer() << tr("wallet is non-deterministic and has no seed"); fail_msg_writer() << tr("wallet is non-deterministic and has no seed");
return true; return true;
@ -1075,11 +1076,12 @@ bool simple_wallet::export_multisig(const std::vector<std::string> &args)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
const std::string filename = args[0]; const std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true; return true;
SCOPED_WALLET_UNLOCK();
try try
{ {
cryptonote::blobdata ciphertext = m_wallet->export_multisig(); cryptonote::blobdata ciphertext = m_wallet->export_multisig();
@ -1127,8 +1129,6 @@ bool simple_wallet::import_multisig(const std::vector<std::string> &args)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
std::vector<cryptonote::blobdata> info; std::vector<cryptonote::blobdata> info;
for (size_t n = 0; n < args.size(); ++n) for (size_t n = 0; n < args.size(); ++n)
{ {
@ -1143,6 +1143,8 @@ bool simple_wallet::import_multisig(const std::vector<std::string> &args)
info.push_back(std::move(data)); info.push_back(std::move(data));
} }
SCOPED_WALLET_UNLOCK();
// all read and parsed, actually import // all read and parsed, actually import
try try
{ {
@ -1280,11 +1282,11 @@ bool simple_wallet::submit_multisig(const std::vector<std::string> &args)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
if (!try_connect_to_daemon()) if (!try_connect_to_daemon())
return true; return true;
SCOPED_WALLET_UNLOCK();
std::string filename = args[0]; std::string filename = args[0];
try try
{ {
@ -1348,11 +1350,12 @@ bool simple_wallet::export_raw_multisig(const std::vector<std::string> &args)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
std::string filename = args[0]; std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true; return true;
SCOPED_WALLET_UNLOCK();
try try
{ {
tools::wallet2::multisig_tx_set txs; tools::wallet2::multisig_tx_set txs;
@ -5683,7 +5686,6 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<st
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
bool simple_wallet::sweep_single(const std::vector<std::string> &args_) bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
{ {
SCOPED_WALLET_UNLOCK();
if (!try_connect_to_daemon()) if (!try_connect_to_daemon())
return true; return true;
@ -5831,6 +5833,8 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
} }
} }
SCOPED_WALLET_UNLOCK();
try try
{ {
// figure out what tx will be necessary // figure out what tx will be necessary
@ -7942,7 +7946,6 @@ bool simple_wallet::sign(const std::vector<std::string> &args)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
std::string filename = args[0]; std::string filename = args[0];
std::string data; std::string data;
bool r = epee::file_io_utils::load_file_to_string(filename, data); bool r = epee::file_io_utils::load_file_to_string(filename, data);
@ -7951,6 +7954,9 @@ bool simple_wallet::sign(const std::vector<std::string> &args)
fail_msg_writer() << tr("failed to read file ") << filename; fail_msg_writer() << tr("failed to read file ") << filename;
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
std::string signature = m_wallet->sign(data); std::string signature = m_wallet->sign(data);
success_msg_writer() << signature; success_msg_writer() << signature;
return true; return true;
@ -8012,11 +8018,12 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
std::string filename = args[0]; std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true; return true;
SCOPED_WALLET_UNLOCK();
try try
{ {
if (!m_wallet->export_key_images(filename)) if (!m_wallet->export_key_images(filename))
@ -8158,11 +8165,12 @@ bool simple_wallet::export_outputs(const std::vector<std::string> &args)
return true; return true;
} }
SCOPED_WALLET_UNLOCK();
std::string filename = args[0]; std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true; return true;
SCOPED_WALLET_UNLOCK();
try try
{ {
std::string data = m_wallet->export_outputs_to_str(); std::string data = m_wallet->export_outputs_to_str();