Skip to content

Commit db6b380

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 ac07d29 commit db6b380

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
@@ -2149,15 +2149,19 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
21492149
},
21502150
};
21512151

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

21782190
self.context.channel_state = ChannelState::FundingNegotiated;
21792191

0 commit comments

Comments
 (0)