aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-10-22 15:34:11 +1000
committerGavin Andresen <gavinandresen@gmail.com>2013-10-22 15:34:11 +1000
commit10dc3c74737eea1f2de694c6582caf3027926034 (patch)
treebe426b48391051c2327577091b95ac6126218871 /src/wallet.cpp
parent0c1222ff848bce72525ddcac3f199de48d407d3c (diff)
parentcc6cfab38fcdd4ec3e4784e01c4407a129289f77 (diff)
downloadbitcoin-10dc3c74737eea1f2de694c6582caf3027926034.tar.xz
Merge branch 'bugfix_unknownoutputs' of git://github.com/luke-jr/bitcoin
Conflicts: src/wallet.cpp Fixed LogPrint/printf merge conflict.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 349498545e..a7a2992bb9 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -654,22 +654,35 @@ void CWalletTx::GetAmounts(list<pair<CTxDestination, int64> >& listReceived,
// Sent/received.
BOOST_FOREACH(const CTxOut& txout, vout)
{
+ bool fIsMine;
+ // Only need to handle txouts if AT LEAST one of these is true:
+ // 1) they debit from us (sent)
+ // 2) the output is to us (received)
+ if (nDebit > 0)
+ {
+ // Don't report 'change' txouts
+ if (pwallet->IsChange(txout))
+ continue;
+ fIsMine = pwallet->IsMine(txout);
+ }
+ else if (!(fIsMine = pwallet->IsMine(txout)))
+ continue;
+
+ // In either case, we need to get the destination address
CTxDestination address;
- vector<unsigned char> vchPubKey;
if (!ExtractDestination(txout.scriptPubKey, address))
{
LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
this->GetHash().ToString().c_str());
+ address = CNoDestination();
}
- // Don't report 'change' txouts
- if (nDebit > 0 && pwallet->IsChange(txout))
- continue;
-
+ // If we are debited by the transaction, add the output as a "sent" entry
if (nDebit > 0)
listSent.push_back(make_pair(address, txout.nValue));
- if (pwallet->IsMine(txout))
+ // If we are receiving the output, add it as a "received" entry
+ if (fIsMine)
listReceived.push_back(make_pair(address, txout.nValue));
}