6#ifndef BITCOIN_SCRIPT_SIGN_H
7#define BITCOIN_SCRIPT_SIGN_H
34 const CScript &scriptCode)
const = 0;
52 const CScript &scriptCode)
const override;
60typedef std::pair<CPubKey, std::vector<uint8_t>>
SigPair;
94template <
typename Stream,
typename... X>
102template <
typename Stream,
typename... X>
109 throw std::ios_base::failure(
"Size of value was not the stated size");
114template <
typename Stream>
116 std::map<CPubKey, KeyOriginInfo> &hd_keypaths) {
120 throw std::ios_base::failure(
121 "Size of key was not the expected size for the type BIP32 keypath");
124 CPubKey pubkey(key.begin() + 1, key.end());
126 throw std::ios_base::failure(
"Invalid pubkey");
128 if (hd_keypaths.count(pubkey) > 0) {
129 throw std::ios_base::failure(
130 "Duplicate Key, pubkey derivation path already provided");
136 throw std::ios_base::failure(
"Invalid length for HD key path");
148 hd_keypaths.emplace(pubkey, std::move(
keypath));
152template <
typename Stream>
154 const std::map<CPubKey, KeyOriginInfo> &hd_keypaths,
158 throw std::ios_base::failure(
"Invalid CPubKey being serialized");
185 unsigned int nIn,
const CTxOut &txout);
198 const std::map<COutPoint, Coin> &coins,
Interface for signature creators.
virtual bool CreateSig(const SigningProvider &provider, std::vector< uint8_t > &vchSig, const CKeyID &keyid, const CScript &scriptCode) const =0
Create a singular (non-script) signature.
virtual const BaseSignatureChecker & Checker() const =0
virtual ~BaseSignatureCreator()
An encapsulated secp256k1 private key.
A reference to a CKey: the Hash160 of its serialized public key.
A mutable version of CTransaction.
An encapsulated public key.
static constexpr unsigned int COMPRESSED_SIZE
static constexpr unsigned int SIZE
secp256k1:
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
Serialized script, used inside transaction inputs and outputs.
A reference to a CScript: the Hash160 of its serialization (see script.h)
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
An output of a transaction.
A signature creator for transactions.
bool CreateSig(const SigningProvider &provider, std::vector< uint8_t > &vchSig, const CKeyID &keyid, const CScript &scriptCode) const override
Create a singular (non-script) signature.
const BaseSignatureChecker & Checker() const override
const CMutableTransaction * txTo
const MutableTransactionSignatureChecker checker
Signature hash type wrapper class.
An interface to be implemented by keystores that support signing.
A Span is an object that can refer to a contiguous sequence of objects.
CONSTEXPR_IF_NOT_DEBUG Span< C > first(std::size_t count) const noexcept
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
void SerializeMany(Stream &s)
size_t GetSerializeSizeMany(int nVersion, const T &...t)
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
void UnserializeMany(Stream &s)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
void UnserializeFromVector(Stream &s, X &...args)
void UpdateInput(CTxIn &input, const SignatureData &data)
void SerializeToVector(Stream &s, const X &...args)
bool SignTransaction(CMutableTransaction &mtx, const SigningProvider *provider, const std::map< COutPoint, Coin > &coins, SigHashType sigHashType, std::map< int, std::string > &input_errors)
Sign the CMutableTransaction.
bool IsSolvable(const SigningProvider &provider, const CScript &script)
Check whether we know how to sign for an output like this, assuming we have all private keys.
const BaseSignatureCreator & DUMMY_MAXIMUM_SIGNATURE_CREATOR
A signature creator that just produces 72-byte empty signatures.
void SerializeHDKeypaths(Stream &s, const std::map< CPubKey, KeyOriginInfo > &hd_keypaths, uint8_t type)
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.
void DeserializeHDKeypaths(Stream &s, const std::vector< uint8_t > &key, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &scriptPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
std::pair< CPubKey, std::vector< uint8_t > > SigPair
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const Amount amount, SigHashType sigHashType)
Produce a script signature for a transaction.
uint8_t fingerprint[4]
First 32 bits of the Hash160 of the public key at the root of the path.
uint160 missing_redeem_script
ScriptID of the missing redeemScript (if any)
std::vector< CKeyID > missing_sigs
KeyIDs of pubkeys for signatures which could not be found.
void MergeSignatureData(SignatureData sigdata)
std::map< CKeyID, SigPair > signatures
BIP 174 style partial signatures for the input.
std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > misc_pubkeys
CScript scriptSig
The scriptSig of an input.
CScript redeem_script
The redeemScript (if any) for the input.
std::vector< CKeyID > missing_pubkeys
KeyIDs of pubkeys which could not be found.
SignatureData(const CScript &script)
bool complete
Stores whether the scriptSig are complete.