Review report

core: PR #36384

2 suggestions

Optional improvements

Link

[suggestion] · The refactor changes the accepted maxtries range

Parsing generatetoaddress's explicit maxtries as uint64_t instead of int changes accepted inputs despite the commit's behavior-neutral description.

Location: src/rpc/mining.cpp:317 (head).

Details and suggested fix

Previously, an explicit maxtries=-1 passed getInt<int>() and converted to UINT64_MAX, an effectively unlimited mining budget. Arg<uint64_t> instead uses unsigned std::from_chars parsing, so it rejects that input with RPC_MISC_ERROR, "JSON integer out of range". Conversely, values in (INT_MAX, UINT64_MAX] are now accepted. The default is unchanged. bitcoin-cli -generate N M forwards M unchanged, so the shortcut is affected too. This matches generatetodescriptor and may be intentional, but should be documented as a behavior change rather than included silently in the refactor. No current in-tree caller supplying negative or above-INT_MAX maxtries was found, so practical impact is unconfirmed. Add boundary tests using generatetoaddress(0, addr, -1) and generatetoaddress(0, addr, 2**31) with a valid address; zero blocks still reaches parsing but skips mining. The existing helper test compares against a uint64_t getter and cannot detect this distinction.

The related walletcreatefundedpsbt conversion from getInt<int>() to Arg<uint32_t> also changes negative psbt_version rejection from RPC_INVALID_PARAMETER to RPC_MISC_ERROR. It does not accept any new PSBT version.


Link

[suggestion] · std::distance loses its direct header include

GetParamIndex still uses std::distance after removing <iterator>, contrary to the repository's direct-include convention.

Location: src/rpc/util.cpp:33 (base).

Details and suggested fix

Replacing <iterator> with <ranges> leaves std::distance(m_args.begin(), it) relying on an indirect include. C++20 requires <ranges> to include <iterator>, so this is not a present compilation failure. However, the developer notes explicitly call for direct includes, and this file belongs to CI's IWYU-enforced set. Restore #include <iterator>. The new std::ranges::find_if is declared in the already included <algorithm>, not <ranges>, so retaining <ranges> is not a substitute for declaring the actual dependency.


Coverage details