Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Proposal: Add a trait wrapping http calls to hook out in the wasm world #101

Open
moneyball opened this issue Jun 20, 2023 · 6 comments
Open

Comments

@moneyball
Copy link

This would abstract users from a specific implementation so they could hook their own if required (eg WASM) or desired (eg use native HTTP client that comes with an OS/environment).

@moneyball
Copy link
Author

Motivation: There is a Rust crate https://github.com/lightningdevkit/rust-lightning/tree/main/lightning-transaction-sync that makes using LDK much easier as it handles a lot of tricky edge cases. However, it depends upon an HTTP client as it uses Esplora/Electrum. LDK also has extensive language bindings to support other languages but currently this create is not available to languages such as TypeScript/JavaScript in the browser as HTTP is not supported in WASM.

Additionally, other environments such as iOS or Android, an LDK user might wish to use the HTTP client available by the platform instead of taking on an extra dependency with a Rust HTTP client.

@apoelstra
Copy link
Owner

Hi @moneyball. Sorry for the delay, I have been letting Github notifications pile up this week.

RIght now we have the Transport trait which is close to what you're looking for. If somebody were to write a WasmTransport implementing this trait, and you were to use this in place of SimpleHttp or MinreqHttp or whatever, would that achieve your goals?

@TheBlueMatt
Copy link

Largely, yes, but it would be substantially easier ecosystem-wide for the hook to be at the HTTP level rather than the request level. That would mean we can reuse it for bitcoind-REST, Electrum, Esplora, etc all in one trait.

@apoelstra
Copy link
Owner

Can you describe this trait? I don't understand what HTTP other than a series of requests.

@TheBlueMatt
Copy link

The only difference would be the Request wouldn't be tied to JSON, but rather the request methods would take a URI, a "GET"/"POST"/etc method, and a body (which would be converted to string from JSON by the caller).

@apoelstra
Copy link
Owner

Ah, I understand! Concept ACK. Not sure when I'll be able to work on it myself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants