Skip to content

Commit

Permalink
Merge #1400: gui: add support for tapminiscript on bitbox02
Browse files Browse the repository at this point in the history
01f6d2b gui: add support for tapminiscript on bitbox02 (pythcoiner)

Pull request description:

  This PR is build on top of #1357, with few adds:
  - get the version from bitbox device
  - check the version for taproot support
  - copy `tap_script_signs` & `tap_key_sig` if present in the pruned psbt after signature

  Tested spending by internal key & taptree w/ differents setups

  ~~Note: this PR use `bitbox-tapminiscript` branch of `async-hwi`~~

ACKs for top commit:
  edouardparis:
    ACK 01f6d2b

Tree-SHA512: aa66a0ebe8553fd13dd5e279adaf1360cdce0d4ccb09f49181f20bc5e4c3c653c0ab056c35ac5cf6ccb3eeb696dcfd94463e6235d1cdb2063ecb503695ad4b99
  • Loading branch information
edouardparis committed Nov 4, 2024
2 parents d87da1e + 01f6d2b commit 3549a71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 6 additions & 0 deletions gui/src/app/state/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,12 @@ async fn sign_psbt(
psbt_in
.partial_sigs
.append(&mut pruned_psbt_in.partial_sigs);
if let Some(tap_key_sig) = pruned_psbt_in.tap_key_sig {
psbt_in.tap_key_sig = Some(tap_key_sig);
}
psbt_in
.tap_script_sigs
.append(&mut pruned_psbt_in.tap_script_sigs);
} else {
log::error!(
"Not all PSBT inputs are present in the pruned psbt. Pruned psbt: '{}'.",
Expand Down
18 changes: 14 additions & 4 deletions gui/src/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl HardwareWallets {
let fingerprint =
bitbox2.get_master_fingerprint().await?;
let mut registered = false;
let version = bitbox2.get_version().await.ok();
if let Some(wallet) = &wallet {
let desc = wallet.main_descriptor.to_string();
bitbox2 = bitbox2.with_policy(&desc)?;
Expand All @@ -257,15 +258,15 @@ impl HardwareWallets {
kind: DeviceKind::BitBox02,
fingerprint,
device: bitbox2.into(),
version: None,
version,
registered: Some(registered),
alias: None,
})
} else {
Ok(HardwareWallet::Unsupported {
id: id.clone(),
kind: DeviceKind::BitBox02,
version: None,
version,
reason: UnsupportedReason::NotPartOfWallet(
fingerprint,
),
Expand All @@ -277,7 +278,7 @@ impl HardwareWallets {
kind: DeviceKind::BitBox02,
fingerprint,
device: bitbox2.into(),
version: None,
version,
registered: Some(registered),
alias: None,
})
Expand Down Expand Up @@ -851,7 +852,7 @@ fn ledger_version_supported(version: &Version) -> bool {

// Kind and minimal version of devices supporting tapminiscript.
// We cannot use a lazy_static HashMap yet, because DeviceKind does not implement Hash.
const DEVICES_COMPATIBLE_WITH_TAPMINISCRIPT: [(DeviceKind, Option<Version>); 4] = [
const DEVICES_COMPATIBLE_WITH_TAPMINISCRIPT: [(DeviceKind, Option<Version>); 5] = [
(
DeviceKind::Ledger,
Some(Version {
Expand All @@ -872,6 +873,15 @@ const DEVICES_COMPATIBLE_WITH_TAPMINISCRIPT: [(DeviceKind, Option<Version>); 4]
prerelease: None,
}),
),
(
DeviceKind::BitBox02,
Some(Version {
major: 9,
minor: 21,
patch: 0,
prerelease: None,
}),
),
];

pub fn is_compatible_with_tapminiscript(
Expand Down

0 comments on commit 3549a71

Please sign in to comment.