@@ -44,6 +44,22 @@ impl BitcoinCoreController {
44
44
}
45
45
}
46
46
47
+ fn add_rpc_cli_args ( & self , command : & mut Command ) {
48
+ command. arg ( format ! ( "-rpcport={}" , self . config. burnchain. rpc_port) ) ;
49
+
50
+ match (
51
+ & self . config . burnchain . username ,
52
+ & self . config . burnchain . password ,
53
+ ) {
54
+ ( Some ( username) , Some ( password) ) => {
55
+ command
56
+ . arg ( format ! ( "-rpcuser={username}" ) )
57
+ . arg ( format ! ( "-rpcpassword={password}" ) ) ;
58
+ }
59
+ _ => { }
60
+ }
61
+ }
62
+
47
63
pub fn start_bitcoind ( & mut self ) -> BitcoinResult < ( ) > {
48
64
std:: fs:: create_dir_all ( & self . config . get_burnchain_path_str ( ) ) . unwrap ( ) ;
49
65
@@ -58,30 +74,16 @@ impl BitcoinCoreController {
58
74
. arg ( "-server=1" )
59
75
. arg ( "-listenonion=0" )
60
76
. arg ( "-rpcbind=127.0.0.1" )
61
- . arg ( & format ! ( "-port={}" , self . config. burnchain. peer_port) )
62
- . arg ( & format ! (
63
- "-datadir={}" ,
64
- self . config. get_burnchain_path_str( )
65
- ) )
66
- . arg ( & format ! ( "-rpcport={}" , self . config. burnchain. rpc_port) ) ;
77
+ . arg ( format ! ( "-port={}" , self . config. burnchain. peer_port) )
78
+ . arg ( format ! ( "-datadir={}" , self . config. get_burnchain_path_str( ) ) ) ;
67
79
68
- match (
69
- & self . config . burnchain . username ,
70
- & self . config . burnchain . password ,
71
- ) {
72
- ( Some ( username) , Some ( password) ) => {
73
- command
74
- . arg ( & format ! ( "-rpcuser={}" , username) )
75
- . arg ( & format ! ( "-rpcpassword={}" , password) ) ;
76
- }
77
- _ => { }
78
- }
80
+ self . add_rpc_cli_args ( & mut command) ;
79
81
80
- eprintln ! ( "bitcoind spawn: {:?}" , command ) ;
82
+ eprintln ! ( "bitcoind spawn: {command :?}" ) ;
81
83
82
84
let mut process = match command. spawn ( ) {
83
85
Ok ( child) => child,
84
- Err ( e) => return Err ( BitcoinCoreError :: SpawnFailed ( format ! ( "{:?}" , e ) ) ) ,
86
+ Err ( e) => return Err ( BitcoinCoreError :: SpawnFailed ( format ! ( "{e :?}" ) ) ) ,
85
87
} ;
86
88
87
89
let mut out_reader = BufReader :: new ( process. stdout . take ( ) . unwrap ( ) ) ;
@@ -108,17 +110,15 @@ impl BitcoinCoreController {
108
110
pub fn stop_bitcoind ( & mut self ) -> Result < ( ) , BitcoinCoreError > {
109
111
if let Some ( _) = self . bitcoind_process . take ( ) {
110
112
let mut command = Command :: new ( "bitcoin-cli" ) ;
111
- command
112
- . stdout ( Stdio :: piped ( ) )
113
- . arg ( "-rpcconnect=127.0.0.1" )
114
- . arg ( "-rpcport=8332" )
115
- . arg ( "-rpcuser=neon-tester" )
116
- . arg ( "-rpcpassword=neon-tester-pass" )
117
- . arg ( "stop" ) ;
113
+ command. stdout ( Stdio :: piped ( ) ) . arg ( "-rpcconnect=127.0.0.1" ) ;
114
+
115
+ self . add_rpc_cli_args ( & mut command) ;
116
+
117
+ command. arg ( "stop" ) ;
118
118
119
119
let mut process = match command. spawn ( ) {
120
120
Ok ( child) => child,
121
- Err ( e) => return Err ( BitcoinCoreError :: SpawnFailed ( format ! ( "{:?}" , e ) ) ) ,
121
+ Err ( e) => return Err ( BitcoinCoreError :: SpawnFailed ( format ! ( "{e :?}" ) ) ) ,
122
122
} ;
123
123
124
124
let mut out_reader = BufReader :: new ( process. stdout . take ( ) . unwrap ( ) ) ;
@@ -127,7 +127,7 @@ impl BitcoinCoreController {
127
127
if bytes_read == 0 {
128
128
break ;
129
129
}
130
- eprintln ! ( "{}" , & line ) ;
130
+ eprintln ! ( "{line}" ) ;
131
131
}
132
132
}
133
133
Ok ( ( ) )
0 commit comments