Bitcoin Core 28.99.0
P2P Digital Currency
Classes | Typedefs | Functions | Variables
sign.cpp File Reference
#include <script/sign.h>
#include <consensus/amount.h>
#include <key.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <script/keyorigin.h>
#include <script/miniscript.h>
#include <script/script.h>
#include <script/signingprovider.h>
#include <script/solver.h>
#include <uint256.h>
#include <util/translation.h>
#include <util/vector.h>
Include dependency graph for sign.cpp:

Go to the source code of this file.

Classes

struct  Satisfier< Pk >
 Context for solving a Miniscript. More...
 
struct  WshSatisfier
 Miniscript satisfier specific to P2WSH context. More...
 
struct  TapSatisfier
 Miniscript satisfier specific to Tapscript context. More...
 

Typedefs

typedef std::vector< unsigned char > valtype
 

Functions

static bool GetCScript (const SigningProvider &provider, const SignatureData &sigdata, const CScriptID &scriptid, CScript &script)
 
static bool GetPubKey (const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
 
static bool CreateSig (const BaseSignatureCreator &creator, SignatureData &sigdata, const SigningProvider &provider, std::vector< unsigned char > &sig_out, const CPubKey &pubkey, const CScript &scriptcode, SigVersion sigversion)
 
static bool CreateTaprootScriptSig (const BaseSignatureCreator &creator, SignatureData &sigdata, const SigningProvider &provider, std::vector< unsigned char > &sig_out, const XOnlyPubKey &pubkey, const uint256 &leaf_hash, SigVersion sigversion)
 
template<typename M , typename K , typename V >
miniscript::Availability MsLookupHelper (const M &map, const K &key, V &value)
 
static bool SignTaprootScript (const SigningProvider &provider, const BaseSignatureCreator &creator, SignatureData &sigdata, int leaf_version, Span< const unsigned char > script_bytes, std::vector< valtype > &result)
 
static bool SignTaproot (const SigningProvider &provider, const BaseSignatureCreator &creator, const WitnessV1Taproot &output, SignatureData &sigdata, std::vector< valtype > &result)
 
static bool SignStep (const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &scriptPubKey, std::vector< valtype > &ret, TxoutType &whichTypeRet, SigVersion sigversion, SignatureData &sigdata)
 Sign scriptPubKey using signature made with creator. More...
 
static CScript PushAll (const std::vector< valtype > &values)
 
bool ProduceSignature (const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
 Produce a script signature using a generic signature creator. More...
 
SignatureData DataFromTransaction (const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
 Extract signature data from a transaction input, and insert it. More...
 
void UpdateInput (CTxIn &input, const SignatureData &data)
 
bool IsSegWitOutput (const SigningProvider &provider, const CScript &script)
 Check whether a scriptPubKey is known to be segwit. More...
 
bool SignTransaction (CMutableTransaction &mtx, const SigningProvider *keystore, const std::map< COutPoint, Coin > &coins, int nHashType, std::map< int, bilingual_str > &input_errors)
 Sign the CMutableTransaction. More...
 

Variables

const BaseSignatureCheckerDUMMY_CHECKER = DummySignatureChecker()
 A signature checker that accepts all signatures. More...
 
const BaseSignatureCreatorDUMMY_SIGNATURE_CREATOR = DummySignatureCreator(32, 32)
 A signature creator that just produces 71-byte empty signatures. More...
 
const BaseSignatureCreatorDUMMY_MAXIMUM_SIGNATURE_CREATOR = DummySignatureCreator(33, 32)
 A signature creator that just produces 72-byte empty signatures. More...
 

Typedef Documentation

◆ valtype

typedef std::vector<unsigned char> valtype

Definition at line 21 of file sign.cpp.

Function Documentation

◆ CreateSig()

static bool CreateSig ( const BaseSignatureCreator creator,
SignatureData sigdata,
const SigningProvider provider,
std::vector< unsigned char > &  sig_out,
const CPubKey pubkey,
const CScript scriptcode,
SigVersion  sigversion 
)
static

Definition at line 132 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateTaprootScriptSig()

static bool CreateTaprootScriptSig ( const BaseSignatureCreator creator,
SignatureData sigdata,
const SigningProvider provider,
std::vector< unsigned char > &  sig_out,
const XOnlyPubKey pubkey,
const uint256 leaf_hash,
SigVersion  sigversion 
)
static

Definition at line 154 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DataFromTransaction()

SignatureData DataFromTransaction ( const CMutableTransaction tx,
unsigned int  nIn,
const CTxOut txout 
)

Extract signature data from a transaction input, and insert it.

Definition at line 610 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCScript()

static bool GetCScript ( const SigningProvider provider,
const SignatureData sigdata,
const CScriptID scriptid,
CScript script 
)
static

Definition at line 93 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPubKey()

static bool GetPubKey ( const SigningProvider provider,
const SignatureData sigdata,
const CKeyID address,
CPubKey pubkey 
)
static

Definition at line 109 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSegWitOutput()

bool IsSegWitOutput ( const SigningProvider provider,
const CScript script 
)

Check whether a scriptPubKey is known to be segwit.

Definition at line 747 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MsLookupHelper()

template<typename M , typename K , typename V >
miniscript::Availability MsLookupHelper ( const M &  map,
const K &  key,
V &  value 
)

Definition at line 180 of file sign.cpp.

Here is the caller graph for this function:

◆ ProduceSignature()

bool ProduceSignature ( const SigningProvider provider,
const BaseSignatureCreator creator,
const CScript fromPubKey,
SignatureData sigdata 
)

Produce a script signature using a generic signature creator.

Definition at line 502 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PushAll()

static CScript PushAll ( const std::vector< valtype > &  values)
static

Definition at line 485 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SignStep()

static bool SignStep ( const SigningProvider provider,
const BaseSignatureCreator creator,
const CScript scriptPubKey,
std::vector< valtype > &  ret,
TxoutType whichTypeRet,
SigVersion  sigversion,
SignatureData sigdata 
)
static

Sign scriptPubKey using signature made with creator.

Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed), unless whichTypeRet is TxoutType::SCRIPTHASH, in which case scriptSigRet is the redemption script. Returns false if scriptPubKey could not be completely satisfied.

Definition at line 401 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SignTaproot()

static bool SignTaproot ( const SigningProvider provider,
const BaseSignatureCreator creator,
const WitnessV1Taproot output,
SignatureData sigdata,
std::vector< valtype > &  result 
)
static

Definition at line 333 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SignTaprootScript()

static bool SignTaprootScript ( const SigningProvider provider,
const BaseSignatureCreator creator,
SignatureData sigdata,
int  leaf_version,
Span< const unsigned char >  script_bytes,
std::vector< valtype > &  result 
)
static

Definition at line 320 of file sign.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SignTransaction()

bool SignTransaction ( CMutableTransaction mtx,
const SigningProvider keystore,
const std::map< COutPoint, Coin > &  coins,
int  nHashType,
std::map< int, bilingual_str > &  input_errors 
)

Sign the CMutableTransaction.

Definition at line 766 of file sign.cpp.

Here is the call graph for this function:

◆ UpdateInput()

void UpdateInput ( CTxIn input,
const SignatureData data 
)

Definition at line 675 of file sign.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ DUMMY_CHECKER

const BaseSignatureChecker& DUMMY_CHECKER = DummySignatureChecker()

A signature checker that accepts all signatures.

Definition at line 710 of file sign.cpp.

◆ DUMMY_MAXIMUM_SIGNATURE_CREATOR

const BaseSignatureCreator& DUMMY_MAXIMUM_SIGNATURE_CREATOR = DummySignatureCreator(33, 32)

A signature creator that just produces 72-byte empty signatures.

Definition at line 745 of file sign.cpp.

◆ DUMMY_SIGNATURE_CREATOR

const BaseSignatureCreator& DUMMY_SIGNATURE_CREATOR = DummySignatureCreator(32, 32)

A signature creator that just produces 71-byte empty signatures.

Definition at line 744 of file sign.cpp.