aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-02-05 11:53:52 +0100
committerLuke Dashjr <luke-jr+git@utopios.org>2012-02-07 22:36:03 -0500
commite7c3e6e4b4bbfaf6772f0c8bd6b4278d0120e6e4 (patch)
tree61232ae7deb18772fb8a6708277e690b6505478b
parentccd69c7d2219a4a72ad1b6ea01838c3388130ea7 (diff)
downloadbitcoin-e7c3e6e4b4bbfaf6772f0c8bd6b4278d0120e6e4.tar.xz
Restructure credit transaction decomposition (solves issue #689)
When a transaction has multiple outputs that go to the wallet, list these as multiple transactions in the UI. This is also applied to generated (coinbase) transactions. Also makes the code shorter and easier to understand.
-rw-r--r--src/qt/transactionrecord.cpp60
1 files changed, 23 insertions, 37 deletions
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index 52a3080e97..4059207b96 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -47,49 +47,35 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
//
// Credit
//
- TransactionRecord sub(hash, nTime);
-
- sub.credit = nNet;
-
- if (wtx.IsCoinBase())
- {
- // Generated
- sub.type = TransactionRecord::Generated;
-
- if (nCredit == 0)
- {
- int64 nUnmatured = 0;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- nUnmatured += wallet->GetCredit(txout);
- sub.credit = nUnmatured;
- }
- }
- else
+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
- bool foundAddress = false;
- // Received by Bitcoin Address
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ if(wallet->IsMine(txout))
{
- if(wallet->IsMine(txout))
+ TransactionRecord sub(hash, nTime);
+ CBitcoinAddress address;
+ sub.idx = parts.size(); // sequence number
+ sub.credit = txout.nValue;
+ if (wtx.IsCoinBase())
{
- CBitcoinAddress address;
- if (ExtractAddress(txout.scriptPubKey, wallet, address))
- {
- sub.type = TransactionRecord::RecvWithAddress;
- sub.address = address.ToString();
- foundAddress = true;
- break;
- }
+ // Generated
+ sub.type = TransactionRecord::Generated;
}
- }
- if(!foundAddress)
- {
- // Received by IP connection, or other non-address transaction like OP_EVAL
- sub.type = TransactionRecord::RecvFromOther;
- sub.address = mapValue["from"];
+ else if (ExtractAddress(txout.scriptPubKey, wallet, address))
+ {
+ // Received by Bitcoin Address
+ sub.type = TransactionRecord::RecvWithAddress;
+ sub.address = address.ToString();
+ }
+ else
+ {
+ // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
+ sub.type = TransactionRecord::RecvFromOther;
+ sub.address = mapValue["from"];
+ }
+
+ parts.append(sub);
}
}
- parts.append(sub);
}
else
{