From da212ad425f1fb1bd671acfe2f0bab6a1895cb02 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 2 Oct 2023 02:18:26 +0700 Subject: [PATCH] follow-up Merge #17381: LegacyScriptPubKeyMan code cleanups - now it's possible to remove workaround --- src/wallet/rpcwallet.cpp | 2 +- src/wallet/scriptpubkeyman.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6be1ae9be6504..41b756df1c887 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3829,12 +3829,12 @@ UniValue getaddressinfo(const JSONRPCRequest& request) ScriptPubKeyMan* spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey); if (spk_man) { - const PKHash *pkhash = std::get_if(&dest); if (const CKeyMetadata* meta = spk_man->GetMetadata(dest)) { ret.pushKV("timestamp", meta->nCreateTime); CHDChain hdChainCurrent; LegacyScriptPubKeyMan* legacy_spk_man = pwallet->GetLegacyScriptPubKeyMan(); if (legacy_spk_man != nullptr) { + const PKHash *pkhash = std::get_if(&dest); if (pkhash && legacy_spk_man->HaveHDKey(ToKeyID(*pkhash), hdChainCurrent)) { ret.pushKV("hdchainid", hdChainCurrent.GetID().GetHex()); } diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 0fe85bff7a632..78a2dbc2bc093 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -749,9 +749,9 @@ const CKeyMetadata* LegacyScriptPubKeyMan::GetMetadata(const CTxDestination& des { LOCK(cs_KeyStore); - const PKHash *pkhash = std::get_if(&dest); - if (pkhash != nullptr && !ToKeyID(*pkhash).IsNull()) { - auto it = mapKeyMetadata.find(ToKeyID(*pkhash)); + CKeyID key_id = GetKeyForDestination(*this, dest); + if (!key_id.IsNull()) { + auto it = mapKeyMetadata.find(key_id); if (it != mapKeyMetadata.end()) { return &it->second; }