Merge pull request #1872 from gmaxwell/listaddrnotmine

In listaddressgroupings push down the IsMine check to run on each input.
This commit is contained in:
Gregory Maxwell 2013-01-21 16:30:34 -08:00
commit d40c164369

View File

@ -1636,30 +1636,39 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
{ {
CWalletTx *pcoin = &walletEntry.second; CWalletTx *pcoin = &walletEntry.second;
if (pcoin->vin.size() > 0 && IsMine(pcoin->vin[0])) if (pcoin->vin.size() > 0)
{ {
bool any_mine = false;
// group all input addresses with each other // group all input addresses with each other
BOOST_FOREACH(CTxIn txin, pcoin->vin) BOOST_FOREACH(CTxIn txin, pcoin->vin)
{ {
CTxDestination address; CTxDestination address;
if(!IsMine(txin)) /* If this input isn't mine, ignore it */
continue;
if(!ExtractDestination(mapWallet[txin.prevout.hash].vout[txin.prevout.n].scriptPubKey, address)) if(!ExtractDestination(mapWallet[txin.prevout.hash].vout[txin.prevout.n].scriptPubKey, address))
continue; continue;
grouping.insert(address); grouping.insert(address);
any_mine = true;
} }
// group change with input addresses // group change with input addresses
if (any_mine)
{
BOOST_FOREACH(CTxOut txout, pcoin->vout) BOOST_FOREACH(CTxOut txout, pcoin->vout)
if (IsChange(txout)) if (IsChange(txout))
{ {
CWalletTx tx = mapWallet[pcoin->vin[0].prevout.hash];
CTxDestination txoutAddr; CTxDestination txoutAddr;
if(!ExtractDestination(txout.scriptPubKey, txoutAddr)) if(!ExtractDestination(txout.scriptPubKey, txoutAddr))
continue; continue;
grouping.insert(txoutAddr); grouping.insert(txoutAddr);
} }
}
if (grouping.size() > 0)
{
groupings.insert(grouping); groupings.insert(grouping);
grouping.clear(); grouping.clear();
} }
}
// group lone addrs by themselves // group lone addrs by themselves
for (unsigned int i = 0; i < pcoin->vout.size(); i++) for (unsigned int i = 0; i < pcoin->vout.size(); i++)