Rename GenerateNewZKey to include Sprout
This commit is contained in:
@@ -105,7 +105,7 @@ TEST(wallet_zkeys_tests, StoreAndLoadSaplingZkeys) {
|
||||
|
||||
/**
|
||||
* This test covers methods on CWallet
|
||||
* GenerateNewZKey()
|
||||
* GenerateNewSproutZKey()
|
||||
* AddSproutZKey()
|
||||
* LoadZKey()
|
||||
* LoadZKeyMetadata()
|
||||
@@ -121,7 +121,7 @@ TEST(wallet_zkeys_tests, store_and_load_zkeys) {
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// wallet should have one key
|
||||
auto address = wallet.GenerateNewZKey();
|
||||
auto address = wallet.GenerateNewSproutZKey();
|
||||
ASSERT_NE(boost::get<libzcash::SproutPaymentAddress>(&address), nullptr);
|
||||
auto addr = boost::get<libzcash::SproutPaymentAddress>(address);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
@@ -236,7 +236,7 @@ TEST(wallet_zkeys_tests, write_zkey_direct_to_db) {
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// Add random key to the wallet
|
||||
auto paymentAddress = wallet.GenerateNewZKey();
|
||||
auto paymentAddress = wallet.GenerateNewSproutZKey();
|
||||
|
||||
// wallet should have one key
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
@@ -353,7 +353,7 @@ TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) {
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// Add random key to the wallet
|
||||
auto address = wallet.GenerateNewZKey();
|
||||
auto address = wallet.GenerateNewSproutZKey();
|
||||
ASSERT_NE(boost::get<libzcash::SproutPaymentAddress>(&address), nullptr);
|
||||
auto paymentAddress = boost::get<libzcash::SproutPaymentAddress>(address);
|
||||
|
||||
@@ -368,11 +368,11 @@ TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) {
|
||||
ASSERT_TRUE(wallet.EncryptWallet(strWalletPass));
|
||||
|
||||
// adding a new key will fail as the wallet is locked
|
||||
EXPECT_ANY_THROW(wallet.GenerateNewZKey());
|
||||
EXPECT_ANY_THROW(wallet.GenerateNewSproutZKey());
|
||||
|
||||
// unlock wallet and then add
|
||||
wallet.Unlock(strWalletPass);
|
||||
auto address2 = wallet.GenerateNewZKey();
|
||||
auto address2 = wallet.GenerateNewSproutZKey();
|
||||
ASSERT_NE(boost::get<libzcash::SproutPaymentAddress>(&address2), nullptr);
|
||||
auto paymentAddress2 = boost::get<libzcash::SproutPaymentAddress>(address2);
|
||||
|
||||
|
||||
@@ -3166,7 +3166,7 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp)
|
||||
}
|
||||
|
||||
if (addrType == ADDR_TYPE_SPROUT) {
|
||||
return EncodePaymentAddress(pwalletMain->GenerateNewZKey());
|
||||
return EncodePaymentAddress(pwalletMain->GenerateNewSproutZKey());
|
||||
} else if (addrType == ADDR_TYPE_SAPLING) {
|
||||
return EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey());
|
||||
} else {
|
||||
|
||||
@@ -82,7 +82,7 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const
|
||||
}
|
||||
|
||||
// Generate a new spending key and return its public payment address
|
||||
libzcash::PaymentAddress CWallet::GenerateNewZKey()
|
||||
libzcash::PaymentAddress CWallet::GenerateNewSproutZKey()
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // mapSproutZKeyMetadata
|
||||
// TODO: Add Sapling support
|
||||
@@ -91,14 +91,14 @@ libzcash::PaymentAddress CWallet::GenerateNewZKey()
|
||||
|
||||
// Check for collision, even though it is unlikely to ever occur
|
||||
if (CCryptoKeyStore::HaveSproutSpendingKey(addr))
|
||||
throw std::runtime_error("CWallet::GenerateNewZKey(): Collision detected");
|
||||
throw std::runtime_error("CWallet::GenerateNewSproutZKey(): Collision detected");
|
||||
|
||||
// Create new metadata
|
||||
int64_t nCreationTime = GetTime();
|
||||
mapSproutZKeyMetadata[addr] = CKeyMetadata(nCreationTime);
|
||||
|
||||
if (!AddSproutZKey(k))
|
||||
throw std::runtime_error("CWallet::GenerateNewZKey(): AddSproutZKey failed");
|
||||
throw std::runtime_error("CWallet::GenerateNewSproutZKey(): AddSproutZKey failed");
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1045,7 +1045,7 @@ public:
|
||||
* ZKeys
|
||||
*/
|
||||
//! Generates a new zaddr
|
||||
libzcash::PaymentAddress GenerateNewZKey();
|
||||
libzcash::PaymentAddress GenerateNewSproutZKey();
|
||||
//! Adds spending key to the store, and saves it to disk
|
||||
bool AddSproutZKey(const libzcash::SproutSpendingKey &key);
|
||||
//! Adds spending key to the store, without saving it to disk (used by LoadWallet)
|
||||
|
||||
Reference in New Issue
Block a user