14 template<
typename M,
typename K,
typename V>
17 auto it = map.find(key);
18 if (
it != map.end()) {
51 std::pair<CPubKey, KeyOriginInfo> out;
53 if (ret) info = std::move(out.second);
91 mapScripts[id] = std::move(script);
98 if (!
GetKey(address, key)) {
108 mapKeys[pubkey.
GetID()] = key;
109 ImplicitlyLearnRelatedKeyScripts(pubkey);
116 return mapKeys.count(address) > 0;
122 std::set<CKeyID> set_address;
123 for (
const auto& mi : mapKeys) {
124 set_address.insert(mi.first);
132 KeyMap::const_iterator mi = mapKeys.find(address);
133 if (mi != mapKeys.end()) {
146 mapScripts[
CScriptID(redeemScript)] = redeemScript;
153 return mapScripts.count(hash) > 0;
159 std::set<CScriptID> set_script;
160 for (
const auto& mi : mapScripts) {
161 set_script.insert(mi.first);
169 ScriptMap::const_iterator mi = mapScripts.find(hash);
170 if (mi != mapScripts.end())
172 redeemScriptOut = (*mi).second;
182 if (
auto id = std::get_if<PKHash>(&dest)) {
185 if (
auto witness_id = std::get_if<WitnessV0KeyHash>(&dest)) {
188 if (
auto script_hash = std::get_if<ScriptHash>(&dest)) {
193 if (
auto inner_witness_id = std::get_if<WitnessV0KeyHash>(&inner_dest)) {
194 return ToKeyID(*inner_witness_id);
virtual bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
std::deque< CInv >::iterator it
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
const SigningProvider * m_provider
CPubKey GetPubKey() const
Compute the public key from a private key.
std::map< CKeyID, CKey > keys
FlatSigningProvider Merge(const FlatSigningProvider &a, const FlatSigningProvider &b)
virtual bool AddCScript(const CScript &redeemScript)
virtual std::set< CScriptID > GetCScripts() const
virtual std::set< CKeyID > GetKeys() const
std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > origins
CKeyID GetKeyForDestination(const SigningProvider &store, const CTxDestination &dest)
Return the CKeyID of the key involved in a script (if there is a unique one).
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
bool GetCScript(const CScriptID &scriptid, CScript &script) const override
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
#define AssertLockHeld(cs)
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
std::map< CScriptID, CScript > scripts
virtual bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const
bool GetPubKey(const CKeyID &keyid, CPubKey &pubkey) const override
const SigningProvider & DUMMY_SIGNING_PROVIDER
An encapsulated public key.
bool GetKey(const CKeyID &keyid, CKey &key) const override
std::map< CKeyID, CPubKey > pubkeys
void ImplicitlyLearnRelatedKeyScripts(const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
virtual bool GetKey(const CKeyID &address, CKey &key) const
virtual bool GetKey(const CKeyID &address, CKey &keyOut) const override
bool GetCScript(const CScriptID &scriptid, CScript &script) const override
bool GetKey(const CKeyID &keyid, CKey &key) const override
An interface to be implemented by keystores that support signing.
Serialized script, used inside transaction inputs and outputs.
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
A reference to a CKey: the Hash160 of its serialized public key.
virtual bool HaveCScript(const CScriptID &hash) const override
A reference to a CScript: the Hash160 of its serialization (see script.h)
virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey)
An encapsulated private key.
bool LookupHelper(const M &map, const K &key, V &value)
bool GetPubKey(const CKeyID &keyid, CPubKey &pubkey) const override
bool error(const char *fmt, const Args &... args)
CKeyID ToKeyID(const PKHash &key_hash)
bool IsCompressed() const
Check whether this is a compressed public key.
virtual bool HaveKey(const CKeyID &address) const override