Skip to content

Commit 5553df6

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 60b6533 commit 5553df6

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
@@ -2035,15 +2035,19 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
20352035
},
20362036
};
20372037

2038-
let funding_ready_for_sig_event = None;
2039-
if signing_session.local_inputs_count() == 0 {
2038+
let funding_ready_for_sig_event = if signing_session.local_inputs_count() == 0 {
20402039
debug_assert_eq!(our_funding_satoshis, 0);
20412040
if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
20422041
debug_assert!(
20432042
false,
20442043
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
20452044
);
2045+
return Err(ChannelError::Close((
2046+
"V2 channel rejected due to sender error".into(),
2047+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2048+
)));
20462049
}
2050+
None
20472051
} else {
20482052
// TODO(dual_funding): Send event for signing if we've contributed funds.
20492053
// Inform the user that SIGHASH_ALL must be used for all signatures when contributing
@@ -2059,7 +2063,15 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
20592063
// will prevent the funding transaction from being relayed on the bitcoin network and hence being
20602064
// confirmed.
20612065
// </div>
2062-
}
2066+
debug_assert!(
2067+
false,
2068+
"We don't support users providing inputs but somehow we had more than zero inputs",
2069+
);
2070+
return Err(ChannelError::Close((
2071+
"V2 channel rejected due to sender error".into(),
2072+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2073+
)));
2074+
};
20632075

20642076
self.context.channel_state = ChannelState::FundingNegotiated;
20652077

0 commit comments

Comments
 (0)