blink: round up fees to next satoshi (#445)

This commit is contained in:
callebtc
2024-02-19 16:30:44 +01:00
committed by GitHub
parent 1e26f235d5
commit 2189728771
2 changed files with 47 additions and 6 deletions

View File

@@ -393,10 +393,18 @@ class BlinkWallet(LightningBackend):
amount_msat = int(invoice_obj.amount_msat)
# we take the highest: fee_msat_response, or BLINK_MAX_FEE_PERCENT, or 2000 msat
fees_msat = max(
# we take the highest: fee_msat_response, or BLINK_MAX_FEE_PERCENT, or MINIMUM_FEE_MSAT msat
# Note: fees with BLINK_MAX_FEE_PERCENT are rounded to the nearest 1000 msat
fees_amount_msat: int = (
math.ceil(amount_msat / 100 * BLINK_MAX_FEE_PERCENT / 1000) * 1000
)
fees_msat: int = max(
fees_response_msat,
max(math.ceil(amount_msat / 100 * BLINK_MAX_FEE_PERCENT), MINIMUM_FEE_MSAT),
max(
fees_amount_msat,
MINIMUM_FEE_MSAT,
),
)
fees = Amount(unit=Unit.msat, amount=fees_msat)