Skip to content

Commit c6434e6

Browse files
committed
Add function for toggle_passphrase
Also adds test for toggle_passphrase
1 parent d30bb76 commit c6434e6

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/interface.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,19 @@ impl HWIClient {
293293
status.into()
294294
})
295295
}
296+
297+
/// Toggle whether the device is using a BIP 39 passphrase.
298+
pub fn toggle_passphrase(&self) -> Result<(), Error> {
299+
Python::with_gil(|py| {
300+
let func_args = (&self.hw_client,);
301+
let output = self
302+
.hwilib
303+
.commands
304+
.getattr(py, "toggle_passphrase")?
305+
.call1(py, func_args)?;
306+
let output = self.hwilib.json_dumps.call1(py, (output,))?;
307+
let status: HWIStatus = deserialize_obj!(&output.to_string())?;
308+
status.into()
309+
})
310+
}
296311
}

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,19 @@ mod tests {
218218
HWIClient::install_udev_rules(None, None).unwrap()
219219
}
220220
}
221+
222+
#[test]
223+
#[serial]
224+
fn test_toggle_passphrase() {
225+
let devices = HWIClient::enumerate().unwrap();
226+
for device in devices {
227+
if device.device_type == "ledger" {
228+
// Ledger devices don't support togglepassphrase
229+
continue;
230+
}
231+
let client = HWIClient::get_client(&device, true, types::HWIChain::Test).unwrap();
232+
client.toggle_passphrase().unwrap();
233+
break;
234+
}
235+
}
221236
}

0 commit comments

Comments
 (0)