@ -8,10 +8,12 @@ use silentdragonlitelib::{commands,
lightclient ::{ LightClient , LightClientConfig } ,
} ;
pub mod version ;
#[ macro_export ]
macro_rules ! configure_clapapp {
( $freshapp : expr ) = > {
$freshapp . version ( "1.1.1" )
$freshapp . version ( VERSION )
. arg ( Arg ::with_name ( "dangerous" )
. long ( "dangerous" )
. help ( "Disable server TLS certificate verification. Use this if you're running a local lightwalletd with a self-signed certificate. WARNING: This is dangerous, don't use it with a server that is not your own." )
@ -91,7 +93,9 @@ pub fn startup(server: http::Uri, dangerous: bool, seed: Option<String>, birthda
Arc ::new ( LightClient ::read_from_disk ( & config ) ? )
} else {
println ! ( "Creating a new wallet" ) ;
Arc ::new ( LightClient ::new ( & config , latest_block_height ) ? )
// Create a wallet with height - 100, to protect against reorgs
Arc ::new ( LightClient ::new ( & config , latest_block_height . saturating_sub ( 100 ) ) ? )
}
}
} ;
@ -208,27 +212,21 @@ pub fn command_loop(lightclient: Arc<LightClient>) -> (Sender<(String, Vec<Strin
let lc = lightclient . clone ( ) ;
std ::thread ::spawn ( move | | {
LightClient ::start_mempool_monitor ( lc . clone ( ) ) ;
loop {
match command_rx . recv_timeout ( std ::time ::Duration ::from_secs ( 5 * 60 ) ) {
Ok ( ( cmd , args ) ) = > {
let args = args . iter ( ) . map ( | s | s . as_ref ( ) ) . collect ( ) ;
if let Ok ( ( cmd , args ) ) = command_rx . recv ( ) {
let args = args . iter ( ) . map ( | s | s . as_ref ( ) ) . collect ( ) ;
let cmd_response = commands ::do_user_command ( & cmd , & args , lc . as_ref ( ) ) ;
resp_tx . send ( cmd_response ) . unwrap ( ) ;
let cmd_response = commands ::do_user_command ( & cmd , & args , lc . as_ref ( ) ) ;
resp_tx . send ( cmd_response ) . unwrap ( ) ;
if cmd = = "quit" {
info ! ( "Quit" ) ;
break ;
}
} ,
Err ( _ ) = > {
// Timeout. Do a sync to keep the wallet up-to-date. False to whether to print updates on the console
info ! ( "Timeout, doing a sync" ) ;
match lc . do_sync ( false ) {
Ok ( _ ) = > { } ,
Err ( e ) = > { error ! ( "{}" , e ) }
}
if cmd = = "quit" {
info ! ( "Quit" ) ;
break ;
}
} else {
break ;
}
}
} ) ;
@ -244,6 +242,7 @@ pub fn attempt_recover_seed(password: Option<String>) {
sapling_activation_height : 0 ,
consensus_branch_id : "000000" . to_string ( ) ,
anchor_offset : 0 ,
monitor_mempool : false ,
no_cert_verification : false ,
data_dir : None ,
} ;