|
|
|
|
@ -7,8 +7,8 @@ from kivy.app import App
|
|
|
|
|
from kivy.clock import Clock |
|
|
|
|
|
|
|
|
|
from electrum.gui.kivy.i18n import _ |
|
|
|
|
from electrum.util import pr_tooltips, pr_color |
|
|
|
|
from electrum.util import PR_UNKNOWN, PR_UNPAID, PR_FAILED |
|
|
|
|
from electrum.util import pr_tooltips, pr_color, get_request_status |
|
|
|
|
from electrum.util import PR_UNKNOWN, PR_UNPAID, PR_FAILED, PR_TYPE_LN |
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
|
from electrum.gui.kivy.main_window import ElectrumWindow |
|
|
|
|
@ -17,10 +17,12 @@ if TYPE_CHECKING:
|
|
|
|
|
Builder.load_string(''' |
|
|
|
|
<InvoiceDialog@Popup> |
|
|
|
|
id: popup |
|
|
|
|
amount: 0 |
|
|
|
|
title: '' |
|
|
|
|
data: '' |
|
|
|
|
status_color: 1,1,1,1 |
|
|
|
|
status_str:'' |
|
|
|
|
warning: '' |
|
|
|
|
can_pay: True |
|
|
|
|
shaded: False |
|
|
|
|
show_text: False |
|
|
|
|
@ -33,9 +35,14 @@ Builder.load_string('''
|
|
|
|
|
spacing: '10dp' |
|
|
|
|
TopLabel: |
|
|
|
|
text: root.data |
|
|
|
|
TopLabel: |
|
|
|
|
text: _('Amount') + ': ' + app.format_amount_and_units(root.amount) |
|
|
|
|
TopLabel: |
|
|
|
|
text: _('Status') + ': ' + root.status_str |
|
|
|
|
color: root.status_color |
|
|
|
|
TopLabel: |
|
|
|
|
warning: root.warning |
|
|
|
|
color: (0.9, 0.6, 0.3, 1) |
|
|
|
|
Widget: |
|
|
|
|
size_hint: 1, 0.2 |
|
|
|
|
BoxLayout: |
|
|
|
|
@ -73,12 +80,19 @@ class InvoiceDialog(Factory.Popup):
|
|
|
|
|
self.title = title |
|
|
|
|
self.data = data |
|
|
|
|
self.key = key |
|
|
|
|
r = self.app.wallet.get_invoice(key) |
|
|
|
|
self.amount = r.get('amount') |
|
|
|
|
self.is_lightning = r.get('type') == PR_TYPE_LN |
|
|
|
|
self.update_status() |
|
|
|
|
|
|
|
|
|
def set_status(self, status): |
|
|
|
|
self.status = status |
|
|
|
|
self.status_str = pr_tooltips[status] |
|
|
|
|
self.status_color = pr_color[status] |
|
|
|
|
self.can_pay = self.status in[PR_UNPAID, PR_FAILED] |
|
|
|
|
def update_status(self): |
|
|
|
|
req = self.app.wallet.get_invoice(self.key) |
|
|
|
|
self.status, self.status_str = get_request_status(req) |
|
|
|
|
self.status_color = pr_color[self.status] |
|
|
|
|
self.can_pay = self.status in [PR_UNPAID, PR_FAILED] |
|
|
|
|
if self.can_pay and self.is_lightning and self.app.wallet.lnworker: |
|
|
|
|
if self.amount and self.amount > self.app.wallet.lnworker.can_send(): |
|
|
|
|
self.warning = _('Warning') + ': ' + _('This amount exceeds the maximum you can currently send with your channels') |
|
|
|
|
|
|
|
|
|
def on_dismiss(self): |
|
|
|
|
self.app.request_popup = None |
|
|
|
|
|