@@ -33,6 +33,7 @@ pub struct Config {
3333 // See below for the documentation of each field:
3434 pub log : stderrlog:: StdErrLog ,
3535 pub network_type : Network ,
36+ pub magic : Option < u32 > ,
3637 pub db_path : PathBuf ,
3738 pub daemon_dir : PathBuf ,
3839 pub blocks_dir : PathBuf ,
@@ -137,6 +138,12 @@ impl Config {
137138 . help ( & network_help)
138139 . takes_value ( true ) ,
139140 )
141+ . arg (
142+ Arg :: with_name ( "magic" )
143+ . long ( "magic" )
144+ . default_value ( "" )
145+ . takes_value ( true ) ,
146+ )
140147 . arg (
141148 Arg :: with_name ( "electrum_rpc_addr" )
142149 . long ( "electrum-rpc-addr" )
@@ -328,6 +335,10 @@ impl Config {
328335
329336 let network_name = m. value_of ( "network" ) . unwrap_or ( "mainnet" ) ;
330337 let network_type = Network :: from ( network_name) ;
338+ let magic: Option < u32 > = m
339+ . value_of ( "magic" )
340+ . filter ( |s| !s. is_empty ( ) )
341+ . map ( |s| u32:: from_str_radix ( s, 16 ) . expect ( "invalid network magic" ) ) ;
331342 let db_dir = Path :: new ( m. value_of ( "db_dir" ) . unwrap_or ( "./db" ) ) ;
332343 let db_path = db_dir. join ( network_name) ;
333344
@@ -353,6 +364,8 @@ impl Config {
353364 Network :: Regtest => 18443 ,
354365 #[ cfg( not( feature = "liquid" ) ) ]
355366 Network :: Signet => 38332 ,
367+ #[ cfg( not( feature = "liquid" ) ) ]
368+ Network :: Testnet4 => 48332 ,
356369
357370 #[ cfg( feature = "liquid" ) ]
358371 Network :: Liquid => 7041 ,
@@ -365,6 +378,8 @@ impl Config {
365378 #[ cfg( not( feature = "liquid" ) ) ]
366379 Network :: Testnet => 60001 ,
367380 #[ cfg( not( feature = "liquid" ) ) ]
381+ Network :: Testnet4 => 40001 ,
382+ #[ cfg( not( feature = "liquid" ) ) ]
368383 Network :: Regtest => 60401 ,
369384 #[ cfg( not( feature = "liquid" ) ) ]
370385 Network :: Signet => 60601 ,
@@ -385,6 +400,8 @@ impl Config {
385400 Network :: Regtest => 3002 ,
386401 #[ cfg( not( feature = "liquid" ) ) ]
387402 Network :: Signet => 3003 ,
403+ #[ cfg( not( feature = "liquid" ) ) ]
404+ Network :: Testnet4 => 3004 ,
388405
389406 #[ cfg( feature = "liquid" ) ]
390407 Network :: Liquid => 3000 ,
@@ -401,6 +418,8 @@ impl Config {
401418 #[ cfg( not( feature = "liquid" ) ) ]
402419 Network :: Regtest => 24224 ,
403420 #[ cfg( not( feature = "liquid" ) ) ]
421+ Network :: Testnet4 => 44224 ,
422+ #[ cfg( not( feature = "liquid" ) ) ]
404423 Network :: Signet => 54224 ,
405424
406425 #[ cfg( feature = "liquid" ) ]
@@ -449,6 +468,8 @@ impl Config {
449468 #[ cfg( not( feature = "liquid" ) ) ]
450469 Network :: Testnet => daemon_dir. push ( "testnet3" ) ,
451470 #[ cfg( not( feature = "liquid" ) ) ]
471+ Network :: Testnet4 => daemon_dir. push ( "testnet4" ) ,
472+ #[ cfg( not( feature = "liquid" ) ) ]
452473 Network :: Regtest => daemon_dir. push ( "regtest" ) ,
453474 #[ cfg( not( feature = "liquid" ) ) ]
454475 Network :: Signet => daemon_dir. push ( "signet" ) ,
@@ -486,6 +507,7 @@ impl Config {
486507 let config = Config {
487508 log,
488509 network_type,
510+ magic,
489511 db_path,
490512 daemon_dir,
491513 blocks_dir,
0 commit comments