mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
node: use uint256::FromUserHex for -assumevalid parsing
Removes dependency on unsafe and deprecated uint256S. This makes parsing more strict, by returning an error when the input contains non-hex characters, or when it contains more than 64 hex digits. Also make feature_assumevalid.py more robust by using CBlock.hash which is guaranteed to be 64 characters long, as opposed to the variable-length hex(CBlock.sha256)
This commit is contained in:
parent
2e58fdb544
commit
6819e5a329
3 changed files with 12 additions and 3 deletions
|
|
@ -39,7 +39,13 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManage
|
|||
}
|
||||
}
|
||||
|
||||
if (auto value{args.GetArg("-assumevalid")}) opts.assumed_valid_block = uint256S(*value);
|
||||
if (auto value{args.GetArg("-assumevalid")}) {
|
||||
if (auto block_hash{uint256::FromUserHex(*value)}) {
|
||||
opts.assumed_valid_block = *block_hash;
|
||||
} else {
|
||||
return util::Error{strprintf(Untranslated("Invalid assumevalid block hash specified (%s), must be up to %d hex digits (or 0 to disable)"), *value, uint256::size() * 2)};
|
||||
}
|
||||
}
|
||||
|
||||
if (auto value{args.GetIntArg("-maxtipage")}) opts.max_tip_age = std::chrono::seconds{*value};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue