Bugfix: make ToPrivateString work with x-only keys

This commit is contained in:
Pieter Wuille 2022-02-15 11:57:25 -05:00
parent 18ad54c3b2
commit 4b2e31a7ae

View file

@ -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;
}