Skip to content

Commit

Permalink
Add send_pin HWI command
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-kaufman committed Sep 3, 2024
1 parent 5e88904 commit ba5a0c8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
Python::with_gil(|py| {
Expand Down
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit ba5a0c8

Please sign in to comment.