autodetect from bitcoin.conf file with network set #2037
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Specter team!
When using a
bitcoin.conf
file with remote Bitcoin node configurations, Specter wouldn't auto-detect the right connection configs when not mainnet and more than only mainnet configs. For some reason, it was ignoring the network when set in the config file. For example, if bitcoin.conf file was:Specter kept using port 8332, which is the default port in its config. It was reading the configurations for all networks in the config file even when a network was specified, like in the example above. Also, when rotating between the different network configs trying to connect to the node, it was exiting on the first failure instead of continue trying with the other network configs.
Maybe I misunderstood the rationale behind ignoring the network config and keeping trying for every network config found in the config file, sorry if that's the case. Ignoring the network config makes it impossible to run several nodes on the same machine on different ports and use the auto-detect feature. For example, if I run mainnet, testnet and regtest nodes on the same
bitcoin
host, current algorithm would only connect to the first one responding. I couldn't switch node by simply replacingregtest=1
bytestnet=1
in the bitcoin.conf file, for instance.This PR only changes rpc.py. What it does:
BrokenCoreConnectionException
inautodetect_rpc_confs
on connection failure so that it continues trying to connect when there are several networks in the confs;regtest=1
for example) to set the network and uses the network-specific config instead of trying everything found in the config file;Let me know if I'm confused :) or if you see improvements or a better way to do this. I tried to minimize the changes for this PR.