bitcoinjs-lib icon indicating copy to clipboard operation
bitcoinjs-lib copied to clipboard

[Taproot] Add an utility for sorting leafs in order of weight (likelihood of use)

Open motorina0 opened this issue 3 years ago • 3 comments
trafficstars

It should not be required to sort in any sort of order, but we should offer some sort of helper function to help out.

Input:

  • an ordered list of scripts with weights attached

Output

  • a binary tree were the weights of the script are correlated with the length of the path from the tree root to that script leaf

motorina0 avatar Jan 20 '22 06:01 motorina0

Hi @motorina0, I’m interested in working on this issue. Is anyone else already working on it? If not, can I take it? Do you have any suggestions or tips on how to approach it?

Bticoinops' Schnorr taproot workshop has a notebook on using Huffman constructor to achieve this.

Eunovo avatar Mar 08 '23 17:03 Eunovo

  • such functionality would be useful, but I'm not sure it should be part of this lib
  • if you create an utility we can point to it in the readme

motorina0 avatar Mar 20 '23 09:03 motorina0

  • such functionality would be useful, but I'm not sure it should be part of this lib

@motorina0 What did you have in mind for this issue? The huffman constructor does what I think this issue is requesting for.

Eunovo avatar Mar 20 '23 15:03 Eunovo