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.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 862edb4c0..5efa54a19 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -108,7 +108,7 @@ typedef cryptonote::simple_wallet sw;
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ \
/* m_idle_mutex is still locked here */ \
m_auto_refresh_enabled.store(auto_refresh_enabled, std::memory_order_relaxed); \
- m_suspend_rpc_payment_mining.store(false, std::memory_order_relaxed);; \
+ m_suspend_rpc_payment_mining.store(false, std::memory_order_relaxed); \
m_rpc_payment_checker.trigger(); \
m_idle_cond.notify_one(); \
})
@@ -1691,7 +1691,7 @@ bool simple_wallet::print_ring(const std::vector<std::string> &args)
rings.push_back({key_image, ring});
else if (!m_wallet->get_rings(txid, rings))
{
- fail_msg_writer() << tr("Key image either not spent, or spent with mixin 0");
+ fail_msg_writer() << tr("Key image either not spent, or spent with ring size 1");
return true;
}
@@ -1963,7 +1963,7 @@ bool simple_wallet::rpc_payment_info(const std::vector<std::string> &args)
if (expected)
message_writer() << tr("Credit discrepancy this session: ") << discrepancy << " (" << 100.0f * discrepancy / expected << "%)";
float cph = credits_per_hash_found / (float)diff;
- message_writer() << tr("Difficulty: ") << diff << ", " << credits_per_hash_found << " " << tr("credits per hash found, ") << cph << " " << tr("credits/hash");;
+ message_writer() << tr("Difficulty: ") << diff << ", " << credits_per_hash_found << " " << tr("credits per hash found, ") << cph << " " << tr("credits/hash");
const boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
bool mining = (now - m_last_rpc_payment_mining_time).total_microseconds() < 1000000;
if (mining)
@@ -6064,11 +6064,14 @@ std::pair<std::string, std::string> simple_wallet::show_outputs_line(const std::
return std::make_pair(ostr.str(), ring_str);
}
//----------------------------------------------------------------------------------------------------
-bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending_tx>& ptx_vector, std::ostream& ostr)
+bool simple_wallet::process_ring_members(const std::vector<tools::wallet2::pending_tx>& ptx_vector, std::ostream& ostr, bool verbose)
{
uint32_t version;
if (!try_connect_to_daemon(false, &version))
+ {
+ fail_msg_writer() << tr("failed to connect to daemon");
return false;
+ }
// available for RPC version 1.4 or higher
if (version < MAKE_CORE_RPC_VERSION(1, 4))
return true;
@@ -6084,7 +6087,8 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
{
const cryptonote::transaction& tx = ptx_vector[n].tx;
const tools::wallet2::tx_construction_data& construction_data = ptx_vector[n].construction_data;
- ostr << boost::format(tr("\nTransaction %llu/%llu: txid=%s")) % (n + 1) % ptx_vector.size() % cryptonote::get_transaction_hash(tx);
+ if (verbose)
+ ostr << boost::format(tr("\nTransaction %llu/%llu: txid=%s")) % (n + 1) % ptx_vector.size() % cryptonote::get_transaction_hash(tx);
// for each input
std::vector<uint64_t> spent_key_height(tx.vin.size());
std::vector<crypto::hash> spent_key_txid (tx.vin.size());
@@ -6105,7 +6109,8 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
}
const cryptonote::tx_source_entry& source = *sptr;
- ostr << boost::format(tr("\nInput %llu/%llu (%s): amount=%s")) % (i + 1) % tx.vin.size() % epee::string_tools::pod_to_hex(in_key.k_image) % print_money(source.amount);
+ if (verbose)
+ ostr << boost::format(tr("\nInput %llu/%llu (%s): amount=%s")) % (i + 1) % tx.vin.size() % epee::string_tools::pod_to_hex(in_key.k_image) % print_money(source.amount);
// convert relative offsets of ring member keys into absolute offsets (indices) associated with the amount
std::vector<uint64_t> absolute_offsets = cryptonote::relative_output_offsets_to_absolute(in_key.key_offsets);
// get block heights from which those ring member keys originated
@@ -6135,7 +6140,8 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
return false;
}
}
- ostr << tr("\nOriginating block heights: ");
+ if (verbose)
+ ostr << tr("\nOriginating block heights: ");
spent_key_height[i] = res.outs[source.real_output].height;
spent_key_txid [i] = res.outs[source.real_output].txid;
std::vector<uint64_t> heights(absolute_offsets.size(), 0);
@@ -6144,7 +6150,8 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
heights[j] = res.outs[j].height;
}
std::pair<std::string, std::string> ring_str = show_outputs_line(heights, blockchain_height, source.real_output);
- ostr << ring_str.first << tr("\n|") << ring_str.second << tr("|\n");
+ if (verbose)
+ ostr << ring_str.first << tr("\n|") << ring_str.second << tr("|\n");
}
// warn if rings contain keys originating from the same tx or temporally very close block heights
bool are_keys_from_same_tx = false;
@@ -6163,7 +6170,7 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
ostr
<< tr("\nWarning: Some input keys being spent are from ")
<< (are_keys_from_same_tx ? tr("the same transaction") : tr("blocks that are temporally very close"))
- << tr(", which can break the anonymity of ring signature. Make sure this is intentional!");
+ << tr(", which can break the anonymity of ring signatures. Make sure this is intentional!");
}
ostr << ENDL;
}
@@ -6604,11 +6611,8 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
float days = locked_blocks / 720.0f;
prompt << boost::format(tr(".\nThis transaction (including %s change) will unlock on block %llu, in approximately %s days (assuming 2 minutes per block)")) % cryptonote::print_money(change) % ((unsigned long long)unlock_block) % days;
}
- if (m_wallet->print_ring_members())
- {
- if (!print_ring_members(ptx_vector, prompt))
- return false;
- }
+ if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members()))
+ return false;
bool default_ring_size = true;
for (const auto &ptx: ptx_vector)
{
@@ -7064,7 +7068,7 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<st
if (subaddr_indices.size() > 1)
prompt << tr("WARNING: Outputs of multiple addresses are being used together, which might potentially compromise your privacy.\n");
}
- if (m_wallet->print_ring_members() && !print_ring_members(ptx_vector, prompt))
+ if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members()))
return true;
if (ptx_vector.size() > 1) {
prompt << boost::format(tr("Sweeping %s in %llu transactions for a total fee of %s. Is this okay?")) %
@@ -7308,7 +7312,7 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
uint64_t total_fee = ptx_vector[0].fee;
uint64_t total_sent = m_wallet->get_transfer_details(ptx_vector[0].selected_transfers.front()).amount();
std::ostringstream prompt;
- if (!print_ring_members(ptx_vector, prompt))
+ if (!process_ring_members(ptx_vector, prompt, m_wallet->print_ring_members()))
return true;
prompt << boost::format(tr("Sweeping %s for a total fee of %s. Is this okay?")) %
print_money(total_sent) %
@@ -8390,7 +8394,7 @@ 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);});
- std::vector<std::pair<cryptonote::transaction, bool>> process_txs;
+ std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> process_txs;
m_wallet->update_pool_state(process_txs);
if (!process_txs.empty())
m_wallet->process_pool_state(process_txs);
@@ -10055,7 +10059,7 @@ bool simple_wallet::show_transfer(const std::vector<std::string> &args)
try
{
- std::vector<std::pair<cryptonote::transaction, bool>> process_txs;
+ std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> process_txs;
m_wallet->update_pool_state(process_txs);
if (!process_txs.empty())
m_wallet->process_pool_state(process_txs);