[#InferTaprootTree]
= InferTaprootTree
:mrdocs:

Given a TaprootSpendData and the output key, reconstruct its script tree&period;

== Synopsis

Declared in `&lt;script&sol;signingprovider&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
std::optional&lt;std::vector&lt;std::tuple&lt;int, std::vector&lt;unsigned char&gt;, int&gt;&gt;&gt;
InferTaprootTree(
    xref:TaprootSpendData.adoc[TaprootSpendData] const& spenddata,
    xref:XOnlyPubKey.adoc[XOnlyPubKey] const& output);
----

== Description

If the output doesn&apos;t match the spenddata, or if the data in spenddata is incomplete, std&colon;&colon;nullopt is returned&period; Otherwise, a vector of (depth, script, leaf&lowbar;ver) tuples is returned, corresponding to a depth&hyphen;first traversal of the script tree&period;

== Return Value

The reconstructed (depth, script, leaf version) tuples, or std&colon;&colon;nullopt on mismatch&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *spenddata*
| The spend data describing the output&apos;s scripts&period;
| *output*
| The output key the tree must match&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
