mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 03:13:28 +01:00
simplewallet: prompt when spending more than one old out in one tx
This commit is contained in:
parent
7973fb6a69
commit
a23dbe69f6
@ -92,6 +92,8 @@ typedef cryptonote::simple_wallet sw;
|
||||
|
||||
#define MIN_RING_SIZE 11 // Used to inform user about min ring size -- does not track actual protocol
|
||||
|
||||
#define OLD_AGE_WARN_THRESHOLD (30 * 86400 / DIFFICULTY_TARGET_V2) // 30 days
|
||||
|
||||
#define LOCK_IDLE_SCOPE() \
|
||||
bool auto_refresh_enabled = m_auto_refresh_enabled.load(std::memory_order_relaxed); \
|
||||
m_auto_refresh_enabled.store(false, std::memory_order_relaxed); \
|
||||
@ -5606,6 +5608,43 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::prompt_if_old(const std::vector<tools::wallet2::pending_tx> &ptx_vector)
|
||||
{
|
||||
// count the number of old outputs
|
||||
std::string err;
|
||||
uint64_t bc_height = get_daemon_blockchain_height(err);
|
||||
if (!err.empty())
|
||||
return true;
|
||||
|
||||
int max_n_old = 0;
|
||||
for (const auto &ptx: ptx_vector)
|
||||
{
|
||||
int n_old = 0;
|
||||
for (const auto i: ptx.selected_transfers)
|
||||
{
|
||||
const tools::wallet2::transfer_details &td = m_wallet->get_transfer_details(i);
|
||||
uint64_t age = bc_height - td.m_block_height;
|
||||
if (age > OLD_AGE_WARN_THRESHOLD)
|
||||
++n_old;
|
||||
}
|
||||
max_n_old = std::max(max_n_old, n_old);
|
||||
}
|
||||
if (max_n_old > 1)
|
||||
{
|
||||
std::stringstream prompt;
|
||||
prompt << tr("Transaction spends more than one very old output. Privacy would be better if they were sent separately.");
|
||||
prompt << ENDL << tr("Spend them now anyway?");
|
||||
std::string accepted = input_line(prompt.str(), true);
|
||||
if (std::cin.eof())
|
||||
return false;
|
||||
if (!command_line::is_yes(accepted))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::string> &args_, bool called_by_mms)
|
||||
{
|
||||
// "transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"
|
||||
@ -5907,6 +5946,12 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
||||
}
|
||||
}
|
||||
|
||||
if (!prompt_if_old(ptx_vector))
|
||||
{
|
||||
fail_msg_writer() << tr("transaction cancelled.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// if more than one tx necessary, prompt user to confirm
|
||||
if (m_wallet->always_confirm_transfers() || ptx_vector.size() > 1)
|
||||
{
|
||||
@ -6088,7 +6133,8 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::locked_sweep_all(const std::vector<std::string> &args_)
|
||||
{
|
||||
return sweep_main(0, true, args_);
|
||||
sweep_main(0, true, args_);
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -6408,6 +6454,12 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<st
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!prompt_if_old(ptx_vector))
|
||||
{
|
||||
fail_msg_writer() << tr("transaction cancelled.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// give user total and fee, and prompt to confirm
|
||||
uint64_t total_fee = 0, total_sent = 0;
|
||||
for (size_t n = 0; n < ptx_vector.size(); ++n)
|
||||
@ -6754,7 +6806,8 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
|
||||
{
|
||||
return sweep_main(0, false, args_);
|
||||
sweep_main(0, false, args_);
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_below(const std::vector<std::string> &args_)
|
||||
@ -6770,7 +6823,8 @@ bool simple_wallet::sweep_below(const std::vector<std::string> &args_)
|
||||
fail_msg_writer() << tr("invalid amount threshold");
|
||||
return true;
|
||||
}
|
||||
return sweep_main(below, false, std::vector<std::string>(++args_.begin(), args_.end()));
|
||||
sweep_main(below, false, std::vector<std::string>(++args_.begin(), args_.end()));
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::donate(const std::vector<std::string> &args_)
|
||||
|
@ -261,6 +261,7 @@ namespace cryptonote
|
||||
void on_refresh_finished(uint64_t start_height, uint64_t fetched_blocks, bool is_init, bool received_money);
|
||||
std::pair<std::string, std::string> show_outputs_line(const std::vector<uint64_t> &heights, uint64_t blockchain_height, uint64_t highlight_height = std::numeric_limits<uint64_t>::max()) const;
|
||||
bool freeze_thaw(const std::vector<std::string>& args, bool freeze);
|
||||
bool prompt_if_old(const std::vector<tools::wallet2::pending_tx> &ptx_vector);
|
||||
|
||||
struct transfer_view
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user