This concludes backport of [[https://github.com/bitcoin/bitcoin/pull/21866 | core#21866]] [12/12]
https://github.com/bitcoin/bitcoin/pull/21866/commits/6f994882deafe62e97f0a889d8bdb8c96dcf913d
Depends on D11752
Backport note: the changes in qt/test/apptests.cpp are done in a different commit in the source material, but this is incorrect and belongs here (as explained in D11752)