Skip to content

Commit

Permalink
Change GetMetadata to use unique_ptr<CKeyMetadata>
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Apr 23, 2020
1 parent 72a9540 commit 8b9603b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3820,7 +3820,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)

ScriptPubKeyMan* spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey);
if (spk_man) {
if (const CKeyMetadata* meta = spk_man->GetMetadata(dest)) {
if (const std::unique_ptr<CKeyMetadata> meta = spk_man->GetMetadata(dest)) {
ret.pushKV("timestamp", meta->nCreateTime);
if (meta->has_key_origin) {
ret.pushKV("hdkeypath", WriteHDKeypath(meta->key_origin.path));
Expand Down
8 changes: 4 additions & 4 deletions src/wallet/scriptpubkeyman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,22 +568,22 @@ TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psb
return TransactionError::OK;
}

const CKeyMetadata* LegacyScriptPubKeyMan::GetMetadata(const CTxDestination& dest) const
std::unique_ptr<CKeyMetadata> LegacyScriptPubKeyMan::GetMetadata(const CTxDestination& dest) const
{
LOCK(cs_KeyStore);

CKeyID key_id = GetKeyForDestination(*this, dest);
if (!key_id.IsNull()) {
auto it = mapKeyMetadata.find(key_id);
if (it != mapKeyMetadata.end()) {
return &it->second;
return MakeUnique<CKeyMetadata>(it->second);
}
}

CScript scriptPubKey = GetScriptForDestination(dest);
auto it = m_script_metadata.find(CScriptID(scriptPubKey));
if (it != m_script_metadata.end()) {
return &it->second;
return MakeUnique<CKeyMetadata>(it->second);
}

return nullptr;
Expand Down Expand Up @@ -2041,7 +2041,7 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction&
return TransactionError::OK;
}

const CKeyMetadata* DescriptorScriptPubKeyMan::GetMetadata(const CTxDestination& dest) const
std::unique_ptr<CKeyMetadata> DescriptorScriptPubKeyMan::GetMetadata(const CTxDestination& dest) const
{
return nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/scriptpubkeyman.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class ScriptPubKeyMan

virtual int64_t GetTimeFirstKey() const { return 0; }

virtual const CKeyMetadata* GetMetadata(const CTxDestination& dest) const { return nullptr; }
virtual std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const { return nullptr; }

virtual std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const { return nullptr; }

Expand Down Expand Up @@ -355,7 +355,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv

int64_t GetTimeFirstKey() const override;

const CKeyMetadata* GetMetadata(const CTxDestination& dest) const override;
std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const override;

bool CanGetAddresses(bool internal = false) const override;

Expand Down Expand Up @@ -560,7 +560,7 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan

int64_t GetTimeFirstKey() const override;

const CKeyMetadata* GetMetadata(const CTxDestination& dest) const override;
std::unique_ptr<CKeyMetadata> GetMetadata(const CTxDestination& dest) const override;

bool CanGetAddresses(bool internal = false) const override;

Expand Down

0 comments on commit 8b9603b

Please sign in to comment.