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

[bug]: lnwallet's DustLimitForSize doesn't consider p2tr outputs precisely #9358

Open
hieblmi opened this issue Dec 14, 2024 · 3 comments
Open
Labels
bug Unintended code behaviour wallet The wallet (lnwallet) which LND uses

Comments

@hieblmi
Copy link
Collaborator

hieblmi commented Dec 14, 2024

Calls to lnwallet.DustLimitForSize(input.P2TRSize) generate a dust limit based on input.GenerateUnknownWitness() which assumes a maximum witness size of 40 bytes.

Similar to GenerateP2PKH, we should provide a function GenerateP2TR to account for the exact taproot witness size.

See:

func DustLimitForSize(scriptSize int) btcutil.Amount {

@hieblmi hieblmi added bug Unintended code behaviour wallet The wallet (lnwallet) which LND uses needs triage labels Dec 14, 2024
@ziggie1984
Copy link
Collaborator

Hmm not sure if we want to fix it, because we overestimate just by 8 bytes and currently the BOLT spec also does classify all other Pk_Script with a StackElement > OP_0 as unknown witness: https://github.com/lightning/bolts/blob/master/03-transactions.md#dust-limits

If we go that route we would also need to maybe adjust the input script (witness) assumption which is currently after discountn 107.

So not sure if we wanna go this route.

@Crypt-iQ
Copy link
Collaborator

input.P2TRSize is identical to input.P2WSHSize so it doesn't hit the unknown case

@hieblmi
Copy link
Collaborator Author

hieblmi commented Dec 16, 2024

input.P2TRSize is identical to input.P2WSHSize so it doesn't hit the unknown case

True, both are 34, maybe a clarifying comment on the case input.P2WSHSize will suffice then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unintended code behaviour wallet The wallet (lnwallet) which LND uses
Projects
None yet
Development

No branches or pull requests

3 participants