Something went screwy with the old request after I accidentally cross-synced forks/branches so this is a continuation of #5772, albeit with a clearer title.
The base commit for this PR includes the changes from https://github.com/jonasschnelli/bitcoin/commit/a16b79b16d9f13f13f13960e858d9416694a2ee4 and I have made sure to clarify the title both on the commit and the PR per a suggestion to do so.