Skip to content

Commit cd270cd

Browse files
zoedbergphilippem
authored andcommitted
feat: support testnet4
1 parent 63ded29 commit cd270cd

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ arraydeque = "0.5.1"
3333
arrayref = "0.3.6"
3434
base64 = "0.22"
3535
bincode = "1.3.1"
36-
bitcoin = { version = "0.32", features = ["serde"] }
36+
bitcoin = { version = "0.32.4", features = ["serde"] }
3737
clap = "2.33.3"
3838
crossbeam-channel = "0.5.0"
3939
dirs = "5.0.1"

src/chain.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub enum Network {
2929
#[cfg(not(feature = "liquid"))]
3030
Testnet,
3131
#[cfg(not(feature = "liquid"))]
32+
Testnet4,
33+
#[cfg(not(feature = "liquid"))]
3234
Regtest,
3335
#[cfg(not(feature = "liquid"))]
3436
Signet,
@@ -97,6 +99,7 @@ impl Network {
9799
return vec![
98100
"mainnet".to_string(),
99101
"testnet".to_string(),
102+
"testnet4".to_string(),
100103
"regtest".to_string(),
101104
"signet".to_string(),
102105
];
@@ -123,6 +126,8 @@ pub fn bitcoin_genesis_hash(network: BNetwork) -> bitcoin::BlockHash {
123126
genesis_block(BNetwork::Bitcoin).block_hash();
124127
static ref TESTNET_GENESIS: bitcoin::BlockHash =
125128
genesis_block(BNetwork::Testnet).block_hash();
129+
static ref TESTNET4_GENESIS: bitcoin::BlockHash =
130+
genesis_block(BNetwork::Testnet4).block_hash();
126131
static ref REGTEST_GENESIS: bitcoin::BlockHash =
127132
genesis_block(BNetwork::Regtest).block_hash();
128133
static ref SIGNET_GENESIS: bitcoin::BlockHash =
@@ -131,6 +136,7 @@ pub fn bitcoin_genesis_hash(network: BNetwork) -> bitcoin::BlockHash {
131136
match network {
132137
BNetwork::Bitcoin => *BITCOIN_GENESIS,
133138
BNetwork::Testnet => *TESTNET_GENESIS,
139+
BNetwork::Testnet4 => *TESTNET4_GENESIS,
134140
BNetwork::Regtest => *REGTEST_GENESIS,
135141
BNetwork::Signet => *SIGNET_GENESIS,
136142
_ => panic!("unknown network {:?}", network),
@@ -165,6 +171,8 @@ impl From<&str> for Network {
165171
#[cfg(not(feature = "liquid"))]
166172
"testnet" => Network::Testnet,
167173
#[cfg(not(feature = "liquid"))]
174+
"testnet4" => Network::Testnet4,
175+
#[cfg(not(feature = "liquid"))]
168176
"regtest" => Network::Regtest,
169177
#[cfg(not(feature = "liquid"))]
170178
"signet" => Network::Signet,
@@ -187,6 +195,7 @@ impl From<Network> for BNetwork {
187195
match network {
188196
Network::Bitcoin => BNetwork::Bitcoin,
189197
Network::Testnet => BNetwork::Testnet,
198+
Network::Testnet4 => BNetwork::Testnet4,
190199
Network::Regtest => BNetwork::Regtest,
191200
Network::Signet => BNetwork::Signet,
192201
}
@@ -199,6 +208,7 @@ impl From<BNetwork> for Network {
199208
match network {
200209
BNetwork::Bitcoin => Network::Bitcoin,
201210
BNetwork::Testnet => Network::Testnet,
211+
BNetwork::Testnet4 => Network::Testnet4,
202212
BNetwork::Regtest => Network::Regtest,
203213
BNetwork::Signet => Network::Signet,
204214
_ => panic!("unknown network {:?}", network),

src/config.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,19 @@ impl Config {
125125
.arg(
126126
Arg::with_name("electrum_rpc_addr")
127127
.long("electrum-rpc-addr")
128-
.help("Electrum server JSONRPC 'addr:port' to listen on (default: '127.0.0.1:50001' for mainnet, '127.0.0.1:60001' for testnet and '127.0.0.1:60401' for regtest)")
128+
.help("Electrum server JSONRPC 'addr:port' to listen on (default: '127.0.0.1:50001' for mainnet, '127.0.0.1:60001' for testnet3, '127.0.0.1:40001' for testnet4 and '127.0.0.1:60401' for regtest)")
129129
.takes_value(true),
130130
)
131131
.arg(
132132
Arg::with_name("http_addr")
133133
.long("http-addr")
134-
.help("HTTP server 'addr:port' to listen on (default: '127.0.0.1:3000' for mainnet, '127.0.0.1:3001' for testnet and '127.0.0.1:3002' for regtest)")
134+
.help("HTTP server 'addr:port' to listen on (default: '127.0.0.1:3000' for mainnet, '127.0.0.1:3001' for testnet3 and '127.0.0.1:3004' for testnet4 and '127.0.0.1:3002' for regtest)")
135135
.takes_value(true),
136136
)
137137
.arg(
138138
Arg::with_name("daemon_rpc_addr")
139139
.long("daemon-rpc-addr")
140-
.help("Bitcoin daemon JSONRPC 'addr:port' to connect (default: 127.0.0.1:8332 for mainnet, 127.0.0.1:18332 for testnet and 127.0.0.1:18443 for regtest)")
140+
.help("Bitcoin daemon JSONRPC 'addr:port' to connect (default: 127.0.0.1:8332 for mainnet, 127.0.0.1:18332 for testnet3 and 127.0.0.1:48332 for testnet4 and 127.0.0.1:18443 for regtest)")
141141
.takes_value(true),
142142
)
143143
.arg(
@@ -149,7 +149,7 @@ impl Config {
149149
.arg(
150150
Arg::with_name("monitoring_addr")
151151
.long("monitoring-addr")
152-
.help("Prometheus monitoring 'addr:port' to listen on (default: 127.0.0.1:4224 for mainnet, 127.0.0.1:14224 for testnet and 127.0.0.1:24224 for regtest)")
152+
.help("Prometheus monitoring 'addr:port' to listen on (default: 127.0.0.1:4224 for mainnet, 127.0.0.1:14224 for testnet3 and 127.0.0.1:44224 for testnet4 and 127.0.0.1:24224 for regtest)")
153153
.takes_value(true),
154154
)
155155
.arg(
@@ -282,6 +282,8 @@ impl Config {
282282
#[cfg(not(feature = "liquid"))]
283283
Network::Testnet => 18332,
284284
#[cfg(not(feature = "liquid"))]
285+
Network::Testnet4 => 48332,
286+
#[cfg(not(feature = "liquid"))]
285287
Network::Regtest => 18443,
286288
#[cfg(not(feature = "liquid"))]
287289
Network::Signet => 38332,
@@ -297,6 +299,8 @@ impl Config {
297299
#[cfg(not(feature = "liquid"))]
298300
Network::Testnet => 60001,
299301
#[cfg(not(feature = "liquid"))]
302+
Network::Testnet4 => 40001,
303+
#[cfg(not(feature = "liquid"))]
300304
Network::Regtest => 60401,
301305
#[cfg(not(feature = "liquid"))]
302306
Network::Signet => 60601,
@@ -314,6 +318,8 @@ impl Config {
314318
#[cfg(not(feature = "liquid"))]
315319
Network::Testnet => 3001,
316320
#[cfg(not(feature = "liquid"))]
321+
Network::Testnet4 => 3004,
322+
#[cfg(not(feature = "liquid"))]
317323
Network::Regtest => 3002,
318324
#[cfg(not(feature = "liquid"))]
319325
Network::Signet => 3003,
@@ -331,6 +337,8 @@ impl Config {
331337
#[cfg(not(feature = "liquid"))]
332338
Network::Testnet => 14224,
333339
#[cfg(not(feature = "liquid"))]
340+
Network::Testnet4 => 44224,
341+
#[cfg(not(feature = "liquid"))]
334342
Network::Regtest => 24224,
335343
#[cfg(not(feature = "liquid"))]
336344
Network::Signet => 54224,
@@ -493,6 +501,8 @@ pub fn get_network_subdir(network: Network) -> Option<&'static str> {
493501
#[cfg(not(feature = "liquid"))]
494502
Network::Testnet => Some("testnet3"),
495503
#[cfg(not(feature = "liquid"))]
504+
Network::Testnet4 => Some("testnet4"),
505+
#[cfg(not(feature = "liquid"))]
496506
Network::Regtest => Some("regtest"),
497507
#[cfg(not(feature = "liquid"))]
498508
Network::Signet => Some("signet"),

0 commit comments

Comments
 (0)