Pass SaplingPaymentAddress to store through the CKeyStore

This commit is contained in:
Jack Grigg
2018-08-02 22:34:31 +01:00
parent bc6344b350
commit 5175a7f07b
9 changed files with 76 additions and 39 deletions

View File

@@ -354,12 +354,14 @@ bool CCryptoKeyStore::AddSpendingKey(const libzcash::SproutSpendingKey &sk)
return true;
}
bool CCryptoKeyStore::AddSaplingSpendingKey(const libzcash::SaplingSpendingKey &sk)
bool CCryptoKeyStore::AddSaplingSpendingKey(
const libzcash::SaplingSpendingKey &sk,
const boost::optional<libzcash::SaplingPaymentAddress> &defaultAddr)
{
{
LOCK(cs_SpendingKeyStore);
if (!IsCrypted()) {
return CBasicKeyStore::AddSaplingSpendingKey(sk);
return CBasicKeyStore::AddSaplingSpendingKey(sk, defaultAddr);
}
if (IsLocked()) {
@@ -375,7 +377,7 @@ bool CCryptoKeyStore::AddSaplingSpendingKey(const libzcash::SaplingSpendingKey &
return false;
}
if (!AddCryptedSaplingSpendingKey(fvk, vchCryptedSecret)) {
if (!AddCryptedSaplingSpendingKey(fvk, vchCryptedSecret, defaultAddr)) {
return false;
}
}
@@ -397,8 +399,10 @@ bool CCryptoKeyStore::AddCryptedSpendingKey(const libzcash::SproutPaymentAddress
return true;
}
bool CCryptoKeyStore::AddCryptedSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk,
const std::vector<unsigned char> &vchCryptedSecret)
bool CCryptoKeyStore::AddCryptedSaplingSpendingKey(
const libzcash::SaplingFullViewingKey &fvk,
const std::vector<unsigned char> &vchCryptedSecret,
const boost::optional<libzcash::SaplingPaymentAddress> &defaultAddr)
{
{
LOCK(cs_SpendingKeyStore);
@@ -406,6 +410,11 @@ bool CCryptoKeyStore::AddCryptedSaplingSpendingKey(const libzcash::SaplingFullVi
return false;
}
// if SaplingFullViewingKey is not in SaplingFullViewingKeyMap, add it
if (!AddSaplingFullViewingKey(fvk, defaultAddr)){
return false;
}
mapCryptedSaplingSpendingKeys[fvk] = vchCryptedSecret;
}
return true;