This is a backport of [[https://github.com/bitcoin/bitcoin/pull/21270 | core#21270]] [6/12] and [[https://github.com/bitcoin/bitcoin/pull/21525 | core#21525]][5/10]
https://github.com/bitcoin/bitcoin/pull/21270/commits/106bcd4f390137904b5579cfef023fb8a5c8b4b5
https://github.com/bitcoin/bitcoin/pull/21525/commits/07156eb387ea580be5e2ce4a1744992ce7575903
Depends on D11420