Skip to content

Commit b2b0d43

Browse files
jkczyzclaude
andcommitted
Document script_pubkey-only matching in into_unique_contributions
The function compares outputs by script_pubkey alone, not full TxOut, so any contribution output sharing a script with an existing output is filtered regardless of value. This is intentional — a change output's value may shift between rounds (e.g., for a new feerate) and should still match. But the consequence isn't obvious: multiple contribution outputs sharing a script are all filtered together when any existing output uses that script. Document it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2bde91e commit b2b0d43

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lightning/src/ln/funding.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,15 @@ impl FundingContribution {
757757
(inputs.into_iter().map(|input| input.utxo.outpoint).collect(), outputs)
758758
}
759759

760+
/// Returns this contribution's inputs and outputs after removing any that overlap with
761+
/// the provided `existing_inputs`/`existing_outputs`.
762+
///
763+
/// Outputs are compared by `script_pubkey` alone (not full `TxOut`), since values may
764+
/// differ between rounds (e.g., a change output adjusted for a new feerate). As a
765+
/// consequence, multiple contribution outputs sharing a `script_pubkey` are all
766+
/// dropped together when any existing output uses the same script.
767+
///
768+
/// Returns `None` if every input and output was filtered as overlapping.
760769
pub(super) fn into_unique_contributions<'a>(
761770
self, existing_inputs: impl Iterator<Item = OutPoint>,
762771
existing_outputs: impl Iterator<Item = &'a TxOut>,

0 commit comments

Comments
 (0)