Browse Source

raise an exception on trezor decrypt

283
ThomasV 10 years ago
parent
commit
449feddaaf
  1. 12
      gui/qt/main_window.py
  2. 21
      plugins/trezor.py

12
gui/qt/main_window.py

@ -2000,9 +2000,9 @@ class ElectrumWindow(QMainWindow):
try:
decrypted = self.wallet.decrypt_message(str(pubkey_e.text()), str(encrypted_e.toPlainText()), password)
message_e.setText(decrypted)
except Exception as e:
except BaseException as e:
traceback.print_exc(file=sys.stdout)
self.show_message(str(e))
self.show_warning(str(e))
def do_encrypt(self, message_e, pubkey_e, encrypted_e):
@ -2011,10 +2011,9 @@ class ElectrumWindow(QMainWindow):
try:
encrypted = bitcoin.encrypt_message(message, str(pubkey_e.text()))
encrypted_e.setText(encrypted)
except Exception as e:
except BaseException as e:
traceback.print_exc(file=sys.stdout)
self.show_message(str(e))
self.show_warning(str(e))
def encrypt_message(self, address = ''):
@ -2065,6 +2064,9 @@ class ElectrumWindow(QMainWindow):
def show_message(self, msg):
QMessageBox.information(self, _('Message'), msg, _('OK'))
def show_warning(self, msg):
QMessageBox.warning(self, _('Warning'), msg, _('OK'))
def password_dialog(self, msg=None):
d = QDialog(self)
d.setModal(1)

21
plugins/trezor.py

@ -214,16 +214,17 @@ class TrezorWallet(NewWallet):
pass
def decrypt_message(self, pubkey, message, password):
address = public_key_to_bc_address(pubkey.decode('hex'))
address_path = self.address_id(address)
address_n = self.get_client().expand_path(address_path)
try:
decrypted_msg = self.get_client().decrypt_message(address_n, b64decode(message))
except Exception, e:
give_error(e)
finally:
twd.emit(SIGNAL('trezor_done'))
return str(decrypted_msg)
raise BaseException( _('Decrypt method is not implemented in Trezor') )
#address = public_key_to_bc_address(pubkey.decode('hex'))
#address_path = self.address_id(address)
#address_n = self.get_client().expand_path(address_path)
#try:
# decrypted_msg = self.get_client().decrypt_message(address_n, b64decode(message))
#except Exception, e:
# give_error(e)
#finally:
# twd.emit(SIGNAL('trezor_done'))
#return str(decrypted_msg)
def sign_message(self, address, message, password):
if not self.check_proper_device():

Loading…
Cancel
Save