when i read the source code. I found the code,but I don't know what it does.
1.
the code is
const CTxOut& CWallet::FindNonChangeParentOutput(const CTransaction& tx, int output) const
{
const CTransaction* ptx = &tx;
int n = output;
while (IsChange(ptx->vout[n]) && ptx->vin.size() > 0) {
const COutPoint& prevout = ptx->vin[0].prevout;
auto it = mapWallet.find(prevout.hash);
if (it == mapWallet.end() || it->second.tx->vout.size() <= prevout.n ||
!IsMine(it->second.tx->vout[prevout.n])) {
break;
}
ptx = it->second.tx.get();
n = prevout.n;
}
return ptx->vout[n];
}
I don't know why must used while.
In test net, if I have a lot of tx(label is send to yourself). when I used coincontroldialog, bitcoin-qt will be slow.
2.
In the function CWallet::ListCoins. result[address].emplace_back(std::move(coin)); it is used the address from coin prevout or again prev. but i think it may be used the coin obj's address.