mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Consolidate XOnlyPubKey lookup hack
The places where we need to lookup information for a XOnlyPubKey currently implement a hack which makes both serializations of the full pubkey in order to try the CKeyIDs for the lookup functions. Instead of duplicating this everywhere it is needed, we can consolidate the CKeyID generation into a function, and then have wrappers around GetPubKey, GetKey, and GetKeyOrigin which takes the XOnlyPubKey, retrieves all of the CKeyIDs (using the new GetKeyIDs() function in XOnlyPubKey), and tries their respective underlying lookup function.
This commit is contained in:
parent
dbcb5742c4
commit
d9d3ec07cf
5 changed files with 48 additions and 23 deletions
|
|
@ -1242,14 +1242,8 @@ std::unique_ptr<PubkeyProvider> InferXOnlyPubkey(const XOnlyPubKey& xkey, ParseS
|
|||
CPubKey pubkey(full_key);
|
||||
std::unique_ptr<PubkeyProvider> key_provider = std::make_unique<ConstPubkeyProvider>(0, pubkey, true);
|
||||
KeyOriginInfo info;
|
||||
if (provider.GetKeyOrigin(pubkey.GetID(), info)) {
|
||||
if (provider.GetKeyOriginByXOnly(xkey, info)) {
|
||||
return std::make_unique<OriginPubkeyProvider>(0, std::move(info), std::move(key_provider));
|
||||
} else {
|
||||
full_key[0] = 0x03;
|
||||
pubkey = CPubKey(full_key);
|
||||
if (provider.GetKeyOrigin(pubkey.GetID(), info)) {
|
||||
return std::make_unique<OriginPubkeyProvider>(0, std::move(info), std::move(key_provider));
|
||||
}
|
||||
}
|
||||
return key_provider;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue