psbt: Change m_tap_tree to store just the tuples

Instead of having an entire TaprootBuilder which may or may not be
complete, and could potentially have future changes that interact oddly
with taproot tree tuples, have m_tap_tree be just the tuples.

When needed in other a TaprootBuilder for actual use, the tuples will be
added to a a TaprootBuilder that, in the future, can take in whatever
other data is needed as well.
This commit is contained in:
Andrew Chow
2022-08-16 21:17:43 -04:00
committed by Andrew Chow
parent 22c051ca70
commit 0577d423ad
3 changed files with 19 additions and 25 deletions

View File

@@ -1241,13 +1241,9 @@ static RPCHelpMan decodepsbt()
}
// Taproot tree
if (output.m_tap_tree.has_value()) {
if (!output.m_tap_tree.empty()) {
UniValue tree(UniValue::VARR);
const auto& tuples = output.m_tap_tree->GetTreeTuples();
for (const auto& tuple : tuples) {
uint8_t depth = std::get<0>(tuple);
uint8_t leaf_ver = std::get<1>(tuple);
CScript script = std::get<2>(tuple);
for (const auto& [depth, leaf_ver, script] : output.m_tap_tree) {
UniValue elem(UniValue::VOBJ);
elem.pushKV("depth", (int)depth);
elem.pushKV("leaf_ver", (int)leaf_ver);