@@ -75,6 +75,7 @@ const CONNECTION_ERR_MSG: &str = "\nCan't connect to the epicbox server!\n\
7575 Check your epic-wallet.toml settings and make sure epicbox domain is correct.\n ";
7676const DEFAULT_CHALLENGE_RAW : & str = "7WUDtkSaKyGRUnQ22rE3QUXChV8DmA6NnunDYP4vheTpc" ;
7777const EPICBOX_PROTOCOL_VERSION : & str = "2.0.0" ;
78+ const EPICBOX_SUBSCRIPTION_INTERVAL : u64 = 60 ;
7879
7980/// Epicbox 'plugin' implementation
8081pub enum CloseReason {
@@ -820,6 +821,18 @@ impl EpicboxBroker {
820821 & slate,
821822 Some ( & mut tx_proof) ,
822823 ) ;
824+
825+ let signature =
826+ sign_challenge ( & subscribe, & secret_key) ?. to_hex ( ) ;
827+ let request_sub = ProtocolRequestV2 :: Subscribe {
828+ address : client. address . public_key . to_string ( ) ,
829+ ver : ver. to_string ( ) ,
830+ signature,
831+ } ;
832+
833+ client
834+ . sendv2 ( & request_sub)
835+ . expect ( "Could not send subscribe request!" ) ;
823836 }
824837 }
825838 ProtocolResponseV2 :: GetVersion { str } => {
@@ -842,6 +855,23 @@ impl EpicboxBroker {
842855 error ! ( "ProtocolResponse::Error {}" , response) ;
843856 }
844857 } ,
858+ ProtocolResponseV2 :: Ok { } => {
859+ info ! ( "Subscription Ok." ) ;
860+ let duration =
861+ std:: time:: Duration :: from_secs ( EPICBOX_SUBSCRIPTION_INTERVAL ) ;
862+ std:: thread:: sleep ( duration) ;
863+ info ! ( "New subscription..." ) ;
864+ let signature = sign_challenge ( & subscribe, & secret_key) ?. to_hex ( ) ;
865+ let request_sub = ProtocolRequestV2 :: Subscribe {
866+ address : client. address . public_key . to_string ( ) ,
867+ ver : ver. to_string ( ) ,
868+ signature,
869+ } ;
870+
871+ client
872+ . sendv2 ( & request_sub)
873+ . expect ( "Could not send subscribe request!" ) ;
874+ }
845875 _ => { }
846876 }
847877 }
0 commit comments