This concludes backport of core#19145 [3/3]
https://github.com/bitcoin/bitcoin/pull/19145/commits/0d3b2f643d7da3202c0a0e757539208c4aa7c450
https://github.com/bitcoin/bitcoin/pull/19145/commits/6ccc8fc067bf516cda7bc5d7d721945be5ac2003
https://github.com/bitcoin/bitcoin/pull/19145/commits/e987ae5a554c9952812746c29f2766bacea4b727