diff --git a/src/script/signingprovider.cpp b/src/script/signingprovider.cpp index fd5231519b..7ce92a5463 100644 --- a/src/script/signingprovider.cpp +++ b/src/script/signingprovider.cpp @@ -150,3 +150,13 @@ bool FillableSigningProvider::GetCScript(const CScriptID &hash, CScript& redeemS } return false; } + +CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest) +{ + // Only supports destinations which map to single public keys, i.e. P2PKH + const PKHash *pkhash = std::get_if(&dest); + + if (pkhash != nullptr) return ToKeyID(*pkhash); + + return CKeyID(); +} diff --git a/src/script/signingprovider.h b/src/script/signingprovider.h index 468dbb4a06..8ab2793a5b 100644 --- a/src/script/signingprovider.h +++ b/src/script/signingprovider.h @@ -131,4 +131,7 @@ public: virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override; }; +/** Return the CKeyID of the key involved in a script (if there is a unique one). */ +CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest); + #endif // BITCOIN_SCRIPT_SIGNINGPROVIDER_H