| 2205 | } |
| 2206 | |
| 2207 | std::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 | |
| 2225 | std::unique_ptr<PubkeyProvider> InferXOnlyPubkey(const XOnlyPubKey& xkey, ParseScriptContext ctx, const SigningProvider& provider) |
| 2226 | { |
no test coverage detected