You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3d12b42a6527bce318ac618d25dd25e2d2946470 fuzz: update taptree regression test to also check control blocks (Andrew Poelstra)
c1d4305db39cf38be823c1e44fcd9580fba15cd9 tr: add a whole bunch of fixed vector unit tests for TrSpendInfo (Andrew Poelstra)
8bc940018b11ff3de18657cc8040f892a0ced652 tr: add conversion from TrSpendInfo to bitcoin::TapTree (Andrew Poelstra)
5fe2d25decd8b31f72692c5750a9d59c760c4c1c tr: replace `bitcoin::TaprootSpendInfo` with `TrSpendInfo`, update psbt (Andrew Poelstra)
795cd4fc8fd2228195d1d88a62cefc343eb5b04e tr: introduce new `TrSpendInfo` structure which holds a full TapTree (Andrew Poelstra)
27a30e61f7dd95f8719241b1add3438dd04aadce psbt: untangle some logic in `update_item_with_descriptor_helper` (Andrew Poelstra)
00495a5442ff0f66c71728e317084ddcc1ed2ff7 descriptor: add unit test from sanket (Andrew Poelstra)
Pull request description:
In Miniscript, to compute control blocks, estimate satisfaction costs, or otherwise iterate through all the leaves of a Taptree, we use the `bitcoin::TaprootSpendInfo` structure to maintain a map of all leaves. This map is inappropriate for Miniscript (it may not be appropriate for *anyone* actually..) for a few reasons:
* It is a map from Tapleaves' encoding as Script to data about the Tapleaves; but in Miniscript the Script encoding isn't primary and isn't even available for non-`ToPublicKey` keys
* This map structure means that if duplicate leaves exist then only one of the dupes will be accessible.
* The map structure is also really inefficient; it stores the entire merkle path for each leaf even those these paths significantly overlap, leading to O(n log n) space instead of O(n).
* Furthermore, we don't need *any* map because we only ever iterate through the entire tree.
We fix all these issues by introducing a new `TrSpendInfo` struct which stores the entire Merkle tree in a flat representation and can produce an iterator over all the leaves. The iterator item can be used to access the Script, the Miniscript, the leaf version, and the control block for each leaf, while the `TrSpendInfo` structure itself can be used to access the internal and external keys. In other words, this one structure efficiently implements APIs for everything that rust-miniscript needs.
This completes the Taproot API overhaul project. After this I'll go back to fixing error types, eliminating recursive structures, or overhauling the validation parameters, whichever one seems most tractable from the current state of `master`.
ACKs for top commit:
sanket1729:
ACK 3d12b42a6527bce318ac618d25dd25e2d2946470
Tree-SHA512: 40fa71ebf22b104304ddbd9b3bf9efdd5d509c071a9461c80eb5f669ecdfd4dd7174cb5fcd2af30f32e45aecd370e077a49fd771eb71edf3f6fe4949c9b80d7d
0 commit comments