eliminate races: hold cs_KeyStore lock while reading fUseCrypto
This commit is contained in:
parent
5a5094bbb5
commit
d9fcc2b558
|
@ -185,24 +185,22 @@ static bool DecryptSaplingSpendingKey(const CKeyingMaterial& vMasterKey,
|
||||||
return sk.expsk.full_viewing_key() == extfvk.fvk;
|
return sk.expsk.full_viewing_key() == extfvk.fvk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cs_KeyStore lock must be held by caller
|
||||||
bool CCryptoKeyStore::SetCrypted()
|
bool CCryptoKeyStore::SetCrypted()
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
|
||||||
if (fUseCrypto)
|
if (fUseCrypto)
|
||||||
return true;
|
return true;
|
||||||
if (!(mapKeys.empty() && mapSproutSpendingKeys.empty() && mapSaplingSpendingKeys.empty()))
|
if (!(mapKeys.empty() && mapSproutSpendingKeys.empty() && mapSaplingSpendingKeys.empty()))
|
||||||
return false;
|
return false;
|
||||||
fUseCrypto = true;
|
return fUseCrypto = true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::Lock()
|
bool CCryptoKeyStore::Lock()
|
||||||
{
|
{
|
||||||
if (!SetCrypted())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
|
if (!SetCrypted())
|
||||||
|
return false;
|
||||||
vMasterKey.clear();
|
vMasterKey.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +289,7 @@ bool CCryptoKeyStore::SetHDSeed(const HDSeed& seed)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted()) {
|
if (!fUseCrypto) {
|
||||||
return CBasicKeyStore::SetHDSeed(seed);
|
return CBasicKeyStore::SetHDSeed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,10 +313,9 @@ bool CCryptoKeyStore::SetHDSeed(const HDSeed& seed)
|
||||||
bool CCryptoKeyStore::SetCryptedHDSeed(
|
bool CCryptoKeyStore::SetCryptedHDSeed(
|
||||||
const uint256& seedFp,
|
const uint256& seedFp,
|
||||||
const std::vector<unsigned char>& vchCryptedSecret)
|
const std::vector<unsigned char>& vchCryptedSecret)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted()) {
|
if (!fUseCrypto) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,14 +326,13 @@ bool CCryptoKeyStore::SetCryptedHDSeed(
|
||||||
}
|
}
|
||||||
|
|
||||||
cryptedHDSeed = std::make_pair(seedFp, vchCryptedSecret);
|
cryptedHDSeed = std::make_pair(seedFp, vchCryptedSecret);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::HaveHDSeed() const
|
bool CCryptoKeyStore::HaveHDSeed() const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::HaveHDSeed();
|
return CBasicKeyStore::HaveHDSeed();
|
||||||
|
|
||||||
return !cryptedHDSeed.second.empty();
|
return !cryptedHDSeed.second.empty();
|
||||||
|
@ -345,7 +341,7 @@ bool CCryptoKeyStore::HaveHDSeed() const
|
||||||
bool CCryptoKeyStore::GetHDSeed(HDSeed& seedOut) const
|
bool CCryptoKeyStore::GetHDSeed(HDSeed& seedOut) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::GetHDSeed(seedOut);
|
return CBasicKeyStore::GetHDSeed(seedOut);
|
||||||
|
|
||||||
if (cryptedHDSeed.second.empty())
|
if (cryptedHDSeed.second.empty())
|
||||||
|
@ -355,10 +351,9 @@ bool CCryptoKeyStore::GetHDSeed(HDSeed& seedOut) const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
|
bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::AddKeyPubKey(key, pubkey);
|
return CBasicKeyStore::AddKeyPubKey(key, pubkey);
|
||||||
|
|
||||||
if (IsLocked())
|
if (IsLocked())
|
||||||
|
@ -369,30 +364,24 @@ bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
|
||||||
if (!EncryptSecret(vMasterKey, vchSecret, pubkey.GetHash(), vchCryptedSecret))
|
if (!EncryptSecret(vMasterKey, vchSecret, pubkey.GetHash(), vchCryptedSecret))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!AddCryptedKey(pubkey, vchCryptedSecret))
|
return AddCryptedKey(pubkey, vchCryptedSecret);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CCryptoKeyStore::AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret)
|
bool CCryptoKeyStore::AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!SetCrypted())
|
if (!SetCrypted())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mapCryptedKeys[vchPubKey.GetID()] = make_pair(vchPubKey, vchCryptedSecret);
|
mapCryptedKeys[vchPubKey.GetID()] = make_pair(vchPubKey, vchCryptedSecret);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
|
bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::GetKey(address, keyOut);
|
return CBasicKeyStore::GetKey(address, keyOut);
|
||||||
|
|
||||||
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
||||||
|
@ -402,15 +391,13 @@ bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
|
||||||
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
|
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
|
||||||
return DecryptKey(vMasterKey, vchCryptedSecret, vchPubKey, keyOut);
|
return DecryptKey(vMasterKey, vchCryptedSecret, vchPubKey, keyOut);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const
|
bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CKeyStore::GetPubKey(address, vchPubKeyOut);
|
return CKeyStore::GetPubKey(address, vchPubKeyOut);
|
||||||
|
|
||||||
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
||||||
|
@ -419,15 +406,13 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co
|
||||||
vchPubKeyOut = (*mi).second.first;
|
vchPubKeyOut = (*mi).second.first;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk)
|
bool CCryptoKeyStore::AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::AddSproutSpendingKey(sk);
|
return CBasicKeyStore::AddSproutSpendingKey(sk);
|
||||||
|
|
||||||
if (IsLocked())
|
if (IsLocked())
|
||||||
|
@ -441,19 +426,15 @@ bool CCryptoKeyStore::AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk
|
||||||
if (!EncryptSecret(vMasterKey, vchSecret, address.GetHash(), vchCryptedSecret))
|
if (!EncryptSecret(vMasterKey, vchSecret, address.GetHash(), vchCryptedSecret))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!AddCryptedSproutSpendingKey(address, sk.receiving_key(), vchCryptedSecret))
|
return AddCryptedSproutSpendingKey(address, sk.receiving_key(), vchCryptedSecret);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::AddSaplingSpendingKey(
|
bool CCryptoKeyStore::AddSaplingSpendingKey(
|
||||||
const libzcash::SaplingExtendedSpendingKey &sk,
|
const libzcash::SaplingExtendedSpendingKey &sk,
|
||||||
const libzcash::SaplingPaymentAddress &defaultAddr)
|
const libzcash::SaplingPaymentAddress &defaultAddr)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted()) {
|
if (!fUseCrypto) {
|
||||||
return CBasicKeyStore::AddSaplingSpendingKey(sk, defaultAddr);
|
return CBasicKeyStore::AddSaplingSpendingKey(sk, defaultAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,18 +451,13 @@ bool CCryptoKeyStore::AddSaplingSpendingKey(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AddCryptedSaplingSpendingKey(extfvk, vchCryptedSecret, defaultAddr)) {
|
return AddCryptedSaplingSpendingKey(extfvk, vchCryptedSecret, defaultAddr);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::AddCryptedSproutSpendingKey(
|
bool CCryptoKeyStore::AddCryptedSproutSpendingKey(
|
||||||
const libzcash::SproutPaymentAddress &address,
|
const libzcash::SproutPaymentAddress &address,
|
||||||
const libzcash::ReceivingKey &rk,
|
const libzcash::ReceivingKey &rk,
|
||||||
const std::vector<unsigned char> &vchCryptedSecret)
|
const std::vector<unsigned char> &vchCryptedSecret)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!SetCrypted())
|
if (!SetCrypted())
|
||||||
|
@ -489,7 +465,6 @@ bool CCryptoKeyStore::AddCryptedSproutSpendingKey(
|
||||||
|
|
||||||
mapCryptedSproutSpendingKeys[address] = vchCryptedSecret;
|
mapCryptedSproutSpendingKeys[address] = vchCryptedSecret;
|
||||||
mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(rk)));
|
mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(rk)));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +472,6 @@ bool CCryptoKeyStore::AddCryptedSaplingSpendingKey(
|
||||||
const libzcash::SaplingExtendedFullViewingKey &extfvk,
|
const libzcash::SaplingExtendedFullViewingKey &extfvk,
|
||||||
const std::vector<unsigned char> &vchCryptedSecret,
|
const std::vector<unsigned char> &vchCryptedSecret,
|
||||||
const libzcash::SaplingPaymentAddress &defaultAddr)
|
const libzcash::SaplingPaymentAddress &defaultAddr)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!SetCrypted()) {
|
if (!SetCrypted()) {
|
||||||
|
@ -510,15 +484,13 @@ bool CCryptoKeyStore::AddCryptedSaplingSpendingKey(
|
||||||
}
|
}
|
||||||
|
|
||||||
mapCryptedSaplingSpendingKeys[extfvk] = vchCryptedSecret;
|
mapCryptedSaplingSpendingKeys[extfvk] = vchCryptedSecret;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey &skOut) const
|
bool CCryptoKeyStore::GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey &skOut) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::GetSproutSpendingKey(address, skOut);
|
return CBasicKeyStore::GetSproutSpendingKey(address, skOut);
|
||||||
|
|
||||||
CryptedSproutSpendingKeyMap::const_iterator mi = mapCryptedSproutSpendingKeys.find(address);
|
CryptedSproutSpendingKeyMap::const_iterator mi = mapCryptedSproutSpendingKeys.find(address);
|
||||||
|
@ -527,15 +499,13 @@ bool CCryptoKeyStore::GetSproutSpendingKey(const libzcash::SproutPaymentAddress
|
||||||
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second;
|
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second;
|
||||||
return DecryptSproutSpendingKey(vMasterKey, vchCryptedSecret, address, skOut);
|
return DecryptSproutSpendingKey(vMasterKey, vchCryptedSecret, address, skOut);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCryptoKeyStore::GetSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk, libzcash::SaplingExtendedSpendingKey &skOut) const
|
bool CCryptoKeyStore::GetSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk, libzcash::SaplingExtendedSpendingKey &skOut) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::GetSaplingSpendingKey(fvk, skOut);
|
return CBasicKeyStore::GetSaplingSpendingKey(fvk, skOut);
|
||||||
|
|
||||||
for (auto entry : mapCryptedSaplingSpendingKeys) {
|
for (auto entry : mapCryptedSaplingSpendingKeys) {
|
||||||
|
@ -544,7 +514,6 @@ bool CCryptoKeyStore::GetSaplingSpendingKey(const libzcash::SaplingFullViewingKe
|
||||||
return DecryptSaplingSpendingKey(vMasterKey, vchCryptedSecret, entry.first, skOut);
|
return DecryptSaplingSpendingKey(vMasterKey, vchCryptedSecret, entry.first, skOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +521,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!mapCryptedKeys.empty() || IsCrypted())
|
if (!mapCryptedKeys.empty() || fUseCrypto)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fUseCrypto = true;
|
fUseCrypto = true;
|
||||||
|
|
|
@ -157,19 +157,14 @@ public:
|
||||||
|
|
||||||
bool IsCrypted() const
|
bool IsCrypted() const
|
||||||
{
|
{
|
||||||
|
LOCK(cs_KeyStore);
|
||||||
return fUseCrypto;
|
return fUseCrypto;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLocked() const
|
bool IsLocked() const
|
||||||
{
|
|
||||||
if (!IsCrypted())
|
|
||||||
return false;
|
|
||||||
bool result;
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
result = vMasterKey.empty();
|
return fUseCrypto && vMasterKey.empty();
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Lock();
|
bool Lock();
|
||||||
|
@ -182,20 +177,18 @@ public:
|
||||||
virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
|
virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
|
||||||
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
|
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
|
||||||
bool HaveKey(const CKeyID &address) const
|
bool HaveKey(const CKeyID &address) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::HaveKey(address);
|
return CBasicKeyStore::HaveKey(address);
|
||||||
return mapCryptedKeys.count(address) > 0;
|
return mapCryptedKeys.count(address) > 0;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool GetKey(const CKeyID &address, CKey& keyOut) const;
|
bool GetKey(const CKeyID &address, CKey& keyOut) const;
|
||||||
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
|
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
|
||||||
void GetKeys(std::set<CKeyID> &setAddress) const
|
void GetKeys(std::set<CKeyID> &setAddress) const
|
||||||
{
|
{
|
||||||
if (!IsCrypted())
|
LOCK(cs_KeyStore);
|
||||||
|
if (!fUseCrypto)
|
||||||
{
|
{
|
||||||
CBasicKeyStore::GetKeys(setAddress);
|
CBasicKeyStore::GetKeys(setAddress);
|
||||||
return;
|
return;
|
||||||
|
@ -214,19 +207,17 @@ public:
|
||||||
const std::vector<unsigned char> &vchCryptedSecret);
|
const std::vector<unsigned char> &vchCryptedSecret);
|
||||||
bool AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk);
|
bool AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk);
|
||||||
bool HaveSproutSpendingKey(const libzcash::SproutPaymentAddress &address) const
|
bool HaveSproutSpendingKey(const libzcash::SproutPaymentAddress &address) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::HaveSproutSpendingKey(address);
|
return CBasicKeyStore::HaveSproutSpendingKey(address);
|
||||||
return mapCryptedSproutSpendingKeys.count(address) > 0;
|
return mapCryptedSproutSpendingKeys.count(address) > 0;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey &skOut) const;
|
bool GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey &skOut) const;
|
||||||
void GetSproutPaymentAddresses(std::set<libzcash::SproutPaymentAddress> &setAddress) const
|
void GetSproutPaymentAddresses(std::set<libzcash::SproutPaymentAddress> &setAddress) const
|
||||||
{
|
{
|
||||||
if (!IsCrypted())
|
LOCK(cs_KeyStore);
|
||||||
|
if (!fUseCrypto)
|
||||||
{
|
{
|
||||||
CBasicKeyStore::GetSproutPaymentAddresses(setAddress);
|
CBasicKeyStore::GetSproutPaymentAddresses(setAddress);
|
||||||
return;
|
return;
|
||||||
|
@ -248,17 +239,15 @@ public:
|
||||||
const libzcash::SaplingExtendedSpendingKey &sk,
|
const libzcash::SaplingExtendedSpendingKey &sk,
|
||||||
const libzcash::SaplingPaymentAddress &defaultAddr);
|
const libzcash::SaplingPaymentAddress &defaultAddr);
|
||||||
bool HaveSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk) const
|
bool HaveSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!fUseCrypto)
|
||||||
return CBasicKeyStore::HaveSaplingSpendingKey(fvk);
|
return CBasicKeyStore::HaveSaplingSpendingKey(fvk);
|
||||||
for (auto entry : mapCryptedSaplingSpendingKeys) {
|
for (auto entry : mapCryptedSaplingSpendingKeys) {
|
||||||
if (entry.first.fvk == fvk) {
|
if (entry.first.fvk == fvk) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool GetSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk, libzcash::SaplingExtendedSpendingKey &skOut) const;
|
bool GetSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk, libzcash::SaplingExtendedSpendingKey &skOut) const;
|
||||||
|
|
Loading…
Reference in New Issue