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 file changed
+4
-7
+4
-7
@@ -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
|
// 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.
|
||||||
|
|
||||||
@@ -36,14 +36,11 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure this is only numbers
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
uint32_t number;
|
path |= *number;
|
||||||
if (!ParseUInt32(item, &number)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
path |= number;
|
|
||||||
|
|
||||||
keypath.push_back(path);
|
keypath.push_back(path);
|
||||||
first = false;
|
first = false;
|
||||||
|
|||||||
Reference in new issue
Block a user