aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-04-26 18:04:00 +0200
committerRiccardo Spagni <ric@spagni.net>2016-04-26 18:04:00 +0200
commit7098ad68043d2491eb82ee986b6fcec2ea4d4f3a (patch)
treef5e5dd96a3a61c76108e7d93ec39bf6f21240056 /src/wallet/wallet2.cpp
parentMerge pull request #813 (diff)
parent modified: src/wallet/wallet2.cpp (diff)
downloadmonero-7098ad68043d2491eb82ee986b6fcec2ea4d4f3a.tar.xz
Merge pull request #814
68cbe15 modified: src/wallet/wallet2.cpp modified: src/wallet/wallet2.h (awfulcrawler) 4b325bd modified: src/simplewallet/simplewallet.cpp modified: src/wallet/wallet2.cpp modified: src/wallet/wallet2.h (awfulcrawler)
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 1c1e386ca..6218eff4b 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -2053,8 +2053,9 @@ void wallet2::commit_tx(pending_tx& ptx)
BOOST_FOREACH(transfer_container::iterator it, ptx.selected_transfers)
it->m_spent = true;
+ //fee includes dust if dust policy specified it.
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
<< "Balance: " << print_money(balance()) << ENDL
<< "Unlocked: " << print_money(unlocked_balance()) << ENDL
<< "Please, wait for confirmation for your balance to be unlocked.");
@@ -2312,10 +2313,17 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
return true;
});
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.fee = fee;
- ptx.dust = dust;
+ ptx.fee = (dust_policy.add_to_fee ? fee+dust : fee);
+ 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.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
@@ -2480,7 +2488,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);
auto txBlob = t_serializable_object_to_blob(test_ptx.tx);
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);
LOG_PRINT_L2("Made a " << txBlob.size() << " kB tx, with " << print_money(available_for_fee) << " available for fee (" <<
print_money(needed_fee) << " needed)");