From b65cea53df99f9dd43af5f60078765bd8e5e84bb Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Tue, 29 Aug 2023 14:39:50 +0700 Subject: [PATCH] partial (missing function GetKeyForDestination) Merge #11403: SegWit wallet support --- src/script/signingprovider.cpp | 10 ++++++++++ src/script/signingprovider.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/script/signingprovider.cpp b/src/script/signingprovider.cpp index fd5231519bde5..7ce92a546336d 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 468dbb4a0674b..8ab2793a5b5d8 100644 --- a/src/script/signingprovider.h +++ b/src/script/signingprovider.h @@ -131,4 +131,7 @@ class FillableSigningProvider : public SigningProvider 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