lightning: assert result type, add invoice qr dialog

This commit is contained in:
Janus 2018-03-28 17:37:17 +02:00 committed by SomberNight
parent 5bf7fb87e3
commit e48ad713c3
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
2 changed files with 6 additions and 0 deletions

View file

@ -5,6 +5,7 @@ from PyQt5 import QtCore, QtWidgets
from collections import OrderedDict
import logging
from electrum.lightning import lightningCall
from .qrcodewidget import QRDialog
mapping = {0: "r_hash", 1: "pay_req", 2: "settled"}
revMapp = {"r_hash": 0, "pay_req": 1, "settled": 2}
@ -61,7 +62,11 @@ class LightningInvoiceList(QtWidgets.QWidget):
def copy():
print(pay_req)
cb.setText(pay_req)
def qr():
d = QRDialog(pay_req, self, "Lightning invoice")
d.exec_()
menu.addAction("Copy payment request", copy)
menu.addAction("Show payment request as QR code", qr)
menu.exec_(self._tv.viewport().mapToGlobal(position))
def lightningWorkerHandler(self, sourceClassName, obj):
new = {}

View file

@ -625,6 +625,7 @@ class LightningRPC:
raise
toprint = result
try:
assert type(result) is not str, result
assert result["stderr"] == "" and result["returncode"] == 0, "LightningRPC detected error: " + result["stderr"]
toprint = json.loads(result["stdout"])
for i in self.subscribers: applyMethodName(i)(toprint)