diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4417,7 +4417,8 @@ ScriptPubKeyMan *spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey); if (spk_man) { - if (const CKeyMetadata *meta = spk_man->GetMetadata(dest)) { + if (const std::unique_ptr meta = + spk_man->GetMetadata(dest)) { ret.pushKV("timestamp", meta->nCreateTime); if (meta->has_key_origin) { ret.pushKV("hdkeypath", WriteHDKeypath(meta->key_origin.path)); diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -243,7 +243,8 @@ virtual int64_t GetTimeFirstKey() const { return 0; } - virtual const CKeyMetadata *GetMetadata(const CTxDestination &dest) const { + virtual std::unique_ptr + GetMetadata(const CTxDestination &dest) const { return nullptr; } @@ -448,7 +449,8 @@ int64_t GetTimeFirstKey() const override; - const CKeyMetadata *GetMetadata(const CTxDestination &dest) const override; + std::unique_ptr + GetMetadata(const CTxDestination &dest) const override; bool CanGetAddresses(bool internal = false) const override; @@ -714,7 +716,8 @@ int64_t GetTimeFirstKey() const override; - const CKeyMetadata *GetMetadata(const CTxDestination &dest) const override; + std::unique_ptr + GetMetadata(const CTxDestination &dest) const override; bool CanGetAddresses(bool internal = false) const override; diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -524,7 +524,7 @@ return TransactionError::OK; } -const CKeyMetadata * +std::unique_ptr LegacyScriptPubKeyMan::GetMetadata(const CTxDestination &dest) const { LOCK(cs_KeyStore); @@ -532,14 +532,14 @@ if (!key_id.IsNull()) { auto it = mapKeyMetadata.find(key_id); if (it != mapKeyMetadata.end()) { - return &it->second; + return std::make_unique(it->second); } } CScript scriptPubKey = GetScriptForDestination(dest); auto it = m_script_metadata.find(CScriptID(scriptPubKey)); if (it != m_script_metadata.end()) { - return &it->second; + return std::make_unique(it->second); } return nullptr; @@ -2123,7 +2123,7 @@ return TransactionError::OK; } -const CKeyMetadata * +std::unique_ptr DescriptorScriptPubKeyMan::GetMetadata(const CTxDestination &dest) const { return nullptr; }