why must used Recursive in the function FindNonChangeParentOutput #13409

issue chen610620 opened this issue on June 7, 2018
  1. chen610620 commented at 12:06 PM on June 7, 2018: none

    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.

  2. fanquake commented at 12:40 PM on June 7, 2018: member

    Issues here are not for general technical questions, please try the bitcoin stackexchange.

  3. fanquake closed this on Jun 7, 2018

  4. MarcoFalke locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me