File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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 . as_str ( ) ) {
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}
You can’t perform that action at this time.
0 commit comments