This is almost entirely a move-only commit.
Reviewer hint: use --color-moved=zebra for review.
This is a partial backport of Core PR14491 : https://github.com/bitcoin/bitcoin/pull/14491/commits/d2b381cc91b2c4e74abe11e5bd66af647b70dafb
Depends on D6189