Skip to content

Commit d71c31d

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 a86a745 commit d71c31d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lightning/src/ln/channel.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -2242,15 +2242,19 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22422242
},
22432243
};
22442244

2245-
let funding_ready_for_sig_event = None;
2246-
if signing_session.local_inputs_count() == 0 {
2245+
let funding_ready_for_sig_event = if signing_session.local_inputs_count() == 0 {
22472246
debug_assert_eq!(our_funding_satoshis, 0);
22482247
if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
22492248
debug_assert!(
22502249
false,
22512250
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
22522251
);
2252+
return Err((self, ChannelError::Close((
2253+
"V2 channel rejected due to sender error".into(),
2254+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2255+
))));
22532256
}
2257+
None
22542258
} else {
22552259
// TODO(dual_funding): Send event for signing if we've contributed funds.
22562260
// Inform the user that SIGHASH_ALL must be used for all signatures when contributing
@@ -2266,7 +2270,15 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22662270
// will prevent the funding transaction from being relayed on the bitcoin network and hence being
22672271
// confirmed.
22682272
// </div>
2269-
}
2273+
debug_assert!(
2274+
false,
2275+
"We don't support users providing inputs but somehow we had more than zero inputs",
2276+
);
2277+
return Err((self, ChannelError::Close((
2278+
"V2 channel rejected due to sender error".into(),
2279+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2280+
))));
2281+
};
22702282

22712283
self.context.channel_state = ChannelState::FundingNegotiated;
22722284

0 commit comments

Comments
 (0)