Skip to content

Commit

Permalink
Fix where epicbox listener stop receiving txs
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Hahn committed Nov 18, 2023
1 parent a8be757 commit c1613e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl GlobalWalletConfig {
/// apply defaults for each chain type
pub fn for_chain(chain_type: &global::ChainTypes) -> GlobalWalletConfig {
let mut defaults_conf = GlobalWalletConfig::default();
let mut defaults = &mut defaults_conf.members.as_mut().unwrap().wallet;
let defaults = &mut defaults_conf.members.as_mut().unwrap().wallet;
defaults.chain_type = Some(chain_type.clone());

match *chain_type {
Expand Down
30 changes: 30 additions & 0 deletions impls/src/adapters/epicbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const CONNECTION_ERR_MSG: &str = "\nCan't connect to the epicbox server!\n\
Check your epic-wallet.toml settings and make sure epicbox domain is correct.\n";
const DEFAULT_CHALLENGE_RAW: &str = "7WUDtkSaKyGRUnQ22rE3QUXChV8DmA6NnunDYP4vheTpc";
const EPICBOX_PROTOCOL_VERSION: &str = "2.0.0";
const EPICBOX_SUBSCRIPTION_INTERVAL: u64 = 60;

/// Epicbox 'plugin' implementation
pub enum CloseReason {
Expand Down Expand Up @@ -820,6 +821,18 @@ impl EpicboxBroker {
&slate,
Some(&mut tx_proof),
);

let signature =
sign_challenge(&subscribe, &secret_key)?.to_hex();
let request_sub = ProtocolRequestV2::Subscribe {
address: client.address.public_key.to_string(),
ver: ver.to_string(),
signature,
};

client
.sendv2(&request_sub)
.expect("Could not send subscribe request!");
}
}
ProtocolResponseV2::GetVersion { str } => {
Expand All @@ -842,6 +855,23 @@ impl EpicboxBroker {
error!("ProtocolResponse::Error {}", response);
}
},
ProtocolResponseV2::Ok {} => {
info!("Subscription Ok.");
let duration =
std::time::Duration::from_secs(EPICBOX_SUBSCRIPTION_INTERVAL);
std::thread::sleep(duration);
info!("New subscription...");
let signature = sign_challenge(&subscribe, &secret_key)?.to_hex();
let request_sub = ProtocolRequestV2::Subscribe {
address: client.address.public_key.to_string(),
ver: ver.to_string(),
signature,
};

client
.sendv2(&request_sub)
.expect("Could not send subscribe request!");
}
_ => {}
}
}
Expand Down

0 comments on commit c1613e8

Please sign in to comment.