aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-11-21 23:22:15 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-11-21 23:22:15 +0000
commit725ae4e71093325fd4674bc86fe34c594cf4b62c (patch)
tree19fb3c2b2b4546139a8d9c8792bc3d5d32c968aa /src/wallet
parentsimplewallet: lessen display flicker confusion (diff)
downloadmonero-725ae4e71093325fd4674bc86fe34c594cf4b62c.tar.xz
wallet: use incoming blocks to keep track of payments too
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp19
-rw-r--r--src/wallet/wallet2.h3
2 files changed, 21 insertions, 1 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 788f96415..f01373644 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -270,7 +270,14 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_
LOG_PRINT_L2("Found unencrypted payment ID: " << payment_id);
}
}
+
uint64_t received = (tx_money_spent_in_ins < tx_money_got_in_outs) ? tx_money_got_in_outs - tx_money_spent_in_ins : 0;
+
+ if (tx_money_spent_in_ins > 0)
+ {
+ process_outgoing(tx, height, tx_money_spent_in_ins, tx_money_got_in_outs);
+ }
+
if (0 < received)
{
payment_details payment;
@@ -301,6 +308,18 @@ void wallet2::process_unconfirmed(const cryptonote::transaction& tx, uint64_t he
}
}
//----------------------------------------------------------------------------------------------------
+void wallet2::process_outgoing(const cryptonote::transaction &tx, uint64_t height, uint64_t spent, uint64_t received)
+{
+ crypto::hash txid = get_transaction_hash(tx);
+ confirmed_transfer_details &ctd = m_confirmed_txs[txid];
+ // operator[] creates if not found
+ // fill with the info we know, some info might already be there
+ ctd.m_amount_in = spent;
+ ctd.m_amount_out = get_outs_money_amount(tx);
+ ctd.m_change = received;
+ ctd.m_block_height = height;
+}
+//----------------------------------------------------------------------------------------------------
void wallet2::process_new_blockchain_entry(const cryptonote::block& b, cryptonote::block_complete_entry& bche, crypto::hash& bl_id, uint64_t height)
{
//handle transactions from new block
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index dbd305a02..70f34c91e 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -115,7 +115,7 @@ namespace tools
uint64_t m_amount_out;
uint64_t m_change;
uint64_t m_block_height;
- confirmed_transfer_details() {}
+ confirmed_transfer_details(): m_amount_in(0), m_amount_out(0), m_change((uint64_t)-1), m_block_height(0) {}
confirmed_transfer_details(const unconfirmed_transfer_details &utd, uint64_t height):
m_amount_out(get_outs_money_amount(utd.m_tx)), m_change(utd.m_change), m_block_height(height) { get_inputs_money_amount(utd.m_tx, m_amount_in); }
};
@@ -341,6 +341,7 @@ namespace tools
uint64_t select_transfers(uint64_t needed_money, bool add_dust, uint64_t dust, std::list<transfer_container::iterator>& selected_transfers);
bool prepare_file_names(const std::string& file_path);
void process_unconfirmed(const cryptonote::transaction& tx, uint64_t height);
+ void process_outgoing(const cryptonote::transaction& tx, uint64_t height, uint64_t spent, uint64_t received);
void add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t change_amount);
void generate_genesis(cryptonote::block& b);
void check_genesis(const crypto::hash& genesis_hash) const; //throws