Skip to content

Commit

Permalink
fix ledger client: no duplicate keys
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Aug 10, 2023
1 parent 32c3977 commit e571f4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "async-hwi"
version = "0.0.9"
version = "0.0.10"
edition = "2018"
description = "Async hardware wallet interface"
authors = ["Edouard Paris <[email protected]>"]
Expand Down Expand Up @@ -28,7 +28,7 @@ serialport = { version = "4.2", optional = true }

# ledger
regex = { version = "1.6.0", optional = true }
ledger_bitcoin_client = { version = "0.3.1", optional = true }
ledger_bitcoin_client = { version = "0.3.2", optional = true }
ledger-apdu = { version = "0.10", optional = true }
ledger-transport-hid = { version = "0.10", optional = true }
hidapi = { version = "1.4.1", features = ["linux-static-hidraw"], default-features = false, optional = true }
Expand Down
8 changes: 5 additions & 3 deletions src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ pub fn extract_keys_and_template(policy: &str) -> Result<(String, Vec<WalletPubK
let mut descriptor_template = policy.to_string();
let mut pubkeys: Vec<WalletPubKey> = Vec::new();
for (index, capture) in re.find_iter(policy).enumerate() {
pubkeys.push(
WalletPubKey::from_str(capture.as_str()).map_err(|_| HWIError::UnsupportedInput)?,
);
let pubkey =
WalletPubKey::from_str(capture.as_str()).map_err(|_| HWIError::UnsupportedInput)?;
if !pubkeys.contains(&pubkey) {
pubkeys.push(pubkey);
}
descriptor_template = descriptor_template.replace(capture.as_str(), &format!("@{}", index));
}

Expand Down

0 comments on commit e571f4f

Please sign in to comment.