14 #include <boost/test/unit_test.hpp>
37 std::set<libzcash::SaplingPaymentAddress> addrs;
61 auto sk = m.Derive(0);
65 auto extfvk = sk.ToXFVK();
82 diversifier.
begin()[0] = 10;
83 auto dpa = sk.ToXFVK().Address(diversifier).get().second;
90 while (dpa == defaultAddr && diversifier.
begin()[0] < 255) {
91 diversifier.
begin()[0] += 1;
92 dpa = sk.ToXFVK().Address(diversifier).get().second;
97 auto ivk = extfvk.fvk.in_viewing_key();
105 auto sk2 = m.Derive(1);
109 auto ivk2 = sk2.expsk.full_viewing_key().in_viewing_key();
119 diversifier.
begin()[0] = 10;
120 auto dpa2 = sk2.ToXFVK().Address(diversifier).get().second;
121 while (dpa2 == defaultAddr2 && diversifier.
begin()[0] < 255) {
122 diversifier.
begin()[0] += 1;
123 dpa2 = sk2.ToXFVK().Address(diversifier).get().second;
135 fs::path path = fs::absolute(
"testWallet1",
GetWalletDir());
136 path.make_preferred();
137 std::unique_ptr<CWallet> testWallet = std::make_unique<CWallet>(
"testWallet1",
WalletDatabase::Create(path));
141 assert(testWallet->SetupSPKM(
true));
144 std::set<libzcash::SaplingPaymentAddress> addrs;
145 testWallet->GetSaplingPaymentAddresses(addrs);
149 auto address = testWallet->GenerateNewSaplingZKey();
152 testWallet->GetSaplingPaymentAddresses(addrs);
157 strWalletPass.reserve(100);
158 strWalletPass =
"hello";
159 BOOST_CHECK(testWallet->EncryptWallet(strWalletPass));
165 testWallet->Unlock(strWalletPass);
169 testWallet->Flush(
true);
174 std::unique_ptr<CWallet> wallet2 = std::make_unique<CWallet>(
"testWallet1",
WalletDatabase::Create(path));
181 wallet2->GetSaplingPaymentAddresses(addrs);
190 BOOST_CHECK(!wallet2->GetSaplingExtendedSpendingKey(address, keyOut));
193 wallet2->Unlock(strWalletPass);
195 BOOST_CHECK(wallet2->GetSaplingExtendedSpendingKey(address, keyOut));
198 BOOST_CHECK(wallet2->GetSaplingExtendedSpendingKey(address2, keyOut));
202 wallet2->Flush(
true);
static std::unique_ptr< BerkeleyDatabase > CreateDummy()
Return object for accessing dummy database with no read/write capabilities.
static std::unique_ptr< BerkeleyDatabase > Create(const fs::path &path)
Return object for accessing database at specified path.
virtual bool HaveSaplingIncomingViewingKey(const libzcash::SaplingPaymentAddress &addr) const
void GetSaplingPaymentAddresses(std::set< libzcash::SaplingPaymentAddress > &setAddress) const
bool HaveSaplingSpendingKey(const libzcash::SaplingExtendedFullViewingKey &extfvk) const override
bool GetSaplingSpendingKey(const libzcash::SaplingExtendedFullViewingKey &extfvk, libzcash::SaplingExtendedSpendingKey &skOut) const override
An encapsulated private key.
CPrivKey GetPrivKey() const
Convert the private key to a CPrivKey (serialized secp256k1 private key data).
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
bool LoadSaplingZKeyMetadata(const libzcash::SaplingIncomingViewingKey &ivk, const CKeyMetadata &meta)
Load spending key metadata (used by LoadWallet)
bool AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &key)
Adds Sapling spending key to the store, and saves it to disk.
bool LoadSaplingZKey(const libzcash::SaplingExtendedSpendingKey &key)
Adds spending key to the store, without saving it to disk (used by LoadWallet)
SaplingScriptPubKeyMan * GetSaplingScriptPubKeyMan() const
libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(std::string label="")
Generates new Sapling key.
bool LoadSaplingPaymentAddress(const libzcash::SaplingPaymentAddress &addr, const libzcash::SaplingIncomingViewingKey &ivk)
Adds a Sapling payment address -> incoming viewing key map entry, without saving it to disk (used by ...
bool AddSaplingIncomingViewingKeyW(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingPaymentAddress &addr)
std::map< libzcash::SaplingIncomingViewingKey, CKeyMetadata > mapSaplingZKeyMetadata
void SetHDSeed(const CPubKey &key, bool force=false, bool memonly=false)
BOOST_AUTO_TEST_SUITE(cuckoocache_tests)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Adds a key to the store, and saves it to disk.
#define BOOST_CHECK_THROW(stmt, excMatch)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
libzcash::SaplingPaymentAddress DefaultAddress() const
static SaplingExtendedSpendingKey Master(const HDSeed &seed)
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
BOOST_FIXTURE_TEST_CASE(StoreAndLoadSaplingZkeys, TestingSetup)
This test covers methods on CWallet GenerateNewZKey() AddZKey() LoadZKey() LoadZKeyMetadata()
fs::path GetWalletDir()
Get the path of the wallet directory.