Skip to content

Commit

Permalink
Support testnet4
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Oct 29, 2024
1 parent bd6f93a commit 2041b76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/config_specification.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ doc = "JSONRPC authentication cookie file (default: ~/.bitcoin/.cookie)"
name = "network"
type = "crate::config::BitcoinNetwork"
convert_into = "::bitcoin::Network"
doc = "Select Bitcoin network type ('bitcoin', 'testnet', 'regtest' or 'signet')"
doc = "Select Bitcoin network type ('bitcoin', 'testnet', 'testnet4', 'regtest' or 'signet')"
default = "Default::default()"

[[param]]
Expand Down
11 changes: 10 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ impl FromStr for BitcoinNetwork {

impl ::configure_me::parse_arg::ParseArgFromStr for BitcoinNetwork {
fn describe_type<W: fmt::Write>(mut writer: W) -> fmt::Result {
write!(writer, "either 'bitcoin', 'testnet', 'regtest' or 'signet'")
write!(
writer,
"either 'bitcoin', 'testnet', 'testnet4', 'regtest' or 'signet'"
)
}
}

Expand Down Expand Up @@ -205,6 +208,7 @@ impl Config {
let db_subdir = match config.network {
Network::Bitcoin => "bitcoin",
Network::Testnet => "testnet",
Network::Testnet4 => "testnet4",
Network::Regtest => "regtest",
Network::Signet => "signet",
unsupported => unsupported_network(unsupported),
Expand All @@ -215,27 +219,31 @@ impl Config {
let default_daemon_rpc_port = match config.network {
Network::Bitcoin => 8332,
Network::Testnet => 18332,
Network::Testnet4 => 48332,
Network::Regtest => 18443,
Network::Signet => 38332,
unsupported => unsupported_network(unsupported),
};
let default_daemon_p2p_port = match config.network {
Network::Bitcoin => 8333,
Network::Testnet => 18333,
Network::Testnet4 => 48333,
Network::Regtest => 18444,
Network::Signet => 38333,
unsupported => unsupported_network(unsupported),
};
let default_electrum_port = match config.network {
Network::Bitcoin => 50001,
Network::Testnet => 60001,
Network::Testnet4 => 40001,
Network::Regtest => 60401,
Network::Signet => 60601,
unsupported => unsupported_network(unsupported),
};
let default_monitoring_port = match config.network {
Network::Bitcoin => 4224,
Network::Testnet => 14224,
Network::Testnet4 => 44224,
Network::Regtest => 24224,
Network::Signet => 34224,
unsupported => unsupported_network(unsupported),
Expand Down Expand Up @@ -283,6 +291,7 @@ impl Config {
match config.network {
Network::Bitcoin => (),
Network::Testnet => config.daemon_dir.push("testnet3"),
Network::Testnet4 => config.daemon_dir.push("testnet4"),
Network::Regtest => config.daemon_dir.push("regtest"),
Network::Signet => config.daemon_dir.push("signet"),
unsupported => unsupported_network(unsupported),
Expand Down

0 comments on commit 2041b76

Please sign in to comment.