5#include <chainparams.h>
41 std::map<CPubKey, KeyOriginInfo> hd_keypaths;
44 }
catch (
const std::ios_base::failure&) {
51 std::map<CPubKey, KeyOriginInfo> hd_keypaths;
53 const std::optional<CPubKey> pub_key = ConsumeDeserializable<CPubKey>(fuzzed_data_provider);
57 const std::optional<KeyOriginInfo> key_origin_info = ConsumeDeserializable<KeyOriginInfo>(fuzzed_data_provider);
58 if (!key_origin_info) {
61 hd_keypaths[*pub_key] = *key_origin_info;
66 }
catch (
const std::ios_base::failure&) {
68 std::map<CPubKey, KeyOriginInfo> deserialized_hd_keypaths;
71 }
catch (
const std::ios_base::failure&) {
73 assert(hd_keypaths.size() >= deserialized_hd_keypaths.size());
79 signature_data_1.MergeSignatureData(signature_data_2);
89 const std::optional<CMutableTransaction> mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider,
TX_WITH_WITNESS);
90 const std::optional<CTxOut> tx_out = ConsumeDeserializable<CTxOut>(fuzzed_data_provider);
91 const unsigned int n_in = fuzzed_data_provider.
ConsumeIntegral<
unsigned int>();
92 if (mutable_transaction && tx_out && mutable_transaction->vin.size() > n_in) {
100 if (mutable_transaction) {
103 const std::optional<CMutableTransaction> opt_tx_to = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider,
TX_WITH_WITNESS);
109 if (n_in < tx_to.
vin.size() && tx_to.
vin[n_in].prevout.n < tx_from.vout.size()) {
113 if (n_in < script_tx_to.
vin.size()) {
118 (void)
SignSignature(provider, from_pub_key, script_tx_to, n_in, amount, n_hash_type, empty);
120 std::vector<unsigned char> vch_sig;
124 address =
k.GetPubKey().GetID();
131 (void)signature_creator.CreateSig(provider, vch_sig, address, script_code, sigversion);
133 std::map<COutPoint, Coin> coins{
ConsumeCoins(fuzzed_data_provider)};
134 std::map<int, bilingual_str> input_errors;
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
An encapsulated private key.
A reference to a CKey: the Hash160 of its serialized public key.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
Double ended buffer combining vector and stream-like interfaces.
RAII class initializing and deinitializing global state for elliptic curve support.
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddKey(const CKey &key)
T PickValueInArray(const T(&array)[size])
A signature creator for transactions.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
@ BASE
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
@ WITNESS_V0
Witness v0 (P2WPKH and P2WSH); see BIP 141.
static constexpr TransactionSerParams TX_WITH_WITNESS
void SerializeHDKeypaths(Stream &s, const std::map< CPubKey, KeyOriginInfo > &hd_keypaths, CompactSizeWriter type)
void DeserializeHDKeypaths(Stream &s, const std::vector< unsigned char > &key, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
void SignTransaction(CMutableTransaction &mtx, const SigningProvider *keystore, const std::map< COutPoint, Coin > &coins, const UniValue &hashType, UniValue &result)
Sign a transaction with the given keystore and previous transactions.
FUZZ_TARGET(script_sign,.init=initialize_script_sign)
void initialize_script_sign()
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
void UpdateInput(CTxIn &input, const SignatureData &data)
const BaseSignatureCreator & DUMMY_MAXIMUM_SIGNATURE_CREATOR
A signature creator that just produces 72-byte empty signatures.
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
Extract signature data from a transaction input, and insert it.
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
A mutable version of CTransaction.
void MergeSignatureData(SignatureData sigdata)
CScript ConsumeScript(FuzzedDataProvider &fuzzed_data_provider, const bool maybe_p2wsh) noexcept
CKey ConsumePrivateKey(FuzzedDataProvider &fuzzed_data_provider, std::optional< bool > compressed) noexcept
CAmount ConsumeMoney(FuzzedDataProvider &fuzzed_data_provider, const std::optional< CAmount > &max) noexcept
std::map< COutPoint, Coin > ConsumeCoins(FuzzedDataProvider &fuzzed_data_provider) noexcept
DataStream ConsumeDataStream(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
std::vector< B > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
uint160 ConsumeUInt160(FuzzedDataProvider &fuzzed_data_provider) noexcept
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType, SignatureData &sig_data)
Produce a satisfying script (scriptSig or witness).