Skip to content

Commit

Permalink
bump bitbox-api with bitcoin 0.32 as a duplicate dep
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Oct 31, 2024
1 parent 1f9a287 commit 80b8794
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.70.0
toolchain: 1.71.1
components: rustfmt, clippy
override: true
- name: rustfmt
Expand All @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
toolchain:
- 1.70.0
- 1.71.1
- nightly
os:
- ubuntu-latest
Expand Down
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["bitcoin"]

[package]
name = "async-hwi"
version = "0.0.23"
version = "0.0.24"
readme = "README.md"
description = "Async hardware wallet interface"
license-file.workspace = true
Expand All @@ -30,7 +30,8 @@ regex = ["dep:regex"]
[dependencies]
async-trait = "0.1.52"
futures = "0.3"
bitcoin = { version = "0.31", default-features = false, features = ["base64", "serde", "std"] }
bitcoin = { package = "bitcoin", version = "0.31", default-features = false, features = ["base64", "serde", "std"] }
bitcoin_32 = { package = "bitcoin", version = "0.32", default-features = false, features = ["base64", "serde", "std"] }

# specter & jade
tokio-serial = { version = "5.4.1", optional = true }
Expand All @@ -43,7 +44,7 @@ serde_cbor = { version = "0.11", optional = true }
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] , optional = true}

# bitbox
bitbox-api = { version = "0.2.3", default-features = false, features = ["usb", "tokio", "multithreaded"], optional = true }
bitbox-api = { version = "0.6.0", default-features = false, features = ["usb", "tokio", "multithreaded"], optional = true }

# coldcard
coldcard = { version = "0.12.2", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# async-hwi

Current **Minimum Supported Rust Version**: v1.70.0
Current **Minimum Supported Rust Version**: v1.71.1

```rust
/// HWI is the common Hardware Wallet Interface.
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ path = "src/bin/hwi.rs"
clap = { version = "4.4.7", features = ["derive"] }
bitcoin = "0.31"
hex = "0.4"
async-hwi = { path = "../", version = "0.0.23" }
async-hwi = { path = "../", version = "0.0.24" }
tokio = { version = "1", features = ["macros", "net", "rt", "rt-multi-thread", "io-util", "sync"] }
30 changes: 22 additions & 8 deletions src/bitbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use bitcoin::{
};
use regex::Regex;
use std::{
convert::TryFrom,
str::FromStr,
sync::{Arc, Mutex},
};
Expand Down Expand Up @@ -197,7 +198,8 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
} else {
pb::BtcCoin::Tbtc
},
&Keypath::from(path),
&Keypath::try_from(path.to_string().as_str())
.expect("Must be a bip32 derivation path"),
if self.network == bitcoin::Network::Bitcoin {
pb::btc_pub_request::XPubType::Xpub
} else {
Expand All @@ -220,7 +222,8 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
} else {
pb::BtcCoin::Tbtc
},
&Keypath::from(path),
&Keypath::try_from(path.to_string().as_str())
.expect("Must be a bip32 derivation path"),
&make_script_config_simple(pb::btc_script_config::SimpleType::P2tr),
true,
)
Expand Down Expand Up @@ -268,7 +271,8 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
} else {
pb::BtcCoin::Tbtc
},
&Keypath::from(&path),
&Keypath::try_from(path.to_string().as_str())
.expect("Must be a bip32 derivation path"),
&policy.into(),
true,
)
Expand Down Expand Up @@ -332,21 +336,26 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
}
Some(pb::BtcScriptConfigWithKeypath {
script_config: Some(policy.into()),
keypath: Keypath::from(&path).to_vec(),
keypath: path.to_u32_vec(),
})
} else {
None
};

let mut psbt_32 =
bitcoin_32::Psbt::from_str(&psbt.to_string()).expect("Must be a correct psbt");

self.client
.btc_sign_psbt(
coin_from_network(self.network),
psbt,
&mut psbt_32,
policy,
pb::btc_sign_init_request::FormatUnit::Default,
)
.await?;

*psbt = Psbt::from_str(&psbt_32.to_string()).expect("Must be a correct psbt");

Ok(())
}
}
Expand Down Expand Up @@ -497,9 +506,14 @@ pub struct KeyInfo {
impl From<KeyInfo> for KeyOriginInfo {
fn from(info: KeyInfo) -> KeyOriginInfo {
KeyOriginInfo {
root_fingerprint: info.master_fingerprint,
keypath: info.path.as_ref().map(Keypath::from),
xpub: info.xpub,
root_fingerprint: info
.master_fingerprint
.map(|fg| bitcoin_32::bip32::Fingerprint::from(fg.to_bytes())),
keypath: info.path.as_ref().map(|path| {
Keypath::try_from(path.to_string().as_str())
.expect("Must be a bip32 derivation path")
}),
xpub: bitcoin_32::bip32::Xpub::from_str(&info.xpub.to_string()).expect("Correct xpub"),
}
}
}
Expand Down

0 comments on commit 80b8794

Please sign in to comment.