When a block reward is spent together with other outputs in the wallet and that block reward is later orphaned, the wallet does not show the other funds as available anymore.  Even a `-rescan` is not enough - only `-zapwallettxes` or an explicit `abandontransaction` "recovers" the funds.  I prepared a [test case](https://github.com/domob1812/bitcoin/blob/wallet-bug-invalidated-block-rewards/test/functional/wallet_bug.py) that shows this behaviour.

Is this a known issue or the expected behaviour?  While this situation is something that will presumably not occur in practice (as it requires a long reorg), I wonder if that transaction should be automatically abandoned as it seems clear it won't be able to be confirmed anymore.
}
}
stdvector<CTxDestination> CWalletListAddrBookAddresses(const stdoptional<AddrBookFilter>& _filter) const
{
    AssertLockHeld(cs_);
    stdvector<CTxDestination> result;
    AddrBookFilter filter = _filter ? *_filter  AddrBookFilter();
    ForEachAddrBookEntry([&result, &filter](const CTxDestination& dest, const stdstring& label, const stdstring& purpose, bool is_change) {
        // Filter by change
        if (filter.ignore_change && is_change) return;
        // Filter by label
        if (filter.m_op_label && *filter.m_op_label != label) return;
        // All good
        result.emplace_back(dest);
    });
    return result;
}
stdset<stdstring> CWalletListAddrBookLabels(const stdstring& purpose) const
{
    AssertLockHeld(cs_);
    stdset<stdstring> label_set;
    ForEachAddrBookEntry([&](const CTxDestination& _dest, const stdstring& _label,
                             const stdstring& _purpose, bool _is_change) {
        if (_is_change) return;
        if (purpose.empty() || _purpose == purpose) {
            label_set.insert(_label);
        }
    });
    return label_set;
}