Add bitreq #1608

Open
lescuer97 wants to merge 20 commits from lescuer97/add_bitreq into main
lescuer97 commented 2026-02-07 10:11:38 +00:00 (Migrated from github.com)

Description

use bitreq for the non wasm targets and use reqwest for wasm. in the http client crate.


Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

### Description use bitreq for the non wasm targets and use reqwest for wasm. in the http client crate. ----- ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ----- ### Suggested [CHANGELOG](https://github.com/cashubtc/cdk/blob/main/CHANGELOG.md) Updates <!-- Please do not edit the actual changelog but note what you changed here. --> #### CHANGED #### ADDED #### REMOVED #### FIXED ---- ### Checklist * [ ] I followed the [code style guidelines](https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md) * [ ] I ran `just final-check` before committing
crodas (Migrated from github.com) reviewed 2026-02-07 10:11:38 +00:00
crodas commented 2026-02-19 14:55:50 +00:00 (Migrated from github.com)

@lescuer97 almost there, I think we should remove reqwuest all together and use this bits for wasm, using the native "fetch" function provided by the browser and bitreq for everything else

@lescuer97 almost there, I think we should remove reqwuest all together and use this bits for wasm, using the native "[fetch](https://github.com/cashubtc/cdk/pull/1660/changes#diff-23639e0989d38e5a6bba93c9eb5557b78fa40439227ab2c0ef64e5daca40e187R13)" function provided by the browser and bitreq for everything else
thesimplekid commented 2026-02-23 14:19:16 +00:00 (Migrated from github.com)

@lescuer97 almost there, I think we should remove reqwuest all together and use this bits for wasm, using the native "fetch" function provided by the browser and bitreq for everything else

I don't think we should remove reqwest all together. Can't we make use of a trait and then implement that trait for both bitreq and reqwest, it should only have a couple fns. We can then feature flag these implementations. Many projects already use reqwest so use reqwest within cdk would not be adding any deps and in fact using bitreq would. This would also make it easier for us to switch between the two as bitreq is still new we could encounter issues.

> @lescuer97 almost there, I think we should remove reqwuest all together and use this bits for wasm, using the native "[fetch](https://github.com/cashubtc/cdk/pull/1660/changes#diff-23639e0989d38e5a6bba93c9eb5557b78fa40439227ab2c0ef64e5daca40e187R13)" function provided by the browser and bitreq for everything else I don't think we should remove reqwest all together. Can't we make use of a trait and then implement that trait for both bitreq and reqwest, it should only have a couple fns. We can then feature flag these implementations. Many projects already use reqwest so use reqwest within cdk would not be adding any deps and in fact using bitreq would. This would also make it easier for us to switch between the two as bitreq is still new we could encounter issues.
lescuer97 commented 2026-02-24 09:35:06 +00:00 (Migrated from github.com)

@lescuer97 almost there, I think we should remove reqwuest all together and use this bits for wasm, using the native "fetch" function provided by the browser and bitreq for everything else

I don't think we should remove reqwest all together. Can't we make use of a trait and then implement that trait for both bitreq and reqwest, it should only have a couple fns. We can then feature flag these implementations. Many projects already use reqwest so use reqwest within cdk would not be adding any deps and in fact using bitreq would. This would also make it easier for us to switch between the two as bitreq is still new we could encounter issues.

projects already using reqwest is true. I had not think about it

> > @lescuer97 almost there, I think we should remove reqwuest all together and use this bits for wasm, using the native "[fetch](https://github.com/cashubtc/cdk/pull/1660/changes#diff-23639e0989d38e5a6bba93c9eb5557b78fa40439227ab2c0ef64e5daca40e187R13)" function provided by the browser and bitreq for everything else > > I don't think we should remove reqwest all together. Can't we make use of a trait and then implement that trait for both bitreq and reqwest, it should only have a couple fns. We can then feature flag these implementations. Many projects already use reqwest so use reqwest within cdk would not be adding any deps and in fact using bitreq would. This would also make it easier for us to switch between the two as bitreq is still new we could encounter issues. projects already using reqwest is true. I had not think about it
crodas commented 2026-02-24 10:08:39 +00:00 (Migrated from github.com)

The reqwest feature needs to be added to the cdk and perhaps the mintd crates as well, since the http crate is not injected or cannot be provided externally.

The reqwest feature needs to be added to the cdk and perhaps the mintd crates as well, since the http crate is not injected or cannot be provided externally.
thesimplekid commented 2026-02-24 10:11:49 +00:00 (Migrated from github.com)

mintd we can just make the choice we don't need to give a feature.

mintd we can just make the choice we don't need to give a feature.
thesimplekid commented 2026-02-24 10:14:35 +00:00 (Migrated from github.com)

Even if we do not provide the feature externally, I still think it makes sense to do as a trait. Since we know we will have at least 2 impls even if we drop reqwest wasm and native.

Even if we do not provide the feature externally, I still think it makes sense to do as a trait. Since we know we will have at least 2 impls even if we drop reqwest wasm and native.
lescuer97 commented 2026-02-24 10:34:36 +00:00 (Migrated from github.com)

okey, just to clear thing up. I will then keep this code but add back the features for bitreq and reqwest.

and reimplement the trait for reqwest.

does this sound correct?

okey, just to clear thing up. I will then keep this code but add back the features for `bitreq` and `reqwest`. and reimplement the trait for reqwest. does this sound correct?
crodas commented 2026-02-24 11:22:41 +00:00 (Migrated from github.com)

I can help if you want, but I also believe the trait is a good idea and it should live in cdk-common perhaps.

I can help if you want, but I also believe the trait is a good idea and it should live in cdk-common perhaps.
thesimplekid commented 2026-02-24 11:55:47 +00:00 (Migrated from github.com)

I just remembered we actually have 3 at minimum due to Tor. We already have a trait there maybe we can just move it and consolidate? github.com/cashubtc/cdk@48e50028af/crates/cdk/src/wallet/mint_connector/transport/tor_transport.rs (L225)

I just remembered we actually have 3 at minimum due to Tor. We already have a trait there maybe we can just move it and consolidate? https://github.com/cashubtc/cdk/blob/48e50028aff6b7782e1f6b03b3952ee81186cda5/crates/cdk/src/wallet/mint_connector/transport/tor_transport.rs#L225
lescuer97 commented 2026-03-08 21:37:58 +00:00 (Migrated from github.com)

@thesimplekid @crodas just to be clear on what to do next. I should keep the trait that already exists in the http package, then use that trait for the tor implementation also. possibly moving that code into the http crate.

plus go back to use features. so users can decide to use either the reqwest or bitreq trait.

@thesimplekid @crodas just to be clear on what to do next. I should keep the trait that already exists in the http package, then use that trait for the tor implementation also. possibly moving that code into the http crate. plus go back to use features. so users can decide to use either the reqwest or bitreq trait.
thesimplekid commented 2026-03-09 12:00:55 +00:00 (Migrated from github.com)

We want to move the transport Trait to the http crate. Tor, bitreq and reqwest should all implement this each behind a feature in the http crate. The MintConnector should stay roughly the same in cdk where it takes the Transport trait.

We want to move the transport Trait to the http crate. Tor, bitreq and reqwest should all implement this each behind a feature in the http crate. The `MintConnector` should stay roughly the same in cdk where it takes the Transport trait.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin lescuer97/add_bitreq:lescuer97/add_bitreq
git switch lescuer97/add_bitreq

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff lescuer97/add_bitreq
git switch lescuer97/add_bitreq
git rebase main
git switch main
git merge --ff-only lescuer97/add_bitreq
git switch lescuer97/add_bitreq
git rebase main
git switch main
git merge --no-ff lescuer97/add_bitreq
git switch main
git merge --squash lescuer97/add_bitreq
git switch main
git merge --ff-only lescuer97/add_bitreq
git switch main
git merge lescuer97/add_bitreq
git push origin main
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cashubtc/cdk!1608
No description provided.