Implement viewing key storage in the wallet
This commit is contained in:
@@ -107,6 +107,10 @@ bool CWallet::AddZKey(const libzcash::SpendingKey &key)
|
||||
if (!CCryptoKeyStore::AddSpendingKey(key))
|
||||
return false;
|
||||
|
||||
// check if we need to remove from viewing keys
|
||||
if (HaveViewingKey(addr))
|
||||
RemoveViewingKey(key.viewing_key());
|
||||
|
||||
if (!fFileBacked)
|
||||
return true;
|
||||
|
||||
@@ -246,6 +250,33 @@ bool CWallet::LoadZKey(const libzcash::SpendingKey &key)
|
||||
return CCryptoKeyStore::AddSpendingKey(key);
|
||||
}
|
||||
|
||||
bool CWallet::AddViewingKey(const libzcash::ViewingKey &vk)
|
||||
{
|
||||
if (!CCryptoKeyStore::AddViewingKey(vk))
|
||||
return false;
|
||||
nTimeFirstKey = 1; // No birthday information for viewing keys.
|
||||
if (!fFileBacked)
|
||||
return true;
|
||||
return CWalletDB(strWalletFile).WriteViewingKey(vk);
|
||||
}
|
||||
|
||||
bool CWallet::RemoveViewingKey(const libzcash::ViewingKey &vk)
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
if (!CCryptoKeyStore::RemoveViewingKey(vk))
|
||||
return false;
|
||||
if (fFileBacked)
|
||||
if (!CWalletDB(strWalletFile).EraseViewingKey(vk))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWallet::LoadViewingKey(const libzcash::ViewingKey &vk)
|
||||
{
|
||||
return CCryptoKeyStore::AddViewingKey(vk);
|
||||
}
|
||||
|
||||
bool CWallet::AddCScript(const CScript& redeemScript)
|
||||
{
|
||||
if (!CCryptoKeyStore::AddCScript(redeemScript))
|
||||
|
||||
Reference in New Issue
Block a user