InferTaprootTree

Given a TaprootSpendData and the output key, reconstruct its script tree.

Synopsis

Declared in <script/signingprovider.h>

std::optional<std::vector<std::tuple<int, std::vector<unsigned char>, int>>>
InferTaprootTree(
    TaprootSpendData const& spenddata,
    XOnlyPubKey const& output);

Description

If the output doesn't match the spenddata, or if the data in spenddata is incomplete, std::nullopt is returned. Otherwise, a vector of (depth, script, leaf_ver) tuples is returned, corresponding to a depth-first traversal of the script tree.

Return Value

The reconstructed (depth, script, leaf version) tuples, or std::nullopt on mismatch.

Parameters

NameDescription
spenddataThe spend data describing the output's scripts.
outputThe output key the tree must match.