GenerateLegacySaplingZKey only needs to return an address, not an extfvk.
This commit is contained in:
parent
ae2213dcdc
commit
b80349d246
|
@ -205,8 +205,8 @@ libzcash::SaplingPaymentAddress AsyncRPCOperation_saplingmigration::getMigration
|
|||
}
|
||||
|
||||
// TODO: move off of legacy addresses.
|
||||
auto generatedKey = pwalletMain->GenerateLegacySaplingZKey(0);
|
||||
return generatedKey.first.ToXFVK().DefaultAddress();
|
||||
auto generated = pwalletMain->GenerateLegacySaplingZKey(0);
|
||||
return generated.first;
|
||||
}
|
||||
|
||||
void AsyncRPCOperation_saplingmigration::cancel() {
|
||||
|
|
|
@ -129,13 +129,12 @@ SaplingPaymentAddress CWallet::GenerateNewLegacySaplingZKey() {
|
|||
|
||||
// loop until we find an unused address index
|
||||
while (true) {
|
||||
auto generatedKey = GenerateLegacySaplingZKey(hdChain.GetLegacySaplingKeyCounter());
|
||||
auto xfvk = generatedKey.first.ToXFVK();
|
||||
auto generated = GenerateLegacySaplingZKey(hdChain.GetLegacySaplingKeyCounter());
|
||||
|
||||
// advance the address index counter so that the next time we need to generate
|
||||
// a key we're pointing at a free index.
|
||||
hdChain.IncrementLegacySaplingKeyCounter();
|
||||
if (!generatedKey.second) {
|
||||
if (!generated.second) {
|
||||
// the key already existed, so try the next one
|
||||
continue;
|
||||
} else {
|
||||
|
@ -145,12 +144,12 @@ SaplingPaymentAddress CWallet::GenerateNewLegacySaplingZKey() {
|
|||
"CWallet::GenerateNewLegacySaplingZKey(): Writing HD chain model failed");
|
||||
}
|
||||
|
||||
return xfvk.DefaultAddress();
|
||||
return generated.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<SaplingExtendedSpendingKey, bool> CWallet::GenerateLegacySaplingZKey(uint32_t addrIndex) {
|
||||
std::pair<SaplingPaymentAddress, bool> CWallet::GenerateLegacySaplingZKey(uint32_t addrIndex) {
|
||||
auto seedOpt = GetMnemonicSeed();
|
||||
if (!seedOpt.has_value()) {
|
||||
throw std::runtime_error(
|
||||
|
@ -159,8 +158,9 @@ std::pair<SaplingExtendedSpendingKey, bool> CWallet::GenerateLegacySaplingZKey(u
|
|||
auto seed = seedOpt.value();
|
||||
|
||||
auto xsk = libzcash::SaplingExtendedSpendingKey::Legacy(seed, BIP44CoinType(), addrIndex);
|
||||
if (!HaveSaplingSpendingKey(xsk.first.ToXFVK())) {
|
||||
auto ivk = xsk.first.expsk.full_viewing_key().in_viewing_key();
|
||||
auto extfvk = xsk.first.ToXFVK();
|
||||
if (!HaveSaplingSpendingKey(extfvk)) {
|
||||
auto ivk = extfvk.fvk.in_viewing_key();
|
||||
CKeyMetadata keyMeta(GetTime());
|
||||
keyMeta.hdKeypath = xsk.second;
|
||||
keyMeta.seedFp = seed.Fingerprint();
|
||||
|
@ -169,9 +169,9 @@ std::pair<SaplingExtendedSpendingKey, bool> CWallet::GenerateLegacySaplingZKey(u
|
|||
if (!AddSaplingZKey(xsk.first)) {
|
||||
throw std::runtime_error("CWallet::GenerateLegacySaplingZKey(): AddSaplingZKey failed.");
|
||||
}
|
||||
return std::make_pair(xsk.first, true) ;
|
||||
return std::make_pair(extfvk.DefaultAddress(), true) ;
|
||||
} else {
|
||||
return std::make_pair(xsk.first, false);
|
||||
return std::make_pair(extfvk.DefaultAddress(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1372,7 +1372,7 @@ public:
|
|||
//! spending key to the wallet if it has not alreay been persisted.
|
||||
//! Returns the newly created key, and a flag distinguishing
|
||||
//! whether or not the key was already known by the wallet.
|
||||
std::pair<libzcash::SaplingExtendedSpendingKey, bool> GenerateLegacySaplingZKey(uint32_t addrIndex);
|
||||
std::pair<libzcash::SaplingPaymentAddress, bool> GenerateLegacySaplingZKey(uint32_t addrIndex);
|
||||
//! Adds Sapling spending key to the store, and saves it to disk
|
||||
bool AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &key);
|
||||
//! Add Sapling full viewing key to the wallet.
|
||||
|
|
Loading…
Reference in New Issue