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