mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +02:00
Pass datacarrier setting into IsStandard
This commit is contained in:
@@ -157,12 +157,12 @@ FUZZ_TARGET_INIT(key, initialize_key)
|
||||
assert(fillable_signing_provider_pub.HaveKey(pubkey.GetID()));
|
||||
|
||||
TxoutType which_type_tx_pubkey;
|
||||
const bool is_standard_tx_pubkey = IsStandard(tx_pubkey_script, which_type_tx_pubkey);
|
||||
const bool is_standard_tx_pubkey = IsStandard(tx_pubkey_script, std::nullopt, which_type_tx_pubkey);
|
||||
assert(is_standard_tx_pubkey);
|
||||
assert(which_type_tx_pubkey == TxoutType::PUBKEY);
|
||||
|
||||
TxoutType which_type_tx_multisig;
|
||||
const bool is_standard_tx_multisig = IsStandard(tx_multisig_script, which_type_tx_multisig);
|
||||
const bool is_standard_tx_multisig = IsStandard(tx_multisig_script, std::nullopt, which_type_tx_multisig);
|
||||
assert(is_standard_tx_multisig);
|
||||
assert(which_type_tx_multisig == TxoutType::MULTISIG);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ FUZZ_TARGET_INIT(script, initialize_script)
|
||||
}
|
||||
|
||||
TxoutType which_type;
|
||||
bool is_standard_ret = IsStandard(script, which_type);
|
||||
bool is_standard_ret = IsStandard(script, std::nullopt, which_type);
|
||||
if (!is_standard_ret) {
|
||||
assert(which_type == TxoutType::NONSTANDARD ||
|
||||
which_type == TxoutType::NULL_DATA ||
|
||||
|
||||
@@ -141,23 +141,30 @@ BOOST_AUTO_TEST_CASE(multisig_IsStandard)
|
||||
for (int i = 0; i < 4; i++)
|
||||
key[i].MakeNewKey(true);
|
||||
|
||||
TxoutType whichType;
|
||||
const auto is_standard{[](const CScript& spk) {
|
||||
TxoutType type;
|
||||
bool res{::IsStandard(spk, std::nullopt, type)};
|
||||
if (res) {
|
||||
BOOST_CHECK_EQUAL(type, TxoutType::MULTISIG);
|
||||
}
|
||||
return res;
|
||||
}};
|
||||
|
||||
CScript a_and_b;
|
||||
a_and_b << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << OP_2 << OP_CHECKMULTISIG;
|
||||
BOOST_CHECK(::IsStandard(a_and_b, whichType));
|
||||
BOOST_CHECK(is_standard(a_and_b));
|
||||
|
||||
CScript a_or_b;
|
||||
a_or_b << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << OP_2 << OP_CHECKMULTISIG;
|
||||
BOOST_CHECK(::IsStandard(a_or_b, whichType));
|
||||
BOOST_CHECK(is_standard(a_or_b));
|
||||
|
||||
CScript escrow;
|
||||
escrow << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << ToByteVector(key[2].GetPubKey()) << OP_3 << OP_CHECKMULTISIG;
|
||||
BOOST_CHECK(::IsStandard(escrow, whichType));
|
||||
BOOST_CHECK(is_standard(escrow));
|
||||
|
||||
CScript one_of_four;
|
||||
one_of_four << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << ToByteVector(key[2].GetPubKey()) << ToByteVector(key[3].GetPubKey()) << OP_4 << OP_CHECKMULTISIG;
|
||||
BOOST_CHECK(!::IsStandard(one_of_four, whichType));
|
||||
BOOST_CHECK(!is_standard(one_of_four));
|
||||
|
||||
CScript malformed[6];
|
||||
malformed[0] << OP_3 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << OP_2 << OP_CHECKMULTISIG;
|
||||
@@ -167,8 +174,9 @@ BOOST_AUTO_TEST_CASE(multisig_IsStandard)
|
||||
malformed[4] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey()) << OP_CHECKMULTISIG;
|
||||
malformed[5] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey());
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
BOOST_CHECK(!::IsStandard(malformed[i], whichType));
|
||||
for (int i = 0; i < 6; i++) {
|
||||
BOOST_CHECK(!is_standard(malformed[i]));
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multisig_Sign)
|
||||
|
||||
Reference in New Issue
Block a user