polar icon indicating copy to clipboard operation
polar copied to clipboard

Feature Request: btcd node

Open hsjoberg opened this issue 4 years ago • 7 comments

I saw that this was included in the TODO, but I would like to open an issue about it so we can discuss and keep track of it. I would like to be able to use btcd as a backend instead of bitcoind.

As lnd makes use of Neutrino SPV for mobile and embedded devices, it's currently not possible to have a complete test environment using Polar as there's no support for the Neutrino protocol in bitcoind yet.

I could work on this if it hasn't already been started, but I cannot tell when it will be done.

Cheers Hampus

hsjoberg avatar Feb 21 '20 16:02 hsjoberg

Yes, adding support for btcd was an original goal of mine since the beginning. It's been lower priority for me because I felt it important to focus on the features that were specifically requested by users first. It would be great if you wanted to work on this. I have no objections.

I have used btcd for my simnet lightning nodes in the past but have never written an app utilizing its RPC interface, so I do not know if there are any good npm packages available like the one we use for bitcoind. Based on my experience adding c-lightning support, I would assume that this feature will likely require some refactoring of the UI components, redux models, and services. I tried to architect the app to support multiple implementations from the start but I know it's not 100% there today.

Feel free to take a shot at implementing this and let me know if you have any questions. Thanks for your help 👍

jamaljsr avatar Feb 21 '20 17:02 jamaljsr

Hello @jamaljsr I would like to try my hand on this. But a little question: Other than writing the dockerfile for btcd, Is there a particular file in src folder I can look at because I noticed by default polar checks for the bitcoin core image over the fly

NonsoAmadi10 avatar May 10 '23 11:05 NonsoAmadi10

Hi @NonsoAmadi10, thanks for offering to give this a go. I think this will require a pretty big update to the codebase, but if you're willing to give it a shot, here's a high level list of things would need to be implemented:

  1. Create a docker image for btcd. Check out the docs to see how I do this for the other implementations now. You should be able to use the bitcoind and lnd Dockerfiles as a reference.
  2. Add a BtcdNode and a BitcoindNode interface which both extend the BitcoinNode interface. You'll likely need to also update a few other dependent interfaces, such as the BasePorts and dockerConfigs. The TS compiler should help find these
  3. Create a BtcdService class that mirrors the BitcoindService in public methods. Of course the implementation would differ. I'm not sure if there's an NPM package to simplify connecting to the node. If not, you may need to add some helper methods. I'd suggest using the REST API over gRPC, otherwise, you'll need to add a IPC proxy because gRPC can only run in the main Electron process. Ex: lndProxyServer & lndProxyClient
  4. Create a BitcoinService interface similar to LightningService which will have implementations for bitcoind and btcd.
  5. Create a BitcoinFactory class similar to LightningFactory which determines which service to use based on the node's implementation
  6. Update the store injections to include the new BitcoinFactory instead of the bitcoindService
  7. Refactor the BitcoindModel store to use the injected BitcoinFactory instead of the bitcoindService
  8. Update the bitcoin components to support BtcdNodes

I think that covers most of what needs to be done. Obviously, the devil is in the details on how to get all of this working. Feel free to ask any more questions.

jamaljsr avatar May 10 '23 22:05 jamaljsr

hey i also looking forward to thie feature

regards

penguin4238 avatar Nov 02 '23 04:11 penguin4238

Hi @jamaljsr I am back again lol. I tried my hands on this based on the information but as you know the devil is in the details. I hit a road block:

  1. How do I push the docker image to your docker hub so that I can test locally
  2. I feel I am missing something vital but I don't know what it is yet
  3. I would love to test locally but I need the docker image pushed to the hub

You can see the work I have done so far here. I know you are very busy but I feel this PR is almost ready but I am missing one fine details. Thanks in advance

NonsoAmadi10 avatar Feb 20 '24 22:02 NonsoAmadi10

Hey @NonsoAmadi10 thanks for the updates.

You do not need to push to docker hub in order to test. Just build the image and it will be available locally on your machine to use.

docker build --build-arg BTCD_VERSION=<version> -t polarlightning/btcd:<version>  .

jamaljsr avatar Feb 21 '24 01:02 jamaljsr