Skip to content

Commit df21960

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 9218a2e commit df21960

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
@@ -2238,15 +2238,19 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22382238
},
22392239
};
22402240

2241-
let funding_ready_for_sig_event = None;
2242-
if signing_session.local_inputs_count() == 0 {
2241+
let funding_ready_for_sig_event = if signing_session.local_inputs_count() == 0 {
22432242
debug_assert_eq!(our_funding_satoshis, 0);
22442243
if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
22452244
debug_assert!(
22462245
false,
22472246
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
22482247
);
2248+
return Err((self, ChannelError::Close((
2249+
"V2 channel rejected due to sender error".into(),
2250+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2251+
))));
22492252
}
2253+
None
22502254
} else {
22512255
// TODO(dual_funding): Send event for signing if we've contributed funds.
22522256
// Inform the user that SIGHASH_ALL must be used for all signatures when contributing
@@ -2262,7 +2266,15 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22622266
// will prevent the funding transaction from being relayed on the bitcoin network and hence being
22632267
// confirmed.
22642268
// </div>
2265-
}
2269+
debug_assert!(
2270+
false,
2271+
"We don't support users providing inputs but somehow we had more than zero inputs",
2272+
);
2273+
return Err((self, ChannelError::Close((
2274+
"V2 channel rejected due to sender error".into(),
2275+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2276+
))));
2277+
};
22662278

22672279
self.context.channel_state = ChannelState::FundingNegotiated;
22682280

0 commit comments

Comments
 (0)