aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-11-16 11:09:41 +0200
committerRiccardo Spagni <ric@spagni.net>2018-11-16 11:09:41 +0200
commit40bb7a304a83cdc7109cee279c2d20a4e5175581 (patch)
tree32b814024c1099ddadda5f62964db5b3f453d086 /src/simplewallet
parentMerge pull request #4791 (diff)
parentsimplewallet: reorganize SCOPED_WALLET_UNLOCK a bit more (diff)
downloadmonero-40bb7a304a83cdc7109cee279c2d20a4e5175581.tar.xz
Merge pull request #4792
5d4f3df8 simplewallet: reorganize SCOPED_WALLET_UNLOCK a bit more (stoffu)
Diffstat (limited to 'src/simplewallet')
-rw-r--r--src/simplewallet/simplewallet.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 1773172f2..a485ec378 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -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>()*/)
{
- SCOPED_WALLET_UNLOCK();
// don't log
PAUSE_READLINE();
if (m_wallet->key_on_device()) {
std::cout << "secret: On device. Not available" << std::endl;
} else {
+ SCOPED_WALLET_UNLOCK();
printf("secret: ");
print_secret_key(m_wallet->get_account().get_keys().m_view_secret_key);
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");
return true;
}
- SCOPED_WALLET_UNLOCK();
// don't log
PAUSE_READLINE();
if (m_wallet->key_on_device()) {
std::cout << "secret: On device. Not available" << std::endl;
} else {
+ SCOPED_WALLET_UNLOCK();
printf("secret: ");
print_secret_key(m_wallet->get_account().get_keys().m_spend_secret_key);
putchar('\n');
@@ -635,8 +635,6 @@ bool simple_wallet::print_seed(bool encrypted)
return true;
}
- SCOPED_WALLET_UNLOCK();
-
multisig = m_wallet->multisig(&ready);
if (multisig)
{
@@ -646,7 +644,10 @@ bool simple_wallet::print_seed(bool encrypted)
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");
return true;
@@ -1075,11 +1076,12 @@ bool simple_wallet::export_multisig(const std::vector<std::string> &args)
return true;
}
- SCOPED_WALLET_UNLOCK();
-
const std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true;
+
+ SCOPED_WALLET_UNLOCK();
+
try
{
cryptonote::blobdata ciphertext = m_wallet->export_multisig();
@@ -1127,8 +1129,6 @@ bool simple_wallet::import_multisig(const std::vector<std::string> &args)
return true;
}
- SCOPED_WALLET_UNLOCK();
-
std::vector<cryptonote::blobdata> info;
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));
}
+ SCOPED_WALLET_UNLOCK();
+
// all read and parsed, actually import
try
{
@@ -1280,11 +1282,11 @@ bool simple_wallet::submit_multisig(const std::vector<std::string> &args)
return true;
}
- SCOPED_WALLET_UNLOCK();
-
if (!try_connect_to_daemon())
return true;
+ SCOPED_WALLET_UNLOCK();
+
std::string filename = args[0];
try
{
@@ -1348,11 +1350,12 @@ bool simple_wallet::export_raw_multisig(const std::vector<std::string> &args)
return true;
}
- SCOPED_WALLET_UNLOCK();
-
std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true;
+
+ SCOPED_WALLET_UNLOCK();
+
try
{
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_)
{
- SCOPED_WALLET_UNLOCK();
if (!try_connect_to_daemon())
return true;
@@ -5831,6 +5833,8 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
}
}
+ SCOPED_WALLET_UNLOCK();
+
try
{
// figure out what tx will be necessary
@@ -7942,7 +7946,6 @@ bool simple_wallet::sign(const std::vector<std::string> &args)
return true;
}
- SCOPED_WALLET_UNLOCK();
std::string filename = args[0];
std::string 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;
return true;
}
+
+ SCOPED_WALLET_UNLOCK();
+
std::string signature = m_wallet->sign(data);
success_msg_writer() << signature;
return true;
@@ -8012,11 +8018,12 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args)
return true;
}
- SCOPED_WALLET_UNLOCK();
std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true;
+ SCOPED_WALLET_UNLOCK();
+
try
{
if (!m_wallet->export_key_images(filename))
@@ -8158,11 +8165,12 @@ bool simple_wallet::export_outputs(const std::vector<std::string> &args)
return true;
}
- SCOPED_WALLET_UNLOCK();
std::string filename = args[0];
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
return true;
+ SCOPED_WALLET_UNLOCK();
+
try
{
std::string data = m_wallet->export_outputs_to_str();