Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

sign.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_SCRIPT_SIGN_H
7 #define BITCOIN_SCRIPT_SIGN_H
8 
9 #include <script/interpreter.h>
10 
11 class CKeyID;
12 class CKeyStore;
13 class CScript;
14 class CTransaction;
15 
16 struct CMutableTransaction;
17 
20 protected:
22 
23 public:
24  explicit BaseSignatureCreator(const CKeyStore* keystoreIn) : keystore(keystoreIn) {}
25  const CKeyStore& KeyStore() const { return *keystore; };
26  virtual ~BaseSignatureCreator() {}
27  virtual const BaseSignatureChecker& Checker() const =0;
28 
30  virtual bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const =0;
31 };
32 
36  unsigned int nIn;
37  int nHashType;
40 
41 public:
42  TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn=SIGHASH_ALL);
43  const BaseSignatureChecker& Checker() const override{ return checker; }
44  bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
45 };
46 
49 
50 public:
51  MutableTransactionSignatureCreator(const CKeyStore* keystoreIn, const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amount, int nHashTypeIn) : TransactionSignatureCreator(keystoreIn, &tx, nInIn, amount, nHashTypeIn), tx(*txToIn) {}
52 };
53 
56 public:
57  explicit DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {}
58  const BaseSignatureChecker& Checker() const override;
59  bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
60 };
61 
62 struct SignatureData {
64 
66  explicit SignatureData(const CScript& script) : scriptSig(script) {}
67 };
68 
70 bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& scriptPubKey, SignatureData& sigdata);
71 
73 bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType);
74 bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType);
75 
77 SignatureData CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecker& checker, const SignatureData& scriptSig1, const SignatureData& scriptSig2);
78 
80 SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nIn);
81 void UpdateTransaction(CMutableTransaction& tx, unsigned int nIn, const SignatureData& data);
82 
83 #endif // BITCOIN_SCRIPT_SIGN_H
const BaseSignatureChecker & Checker() const override
Definition: sign.h:43
CScript scriptSig
Definition: sign.h:63
Virtual base class for signature creators.
Definition: sign.h:19
A signature creator for transactions.
Definition: sign.h:34
SignatureData CombineSignatures(const CScript &scriptPubKey, const BaseSignatureChecker &checker, const SignatureData &scriptSig1, const SignatureData &scriptSig2)
Combine two script signatures using a generic signature checker, intelligently, possibly with OP_0 pl...
Definition: sign.cpp:310
unsigned int nIn
Definition: sign.h:36
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
SignatureData(const CScript &script)
Definition: sign.h:66
const CKeyStore * keystore
Definition: sign.h:21
const BaseSignatureChecker & Checker() const override
Definition: sign.cpp:335
virtual bool CreateSig(std::vector< unsigned char > &vchSig, const CKeyID &keyid, const CScript &scriptCode, SigVersion sigversion) const =0
Create a singular (non-script) signature.
const CKeyStore & KeyStore() const
Definition: sign.h:25
BaseSignatureCreator(const CKeyStore *keystoreIn)
Definition: sign.h:24
TransactionSignatureCreator(const CKeyStore *keystoreIn, const CTransaction *txToIn, unsigned int nInIn, const CAmount &amountIn, int nHashTypeIn=SIGHASH_ALL)
Definition: sign.cpp:18
bool CreateSig(std::vector< unsigned char > &vchSig, const CKeyID &keyid, const CScript &scriptCode, SigVersion sigversion) const override
Create a singular (non-script) signature.
Definition: sign.cpp:20
bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType)
Produce a script signature for a transaction.
Definition: sign.cpp:167
const TransactionSignatureChecker checker
Definition: sign.h:39
MutableTransactionSignatureCreator(const CKeyStore *keystoreIn, const CMutableTransaction *txToIn, unsigned int nInIn, const CAmount &amount, int nHashTypeIn)
Definition: sign.h:51
virtual ~BaseSignatureCreator()
Definition: sign.h:26
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:389
A virtual base class for key stores.
Definition: keystore.h:19
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:20
SignatureData()
Definition: sign.h:65
A mutable version of CTransaction.
Definition: transaction.h:291
DummySignatureCreator(const CKeyStore *keystoreIn)
Definition: sign.h:57
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
bool CreateSig(std::vector< unsigned char > &vchSig, const CKeyID &keyid, const CScript &scriptCode, SigVersion sigversion) const override
Create a singular (non-script) signature.
Definition: sign.cpp:340
const CTransaction * txTo
Definition: sign.h:35
bool ProduceSignature(const BaseSignatureCreator &creator, const CScript &scriptPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
Definition: sign.cpp:124
void UpdateTransaction(CMutableTransaction &tx, unsigned int nIn, const SignatureData &data)
Definition: sign.cpp:161
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn)
Extract signature data from a transaction, and insert it.
Definition: sign.cpp:153
A signature creator that just produces 72-byte empty signatures.
Definition: sign.h:55
virtual const BaseSignatureChecker & Checker() const =0
SigVersion
Definition: interpreter.h:109
Released under the MIT license