Repository navigation
Conversation
When acting as an LSPS2 service, the amount of a JIT channel was derived from the millisatoshi forward amount with integer division, i.e., it was rounded down. For forward amounts that aren't a whole number of satoshis the channel could end up too small to carry the intercepted HTLC. In the LSP-trusts-client flow the service has already paid the funding fee at that point, and any client can trigger this remotely. We now round up to the next whole satoshi when converting, so the opened channel always has enough capacity for the forward. Reported by Project Loupe. Co-Authored-By: HAL 9000
|
I've assigned @tankyleo as a reviewer! |
| let channel_amount_sats = | ||
| (amt_to_forward_msat + over_provisioning_msat).div_ceil(1000); |
There was a problem hiding this comment.
The div_ceil fix looks good, and I like that the funds check (L462) and create_channel use the same variable. One caveat: the channel isn't guaranteed to have enough usable capacity for the forward.
With channel_over_provisioning_ppm = 0, the channel is sized to exactly ceil(forward) sats and funded entirely by the LSP (push_msat = 0). The LSP still needs to account for the client's reserve (~1% by default), commitment fees, and anchor outputs, so the HTLC may not fit.
Could we either scope the PR description to fixing sub-sat truncation, or account for the reserve and fees explicitly and document the minimum sensible channel_over_provisioning_ppm?
When acting as an LSPS2 service, the amount of a JIT channel was derived from the millisatoshi forward amount with integer division, i.e., it was rounded down. For forward amounts that aren't a whole number of satoshis the channel could end up too small to carry the intercepted HTLC. In the LSP-trusts-client flow the service has already paid the funding fee at that point, and any client can trigger this remotely.
We now round up to the next whole satoshi when converting, so the opened channel always has enough capacity for the forward.
Reported by Project Loupe.
Co-Authored-By: HAL 9000