From 97e849a248c6415e1032090ebb01b999c6fff1d4 Mon Sep 17 00:00:00 2001 From: ecdsa Date: Wed, 1 May 2013 10:40:44 +0200 Subject: [PATCH] move verify_message to wallet --- gui/gui_classic.py | 8 +++----- lib/commands.py | 7 +------ lib/wallet.py | 7 +++++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gui/gui_classic.py b/gui/gui_classic.py index de5e561f1..b14b11e1f 100644 --- a/gui/gui_classic.py +++ b/gui/gui_classic.py @@ -1465,12 +1465,10 @@ class ElectrumWindow(QMainWindow): layout.setRowStretch(3,1) def do_verify(): - try: - self.wallet.verify_message(verify_address.text(), str(verify_signature.toPlainText()), str(verify_message.toPlainText())) + if self.wallet.verify_message(verify_address.text(), str(verify_signature.toPlainText()), str(verify_message.toPlainText())): self.show_message(_("Signature verified")) - except BaseException, e: - self.show_message(str(e)) - return + else: + self.show_message(_("Error: wrong signature")) hbox = QHBoxLayout() b = QPushButton(_("Verify")) diff --git a/lib/commands.py b/lib/commands.py index 8db79b663..d9df504c0 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -203,12 +203,7 @@ class Commands: def verifymessage(self, address, signature, message): - try: - EC_KEY.verify_message(address, signature, message) - return True - except BaseException as e: - print_error("Verification error: {0}".format(e)) - return False + return self.wallet.verify_message(address, signature, message) def _mktx(self, to_address, amount, fee = None, change_addr = None, domain = None): diff --git a/lib/wallet.py b/lib/wallet.py index 844e3d18d..ddfb9cc22 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -292,6 +292,13 @@ class Wallet: compressed = is_compressed(sec) return key.sign_message(message, compressed, address) + def verify_message(self, address, signature, message): + try: + EC_KEY.verify_message(address, signature, message) + return True + except BaseException as e: + print_error("Verification error: {0}".format(e)) + return False def create_new_address(self, account, for_change): addresses = self.accounts[account][for_change]