def init(self):
self.win = self.gui.main_window
-
- def load_wallet(self, wallet):
+ self.win.raw_transaction_menu.addAction(_("&From QR code"), self.read_raw_qr)
b = QPushButton(_("Scan QR code"))
b.clicked.connect(self.fill_from_qr)
- self.send_tab_grid.addWidget(b, 1, 5)
- b2 = QPushButton(_("Scan TxQR"))
- b2.clicked.connect(self.read_raw_qr)
-
- if not wallet.seed:
- b3 = QPushButton(_("Show unsigned TxQR"))
- b3.clicked.connect(self.show_raw_qr)
- self.send_tab_grid.addWidget(b3, 7, 1)
- self.send_tab_grid.addWidget(b2, 7, 2)
- else:
- self.send_tab_grid.addWidget(b2, 7, 1)
+ self.win.send_grid.addWidget(b, 1, 5)
+ self.win.send_grid.setColumnStretch(5, 0)
+ self.win.send_grid.setColumnStretch(6, 1)
+
+ def init_transaction_dialog(self, dialog, buttons):
+ b = QPushButton(_("Show QR code"))
+ b.clicked.connect(lambda: self.show_raw_qr(dialog.tx))
+ buttons.insertWidget(1,b)
def is_available(self):
return self._is_available
- def create_send_tab(self, grid):
- self.send_tab_grid = grid
-
def scan_qr(self):
proc = zbar.Processor()
try:
continue
return r.data
- def show_raw_qr(self):
- r = self.win.read_send_tab()
- if not r:
- return
-
- outputs, fee, label, coins = r
- try:
- tx = self.win.wallet.make_unsigned_transaction(outputs, fee, None, None, coins)
- except Exception as e:
- self.win.show_message(str(e))
- return
-
- if tx.requires_fee(self.win.wallet.verifier) and fee < MIN_RELAY_TX_FEE:
- QMessageBox.warning(self.win, _('Error'), _("This transaction requires a higher fee, or it will not be propagated by the network."), _('OK'))
- return
-
- try:
- out = {
- "hex" : tx.hash(),
- "complete" : "false"
- }
-
- input_info = []
-
- except Exception as e:
- self.win.show_message(str(e))
-
+ def show_raw_qr(self, tx):
try:
json_text = json.dumps(tx.as_dict()).replace(' ', '')
- self.show_tx_qrcode(json_text, 'Unsigned Transaction')
+ self.win.show_qrcode(json_text, 'Unsigned Transaction')
except Exception as e:
self.win.show_message(str(e))
- def show_tx_qrcode(self, data, title):
- if not data: return
- d = QDialog(self.win)
- d.setModal(1)
- d.setWindowTitle(title)
- d.setMinimumSize(250, 525)
- vbox = QVBoxLayout()
- qrw = QRCodeWidget(data)
- vbox.addWidget(qrw, 0)
- hbox = QHBoxLayout()
- hbox.addStretch(1)
-
- def print_qr(self):
- filename = "qrcode.bmp"
- electrum_gui.bmp.save_qrcode(qrw.qr, filename)
- QMessageBox.information(None, _('Message'), _("QR code saved to file") + " " + filename, _('OK'))
-
- b = QPushButton(_("Save"))
- hbox.addWidget(b)
- b.clicked.connect(print_qr)
-
- b = QPushButton(_("Close"))
- hbox.addWidget(b)
- b.clicked.connect(d.accept)
- b.setDefault(True)
-
- vbox.addLayout(hbox, 1)
- d.setLayout(vbox)
- d.exec_()
def read_raw_qr(self):
qrcode = self.scan_qr()