Skip to content

Commit 80b8794

Browse files
committedOct 31, 2024·
bump bitbox-api with bitcoin 0.32 as a duplicate dep
1 parent 1f9a287 commit 80b8794

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed
 

‎.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v1
1010
- uses: actions-rs/toolchain@v1
1111
with:
12-
toolchain: 1.70.0
12+
toolchain: 1.71.1
1313
components: rustfmt, clippy
1414
override: true
1515
- name: rustfmt
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
matrix:
2727
toolchain:
28-
- 1.70.0
28+
- 1.71.1
2929
- nightly
3030
os:
3131
- ubuntu-latest

‎Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords = ["bitcoin"]
1010

1111
[package]
1212
name = "async-hwi"
13-
version = "0.0.23"
13+
version = "0.0.24"
1414
readme = "README.md"
1515
description = "Async hardware wallet interface"
1616
license-file.workspace = true
@@ -30,7 +30,8 @@ regex = ["dep:regex"]
3030
[dependencies]
3131
async-trait = "0.1.52"
3232
futures = "0.3"
33-
bitcoin = { version = "0.31", default-features = false, features = ["base64", "serde", "std"] }
33+
bitcoin = { package = "bitcoin", version = "0.31", default-features = false, features = ["base64", "serde", "std"] }
34+
bitcoin_32 = { package = "bitcoin", version = "0.32", default-features = false, features = ["base64", "serde", "std"] }
3435

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

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

4849
# coldcard
4950
coldcard = { version = "0.12.2", optional = true }

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# async-hwi
22

3-
Current **Minimum Supported Rust Version**: v1.70.0
3+
Current **Minimum Supported Rust Version**: v1.71.1
44

55
```rust
66
/// HWI is the common Hardware Wallet Interface.

‎cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ path = "src/bin/hwi.rs"
1616
clap = { version = "4.4.7", features = ["derive"] }
1717
bitcoin = "0.31"
1818
hex = "0.4"
19-
async-hwi = { path = "../", version = "0.0.23" }
19+
async-hwi = { path = "../", version = "0.0.24" }
2020
tokio = { version = "1", features = ["macros", "net", "rt", "rt-multi-thread", "io-util", "sync"] }

‎src/bitbox.rs

+22-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use bitcoin::{
1414
};
1515
use regex::Regex;
1616
use std::{
17+
convert::TryFrom,
1718
str::FromStr,
1819
sync::{Arc, Mutex},
1920
};
@@ -197,7 +198,8 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
197198
} else {
198199
pb::BtcCoin::Tbtc
199200
},
200-
&Keypath::from(path),
201+
&Keypath::try_from(path.to_string().as_str())
202+
.expect("Must be a bip32 derivation path"),
201203
if self.network == bitcoin::Network::Bitcoin {
202204
pb::btc_pub_request::XPubType::Xpub
203205
} else {
@@ -220,7 +222,8 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
220222
} else {
221223
pb::BtcCoin::Tbtc
222224
},
223-
&Keypath::from(path),
225+
&Keypath::try_from(path.to_string().as_str())
226+
.expect("Must be a bip32 derivation path"),
224227
&make_script_config_simple(pb::btc_script_config::SimpleType::P2tr),
225228
true,
226229
)
@@ -268,7 +271,8 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
268271
} else {
269272
pb::BtcCoin::Tbtc
270273
},
271-
&Keypath::from(&path),
274+
&Keypath::try_from(path.to_string().as_str())
275+
.expect("Must be a bip32 derivation path"),
272276
&policy.into(),
273277
true,
274278
)
@@ -332,21 +336,26 @@ impl<T: Runtime + Sync + Send> HWI for BitBox02<T> {
332336
}
333337
Some(pb::BtcScriptConfigWithKeypath {
334338
script_config: Some(policy.into()),
335-
keypath: Keypath::from(&path).to_vec(),
339+
keypath: path.to_u32_vec(),
336340
})
337341
} else {
338342
None
339343
};
340344

345+
let mut psbt_32 =
346+
bitcoin_32::Psbt::from_str(&psbt.to_string()).expect("Must be a correct psbt");
347+
341348
self.client
342349
.btc_sign_psbt(
343350
coin_from_network(self.network),
344-
psbt,
351+
&mut psbt_32,
345352
policy,
346353
pb::btc_sign_init_request::FormatUnit::Default,
347354
)
348355
.await?;
349356

357+
*psbt = Psbt::from_str(&psbt_32.to_string()).expect("Must be a correct psbt");
358+
350359
Ok(())
351360
}
352361
}
@@ -497,9 +506,14 @@ pub struct KeyInfo {
497506
impl From<KeyInfo> for KeyOriginInfo {
498507
fn from(info: KeyInfo) -> KeyOriginInfo {
499508
KeyOriginInfo {
500-
root_fingerprint: info.master_fingerprint,
501-
keypath: info.path.as_ref().map(Keypath::from),
502-
xpub: info.xpub,
509+
root_fingerprint: info
510+
.master_fingerprint
511+
.map(|fg| bitcoin_32::bip32::Fingerprint::from(fg.to_bytes())),
512+
keypath: info.path.as_ref().map(|path| {
513+
Keypath::try_from(path.to_string().as_str())
514+
.expect("Must be a bip32 derivation path")
515+
}),
516+
xpub: bitcoin_32::bip32::Xpub::from_str(&info.xpub.to_string()).expect("Correct xpub"),
503517
}
504518
}
505519
}

0 commit comments

Comments
 (0)
Please sign in to comment.