diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-06-28 15:00:33 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-08-23 21:38:34 -0400 |
commit | d9d3ec07cfe45cfa55028cc879dc8a55aecb4d3c (patch) | |
tree | 32cb83e14faad38a733c603196d2625349cfac58 /src/script/sign.cpp | |
parent | dbcb5742c48fd26f77e500291d7083e12eec741b (diff) | |
download | bitcoin-d9d3ec07cfe45cfa55028cc879dc8a55aecb4d3c.tar.xz |
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.
Diffstat (limited to 'src/script/sign.cpp')
-rw-r--r-- | src/script/sign.cpp | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 4714d0ef11..b912b00365 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -60,22 +60,7 @@ bool MutableTransactionSignatureCreator::CreateSchnorrSig(const SigningProvider& assert(sigversion == SigVersion::TAPROOT || sigversion == SigVersion::TAPSCRIPT); CKey key; - { - // For now, use the old full pubkey-based key derivation logic. As it is indexed by - // Hash160(full pubkey), we need to try both a version prefixed with 0x02, and one - // with 0x03. - unsigned char b[33] = {0x02}; - std::copy(pubkey.begin(), pubkey.end(), b + 1); - CPubKey fullpubkey; - fullpubkey.Set(b, b + 33); - CKeyID keyid = fullpubkey.GetID(); - if (!provider.GetKey(keyid, key)) { - b[0] = 0x03; - fullpubkey.Set(b, b + 33); - CKeyID keyid = fullpubkey.GetID(); - if (!provider.GetKey(keyid, key)) return false; - } - } + if (!provider.GetKeyByXOnly(pubkey, key)) return false; // BIP341/BIP342 signing needs lots of precomputed transaction data. While some // (non-SIGHASH_DEFAULT) sighash modes exist that can work with just some subset |