From fa23ed7fc24212d85cdc7f52b317906b37a1a120 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 28 Apr 2025 15:47:16 +0200 Subject: [PATCH] refactor: Use ToIntegral in ParseHDKeypath ToIntegral only accepts numbers, so just use that to replace the equivalent but more verbose way with find_first_not_of+ParseUInt32. --- src/util/bip32.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/util/bip32.cpp b/src/util/bip32.cpp index 4ab14bd7041..db40bfb5b9e 100644 --- a/src/util/bip32.cpp +++ b/src/util/bip32.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2022 The Bitcoin Core developers +// Copyright (c) 2019-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -36,14 +36,11 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector& keypa } // Ensure this is only numbers - if (item.find_first_not_of( "0123456789" ) != std::string::npos) { + const auto number{ToIntegral(item)}; + if (!number) { return false; } - uint32_t number; - if (!ParseUInt32(item, &number)) { - return false; - } - path |= number; + path |= *number; keypath.push_back(path); first = false;