New Weight Calculation Functionalities and General Optimizations in Descriptors #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Pull Request introduces a series of enhancements and optimizations to the descriptor methods in the
@bitcoinerlab/descriptors
package. Key updates include the addition of new methods for weight calculation, improvements in memoization, and updates to dependencies and configurations. These changes are aimed at improving the performance and functionality of the module, especially in scenarios involvingcoinselector
algorithms.Key Changes:
New Descriptor Methods:
guessOutput
: Identifies the output type (PKH, WPKH, SH) based on a given script.inputWeight
: Calculates the Weight Unit contributions of an Output as an input in a transaction.outputWeight
: Computes the Weight Unit contributions of an Output as an output in a transaction.Memoization Implementation:
guessOutput
,getSequence
,getLockTime
,getScriptSatisfaction
,inputWeight
, andoutputWeight
for enhanced performance and reduced redundant computations.Behavioral Changes:
isSegwit()
method now assumesaddr(SH_TYPE_ADDRESS)
descriptors as SegwitSH_WPKH
. For non-standard script inputs, the formatsh(MINISCRIPT)
should be used.Dependency and Configuration Updates:
build:test
script to include--resolveJsonModule
.lodash.memoize
for memoization functionality.varuint-bitcoin
explicitelly.Additional Improvements:
varuint-bitcoin
functions from the official npm package.Testing:
inputWeight
,outputWeight
, andguessOutput
.Rationale for Changes:
The relocation of
guessOutput
,inputWeight
, andoutputWeight
from@bitcoinerlab/coinselect
to@bitcoinerlab/descriptors
aligns these methods more closely with the module's purpose. The implementation of a caching strategy and memoization significantly boosts performance, particularly for algorithms that frequently access these weight calculation methods.Documentation: