Skip to content

Support signet and testnet4 deployments - #307

Merged
prusnak merged 2 commits into
bitcoinix:masterfrom
viberaven:support-public-test-networks
Nov 23, 2026
Merged

prusnak merged 2 commits into
bitcoinix:masterfrom
viberaven:support-public-test-networks

Conversation

@viberaven

@viberaven viberaven commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Target release v0.2.0. Follows #253 and addresses #17 for signet and testnet4.

Set services.bitcoind.network to "signet" or "testnet4" to configure Bitcoin Core and its dependent services. Core Lightning, electrs, Fulcrum, Unbeholden Wallet, Mempool and BTCPay Server can use either network. Evaluation rejects LND on both because the packaged lndinit cannot initialize those wallets. CLBOSS and Trustedcoin are rejected on testnet4.

The configuration guide warns that switching networks in place reuses the Fulcrum, Mempool, BTCPay Server and NBXplorer databases. Use separate deployments to keep their data apart.

On regtest, the generated Tor mapping now forwards port 18444 to local port 18445. Users who maintain their own mapping can update its target or keep services.bitcoind.onionPort = 8334;. The 0.2.0 migration notice targets nodes using the default.

Verification

  • Offline signet and testnet4 VMs verified genesis hashes, Core Lightning network selection, NBXplorer cookie access and Mempool frontend settings.
  • A regtest VM verified that bitcoind listens on 18445. Evaluation tests cover the generated mapping, explicit overrides and incompatible service combinations.
  • The release-note validator and documentation build passed with the 0.2.0 drafts.

@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: feature New capability or service labels Nov 20, 2026
@seberm seberm added this to the v0.2.1 milestone Nov 20, 2026

@sebsgent sebsgent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should:

  • The warning in docs/configuration.md ("Use separate deployments to keep nodes on different networks … services such as Fulcrum, Mempool and BTCPay Server reuse their configured databases") is the main risk of this feature, but it reads as a closing remark after the compatibility list and is easy to miss. Switching an existing node's services.bitcoind.network in place keeps those services' existing databases, e.g. mainnet BTCPay stores and xpubs carry over to signet, while Bitcoin Core, Core Lightning and electrs move to per-network dirs. Please make it stand out (the docs already use admonitions, e.g. > [!NOTE] in docs/install.md) and say what happens on an in-place switch. The release note could link to it too.

Tested: merged onto current master, checks.x86_64-linux.module-config passes; CI covers the new signet/testnet4 VM scenarios. Checked that the pinned lndinit's --network choices exclude signet/testnet4, and that mainnet config is unchanged apart from the explicit --network=mainnet on wallet init.

Assisted-by: Claude Code (Claude Opus 5.5)

@viberaven viberaven closed this Nov 20, 2026
@viberaven
viberaven force-pushed the support-public-test-networks branch from e1223d6 to cbc2310 Compare November 20, 2026 22:58
@viberaven viberaven reopened this Nov 20, 2026
@prusnak prusnak modified the milestones: v0.2.1, v0.2.0 Nov 20, 2026
@viberaven

Copy link
Copy Markdown
Contributor Author

@sebsgent Thanks for the review. In 678eff6 I moved the warning to the top of the Bitcoin network section, before the configuration example. It now recommends a separate deployment for each network and explains what happens if you change services.bitcoind.network on an existing node. Updated warning

Bitcoin Core, Core Lightning and electrs switch to per-network directories. Fulcrum, Mempool, BTCPay Server and NBXplorer reuse their existing databases. I included your example explicitly: switching a BTCPay node from mainnet to signet leaves its mainnet stores and xpubs in the database used on signet.

The 0.2.0 release note now links directly to the warning. I also checked that the warning appears in the built guide. Release note

@ostermayer

Copy link
Copy Markdown
Collaborator

This overlaps with #305 in the bitcoind preStart. Both move the blocks chmod to the network dir, and #305 adds a local networkDir with the same value. #305 already works on any non-mainnet network. If this merges first, I'll rebase #305 onto services.bitcoind.networkDir and change its "on regtest" wording to cover signet and testnet4.

@ostermayer ostermayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked each module that a signet or testnet4 node can now enable against the pinned upstream versions. That covers the network names, ports, data dirs, the NBXplorer cookie dir, the Mempool frontend, the lnd and plugin assertions with indirect enables, and the regtest onion notice. Those hold. Three things don't, and the first two are about the in-place switch that the warning describes.

  • The backups follow only the current network, so an in-place switch puts the old network's data back in. modules/backups.nix excludes lightningd.sqlite3 only in the current network dir, but it includes all of /var/lib/clightning. On signet the file list excludes /var/lib/clightning/signet/lightningd.sqlite3 and keeps /var/lib/clightning/bitcoin/lightningd.sqlite3. The 0.2.0 backups change took that file out because a restored old copy can lose the channel funds. The bulk data has the same gap. On mainnet the list doesn't exclude signet/blocks or testnet4/blocks, so a node that ran signet before backs up the whole signet chain. Please exclude the Core Lightning database in every dir below clightning.dataDir (a * for the network dir in the duplicity file list does that), and put the signet and testnet4 dirs in bulkDataDirs on every network.
  • With services.clightning.replication, an in-place switch overwrites the old network's replica. modules/clightning-replication.nix puts the replica at <dir>/lightningd.sqlite3 on every network. On the first start on signet, Core Lightning finds a replica with another data_version and copies the new, empty database over it (db/db_sqlite3.c). So the mainnet replica is gone while the node runs signet. Please keep the replica apart per network, for example lightningd-signet.sqlite3 on the new networks, which keeps the mainnet path. Or add it to the warning.
  • The testnet4 blockexplorerlink line in modules/btcpayserver.nix has no effect on a bitcoinix node. BTCPay sets it in BlockExplorerLinkStartupTask and then calls RefreshTransactionLinkTemplates. Once PoliciesSettings is stored, that call resets every link to the stored override or the built-in default. btcpayserver-admin creates the first admin through the Greenfield API, and that stores PoliciesSettings because disable-registration defaults to true. So every start falls back to https://mempool.space/testnet/tx/{0}. I checked this in the testnet4 VM. The store reports page lists the testnet3 link. When I delete the stored policies and restart BTCPay, it lists the testnet4 link. I'd drop the line and point testnet4 users to the block explorer setting in the server policies. The real fix is upstream in BitcoinPlugin.cs, which picks the testnet3 link for every chain that isn't mainnet or signet.

@viberaven

Copy link
Copy Markdown
Contributor Author

@ostermayer Thanks for tracing these. I addressed all three points in 60b01636.

  • Backups now exclude lightningd.sqlite3 and its SQLite sidecars in every Core Lightning network directory, plus the managed local replicas. The default backup also skips signet and testnet4 blocks, chainstate, and indexes regardless of the active network. I checked the duplicity archive in a VM. It kept the inactive network’s hsm_secret and omitted its database, WAL, and block data.
  • Live replication now writes lightningd-signet.sqlite3 on signet and lightningd-testnet4.sqlite3 on testnet4. Mainnet and regtest keep their existing lightningd.sqlite3 filename and need separate destinations. The replication VM switched from mainnet to signet to testnet4 and verified the checksums of all earlier replicas after each switch.
  • BTCPay Server reloads the explorer URL from its stored policy, so I removed the ineffective blockexplorerlink override. The guide now directs testnet4 admins to Server Settings → Policies → Block Explorers. I set BTC-CHAIN to https://mempool.space/testnet4/tx/{0} there on a testnet4 VM and verified that the setting survived a restart.

@prusnak
prusnak force-pushed the support-public-test-networks branch from 60b0163 to 08e3af6 Compare November 21, 2026 23:00
seberm
seberm previously approved these changes Nov 21, 2026

@seberm seberm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No must/should items. The earlier review points and the backup, replica and BTCPay points from ostermayer's review are resolved in 678eff6 and 60b0163.

Tested: merged onto current master, checks.x86_64-linux.module-config passes, and the clightning-replication VM test (not in CI) passes, including the new mainnet → signet → testnet4 replica checksum steps. Checked that the per-network P2P, RPC and onion ports match Bitcoin Core's defaults.

Assisted-by: Claude Code (Claude Opus 5.5)

Select public test networks through services.bitcoind.network and reject incompatible LND and Core Lightning plugin configurations at evaluation. Document which services reuse their databases on an in-place switch. Align the regtest onion target with Bitcoin Core and cover the override in the 0.2.0 upgrade notes.

Assisted-by: OpenAI Codex (GPT-6.2 Astra)
Exclude inactive Core Lightning databases, SQLite sidecars and local replicas
from backups. Apply the bulk-data setting to mainnet, signet and testnet4
regardless of the selected network.

Give signet and testnet4 distinct live replica files. Exercise both network
switches in the replication VM and check the contents of a duplicity archive.

BTCPay reloads the block explorer from its stored server policies. Document
the testnet4 policy setting and remove the ineffective config override.

Assisted-by: OpenAI Codex (GPT-6.2 Astra)
@viberaven
viberaven force-pushed the support-public-test-networks branch from 08e3af6 to 0767104 Compare November 23, 2026 15:13
@github-actions github-actions Bot removed the status: rebase needed Merge conflicts need to be resolved label Nov 23, 2026
@prusnak
prusnak merged commit a3bbac6 into bitcoinix:master Nov 23, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: feature New capability or service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants