Since #26499, we mark coinbase transactions and their descendants as abandoned when a reorg arises through the “block disconnection” signal handler. However, this does not cover all scenarios; external wallets could contain coinbase transactions from blocks the node has not seen yet, or the user could have replaced the chain with an earlier or different version (one without the coinbase chain).
This affects balance calculation as well as mempool rebroadcast (descendants shouldn’t be relayed). Fix this by marking orphaned coinbase transactions and their descendants as abandoned during wallet startup.