aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2022-02-15 11:57:25 -0500
committerPieter Wuille <pieter@wuille.net>2022-02-15 11:57:25 -0500
commit4b2e31a7ae630e68735e9c8e32f1df422ef4aff0 (patch)
tree4c696cf141c219c5aeba46c5ea06a8ab53d77292 /src
parent18ad54c3b21804ad540631dd4527cbad6d6ccc75 (diff)
downloadbitcoin-4b2e31a7ae630e68735e9c8e32f1df422ef4aff0.tar.xz
Bugfix: make ToPrivateString work with x-only keys
Diffstat (limited to 'src')
-rw-r--r--src/script/descriptor.cpp10
1 files changed, 9 insertions, 1 deletions
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;
}