@@ -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
@@ -59,22 +75,11 @@ impl BitcoinCoreController {
59
75
. arg ( "-listenonion=0" )
60
76
. arg ( "-rpcbind=127.0.0.1" )
61
77
. arg ( format ! ( "-port={}" , self . config. burnchain. peer_port) )
62
- . arg ( format ! ( "-datadir={}" , self . config. get_burnchain_path_str( ) ) )
63
- . arg ( format ! ( "-rpcport={}" , self . config. burnchain. rpc_port) ) ;
78
+ . arg ( format ! ( "-datadir={}" , self . config. get_burnchain_path_str( ) ) ) ;
64
79
65
- match (
66
- & self . config . burnchain . username ,
67
- & self . config . burnchain . password ,
68
- ) {
69
- ( Some ( username) , Some ( password) ) => {
70
- command
71
- . arg ( format ! ( "-rpcuser={username}" ) )
72
- . arg ( format ! ( "-rpcpassword={password}" ) ) ;
73
- }
74
- _ => { }
75
- }
80
+ self . add_rpc_cli_args ( & mut command) ;
76
81
77
- eprintln ! ( "bitcoind spawn: {:?}" , command ) ;
82
+ eprintln ! ( "bitcoind spawn: {command :?}" ) ;
78
83
79
84
let mut process = match command. spawn ( ) {
80
85
Ok ( child) => child,
@@ -105,22 +110,9 @@ impl BitcoinCoreController {
105
110
pub fn stop_bitcoind ( & mut self ) -> Result < ( ) , BitcoinCoreError > {
106
111
if let Some ( _) = self . bitcoind_process . take ( ) {
107
112
let mut command = Command :: new ( "bitcoin-cli" ) ;
108
- command
109
- . stdout ( Stdio :: piped ( ) )
110
- . arg ( "-rpcconnect=127.0.0.1" )
111
- . arg ( format ! ( "-rpcport={}" , self . config. burnchain. rpc_port) ) ;
112
-
113
- match (
114
- & self . config . burnchain . username ,
115
- & self . config . burnchain . password ,
116
- ) {
117
- ( Some ( username) , Some ( password) ) => {
118
- command
119
- . arg ( format ! ( "-rpcuser={username}" ) )
120
- . arg ( format ! ( "-rpcpassword={password}" ) ) ;
121
- }
122
- _ => { }
123
- }
113
+ command. stdout ( Stdio :: piped ( ) ) . arg ( "-rpcconnect=127.0.0.1" ) ;
114
+
115
+ self . add_rpc_cli_args ( & mut command) ;
124
116
125
117
command. arg ( "stop" ) ;
126
118
0 commit comments