This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19521 | core#19521]] [9 & 10/17]
https://github.com/bitcoin/bitcoin/pull/19521/commits/ca01bb8d689f93e1c7669b0ba7a4994c0206dabd
https://github.com/bitcoin/bitcoin/pull/19521/commits/655d929836a71af23d2035d2e2e99ad8b8c340c3