diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 36a0696a7..dc0123cac 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -2200,14 +2200,15 @@ TEST(WalletTests, GenerateUnifiedAddress) { EXPECT_EQ(uaResult, expected); // Create an account, then generate an address for that account. - auto skpair = wallet.GenerateNewUnifiedSpendingKey(); - uaResult = wallet.GenerateUnifiedAddress(skpair.second, {ReceiverType::P2PKH, ReceiverType::Sapling}); + auto ufvkpair = wallet.GenerateNewUnifiedSpendingKey(); + auto ufvk = ufvkpair.first; + auto account = ufvkpair.second; + uaResult = wallet.GenerateUnifiedAddress(account, {ReceiverType::P2PKH, ReceiverType::Sapling}); auto ua = std::get_if>(&uaResult); EXPECT_NE(ua, nullptr); auto uaSaplingReceiver = ua->first.GetSaplingReceiver(); EXPECT_TRUE(uaSaplingReceiver.has_value()); - auto ufvk = skpair.first.ToFullViewingKey(); EXPECT_EQ(uaSaplingReceiver.value(), ufvk.GetSaplingKey().value().Address(ua->second)); auto u4r = wallet.FindUnifiedAddressByReceiver(uaSaplingReceiver.value()); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 90f89d9b7..aa99bb0cb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3057,8 +3057,8 @@ UniValue z_getnewaccount(const UniValue& params, bool fHelp) EnsureWalletIsUnlocked(); // Generate the new account. - auto skNew = pwalletMain->GenerateNewUnifiedSpendingKey(); - const auto& account = skNew.second; + auto ufvkNew = pwalletMain->GenerateNewUnifiedSpendingKey(); + const auto& account = ufvkNew.second; UniValue result(UniValue::VOBJ); result.pushKV("account", (uint64_t)account); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f57bd8ae0..42130bb93 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -477,7 +477,7 @@ libzcash::transparent::AccountKey CWallet::GetLegacyAccountKey() const { } -std::pair CWallet::GenerateNewUnifiedSpendingKey() { +std::pair CWallet::GenerateNewUnifiedSpendingKey() { AssertLockHeld(cs_wallet); if (!mnemonicHDChain.has_value()) { @@ -488,17 +488,17 @@ std::pair CWallet::GenerateNewUni CHDChain& hdChain = mnemonicHDChain.value(); while (true) { auto accountId = hdChain.GetAccountCounter(); - auto usk = GenerateUnifiedSpendingKeyForAccount(accountId); + auto generated = GenerateUnifiedSpendingKeyForAccount(accountId); hdChain.IncrementAccountCounter(); - if (usk.has_value()) { + if (generated.has_value()) { // Update the persisted chain information if (fFileBacked && !CWalletDB(strWalletFile).WriteMnemonicHDChain(hdChain)) { throw std::runtime_error( "CWallet::GenerateNewUnifiedSpendingKey(): Writing HD chain model failed"); } - return std::make_pair(usk.value(), accountId); + return std::make_pair(generated.value().ToFullViewingKey(), accountId); } } } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 3b297098b..bbe1279e2 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1480,7 +1480,7 @@ public: //! Generate the unified spending key from the wallet's mnemonic seed //! for the next unused account identifier. - std::pair + std::pair GenerateNewUnifiedSpendingKey(); //! Generate the unified spending key for the specified ZIP-32/BIP-44