diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-09-22 03:20:14 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2013-07-17 03:03:13 +0000 |
commit | 96ed68217626ad07b0d8d9ea6e4871b092535963 (patch) | |
tree | 43f3238e923118e2db9684cd68905210032516fe /src | |
parent | c2aca505510337cc82c927bc56edcdc8d0d58dd2 (diff) |
Bugfix: Avoid trying to parse outputs that aren't relevant to CWalletTx::GetAmounts
This fixes a warning when an output we aren't concerned with can't be parsed.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index 488787f967..76f3df602a 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -673,22 +673,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)) { printf("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)); } |