Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | List of all members
FillableSigningProvider Class Reference

Fillable signing provider that keeps keys in an address->secret map. More...

#include <signingprovider.h>

Inheritance diagram for FillableSigningProvider:
[legend]
Collaboration diagram for FillableSigningProvider:
[legend]

Public Member Functions

virtual bool AddKeyPubKey (const CKey &key, const CPubKey &pubkey)
 
virtual bool AddKey (const CKey &key)
 
virtual bool GetPubKey (const CKeyID &address, CPubKey &vchPubKeyOut) const override
 
virtual bool HaveKey (const CKeyID &address) const override
 
virtual std::set< CKeyIDGetKeys () const
 
virtual bool GetKey (const CKeyID &address, CKey &keyOut) const override
 
virtual bool AddCScript (const CScript &redeemScript)
 
virtual bool HaveCScript (const CScriptID &hash) const override
 
virtual std::set< CScriptIDGetCScripts () const
 
virtual bool GetCScript (const CScriptID &hash, CScript &redeemScriptOut) const override
 
- Public Member Functions inherited from SigningProvider
virtual ~SigningProvider ()=default
 
virtual bool GetCScript (const CScriptID &scriptid, CScript &script) const
 
virtual bool HaveCScript (const CScriptID &scriptid) const
 
virtual bool GetPubKey (const CKeyID &address, CPubKey &pubkey) const
 
virtual bool GetKey (const CKeyID &address, CKey &key) const
 
virtual bool HaveKey (const CKeyID &address) const
 
virtual bool GetKeyOrigin (const CKeyID &keyid, KeyOriginInfo &info) const
 
virtual bool GetTaprootSpendData (const XOnlyPubKey &output_key, TaprootSpendData &spenddata) const
 
virtual bool GetTaprootBuilder (const XOnlyPubKey &output_key, TaprootBuilder &builder) const
 
bool GetKeyByXOnly (const XOnlyPubKey &pubkey, CKey &key) const
 
bool GetPubKeyByXOnly (const XOnlyPubKey &pubkey, CPubKey &out) const
 
bool GetKeyOriginByXOnly (const XOnlyPubKey &pubkey, KeyOriginInfo &info) const
 

Public Attributes

RecursiveMutex cs_KeyStore
 

Protected Types

using KeyMap = std::map< CKeyID, CKey >
 
using ScriptMap = std::map< CScriptID, CScript >
 

Protected Member Functions

KeyMap mapKeys GUARDED_BY (cs_KeyStore)
 Map of key id to unencrypted private keys known by the signing provider. More...
 
ScriptMap mapScripts GUARDED_BY (cs_KeyStore)
 Map of script id to scripts known by the signing provider. More...
 
void ImplicitlyLearnRelatedKeyScripts (const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
 

Detailed Description

Fillable signing provider that keeps keys in an address->secret map.

Definition at line 226 of file signingprovider.h.

Member Typedef Documentation

◆ KeyMap

using FillableSigningProvider::KeyMap = std::map<CKeyID, CKey>
protected

Definition at line 229 of file signingprovider.h.

◆ ScriptMap

Definition at line 230 of file signingprovider.h.

Member Function Documentation

◆ AddCScript()

bool FillableSigningProvider::AddCScript ( const CScript redeemScript)
virtual

Reimplemented in wallet::LegacyScriptPubKeyMan.

Definition at line 158 of file signingprovider.cpp.

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

◆ AddKey()

virtual bool FillableSigningProvider::AddKey ( const CKey key)
inlinevirtual

Definition at line 287 of file signingprovider.h.

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

◆ AddKeyPubKey()

bool FillableSigningProvider::AddKeyPubKey ( const CKey key,
const CPubKey pubkey 
)
virtual

Reimplemented in wallet::LegacyScriptPubKeyMan.

Definition at line 123 of file signingprovider.cpp.

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

◆ GetCScript()

bool FillableSigningProvider::GetCScript ( const CScriptID hash,
CScript redeemScriptOut 
) const
overridevirtual

Reimplemented from SigningProvider.

Definition at line 186 of file signingprovider.cpp.

Here is the caller graph for this function:

◆ GetCScripts()

std::set< CScriptID > FillableSigningProvider::GetCScripts ( ) const
virtual

Definition at line 176 of file signingprovider.cpp.

Here is the caller graph for this function:

◆ GetKey()

bool FillableSigningProvider::GetKey ( const CKeyID address,
CKey keyOut 
) const
overridevirtual

Reimplemented from SigningProvider.

Reimplemented in wallet::LegacyDataSPKM.

Definition at line 147 of file signingprovider.cpp.

Here is the caller graph for this function:

◆ GetKeys()

std::set< CKeyID > FillableSigningProvider::GetKeys ( ) const
virtual

Reimplemented in wallet::LegacyScriptPubKeyMan.

Definition at line 137 of file signingprovider.cpp.

Here is the caller graph for this function:

◆ GetPubKey()

bool FillableSigningProvider::GetPubKey ( const CKeyID address,
CPubKey vchPubKeyOut 
) const
overridevirtual

Reimplemented from SigningProvider.

Reimplemented in wallet::LegacyDataSPKM.

Definition at line 113 of file signingprovider.cpp.

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

◆ GUARDED_BY() [1/2]

KeyMap mapKeys FillableSigningProvider::GUARDED_BY ( cs_KeyStore  )
protected

Map of key id to unencrypted private keys known by the signing provider.

Map may be empty if the provider has another source of keys, like an encrypted store.

◆ GUARDED_BY() [2/2]

ScriptMap mapScripts FillableSigningProvider::GUARDED_BY ( cs_KeyStore  )
protected

Map of script id to scripts known by the signing provider.

This map originally just held P2SH redeemScripts, and was used by wallet code to look up script ids referenced in "OP_HASH160 <script id> OP_EQUAL" P2SH outputs. Later in 605e8473a7d it was extended to hold P2WSH witnessScripts as well, and used to look up nested scripts referenced in "OP_0 <script hash>" P2WSH outputs. Later in commits f4691ab3a9d and 248f3a76a82, it was extended once again to hold segwit "OP_0 <key or script hash>" scriptPubKeys, in order to give the wallet a way to distinguish between segwit outputs that it generated addresses for and wanted to receive payments from, and segwit outputs that it never generated addresses for, but it could spend just because of having keys. (Before segwit activation it was also important to not treat segwit outputs to arbitrary wallet keys as payments, because these could be spent by anyone without even needing to sign with the keys.)

Some of the scripts stored in mapScripts are memory-only and intentionally not saved to disk. Specifically, scripts added by ImplicitlyLearnRelatedKeyScripts(pubkey) calls are not written to disk so future wallet code can have flexibility to be more selective about what transaction outputs it recognizes as payments, instead of having to treat all outputs spending to keys it knows as payments. By contrast, mapScripts entries added by AddCScript(script), LearnRelatedScripts(pubkey, type), and LearnAllRelatedScripts(pubkey) calls are saved because they are all intentionally used to receive payments.

The FillableSigningProvider::mapScripts script map should not be confused with LegacyScriptPubKeyMan::setWatchOnly script set. The two collections can hold the same scripts, but they serve different purposes. The setWatchOnly script set is intended to expand the set of outputs the wallet considers payments. Every output with a script it contains is considered to belong to the wallet, regardless of whether the script is solvable or signable. By contrast, the scripts in mapScripts are only used for solving, and to restrict which outputs are considered payments by the wallet. An output with a script in mapScripts, unlike setWatchOnly, is not automatically considered to belong to the wallet if it can't be solved and signed for.

◆ HaveCScript()

bool FillableSigningProvider::HaveCScript ( const CScriptID hash) const
overridevirtual

Reimplemented from SigningProvider.

Definition at line 170 of file signingprovider.cpp.

Here is the caller graph for this function:

◆ HaveKey()

bool FillableSigningProvider::HaveKey ( const CKeyID address) const
overridevirtual

Reimplemented from SigningProvider.

Reimplemented in wallet::LegacyDataSPKM.

Definition at line 131 of file signingprovider.cpp.

Here is the caller graph for this function:

◆ ImplicitlyLearnRelatedKeyScripts()

void FillableSigningProvider::ImplicitlyLearnRelatedKeyScripts ( const CPubKey pubkey)
protected

Definition at line 90 of file signingprovider.cpp.

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

Member Data Documentation

◆ cs_KeyStore

RecursiveMutex FillableSigningProvider::cs_KeyStore
mutable

Definition at line 284 of file signingprovider.h.


The documentation for this class was generated from the following files: