@@ -19,6 +19,8 @@ use clap::CommandFactory;
1919use clap:: Parser ;
2020use clap_complete:: generate;
2121use clap_complete:: Shell ;
22+ use dialoguer:: theme:: ColorfulTheme ;
23+ use dialoguer:: Select ;
2224use itertools:: Itertools ;
2325use neptune_cash:: api:: export:: TransactionKernelId ;
2426use neptune_cash:: api:: tx_initiation:: builder:: tx_output_list_builder:: OutputFormat ;
@@ -188,7 +190,7 @@ enum Command {
188190 max_num_blocks : Option < usize > ,
189191 } ,
190192
191- /// Show smallest block interval in the specified range.
193+ /// Show the smallest block interval in the specified range.
192194 MinBlockInterval {
193195 last_block : BlockSelector ,
194196 max_num_blocks : Option < usize > ,
@@ -200,7 +202,7 @@ enum Command {
200202 max_num_blocks : Option < usize > ,
201203 } ,
202204
203- /// Show largest difficulty in the specified range.
205+ /// Show the largest difficulty in the specified range.
204206 MaxBlockDifficulty {
205207 last_block : BlockSelector ,
206208 max_num_blocks : Option < usize > ,
@@ -297,7 +299,7 @@ enum Command {
297299 /// block proposals, and new transactions from being received.
298300 Freeze ,
299301
300- /// If state updates have been paused, resumes them. Otherwise does nothing.
302+ /// If state updates have been paused, resumes them. Otherwise, does nothing.
301303 Unfreeze ,
302304
303305 /// pause mining
@@ -549,12 +551,12 @@ async fn main() -> Result<()> {
549551
550552 // prompt user for all shares
551553 let mut shares = vec ! [ ] ;
552- let capture_integers = Regex :: new ( r"^(\d+)\/(\d+)$" ) . unwrap ( ) ;
554+ let capture_integers = Regex :: new ( r"^(\d+)\/(\d+)$" ) ? ;
553555 while shares. len ( ) != * t {
554556 println ! ( "Enter share index (\" i/n\" ): " ) ;
555557
556558 let mut buffer = "" . to_string ( ) ;
557- std :: io:: stdin ( )
559+ io:: stdin ( )
558560 . read_line ( & mut buffer)
559561 . expect ( "Cannot accept user input." ) ;
560562 let buffer = buffer. trim ( ) ;
@@ -722,7 +724,7 @@ async fn main() -> Result<()> {
722724 }
723725
724726 // all other operations need a connection to the server
725- let server_socket = SocketAddr :: new ( std :: net :: IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , args. port ) ;
727+ let server_socket = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , args. port ) ;
726728 let Ok ( transport) = tarpc:: serde_transport:: tcp:: connect ( server_socket, Json :: default) . await
727729 else {
728730 eprintln ! ( "This command requires a connection to `neptune-core`, but that connection could not be established. Is `neptune-core` running?" ) ;
@@ -1332,8 +1334,8 @@ async fn main() -> Result<()> {
13321334//
13331335// Otherwise, we call cookie_hint() RPC to obtain data-dir.
13341336// But the API might be disabled, which we detect and fallback to the default data-dir.
1335- async fn get_cookie_hint ( client : & RPCClient , args : & Config ) -> anyhow :: Result < auth:: CookieHint > {
1336- async fn fallback ( client : & RPCClient , args : & Config ) -> anyhow :: Result < auth:: CookieHint > {
1337+ async fn get_cookie_hint ( client : & RPCClient , args : & Config ) -> Result < auth:: CookieHint > {
1338+ async fn fallback ( client : & RPCClient , args : & Config ) -> Result < auth:: CookieHint > {
13371339 let network = client. network ( context:: current ( ) ) . await ??;
13381340 let data_directory = DataDirectory :: get ( args. data_dir . clone ( ) , network) ?;
13391341 Ok ( auth:: CookieHint {
@@ -1416,7 +1418,7 @@ fn process_utxo_notifications(
14161418 network : Network ,
14171419 private_notifications : Vec < PrivateNotificationData > ,
14181420 receiver_tag : Option < String > ,
1419- ) -> anyhow :: Result < ( ) > {
1421+ ) -> Result < ( ) > {
14201422 let data_dir = root_data_dir. utxo_transfer_directory_path ( ) ;
14211423
14221424 if !private_notifications. is_empty ( ) {
@@ -1428,10 +1430,7 @@ fn process_utxo_notifications(
14281430
14291431 // TODO: It would be better if this timestamp was read from the created
14301432 // transaction.
1431- let timestamp = SystemTime :: now ( )
1432- . duration_since ( UNIX_EPOCH )
1433- . unwrap ( )
1434- . as_millis ( ) ;
1433+ let timestamp = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) ?. as_millis ( ) ;
14351434
14361435 // write out one UtxoTransferEntry in a json file, per output
14371436 let mut wrote_file_cnt = 0usize ;
@@ -1461,7 +1460,7 @@ fn process_utxo_notifications(
14611460 let file_path = file_dir. join ( & file_name) ;
14621461 println ! ( "creating file: {}" , file_path. display( ) ) ;
14631462 let file = std:: fs:: File :: create_new ( & file_path) ?;
1464- let mut writer = std :: io:: BufWriter :: new ( file) ;
1463+ let mut writer = io:: BufWriter :: new ( file) ;
14651464 serde_json:: to_writer_pretty ( & mut writer, & entry) ?;
14661465 writer. flush ( ) ?;
14671466
@@ -1491,13 +1490,20 @@ or use equivalent claim functionality of your chosen wallet software.
14911490}
14921491
14931492fn enter_seed_phrase_dialog ( ) -> Result < SecretKeyMaterial > {
1493+ let mnemonic_length_list = [ 18 , 24 ] ;
1494+ let selection = Select :: with_theme ( & ColorfulTheme :: default ( ) )
1495+ . with_prompt ( "Choose your mnemonic length" )
1496+ . default ( 0 )
1497+ . items ( mnemonic_length_list)
1498+ . interact ( ) ?;
1499+ let mnemonic_length = mnemonic_length_list[ selection] ;
14941500 let mut phrase = vec ! [ ] ;
14951501 let mut i = 1 ;
14961502 loop {
14971503 print ! ( "{i}. " ) ;
1498- io :: stdout ( ) . flush ( ) ?;
1504+ stdout ( ) . flush ( ) ?;
14991505 let mut buffer = "" . to_string ( ) ;
1500- std :: io:: stdin ( )
1506+ io:: stdin ( )
15011507 . read_line ( & mut buffer)
15021508 . expect ( "Cannot accept user input." ) ;
15031509 let word = buffer. trim ( ) ;
@@ -1508,7 +1514,7 @@ fn enter_seed_phrase_dialog() -> Result<SecretKeyMaterial> {
15081514 {
15091515 phrase. push ( word. to_string ( ) ) ;
15101516 i += 1 ;
1511- if i > 18 {
1517+ if i > mnemonic_length {
15121518 break ;
15131519 }
15141520 } else {
0 commit comments