Rename *SpendingKey -> *SproutSpendingKey
Also GetPaymentAddresses -> GetSproutPaymentAddresses
This commit is contained in:
@@ -166,7 +166,7 @@ TEST(wallet_tests, find_unspent_notes) {
|
||||
SelectParams(CBaseChainParams::TESTNET);
|
||||
CWallet wallet;
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto note = GetNote(sk, wtx, 0, 1);
|
||||
@@ -371,7 +371,7 @@ TEST(wallet_tests, GetNoteNullifier) {
|
||||
hSig, 1);
|
||||
EXPECT_NE(nullifier, ret);
|
||||
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
ret = wallet.GetNoteNullifier(
|
||||
wtx.vjoinsplit[0],
|
||||
@@ -386,7 +386,7 @@ TEST(wallet_tests, FindMyNotes) {
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
auto sk2 = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk2);
|
||||
wallet.AddSproutSpendingKey(sk2);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto note = GetNote(sk, wtx, 0, 1);
|
||||
@@ -395,7 +395,7 @@ TEST(wallet_tests, FindMyNotes) {
|
||||
auto noteMap = wallet.FindMyNotes(wtx);
|
||||
EXPECT_EQ(0, noteMap.size());
|
||||
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
noteMap = wallet.FindMyNotes(wtx);
|
||||
EXPECT_EQ(2, noteMap.size());
|
||||
@@ -412,7 +412,7 @@ TEST(wallet_tests, FindMyNotesInEncryptedWallet) {
|
||||
CKeyingMaterial vMasterKey (r.begin(), r.end());
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
ASSERT_TRUE(wallet.EncryptKeys(vMasterKey));
|
||||
|
||||
@@ -440,7 +440,7 @@ TEST(wallet_tests, get_conflicted_notes) {
|
||||
CWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto note = GetNote(sk, wtx, 0, 1);
|
||||
@@ -471,7 +471,7 @@ TEST(wallet_tests, nullifier_is_spent) {
|
||||
CWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto note = GetNote(sk, wtx, 0, 1);
|
||||
@@ -511,7 +511,7 @@ TEST(wallet_tests, navigate_from_nullifier_to_note) {
|
||||
CWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto note = GetNote(sk, wtx, 0, 1);
|
||||
@@ -537,7 +537,7 @@ TEST(wallet_tests, spent_note_is_from_me) {
|
||||
CWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto note = GetNote(sk, wtx, 0, 1);
|
||||
@@ -565,7 +565,7 @@ TEST(wallet_tests, cached_witnesses_empty_chain) {
|
||||
TestWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true, 4);
|
||||
auto note = GetNote(sk, wtx, 0, 0);
|
||||
@@ -628,7 +628,7 @@ TEST(wallet_tests, cached_witnesses_chain_tip) {
|
||||
SaplingMerkleTree saplingTree;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
{
|
||||
// First block (case tested in _empty_chain)
|
||||
@@ -728,7 +728,7 @@ TEST(wallet_tests, CachedWitnessesDecrementFirst) {
|
||||
SaplingMerkleTree saplingTree;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
{
|
||||
// First block (case tested in _empty_chain)
|
||||
@@ -818,7 +818,7 @@ TEST(wallet_tests, CachedWitnessesCleanIndex) {
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
// Generate a chain
|
||||
size_t numBlocks = WITNESS_CACHE_SIZE + 10;
|
||||
@@ -893,7 +893,7 @@ TEST(wallet_tests, ClearNoteWitnessCache) {
|
||||
TestWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true, 4);
|
||||
auto hash = wtx.GetHash();
|
||||
@@ -953,7 +953,7 @@ TEST(wallet_tests, WriteWitnessCache) {
|
||||
CBlockLocator loc;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
wallet.AddToWallet(wtx, true, NULL);
|
||||
@@ -1030,7 +1030,7 @@ TEST(wallet_tests, UpdateNullifierNoteMap) {
|
||||
CKeyingMaterial vMasterKey (r.begin(), r.end());
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
ASSERT_TRUE(wallet.EncryptKeys(vMasterKey));
|
||||
|
||||
@@ -1063,7 +1063,7 @@ TEST(wallet_tests, UpdatedNoteData) {
|
||||
TestWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto note = GetNote(sk, wtx, 0, 0);
|
||||
@@ -1110,7 +1110,7 @@ TEST(wallet_tests, MarkAffectedTransactionsDirty) {
|
||||
TestWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto hash = wtx.GetHash();
|
||||
@@ -1141,7 +1141,7 @@ TEST(wallet_tests, NoteLocking) {
|
||||
TestWallet wallet;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
auto wtx = GetValidReceive(sk, 10, true);
|
||||
auto wtx2 = GetValidReceive(sk, 10, true);
|
||||
|
||||
@@ -63,18 +63,18 @@ TEST(wallet_zkeys_tests, store_and_load_zkeys) {
|
||||
|
||||
// wallet should be empty
|
||||
std::set<libzcash::SproutPaymentAddress> addrs;
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// wallet should have one key
|
||||
auto address = wallet.GenerateNewZKey();
|
||||
ASSERT_NE(boost::get<libzcash::SproutPaymentAddress>(&address), nullptr);
|
||||
auto addr = boost::get<libzcash::SproutPaymentAddress>(address);
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(1, addrs.size());
|
||||
|
||||
// verify wallet has spending key for the address
|
||||
ASSERT_TRUE(wallet.HaveSpendingKey(addr));
|
||||
ASSERT_TRUE(wallet.HaveSproutSpendingKey(addr));
|
||||
|
||||
// manually add new spending key to wallet
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
@@ -82,15 +82,15 @@ TEST(wallet_zkeys_tests, store_and_load_zkeys) {
|
||||
|
||||
// verify wallet did add it
|
||||
addr = sk.address();
|
||||
ASSERT_TRUE(wallet.HaveSpendingKey(addr));
|
||||
ASSERT_TRUE(wallet.HaveSproutSpendingKey(addr));
|
||||
|
||||
// verify spending key stored correctly
|
||||
libzcash::SproutSpendingKey keyOut;
|
||||
wallet.GetSpendingKey(addr, keyOut);
|
||||
wallet.GetSproutSpendingKey(addr, keyOut);
|
||||
ASSERT_EQ(sk, keyOut);
|
||||
|
||||
// verify there are two keys
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(2, addrs.size());
|
||||
ASSERT_EQ(1, addrs.count(addr));
|
||||
|
||||
@@ -122,7 +122,7 @@ TEST(wallet_zkeys_tests, StoreAndLoadViewingKeys) {
|
||||
|
||||
// wallet should be empty
|
||||
std::set<libzcash::SproutPaymentAddress> addrs;
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// manually add new viewing key to wallet
|
||||
@@ -134,7 +134,7 @@ TEST(wallet_zkeys_tests, StoreAndLoadViewingKeys) {
|
||||
auto addr = sk.address();
|
||||
ASSERT_TRUE(wallet.HaveSproutViewingKey(addr));
|
||||
// and that we don't have the corresponding spending key
|
||||
ASSERT_FALSE(wallet.HaveSpendingKey(addr));
|
||||
ASSERT_FALSE(wallet.HaveSproutSpendingKey(addr));
|
||||
|
||||
// verify viewing key stored correctly
|
||||
libzcash::SproutViewingKey vkOut;
|
||||
@@ -148,7 +148,7 @@ TEST(wallet_zkeys_tests, StoreAndLoadViewingKeys) {
|
||||
// verify wallet did add it
|
||||
auto addr2 = sk2.address();
|
||||
ASSERT_TRUE(wallet.HaveSproutViewingKey(addr2));
|
||||
ASSERT_FALSE(wallet.HaveSpendingKey(addr2));
|
||||
ASSERT_FALSE(wallet.HaveSproutSpendingKey(addr2));
|
||||
|
||||
// Remove the first viewing key
|
||||
ASSERT_TRUE(wallet.RemoveSproutViewingKey(vk));
|
||||
@@ -178,14 +178,14 @@ TEST(wallet_zkeys_tests, write_zkey_direct_to_db) {
|
||||
|
||||
// wallet should be empty
|
||||
std::set<libzcash::SproutPaymentAddress> addrs;
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// Add random key to the wallet
|
||||
auto paymentAddress = wallet.GenerateNewZKey();
|
||||
|
||||
// wallet should have one key
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(1, addrs.size());
|
||||
|
||||
// create random key and add it to database directly, bypassing wallet
|
||||
@@ -197,10 +197,10 @@ TEST(wallet_zkeys_tests, write_zkey_direct_to_db) {
|
||||
db.WriteZKey(addr, sk, meta);
|
||||
|
||||
// wallet should not be aware of key
|
||||
ASSERT_FALSE(wallet.HaveSpendingKey(addr));
|
||||
ASSERT_FALSE(wallet.HaveSproutSpendingKey(addr));
|
||||
|
||||
// wallet sees one key
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(1, addrs.size());
|
||||
|
||||
// wallet should have default metadata for addr with null createtime
|
||||
@@ -212,15 +212,15 @@ TEST(wallet_zkeys_tests, write_zkey_direct_to_db) {
|
||||
ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun));
|
||||
|
||||
// wallet can now see the spending key
|
||||
ASSERT_TRUE(wallet.HaveSpendingKey(addr));
|
||||
ASSERT_TRUE(wallet.HaveSproutSpendingKey(addr));
|
||||
|
||||
// check key is the same
|
||||
libzcash::SproutSpendingKey keyOut;
|
||||
wallet.GetSpendingKey(addr, keyOut);
|
||||
wallet.GetSproutSpendingKey(addr, keyOut);
|
||||
ASSERT_EQ(sk, keyOut);
|
||||
|
||||
// wallet should have two keys
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(2, addrs.size());
|
||||
|
||||
// check metadata is now the same
|
||||
@@ -295,7 +295,7 @@ TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) {
|
||||
|
||||
// wallet should be empty
|
||||
std::set<libzcash::SproutPaymentAddress> addrs;
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// Add random key to the wallet
|
||||
@@ -304,7 +304,7 @@ TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) {
|
||||
auto paymentAddress = boost::get<libzcash::SproutPaymentAddress>(address);
|
||||
|
||||
// wallet should have one key
|
||||
wallet.GetPaymentAddresses(addrs);
|
||||
wallet.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(1, addrs.size());
|
||||
|
||||
// encrypt wallet
|
||||
@@ -330,7 +330,7 @@ TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) {
|
||||
ASSERT_TRUE(&wallet != &wallet2);
|
||||
|
||||
// wallet should have two keys
|
||||
wallet2.GetPaymentAddresses(addrs);
|
||||
wallet2.GetSproutPaymentAddresses(addrs);
|
||||
ASSERT_EQ(2, addrs.size());
|
||||
|
||||
// check we have entries for our payment addresses
|
||||
@@ -339,16 +339,16 @@ TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) {
|
||||
|
||||
// spending key is crypted, so we can't extract valid payment address
|
||||
libzcash::SproutSpendingKey keyOut;
|
||||
wallet2.GetSpendingKey(paymentAddress, keyOut);
|
||||
wallet2.GetSproutSpendingKey(paymentAddress, keyOut);
|
||||
ASSERT_FALSE(paymentAddress == keyOut.address());
|
||||
|
||||
// unlock wallet to get spending keys and verify payment addresses
|
||||
wallet2.Unlock(strWalletPass);
|
||||
|
||||
wallet2.GetSpendingKey(paymentAddress, keyOut);
|
||||
wallet2.GetSproutSpendingKey(paymentAddress, keyOut);
|
||||
ASSERT_EQ(paymentAddress, keyOut.address());
|
||||
|
||||
wallet2.GetSpendingKey(paymentAddress2, keyOut);
|
||||
wallet2.GetSproutSpendingKey(paymentAddress2, keyOut);
|
||||
ASSERT_EQ(paymentAddress2, keyOut.address());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user