From 00790a8921c93d77a4de0a93d289e19e34c11e5e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 21 Nov 2015 11:52:35 +0000 Subject: simplewallet: lessen display flicker confusion Height seemed to be flying all over the place on a rescan here. Logging to a file shows the heights are actually correct, and this is some kind of screen refresh artifact. Flush after \r and update less often to reduce this effect a lot. --- src/simplewallet/simplewallet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/simplewallet') diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 8636c1c7b..a4cb79124 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -175,9 +175,9 @@ namespace cryptonote m_blockchain_height = (std::max)(m_blockchain_height, height); } - if (std::chrono::milliseconds(1) < current_time - m_print_time || force) + if (std::chrono::milliseconds(20) < current_time - m_print_time || force) { - std::cout << QT_TRANSLATE_NOOP("cryptonote::simple_wallet", "Height ") << height << " / " << m_blockchain_height << '\r'; + std::cout << QT_TRANSLATE_NOOP("cryptonote::simple_wallet", "Height ") << height << " / " << m_blockchain_height << '\r' << std::flush; m_print_time = current_time; } } -- cgit v1.2.3 From 725ae4e71093325fd4674bc86fe34c594cf4b62c Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 21 Nov 2015 23:22:15 +0000 Subject: wallet: use incoming blocks to keep track of payments too --- src/simplewallet/simplewallet.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/simplewallet') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 3d7a23d5e..1ef572926 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2055,7 +2055,7 @@ bool simple_wallet::show_transfers(const std::vector &args_) std::string payment_id = string_tools::pod_to_hex(i->first); if (payment_id.substr(16).find_first_not_of('0') == std::string::npos) payment_id = payment_id.substr(0,16); - output.insert(std::make_pair(pd.m_block_height, std::make_pair(true, (boost::format("%18.18s %s %s") % print_money(pd.m_amount) % string_tools::pod_to_hex(pd.m_tx_hash) % payment_id).str()))); + output.insert(std::make_pair(pd.m_block_height, std::make_pair(true, (boost::format("%20.20s %s %s") % print_money(pd.m_amount) % string_tools::pod_to_hex(pd.m_tx_hash) % payment_id).str()))); } } @@ -2065,14 +2065,16 @@ bool simple_wallet::show_transfers(const std::vector &args_) for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { const tools::wallet2::confirmed_transfer_details &pd = i->second; uint64_t fee = pd.m_amount_in - pd.m_amount_out; - output.insert(std::make_pair(pd.m_block_height, std::make_pair(false, (boost::format("%18.18s %s") % print_money(pd.m_amount_in - pd.m_change - fee) % "-").str()))); + uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known + LOG_PRINT_L2("out: in " << print_money(pd.m_amount_in) << ", out " << print_money(pd.m_amount_out) << ", change " << print_money(change) << ", fee " << print_money(fee)); + output.insert(std::make_pair(pd.m_block_height, std::make_pair(false, (boost::format("%20.20s %s") % print_money(pd.m_amount_in - change - fee) % "-").str()))); } } // print in and out sorted by height for (std::map>::const_iterator i = output.begin(); i != output.end(); ++i) { message_writer(i->second.first ? epee::log_space::console_color_magenta : epee::log_space::console_color_green, false) << - boost::format("[%8.8llu] %4.4s %s") % + boost::format("%8.8llu %6.6s %s") % ((unsigned long long)i->first) % (i->second.first ? tr("in") : tr("out")) % i->second.second; } @@ -2084,7 +2086,7 @@ bool simple_wallet::show_transfers(const std::vector &args_) const tools::wallet2::unconfirmed_transfer_details &pd = i->second; uint64_t amount = 0; cryptonote::get_inputs_money_amount(pd.m_tx, amount); - message_writer() << (boost::format("[%8.8s] %4.4s %18.18s") % tr("pending") % tr("out") % print_money(amount - pd.m_change)).str(); + message_writer() << (boost::format("%8.8s %6.6s %20.20s") % tr("pending") % tr("out") % print_money(amount - pd.m_change)).str(); } } -- cgit v1.2.3 From b3d4d41e290c1a36ad39c85c2b5de284c0291297 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 22 Nov 2015 12:13:59 +0000 Subject: wallet: improve show_transfers More information is now saved and displayed --- src/simplewallet/simplewallet.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/simplewallet') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 1ef572926..06280486c 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1998,24 +1998,29 @@ bool simple_wallet::show_transfers(const std::vector &args_) std::vector local_args = args_; bool in = true; bool out = true; + bool pending = true; uint64_t min_height = 0; uint64_t max_height = (uint64_t)-1; if(local_args.size() > 3) { - fail_msg_writer() << tr("Usage: show_transfers [in|out] [ []]"); + fail_msg_writer() << tr("Usage: show_transfers [in|out|all|pending] [ []]"); return true; } // optional in/out selector if (local_args.size() > 0) { if (local_args[0] == "in" || local_args[0] == "incoming") { - out = false; + out = pending = false; local_args.erase(local_args.begin()); } else if (local_args[0] == "out" || local_args[0] == "outgoing") { in = false; local_args.erase(local_args.begin()); } + else if (local_args[0] == "pending") { + in = out = false; + local_args.erase(local_args.begin()); + } else if (local_args[0] == "all" || local_args[0] == "both") { local_args.erase(local_args.begin()); } @@ -2055,7 +2060,7 @@ bool simple_wallet::show_transfers(const std::vector &args_) std::string payment_id = string_tools::pod_to_hex(i->first); if (payment_id.substr(16).find_first_not_of('0') == std::string::npos) payment_id = payment_id.substr(0,16); - output.insert(std::make_pair(pd.m_block_height, std::make_pair(true, (boost::format("%20.20s %s %s") % print_money(pd.m_amount) % string_tools::pod_to_hex(pd.m_tx_hash) % payment_id).str()))); + output.insert(std::make_pair(pd.m_block_height, std::make_pair(true, (boost::format("%20.20s %s %s %s") % print_money(pd.m_amount) % string_tools::pod_to_hex(pd.m_tx_hash) % payment_id % "-").str()))); } } @@ -2066,27 +2071,39 @@ bool simple_wallet::show_transfers(const std::vector &args_) const tools::wallet2::confirmed_transfer_details &pd = i->second; uint64_t fee = pd.m_amount_in - pd.m_amount_out; uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known - LOG_PRINT_L2("out: in " << print_money(pd.m_amount_in) << ", out " << print_money(pd.m_amount_out) << ", change " << print_money(change) << ", fee " << print_money(fee)); - output.insert(std::make_pair(pd.m_block_height, std::make_pair(false, (boost::format("%20.20s %s") % print_money(pd.m_amount_in - change - fee) % "-").str()))); + std::string dests; + for (const auto &d: pd.m_dests) { + if (!dests.empty()) + dests += ", "; + dests += get_account_address_as_str(m_wallet->testnet(), d.addr) + ": " + print_money(d.amount); + } + std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id); + if (payment_id.substr(16).find_first_not_of('0') == std::string::npos) + payment_id = payment_id.substr(0,16); + output.insert(std::make_pair(pd.m_block_height, std::make_pair(false, (boost::format("%20.20s %s %s %14.14s %s") % print_money(pd.m_amount_in - change - fee) % string_tools::pod_to_hex(i->first) % payment_id % print_money(fee) % dests).str()))); } } // print in and out sorted by height for (std::map>::const_iterator i = output.begin(); i != output.end(); ++i) { message_writer(i->second.first ? epee::log_space::console_color_magenta : epee::log_space::console_color_green, false) << - boost::format("%8.8llu %6.6s %s") % + boost::format("%8.8llu %6.6s %s") % ((unsigned long long)i->first) % (i->second.first ? tr("in") : tr("out")) % i->second.second; } // print unconfirmed last - if (out) { + if (pending) { std::list> upayments; m_wallet->get_unconfirmed_payments_out(upayments); for (std::list>::const_iterator i = upayments.begin(); i != upayments.end(); ++i) { const tools::wallet2::unconfirmed_transfer_details &pd = i->second; uint64_t amount = 0; cryptonote::get_inputs_money_amount(pd.m_tx, amount); - message_writer() << (boost::format("%8.8s %6.6s %20.20s") % tr("pending") % tr("out") % print_money(amount - pd.m_change)).str(); + uint64_t fee = amount - get_outs_money_amount(pd.m_tx); + std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id); + if (payment_id.substr(16).find_first_not_of('0') == std::string::npos) + payment_id = payment_id.substr(0,16); + message_writer() << (boost::format("%8.8s %6.6s %20.20s %s %s %14.14s") % tr("pending") % tr("out") % print_money(amount - pd.m_change) % string_tools::pod_to_hex(i->first) % payment_id % print_money(fee)).str(); } } -- cgit v1.2.3 From 9156ba3a3cf26a9dc3e320c06c2e7c45652052cf Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 22 Nov 2015 12:26:27 +0000 Subject: wallet: rename store-tx-keys to store-tx-info With backward compatibility --- src/simplewallet/simplewallet.cpp | 12 ++++++------ src/simplewallet/simplewallet.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/simplewallet') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 06280486c..2ed9bca8f 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -335,7 +335,7 @@ bool simple_wallet::set_always_confirm_transfers(const std::vector return true; } -bool simple_wallet::set_store_tx_keys(const std::vector &args/* = std::vector()*/) +bool simple_wallet::set_store_tx_info(const std::vector &args/* = std::vector()*/) { bool success = false; if (m_wallet->watch_only()) @@ -359,7 +359,7 @@ bool simple_wallet::set_store_tx_keys(const std::vector &args/* = s return true; } - m_wallet->store_tx_keys(is_it_true(args[1])); + m_wallet->store_tx_info(is_it_true(args[1])); m_wallet->rewrite(m_wallet_file, pwd_container.password()); return true; } @@ -449,7 +449,7 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Get viewkey")); m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Get spendkey")); m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Get deterministic seed")); - m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("available options: seed language - Set wallet seed langage; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-keys <1|0> - whether to store per-tx private keys for future reference; default_mixin - set default mixin (default default is 4")); + m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("available options: seed language - Set wallet seed langage; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store per outgoing tx info (destination address, payment id, tx secret key) for future reference; default_mixin - set default mixin (default default is 4")); m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs")); m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given tx")); m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to a given address in a partcular tx")); @@ -496,18 +496,18 @@ bool simple_wallet::set_variable(const std::vector &args) return true; } } - else if (args[0] == "store-tx-keys") + else if (args[0] == "store-tx-info") { if (args.size() <= 1) { - fail_msg_writer() << tr("set store-tx-keys: needs an argument (0 or 1)"); + fail_msg_writer() << tr("set store-tx-info: needs an argument (0 or 1)"); return true; } else { std::vector local_args = args; local_args.erase(local_args.begin(), local_args.begin()+2); - set_store_tx_keys(local_args); + set_store_tx_info(local_args); return true; } } diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index a4cb79124..94ad724be 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -99,7 +99,7 @@ namespace cryptonote */ bool seed_set_language(const std::vector &args = std::vector()); bool set_always_confirm_transfers(const std::vector &args = std::vector()); - bool set_store_tx_keys(const std::vector &args = std::vector()); + bool set_store_tx_info(const std::vector &args = std::vector()); bool set_default_mixin(const std::vector &args = std::vector()); bool help(const std::vector &args = std::vector()); bool start_mining(const std::vector &args); -- cgit v1.2.3