desprout
This commit is contained in:
@@ -117,22 +117,7 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const
|
|||||||
// Generate a new spending key and return its public payment address
|
// Generate a new spending key and return its public payment address
|
||||||
libzcash::SproutPaymentAddress CWallet::GenerateNewSproutZKey()
|
libzcash::SproutPaymentAddress CWallet::GenerateNewSproutZKey()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // mapSproutZKeyMetadata
|
throw std::runtime_error("unsupported");
|
||||||
|
|
||||||
auto k = SproutSpendingKey::random();
|
|
||||||
auto addr = k.address();
|
|
||||||
|
|
||||||
// Check for collision, even though it is unlikely to ever occur
|
|
||||||
if (CCryptoKeyStore::HaveSproutSpendingKey(addr))
|
|
||||||
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::GenerateNewSproutZKey(): AddSproutZKey failed");
|
|
||||||
return addr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a new Sapling spending key and return its public payment address
|
// Generate a new Sapling spending key and return its public payment address
|
||||||
@@ -313,24 +298,6 @@ bool CWallet::AddCryptedSproutSpendingKey(
|
|||||||
const libzcash::ReceivingKey &rk,
|
const libzcash::ReceivingKey &rk,
|
||||||
const std::vector<unsigned char> &vchCryptedSecret)
|
const std::vector<unsigned char> &vchCryptedSecret)
|
||||||
{
|
{
|
||||||
if (!CCryptoKeyStore::AddCryptedSproutSpendingKey(address, rk, vchCryptedSecret))
|
|
||||||
return false;
|
|
||||||
if (!fFileBacked)
|
|
||||||
return true;
|
|
||||||
{
|
|
||||||
LOCK(cs_wallet);
|
|
||||||
if (pwalletdbEncryption) {
|
|
||||||
return pwalletdbEncryption->WriteCryptedZKey(address,
|
|
||||||
rk,
|
|
||||||
vchCryptedSecret,
|
|
||||||
mapSproutZKeyMetadata[address]);
|
|
||||||
} else {
|
|
||||||
return CWalletDB(strWalletFile).WriteCryptedZKey(address,
|
|
||||||
rk,
|
|
||||||
vchCryptedSecret,
|
|
||||||
mapSproutZKeyMetadata[address]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,47 +382,6 @@ bool CWallet::LoadZKey(const libzcash::SproutSpendingKey &key)
|
|||||||
return CCryptoKeyStore::AddSproutSpendingKey(key);
|
return CCryptoKeyStore::AddSproutSpendingKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::AddSproutViewingKey(const libzcash::SproutViewingKey &vk)
|
|
||||||
{
|
|
||||||
if (!CCryptoKeyStore::AddSproutViewingKey(vk)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
nTimeFirstKey = 1; // No birthday information for viewing keys.
|
|
||||||
if (!fFileBacked) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return CWalletDB(strWalletFile).WriteSproutViewingKey(vk);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CWallet::RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk)
|
|
||||||
{
|
|
||||||
AssertLockHeld(cs_wallet);
|
|
||||||
if (!CCryptoKeyStore::RemoveSproutViewingKey(vk)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (fFileBacked) {
|
|
||||||
if (!CWalletDB(strWalletFile).EraseSproutViewingKey(vk)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CWallet::LoadSproutViewingKey(const libzcash::SproutViewingKey &vk)
|
|
||||||
{
|
|
||||||
return CCryptoKeyStore::AddSproutViewingKey(vk);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CWallet::AddCScript(const CScript& redeemScript)
|
|
||||||
{
|
|
||||||
if (!CCryptoKeyStore::AddCScript(redeemScript))
|
|
||||||
return false;
|
|
||||||
if (!fFileBacked)
|
|
||||||
return true;
|
|
||||||
return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CWallet::LoadCScript(const CScript& redeemScript)
|
bool CWallet::LoadCScript(const CScript& redeemScript)
|
||||||
{
|
{
|
||||||
/* A sanity check was added in pull #3843 to avoid adding redeemScripts
|
/* A sanity check was added in pull #3843 to avoid adding redeemScripts
|
||||||
|
|||||||
@@ -1111,17 +1111,6 @@ public:
|
|||||||
bool LoadZKeyMetadata(const libzcash::SproutPaymentAddress &addr, const CKeyMetadata &meta);
|
bool LoadZKeyMetadata(const libzcash::SproutPaymentAddress &addr, const CKeyMetadata &meta);
|
||||||
//! Adds an encrypted spending key to the store, without saving it to disk (used by LoadWallet)
|
//! Adds an encrypted spending key to the store, without saving it to disk (used by LoadWallet)
|
||||||
bool LoadCryptedZKey(const libzcash::SproutPaymentAddress &addr, const libzcash::ReceivingKey &rk, const std::vector<unsigned char> &vchCryptedSecret);
|
bool LoadCryptedZKey(const libzcash::SproutPaymentAddress &addr, const libzcash::ReceivingKey &rk, const std::vector<unsigned char> &vchCryptedSecret);
|
||||||
//! Adds an encrypted spending key to the store, and saves it to disk (virtual method, declared in crypter.h)
|
|
||||||
bool AddCryptedSproutSpendingKey(
|
|
||||||
const libzcash::SproutPaymentAddress &address,
|
|
||||||
const libzcash::ReceivingKey &rk,
|
|
||||||
const std::vector<unsigned char> &vchCryptedSecret);
|
|
||||||
|
|
||||||
//! Adds a Sprout viewing key to the store, and saves it to disk.
|
|
||||||
bool AddSproutViewingKey(const libzcash::SproutViewingKey &vk);
|
|
||||||
bool RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk);
|
|
||||||
//! Adds a Sprout viewing key to the store, without saving it to disk (used by LoadWallet)
|
|
||||||
bool LoadSproutViewingKey(const libzcash::SproutViewingKey &dest);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sapling ZKeys
|
* Sapling ZKeys
|
||||||
|
|||||||
Reference in New Issue
Block a user