Co-authored-by: Andrew Chow <achow101-github@achow101.com>
Backport of Core PR16528 [36/43] : https://github.com/bitcoin/bitcoin/pull/16528/commits/f193ea889ddb53d9a5c47647966681d525e38368
Add the wallet_util changes from 223588b because the patch is broken without it.