Skip to content

Commit 5f79661

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 311aa1d commit 5f79661

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
@@ -2122,15 +2122,19 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
21222122
},
21232123
};
21242124

2125-
let funding_ready_for_sig_event = None;
2126-
if signing_session.local_inputs_count() == 0 {
2125+
let funding_ready_for_sig_event = if signing_session.local_inputs_count() == 0 {
21272126
debug_assert_eq!(our_funding_satoshis, 0);
21282127
if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
21292128
debug_assert!(
21302129
false,
21312130
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
21322131
);
2132+
return Err((self, ChannelError::Close((
2133+
"V2 channel rejected due to sender error".into(),
2134+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2135+
))));
21332136
}
2137+
None
21342138
} else {
21352139
// TODO(dual_funding): Send event for signing if we've contributed funds.
21362140
// Inform the user that SIGHASH_ALL must be used for all signatures when contributing
@@ -2146,7 +2150,15 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
21462150
// will prevent the funding transaction from being relayed on the bitcoin network and hence being
21472151
// confirmed.
21482152
// </div>
2149-
}
2153+
debug_assert!(
2154+
false,
2155+
"We don't support users providing inputs but somehow we had more than zero inputs",
2156+
);
2157+
return Err((self, ChannelError::Close((
2158+
"V2 channel rejected due to sender error".into(),
2159+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2160+
))));
2161+
};
21502162

21512163
self.context.channel_state = ChannelState::FundingNegotiated;
21522164

0 commit comments

Comments
 (0)