mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
fuzz: bolster ExtractDestination(s) checks
This commit is contained in:
parent
2dab2d239a
commit
a29f522ba4
1 changed files with 38 additions and 10 deletions
|
@ -56,22 +56,45 @@ FUZZ_TARGET_INIT(script, initialize_script)
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
(void)ExtractDestination(script, address);
|
|
||||||
|
|
||||||
TxoutType type_ret;
|
TxoutType type_ret;
|
||||||
std::vector<CTxDestination> addresses;
|
std::vector<CTxDestination> addresses;
|
||||||
int required_ret;
|
int required_ret;
|
||||||
(void)ExtractDestinations(script, type_ret, addresses, required_ret);
|
bool extract_destinations_ret = ExtractDestinations(script, type_ret, addresses, required_ret);
|
||||||
|
bool extract_destination_ret = ExtractDestination(script, address);
|
||||||
const FlatSigningProvider signing_provider;
|
if (!extract_destinations_ret) {
|
||||||
(void)InferDescriptor(script, signing_provider);
|
assert(!extract_destination_ret);
|
||||||
|
if (type_ret == TxoutType::MULTISIG) {
|
||||||
(void)IsSegWitOutput(signing_provider, script);
|
assert(addresses.empty() && required_ret == 0);
|
||||||
|
} else {
|
||||||
(void)IsSolvable(signing_provider, script);
|
assert(type_ret == TxoutType::PUBKEY ||
|
||||||
|
type_ret == TxoutType::NONSTANDARD ||
|
||||||
|
type_ret == TxoutType::NULL_DATA);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert(required_ret >= 1 && required_ret <= 16);
|
||||||
|
assert((unsigned long)required_ret == addresses.size());
|
||||||
|
assert(type_ret == TxoutType::MULTISIG || required_ret == 1);
|
||||||
|
}
|
||||||
|
if (type_ret == TxoutType::NONSTANDARD || type_ret == TxoutType::NULL_DATA) {
|
||||||
|
assert(!extract_destinations_ret);
|
||||||
|
}
|
||||||
|
if (!extract_destination_ret) {
|
||||||
|
assert(type_ret == TxoutType::PUBKEY ||
|
||||||
|
type_ret == TxoutType::NONSTANDARD ||
|
||||||
|
type_ret == TxoutType::NULL_DATA ||
|
||||||
|
type_ret == TxoutType::MULTISIG);
|
||||||
|
} else {
|
||||||
|
assert(address == addresses[0]);
|
||||||
|
}
|
||||||
|
if (type_ret == TxoutType::NONSTANDARD ||
|
||||||
|
type_ret == TxoutType::NULL_DATA ||
|
||||||
|
type_ret == TxoutType::MULTISIG) {
|
||||||
|
assert(!extract_destination_ret);
|
||||||
|
}
|
||||||
|
|
||||||
TxoutType which_type;
|
TxoutType which_type;
|
||||||
bool is_standard_ret = IsStandard(script, which_type);
|
bool is_standard_ret = IsStandard(script, which_type);
|
||||||
|
assert(type_ret == which_type);
|
||||||
if (!is_standard_ret) {
|
if (!is_standard_ret) {
|
||||||
assert(which_type == TxoutType::NONSTANDARD ||
|
assert(which_type == TxoutType::NONSTANDARD ||
|
||||||
which_type == TxoutType::NULL_DATA ||
|
which_type == TxoutType::NULL_DATA ||
|
||||||
|
@ -88,6 +111,11 @@ FUZZ_TARGET_INIT(script, initialize_script)
|
||||||
which_type == TxoutType::NONSTANDARD);
|
which_type == TxoutType::NONSTANDARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FlatSigningProvider signing_provider;
|
||||||
|
(void)InferDescriptor(script, signing_provider);
|
||||||
|
(void)IsSegWitOutput(signing_provider, script);
|
||||||
|
(void)IsSolvable(signing_provider, script);
|
||||||
|
|
||||||
(void)RecursiveDynamicUsage(script);
|
(void)RecursiveDynamicUsage(script);
|
||||||
|
|
||||||
std::vector<std::vector<unsigned char>> solutions;
|
std::vector<std::vector<unsigned char>> solutions;
|
||||||
|
|
Loading…
Add table
Reference in a new issue