Closed ok300 closed 6 months ago
It maybe an overkill to re-export the entire library. Instead we should be looking to only re-export those structs that we use as inputs and outputs in our code.
Bolt11Invoice for example is already re-exported so you can already use:
boltz_client::Bolt11Invoice
It maybe an overkill to re-export the entire library
Well, it doesn't hurt boltz-client
to do it, but could help the projects integrating it.
Bolt11Invoice for example is already re-exported
Yes, but for anything more advanced, for example matching on the description, which is of type Bolt11InvoiceDescription
, the caller now has to import the precise correct version of lightning_invoice
crate. If its a different version, best case the compiler accepts it and the project now carries 2 dependency trees of 2 versions of lightning_invoice
, worst case the compiler says the structs are incompatible. If they use any other dependency, which also uses e.g. lightning_invoice
but with a different version, it becomes exponentially more difficult trying to bring the different modules to integrate with each other. Being able to use a dependency's specific e.g. lightning_invoice
version massively simplifies that.
Especially for utility libraries, IMO it makes sense to export them, as projects using the boltz crate will likely need to use those utility libraries as well, so they will likely run in the above conundrum.
In the end its your call, but re-exporting them would be greatly appreciated.
makes sense.
Thanks for the PR @ok300 !
This PR re-exports common libs
bitcoin
,elements
andlightning_invoice
.TLDR: This allows callers, if necessary, to use structs from these libs without having to worry about having an incompatible lib version.
For example, without this PR, a caller would have access to
lightning_invoice::Bolt11Invoice
asboltz_client::Bolt11Invoice
, but not tolightning_invoice::Bolt11InvoiceDescription
since this is not re-exported at the moment. If the caller would import thelightning_invoice
dependency to get access to this, they may run into compatibility issues if they use e.g.Bolt11Invoice::from_str(..)?.description()
with the import fromboltz_client
andBolt11InvoiceDescription
from their own dependency.With the new re-exports, callers can access all structs from
boltz_client
's specific versions ofbitcoin
,elements
andlightning_invoice
.