def create_quote_text(self, btc_balance): """Return a string copy of the amount fiat currency the user has in xmc.""" from electrum_xmc.plugins import run_hook r = {} run_hook("get_fiat_balance_text", btc_balance, r) return r.get(0, "")
def get_tx_fee(self, tx): fee = Multisig_Wallet.get_tx_fee(self, tx) x = run_hook('extra_fee', tx) if x: fee += x return fee
def estimated_fee(self, tx): fee = Multisig_Wallet.estimated_fee(self, tx) x = run_hook('extra_fee', tx) if x: fee += x return fee
def main(self, url): last_wallet = self.config.get('gui_last_wallet') if last_wallet is not None and self.config.get('wallet_path') is None: if os.path.exists(last_wallet): self.config.cmdline_options['default_wallet_path'] = last_wallet try: storage = WalletStorage(self.config.get_wallet_path()) except BaseException as e: QMessageBox.warning(None, _('Warning'), str(e), _('OK')) self.config.set_key('gui_last_wallet', None) return if storage.file_exists: try: wallet = Wallet(storage) except BaseException as e: QMessageBox.warning(None, _('Warning'), str(e), _('OK')) return action = wallet.get_action() else: action = 'new' if action is not None: wallet = self.run_wizard(storage, action) if not wallet: return else: wallet.start_threads(self.network) # init tray self.dark_icon = self.config.get("dark_icon", False) icon = QIcon(":icons/electrum_dark_icon.png") if self.dark_icon else QIcon(':icons/electrum_light_icon.png') self.tray = QSystemTrayIcon(icon, None) self.tray.setToolTip('Electrum-XMC') self.tray.activated.connect(self.tray_activated) self.build_tray_menu() self.tray.show() # main window self.main_window = w = ElectrumWindow(self.config, self.network, self) self.current_window = self.main_window #lite window self.init_lite() # plugins interact with main window run_hook('init_qt', self) w.load_wallet(wallet) # initial configuration if self.config.get('hide_gui') is True and self.tray.isVisible(): self.main_window.hide() self.lite_window.hide() else: if self.config.get('lite_mode') is True: self.go_lite() else: self.go_full() s = Timer() s.start() self.windows.append(w) if url: self.set_url(url) w.connect_slots(s) signal.signal(signal.SIGINT, lambda *args: self.app.quit()) self.app.exec_() if self.tray: self.tray.hide() # clipboard persistence # see http://www.mail-archive.com/[email protected]/msg17328.html event = QtCore.QEvent(QtCore.QEvent.Clipboard) self.app.sendEvent(self.app.clipboard(), event) w.close_wallet()
def __init__(self, tx, parent, desc, prompt_if_unsaved): """Transactions in the wallet will show their description. Pass desc to give a description for txs not yet in the wallet. """ self.tx = tx self.tx.deserialize() self.parent = parent self.wallet = parent.wallet self.prompt_if_unsaved = prompt_if_unsaved self.saved = False self.broadcast = False self.desc = desc QDialog.__init__(self) self.setMinimumWidth(600) self.setWindowTitle(_("Transaction")) vbox = QVBoxLayout() self.setLayout(vbox) vbox.addWidget(QLabel(_("Transaction ID:"))) self.tx_hash_e = ButtonsLineEdit() qr_show = lambda: self.parent.show_qrcode(str(self.tx_hash_e.text()), "Transaction ID") self.tx_hash_e.addButton(":icons/qrcode.png", qr_show, _("Show as QR code")) self.tx_hash_e.setReadOnly(True) vbox.addWidget(self.tx_hash_e) self.status_label = QLabel() vbox.addWidget(self.status_label) self.tx_desc = QLabel() vbox.addWidget(self.tx_desc) self.date_label = QLabel() vbox.addWidget(self.date_label) self.amount_label = QLabel() vbox.addWidget(self.amount_label) self.fee_label = QLabel() vbox.addWidget(self.fee_label) self.add_io(vbox) vbox.addStretch(1) self.sign_button = b = QPushButton(_("Sign")) b.clicked.connect(self.sign) self.broadcast_button = b = QPushButton(_("Broadcast")) b.clicked.connect(self.do_broadcast) self.save_button = b = QPushButton(_("Save")) b.clicked.connect(self.save) self.cancel_button = b = QPushButton(_("Close")) b.clicked.connect(self.close) b.setDefault(True) self.qr_button = b = QPushButton() b.setIcon(QIcon(":icons/qrcode.png")) b.clicked.connect(self.show_qr) self.copy_button = CopyButton(lambda: str(self.tx), self.parent.app) # Action buttons self.buttons = [self.sign_button, self.broadcast_button, self.cancel_button] # Transaction sharing buttons self.sharing_buttons = [self.copy_button, self.qr_button, self.save_button] run_hook("transaction_dialog", self) hbox = QHBoxLayout() hbox.addLayout(Buttons(*self.sharing_buttons)) hbox.addStretch(1) hbox.addLayout(Buttons(*self.buttons)) vbox.addLayout(hbox) self.update()
def update(self): is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(self.tx) tx_hash = self.tx.hash() desc = self.desc time_str = None self.broadcast_button.hide() if self.tx.is_complete(): status = _("Signed") if tx_hash in self.wallet.transactions.keys(): desc, is_default = self.wallet.get_label(tx_hash) conf, timestamp = self.wallet.get_confirmations(tx_hash) if timestamp: time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(" ")[:-3] else: time_str = _("Pending") status = _("%d confirmations") % conf else: self.broadcast_button.show() # cannot broadcast when offline if self.parent.network is None: self.broadcast_button.setEnabled(False) else: s, r = self.tx.signature_count() status = _("Unsigned") if s == 0 else _("Partially signed") + " (%d/%d)" % (s, r) tx_hash = _("Unknown") if self.wallet.can_sign(self.tx): self.sign_button.show() else: self.sign_button.hide() self.tx_hash_e.setText(tx_hash) if desc is None: self.tx_desc.hide() else: self.tx_desc.setText(_("Description") + ": " + desc) self.tx_desc.show() self.status_label.setText(_("Status:") + " " + status) if time_str is not None: self.date_label.setText(_("Date: %s") % time_str) self.date_label.show() else: self.date_label.hide() # if we are not synchronized, we cannot tell if not self.wallet.up_to_date: return if is_relevant: if is_mine: if fee is not None: self.amount_label.setText( _("Amount sent:") + " %s" % self.parent.format_amount(-v + fee) + " " + self.parent.base_unit() ) self.fee_label.setText( _("Transaction fee") + ": %s" % self.parent.format_amount(-fee) + " " + self.parent.base_unit() ) else: self.amount_label.setText( _("Amount sent:") + " %s" % self.parent.format_amount(-v) + " " + self.parent.base_unit() ) self.fee_label.setText(_("Transaction fee") + ": " + _("unknown")) else: self.amount_label.setText( _("Amount received:") + " %s" % self.parent.format_amount(v) + " " + self.parent.base_unit() ) else: self.amount_label.setText(_("Transaction unrelated to your wallet")) run_hook("transaction_dialog_update", self)