X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=gui%2Fqt%2Fmain_window.py;h=706c1f758515b3cbb6a87f5a3dc74936fce470ea;hb=6f246fe90e549760984fd3eb3baaef8979148291;hp=7ced30e85782be3625ce3ae6415f894e5285ca11;hpb=1bb00ff5af3a7f23f23c92b69cc2ff412731a7f3;p=electrum-nvc.git diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 7ced30e..706c1f7 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -75,7 +75,7 @@ PR_ERROR = 4 # could not parse from electrum import ELECTRUM_VERSION import re -from util import * +from util import MyTreeWidget, HelpButton, EnterButton, line_dialog, text_dialog, ok_cancel_buttons, close_button, WaitingDialog def format_status(x): @@ -286,12 +286,20 @@ class ElectrumWindow(QMainWindow): import installwizard wallet_folder = os.path.dirname(self.wallet.storage.path) - filename = unicode( QFileDialog.getSaveFileName(self, _('Enter a new file name'), wallet_folder) ) + i = 1 + while True: + filename = "wallet_%d"%i + if filename in os.listdir(wallet_folder): + i += 1 + else: + break + + filename = line_dialog(self, _('New Wallet'), _('Enter file name') + ':', _('OK'), filename) if not filename: return - filename = os.path.join(wallet_folder, filename) - storage = WalletStorage({'wallet_path': filename}) + full_path = os.path.join(wallet_folder, filename) + storage = WalletStorage({'wallet_path': full_path}) if storage.file_exists: QMessageBox.critical(None, "Error", _("File exists")) return @@ -352,6 +360,7 @@ class ElectrumWindow(QMainWindow): raw_transaction_menu.addAction(_("&From file"), self.do_process_from_file) raw_transaction_menu.addAction(_("&From text"), self.do_process_from_text) raw_transaction_menu.addAction(_("&From the blockchain"), self.do_process_from_txid) + raw_transaction_menu.addAction(_("&From QR code"), self.read_tx_from_qrcode) self.raw_transaction_menu = raw_transaction_menu help_menu = menubar.addMenu(_("&Help")) @@ -748,7 +757,7 @@ class ElectrumWindow(QMainWindow): def new_receive_address(self): domain = self.wallet.get_account_addresses(self.current_account, include_change=False) for addr in domain: - if not self.wallet.address_is_old(addr) and addr not in self.receive_requests.keys(): + if not self.wallet.history.get(addr) and addr not in self.receive_requests.keys(): break else: if isinstance(self.wallet, Imported_Wallet): @@ -765,7 +774,7 @@ class ElectrumWindow(QMainWindow): self.receive_requests = self.wallet.storage.get('receive_requests',{}) domain = self.wallet.get_account_addresses(self.current_account, include_change=False) for addr in domain: - if not self.wallet.address_is_old(addr) and addr not in self.receive_requests.keys(): + if not self.wallet.history.get(addr) and addr not in self.receive_requests.keys(): break else: addr = '' @@ -1060,6 +1069,7 @@ class ElectrumWindow(QMainWindow): self.wallet.add_keypairs(tx, keypairs, password) self.wallet.sign_transaction(tx, keypairs, password) except Exception as e: + traceback.print_exc(file=sys.stdout) tx.error = str(e) return tx @@ -1306,8 +1316,10 @@ class ElectrumWindow(QMainWindow): def create_invoices_tab(self): - l, w = self.create_list_tab([_('Requestor'), _('Memo'),_('Amount'), _('Status')]) + l, w = self.create_list_tab([_('Requestor'), _('Memo'), _('Date'), _('Amount'), _('Status')]) l.setColumnWidth(0, 150) + l.setColumnWidth(2, 150) + l.setColumnWidth(3, 150) h = l.header() h.setStretchLastSection(False) h.setResizeMode(1, QHeaderView.Stretch) @@ -1320,21 +1332,17 @@ class ElectrumWindow(QMainWindow): invoices = self.wallet.storage.get('invoices', {}) l = self.invoices_list l.clear() - for key, value in invoices.items(): - try: - domain, memo, amount, expiration_date, status, tx_hash = value - except: - invoices.pop(key) - continue + for value in sorted(invoices.values(), key=lambda x: -x[3]): + domain, memo, amount, expiration_date, status, tx_hash = value if status == PR_UNPAID and expiration_date and expiration_date < time.time(): status = PR_EXPIRED - item = QTreeWidgetItem( [ domain, memo, self.format_amount(amount), format_status(status)] ) + date_str = datetime.datetime.fromtimestamp(expiration_date).isoformat(' ')[:-3] + item = QTreeWidgetItem( [ domain, memo, date_str, self.format_amount(amount, whitespaces=True), format_status(status)] ) + item.setFont(0, QFont(MONOSPACE_FONT)) + item.setFont(3, QFont(MONOSPACE_FONT)) l.addTopLevelItem(item) - l.setCurrentItem(l.topLevelItem(0)) - - def delete_imported_key(self, addr): if self.question(_("Do you want to remove")+" %s "%addr +_("from your wallet?")): self.wallet.delete_imported_key(addr) @@ -2082,6 +2090,21 @@ class ElectrumWindow(QMainWindow): QMessageBox.critical(None, _("Unable to parse transaction"), _("Electrum was unable to parse your transaction")) + def read_tx_from_qrcode(self): + data = run_hook('scan_qr_hook') + if not data: + return + # transactions are binary, but qrcode seems to return utf8... + z = data.decode('utf8') + s = '' + for b in z: + s += chr(ord(b)) + data = s.encode('hex') + tx = self.tx_from_text(data) + if not tx: + return + self.show_transaction(tx) + def read_tx_from_file(self): fileName = self.getOpenFileName(_("Select your transaction file"), "*.txn")