Auto merge of #3579 - Eirik0:3577-generate-sprout-zkey, r=bitcartel
Make it clear that CWallet::GenerateNewZKey is Sprout specific Closes https://github.com/zcash/zcash/issues/3577 When adding sapling support we had considered making the method `GenerateNewZKey` generic, but it ended up making more sense to add a second method `GenerateNewSaplingZKey` for sapling support. This PR changes the name of `GenerateNewZKey` to `GenerateNewSproutZKey` and changes the return type from `libzcash::PaymentAddress` to `libzcash::SproutPaymentAddress` to make it more clear that this is what the method does.
This commit is contained in:
@@ -82,23 +82,23 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const
|
||||
}
|
||||
|
||||
// Generate a new spending key and return its public payment address
|
||||
libzcash::PaymentAddress CWallet::GenerateNewZKey()
|
||||
libzcash::SproutPaymentAddress CWallet::GenerateNewSproutZKey()
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // mapSproutZKeyMetadata
|
||||
// TODO: Add Sapling support
|
||||
|
||||
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::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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user