Implement CKeyStore::GetSaplingPaymentAddresses()
This commit is contained in:
parent
6b9c962725
commit
4715b31c76
|
@ -75,6 +75,7 @@ public:
|
|||
virtual bool GetSaplingIncomingViewingKey(
|
||||
const libzcash::SaplingPaymentAddress &addr,
|
||||
libzcash::SaplingIncomingViewingKey& ivkOut) const =0;
|
||||
virtual void GetSaplingPaymentAddresses(std::set<libzcash::SaplingPaymentAddress> &setAddress) const =0;
|
||||
|
||||
//! Support for viewing keys
|
||||
virtual bool AddViewingKey(const libzcash::SproutViewingKey &vk) =0;
|
||||
|
@ -251,6 +252,19 @@ public:
|
|||
virtual bool GetSaplingIncomingViewingKey(
|
||||
const libzcash::SaplingPaymentAddress &addr,
|
||||
libzcash::SaplingIncomingViewingKey& ivkOut) const;
|
||||
void GetSaplingPaymentAddresses(std::set<libzcash::SaplingPaymentAddress> &setAddress) const
|
||||
{
|
||||
setAddress.clear();
|
||||
{
|
||||
LOCK(cs_SpendingKeyStore);
|
||||
auto mi = mapSaplingIncomingViewingKeys.begin();
|
||||
while (mi != mapSaplingIncomingViewingKeys.end())
|
||||
{
|
||||
setAddress.insert((*mi).first);
|
||||
mi++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool AddViewingKey(const libzcash::SproutViewingKey &vk);
|
||||
virtual bool RemoveViewingKey(const libzcash::SproutViewingKey &vk);
|
||||
|
|
|
@ -16,7 +16,15 @@ TEST(wallet_zkeys_tests, store_and_load_sapling_zkeys) {
|
|||
|
||||
CWallet wallet;
|
||||
|
||||
// wallet should be empty
|
||||
std::set<libzcash::SaplingPaymentAddress> addrs;
|
||||
wallet.GetSaplingPaymentAddresses(addrs);
|
||||
ASSERT_EQ(0, addrs.size());
|
||||
|
||||
// wallet should have one key
|
||||
auto address = wallet.GenerateNewSaplingZKey();
|
||||
wallet.GetSaplingPaymentAddresses(addrs);
|
||||
ASSERT_EQ(1, addrs.size());
|
||||
|
||||
// verify wallet has incoming viewing key for the address
|
||||
ASSERT_TRUE(wallet.HaveSaplingIncomingViewingKey(address));
|
||||
|
@ -28,6 +36,16 @@ TEST(wallet_zkeys_tests, store_and_load_sapling_zkeys) {
|
|||
// verify wallet did add it
|
||||
auto fvk = sk.full_viewing_key();
|
||||
ASSERT_TRUE(wallet.HaveSaplingSpendingKey(fvk));
|
||||
|
||||
// verify spending key stored correctly
|
||||
libzcash::SaplingSpendingKey keyOut;
|
||||
wallet.GetSaplingSpendingKey(fvk, keyOut);
|
||||
ASSERT_EQ(sk, keyOut);
|
||||
|
||||
// verify there are two keys
|
||||
wallet.GetSaplingPaymentAddresses(addrs);
|
||||
ASSERT_EQ(2, addrs.size());
|
||||
ASSERT_EQ(1, addrs.count(address));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue