diff --git a/electrum/commands.py b/electrum/commands.py index 1a764067c..c07760530 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -1766,7 +1766,7 @@ class Commands(Logger): max_cltv_remaining = max_cltv - lnaddr.get_min_final_cltv_delta() assert max_cltv_remaining > 0, f"{max_cltv=} - {lnaddr.get_min_final_cltv_delta()=} < 1" max_cltv = max_cltv_remaining - budget = PaymentFeeBudget.custom( + budget = PaymentFeeBudget.from_invoice_amount( config=wallet.config, invoice_amount_msat=invoice_obj.amount_msat, max_cltv_delta=max_cltv, diff --git a/electrum/lnutil.py b/electrum/lnutil.py index 72fc8173e..3903f6979 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -1947,25 +1947,14 @@ class PaymentFeeBudget(NamedTuple): #num_htlc: int @classmethod - def default(cls, *, invoice_amount_msat: int, config: 'SimpleConfig') -> 'PaymentFeeBudget': - fee_msat = PaymentFeeBudget._calculate_fee_msat( - invoice_amount_msat=invoice_amount_msat, - config=config, - ) - return PaymentFeeBudget( - fee_msat=fee_msat, - cltv=NBLOCK_CLTV_DELTA_TOO_FAR_INTO_FUTURE, - ) - - @classmethod - def custom( + def from_invoice_amount( cls, - config: 'SimpleConfig', *, invoice_amount_msat: int, + config: 'SimpleConfig', max_cltv_delta: Optional[int] = None, max_fee_msat: Optional[int] = None, - ): + ) -> 'PaymentFeeBudget': if max_fee_msat is None: max_fee_msat = PaymentFeeBudget._calculate_fee_msat( invoice_amount_msat=invoice_amount_msat, @@ -1980,7 +1969,8 @@ class PaymentFeeBudget(NamedTuple): ) @classmethod - def _calculate_fee_msat(cls, + def _calculate_fee_msat( + cls, *, invoice_amount_msat: int, config: 'SimpleConfig', diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 9b7f5affc..6f5c26d04 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1549,7 +1549,7 @@ class LNWallet(LNWorker): self.wallet.set_label(key, lnaddr.get_description()) self.set_invoice_status(key, PR_INFLIGHT) if budget is None: - budget = PaymentFeeBudget.default(invoice_amount_msat=amount_to_pay, config=self.config) + budget = PaymentFeeBudget.from_invoice_amount(invoice_amount_msat=amount_to_pay, config=self.config) if attempts is None and self.uses_trampoline(): # we don't expect lots of failed htlcs with trampoline, so we can fail sooner attempts = 30 diff --git a/tests/test_lnpeer.py b/tests/test_lnpeer.py index d8a928011..9ffbaf61f 100644 --- a/tests/test_lnpeer.py +++ b/tests/test_lnpeer.py @@ -288,7 +288,7 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]): amount_msat=amount_msat, paysession=paysession, full_path=full_path, - budget=PaymentFeeBudget.default(invoice_amount_msat=amount_msat, config=self.config), + budget=PaymentFeeBudget.from_invoice_amount(invoice_amount_msat=amount_msat, config=self.config), )] get_payments = LNWallet.get_payments