Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
251std::vector<CPubKey> GetMuSig2ParticipantPubkeys(const CPubKey& pubkey) const override;252std::map<CPubKey, std::vector<CPubKey>> GetAllMuSig2ParticipantPubkeys() const override;253void SetMuSig2SecNonce(const uint256& id, MuSig2SecNonce&& nonce) const override;254std::optional<std::reference_wrapper<MuSig2SecNonce>> GetMuSig2SecNonce(const uint256& session_id) const override;255void DeleteMuSig2Session(const uint256& session_id) const override;257FlatSigningProvider& Merge(FlatSigningProvider&& b) LIFETIMEBOUND;258};260/** Fillable signing provider that keeps keys in an address->secret map */261class FillableSigningProvider : public SigningProvider262{263protected:264using KeyMap = std::map<CKeyID, CKey>;265using ScriptMap = std::map<CScriptID, CScript>;267/**268* Map of key id to unencrypted private keys known by the signing provider.269* Map may be empty if the provider has another source of keys, like an270* encrypted store.271*/272KeyMap mapKeys GUARDED_BY(cs_KeyStore);274/**275* Map of script id to scripts known by the signing provider.276*277* This map originally just held P2SH redeemScripts, and was used by wallet278* code to look up script ids referenced in "OP_HASH160 <script id>279* OP_EQUAL" P2SH outputs. Later in 605e8473a7d it was extended to hold280* P2WSH witnessScripts as well, and used to look up nested scripts281* referenced in "OP_0 <script hash>" P2WSH outputs. Later in commits282* f4691ab3a9d and 248f3a76a82, it was extended once again to hold segwit283* "OP_0 <key or script hash>" scriptPubKeys, in order to give the wallet a284* way to distinguish between segwit outputs that it generated addresses for285* and wanted to receive payments from, and segwit outputs that it never286* generated addresses for, but it could spend just because of having keys.287* (Before segwit activation it was also important to not treat segwit288* outputs to arbitrary wallet keys as payments, because these could be289* spent by anyone without even needing to sign with the keys.)290*291* Some of the scripts stored in mapScripts are memory-only and292* intentionally not saved to disk. Specifically, scripts added by293* ImplicitlyLearnRelatedKeyScripts(pubkey) calls are not written to disk so294* future wallet code can have flexibility to be more selective about what295* transaction outputs it recognizes as payments, instead of having to treat296* all outputs spending to keys it knows as payments. By contrast,297* mapScripts entries added by AddCScript(script),298* LearnRelatedScripts(pubkey, type), and LearnAllRelatedScripts(pubkey)299* calls are saved because they are all intentionally used to receive300* payments.301*302* The FillableSigningProvider::mapScripts script map should not be confused303* with the wallet::LegacyDataSPKM::setWatchOnly script set. The two collections304* can hold the same scripts, but they serve different purposes. The305* setWatchOnly script set is intended to expand the set of outputs the306* wallet considers payments. Every output with a script it contains is307* considered to belong to the wallet, regardless of whether the script is308* solvable or signable. By contrast, the scripts in mapScripts are only309* used for solving, and to restrict which outputs are considered payments310* by the wallet. An output with a script in mapScripts, unlike311* setWatchOnly, is not automatically considered to belong to the wallet if312* it can't be solved and signed for.313*/314ScriptMap mapScripts GUARDED_BY(cs_KeyStore);316void ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);318public:319mutable RecursiveMutex cs_KeyStore;321virtual bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);322virtual bool AddKey(const CKey &key) { return AddKeyPubKey(key, key.GetPubKey()); }323virtual bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;324virtual bool HaveKey(const CKeyID &address) const override;325virtual std::set<CKeyID> GetKeys() const;326virtual bool GetKey(const CKeyID &address, CKey &keyOut) const override;327virtual bool AddCScript(const CScript& redeemScript);328virtual bool HaveCScript(const CScriptID &hash) const override;329virtual std::set<CScriptID> GetCScripts() const;330virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override;331};333/** Return the CKeyID of the key involved in a script (if there is a unique one). */334CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest);336/** A signing provider to be used to interface with multiple signing providers at once. */337class MultiSigningProvider: public SigningProvider {338std::vector<std::unique_ptr<SigningProvider>> m_providers;340public:341void AddProvider(std::unique_ptr<SigningProvider> provider);343bool GetCScript(const CScriptID& scriptid, CScript& script) const override;344bool GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const override;345bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;346bool GetKey(const CKeyID& keyid, CKey& key) const override;347bool GetTaprootSpendData(const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const override;348bool GetTaprootBuilder(const XOnlyPubKey& output_key, TaprootBuilder& builder) const override;349};351#endif // BITCOIN_SCRIPT_SIGNINGPROVIDER_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.