mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 00:37:43 +00:00
modified: src/simplewallet/simplewallet.cpp
modified: src/wallet/wallet2.cpp modified: src/wallet/wallet2.h Update to fix unconfirmed balance and give a slightly more verbose and informative confirmation message for transfers
This commit is contained in:
parent
2d9dfd0820
commit
4b325bdb66
3 changed files with 39 additions and 13 deletions
|
@ -2202,24 +2202,36 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str
|
||||||
if (m_wallet->always_confirm_transfers() || ptx_vector.size() > 1)
|
if (m_wallet->always_confirm_transfers() || ptx_vector.size() > 1)
|
||||||
{
|
{
|
||||||
uint64_t total_fee = 0;
|
uint64_t total_fee = 0;
|
||||||
|
uint64_t dust_not_in_fee = 0;
|
||||||
|
uint64_t dust_in_fee = 0;
|
||||||
for (size_t n = 0; n < ptx_vector.size(); ++n)
|
for (size_t n = 0; n < ptx_vector.size(); ++n)
|
||||||
{
|
{
|
||||||
total_fee += ptx_vector[n].fee;
|
total_fee += ptx_vector[n].fee;
|
||||||
|
|
||||||
|
if (ptx_vector[n].dust_added_to_fee)
|
||||||
|
dust_in_fee += ptx_vector[n].dust;
|
||||||
|
else
|
||||||
|
dust_not_in_fee += ptx_vector[n].dust;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string prompt_str;
|
std::stringstream prompt;
|
||||||
if (ptx_vector.size() > 1)
|
if (ptx_vector.size() > 1)
|
||||||
{
|
{
|
||||||
prompt_str = (boost::format(tr("Your transaction needs to be split into %llu transactions. "
|
prompt << boost::format(tr("Your transaction needs to be split into %llu transactions. "
|
||||||
"This will result in a transaction fee being applied to each transaction, for a total fee of %s. Is this okay? (Y/Yes/N/No)")) %
|
"This will result in a transaction fee being applied to each transaction, for a total fee of %s")) %
|
||||||
((unsigned long long)ptx_vector.size()) % print_money(total_fee)).str();
|
((unsigned long long)ptx_vector.size()) % print_money(total_fee);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prompt_str = (boost::format(tr("The transaction fee is %s. Is this okay? (Y/Yes/N/No)")) %
|
prompt << boost::format(tr("The transaction fee is %s")) %
|
||||||
print_money(total_fee)).str();
|
print_money(total_fee);
|
||||||
}
|
}
|
||||||
std::string accepted = command_line::input_line(prompt_str);
|
if (dust_in_fee != 0) prompt << boost::format(tr(", of which %s is dust from change")) % print_money(dust_in_fee);
|
||||||
|
if (dust_not_in_fee != 0) prompt << tr(".") << ENDL << boost::format(tr("A total of %s from dust change will be sent to dust address"))
|
||||||
|
% print_money(dust_not_in_fee);
|
||||||
|
prompt << tr(".") << ENDL << tr("Is this okay? (Y/Yes/N/No)");
|
||||||
|
|
||||||
|
std::string accepted = command_line::input_line(prompt.str());
|
||||||
if (std::cin.eof())
|
if (std::cin.eof())
|
||||||
return true;
|
return true;
|
||||||
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
|
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
|
||||||
|
|
|
@ -1967,7 +1967,7 @@ void wallet2::commit_tx(pending_tx& ptx)
|
||||||
it->m_spent = true;
|
it->m_spent = true;
|
||||||
|
|
||||||
LOG_PRINT_L0("Transaction successfully sent. <" << txid << ">" << ENDL
|
LOG_PRINT_L0("Transaction successfully sent. <" << txid << ">" << ENDL
|
||||||
<< "Commission: " << print_money(ptx.fee+ptx.dust) << " (dust: " << print_money(ptx.dust) << ")" << ENDL
|
<< "Commission: " << print_money(ptx.fee) << " (dust sent to dust addr: " << print_money((ptx.dust_added_to_fee ? 0 : ptx.dust)) << ")" << ENDL //AC: fee includes dust; dust lists dust sent elsewhere
|
||||||
<< "Balance: " << print_money(balance()) << ENDL
|
<< "Balance: " << print_money(balance()) << ENDL
|
||||||
<< "Unlocked: " << print_money(unlocked_balance()) << ENDL
|
<< "Unlocked: " << print_money(unlocked_balance()) << ENDL
|
||||||
<< "Please, wait for confirmation for your balance to be unlocked.");
|
<< "Please, wait for confirmation for your balance to be unlocked.");
|
||||||
|
@ -2226,9 +2226,16 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
|
||||||
});
|
});
|
||||||
THROW_WALLET_EXCEPTION_IF(!all_are_txin_to_key, error::unexpected_txin_type, tx);
|
THROW_WALLET_EXCEPTION_IF(!all_are_txin_to_key, error::unexpected_txin_type, tx);
|
||||||
|
|
||||||
|
|
||||||
|
bool dust_sent_elsewhere = (dust_policy.addr_for_dust.m_view_public_key != change_dts.addr.m_view_public_key
|
||||||
|
|| dust_policy.addr_for_dust.m_spend_public_key != change_dts.addr.m_spend_public_key);
|
||||||
|
|
||||||
|
if (dust_policy.add_to_fee || dust_sent_elsewhere) change_dts.amount -= dust; //AC
|
||||||
|
|
||||||
ptx.key_images = key_images;
|
ptx.key_images = key_images;
|
||||||
ptx.fee = fee;
|
ptx.fee = (dust_policy.add_to_fee ? fee+dust : fee);
|
||||||
ptx.dust = dust;
|
ptx.dust = ((dust_policy.add_to_fee || dust_sent_elsewhere) ? dust : 0);
|
||||||
|
ptx.dust_added_to_fee = dust_policy.add_to_fee;
|
||||||
ptx.tx = tx;
|
ptx.tx = tx;
|
||||||
ptx.change_dts = change_dts;
|
ptx.change_dts = change_dts;
|
||||||
ptx.selected_transfers = selected_transfers;
|
ptx.selected_transfers = selected_transfers;
|
||||||
|
@ -2393,7 +2400,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||||
detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx);
|
detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx);
|
||||||
auto txBlob = t_serializable_object_to_blob(test_ptx.tx);
|
auto txBlob = t_serializable_object_to_blob(test_ptx.tx);
|
||||||
needed_fee = calculate_fee(txBlob);
|
needed_fee = calculate_fee(txBlob);
|
||||||
available_for_fee = test_ptx.fee + test_ptx.change_dts.amount;
|
available_for_fee = test_ptx.fee + test_ptx.change_dts.amount + (!test_ptx.dust_added_to_fee ? test_ptx.dust : 0); //AC
|
||||||
LOG_PRINT_L2("Made a " << txBlob.size() << " kB tx, with " << print_money(available_for_fee) << " available for fee (" <<
|
LOG_PRINT_L2("Made a " << txBlob.size() << " kB tx, with " << print_money(available_for_fee) << " available for fee (" <<
|
||||||
print_money(needed_fee) << " needed)");
|
print_money(needed_fee) << " needed)");
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,7 @@ namespace tools
|
||||||
{
|
{
|
||||||
cryptonote::transaction tx;
|
cryptonote::transaction tx;
|
||||||
uint64_t dust, fee;
|
uint64_t dust, fee;
|
||||||
|
bool dust_added_to_fee; //AC
|
||||||
cryptonote::tx_destination_entry change_dts;
|
cryptonote::tx_destination_entry change_dts;
|
||||||
std::list<transfer_container::iterator> selected_transfers;
|
std::list<transfer_container::iterator> selected_transfers;
|
||||||
std::string key_images;
|
std::string key_images;
|
||||||
|
@ -712,9 +713,15 @@ namespace tools
|
||||||
});
|
});
|
||||||
THROW_WALLET_EXCEPTION_IF(!all_are_txin_to_key, error::unexpected_txin_type, tx);
|
THROW_WALLET_EXCEPTION_IF(!all_are_txin_to_key, error::unexpected_txin_type, tx);
|
||||||
|
|
||||||
|
bool dust_sent_elsewhere = (dust_policy.addr_for_dust.m_view_public_key != change_dts.addr.m_view_public_key
|
||||||
|
|| dust_policy.addr_for_dust.m_spend_public_key != change_dts.addr.m_spend_public_key);
|
||||||
|
|
||||||
|
if (dust_policy.add_to_fee || dust_sent_elsewhere) change_dts.amount -= dust;
|
||||||
|
|
||||||
ptx.key_images = key_images;
|
ptx.key_images = key_images;
|
||||||
ptx.fee = fee;
|
ptx.fee = (dust_policy.add_to_fee ? fee+dust : fee);
|
||||||
ptx.dust = dust;
|
ptx.dust = ((dust_policy.add_to_fee || dust_sent_elsewhere) ? dust : 0);
|
||||||
|
ptx.dust_added_to_fee = dust_policy.add_to_fee; //AC
|
||||||
ptx.tx = tx;
|
ptx.tx = tx;
|
||||||
ptx.change_dts = change_dts;
|
ptx.change_dts = change_dts;
|
||||||
ptx.selected_transfers = selected_transfers;
|
ptx.selected_transfers = selected_transfers;
|
||||||
|
|
Loading…
Reference in a new issue