more rebase fixes, add invoice delete
This commit is contained in:
@@ -17,8 +17,8 @@ Frame {
|
||||
root.formattedBalance = Config.formatSats(Daemon.currentWallet.confirmedBalance)
|
||||
root.formattedUnconfirmed = Config.formatSats(Daemon.currentWallet.unconfirmedBalance)
|
||||
if (Daemon.fx.enabled) {
|
||||
root.formattedBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.confirmedBalance.toString(), false)
|
||||
root.formattedUnconfirmedFiat = Daemon.fx.fiatValue(Daemon.currentWallet.unconfirmedBalance.toString(), false)
|
||||
root.formattedBalanceFiat = Daemon.fx.fiatValue(Daemon.currentWallet.confirmedBalance, false)
|
||||
root.formattedUnconfirmedFiat = Daemon.fx.fiatValue(Daemon.currentWallet.unconfirmedBalance, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,15 @@ Dialog {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
spacing: constants.paddingMedium
|
||||
|
||||
Button {
|
||||
text: qsTr('Delete')
|
||||
visible: invoice_key != ''
|
||||
onClicked: {
|
||||
invoice.wallet.delete_invoice(invoice_key)
|
||||
dialog.close()
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr('Cancel')
|
||||
onClicked: dialog.close()
|
||||
|
||||
@@ -130,17 +130,17 @@ Dialog {
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: modelItem.amount > 0
|
||||
visible: modelItem.amount != 0
|
||||
text: qsTr('Amount')
|
||||
}
|
||||
Label {
|
||||
visible: modelItem.amount > 0
|
||||
visible: modelItem.amount != 0
|
||||
text: Config.formatSats(modelItem.amount)
|
||||
font.family: FixedFont
|
||||
font.pixelSize: constants.fontSizeLarge
|
||||
}
|
||||
Label {
|
||||
visible: modelItem.amount > 0
|
||||
visible: modelItem.amount != 0
|
||||
text: Config.baseUnit
|
||||
color: Material.accentColor
|
||||
font.pixelSize: constants.fontSizeLarge
|
||||
@@ -148,7 +148,7 @@ Dialog {
|
||||
|
||||
Label {
|
||||
id: fiatValue
|
||||
visible: modelItem.amount > 0
|
||||
visible: modelItem.amount != 0
|
||||
Layout.fillWidth: true
|
||||
Layout.columnSpan: 2
|
||||
text: Daemon.fx.enabled
|
||||
@@ -199,7 +199,7 @@ Dialog {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
_bip21uri = bitcoin.create_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.expiration)
|
||||
_bip21uri = bitcoin.create_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.expiration - modelItem.timestamp)
|
||||
qr.source = 'image://qrgen/' + _bip21uri
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ Dialog {
|
||||
onClicked: AppController.textToClipboard(dialog.text)
|
||||
}
|
||||
Button {
|
||||
enabled: false
|
||||
text: qsTr('Share')
|
||||
icon.source: '../../../icons/share.png'
|
||||
onClicked: console.log('TODO')
|
||||
|
||||
@@ -42,7 +42,11 @@ ItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: model.message ? model.message : model.address
|
||||
text: model.message
|
||||
? model.message
|
||||
: model.type == 'request'
|
||||
? model.address
|
||||
: ''
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.Wrap
|
||||
maximumLineCount: 2
|
||||
|
||||
@@ -18,7 +18,7 @@ class QEAbstractInvoiceListModel(QAbstractListModel):
|
||||
self.invoices = []
|
||||
|
||||
# define listmodel rolemap
|
||||
_ROLE_NAMES=('key','is_lightning','timestamp','date','message','amount','status','status_str','address','expiration')
|
||||
_ROLE_NAMES=('key','is_lightning','timestamp','date','message','amount','status','status_str','address','expiration','type')
|
||||
_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))
|
||||
@@ -88,6 +88,7 @@ class QEAbstractInvoiceListModel(QAbstractListModel):
|
||||
item['status_str'] = invoice.get_status_str(status)
|
||||
index = self.index(i,0)
|
||||
self.dataChanged.emit(index, index, [self._ROLE_RMAP['status'], self._ROLE_RMAP['status_str']])
|
||||
return
|
||||
i = i + 1
|
||||
|
||||
@abstractmethod
|
||||
@@ -118,6 +119,8 @@ class QEInvoiceListModel(QEAbstractInvoiceListModel):
|
||||
item['amount'] = QEAmount(amount_sat=invoice.get_amount_sat())
|
||||
item['key'] = invoice.get_id()
|
||||
|
||||
item['type'] = 'invoice'
|
||||
|
||||
return item
|
||||
|
||||
def get_invoice_for_key(self, key: str):
|
||||
@@ -134,11 +137,13 @@ class QERequestListModel(QEAbstractInvoiceListModel):
|
||||
|
||||
def invoice_to_model(self, req: Invoice):
|
||||
item = self.wallet.export_request(req)
|
||||
item['key'] = req.get_id() #self.wallet.get_key_for_receive_request(req)
|
||||
item['key'] = req.get_rhash() if req.is_lightning() else req.get_address()
|
||||
item['is_lightning'] = req.is_lightning()
|
||||
item['date'] = format_time(item['timestamp'])
|
||||
item['amount'] = QEAmount(amount_sat=req.get_amount_sat())
|
||||
|
||||
item['type'] = 'request'
|
||||
|
||||
return item
|
||||
|
||||
def get_invoice_for_key(self, key: str):
|
||||
|
||||
@@ -311,18 +311,18 @@ class QEWallet(QObject):
|
||||
return
|
||||
addr = self.wallet.create_new_address(False)
|
||||
|
||||
req = self.wallet.make_payment_request(addr, amount, message, expiration)
|
||||
try:
|
||||
self.wallet.add_payment_request(req)
|
||||
except Exception as e:
|
||||
self.logger.exception('Error adding payment request')
|
||||
self.requestCreateError.emit('fatal',_('Error adding payment request') + ':\n' + repr(e))
|
||||
else:
|
||||
# TODO: check this flow. Only if alias is defined in config. OpenAlias?
|
||||
pass
|
||||
#self.sign_payment_request(addr)
|
||||
self._requestModel.add_invoice(req)
|
||||
return addr
|
||||
req_key = self.wallet.create_request(amount, message, expiration, addr, False)
|
||||
#try:
|
||||
#self.wallet.add_payment_request(req)
|
||||
#except Exception as e:
|
||||
#self.logger.exception('Error adding payment request')
|
||||
#self.requestCreateError.emit('fatal',_('Error adding payment request') + ':\n' + repr(e))
|
||||
#else:
|
||||
## TODO: check this flow. Only if alias is defined in config. OpenAlias?
|
||||
#pass
|
||||
##self.sign_payment_request(addr)
|
||||
self._requestModel.add_invoice(self.wallet.get_request(req_key))
|
||||
#return addr
|
||||
|
||||
@pyqtSlot(QEAmount, 'QString', int)
|
||||
@pyqtSlot(QEAmount, 'QString', int, bool)
|
||||
@@ -350,6 +350,7 @@ class QEWallet(QObject):
|
||||
|
||||
@pyqtSlot('QString')
|
||||
def delete_request(self, key: str):
|
||||
self._logger.debug('delete req %s' % key)
|
||||
self.wallet.delete_request(key)
|
||||
self._requestModel.delete_invoice(key)
|
||||
|
||||
@@ -360,6 +361,7 @@ class QEWallet(QObject):
|
||||
|
||||
@pyqtSlot('QString')
|
||||
def delete_invoice(self, key: str):
|
||||
self._logger.debug('delete inv %s' % key)
|
||||
self.wallet.delete_invoice(key)
|
||||
self._invoiceModel.delete_invoice(key)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user