electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 37cf6925cf7677b79c673600d460f163b8a1faaf
parent d160851496ccf196f76fbf8dee063c4cd7cddcdb
Author: ThomasV <thomasv@gitorious>
Date:   Sun,  2 Mar 2014 20:26:42 +0100

Merge branch 'verify-message' of github.com:wozz/electrum into wozz-verify-message

Diffstat:
Mgui/qt/main_window.py | 83+++++++++++++++++++++++++++++--------------------------------------------------
1 file changed, 30 insertions(+), 53 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -409,6 +409,9 @@ class ElectrumWindow(QMainWindow): plugins_labels = tools_menu.addAction(_("&Plugins")) plugins_labels.triggered.connect(self.plugins_dialog) + verifymessage = tools_menu.addAction(_("&Verify message")) + verifymessage.triggered.connect(self.verify_message) + tools_menu.addSeparator() csv_transaction_menu = tools_menu.addMenu(_("&Create transaction")) @@ -1151,7 +1154,7 @@ class ElectrumWindow(QMainWindow): menu.addAction(_("Edit label"), lambda: self.edit_label(True)) if self.wallet.seed: menu.addAction(_("Private key"), lambda: self.show_private_key(addr)) - menu.addAction(_("Sign message"), lambda: self.sign_message(addr)) + menu.addAction(_("Sign message"), lambda: self.sign_message(True,addr)) if addr in self.wallet.imported_keys: menu.addAction(_("Remove from wallet"), lambda: self.delete_imported_key(addr)) @@ -1718,16 +1721,26 @@ class ElectrumWindow(QMainWindow): except Exception as e: self.show_message(str(e)) - def sign_message(self, address): - if not address: return + def do_verify(self, address, message, signature): + message = unicode(message.toPlainText()) + message = message.encode('utf-8') + if bitcoin.verify_message(address.text(), str(signature.toPlainText()), message): + self.show_message(_("Signature verified")) + else: + self.show_message(_("Error: wrong signature")) + + + def sign_message(self, sign, address): + if sign and not address: return d = QDialog(self) d.setModal(1) - d.setWindowTitle(_('Sign Message')) + if sign: + d.setWindowTitle(_('Sign Message')) + elif not sign: + d.setWindowTitle(_('Verify Message')) d.setMinimumSize(410, 290) - tab_widget = QTabWidget() - tab = QWidget() - layout = QGridLayout(tab) + layout = QGridLayout(d) sign_address = QLineEdit() @@ -1745,61 +1758,23 @@ class ElectrumWindow(QMainWindow): layout.addWidget(sign_signature, 3, 1) layout.setRowStretch(3,1) - - hbox = QHBoxLayout() - b = QPushButton(_("Sign")) - hbox.addWidget(b) - b.clicked.connect(lambda: self.do_sign(sign_address, sign_message, sign_signature)) - b = QPushButton(_("Close")) - b.clicked.connect(d.accept) - hbox.addWidget(b) - layout.addLayout(hbox, 4, 1) - tab_widget.addTab(tab, _("Sign")) - - - tab = QWidget() - layout = QGridLayout(tab) - - verify_address = QLineEdit() - layout.addWidget(QLabel(_('Address')), 1, 0) - layout.addWidget(verify_address, 1, 1) - - verify_message = QTextEdit() - layout.addWidget(QLabel(_('Message')), 2, 0) - layout.addWidget(verify_message, 2, 1) - layout.setRowStretch(2,3) - - verify_signature = QTextEdit() - layout.addWidget(QLabel(_('Signature')), 3, 0) - layout.addWidget(verify_signature, 3, 1) - layout.setRowStretch(3,1) - - def do_verify(): - message = unicode(verify_message.toPlainText()) - message = message.encode('utf-8') - if bitcoin.verify_message(verify_address.text(), str(verify_signature.toPlainText()), message): - self.show_message(_("Signature verified")) - else: - self.show_message(_("Error: wrong signature")) - hbox = QHBoxLayout() - b = QPushButton(_("Verify")) - b.clicked.connect(do_verify) + if sign: + b = QPushButton(_("Sign")) + elif not sign: + b = QPushButton(_("Verify")) hbox.addWidget(b) + if sign: + b.clicked.connect(lambda: self.do_sign(sign_address, sign_message, sign_signature)) + elif not sign: + b.clicked.connect(lambda: self.do_verify(sign_address, sign_message, sign_signature)) b = QPushButton(_("Close")) b.clicked.connect(d.accept) hbox.addWidget(b) layout.addLayout(hbox, 4, 1) - tab_widget.addTab(tab, _("Verify")) - - vbox = QVBoxLayout() - vbox.addWidget(tab_widget) - d.setLayout(vbox) d.exec_() - - def question(self, msg): return QMessageBox.question(self, _('Message'), msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes @@ -2188,6 +2163,8 @@ class ElectrumWindow(QMainWindow): event.accept() + def verify_message(self): + self.sign_message(False, "") def plugins_dialog(self): from electrum.plugins import plugins