MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / InferPubkey

Function InferPubkey

src/script/descriptor.cpp:2207–2223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2205}
2206
2207std::unique_ptr<PubkeyProvider> InferPubkey(const CPubKey& pubkey, ParseScriptContext ctx, const SigningProvider& provider)
2208{
2209 // Key cannot be hybrid
2210 if (!pubkey.IsValidNonHybrid()) {
2211 return nullptr;
2212 }
2213 // Uncompressed is only allowed in TOP and P2SH contexts
2214 if (ctx != ParseScriptContext::TOP && ctx != ParseScriptContext::P2SH && !pubkey.IsCompressed()) {
2215 return nullptr;
2216 }
2217 std::unique_ptr<PubkeyProvider> key_provider = std::make_unique<ConstPubkeyProvider>(0, pubkey, false);
2218 KeyOriginInfo info;
2219 if (provider.GetKeyOrigin(pubkey.GetID(), info)) {
2220 return std::make_unique<OriginPubkeyProvider>(0, std::move(info), std::move(key_provider), /*apostrophe=*/false);
2221 }
2222 return key_provider;
2223}
2224
2225std::unique_ptr<PubkeyProvider> InferXOnlyPubkey(const XOnlyPubKey& xkey, ParseScriptContext ctx, const SigningProvider& provider)
2226{

Callers 3

FromPKBytesMethod · 0.85
FromPKHBytesMethod · 0.85
InferScriptFunction · 0.85

Calls 4

IsValidNonHybridMethod · 0.80
IsCompressedMethod · 0.45
GetKeyOriginMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected