refactor: Use ToIntegral in ParseHDKeypath

ToIntegral<uint32_t> only accepts numbers, so just use that to replace
the equivalent but more verbose way with find_first_not_of+ParseUInt32.
This commit is contained in:
MarcoFalke
2025-04-28 15:47:16 +02:00
parent bdc1cef1de
commit fa23ed7fc2

View File

@@ -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<uint32_t>& keypa
}
// Ensure this is only numbers
if (item.find_first_not_of( "0123456789" ) != std::string::npos) {
const auto number{ToIntegral<uint32_t>(item)};
if (!number) {
return false;
}
uint32_t number;
if (!ParseUInt32(item, &number)) {
return false;
}
path |= number;
path |= *number;
keypath.push_back(path);
first = false;