lightning-power-users / node-launcher

Easiest Bitcoin Lightning desktop app, for Windows, macOS, and Linux
MIT License
358 stars 67 forks source link

Allow for custom ports to be specified for bitcoin RPC #146

Open hkrugersa opened 5 years ago

hkrugersa commented 5 years ago

It looks like currently the Bitcoin's RPC ports are hard-coded to the defaults. I see that issue #49 addressed this by providing the capability for custom LND ports, but it seems that the Bitcoin ports were overseen and always refer to the hard-coded values.

This should be relatively easy to fix by just checking the relevant configuration file for the rpcport value. However, I see from version 0.17.0 onwards the configuration file supports that you can specify parameters for mainnet, testnet and regtest all in the same file with a section tag like [main] or [test] or [regtest].

The following section from the release documentation is of interest:(https://bitcoin.org/en/release/v0.17.0#configuration-sections-for-testnet-and-regtest)

If the following options are not in a section, they will only apply to mainnet: addnode=, connect=, port=, bind=, rpcport=, rpcbind= and wallet=. The options to choose a network (regtest= and testnet=) must be specified outside of sections.

Thus if the section isn't specified in the file those options will be ignored for testnet and regtest. Hence, it is necessary to populate the [test] section tag at the beginning of the testnet configuration file for bitcoin version 0.17.0 onwards.

I can have a look at this and submit a pull request once I'm done, but I need to know whether the assumption can be made that the bitcoin node will always be the newest version (or at least > 0.17.0) or should the configuration file class check the bitcoin version before inserting the [test] or [main] section tag?

hkrugersa commented 5 years ago

I've forked the code and made the relevant changes, which can be viewed at

https://github.com/PierreRochard/node-launcher/compare/master...hkrugersa:master

Please let me know if there are any problems or if you require any additional changes to be made.

In the configuration_file.py I've had to pass in a network keyword argument for the class to know whether it is for mainnet or testnet. It is a bit ugly, so please let me know if you're happy with that or if you have any other ideas of how to approach it.

I've also noticed that in the PortsLayout widget, the application needs a restart for the ports to refresh (if changed in the text file midway). I'm not sure why that would be, but I'm guessing this is due to the fact that the variables are only set on initialization of the widget and when you click to close the advanced window it doesn't actually close it, but merely hides it. I'll have a look if I can find a way to fix this, but please let me know if you have any ideas.

PierreRochard commented 5 years ago

Thank you @hkrugersa! This is a great improvement!

Changing the PortsLayout widget should be similar to how the Data Directory widget changes when a new directory is selected, so take a look at that!

Unfortunately I won't be able to dig into this until Friday, happy hacking!

hkrugersa commented 5 years ago

Thanks Pierre!

Just an update, I'm almost done with the changes. Just updating the tests and doing some final testing. I decided to use the QFileSystemWatcher object to monitor the relevant files in the Configurationfile object. This way you can connect the signals to all relevant objects that need to be notified if the lnd or bitcoin config files changed. It also means you can change the file outside of the application without going through the advanced widget and it would still work.

Hopefully I'll be able to finish up this evening still, but I'll keep you updated.

PierreRochard commented 5 years ago

That is really awesome @hkrugersa thank you! Huge improvement

hkrugersa commented 5 years ago

Hi @PierreRochard,

Apologies for the delays, but have been trying to catch up with all the changes you guys have been making to the codebase :-) Well done on all the work by the way.

Just an update from my side, I'm pretty much done with the code on my end - but would like to ask a few questions before I submit the pull request to make sure I've covered everything:

hkrugersa commented 5 years ago

My ideas for what constitutes an invalid configuration file for bitcoin:

hkrugersa commented 5 years ago

I'm a bit in the dark as to all the lnd configurations, but I'll give it a shot as to what could constitute an invalid lnd configuration file:

hkrugersa commented 5 years ago

Additional thoughts:

hkrugersa commented 5 years ago

For first pass at critical bitcoin configuration file changes that require restart (that the user will be notified of) include the following:

hkrugersa commented 5 years ago

Also my basic rules are that anything that requires a bitcoin restart used by lnd, requires a lnd restart

PierreRochard commented 5 years ago

Thank you @hkrugersa! Please submit a pull request so I can comment on the code, happy to help with that process or ping Justin!

PierreRochard commented 5 years ago
  • txindex=0 (I'm assuming this would defeat the purpose of what node-launcher is meant for)

txindex is disabled if the user is pruning, and LND is compatible with no txindex, it's just a little slower