Merge branch 'decomposetransfix' of https://github.com/laanwj/bitcoin

This commit is contained in:
Gavin Andresen 2012-02-06 14:50:59 -05:00
commit 30999ec6f9

View File

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