peercoin / coinlib

The most feature-complete *coin library in the entire Dart/Flutter ecosystem.
BSD 3-Clause "New" or "Revised" License
5 stars 8 forks source link

TapBranch and TapLeaf classes #16

Closed MatthewLM closed 9 months ago

MatthewLM commented 10 months ago

Added alongside the Taproot class shall be two classes to represent a MAST tree: TapBranch and TapLeaf. Both of these shall inherit from a TapNode base class. The TapLeaf class shall be Writable with a script and leaf version. The TapBranch class must contain two TapNode children. The constructor will take a left and right node.

The Taproot class will be updated to take a TapNode as mast in addition to an internal key. If mast is null, then the existing key-path-only tweak will be used. The class will provide a leaves getter to access underlying leafs in the left-to-right order. A new controlBlockFor(int n) method will obtain the control block data for a given leaf.

MatthewLM commented 9 months ago

Completed in 2-taproot branch.