mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
Add multi_a descriptor inference
This commit is contained in:
parent
79728c4a3d
commit
3eed6fca57
@ -1287,6 +1287,21 @@ std::unique_ptr<PubkeyProvider> InferXOnlyPubkey(const XOnlyPubKey& xkey, ParseS
|
|||||||
return key_provider;
|
return key_provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<DescriptorImpl> InferMultiA(const CScript& script, ParseScriptContext ctx, const SigningProvider& provider)
|
||||||
|
{
|
||||||
|
auto match = MatchMultiA(script);
|
||||||
|
if (!match) return {};
|
||||||
|
std::vector<std::unique_ptr<PubkeyProvider>> keys;
|
||||||
|
keys.reserve(match->second.size());
|
||||||
|
for (const auto keyspan : match->second) {
|
||||||
|
if (keyspan.size() != 32) return {};
|
||||||
|
auto key = InferXOnlyPubkey(XOnlyPubKey{keyspan}, ctx, provider);
|
||||||
|
if (!key) return {};
|
||||||
|
keys.push_back(std::move(key));
|
||||||
|
}
|
||||||
|
return std::make_unique<MultiADescriptor>(match->first, std::move(keys));
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptContext ctx, const SigningProvider& provider)
|
std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptContext ctx, const SigningProvider& provider)
|
||||||
{
|
{
|
||||||
if (ctx == ParseScriptContext::P2TR && script.size() == 34 && script[0] == 32 && script[33] == OP_CHECKSIG) {
|
if (ctx == ParseScriptContext::P2TR && script.size() == 34 && script[0] == 32 && script[33] == OP_CHECKSIG) {
|
||||||
@ -1294,6 +1309,11 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
|
|||||||
return std::make_unique<PKDescriptor>(InferXOnlyPubkey(key, ctx, provider));
|
return std::make_unique<PKDescriptor>(InferXOnlyPubkey(key, ctx, provider));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx == ParseScriptContext::P2TR) {
|
||||||
|
auto ret = InferMultiA(script, ctx, provider);
|
||||||
|
if (ret) return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::vector<unsigned char>> data;
|
std::vector<std::vector<unsigned char>> data;
|
||||||
TxoutType txntype = Solver(script, data);
|
TxoutType txntype = Solver(script, data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user