Document script_pubkey-only matching in into_unique_contributions
What changed, and why it matters
This commit only adds a comment explaining existing behavior in a Bitcoin Lightning funding function. It does not change any code logic. The behavior being documented—filtering duplicate outputs based only on their script address—could theoretically let a malicious or buggy participant hide funds in some edge cases, but the commit itself is a documentation-only change and does not introduce or fix a vulnerability.
No immediate action required. Treat as a documentation improvement. If the script_pubkey-only matching behavior is later found to enable attacks (e.g., duplicate-script output suppression in interactive funding), it should be evaluated separately as a design issue, not as a vulnerability introduced by this commit.
Security signals we found
Documentation-only change
Describes intentional script_pubkey-only matching behavior
Notes that multiple outputs sharing a script are dropped together
No logic or control-flow changes
Evidence from the diff
The commit adds a doc comment to FundingContribution::into_unique_contributions in lightning/src/ln/funding.rs. The function already compared contribution outputs against existing outputs by script_pubkey only, dropping all contribution outputs that share a script with any existing output. The patch documents that this is intentional so that change outputs whose values shift between rounds (e.g., due to feerate changes) still match, but it also means multiple contribution outputs sharing a script are all filtered together. No executable code was modified.
Changed components
lightning/src/ln/funding.rsFundingContribution::into_unique_contributionsInspect captured patch +7 / −0
diff --git a/lightning/src/ln/funding.rs b/lightning/src/ln/funding.rs
index 3a0b4fb..f73b487 100644
--- a/lightning/src/ln/funding.rs
+++ b/lightning/src/ln/funding.rs
@@ -761,6 +761,13 @@ impl FundingContribution {
(contributed_inputs, contributed_outputs.map(|output| output.script_pubkey).collect())
}
+ /// Returns this contribution's inputs and outputs after removing any that overlap
+ /// with the provided `existing_inputs`/`existing_outputs`.
+ ///
+ /// Multiple contribution outputs sharing a `script_pubkey` are all dropped when any
+ /// existing output uses the same script.
+ ///
+ /// Returns `None` if every input and output was filtered as overlapping.
pub(crate) fn into_unique_contributions<'a>(
self, existing_inputs: impl Iterator<Item = OutPoint>,
existing_outputs: impl Iterator<Item = &'a bitcoin::Script>,
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.