From 4b2e31a7ae630e68735e9c8e32f1df422ef4aff0 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 15 Feb 2022 11:57:25 -0500 Subject: Bugfix: make ToPrivateString work with x-only keys --- src/script/descriptor.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 9f12714e02..798c4b3ea0 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -259,7 +259,15 @@ public: bool ToPrivateString(const SigningProvider& arg, std::string& ret) const override { CKey key; - if (!arg.GetKey(m_pubkey.GetID(), key)) return false; + if (m_xonly) { + for (const auto& keyid : XOnlyPubKey(m_pubkey).GetKeyIDs()) { + arg.GetKey(keyid, key); + if (key.IsValid()) break; + } + } else { + arg.GetKey(m_pubkey.GetID(), key); + } + if (!key.IsValid()) return false; ret = EncodeSecret(key); return true; } -- cgit v1.2.3