electrum

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

commit e4ec690ffd70956331ea2e04aee1f963c3d19f68
parent c61f16ba0d0af17e5d428d4c4a45c131db9247ff
Author: Maran <maran.hidskes@gmail.com>
Date:   Sun, 10 Mar 2013 21:34:10 +0100

Merge branch 'master' into feature/label_sync

Diffstat:
Mgui/gui_classic.py | 151++++++++++++++++++++++++++++++++++---------------------------------------------
1 file changed, 65 insertions(+), 86 deletions(-)

diff --git a/gui/gui_classic.py b/gui/gui_classic.py @@ -1686,7 +1686,7 @@ class ElectrumWindow(QMainWindow): @protected - def sign_raw_transaction(self, tx, input_info, password): + def sign_raw_transaction(self, tx, input_info, dialog ="", password = ""): try: self.wallet.signrawtransaction(tx, input_info, [], password) @@ -1695,92 +1695,82 @@ class ElectrumWindow(QMainWindow): with open(fileName, "w+") as f: f.write(json.dumps(tx.as_dict(),indent=4) + '\n') self.show_message(_("Transaction saved succesfully")) + if dialog: + dialog.done(0) except BaseException, e: self.show_message(str(e)) + + def send_raw_transaction(self, raw_tx, dialog = ""): + result, result_message = self.wallet.sendtx( raw_tx ) + if result: + self.show_message("Transaction succesfully sent: %s" % (result_message)) + if dialog: + dialog.done(0) + else: + self.show_message("There was a problem sending your transaction:\n %s" % (result_message)) - def create_sign_transaction_window(self, tx_dict): - tx = Transaction(tx_dict["hex"]) - + def do_process_from_text(self): dialog = QDialog(self) dialog.setMinimumWidth(500) - dialog.setWindowTitle(_('Sign unsigned transaction')) + dialog.setWindowTitle(_('Input raw transaction')) dialog.setModal(1) + l = QVBoxLayout() + dialog.setLayout(l) + l.addWidget(QLabel(_("Transaction:"))) + txt = QTextEdit() + l.addWidget(txt) - vbox = QVBoxLayout() - dialog.setLayout(vbox) - vbox.addWidget( self.generate_transaction_information_widget(tx) ) - - if tx_dict["complete"] == True: - vbox.addWidget(QLabel(_("This transaction is already signed."))) - else: - vbox.addWidget(QLabel(_("Create a signed transaction."))) - vbox.addLayout(ok_cancel_buttons(dialog)) - input_info = json.loads(tx_dict["input_info"]) - - if dialog.exec_(): - self.sign_raw_transaction(tx, input_info) - - + ok_button = QPushButton(_("Load transaction")) + ok_button.setDefault(True) + ok_button.clicked.connect(dialog.accept) + l.addWidget(ok_button) - def do_sign_from_text(self): - txt, ok = QInputDialog.getText(QTextEdit(), _('Sign raw transaction'), _('Transaction data in JSON') + ':') - if not ok: - return - tx_dict = self.tx_dict_from_text(unicode(txt)) + dialog.exec_() + tx_dict = self.tx_dict_from_text(unicode(txt.toPlainText())) if tx_dict: - self.create_sign_transaction_window(tx_dict) - + self.create_process_transaction_window(tx_dict) - def do_sign_from_file(self): + def do_process_from_file(self): tx_dict = self.read_tx_from_file() - if tx_dict: - self.create_sign_transaction_window(tx_dict) - - - def send_raw_transaction(self, raw_tx): - result, result_message = self.wallet.sendtx( raw_tx ) - if result: - self.show_message("Transaction succesfully sent: %s" % (result_message)) - else: - self.show_message("There was a problem sending your transaction:\n %s" % (result_message)) - + if tx_dict: + self.create_process_transaction_window(tx_dict) - def create_send_transaction_window(self, tx_dict): + def create_process_transaction_window(self, tx_dict): tx = Transaction(tx_dict["hex"]) - + dialog = QDialog(self) dialog.setMinimumWidth(500) - dialog.setWindowTitle(_('Send raw transaction')) + dialog.setWindowTitle(_('Process raw transaction')) dialog.setModal(1) - vbox = QVBoxLayout() - dialog.setLayout(vbox) - vbox.addWidget( self.generate_transaction_information_widget(tx)) + l = QGridLayout() + dialog.setLayout(l) + + l.addWidget(QLabel(_("Transaction status: ")), 3,0) + l.addWidget(QLabel(_("Actions")), 4,0) if tx_dict["complete"] == False: - vbox.addWidget(QLabel(_("This transaction is not signed yet."))) + l.addWidget(QLabel(_("Unsigned")), 3,1) + if self.wallet.seed : + b = QPushButton("Sign transaction") + input_info = json.loads(tx_dict["input_info"]) + b.clicked.connect(lambda: self.sign_raw_transaction(tx, input_info, dialog)) + l.addWidget(b, 4, 1) + else: + l.addWidget(QLabel(_("Wallet is de-seeded, can't sign.")), 4,1) else: - vbox.addWidget(QLabel(_("Broadcast this transaction"))) - vbox.addLayout(ok_cancel_buttons(dialog)) - - if dialog.exec_(): - self.send_raw_transaction(tx_dict["hex"]) - + l.addWidget(QLabel(_("Signed")), 3,1) + b = QPushButton("Broadcast transaction") + b.clicked.connect(lambda: self.send_raw_transaction(tx, dialog)) + l.addWidget(b,4,1) - def do_send_from_file(self): - tx_dict = self.read_tx_from_file() - if tx_dict: - self.create_send_transaction_window(tx_dict) - + l.addWidget( self.generate_transaction_information_widget(tx), 0,0,2,3) + cancelButton = QPushButton(_("Cancel")) + cancelButton.clicked.connect(lambda: dialog.done(0)) + l.addWidget(cancelButton, 4,2) - def do_send_from_text(self): - txt, ok = QInputDialog.getText(QTextEdit(), _('Send raw transaction'), _('Transaction data in JSON') + ':') - if not ok: - return - tx_dict = self.tx_dict_from_text(unicode(txt)) - if tx_dict: - self.create_send_transaction_window(tx_dict) + dialog.exec_() @protected @@ -1939,14 +1929,19 @@ class ElectrumWindow(QMainWindow): grid_wallet.setColumnStretch(0,1) tabs.addTab(tab2, _('Wallet') ) + grid_wallet.addWidget(QLabel(_("Load raw transaction")), 3, 0) + grid_wallet.addWidget(EnterButton(_("From file"), self.do_process_from_file),3,1) + grid_wallet.addWidget(EnterButton(_("From text"), self.do_process_from_text),3,2) + grid_wallet.addWidget(HelpButton(_("This will give you the option to sign or broadcast a transaction based on it's status.")),3,3) + fee_label = QLabel(_('Transaction fee')) grid_wallet.addWidget(fee_label, 0, 0) fee_e = QLineEdit() fee_e.setText("%s"% str( Decimal( self.wallet.fee)/100000000 ) ) - grid_wallet.addWidget(fee_e, 0, 1) + grid_wallet.addWidget(fee_e, 0, 2) msg = _('Fee per transaction input. Transactions involving multiple inputs tend to require a higher fee.') + ' ' \ + _('Recommended value') + ': 0.001' - grid_wallet.addWidget(HelpButton(msg), 0, 2) + grid_wallet.addWidget(HelpButton(msg), 0, 3) fee_e.textChanged.connect(lambda: numbify(fee_e,False)) if not self.config.is_modifiable('fee'): for w in [fee_e, fee_label]: w.setEnabled(False) @@ -1956,15 +1951,15 @@ class ElectrumWindow(QMainWindow): usechange_combo = QComboBox() usechange_combo.addItems([_('Yes'), _('No')]) usechange_combo.setCurrentIndex(not self.wallet.use_change) - grid_wallet.addWidget(usechange_combo, 1, 1) - grid_wallet.addWidget(HelpButton(_('Using change addresses makes it more difficult for other people to track your transactions.')+' '), 1, 2) + grid_wallet.addWidget(usechange_combo, 1, 2) + grid_wallet.addWidget(HelpButton(_('Using change addresses makes it more difficult for other people to track your transactions.')+' '), 1, 3) if not self.config.is_modifiable('use_change'): usechange_combo.setEnabled(False) gap_label = QLabel(_('Gap limit')) grid_wallet.addWidget(gap_label, 2, 0) gap_e = QLineEdit() gap_e.setText("%d"% self.wallet.gap_limit) - grid_wallet.addWidget(gap_e, 2, 1) + grid_wallet.addWidget(gap_e, 2, 2) msg = _('The gap limit is the maximal number of contiguous unused addresses in your sequence of receiving addresses.') + '\n' \ + _('You may increase it if you need more receiving addresses.') + '\n\n' \ + _('Your current gap limit is') + ': %d'%self.wallet.gap_limit + '\n' \ @@ -1972,7 +1967,7 @@ class ElectrumWindow(QMainWindow): + _('Warning') + ': ' \ + _('The gap limit parameter must be provided in order to recover your wallet from seed.') + ' ' \ + _('Do not modify it if you do not understand what you are doing, or if you expect to recover your wallet without knowing it!') + '\n\n' - grid_wallet.addWidget(HelpButton(msg), 2, 2) + grid_wallet.addWidget(HelpButton(msg), 2, 3) gap_e.textChanged.connect(lambda: numbify(nz_e,True)) if not self.config.is_modifiable('gap_limit'): for w in [gap_e, gap_label]: w.setEnabled(False) @@ -2009,22 +2004,6 @@ class ElectrumWindow(QMainWindow): grid_io.setRowStretch(4,1) - tab4 = QWidget() - grid_raw = QGridLayout(tab4) - grid_raw.setColumnStretch(0,1) - tabs.addTab(tab4, _('Raw tx') ) # move this to wallet tab - - if self.wallet.seed: - grid_raw.addWidget(QLabel(_("Sign transaction")), 1, 0) - grid_raw.addWidget(EnterButton(_("From file"), self.do_sign_from_file),1,1) - grid_raw.addWidget(EnterButton(_("From text"), self.do_sign_from_text),1,2) - grid_raw.addWidget(HelpButton(_("Sign an unsigned transaction generated by a watching-only wallet")),1,3) - - grid_raw.addWidget(QLabel(_("Send signed transaction")), 2, 0) - grid_raw.addWidget(EnterButton(_("From file"), self.do_send_from_file),2,1) - grid_raw.addWidget(EnterButton(_("From text"), self.do_send_from_text),2,2) - grid_raw.addWidget(HelpButton(_("This will broadcast a transaction to the network.")),2,3) - grid_raw.setRowStretch(3,1) # plugins if self.plugins: