Skip to content

Commit c1613e8

Browse files
author
Johannes Hahn
committed
Fix where epicbox listener stop receiving txs
1 parent a8be757 commit c1613e8

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

config/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl GlobalWalletConfig {
175175
/// apply defaults for each chain type
176176
pub fn for_chain(chain_type: &global::ChainTypes) -> GlobalWalletConfig {
177177
let mut defaults_conf = GlobalWalletConfig::default();
178-
let mut defaults = &mut defaults_conf.members.as_mut().unwrap().wallet;
178+
let defaults = &mut defaults_conf.members.as_mut().unwrap().wallet;
179179
defaults.chain_type = Some(chain_type.clone());
180180

181181
match *chain_type {

impls/src/adapters/epicbox.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
7676
const DEFAULT_CHALLENGE_RAW: &str = "7WUDtkSaKyGRUnQ22rE3QUXChV8DmA6NnunDYP4vheTpc";
7777
const EPICBOX_PROTOCOL_VERSION: &str = "2.0.0";
78+
const EPICBOX_SUBSCRIPTION_INTERVAL: u64 = 60;
7879

7980
/// Epicbox 'plugin' implementation
8081
pub 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

Comments
 (0)