coins, refactor: Assume state after SetClean in AddFlags to prevent dangling pointers
Summary:
This is a partial backport of core#30906
https://github.com/bitcoin/bitcoin/pull/30906/commits/cd0498eabc910efa3ed7a6d32e687107248bb5be
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Depends on D18807
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18808