-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add support for service fees #474
Conversation
This introduces a new transaction type "service_fee" Each outgoing payment is charged a service fee of x/1000. The service fee entries is added with the routing fee reserve entry. For failed payments the service fee is reversed.
ignore NoRows errors
payment amounts up to NO_SERVICE_FEE_UP_TO_AMOUNT don't get a service fee charged
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.
Great progress! 💯
Left some feedback and added a fix / test.
transaction entries are associated with the invoice and have a type (outgoing, service_fee, fee, etc.)this is associating the related tx entries.
|
we already do exactly that when in the normal PayInvoice flow. Normally the RHash is already set here, but I guess it does not hurt to have it consistent everywhere.
…harged It feels a bit indirect to check if we have set a FeeReserve. We save the routing fee on the invoice thus we should be able to use that information
@@ -359,22 +385,35 @@ func (svc *LndhubService) RevertFeeReserve(ctx context.Context, entry *models.Tr | |||
return nil | |||
} | |||
|
|||
func (svc *LndhubService) AddFeeEntry(ctx context.Context, entry *models.TransactionEntry, invoice *models.Invoice, tx bun.Tx) (err error) { | |||
if entry.FeeReserve != nil { |
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.
@kiwiidb why did we check for entry.FeeReserve
here? can't we check for invoice.Fee
(new name invoice.RoutingFee) here?
If the invoice has a not zero routing fee we have to add a fee transaction entry.
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 guess it can also work but the way how it used to be it's more explicit in avoiding the nil pointer exception.
we want those to be 0 by default
This introduces a new transaction type "service_fee".
Each outgoing payment is charged a service fee of x/1000. The service fee entries is added with the routing fee reserve entry. For failed payments the service fee is reversed.
A threshold up to which transactions are free can be configured (
NO_SERVICE_FEE_UP_TO_AMOUNT
)