From ba5a0c8aff1c42e908ebfd00ca811455165ecd2d Mon Sep 17 00:00:00 2001 From: benk10 Date: Tue, 3 Sep 2024 20:57:30 +0400 Subject: [PATCH] Add send_pin HWI command --- src/interface.rs | 15 +++++++++++++++ src/lib.rs | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/interface.rs b/src/interface.rs index e324bbe..d060e21 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -497,6 +497,21 @@ impl HWIClient { }) } + /// Send PIN to a device + pub fn send_pin(&self, pin: &str) -> Result<(), Error> { + Python::with_gil(|py| { + let func_args = (&self.hw_client, pin); + let output = self + .hwilib + .commands + .getattr(py, "send_pin")? + .call1(py, func_args)?; + let output = self.hwilib.json_dumps.call1(py, (output,))?; + let status: HWIStatus = deserialize_obj!(&output.to_string())?; + status.into() + }) + } + /// Get the installed version of hwilib. Returns None if hwi is not installed. pub fn get_version() -> Option { Python::with_gil(|py| { diff --git a/src/lib.rs b/src/lib.rs index d549e92..7861bc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -435,6 +435,21 @@ mod tests { } } + #[test] + #[serial] + #[ignore] + fn test_send_pin_to_trezor_device() { + let client = HWIClient::find_device( + None, + Some(HWIDeviceType::Trezor), + None, + false, + Network::Testnet, + ) + .unwrap(); + client.send_pin("123456").unwrap(); + } + #[test] #[serial] #[ignore]