When constructing an UniValue from integral values, historically (long ago), in some cases casts where needed. With the current UniValue constructor, only very few are actually needed.
Keeping the unused casts around is:
- confusing, because code readers do not understand why they are needed
- brittle, because some may copy them into new places, where they will lead to hard-to-find logic bugs, such as the ones fixed in pull #34112
So fix all issues by removing them, except for a few cases, where casting was required:
ret.pushKV("coinbase", static_cast<bool>(coin->fCoinBase));, orstatic_cast<std::underlying_type_t<decltype(info.nServices)>>(info.nServices).
This hardening refactor does not fix any bugs and does not change any behavior.