AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 51 Bitcoin

lnwallet: make DustLimitForSize total over the sizes it can be handed

Public commit record

What the developer wrote

Authored by Olaoluwa Osuntokun

73/100 · Adequate
lnwallet: make DustLimitForSize total over the sizes it can be handed

In this commit, we have DustLimitForSize fall back to the generic witness dust
threshold for any script size that doesn't match one of the well-known
templates.

The size switch covered P2WPKH, P2WSH, P2SH, P2PKH, and the explicit
unknown-witness size, and treated every other length as unreachable. That's a
narrower assumption than the callers can actually make good on: a witness
program for versions 1 through 16 carries a program of anywhere from 2 to 40
bytes, so its serialized length won't always land on one of those exact values.

The dust calculation only needs a representative output of roughly the right
shape, and the unknown-witness pricing is the conservative choice among the
ones we have, so we make it the default. That leaves the helper well defined
across the whole range of sizes callers can pass it, including scripts carrying
witness versions we don't know about yet.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This change removes a deliberate program crash (panic) in LND's fee/dust-limit helper and replaces it with a safe fallback. Previously, if the helper received a script length it didn't explicitly recognize, it would panic and potentially crash the node. Now it treats any unrecognized length as a generic witness output and returns a dust value instead. The patch is defensive: it makes the code well-defined for future Bitcoin witness versions and arbitrary script sizes, but the commit message does not frame it as fixing a known exploitable vulnerability.

Recommended action

Review callers of DustLimitForSize to confirm they no longer rely on panic behavior, and ensure the conservative unknown-witness dust threshold is acceptable for all possible script sizes in production paths. Consider whether any caller should explicitly reject unsupported sizes rather than silently accepting the fallback.

Security signals we found

01

Removal of a panic/default branch in favor of a conservative fallback

02

Defensive handling of arbitrary and future witness-version script sizes

03

Potential denial-of-service vector eliminated: unhandled script lengths no longer crash the helper

04

Conservative dust pricing chosen for unknown cases, reducing economic risk

Risk score

Why this scored 51/100

Our methodology →
Potential impact 12/30
Exploitability 10/25
Stealth signal 8/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.