bitcoinerlab / descriptors

A TypeScript library for parsing Bitcoin Descriptors, including Miniscript-based ones. Streamlines creating Partially Signed Bitcoin Transactions (PSBTs) from Descriptors. Features BIP32, single-signature, and Hardware Wallet signing capabilities, and facilitates finalizing transactions.
https://bitcoinerlab.com/modules/descriptors
41 stars 14 forks source link

TS types are not available #34

Open saravanan7mani opened 7 months ago

saravanan7mani commented 7 months ago

TS types ExpansionMap, ParseKeyExpression, Preimage, TimeConstraints are not exported.

https://github.com/saravanan7mani/descriptors/blob/main/src/index.ts#L4

landabaso commented 6 months ago

Hi @saravanan7mani, thank you for bringing this to my attention.

I've aimed to minimize the number of types exported, with the intention that they should be implicitly set. For instance, in const expansionMap = output.expand().expansionMap, the type is inferred by TypeScript, so an explicit declaration isn't necessary.

However, I'm open to the idea of exposing these types. Could you please clarify the specific circumstances under which you needed each one? For example, I'm curious about your need for TimeConstraints. This is an internal type, and its external usage isn't clear. If we expose it and subsequently change the API, it could result in a breaking change. Understanding your use case will help me make an informed decision.

Looking forward to your response.

saravanan7mani commented 6 months ago

Hi @landabaso, thank you for the response.

  1. As a function argument types, they are useful. Ex: processExpansionMap(expansionMap: ExpansionMap) and validatePreimage(preimage: Preimage).

  2. Please ignore TimeConstraints and ParseKeyExpression. I just copied them from types.ts without thought.

landabaso commented 6 months ago

Are you in need of an immediate fix for this? For now, you might need to manually copy the types. I plan to address this in the next release and will keep the issue open until then. Is this approach workable for you?

saravanan7mani commented 6 months ago

Yep. Works for me.