add invoice status
This commit is contained in:
@@ -86,13 +86,11 @@ Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr('Expiration')
|
text: qsTr('Status')
|
||||||
visible: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: expiration
|
text: invoice.status_str
|
||||||
text: invoice.time + invoice.expiration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@@ -108,7 +106,6 @@ Dialog {
|
|||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: qsTr('Save')
|
text: qsTr('Save')
|
||||||
// enabled: invoice.invoiceType != Invoice.Invalid
|
|
||||||
enabled: invoice.invoiceType == Invoice.OnchainInvoice
|
enabled: invoice.invoiceType == Invoice.OnchainInvoice
|
||||||
onClicked: {
|
onClicked: {
|
||||||
invoice.save_invoice()
|
invoice.save_invoice()
|
||||||
|
|||||||
@@ -279,8 +279,6 @@ Pane {
|
|||||||
// no popups when editing
|
// no popups when editing
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(code + ' ' + message)
|
|
||||||
|
|
||||||
var dialog = app.messageDialog.createObject(app, {'text': message })
|
var dialog = app.messageDialog.createObject(app, {'text': message })
|
||||||
dialog.open()
|
dialog.open()
|
||||||
rootItem.clear()
|
rootItem.clear()
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ from electrum.keystore import bip39_is_checksum_valid
|
|||||||
from electrum.util import (parse_URI, create_bip21_uri, InvalidBitcoinURI, InvoiceError,
|
from electrum.util import (parse_URI, create_bip21_uri, InvalidBitcoinURI, InvoiceError,
|
||||||
maybe_extract_bolt11_invoice)
|
maybe_extract_bolt11_invoice)
|
||||||
from electrum.invoices import Invoice, OnchainInvoice, LNInvoice
|
from electrum.invoices import Invoice, OnchainInvoice, LNInvoice
|
||||||
|
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
|
from electrum.transaction import PartialTxOutput
|
||||||
|
|
||||||
from .qewallet import QEWallet
|
from .qewallet import QEWallet
|
||||||
@@ -25,7 +27,18 @@ class QEInvoice(QObject):
|
|||||||
LightningInvoice = 2
|
LightningInvoice = 2
|
||||||
LightningAndOnchainInvoice = 3
|
LightningAndOnchainInvoice = 3
|
||||||
|
|
||||||
|
class Status:
|
||||||
|
Unpaid = PR_UNPAID
|
||||||
|
Expired = PR_EXPIRED
|
||||||
|
Unknown = PR_UNKNOWN
|
||||||
|
Paid = PR_PAID
|
||||||
|
Inflight = PR_INFLIGHT
|
||||||
|
Failed = PR_FAILED
|
||||||
|
Routing = PR_ROUTING
|
||||||
|
Unconfirmed = PR_UNCONFIRMED
|
||||||
|
|
||||||
Q_ENUMS(Type)
|
Q_ENUMS(Type)
|
||||||
|
Q_ENUMS(Status)
|
||||||
|
|
||||||
_wallet = None
|
_wallet = None
|
||||||
_invoiceType = Type.Invalid
|
_invoiceType = Type.Invalid
|
||||||
@@ -83,7 +96,7 @@ class QEInvoice(QObject):
|
|||||||
@pyqtProperty(QEAmount, notify=invoiceChanged)
|
@pyqtProperty(QEAmount, notify=invoiceChanged)
|
||||||
def amount(self):
|
def amount(self):
|
||||||
# store ref to QEAmount on instance, otherwise we get destroyed when going out of scope
|
# store ref to QEAmount on instance, otherwise we get destroyed when going out of scope
|
||||||
self._amount = QEAmount() #
|
self._amount = QEAmount()
|
||||||
if not self._effectiveInvoice:
|
if not self._effectiveInvoice:
|
||||||
return self._amount
|
return self._amount
|
||||||
sats = self._effectiveInvoice.get_amount_sat()
|
sats = self._effectiveInvoice.get_amount_sat()
|
||||||
@@ -100,6 +113,20 @@ class QEInvoice(QObject):
|
|||||||
def time(self):
|
def time(self):
|
||||||
return self._effectiveInvoice.time if self._effectiveInvoice else 0
|
return self._effectiveInvoice.time if self._effectiveInvoice else 0
|
||||||
|
|
||||||
|
statusChanged = pyqtSignal()
|
||||||
|
@pyqtProperty(int, notify=statusChanged)
|
||||||
|
def status(self):
|
||||||
|
if not self._effectiveInvoice:
|
||||||
|
return ''
|
||||||
|
status = self._wallet.wallet.get_invoice_status(self._effectiveInvoice)
|
||||||
|
|
||||||
|
@pyqtProperty(str, notify=statusChanged)
|
||||||
|
def status_str(self):
|
||||||
|
if not self._effectiveInvoice:
|
||||||
|
return ''
|
||||||
|
status = self._wallet.wallet.get_invoice_status(self._effectiveInvoice)
|
||||||
|
return self._effectiveInvoice.get_status_str(status)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.recipient = ''
|
self.recipient = ''
|
||||||
@@ -124,6 +151,7 @@ class QEInvoice(QObject):
|
|||||||
else:
|
else:
|
||||||
self.setInvoiceType(QEInvoice.Type.OnchainInvoice)
|
self.setInvoiceType(QEInvoice.Type.OnchainInvoice)
|
||||||
self.invoiceChanged.emit()
|
self.invoiceChanged.emit()
|
||||||
|
self.statusChanged.emit()
|
||||||
|
|
||||||
def setValidAddressOnly(self):
|
def setValidAddressOnly(self):
|
||||||
self._logger.debug('setValidAddressOnly')
|
self._logger.debug('setValidAddressOnly')
|
||||||
@@ -226,8 +254,8 @@ class QEInvoice(QObject):
|
|||||||
self._wallet.wallet.save_invoice(self._effectiveInvoice)
|
self._wallet.wallet.save_invoice(self._effectiveInvoice)
|
||||||
self.invoiceSaved.emit()
|
self.invoiceSaved.emit()
|
||||||
|
|
||||||
@pyqtSlot(str, 'quint64', str)
|
@pyqtSlot(str, QEAmount, str)
|
||||||
def create_invoice(self, address: str, amount: int, message: str):
|
def create_invoice(self, address: str, amount: QEAmount, message: str):
|
||||||
# create onchain invoice from user entered fields
|
# create onchain invoice from user entered fields
|
||||||
# (any other type of invoice is created from parsing recipient)
|
# (any other type of invoice is created from parsing recipient)
|
||||||
self._logger.debug('saving invoice to %s' % address)
|
self._logger.debug('saving invoice to %s' % address)
|
||||||
|
|||||||
Reference in New Issue
Block a user