All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
-
Main Class Renaming:
- Deprecated the old naming convention.
- Renamed the main class from "Descriptor" to "Output".
- This change emphasizes that a descriptor describes an "Output".
-
Parameter Refactoring:
- Refactored the main input parameter in the constructor of the "Output" class.
- Previously: "expression" (string).
- Now: "descriptor" (string).
- This modification better aligns with the principle above that a descriptor describes an Output.
- Refactored the main input parameter in the constructor of the "Output" class.
-
Function Updates:
- All functions that utilized "expression" have been updated to use "descriptor".
-
Ledger Hardware Wallet & PSBT Finalizers Improvements:
- Refined functions related to the Ledger Hardware Wallet and PSBT finalizers.
- These refinements greatly simplify and enhance the library's usability. See details below.
-
Finalizers Update:
- Deprecated
updatePsbt
in favor ofupdatePsbtAsInput
.- The new function returns the finalizer directly instead of the input number.
- This change eliminates the need to explicitly call the
finalizePsbtInput
method of the Output class. - Previous implementations were error-prone due to the need to keep track of the input number of the PSBT input being finalized and the Output instance of the previous output.
- Deprecated
-
Ledger Enhancements:
- Simplified the signer's requirements before v2.0.0, which previously required tracking the Output instances of each input and passing them to the signer.
- The essential information is now directly extracted from the PSBT, facilitating usability.
- Unified
ledgerClient
andledgerState
parameters into a new typeLedgerManager
, which also includes an instance to the Elliptic Curve Library (ecc
).- To initialize:
const ledgerManager = {ledgerClient, ledgerState: {}, ecc};
, whereimport * as ecc from '@bitcoinerlab/secp256k1'
.
- To initialize:
- Simplified the signer's requirements before v2.0.0, which previously required tracking the Output instances of each input and passing them to the signer.
-
Deprecation Notices:
- While the old functions and classes with former signatures remain available in 2.0.0, they are now deprecated.
- Transitioning to v2.0.0 requires no immediate action, but you may encounter "deprecated" warnings if your code editor supports typedoc/jsdoc linting.
- It's highly recommended to start updating to the new functions and classes.
- While the old functions and classes with former signatures remain available in 2.0.0, they are now deprecated.
-
Key Updates to Consider:
- Substitute
new Descriptor({expression})
withnew Output({descriptor})
. - Transition from
expand({expression})
toexpand({descriptor})
. - Use
updatePsbtAsInput
asupdatePsbt
is now deprecated. - Introduced
updatePsbtAsOutput
for completeness. - Opt for finalizers returned by
updatePsbtAsInput
asfinalizePsbtInput
andfinalizePsbt
have been deprecated.
- Substitute
-
Additional Ledger Updates:
- Functions previously expecting
ledgerClient
andledgerState
should now receiveledgerManager
instead.- This change affects multiple functions, including
signLedger
, all Ledger script expression functions and also:keyExpressionLedger
,registerLedgerWallet
,getLedgerMasterFingerPrint
, andassertLedgerApp
.
- This change affects multiple functions, including
signLedger
andsignInputLedger
no longer necessitate passing an instance to the formerDescriptor
class. All relevant information is automatically retrieved from the psbt now.
- Functions previously expecting
-
Testing Enhancements:
- Deprecated Function Testing:
- Retained old tests, now suffixed with
-deprecated
, to continue testing the deprecated functions and classes.
- Retained old tests, now suffixed with
- New API Testing:
- Introduced additional tests specifically designed to evaluate the new API's functionality.
- Deprecated Function Testing:
-
Documentation Enhancements:
- Extensively documented all methods using typedoc.
- This facilitates the generation of a comprehensive API reference for developers.
- Updated the README.md to mirror the latest changes, optimizing clarity by referencing the API for intricate details.
- Extensively documented all methods using typedoc.
- Descriptor Buffer Comparison:
- Resolved a bug associated with buffer comparisons in
src/descriptors.ts
.- Adjusted the comparison logic for
witnessScript
andredeemScript
to manage scenarios where one buffer may beundefined
. - Introduced the
eqBuffers
function for accurate buffer comparisons, particularly when handlingundefined
values. - This correction is vital for precise descriptor comparisons, especially when determining psbt indexes.
- Adjusted the comparison logic for
- For an in-depth analysis, consult issue-20.
- Resolved a bug associated with buffer comparisons in
- React Native Compatibility:
- Adjusted the way the library imports
ledger-bitcoin
insrc/ledger.ts
to improve compatibility with React Native projects using the Metro bundler.- Previously, the library utilized dynamic imports (
await import('ledger-bitcoin')
), but this approach caused issues with Metro bundler. The bundler tried to unconditionally requireledger-bitcoin
even if it wasn't installed (since it's an optional peerDependency). - The new approach bypasses this by using a direct
require
statement. For more details on the underlying issue, refer to this React Native discussion. - This update ensures smoother integration for developers using this library in React Native projects.
- Previously, the library utilized dynamic imports (
- Adjusted the way the library imports
-
Configuration:
- Adopted sharable configurations from
@bitcoinerlab/configs
to enhance library maintainability.
- Adopted sharable configurations from
-
Exported Types:
- Revised the exported types for descriptors:
-
Before: The library previously exported both
DescriptorInterface
andDescriptorInterfaceConstructor
. -
Now: The library now exports
DescriptorInstance
, a more comprehensive type derived usingInstanceType<ReturnType<typeof DescriptorsFactory>['Descriptor']>;
. This type embodies an instance of the descriptor class returned by the factory, inclusive of its methods. Furthermore, the library now exportsDescriptorConstructor
in place ofDescriptorInterfaceConstructor
.If you previously used
DescriptorInterface
for type annotations with instances of the descriptor class, it's recommended to transition to the newly introducedDescriptorInstance
type. For example:const descriptor: DescriptorInterface = new Descriptor();
should now beconst descriptor: DescriptorInstance = new Descriptor();
. This new type not only offers more precise typings but also has a more appropriate name.
-
- Revised the exported types for descriptors:
- Updated
@bitcoinerlab/secp256k1
from version1.0.2
to1.0.5
,bip32
from3.1.0
to4.0.0
, andbitcoinjs-lib
from6.1.0
to6.1.3
. There are no breaking changes. - Started using
noble-hashes
instead ofcreate-hash
,pbkdf2
, andrandombytes
. This change was made to improve the maintainability of the library.
ledger-bitcoin
is now a peer dependency. To use Ledger support, you need to install it separately. This change allows users to have control over the version ofledger-bitcoin
they want to use and makes sure they are aware of the specific dependencies they are adding to their project. Additionally, if users are not interested in Ledger support, they can now omitledger-bitcoin
to minimize the size of their bundles.
AppClient
is no longer exported within@bitcoinerlab/descriptors
.AppClient
is the client library used to connect and interact with Ledger devices. Now, you need to import it directly fromledger-bitcoin
. This change provides more clarity and control over where the dependencies are coming from.