Skip to content

Commit 8743caf

Browse files
committed
Add function for toggle_passphrase
Also adds test for toggle_passphrase
1 parent 983c057 commit 8743caf

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/interface.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,19 @@ impl HWIClient {
330330
Ok(())
331331
})
332332
}
333+
334+
/// Toggle whether the device is using a BIP 39 passphrase.
335+
pub fn toggle_passphrase(&self) -> Result<(), Error> {
336+
Python::with_gil(|py| {
337+
let func_args = (&self.hw_client,);
338+
let output = self
339+
.hwilib
340+
.commands
341+
.getattr(py, "toggle_passphrase")?
342+
.call1(py, func_args)?;
343+
let output = self.hwilib.json_dumps.call1(py, (output,))?;
344+
let status: HWIStatus = deserialize_obj!(&output.to_string())?;
345+
status.into()
346+
})
347+
}
333348
}

src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,20 @@ mod tests {
227227
HWIClient::set_log_level(types::LogLevel::DEBUG).unwrap();
228228
test_enumerate();
229229
}
230+
231+
#[test]
232+
#[serial]
233+
fn test_toggle_passphrase() {
234+
let devices = HWIClient::enumerate().unwrap();
235+
let unsupported = ["ledger", "bitbox01", "coldcard", "jade"];
236+
for device in devices {
237+
if unsupported.contains(&&device.device_type[..]) {
238+
// These devices don't support togglepassphrase
239+
continue;
240+
}
241+
let client = HWIClient::get_client(&device, true, types::HWIChain::Test).unwrap();
242+
client.toggle_passphrase().unwrap();
243+
break;
244+
}
245+
}
230246
}

0 commit comments

Comments
 (0)