mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-15 18:10:26 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user