Rename *ViewingKey* -> *SproutViewingKey*

This commit is contained in:
Jack Grigg
2018-08-03 02:16:42 +01:00
parent 74f5b010df
commit 4c77517772
10 changed files with 78 additions and 73 deletions

View File

@@ -117,8 +117,8 @@ TEST(keystore_tests, StoreAndRetrieveViewingKey) {
auto addr = sk.address(); auto addr = sk.address();
// Sanity-check: we can't get a viewing key we haven't added // Sanity-check: we can't get a viewing key we haven't added
EXPECT_FALSE(keyStore.HaveViewingKey(addr)); EXPECT_FALSE(keyStore.HaveSproutViewingKey(addr));
EXPECT_FALSE(keyStore.GetViewingKey(addr, vkOut)); EXPECT_FALSE(keyStore.GetSproutViewingKey(addr, vkOut));
// and we shouldn't have a spending key or decryptor either // and we shouldn't have a spending key or decryptor either
EXPECT_FALSE(keyStore.HaveSpendingKey(addr)); EXPECT_FALSE(keyStore.HaveSpendingKey(addr));
@@ -130,9 +130,9 @@ TEST(keystore_tests, StoreAndRetrieveViewingKey) {
keyStore.GetPaymentAddresses(addresses); keyStore.GetPaymentAddresses(addresses);
EXPECT_FALSE(addresses.count(addr)); EXPECT_FALSE(addresses.count(addr));
keyStore.AddViewingKey(vk); keyStore.AddSproutViewingKey(vk);
EXPECT_TRUE(keyStore.HaveViewingKey(addr)); EXPECT_TRUE(keyStore.HaveSproutViewingKey(addr));
EXPECT_TRUE(keyStore.GetViewingKey(addr, vkOut)); EXPECT_TRUE(keyStore.GetSproutViewingKey(addr, vkOut));
EXPECT_EQ(vk, vkOut); EXPECT_EQ(vk, vkOut);
// We should still not have the spending key... // We should still not have the spending key...
@@ -148,9 +148,9 @@ TEST(keystore_tests, StoreAndRetrieveViewingKey) {
keyStore.GetPaymentAddresses(addresses); keyStore.GetPaymentAddresses(addresses);
EXPECT_TRUE(addresses.count(addr)); EXPECT_TRUE(addresses.count(addr));
keyStore.RemoveViewingKey(vk); keyStore.RemoveSproutViewingKey(vk);
EXPECT_FALSE(keyStore.HaveViewingKey(addr)); EXPECT_FALSE(keyStore.HaveSproutViewingKey(addr));
EXPECT_FALSE(keyStore.GetViewingKey(addr, vkOut)); EXPECT_FALSE(keyStore.GetSproutViewingKey(addr, vkOut));
EXPECT_FALSE(keyStore.HaveSpendingKey(addr)); EXPECT_FALSE(keyStore.HaveSpendingKey(addr));
EXPECT_FALSE(keyStore.GetSpendingKey(addr, skOut)); EXPECT_FALSE(keyStore.GetSpendingKey(addr, skOut));
addresses.clear(); addresses.clear();

View File

@@ -111,11 +111,11 @@ bool CBasicKeyStore::AddSaplingSpendingKey(
return true; return true;
} }
bool CBasicKeyStore::AddViewingKey(const libzcash::SproutViewingKey &vk) bool CBasicKeyStore::AddSproutViewingKey(const libzcash::SproutViewingKey &vk)
{ {
LOCK(cs_SpendingKeyStore); LOCK(cs_SpendingKeyStore);
auto address = vk.address(); auto address = vk.address();
mapViewingKeys[address] = vk; mapSproutViewingKeys[address] = vk;
mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(vk.sk_enc))); mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(vk.sk_enc)));
return true; return true;
} }
@@ -136,17 +136,17 @@ bool CBasicKeyStore::AddSaplingFullViewingKey(
return true; return true;
} }
bool CBasicKeyStore::RemoveViewingKey(const libzcash::SproutViewingKey &vk) bool CBasicKeyStore::RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk)
{ {
LOCK(cs_SpendingKeyStore); LOCK(cs_SpendingKeyStore);
mapViewingKeys.erase(vk.address()); mapSproutViewingKeys.erase(vk.address());
return true; return true;
} }
bool CBasicKeyStore::HaveViewingKey(const libzcash::SproutPaymentAddress &address) const bool CBasicKeyStore::HaveSproutViewingKey(const libzcash::SproutPaymentAddress &address) const
{ {
LOCK(cs_SpendingKeyStore); LOCK(cs_SpendingKeyStore);
return mapViewingKeys.count(address) > 0; return mapSproutViewingKeys.count(address) > 0;
} }
bool CBasicKeyStore::HaveSaplingFullViewingKey(const libzcash::SaplingIncomingViewingKey &ivk) const bool CBasicKeyStore::HaveSaplingFullViewingKey(const libzcash::SaplingIncomingViewingKey &ivk) const
@@ -161,12 +161,13 @@ bool CBasicKeyStore::HaveSaplingIncomingViewingKey(const libzcash::SaplingPaymen
return mapSaplingIncomingViewingKeys.count(addr) > 0; return mapSaplingIncomingViewingKeys.count(addr) > 0;
} }
bool CBasicKeyStore::GetViewingKey(const libzcash::SproutPaymentAddress &address, bool CBasicKeyStore::GetSproutViewingKey(
libzcash::SproutViewingKey &vkOut) const const libzcash::SproutPaymentAddress &address,
libzcash::SproutViewingKey &vkOut) const
{ {
LOCK(cs_SpendingKeyStore); LOCK(cs_SpendingKeyStore);
ViewingKeyMap::const_iterator mi = mapViewingKeys.find(address); SproutViewingKeyMap::const_iterator mi = mapSproutViewingKeys.find(address);
if (mi != mapViewingKeys.end()) { if (mi != mapSproutViewingKeys.end()) {
vkOut = mi->second; vkOut = mi->second;
return true; return true;
} }

View File

@@ -81,18 +81,20 @@ public:
libzcash::SaplingIncomingViewingKey& ivkOut) const =0; libzcash::SaplingIncomingViewingKey& ivkOut) const =0;
virtual void GetSaplingPaymentAddresses(std::set<libzcash::SaplingPaymentAddress> &setAddress) const =0; virtual void GetSaplingPaymentAddresses(std::set<libzcash::SaplingPaymentAddress> &setAddress) const =0;
//! Support for viewing keys //! Support for Sprout viewing keys
virtual bool AddViewingKey(const libzcash::SproutViewingKey &vk) =0; virtual bool AddSproutViewingKey(const libzcash::SproutViewingKey &vk) =0;
virtual bool RemoveViewingKey(const libzcash::SproutViewingKey &vk) =0; virtual bool RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk) =0;
virtual bool HaveViewingKey(const libzcash::SproutPaymentAddress &address) const =0; virtual bool HaveSproutViewingKey(const libzcash::SproutPaymentAddress &address) const =0;
virtual bool GetViewingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutViewingKey& vkOut) const =0; virtual bool GetSproutViewingKey(
const libzcash::SproutPaymentAddress &address,
libzcash::SproutViewingKey& vkOut) const =0;
}; };
typedef std::map<CKeyID, CKey> KeyMap; typedef std::map<CKeyID, CKey> KeyMap;
typedef std::map<CScriptID, CScript > ScriptMap; typedef std::map<CScriptID, CScript > ScriptMap;
typedef std::set<CScript> WatchOnlySet; typedef std::set<CScript> WatchOnlySet;
typedef std::map<libzcash::SproutPaymentAddress, libzcash::SproutSpendingKey> SproutSpendingKeyMap; typedef std::map<libzcash::SproutPaymentAddress, libzcash::SproutSpendingKey> SproutSpendingKeyMap;
typedef std::map<libzcash::SproutPaymentAddress, libzcash::SproutViewingKey> ViewingKeyMap; typedef std::map<libzcash::SproutPaymentAddress, libzcash::SproutViewingKey> SproutViewingKeyMap;
typedef std::map<libzcash::SproutPaymentAddress, ZCNoteDecryption> NoteDecryptorMap; typedef std::map<libzcash::SproutPaymentAddress, ZCNoteDecryption> NoteDecryptorMap;
// Full viewing key has equivalent functionality to a transparent address // Full viewing key has equivalent functionality to a transparent address
@@ -111,9 +113,9 @@ protected:
ScriptMap mapScripts; ScriptMap mapScripts;
WatchOnlySet setWatchOnly; WatchOnlySet setWatchOnly;
SproutSpendingKeyMap mapSproutSpendingKeys; SproutSpendingKeyMap mapSproutSpendingKeys;
ViewingKeyMap mapViewingKeys; SproutViewingKeyMap mapSproutViewingKeys;
NoteDecryptorMap mapNoteDecryptors; NoteDecryptorMap mapNoteDecryptors;
SaplingSpendingKeyMap mapSaplingSpendingKeys; SaplingSpendingKeyMap mapSaplingSpendingKeys;
SaplingFullViewingKeyMap mapSaplingFullViewingKeys; SaplingFullViewingKeyMap mapSaplingFullViewingKeys;
SaplingIncomingViewingKeyMap mapSaplingIncomingViewingKeys; SaplingIncomingViewingKeyMap mapSaplingIncomingViewingKeys;
@@ -211,8 +213,8 @@ public:
setAddress.insert((*mi).first); setAddress.insert((*mi).first);
mi++; mi++;
} }
ViewingKeyMap::const_iterator mvi = mapViewingKeys.begin(); SproutViewingKeyMap::const_iterator mvi = mapSproutViewingKeys.begin();
while (mvi != mapViewingKeys.end()) while (mvi != mapSproutViewingKeys.end())
{ {
setAddress.insert((*mvi).first); setAddress.insert((*mvi).first);
mvi++; mvi++;
@@ -274,10 +276,12 @@ public:
} }
} }
virtual bool AddViewingKey(const libzcash::SproutViewingKey &vk); virtual bool AddSproutViewingKey(const libzcash::SproutViewingKey &vk);
virtual bool RemoveViewingKey(const libzcash::SproutViewingKey &vk); virtual bool RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk);
virtual bool HaveViewingKey(const libzcash::SproutPaymentAddress &address) const; virtual bool HaveSproutViewingKey(const libzcash::SproutPaymentAddress &address) const;
virtual bool GetViewingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutViewingKey& vkOut) const; virtual bool GetSproutViewingKey(
const libzcash::SproutPaymentAddress &address,
libzcash::SproutViewingKey& vkOut) const;
}; };
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial; typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;

View File

@@ -111,9 +111,9 @@ TEST(wallet_zkeys_tests, store_and_load_zkeys) {
/** /**
* This test covers methods on CWallet * This test covers methods on CWallet
* AddViewingKey() * AddSproutViewingKey()
* RemoveViewingKey() * RemoveSproutViewingKey()
* LoadViewingKey() * LoadSproutViewingKey()
*/ */
TEST(wallet_zkeys_tests, StoreAndLoadViewingKeys) { TEST(wallet_zkeys_tests, StoreAndLoadViewingKeys) {
SelectParams(CBaseChainParams::MAIN); SelectParams(CBaseChainParams::MAIN);
@@ -128,32 +128,32 @@ TEST(wallet_zkeys_tests, StoreAndLoadViewingKeys) {
// manually add new viewing key to wallet // manually add new viewing key to wallet
auto sk = libzcash::SproutSpendingKey::random(); auto sk = libzcash::SproutSpendingKey::random();
auto vk = sk.viewing_key(); auto vk = sk.viewing_key();
ASSERT_TRUE(wallet.AddViewingKey(vk)); ASSERT_TRUE(wallet.AddSproutViewingKey(vk));
// verify wallet did add it // verify wallet did add it
auto addr = sk.address(); auto addr = sk.address();
ASSERT_TRUE(wallet.HaveViewingKey(addr)); ASSERT_TRUE(wallet.HaveSproutViewingKey(addr));
// and that we don't have the corresponding spending key // and that we don't have the corresponding spending key
ASSERT_FALSE(wallet.HaveSpendingKey(addr)); ASSERT_FALSE(wallet.HaveSpendingKey(addr));
// verify viewing key stored correctly // verify viewing key stored correctly
libzcash::SproutViewingKey vkOut; libzcash::SproutViewingKey vkOut;
wallet.GetViewingKey(addr, vkOut); wallet.GetSproutViewingKey(addr, vkOut);
ASSERT_EQ(vk, vkOut); ASSERT_EQ(vk, vkOut);
// Load a second viewing key into the wallet // Load a second viewing key into the wallet
auto sk2 = libzcash::SproutSpendingKey::random(); auto sk2 = libzcash::SproutSpendingKey::random();
ASSERT_TRUE(wallet.LoadViewingKey(sk2.viewing_key())); ASSERT_TRUE(wallet.LoadSproutViewingKey(sk2.viewing_key()));
// verify wallet did add it // verify wallet did add it
auto addr2 = sk2.address(); auto addr2 = sk2.address();
ASSERT_TRUE(wallet.HaveViewingKey(addr2)); ASSERT_TRUE(wallet.HaveSproutViewingKey(addr2));
ASSERT_FALSE(wallet.HaveSpendingKey(addr2)); ASSERT_FALSE(wallet.HaveSpendingKey(addr2));
// Remove the first viewing key // Remove the first viewing key
ASSERT_TRUE(wallet.RemoveViewingKey(vk)); ASSERT_TRUE(wallet.RemoveSproutViewingKey(vk));
ASSERT_FALSE(wallet.HaveViewingKey(addr)); ASSERT_FALSE(wallet.HaveSproutViewingKey(addr));
ASSERT_TRUE(wallet.HaveViewingKey(addr2)); ASSERT_TRUE(wallet.HaveSproutViewingKey(addr2));
} }
/** /**
@@ -230,7 +230,7 @@ TEST(wallet_zkeys_tests, write_zkey_direct_to_db) {
/** /**
* This test covers methods on CWalletDB * This test covers methods on CWalletDB
* WriteViewingKey() * WriteSproutViewingKey()
*/ */
TEST(wallet_zkeys_tests, WriteViewingKeyDirectToDB) { TEST(wallet_zkeys_tests, WriteViewingKeyDirectToDB) {
SelectParams(CBaseChainParams::TESTNET); SelectParams(CBaseChainParams::TESTNET);
@@ -255,20 +255,20 @@ TEST(wallet_zkeys_tests, WriteViewingKeyDirectToDB) {
int64_t now = GetTime(); int64_t now = GetTime();
CKeyMetadata meta(now); CKeyMetadata meta(now);
CWalletDB db("wallet-vkey.dat"); CWalletDB db("wallet-vkey.dat");
db.WriteViewingKey(vk); db.WriteSproutViewingKey(vk);
// wallet should not be aware of viewing key // wallet should not be aware of viewing key
ASSERT_FALSE(wallet.HaveViewingKey(addr)); ASSERT_FALSE(wallet.HaveSproutViewingKey(addr));
// load the wallet again // load the wallet again
ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun)); ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun));
// wallet can now see the viewing key // wallet can now see the viewing key
ASSERT_TRUE(wallet.HaveViewingKey(addr)); ASSERT_TRUE(wallet.HaveSproutViewingKey(addr));
// check key is the same // check key is the same
libzcash::SproutViewingKey vkOut; libzcash::SproutViewingKey vkOut;
wallet.GetViewingKey(addr, vkOut); wallet.GetSproutViewingKey(addr, vkOut);
ASSERT_EQ(vk, vkOut); ASSERT_EQ(vk, vkOut);
} }

View File

@@ -763,14 +763,14 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
} }
// Don't throw error in case a viewing key is already there // Don't throw error in case a viewing key is already there
if (pwalletMain->HaveViewingKey(addr)) { if (pwalletMain->HaveSproutViewingKey(addr)) {
if (fIgnoreExistingKey) { if (fIgnoreExistingKey) {
return NullUniValue; return NullUniValue;
} }
} else { } else {
pwalletMain->MarkDirty(); pwalletMain->MarkDirty();
if (!pwalletMain->AddViewingKey(vkey)) { if (!pwalletMain->AddSproutViewingKey(vkey)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding viewing key to wallet"); throw JSONRPCError(RPC_WALLET_ERROR, "Error adding viewing key to wallet");
} }
} }
@@ -889,7 +889,7 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
auto addr = boost::get<libzcash::SproutPaymentAddress>(address); auto addr = boost::get<libzcash::SproutPaymentAddress>(address);
libzcash::SproutViewingKey vk; libzcash::SproutViewingKey vk;
if (!pwalletMain->GetViewingKey(addr, vk)) { if (!pwalletMain->GetSproutViewingKey(addr, vk)) {
libzcash::SproutSpendingKey k; libzcash::SproutSpendingKey k;
if (!pwalletMain->GetSpendingKey(addr, k)) { if (!pwalletMain->GetSpendingKey(addr, k)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet does not hold private key or viewing key for this zaddr"); throw JSONRPCError(RPC_WALLET_ERROR, "Wallet does not hold private key or viewing key for this zaddr");

View File

@@ -3296,7 +3296,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
assert(boost::get<libzcash::SproutPaymentAddress>(&zaddr) != nullptr); assert(boost::get<libzcash::SproutPaymentAddress>(&zaddr) != nullptr);
auto sproutzaddr = boost::get<libzcash::SproutPaymentAddress>(zaddr); auto sproutzaddr = boost::get<libzcash::SproutPaymentAddress>(zaddr);
if (!(pwalletMain->HaveSpendingKey(sproutzaddr) || pwalletMain->HaveViewingKey(sproutzaddr))) { if (!(pwalletMain->HaveSpendingKey(sproutzaddr) || pwalletMain->HaveSproutViewingKey(sproutzaddr))) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key or viewing key not found."); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key or viewing key not found.");
} }
@@ -3368,7 +3368,7 @@ UniValue z_getbalance(const UniValue& params, bool fHelp)
// TODO: Add Sapling support. For now, ensure we can freely convert. // TODO: Add Sapling support. For now, ensure we can freely convert.
assert(boost::get<libzcash::SproutPaymentAddress>(&res) != nullptr); assert(boost::get<libzcash::SproutPaymentAddress>(&res) != nullptr);
auto zaddr = boost::get<libzcash::SproutPaymentAddress>(res); auto zaddr = boost::get<libzcash::SproutPaymentAddress>(res);
if (!(pwalletMain->HaveSpendingKey(zaddr) || pwalletMain->HaveViewingKey(zaddr))) { if (!(pwalletMain->HaveSpendingKey(zaddr) || pwalletMain->HaveSproutViewingKey(zaddr))) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key or viewing key not found."); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key or viewing key not found.");
} }
} }

View File

@@ -156,8 +156,8 @@ bool CWallet::AddZKey(const libzcash::SproutSpendingKey &key)
return false; return false;
// check if we need to remove from viewing keys // check if we need to remove from viewing keys
if (HaveViewingKey(addr)) if (HaveSproutViewingKey(addr))
RemoveViewingKey(key.viewing_key()); RemoveSproutViewingKey(key.viewing_key());
if (!fFileBacked) if (!fFileBacked)
return true; return true;
@@ -312,26 +312,26 @@ bool CWallet::LoadZKey(const libzcash::SproutSpendingKey &key)
return CCryptoKeyStore::AddSpendingKey(key); return CCryptoKeyStore::AddSpendingKey(key);
} }
bool CWallet::AddViewingKey(const libzcash::SproutViewingKey &vk) bool CWallet::AddSproutViewingKey(const libzcash::SproutViewingKey &vk)
{ {
if (!CCryptoKeyStore::AddViewingKey(vk)) { if (!CCryptoKeyStore::AddSproutViewingKey(vk)) {
return false; return false;
} }
nTimeFirstKey = 1; // No birthday information for viewing keys. nTimeFirstKey = 1; // No birthday information for viewing keys.
if (!fFileBacked) { if (!fFileBacked) {
return true; return true;
} }
return CWalletDB(strWalletFile).WriteViewingKey(vk); return CWalletDB(strWalletFile).WriteSproutViewingKey(vk);
} }
bool CWallet::RemoveViewingKey(const libzcash::SproutViewingKey &vk) bool CWallet::RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk)
{ {
AssertLockHeld(cs_wallet); AssertLockHeld(cs_wallet);
if (!CCryptoKeyStore::RemoveViewingKey(vk)) { if (!CCryptoKeyStore::RemoveSproutViewingKey(vk)) {
return false; return false;
} }
if (fFileBacked) { if (fFileBacked) {
if (!CWalletDB(strWalletFile).EraseViewingKey(vk)) { if (!CWalletDB(strWalletFile).EraseSproutViewingKey(vk)) {
return false; return false;
} }
} }
@@ -339,9 +339,9 @@ bool CWallet::RemoveViewingKey(const libzcash::SproutViewingKey &vk)
return true; return true;
} }
bool CWallet::LoadViewingKey(const libzcash::SproutViewingKey &vk) bool CWallet::LoadSproutViewingKey(const libzcash::SproutViewingKey &vk)
{ {
return CCryptoKeyStore::AddViewingKey(vk); return CCryptoKeyStore::AddSproutViewingKey(vk);
} }
bool CWallet::AddCScript(const CScript& redeemScript) bool CWallet::AddCScript(const CScript& redeemScript)

View File

@@ -994,11 +994,11 @@ public:
//! Adds an encrypted spending key to the store, and saves it to disk (virtual method, declared in crypter.h) //! Adds an encrypted spending key to the store, and saves it to disk (virtual method, declared in crypter.h)
bool AddCryptedSpendingKey(const libzcash::SproutPaymentAddress &address, const libzcash::ReceivingKey &rk, const std::vector<unsigned char> &vchCryptedSecret); bool AddCryptedSpendingKey(const libzcash::SproutPaymentAddress &address, const libzcash::ReceivingKey &rk, const std::vector<unsigned char> &vchCryptedSecret);
//! Adds a viewing key to the store, and saves it to disk. //! Adds a Sprout viewing key to the store, and saves it to disk.
bool AddViewingKey(const libzcash::SproutViewingKey &vk); bool AddSproutViewingKey(const libzcash::SproutViewingKey &vk);
bool RemoveViewingKey(const libzcash::SproutViewingKey &vk); bool RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk);
//! Adds a viewing key to the store, without saving it to disk (used by LoadWallet) //! Adds a Sprout viewing key to the store, without saving it to disk (used by LoadWallet)
bool LoadViewingKey(const libzcash::SproutViewingKey &dest); bool LoadSproutViewingKey(const libzcash::SproutViewingKey &dest);
/** /**
* Sapling ZKeys * Sapling ZKeys

View File

@@ -142,13 +142,13 @@ bool CWalletDB::WriteZKey(const libzcash::SproutPaymentAddress& addr, const libz
return Write(std::make_pair(std::string("zkey"), addr), key, false); return Write(std::make_pair(std::string("zkey"), addr), key, false);
} }
bool CWalletDB::WriteViewingKey(const libzcash::SproutViewingKey &vk) bool CWalletDB::WriteSproutViewingKey(const libzcash::SproutViewingKey &vk)
{ {
nWalletDBUpdated++; nWalletDBUpdated++;
return Write(std::make_pair(std::string("vkey"), vk), '1'); return Write(std::make_pair(std::string("vkey"), vk), '1');
} }
bool CWalletDB::EraseViewingKey(const libzcash::SproutViewingKey &vk) bool CWalletDB::EraseSproutViewingKey(const libzcash::SproutViewingKey &vk)
{ {
nWalletDBUpdated++; nWalletDBUpdated++;
return Erase(std::make_pair(std::string("vkey"), vk)); return Erase(std::make_pair(std::string("vkey"), vk));
@@ -490,7 +490,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
char fYes; char fYes;
ssValue >> fYes; ssValue >> fYes;
if (fYes == '1') if (fYes == '1')
pwallet->LoadViewingKey(vk); pwallet->LoadSproutViewingKey(vk);
// Viewing keys have no birthday information for now, // Viewing keys have no birthday information for now,
// so set the wallet birthday to the beginning of time. // so set the wallet birthday to the beginning of time.

View File

@@ -139,8 +139,8 @@ public:
const std::vector<unsigned char>& vchCryptedSecret, const std::vector<unsigned char>& vchCryptedSecret,
const CKeyMetadata &keyMeta); const CKeyMetadata &keyMeta);
bool WriteViewingKey(const libzcash::SproutViewingKey &vk); bool WriteSproutViewingKey(const libzcash::SproutViewingKey &vk);
bool EraseViewingKey(const libzcash::SproutViewingKey &vk); bool EraseSproutViewingKey(const libzcash::SproutViewingKey &vk);
private: private:
CWalletDB(const CWalletDB&); CWalletDB(const CWalletDB&);