@@ -27,24 +27,34 @@ async fn prompt_cancel(hal: &mut impl crate::hal::Hal) -> Result<(), confirm::Us
27
27
. await
28
28
}
29
29
30
+ pub enum PasswordType {
31
+ /// The password to be entered is the device unlock password.
32
+ DevicePassword ,
33
+ /// The password to be entered is the BIP39 passphrase.
34
+ Bip39Passphrase ,
35
+ }
36
+
30
37
/// If `can_cancel` is `Yes`, the workflow can be cancelled.
31
38
/// If it is no, the result is always `Ok(())`.
32
39
///
33
40
/// Example:
34
41
/// ```no_run
35
- /// let pw = enter("Enter password", true , CanCancel::No).await.unwrap();
42
+ /// let pw = enter(hal, "Enter password", PassswordType::DevicePassword , CanCancel::No).await.unwrap();
36
43
/// // use pw.
37
44
/// ```
38
45
pub async fn enter (
39
46
hal : & mut impl crate :: hal:: Hal ,
40
47
title : & str ,
41
- special_chars : bool ,
48
+ password_type : PasswordType ,
42
49
can_cancel : CanCancel ,
43
50
) -> Result < zeroize:: Zeroizing < String > , Error > {
44
51
let params = trinary_input_string:: Params {
45
52
title,
46
53
hide : true ,
47
- special_chars,
54
+ special_chars : match password_type {
55
+ PasswordType :: DevicePassword => false ,
56
+ PasswordType :: Bip39Passphrase => true ,
57
+ } ,
48
58
longtouch : true ,
49
59
..Default :: default ( )
50
60
} ;
@@ -84,8 +94,20 @@ impl core::convert::From<Error> for EnterTwiceError {
84
94
pub async fn enter_twice (
85
95
hal : & mut impl crate :: hal:: Hal ,
86
96
) -> Result < zeroize:: Zeroizing < String > , EnterTwiceError > {
87
- let password = enter ( hal, "Set password" , false , CanCancel :: Yes ) . await ?;
88
- let password_repeat = enter ( hal, "Repeat password" , false , CanCancel :: Yes ) . await ?;
97
+ let password = enter (
98
+ hal,
99
+ "Set password" ,
100
+ PasswordType :: DevicePassword ,
101
+ CanCancel :: Yes ,
102
+ )
103
+ . await ?;
104
+ let password_repeat = enter (
105
+ hal,
106
+ "Repeat password" ,
107
+ PasswordType :: DevicePassword ,
108
+ CanCancel :: Yes ,
109
+ )
110
+ . await ?;
89
111
if password. as_str ( ) != password_repeat. as_str ( ) {
90
112
hal. ui ( ) . status ( "Passwords\n do not match" , false ) . await ;
91
113
return Err ( EnterTwiceError :: DoNotMatch ) ;
0 commit comments