lightningdevkit / lightning-liquidity

Other
27 stars 17 forks source link

Fixes proportional fees for MPP #105

Closed wvanlint closed 6 months ago

wvanlint commented 7 months ago

Proportional fee attribution across HTLCs contained a rounding error, dividing two integers whose value would always be smaller than 1. https://github.com/lightningdevkit/lightning-liquidity/blob/71b9dd2a8df3c5d0bae43dd442c7c225cf0763f4/src/lsps2/service.rs#L775-L776 This resulted in the fee being solely assigned to the final HTLC. https://github.com/lightningdevkit/lightning-liquidity/blob/71b9dd2a8df3c5d0bae43dd442c7c225cf0763f4/src/lsps2/service.rs#L782-L784 This PR applies a fix, adds a unit test, and adjusts the proptest for coverage.

The method now also takes in the fee as opposed to the amount to forward. This was done for clarity and for the future case where an initial payment determines the channel parameters and fails, but a subsequent payment of a different size succeeds and pays for the fee.