rpc, refactor: Prevent potential race conditions in dumptxoutset
Summary:
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This is a partial backport of core#29553
https://github.com/bitcoin/bitcoin/pull/29553/commits/94b0adcc371540732453d70309c4083d4bd9cd6b
Bypasses a comment about the racy condition added in https://github.com/bitcoin/bitcoin/pull/29553/commits/94b0adcc371540732453d70309c4083d4bd9cd6b
Depends on D18047
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18048