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.
This commit is contained in:
Wladimir J. van der Laan 2012-02-05 11:53:52 +01:00
parent f69b82e78a
commit ab07866c8d

View file

@ -47,49 +47,35 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// //
// Credit // Credit
// //
TransactionRecord sub(hash, nTime); BOOST_FOREACH(const CTxOut& txout, wtx.vout)
sub.credit = nNet;
if (wtx.IsCoinBase())
{ {
// Generated if(wallet->IsMine(txout))
sub.type = TransactionRecord::Generated;
if (nCredit == 0)
{ {
int64 nUnmatured = 0; TransactionRecord sub(hash, nTime);
BOOST_FOREACH(const CTxOut& txout, wtx.vout) CBitcoinAddress address;
nUnmatured += wallet->GetCredit(txout); sub.idx = parts.size(); // sequence number
sub.credit = nUnmatured; sub.credit = txout.nValue;
} if (wtx.IsCoinBase())
}
else
{
bool foundAddress = false;
// Received by Bitcoin Address
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
if(wallet->IsMine(txout))
{ {
CBitcoinAddress address; // Generated
if (ExtractAddress(txout.scriptPubKey, address) && wallet->HaveKey(address)) sub.type = TransactionRecord::Generated;
{
sub.type = TransactionRecord::RecvWithAddress;
sub.address = address.ToString();
foundAddress = true;
break;
}
} }
} else if (ExtractAddress(txout.scriptPubKey, address) && wallet->HaveKey(address))
if(!foundAddress) {
{ // Received by Bitcoin Address
// Received by IP connection, or other non-address transaction like OP_EVAL sub.type = TransactionRecord::RecvWithAddress;
sub.type = TransactionRecord::RecvFromOther; sub.address = address.ToString();
sub.address = mapValue["from"]; }
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 else
{ {