From 84b4978c02102171775c77a45f6ec198930f0a88 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 11 Feb 2020 17:36:44 -0500 Subject: [PATCH] Implement SignMessage for descriptor wallets --- src/wallet/scriptpubkeyman.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 1eb9dc4d7a2..b5272be83b9 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -1957,7 +1957,21 @@ bool DescriptorScriptPubKeyMan::SignTransaction(CMutableTransaction& tx, const s SigningResult DescriptorScriptPubKeyMan::SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const { - return SigningResult::SIGNING_FAILED; + std::unique_ptr keys = GetSigningProvider(GetScriptForDestination(pkhash), true); + if (!keys) { + return SigningResult::PRIVATE_KEY_NOT_AVAILABLE; + } + + CKeyID key_id(pkhash); + CKey key; + if (!keys->GetKey(key_id, key)) { + return SigningResult::PRIVATE_KEY_NOT_AVAILABLE; + } + + if (!MessageSign(key, message, str_sig)) { + return SigningResult::SIGNING_FAILED; + } + return SigningResult::OK; } TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbt, int sighash_type, bool sign, bool bip32derivs) const