follow-up prev: clean-up PaymentFeeBudget API
This commit is contained in:
@@ -1766,7 +1766,7 @@ class Commands(Logger):
|
|||||||
max_cltv_remaining = max_cltv - lnaddr.get_min_final_cltv_delta()
|
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"
|
assert max_cltv_remaining > 0, f"{max_cltv=} - {lnaddr.get_min_final_cltv_delta()=} < 1"
|
||||||
max_cltv = max_cltv_remaining
|
max_cltv = max_cltv_remaining
|
||||||
budget = PaymentFeeBudget.custom(
|
budget = PaymentFeeBudget.from_invoice_amount(
|
||||||
config=wallet.config,
|
config=wallet.config,
|
||||||
invoice_amount_msat=invoice_obj.amount_msat,
|
invoice_amount_msat=invoice_obj.amount_msat,
|
||||||
max_cltv_delta=max_cltv,
|
max_cltv_delta=max_cltv,
|
||||||
|
|||||||
@@ -1947,25 +1947,14 @@ class PaymentFeeBudget(NamedTuple):
|
|||||||
#num_htlc: int
|
#num_htlc: int
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default(cls, *, invoice_amount_msat: int, config: 'SimpleConfig') -> 'PaymentFeeBudget':
|
def from_invoice_amount(
|
||||||
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(
|
|
||||||
cls,
|
cls,
|
||||||
config: 'SimpleConfig',
|
|
||||||
*,
|
*,
|
||||||
invoice_amount_msat: int,
|
invoice_amount_msat: int,
|
||||||
|
config: 'SimpleConfig',
|
||||||
max_cltv_delta: Optional[int] = None,
|
max_cltv_delta: Optional[int] = None,
|
||||||
max_fee_msat: Optional[int] = None,
|
max_fee_msat: Optional[int] = None,
|
||||||
):
|
) -> 'PaymentFeeBudget':
|
||||||
if max_fee_msat is None:
|
if max_fee_msat is None:
|
||||||
max_fee_msat = PaymentFeeBudget._calculate_fee_msat(
|
max_fee_msat = PaymentFeeBudget._calculate_fee_msat(
|
||||||
invoice_amount_msat=invoice_amount_msat,
|
invoice_amount_msat=invoice_amount_msat,
|
||||||
@@ -1980,7 +1969,8 @@ class PaymentFeeBudget(NamedTuple):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _calculate_fee_msat(cls,
|
def _calculate_fee_msat(
|
||||||
|
cls,
|
||||||
*,
|
*,
|
||||||
invoice_amount_msat: int,
|
invoice_amount_msat: int,
|
||||||
config: 'SimpleConfig',
|
config: 'SimpleConfig',
|
||||||
|
|||||||
@@ -1549,7 +1549,7 @@ class LNWallet(LNWorker):
|
|||||||
self.wallet.set_label(key, lnaddr.get_description())
|
self.wallet.set_label(key, lnaddr.get_description())
|
||||||
self.set_invoice_status(key, PR_INFLIGHT)
|
self.set_invoice_status(key, PR_INFLIGHT)
|
||||||
if budget is None:
|
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():
|
if attempts is None and self.uses_trampoline():
|
||||||
# we don't expect lots of failed htlcs with trampoline, so we can fail sooner
|
# we don't expect lots of failed htlcs with trampoline, so we can fail sooner
|
||||||
attempts = 30
|
attempts = 30
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
|
|||||||
amount_msat=amount_msat,
|
amount_msat=amount_msat,
|
||||||
paysession=paysession,
|
paysession=paysession,
|
||||||
full_path=full_path,
|
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
|
get_payments = LNWallet.get_payments
|
||||||
|
|||||||
Reference in New Issue
Block a user