@@ -1076,7 +1076,14 @@ def is_psbt(filename):
10761076 return False
10771077
10781078 with open (filename , 'rb' ) as fd :
1079- return fd .read (5 ) == b'psbt\xff '
1079+ taste = fd .read (10 )
1080+ if taste [0 :5 ] == b'psbt\xff ' :
1081+ return True
1082+ if taste [0 :10 ] == b'70736274ff' : # hex-encoded
1083+ return True
1084+ if taste [0 :6 ] == b'cHNidP' : # base64-encoded
1085+ return True
1086+ return False
10801087
10811088 choices = await file_picker (None , suffix = 'psbt' , min_size = 50 ,
10821089 max_size = MAX_TXN_LEN , taster = is_psbt )
@@ -1109,6 +1116,29 @@ def is_psbt(filename):
11091116 await sign_psbt_file (input_psbt )
11101117
11111118
1119+ async def sign_message_on_sd (* a ):
1120+ # Menu item: choose a file to be signed (as a short text message)
1121+ #
1122+ def is_signable (filename ):
1123+ if '-signed' in filename .lower ():
1124+ return False
1125+ with open (filename , 'rt' ) as fd :
1126+ lines = fd .readlines ()
1127+ return (1 <= len (lines ) <= 5 )
1128+
1129+ fn = await file_picker ('Choose text file to be signed.' ,
1130+ suffix = 'txt' , min_size = 2 ,
1131+ max_size = 500 , taster = is_signable ,
1132+ none_msg = 'No suitable files found. Must be one line of text, in a .TXT file, optionally followed by a subkey derivation path on a second line.' )
1133+
1134+ if not fn :
1135+ return
1136+
1137+ # start the process
1138+ from auth import sign_txt_file
1139+ await sign_txt_file (fn )
1140+
1141+
11121142async def pin_changer (_1 , _2 , item ):
11131143 # Help them to change pins with appropriate warnings.
11141144 # - forcing them to drill-down to get warning about secondary is on purpose
0 commit comments