Add support for spending keys to the encrypted wallet.

This commit is contained in:
Simon
2016-09-21 14:02:35 -07:00
parent 71b2b66e26
commit 73699ceaf6
7 changed files with 209 additions and 6 deletions

View File

@@ -18,6 +18,7 @@
#include "util.h"
#include "utilmoneystr.h"
#include "zcash/Note.hpp"
#include "crypter.h"
#include <assert.h>
@@ -169,6 +170,7 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
const vector<unsigned char> &vchCryptedSecret)
{
if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret))
return false;
if (!fFileBacked)
@@ -187,6 +189,28 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
return false;
}
bool CWallet::AddCryptedSpendingKey(const libzcash::PaymentAddress &address,
const std::vector<unsigned char> &vchCryptedSecret)
{
if (!CCryptoKeyStore::AddCryptedSpendingKey(address, vchCryptedSecret))
return false;
if (!fFileBacked)
return true;
{
LOCK(cs_wallet);
if (pwalletdbEncryption)
return pwalletdbEncryption->WriteCryptedZKey(address,
vchCryptedSecret,
mapZKeyMetadata[address]);
else
return CWalletDB(strWalletFile).WriteCryptedZKey(address,
vchCryptedSecret,
mapZKeyMetadata[address]);
}
return false;
}
bool CWallet::LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &meta)
{
AssertLockHeld(cs_wallet); // mapKeyMetadata
@@ -209,6 +233,11 @@ bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigne
return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret);
}
bool CWallet::LoadCryptedZKey(const libzcash::PaymentAddress &addr, const std::vector<unsigned char> &vchCryptedSecret)
{
return CCryptoKeyStore::AddCryptedSpendingKey(addr, vchCryptedSecret);
}
bool CWallet::LoadZKey(const libzcash::SpendingKey &key)
{
return CCryptoKeyStore::AddSpendingKey(key);