Skip to content

Commit fa23ed7

Browse files
author
MarcoFalke
committed
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.
1 parent bdc1cef commit fa23ed7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/util/bip32.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019-2022 The Bitcoin Core developers
1+
// Copyright (c) 2019-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -36,14 +36,11 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypa
3636
}
3737

3838
// Ensure this is only numbers
39-
if (item.find_first_not_of( "0123456789" ) != std::string::npos) {
39+
const auto number{ToIntegral<uint32_t>(item)};
40+
if (!number) {
4041
return false;
4142
}
42-
uint32_t number;
43-
if (!ParseUInt32(item, &number)) {
44-
return false;
45-
}
46-
path |= number;
43+
path |= *number;
4744

4845
keypath.push_back(path);
4946
first = false;

0 commit comments

Comments
 (0)