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);
75 CKeyID key_id = pubkey.GetID();
87 if (pubkey.IsCompressed()) {
91 mapScripts[id] = std::move(script);
98 if (!
GetKey(address, key)) {
101 vchPubKeyOut = key.GetPubKey();
108 mapKeys[pubkey.GetID()] = key;
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 = boost::get<PKHash>(&dest)) {
185 if (
auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) {
188 if (
auto script_hash = boost::get<ScriptHash>(&dest)) {
193 if (
auto inner_witness_id = boost::get<WitnessV0KeyHash>(&inner_dest)) {
194 return ToKeyID(*inner_witness_id);
virtual bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
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
RecursiveMutex cs_KeyStore
std::map< CKeyID, CKey > keys
FlatSigningProvider Merge(const FlatSigningProvider &a, const FlatSigningProvider &b)
virtual bool AddCScript(const CScript &redeemScript)
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).
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
bool GetCScript(const CScriptID &scriptid, CScript &script) const override
virtual std::set< CKeyID > GetKeys() const
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
bool error(const char *fmt, const Args &...args)
virtual bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const
std::map< CScriptID, CScript > scripts
bool GetPubKey(const CKeyID &keyid, CPubKey &pubkey) const override
const SigningProvider & DUMMY_SIGNING_PROVIDER
AssertLockHeld(mempool.cs)
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 GetKey(const CKeyID &address, CKey &keyOut) const override
virtual std::set< CScriptID > GetCScripts() const
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
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
A reference to a CKey: the Hash160 of its serialized public key.
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
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)
virtual bool GetKey(const CKeyID &address, CKey &key) const
An encapsulated private key.
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool LookupHelper(const M &map, const K &key, V &value)
bool GetPubKey(const CKeyID &keyid, CPubKey &pubkey) const override
CKeyID ToKeyID(const PKHash &key_hash)
virtual bool HaveKey(const CKeyID &address) const override