From 7a47ca044f730ea2a332b933ff94a4de07e7edc0 Mon Sep 17 00:00:00 2001 From: oskarszoon <1449115+oskarszoon@users.noreply.github.com> Date: Wed, 2 Jul 2025 15:32:20 +0200 Subject: [PATCH 1/4] Add support for Testnet --- README.md | 6 ++++++ config/load.go | 8 ++++++++ config/p2p_network_params.go | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a785603..73ef4be0 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,12 @@ To override history_max in websocket config, use the path with "_" as a path del BHS_HISTORY_MAX=300 ``` +To connect BHS to Testnet, you can use the following environment variable: + +```bash +BHS_P2P_CHAIN_NET_TYPE=testnet +```` +
diff --git a/config/load.go b/config/load.go index 611160d4..941c93cc 100644 --- a/config/load.go +++ b/config/load.go @@ -35,6 +35,14 @@ func Load(cfg *AppConfig) (*AppConfig, *zerolog.Logger, error) { } setP2PLogger(logger) + + // Update ActiveNetParams based on the loaded configuration + if cfg.P2P != nil { + ActiveNetParams = cfg.P2P.GetNetParams() + // Update checkpoints to use the new network params + Checkpoints = ActiveNetParams.Checkpoints + } + return cfg, logger, nil } diff --git a/config/p2p_network_params.go b/config/p2p_network_params.go index aed40db5..59298ea1 100644 --- a/config/p2p_network_params.go +++ b/config/p2p_network_params.go @@ -35,6 +35,7 @@ func (c *P2PConfig) GetNetParams() *chaincfg.Params { } // ActiveNetParams is a pointer to the parameters specific to the -// currently active bitcoin network. +// currently active bitcoin network. This is initialized to MainNet +// but will be updated based on the P2P config when the configuration is loaded. // TODO: remove this after switching to new p2p server. var ActiveNetParams = &chaincfg.MainNetParams From 4c1dc8c94f36d0e4af0176bc271dd7600420a4f1 Mon Sep 17 00:00:00 2001 From: oskarszoon <1449115+oskarszoon@users.noreply.github.com> Date: Wed, 2 Jul 2025 15:32:36 +0200 Subject: [PATCH 2/4] Switch to same seed nodes that SVNode is using --- internal/chaincfg/params.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/chaincfg/params.go b/internal/chaincfg/params.go index f7919c28..bdb73b04 100644 --- a/internal/chaincfg/params.go +++ b/internal/chaincfg/params.go @@ -224,7 +224,9 @@ var MainNetParams = Params{ Net: wire.MainNet, DefaultPort: "8333", DNSSeeds: []DNSSeed{ - {"seed-nodes.bsvb.tech", true}, + {"seed.bitcoinsv.io", true}, + {"seed.satoshisvision.network", true}, + {"seed.bitcoinseed.directory", true}, }, // Chain parameters @@ -367,8 +369,9 @@ var TestNet3Params = Params{ Net: wire.TestNet3, DefaultPort: "18333", DNSSeeds: []DNSSeed{ - {"testnet-seed.metasv.io", true}, - {"testnet-btccash-seeder.bitcoinunlimited.info", true}, + {"testnet-seed.bitcoinsv.io", true}, + {"testnet-seed.bitcoincloud.net", true}, + {"testnet-seed.bitcoinseed.directory", true}, }, // Chain parameters From c154d7d7a42608b948ef4fdb3cea0bcaa4fd7aa7 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 2 Jul 2025 13:33:36 +0000 Subject: [PATCH 3/4] chore: update generated files --- config/load.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/load.go b/config/load.go index 941c93cc..5c36606e 100644 --- a/config/load.go +++ b/config/load.go @@ -35,14 +35,14 @@ func Load(cfg *AppConfig) (*AppConfig, *zerolog.Logger, error) { } setP2PLogger(logger) - + // Update ActiveNetParams based on the loaded configuration if cfg.P2P != nil { ActiveNetParams = cfg.P2P.GetNetParams() // Update checkpoints to use the new network params Checkpoints = ActiveNetParams.Checkpoints } - + return cfg, logger, nil } From b31c774a327bf26747e2745709dd3c78c6035cb8 Mon Sep 17 00:00:00 2001 From: oskarszoon <1449115+oskarszoon@users.noreply.github.com> Date: Wed, 2 Jul 2025 15:39:32 +0200 Subject: [PATCH 4/4] Fix the seed test --- internal/chaincfg/params_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/chaincfg/params_test.go b/internal/chaincfg/params_test.go index 13e73c8d..4ba13e56 100644 --- a/internal/chaincfg/params_test.go +++ b/internal/chaincfg/params_test.go @@ -37,7 +37,9 @@ func TestMustRegisterPanic(t *testing.T) { // TestSeeds ensures the right seeds are defined. func TestSeeds(t *testing.T) { expectedSeeds := []DNSSeed{ - {"seed-nodes.bsvb.tech", true}, + {"seed.bitcoinsv.io", true}, + {"seed.satoshisvision.network", true}, + {"seed.bitcoinseed.directory", true}, } if MainNetParams.DNSSeeds == nil {