Skip to content

Commit 4b2e31a

Browse files
committed
Bugfix: make ToPrivateString work with x-only keys
1 parent 18ad54c commit 4b2e31a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/script/descriptor.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,15 @@ class ConstPubkeyProvider final : public PubkeyProvider
259259
bool ToPrivateString(const SigningProvider& arg, std::string& ret) const override
260260
{
261261
CKey key;
262-
if (!arg.GetKey(m_pubkey.GetID(), key)) return false;
262+
if (m_xonly) {
263+
for (const auto& keyid : XOnlyPubKey(m_pubkey).GetKeyIDs()) {
264+
arg.GetKey(keyid, key);
265+
if (key.IsValid()) break;
266+
}
267+
} else {
268+
arg.GetKey(m_pubkey.GetID(), key);
269+
}
270+
if (!key.IsValid()) return false;
263271
ret = EncodeSecret(key);
264272
return true;
265273
}

0 commit comments

Comments
 (0)