Skip to content

Commit

Permalink
Merge #1134: update async-hwi with serial fix
Browse files Browse the repository at this point in the history
5a31324 bump async-hwi for hw serial connection fix (edouardparis)

Pull request description:

  close #1126

ACKs for top commit:
  edouardparis:
    Self-ACK 5a31324

Tree-SHA512: 1ba101a7f02c0aa339c76c8b9a72c6b97ec4ee27f13263de106b58c81ce31c1d6ad189d0f93a62c204966745ebaadab4efe8f34a38d65d5f7b0dd15ebd6982ac
  • Loading branch information
edouardparis committed Jun 25, 2024
2 parents 67d835a + 5a31324 commit 8e6fa8b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 30 deletions.
4 changes: 2 additions & 2 deletions gui/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ path = "src/main.rs"

[dependencies]
async-trait = "0.1"
async-hwi = "0.0.18"
async-hwi = { version = "0.0.21" }
liana = { git = "https://github.com/wizardsardine/liana", branch = "master", default-features = false, features = ["nonblocking_shutdown"] }
liana_ui = { path = "ui" }
backtrace = "0.3"
Expand Down
69 changes: 42 additions & 27 deletions gui/src/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,30 @@ async fn refresh(mut state: State) -> (HardwareWalletMessage, State) {
if state.connected_supported_hws.contains(&id) {
still.push(id);
} else {
let device = specter::Specter::<specter::SerialTransport>::new(port.clone());
if tokio::time::timeout(
std::time::Duration::from_millis(500),
device.fingerprint(),
)
.await
.is_ok()
{
match HardwareWallet::new(id, Arc::new(device), Some(&state.keys_aliases))
match specter::Specter::<specter::SerialTransport>::new(port.clone()) {
Err(e) => {
warn!("{}", e);
}
Ok(device) => {
if tokio::time::timeout(
std::time::Duration::from_millis(500),
device.fingerprint(),
)
.await
{
Ok(hw) => hws.push(hw),
Err(e) => {
debug!("{}", e);
.is_ok()
{
match HardwareWallet::new(
id,
Arc::new(device),
Some(&state.keys_aliases),
)
.await
{
Ok(hw) => hws.push(hw),
Err(e) => {
debug!("{}", e);
}
}
}
}
}
Expand All @@ -444,23 +454,28 @@ async fn refresh(mut state: State) -> (HardwareWalletMessage, State) {
if state.connected_supported_hws.contains(&id) {
still.push(id);
} else {
let device =
Jade::new(jade::SerialTransport::new(port)).with_network(state.network);
match handle_jade_device(
id,
state.network,
device,
state.wallet.as_ref().map(|w| w.as_ref()),
Some(&state.keys_aliases),
)
.await
{
Ok(hw) => {
hws.push(hw);
}
match jade::SerialTransport::new(port) {
Err(e) => {
warn!("{:?}", e);
}
Ok(device) => {
match handle_jade_device(
id,
state.network,
Jade::new(device).with_network(state.network),
state.wallet.as_ref().map(|w| w.as_ref()),
Some(&state.keys_aliases),
)
.await
{
Ok(hw) => {
hws.push(hw);
}
Err(e) => {
warn!("{:?}", e);
}
}
}
}
}
}
Expand Down

0 comments on commit 8e6fa8b

Please sign in to comment.