cli: Reject + sign in -netinfo level parsing

It would be confusing to specify the sign for an unsigned value here, so
reject it.
This commit is contained in:
MarcoFalke committed 2025-05-15 19:48:38 +02:00
1 parent fa98041325
commit fa9c45577d
1 file changed
+3 -2
+3 -2
View File
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2022 The Bitcoin Core developers // Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -472,7 +472,8 @@ public:
{ {
if (!args.empty()) { if (!args.empty()) {
uint8_t n{0}; uint8_t n{0};
if (ParseUInt8(args.at(0), &n)) { if (const auto res{ToIntegral<uint8_t>(args.at(0))}) {
n = *res;
m_details_level = std::min(n, NETINFO_MAX_LEVEL); m_details_level = std::min(n, NETINFO_MAX_LEVEL);
} else { } else {
throw std::runtime_error(strprintf("invalid -netinfo level argument: %s\nFor more information, run: bitcoin-cli -netinfo help", args.at(0))); throw std::runtime_error(strprintf("invalid -netinfo level argument: %s\nFor more information, run: bitcoin-cli -netinfo help", args.at(0)));