aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-11-02 23:11:30 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-11-02 23:11:30 +0000
commitb5d6faada3d5604214de436a9acbb1687ca35587 (patch)
treef69531fa7ad225884267ac3e903203708036f31b /src/wallet/wallet2.cpp
parentMerge pull request #1272 (diff)
downloadmonero-b5d6faada3d5604214de436a9acbb1687ca35587.tar.xz
wallet: fix bad amounts/fees again
m_amount_out was sometimes getting initialized with the sum of an transaction's outputs, and sometimes with the sum of outputs that were not change. This caused confusion and bugs. We now always set it to the sum of outputs. This reverts an earlier fix for bad amounts as this used the other semantics. The wallet data should be converted automatically in a percentage of cases that I'm hesitant to estimate. In any case, restoring from seed or keys or rebuilding the cache will get it right.
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 8ea605375..f57a8d2ca 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -704,6 +704,17 @@ void wallet2::process_outgoing(const cryptonote::transaction &tx, uint64_t heigh
else
entry.first->second.m_amount_out = spent - tx.rct_signatures.txnFee;
entry.first->second.m_change = received;
+
+ std::vector<tx_extra_field> tx_extra_fields;
+ if(parse_tx_extra(tx.extra, tx_extra_fields))
+ {
+ tx_extra_nonce extra_nonce;
+ if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
+ {
+ // we do not care about failure here
+ get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, entry.first->second.m_payment_id);
+ }
+ }
}
entry.first->second.m_block_height = height;
entry.first->second.m_timestamp = ts;
@@ -2355,6 +2366,7 @@ void wallet2::add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t amo
utd.m_amount_out = 0;
for (const auto &d: dests)
utd.m_amount_out += d.amount;
+ utd.m_amount_out += change_amount;
utd.m_change = change_amount;
utd.m_sent_time = time(NULL);
utd.m_tx = (const cryptonote::transaction_prefix&)tx;