aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-04-12 17:04:49 -0400
committerAndrew Chow <achow101-github@achow101.com>2018-05-05 00:43:04 -0400
commitdd3c07acce7ab67f32a79393abf6227009bd440d (patch)
tree758ce969f58e219dc7c813f8b4229cabffd000b6
parentf82e1c94821212cc8962775a7a29599ebd92eee0 (diff)
downloadbitcoin-dd3c07acce7ab67f32a79393abf6227009bd440d.tar.xz
Separate HaveKey function that checks whether a key is in a keystore
-rw-r--r--src/keystore.cpp7
-rw-r--r--src/keystore.h3
2 files changed, 10 insertions, 0 deletions
diff --git a/src/keystore.cpp b/src/keystore.cpp
index e69d518890..ea93ed69fa 100644
--- a/src/keystore.cpp
+++ b/src/keystore.cpp
@@ -195,3 +195,10 @@ CKeyID GetKeyForDestination(const CKeyStore& store, const CTxDestination& dest)
}
return CKeyID();
}
+
+bool HaveKey(const CKeyStore& store, const CKey& key)
+{
+ CKey key2;
+ key2.Set(key.begin(), key.end(), !key.IsCompressed());
+ return store.HaveKey(key.GetPubKey().GetID()) || store.HaveKey(key2.GetPubKey().GetID());
+}
diff --git a/src/keystore.h b/src/keystore.h
index c56e4751de..cd5ded9203 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -80,4 +80,7 @@ typedef std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char> > > Crypt
/** Return the CKeyID of the key involved in a script (if there is a unique one). */
CKeyID GetKeyForDestination(const CKeyStore& store, const CTxDestination& dest);
+/** Checks if a CKey is in the given CKeyStore compressed or otherwise*/
+bool HaveKey(const CKeyStore& store, const CKey& key);
+
#endif // BITCOIN_KEYSTORE_H