Add Bitcoin network configuration support via NETWORK environment variable in bitcoin.conf #3
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.
This PR adds support for configuring the Bitcoin network via a
NETWORKenvironment variable in thedocker/knots/entrypoint.shscript, addressing the need for easy network switching between mainnet, testnet, and regtest environments.Changes Made
Network Configuration: Added
NETWORKenvironment variable support with three valid values:mainnet(default) - no additional configuration neededtestnet- addstestnet=1to bitcoin.confregtest- addsregtest=1to bitcoin.confConfiguration File Approach: Network settings are written directly to the bitcoin.conf file instead of using command line flags, following Bitcoin Core best practices and configuration management standards
Input Validation: Added early validation that exits with a descriptive error message if an invalid network value is provided
Documentation: Enhanced script comments to document the new network configuration feature and usage
Usage
Users can now configure the Bitcoin network in their
docker-compose.yaml:Or via direct environment variable:
Backward Compatibility
The changes are fully backward compatible:
NETWORKis not set, defaults tomainnet(existing behavior)Implementation Details
The implementation writes network configuration directly to the bitcoin.conf file:
testnet=1for testnet moderegtest=1for regtest modeThis approach is cleaner, more maintainable, and follows Bitcoin Core's standard configuration file approach rather than relying on command line flags. It ensures all configuration is centralized in the bitcoin.conf file for easier debugging and management.
This enables developers to easily switch between networks for testing and development without modifying configuration files or rebuilding containers.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.