6 #ifndef BITCOIN_SCRIPT_SIGN_H 7 #define BITCOIN_SCRIPT_SIGN_H 33 std::vector<uint8_t> &vchSig,
const CKeyID &keyid,
34 const CScript &scriptCode)
const = 0;
51 std::vector<uint8_t> &vchSig,
const CKeyID &keyid,
52 const CScript &scriptCode)
const override;
60 typedef std::pair<CPubKey, std::vector<uint8_t>>
SigPair;
68 bool complete =
false;
94 template <
typename Stream,
typename... X>
102 template <
typename Stream,
typename... X>
105 size_t remaining_before = s.size();
107 size_t remaining_after = s.size();
108 if (remaining_after + expected_size != remaining_before) {
109 throw std::ios_base::failure(
"Size of value was not the stated size");
114 template <
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());
125 if (!pubkey.IsFullyValid()) {
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");
135 if (value_len % 4 || value_len == 0) {
136 throw std::ios_base::failure(
"Invalid length for HD key path");
141 for (
unsigned int i = 4; i < value_len; i +=
sizeof(uint32_t)) {
144 keypath.
path.push_back(index);
148 hd_keypaths.emplace(pubkey, std::move(keypath));
152 template <
typename Stream>
154 const std::map<CPubKey, KeyOriginInfo> &hd_keypaths,
156 for (
auto keypath_pair : hd_keypaths) {
157 if (!keypath_pair.first.IsValid()) {
158 throw std::ios_base::failure(
"Invalid CPubKey being serialized");
163 s << keypath_pair.second.fingerprint;
164 for (
const auto &path : keypath_pair.second.path) {
185 unsigned int nIn,
const CTxOut &txout);
198 const std::map<COutPoint, Coin> &coins,
200 std::map<int, std::string> &input_errors);
202 #endif // BITCOIN_SCRIPT_SIGN_H 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...
static constexpr unsigned int SIZE
secp256k1:
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.
void SerializeToVector(Stream &s, const X &... args)
uint64_t ReadCompactSize(Stream &is)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
const MutableTransactionSignatureChecker checker
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
Extract signature data from a transaction input, and insert it.
CScript scriptSig
The scriptSig of an input.
std::vector< CKeyID > missing_sigs
KeyIDs of pubkeys for signatures which could not be found.
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
Interface for signature creators.
std::vector< CKeyID > missing_pubkeys
KeyIDs of pubkeys which could not be found.
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.
const BaseSignatureChecker & Checker() const override
std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > misc_pubkeys
A signature creator for transactions.
constexpr Span< A > MakeSpan(A(&a)[N])
Create a span to a container exposing data() and size().
void UnserializeMany(Stream &s)
void UnserializeFromVector(Stream &s, X &... args)
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.
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &scriptPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
SignatureData(const CScript &script)
void UpdateInput(CTxIn &input, const SignatureData &data)
uint160 missing_redeem_script
ScriptID of the missing redeemScript (if any)
static constexpr unsigned int COMPRESSED_SIZE
An input of a transaction.
An encapsulated public key.
An output of a transaction.
std::pair< CPubKey, std::vector< uint8_t > > SigPair
const BaseSignatureCreator & DUMMY_MAXIMUM_SIGNATURE_CREATOR
A signature creator that just produces 72-byte empty signatures.
void SerializeMany(Stream &s)
An interface to be implemented by keystores that support signing.
void SerializeHDKeypaths(Stream &s, const std::map< CPubKey, KeyOriginInfo > &hd_keypaths, uint8_t type)
virtual ~BaseSignatureCreator()
Serialized script, used inside transaction inputs and outputs.
void DeserializeHDKeypaths(Stream &s, const std::vector< uint8_t > &key, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
A mutable version of CTransaction.
A reference to a CKey: the Hash160 of its serialized public key.
size_t GetSerializeSizeMany(int nVersion, const T &... t)
A reference to a CScript: the Hash160 of its serialization (see script.h)
An encapsulated secp256k1 private key.
The basic transaction that is broadcasted on the network and contained in blocks. ...
std::vector< uint32_t > path
CScript redeem_script
The redeemScript (if any) for the input.
std::map< CKeyID, SigPair > signatures
BIP 174 style partial signatures for the input.
Signature hash type wrapper class.
virtual const BaseSignatureChecker & Checker() const =0
const CMutableTransaction * txTo
uint8_t fingerprint[4]
First 32 bits of the Hash160 of the public key at the root of the path.