Partial backport of core#22025:
https://github.com/bitcoin/bitcoin/pull/22025/commits/5cd7f8abe3996d303774b6cddeb419337d605d02
Actually this backport does a bit more than the source material because:
- There is no point adding the private label for a class, it's already the default;
- Our members visibility are all over the place for some reason, so I better fix it completely.