From acaaaa00ca80ad9185802f10aae6378744d20e80 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 14 May 2025 13:59:27 +0200 Subject: [PATCH] invoices: only skip generating BIP21 URI for payment request if both amount and message are empty. This will result in only showing a bare address QR in the GUIs iff both amount and message are left empty. --- electrum/gui/qml/qerequestdetails.py | 5 +++-- electrum/invoices.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/electrum/gui/qml/qerequestdetails.py b/electrum/gui/qml/qerequestdetails.py index 06a616c17..319d512bd 100644 --- a/electrum/gui/qml/qerequestdetails.py +++ b/electrum/gui/qml/qerequestdetails.py @@ -4,8 +4,9 @@ from typing import Optional from PyQt6.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QTimer, pyqtEnum from electrum.logging import get_logger -from electrum.invoices import (PR_UNPAID, PR_EXPIRED, PR_UNKNOWN, PR_PAID, PR_INFLIGHT, - PR_FAILED, PR_ROUTING, PR_UNCONFIRMED, LN_EXPIRY_NEVER) +from electrum.invoices import ( + PR_UNPAID, PR_EXPIRED, PR_UNKNOWN, PR_PAID, PR_INFLIGHT, PR_FAILED, PR_ROUTING, PR_UNCONFIRMED, LN_EXPIRY_NEVER +) from electrum.lnutil import MIN_FUNDING_SAT from .qewallet import QEWallet diff --git a/electrum/invoices.py b/electrum/invoices.py index 95fd67004..eb55dfe01 100644 --- a/electrum/invoices.py +++ b/electrum/invoices.py @@ -344,10 +344,11 @@ class Request(BaseInvoice): ) -> Optional[str]: addr = self.get_address() amount = self.get_amount_sat() - if amount is None: - return - amount = int(amount) message = self.message + if amount is None and not message: + return + if amount: + amount = int(amount) extra = {} if self.time and self.exp: extra['time'] = str(int(self.time))