Browse Source

after-rebase fixes

patch-4
Sander van Grieken 3 years ago
parent
commit
b188b48e2f
  1. 4
      electrum/gui/qml/components/controls/InvoiceDelegate.qml
  2. 1
      electrum/gui/qml/qeaddressdetails.py
  3. 5
      electrum/gui/qml/qebitcoin.py
  4. 12
      electrum/gui/qml/qeinvoice.py
  5. 13
      electrum/gui/qml/qeinvoicelistmodel.py
  6. 5
      electrum/gui/qml/qeqr.py
  7. 5
      electrum/gui/qml/qewallet.py

4
electrum/gui/qml/components/controls/InvoiceDelegate.qml

@ -33,7 +33,9 @@ ItemDelegate {
Layout.rowSpan: 2
Layout.preferredWidth: constants.iconSizeLarge
Layout.preferredHeight: constants.iconSizeLarge
source: model.type == 0 ? "../../../icons/bitcoin.png" : "../../../icons/lightning.png"
source: model.is_lightning
? "../../../icons/lightning.png"
: "../../../icons/bitcoin.png"
}
RowLayout {

1
electrum/gui/qml/qeaddressdetails.py

@ -5,7 +5,6 @@ from decimal import Decimal
from electrum.logging import get_logger
from electrum.util import DECIMAL_POINT_DEFAULT
from .qetransactionlistmodel import QEAddressTransactionListModel
from .qewallet import QEWallet
from .qetypes import QEAmount

5
electrum/gui/qml/qebitcoin.py

@ -8,7 +8,7 @@ from electrum.keystore import bip39_is_checksum_valid
from electrum.bip32 import is_bip32_derivation
from electrum.slip39 import decode_mnemonic, Slip39Error
from electrum import mnemonic
from electrum.util import parse_URI, create_bip21_uri, InvalidBitcoinURI
from electrum.util import parse_URI, create_bip21_uri, InvalidBitcoinURI, get_asyncio_loop
from .qetypes import QEAmount
@ -58,8 +58,7 @@ class QEBitcoin(QObject):
self._logger.debug('seed generated')
self.generatedSeedChanged.emit()
loop = asyncio.get_event_loop()
asyncio.run_coroutine_threadsafe(co_gen_seed(seed_type, language), loop)
asyncio.run_coroutine_threadsafe(co_gen_seed(seed_type, language), get_asyncio_loop())
@pyqtSlot(str)
@pyqtSlot(str,bool,bool)

12
electrum/gui/qml/qeinvoice.py

@ -8,7 +8,7 @@ from electrum.i18n import _
from electrum.keystore import bip39_is_checksum_valid
from electrum.util import (parse_URI, create_bip21_uri, InvalidBitcoinURI, InvoiceError,
maybe_extract_bolt11_invoice)
from electrum.invoices import Invoice, OnchainInvoice, LNInvoice
from electrum.invoices import Invoice
from electrum.invoices import (PR_UNPAID,PR_EXPIRED,PR_UNKNOWN,PR_PAID,PR_INFLIGHT,
PR_FAILED,PR_ROUTING,PR_UNCONFIRMED)
from electrum.transaction import PartialTxOutput
@ -164,12 +164,16 @@ class QEInvoice(QObject):
self._effectiveInvoice = None ###TODO
self.invoiceChanged.emit()
def setValidOnchainInvoice(self, invoice: OnchainInvoice):
def setValidOnchainInvoice(self, invoice: Invoice):
self._logger.debug('setValidOnchainInvoice')
if invoice.is_lightning():
raise Exception('unexpected LN invoice')
self.set_effective_invoice(invoice)
def setValidLightningInvoice(self, invoice: LNInvoice):
def setValidLightningInvoice(self, invoice: Invoice):
self._logger.debug('setValidLightningInvoice')
if not invoice.is_lightning():
raise Exception('unexpected Onchain invoice')
self.set_effective_invoice(invoice)
def create_onchain_invoice(self, outputs, message, payment_request, uri):
@ -215,7 +219,7 @@ class QEInvoice(QObject):
lninvoice = None
try:
maybe_lightning_invoice = maybe_extract_bolt11_invoice(maybe_lightning_invoice)
lninvoice = LNInvoice.from_bech32(maybe_lightning_invoice)
lninvoice = Invoice.from_bech32(maybe_lightning_invoice)
except InvoiceError as e:
pass

13
electrum/gui/qml/qeinvoicelistmodel.py

@ -18,7 +18,7 @@ class QEAbstractInvoiceListModel(QAbstractListModel):
self.invoices = []
# define listmodel rolemap
_ROLE_NAMES=('key','type','timestamp','date','message','amount','status','status_str','address','expiration')
_ROLE_NAMES=('key','is_lightning','timestamp','date','message','amount','status','status_str','address','expiration')
_ROLE_KEYS = range(Qt.UserRole, Qt.UserRole + len(_ROLE_NAMES))
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))
_ROLE_RMAP = dict(zip(_ROLE_NAMES, _ROLE_KEYS))
@ -113,13 +113,10 @@ class QEInvoiceListModel(QEAbstractInvoiceListModel):
def invoice_to_model(self, invoice: Invoice):
item = self.wallet.export_invoice(invoice)
item['type'] = invoice.type # 0=onchain, 2=LN
item['is_lightning'] = invoice.is_lightning()
item['date'] = format_time(item['timestamp'])
item['amount'] = QEAmount(amount_sat=invoice.get_amount_sat())
if invoice.type == 0:
item['key'] = invoice.id
elif invoice.type == 2:
item['key'] = invoice.rhash
item['key'] = invoice.get_id()
return item
@ -137,8 +134,8 @@ class QERequestListModel(QEAbstractInvoiceListModel):
def invoice_to_model(self, req: Invoice):
item = self.wallet.export_request(req)
item['key'] = self.wallet.get_key_for_receive_request(req)
item['type'] = req.type # 0=onchain, 2=LN
item['key'] = req.get_id() #self.wallet.get_key_for_receive_request(req)
item['is_lightning'] = req.is_lightning()
item['date'] = format_time(item['timestamp'])
item['amount'] = QEAmount(amount_sat=req.get_amount_sat())

5
electrum/gui/qml/qeqr.py

@ -10,7 +10,7 @@ from PIL import Image, ImageQt
from electrum.logging import get_logger
from electrum.qrreader import get_qr_reader
from electrum.i18n import _
from electrum.util import profiler
from electrum.util import profiler, get_asyncio_loop
class QEQRParser(QObject):
def __init__(self, text=None, parent=None):
@ -81,8 +81,7 @@ class QEQRParser(QObject):
self._busy = False
self.busyChanged.emit()
loop = asyncio.get_event_loop()
asyncio.run_coroutine_threadsafe(co_parse_qr(frame_cropped), loop)
asyncio.run_coroutine_threadsafe(co_parse_qr(frame_cropped), get_asyncio_loop())
def _get_crop(self, image: QImage, scan_size: int) -> QRect:
"""

5
electrum/gui/qml/qewallet.py

@ -10,8 +10,9 @@ from electrum.logging import get_logger
from electrum.wallet import Wallet, Abstract_Wallet
from electrum import bitcoin
from electrum.transaction import PartialTxOutput
from electrum.invoices import (Invoice, InvoiceError, PR_TYPE_ONCHAIN, PR_TYPE_LN,
PR_DEFAULT_EXPIRATION_WHEN_CREATING, PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED, PR_UNCONFIRMED, PR_TYPE_ONCHAIN, PR_TYPE_LN)
from electrum.invoices import (Invoice, InvoiceError,
PR_DEFAULT_EXPIRATION_WHEN_CREATING, PR_PAID,
PR_UNPAID, PR_UNKNOWN, PR_EXPIRED, PR_UNCONFIRMED)
from .qeinvoicelistmodel import QEInvoiceListModel, QERequestListModel
from .qetransactionlistmodel import QETransactionListModel

Loading…
Cancel
Save