This is a backport of [[https://github.com/bitcoin/bitcoin/pull/21270 | core#21270]] [9/12] and [[https://github.com/bitcoin/bitcoin/pull/21525 | core#21525]] [10/10]
https://github.com/bitcoin/bitcoin/pull/21270/commits/91c5b68acd12cf7c2b4888d54d8fdd21837b2817
https://github.com/bitcoin/bitcoin/pull/21525/commits/693414d27181cf967f787a2ca72344e52c58c7f0
Depends on D11424