13
13
// limitations under the License.
14
14
15
15
use crate :: commands:: override_config;
16
- use crate :: config:: Config ;
16
+ use crate :: config:: { persistence :: pathfinder :: MixNodePathfinder , Config } ;
17
17
use crate :: node:: MixNode ;
18
18
use clap:: { App , Arg , ArgMatches } ;
19
19
use config:: NymConfig ;
20
+ use crypto:: encryption;
21
+ use pemstore:: pemstore:: PemStore ;
20
22
21
23
pub fn command_args < ' a , ' b > ( ) -> App < ' a , ' b > {
22
24
App :: new ( "run" )
@@ -94,6 +96,17 @@ fn special_addresses() -> Vec<&'static str> {
94
96
vec ! [ "localhost" , "127.0.0.1" , "0.0.0.0" , "::1" , "[::1]" ]
95
97
}
96
98
99
+ fn load_sphinx_keys ( config_file : & Config ) -> encryption:: KeyPair {
100
+ let sphinx_keypair = PemStore :: new ( MixNodePathfinder :: new_from_config ( & config_file) )
101
+ . read_encryption ( )
102
+ . expect ( "Failed to read stored sphinx key files" ) ;
103
+ println ! (
104
+ "Public key: {}\n " ,
105
+ sphinx_keypair. public_key( ) . to_base58_string( )
106
+ ) ;
107
+ sphinx_keypair
108
+ }
109
+
97
110
pub fn execute ( matches : & ArgMatches ) {
98
111
let id = matches. value_of ( "id" ) . unwrap ( ) ;
99
112
@@ -105,6 +118,8 @@ pub fn execute(matches: &ArgMatches) {
105
118
106
119
config = override_config ( config, matches) ;
107
120
121
+ let sphinx_keypair = load_sphinx_keys ( & config) ;
122
+
108
123
let listening_ip_string = config. get_listening_address ( ) . ip ( ) . to_string ( ) ;
109
124
if special_addresses ( ) . contains ( & listening_ip_string. as_ref ( ) ) {
110
125
show_binding_warning ( listening_ip_string) ;
@@ -128,5 +143,5 @@ pub fn execute(matches: &ArgMatches) {
128
143
config. get_announce_address( )
129
144
) ;
130
145
131
- MixNode :: new ( config) . run ( ) ;
146
+ MixNode :: new ( config, sphinx_keypair ) . run ( ) ;
132
147
}
0 commit comments