Skip to content
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 LNURL-pay drain #559

Open
dangeross opened this issue Nov 11, 2024 · 1 comment
Open

Add LNURL-pay drain #559

dangeross opened this issue Nov 11, 2024 · 1 comment

Comments

@dangeross
Copy link
Collaborator

Calculate an invoice inversing the Boltz fees in a way to drain the wallet. If the invoice returned contains an MRH request a new invoice without Boltz fees.

Some findings

Calculating the inverse fee can be tricky. Every time the invoice amount goes from x000 to x001 (e.g 2000 -> 2001) the total amount skips a number. It means we could not create a drain tx for that amount (unless we hack the drain tx and increase the fee out by 1 sat)

Invoice Boltz Fee       Network Fee     Total
1000    1               14              1015
1001    2               14              1017

1999    2               14              2015
2000    2               14              2016
2001    3               14              2018
2002    3               14              2019

2999    3               14              3016
3000    3               14              3017
3001    4               14              3019
3002    4               14              3020

So if the wallet total is 2031 sats, lockup fee is 14 sats its not possible to create an invoice that will result in 2017 sats (invoice amount + boltz fee + network fee) for the drain

(again unless you change the lockup fee tx output to 15 sats in this case)

2031 total - 15 lockup fee = 2016
2016 - 14 network fee - 2 boltz fee = 2000

This was referenced Nov 11, 2024
@ok300
Copy link
Contributor

ok300 commented Nov 14, 2024

This is because the Boltz service fees use a ceil rounding in their calculation.

// For 1000 sats:
service_fee = ceil( amount * service_feerate )
            = ceil( 1000 * 0.001 )
            = 1

// For 1001 sats:
service_fee = ceil( 1001 * 0.001 )
            = ceil( 1.001 )
            = 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants