Skip to content

Commit b5ed7f7

Browse files
committed
Clean up conditional assignment of funding_ready_for_sig_event
We don't yet support contibuting inputs to V2 channels, so we need to debug_assert and return an error if our signing session somehow has local inputs. We also return an error if for some mystical reason, in the no input contributions case, the input count does not equal the witness count of zero.
1 parent f5f7aa8 commit b5ed7f7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,15 +2151,19 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
21512151
},
21522152
};
21532153

2154-
let funding_ready_for_sig_event = None;
2155-
if signing_session.local_inputs_count() == 0 {
2154+
let funding_ready_for_sig_event = if signing_session.local_inputs_count() == 0 {
21562155
debug_assert_eq!(our_funding_satoshis, 0);
21572156
if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
21582157
debug_assert!(
21592158
false,
21602159
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
21612160
);
2161+
return Err((self, ChannelError::Close((
2162+
"V2 channel rejected due to sender error".into(),
2163+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2164+
))));
21622165
}
2166+
None
21632167
} else {
21642168
// TODO(dual_funding): Send event for signing if we've contributed funds.
21652169
// Inform the user that SIGHASH_ALL must be used for all signatures when contributing
@@ -2175,7 +2179,15 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
21752179
// will prevent the funding transaction from being relayed on the bitcoin network and hence being
21762180
// confirmed.
21772181
// </div>
2178-
}
2182+
debug_assert!(
2183+
false,
2184+
"We don't support users providing inputs but somehow we had more than zero inputs",
2185+
);
2186+
return Err((self, ChannelError::Close((
2187+
"V2 channel rejected due to sender error".into(),
2188+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2189+
))));
2190+
};
21792191

21802192
self.context.channel_state = ChannelState::FundingNegotiated;
21812193

0 commit comments

Comments
 (0)