diff --git a/Cargo.toml b/Cargo.toml index 2c55b60..27228b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,8 @@ reqwest = { version = "0.11", default-features = false, features = ["json", "rus bitbox-api = { version = "0.9.0", default-features = false, features = ["usb", "tokio", "multithreaded"], optional = true } # coldcard -coldcard = { version = "0.12.2", optional = true } +# coldcard = { version = "0.12.2", optional = true } +coldcard = { git = "https://github.com/pythcoiner/rust-coldcard.git", rev = "5f6a6a6",optional = true } # ledger ledger_bitcoin_client = { version = "0.5.0", optional = true } diff --git a/src/coldcard.rs b/src/coldcard.rs index 291b6e7..5cc8ae0 100644 --- a/src/coldcard.rs +++ b/src/coldcard.rs @@ -8,6 +8,7 @@ use bitcoin::{ bip32::{DerivationPath, Fingerprint, Xpub}, psbt::Psbt, }; +use coldcard::protocol::DescriptorName; use crate::{parse_version, AddressScript, DeviceKind, Error as HWIError, Version, HWI}; pub use coldcard as api; @@ -120,7 +121,16 @@ impl HWI for Coldcard { async fn sign_tx(&self, psbt: &mut Psbt) -> Result<(), HWIError> { let mut cc = self.device()?; - let _ = cc.sign_psbt(&psbt.serialize(), api::SignMode::Signed)?; + let wallet_name = if let Some(name) = self.wallet_name.clone() { + Some( + DescriptorName::new(name) + .map_err(|_| HWIError::Unexpected("Coldcard: Invalid wallet name"))?, + ) + } else { + None + }; + + let _ = cc.sign_psbt_miniscript(&psbt.serialize(), api::SignMode::Signed, wallet_name)?; let tx = loop { if let Some(tx) = cc.get_signed_tx()? {