aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 03693a57c..a35ee40ae 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -912,16 +912,6 @@ bool simple_wallet::change_password(const std::vector<std::string> &args)
bool simple_wallet::payment_id(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
LONG_PAYMENT_ID_SUPPORT_CHECK();
-
- crypto::hash payment_id;
- if (args.size() > 0)
- {
- PRINT_USAGE(USAGE_PAYMENT_ID);
- return true;
- }
- payment_id = crypto::rand<crypto::hash>();
- success_msg_writer() << tr("Random payment ID: ") << payment_id;
- return true;
}
bool simple_wallet::print_fee_info(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
@@ -6293,13 +6283,6 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
if (tools::wallet2::parse_long_payment_id(payment_id_str, payment_id))
{
LONG_PAYMENT_ID_SUPPORT_CHECK();
-
- std::string extra_nonce;
- set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
- r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
- local_args.pop_back();
- payment_id_seen = true;
- message_writer() << tr("Warning: Unencrypted payment IDs will harm your privacy: ask the recipient to use subaddresses instead");
}
if(!r)
{
@@ -6408,8 +6391,6 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
else if (tools::wallet2::parse_payment_id(payment_id_uri, payment_id))
{
LONG_PAYMENT_ID_SUPPORT_CHECK();
- set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
- message_writer() << tr("Warning: Unencrypted payment IDs will harm your privacy: ask the recipient to use subaddresses instead");
}
else
{
@@ -6945,11 +6926,6 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<st
if(r)
{
LONG_PAYMENT_ID_SUPPORT_CHECK();
-
- std::string extra_nonce;
- set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
- r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
- payment_id_seen = true;
}
if(!r && local_args.size() == 3)
@@ -7191,7 +7167,6 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
if (tools::wallet2::parse_long_payment_id(local_args.back(), payment_id))
{
LONG_PAYMENT_ID_SUPPORT_CHECK();
- set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
}
else
{
@@ -8356,7 +8331,11 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
m_in_manual_refresh.store(true, std::memory_order_relaxed);
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
- m_wallet->update_pool_state();
+ std::vector<std::pair<cryptonote::transaction, bool>> process_txs;
+ m_wallet->update_pool_state(process_txs);
+ if (!process_txs.empty())
+ m_wallet->process_pool_state(process_txs);
+
std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>> payments;
m_wallet->get_unconfirmed_payments(payments, m_current_subaddress_account, subaddr_indices);
for (std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>>::const_iterator i = payments.begin(); i != payments.end(); ++i) {
@@ -8803,22 +8782,41 @@ void simple_wallet::check_for_messages()
//----------------------------------------------------------------------------------------------------
void simple_wallet::wallet_idle_thread()
{
+ const boost::posix_time::ptime start_time = boost::posix_time::microsec_clock::universal_time();
while (true)
{
boost::unique_lock<boost::mutex> lock(m_idle_mutex);
if (!m_idle_run.load(std::memory_order_relaxed))
break;
+ // if another thread was busy (ie, a foreground refresh thread), we'll end up here at
+ // some random time that's not what we slept for, so we should not call refresh now
+ // or we'll be leaking that fact through timing
+ const boost::posix_time::ptime now0 = boost::posix_time::microsec_clock::universal_time();
+ const uint64_t dt_actual = (now0 - start_time).total_microseconds() % 1000000;
+#ifdef _WIN32
+ static const uint64_t threshold = 10000;
+#else
+ static const uint64_t threshold = 2000;
+#endif
+ if (dt_actual < threshold) // if less than a threshold... would a very slow machine always miss it ?
+ {
#ifndef _WIN32
- m_inactivity_checker.do_call(boost::bind(&simple_wallet::check_inactivity, this));
+ m_inactivity_checker.do_call(boost::bind(&simple_wallet::check_inactivity, this));
#endif
- m_refresh_checker.do_call(boost::bind(&simple_wallet::check_refresh, this));
- m_mms_checker.do_call(boost::bind(&simple_wallet::check_mms, this));
- m_rpc_payment_checker.do_call(boost::bind(&simple_wallet::check_rpc_payment, this));
+ m_refresh_checker.do_call(boost::bind(&simple_wallet::check_refresh, this));
+ m_mms_checker.do_call(boost::bind(&simple_wallet::check_mms, this));
+ m_rpc_payment_checker.do_call(boost::bind(&simple_wallet::check_rpc_payment, this));
- if (!m_idle_run.load(std::memory_order_relaxed))
- break;
- m_idle_cond.wait_for(lock, boost::chrono::seconds(1));
+ if (!m_idle_run.load(std::memory_order_relaxed))
+ break;
+ }
+
+ // aim for the next multiple of 1 second
+ const boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
+ const auto dt = (now - start_time).total_microseconds();
+ const auto wait = 1000000 - dt % 1000000;
+ m_idle_cond.wait_for(lock, boost::chrono::microseconds(wait));
}
}
//----------------------------------------------------------------------------------------------------
@@ -9398,7 +9396,6 @@ bool simple_wallet::address_book(const std::vector<std::string> &args/* = std::v
if (tools::wallet2::parse_long_payment_id(args[3], payment_id))
{
LONG_PAYMENT_ID_SUPPORT_CHECK();
- description_start += 2;
}
else if (tools::wallet2::parse_short_payment_id(args[3], info.payment_id))
{
@@ -10002,7 +9999,11 @@ bool simple_wallet::show_transfer(const std::vector<std::string> &args)
try
{
- m_wallet->update_pool_state();
+ std::vector<std::pair<cryptonote::transaction, bool>> process_txs;
+ m_wallet->update_pool_state(process_txs);
+ if (!process_txs.empty())
+ m_wallet->process_pool_state(process_txs);
+
std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>> pool_payments;
m_wallet->get_unconfirmed_payments(pool_payments, m_current_subaddress_account);
for (std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>>::const_iterator i = pool_payments.begin(); i != pool_payments.end(); ++i) {