1
0

payment_identifier: return onchain invoice when GUI requests MAX amount (fixes #8900)

This commit is contained in:
Sander van Grieken
2024-02-19 10:35:55 +01:00
parent e11d7b37f2
commit ef87fbd3e5
2 changed files with 6 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
# file LICENCE or http://www.opensource.org/licenses/mit-license.php # file LICENCE or http://www.opensource.org/licenses/mit-license.php
from decimal import Decimal from decimal import Decimal
from typing import Optional, TYPE_CHECKING, Sequence, List, Callable from typing import Optional, TYPE_CHECKING, Sequence, List, Callable, Union
from PyQt5.QtCore import pyqtSignal, QPoint, QSize, Qt from PyQt5.QtCore import pyqtSignal, QPoint, QSize, Qt
from PyQt5.QtWidgets import (QLabel, QVBoxLayout, QGridLayout, QHBoxLayout, from PyQt5.QtWidgets import (QLabel, QVBoxLayout, QGridLayout, QHBoxLayout,
QWidget, QToolTip, QPushButton, QApplication) QWidget, QToolTip, QPushButton, QApplication)
@@ -600,7 +600,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
else: else:
self.pay_onchain_dialog(invoice.outputs, invoice=invoice) self.pay_onchain_dialog(invoice.outputs, invoice=invoice)
def read_amount(self) -> List[PartialTxOutput]: def read_amount(self) -> Union[int, str]:
amount = '!' if self.max_button.isChecked() else self.get_amount() amount = '!' if self.max_button.isChecked() else self.get_amount()
return amount return amount

View File

@@ -675,11 +675,13 @@ class PaymentIdentifier(Logger):
def invoice_from_payment_identifier( def invoice_from_payment_identifier(
pi: 'PaymentIdentifier', pi: 'PaymentIdentifier',
wallet: 'Abstract_Wallet', wallet: 'Abstract_Wallet',
amount_sat: int, amount_sat: Union[int, str],
message: str = None message: str = None
) -> Optional[Invoice]: ) -> Optional[Invoice]:
assert pi.state in [PaymentIdentifierState.AVAILABLE, PaymentIdentifierState.MERCHANT_NOTIFY] assert pi.state in [PaymentIdentifierState.AVAILABLE, PaymentIdentifierState.MERCHANT_NOTIFY]
if pi.is_lightning(): assert pi.is_onchain() if amount_sat == '!' else True # MAX should only be allowed if pi has onchain destination
if pi.is_lightning() and not amount_sat == '!':
invoice = pi.bolt11 invoice = pi.bolt11
if not invoice: if not invoice:
return return