-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Weight Methods and Optimizations
- New Methods Added: - `guessOutput`: Determines the output type (PKH, WPKH, SH) for 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 Applied: Memoization has been implemented for the following methods to enhance performance and reduce redundant computations: - `guessOutput` - `getSequence` - `getLockTime` - `getScriptSatisfaction` - `inputWeight` - `outputWeight` - Changes in Behavior: - `isSegwit()` now assumes `addr(SH_TYPE_ADDRESS)` descriptors as Segwit `SH_WPKH`. For non-standard script inputs, the format `sh(MINISCRIPT)` should be used. - Rationale for Changes: guessOutput, inputWeight and outputWeight, previously part of `@bitcoinerlab/coinselect`, have been relocated to better align with the module's purpose. Centralizing these methods and implementing a caching strategy significantly improves performance, especially beneficial for the `coinselector` algorithms that frequently access `inputWeight` and `outputWeight`. - Dependencies Added: - Imported `lodash.memoize` for memoization. - Imported `encodingLength` from `varuint-bitcoin` for accurate size calculations. - Other Improvements: - Code comments and documentation have been updated for better clarity and to reflect the new logic.
- Loading branch information
Showing
1 changed file
with
294 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters