lightningdevkit / ldk-node

A ready-to-go node implementation built using LDK.
Other
147 stars 73 forks source link

Add Electrum support #196

Open tnull opened 11 months ago

tnull commented 11 months ago

We will add Electrum support.

enigbe commented 2 weeks ago

Hi @tnull, I would like to work on this if no one is assigned to it.

I have outlined a strategy to:

  1. Create a new type, i.e. ElectrumSyncClient
  2. Introduce a set_chain_source/set_tx_sync/set_electrum_client function on NodeBuilder to allow users customize their transaction filters, and default to the EsploraSyncClient in the absence of customization.
  3. Test with one or a few electrum servers. Here is a list of some I have read about and/or used. Given that I don't have extensive knowledge of their adoption in the industry, I would appreciate other suggestions from you to trim/expand the list.
tnull commented 2 weeks ago

Hi @tnull, I would like to work on this if no one is assigned to it.

Ah, thanks for showing interest for this! So, this is still blocked on #358, and a follow-up refactoring our syncing logic I intend to open some time this week. After that it should be relatively easy to add Electrum support. Tbh. I might even try to just do it in a commit as part of that refactor PR, we'll see. Happy to have you pick it up though if it doesn't work out though.

I have outlined a strategy to:

  1. Create a new type, i.e. ElectrumSyncClient
  2. Introduce a set_chain_source/set_tx_sync/set_electrum_client function on NodeBuilder to allow users customize their transaction filters, and default to the EsploraSyncClient in the absence of customization.
  3. Test with one or a few electrum servers. Here is a list of some I have read about and/or used. Given that I don't have extensive knowledge of their adoption in the industry, I would appreciate other suggestions from you to trim/expand the list.

So 1. should already be done in LDK's lightning-transaction-sync (https://github.com/lightningdevkit/rust-lightning/pull/2685), and 2. is part of the syncing (API) refactor mentioned above (at least I hope it will be as easy as I think it is :) ).

Testing (i.e., 3.) sounds good and I'd be very curious to learn if we find any hiccups. I think so far the rust-electrum-client we're building on has been pretty conservative about adding protocol features that aren't widely supported by all server implementations, so I hope we should get good compatibility. But, it would be great to test if this indeed is the case.

enigbe commented 2 weeks ago

I might even try to just do it in a commit as part of that refactor PR, we'll see. Happy to have you pick it up though if it doesn't work out though.

If this is still up when you are done with refactoring the syncing logic, I would be happy to pick it up.

So 1. should already be done in LDK's lightning-transaction-sync

Yeah, I spent some time reading electrum and esplora modules to build an understanding of what's required. It looked like adding a concrete type like was done with EsploraSyncClient, and configuring, was all it would require, given that syncing is already implemented in lightning-transaction-sync. I would like to review this when it is ready as I build more understanding of the project. https://github.com/lightningdevkit/ldk-node/blob/1a6a2ca1d0327bece964f92a31e67921f13ef316/src/types.rs#L55

Testing (i.e., 3.) sounds good and I'd be very curious to learn if we find any hiccups. I think so far the rust-electrum-client we're building on has been pretty conservative about adding protocol features that aren't widely supported by all server implementations, so I hope we should get good compatibility. But, it would be great to test if this indeed is the case.

Open to working on this when you are done.