-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Gateway Enforce Routing Fees #4412
Conversation
Iirc we don't check that fees were paid but only allow the LN node to pay as much in fees as the user. We don't have a guarantee of making money anyway rn (could introduce a fee margin that's guaranteed to go to the gateway to fix this). |
Right now the only check we have is if a contract is "underfunded", which essentially just compares the amount in the contract to the amount that the client tells the gateway to pay. The issue is that, if the gateway is charging a routing fee, we do not currently independently compute that fee. So malicious clients could create a contract that pays exactly the amount that the invoice is, and the gateway won't enforce that their fee is included. This is hard to exploit currently since it requires a malicious client to not attach fees for the gateway. In practice though this probably can occur if a gateway changes their advertised fees, since it might not re-register with the federation for another ~10mins. |
@elsirion let me know if you think this is still necessary, I think we're on the same page. This essentially just turns the under-funding of a contract (without fees) into an explicit error, whereas before the gateway would rely on routing on the LN to make a profit |
05dd47c
to
692ce1c
Compare
692ce1c
to
1e68026
Compare
1e68026
to
596628e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's super useful rn, but it's well-tested and might become useful if we ever want to enforce profit for gateways.
596628e
to
964fe73
Compare
In debugging #4350 I realized that the gateway is not independently verifying that the client attached routing fees to the contract. We check if the contract is underfunded, but only against the invoice amount, not invoice amount gateway fee.
This PR adds gateway enforcement of fees and adds a test that verifies clients cannot cheat and not pay fees.