Repository navigation
Apply the default routing fee limit to spontaneous sends - #326
Open
ajaysehwal wants to merge 1 commit into
Open
ajaysehwal wants to merge 1 commit into
ajaysehwal wants to merge 1 commit into
Conversation
The documented default for `RouteParametersConfig::max_total_routing_fee_msat` is 1% of the payment amount plus 50 sats. When no route parameters are given at all, ldk-node keeps LDK's default limit. But ldk-node's spontaneous send applies provided route parameters as a whole, i.e., it overwrites the limit with the given value, which is `None` if the field is unset. A `None` limit means no limit, so a spontaneous send with route parameters but without an explicit fee limit could pay arbitrary routing fees. This affects every client that sends route parameters without a fee limit. Notably, `ldk-server-cli spontaneous-send` always sends route parameters (filling the other fields with their defaults), so it didn't limit routing fees unless `--max-total-routing-fee` was passed. BOLT11 and (non-async) BOLT12 payments are not affected, as LDK only overrides the default limit if one is given. Here, we fill in the documented default (1% of the amount plus 50 sats) in the spontaneous send handler whenever route parameters are provided without a fee limit. Explicit limits, including 0, are left untouched.
|
👋 Thanks for assigning @benthecarman as a reviewer! |
Collaborator
|
this seems more like a bug in ldk-node than ldk-server |
Contributor
Author
Agreed, this appears to be an I'll close this PR once the fix is merged and we've bumped the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RouteParametersConfig::max_total_routing_fee_msatis documented to default to 1% of the payment amount plus 50 sats. When no route parameters are given at all, ldk-node keeps LDK's default limit. But ldk-node's spontaneous send applies provided route parameters as a whole: it overwrites the limit with the given value, which isNoneif the field is unset, andNonemeans no limit. A spontaneous send with route parameters but without an explicit fee limit could therefore pay arbitrary routing fees.This affects every client that sends route parameters without a fee limit. Notably,
ldk-server-cli spontaneous-sendalways sends route parameters (filling the other fields with their defaults), so it did not limit routing fees unless--max-total-routing-feewas passed.Here, we fill in the documented default (1% of the amount plus 50 sats) in the spontaneous send handler whenever route parameters are provided without a fee limit. Explicit limits, including 0, are left untouched, and nothing changes if no route parameters are sent.
Notes for reviewers
send_payment_for_static_invoicein rust-lightning assigns the config'sNone). That is outside of this PR and I think it needs a fix in LDK/ldk-node.RouteParametersConfigfields are plainuint32s, so a client that sends only a fee limit getsmax_path_count = 0etc. Making themoptionalwould be a small follow-up.Testing
with_default_max_routing_fee: the default is applied for an unset limit (including amount 0 andu64::MAX), explicit limits (0, 1,000,u64::MAX) are kept, other parameters are untouched, and absent parameters stay absent.cargo test -p ldk-serverpasses (143 tests);cargo fmtis clean. I did not run the e2e tests.