aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorAntoine Poinsot <darosior@protonmail.com>2023-02-14 10:31:32 +0100
committerAntoine Poinsot <darosior@protonmail.com>2023-10-08 02:43:19 +0200
commitfcb6f13f442d6a3f27689a87e3ed2bb9b431a332 (patch)
tree643b4e10ed9108d579fcae63cde68b851d9cb8b2 /src/script
parentce8845f5dda403461178c08e7363978fda423999 (diff)
downloadbitcoin-fcb6f13f442d6a3f27689a87e3ed2bb9b431a332.tar.xz
pubkey: introduce a GetEvenCorrespondingCPubKey helper
We'll need to get a compressed key out of an x-only one in other places. Avoid duplicating the code.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/descriptor.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp
index eaef481c51..22177504fc 100644
--- a/src/script/descriptor.cpp
+++ b/src/script/descriptor.cpp
@@ -1401,9 +1401,7 @@ std::unique_ptr<PubkeyProvider> InferPubkey(const CPubKey& pubkey, ParseScriptCo
std::unique_ptr<PubkeyProvider> InferXOnlyPubkey(const XOnlyPubKey& xkey, ParseScriptContext ctx, const SigningProvider& provider)
{
- unsigned char full_key[CPubKey::COMPRESSED_SIZE] = {0x02};
- std::copy(xkey.begin(), xkey.end(), full_key + 1);
- CPubKey pubkey(full_key);
+ CPubKey pubkey{xkey.GetEvenCorrespondingCPubKey()};
std::unique_ptr<PubkeyProvider> key_provider = std::make_unique<ConstPubkeyProvider>(0, pubkey, true);
KeyOriginInfo info;
if (provider.GetKeyOriginByXOnly(xkey, info)) {