bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.68k stars 2.1k forks source link

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

Open motorina0 opened 2 years ago

motorina0 commented 2 years ago

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:

Output

Eunovo commented 1 year ago

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.

motorina0 commented 1 year ago
Eunovo commented 1 year ago
  • 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.