mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
descriptors: Reject + sign in ParseKeyPathNum
This commit is contained in:
@@ -1423,16 +1423,16 @@ std::optional<uint32_t> ParseKeyPathNum(std::span<const char> elem, bool& apostr
|
||||
apostrophe = last == '\'';
|
||||
}
|
||||
}
|
||||
uint32_t p;
|
||||
if (!ParseUInt32(std::string(elem.begin(), elem.end()), &p)) {
|
||||
error = strprintf("Key path value '%s' is not a valid uint32", std::string(elem.begin(), elem.end()));
|
||||
const auto p{ToIntegral<uint32_t>(std::string_view{elem.begin(), elem.end()})};
|
||||
if (!p) {
|
||||
error = strprintf("Key path value '%s' is not a valid uint32", std::string_view{elem.begin(), elem.end()});
|
||||
return std::nullopt;
|
||||
} else if (p > 0x7FFFFFFFUL) {
|
||||
error = strprintf("Key path value %u is out of range", p);
|
||||
} else if (*p > 0x7FFFFFFFUL) {
|
||||
error = strprintf("Key path value %u is out of range", *p);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return std::make_optional<uint32_t>(p | (((uint32_t)hardened) << 31));
|
||||
return std::make_optional<uint32_t>(*p | (((uint32_t)hardened) << 31));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user