This commit does not change behavior except for error messages which now
include more complete information.
This concludes backport of core#19619 [8/8]
https://github.com/bitcoin/bitcoin/pull/19619/commits/7bf6dfbb484adfda3b8df26ee3e2ebda239dd263
Depends on D10230