mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
descriptor: Try the other parity in ConstPubkeyProvider::GetPrivKey()
GetPrivKey() needs the same handling of all keyids for xonly keys that ToPrivateString() does. Refactor that into GetPrivKey() and reuse it in ToPrivateString() to resolve this.
This commit is contained in:
parent
228aba2c4d
commit
092569e858
1 changed files with 3 additions and 10 deletions
|
@ -312,15 +312,7 @@ public:
|
||||||
bool ToPrivateString(const SigningProvider& arg, std::string& ret) const override
|
bool ToPrivateString(const SigningProvider& arg, std::string& ret) const override
|
||||||
{
|
{
|
||||||
CKey key;
|
CKey key;
|
||||||
if (m_xonly) {
|
if (!GetPrivKey(/*pos=*/0, arg, key)) return false;
|
||||||
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);
|
ret = EncodeSecret(key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +323,8 @@ public:
|
||||||
}
|
}
|
||||||
bool GetPrivKey(int pos, const SigningProvider& arg, CKey& key) const override
|
bool GetPrivKey(int pos, const SigningProvider& arg, CKey& key) const override
|
||||||
{
|
{
|
||||||
return arg.GetKey(m_pubkey.GetID(), key);
|
return m_xonly ? arg.GetKeyByXOnly(XOnlyPubKey(m_pubkey), key) :
|
||||||
|
arg.GetKey(m_pubkey.GetID(), key);
|
||||||
}
|
}
|
||||||
std::optional<CPubKey> GetRootPubKey() const override
|
std::optional<CPubKey> GetRootPubKey() const override
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue