mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 10:12:28 +02:00
Add PubKeyDestination for P2PK scripts
P2PK scripts are not PKHash destinations, they should have their own type. This also results in no longer showing a p2pkh address for p2pk outputs. However for backwards compatibility, ListCoinst will still do this conversion.
This commit is contained in:
@@ -149,13 +149,16 @@ FUZZ_TARGET(script, .init = initialize_script)
|
||||
const CTxDestination tx_destination_2{ConsumeTxDestination(fuzzed_data_provider)};
|
||||
const std::string encoded_dest{EncodeDestination(tx_destination_1)};
|
||||
const UniValue json_dest{DescribeAddress(tx_destination_1)};
|
||||
Assert(tx_destination_1 == DecodeDestination(encoded_dest));
|
||||
(void)GetKeyForDestination(/*store=*/{}, tx_destination_1);
|
||||
const CScript dest{GetScriptForDestination(tx_destination_1)};
|
||||
const bool valid{IsValidDestination(tx_destination_1)};
|
||||
Assert(dest.empty() != valid);
|
||||
|
||||
Assert(valid == IsValidDestinationString(encoded_dest));
|
||||
if (!std::get_if<PubKeyDestination>(&tx_destination_1)) {
|
||||
// Only try to round trip non-pubkey destinations since PubKeyDestination has no encoding
|
||||
Assert(dest.empty() != valid);
|
||||
Assert(tx_destination_1 == DecodeDestination(encoded_dest));
|
||||
Assert(valid == IsValidDestinationString(encoded_dest));
|
||||
}
|
||||
|
||||
(void)(tx_destination_1 < tx_destination_2);
|
||||
if (tx_destination_1 == tx_destination_2) {
|
||||
|
||||
@@ -172,6 +172,15 @@ CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) no
|
||||
[&] {
|
||||
tx_destination = CNoDestination{};
|
||||
},
|
||||
[&] {
|
||||
bool compressed = fuzzed_data_provider.ConsumeBool();
|
||||
CPubKey pk{ConstructPubKeyBytes(
|
||||
fuzzed_data_provider,
|
||||
ConsumeFixedLengthByteVector(fuzzed_data_provider, (compressed ? CPubKey::COMPRESSED_SIZE : CPubKey::SIZE)),
|
||||
compressed
|
||||
)};
|
||||
tx_destination = PubKeyDestination{pk};
|
||||
},
|
||||
[&] {
|
||||
tx_destination = PKHash{ConsumeUInt160(fuzzed_data_provider)};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user