Skip to content

Commit 8d9624f

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 e563b9d commit 8d9624f

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
@@ -1801,15 +1801,19 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
18011801
},
18021802
};
18031803

1804-
let funding_ready_for_sig_event = None;
1805-
if signing_session.local_inputs_count() == 0 {
1804+
let funding_ready_for_sig_event = if signing_session.local_inputs_count() == 0 {
18061805
debug_assert_eq!(our_funding_satoshis, 0);
18071806
if signing_session.provide_holder_witnesses(context.channel_id, Vec::new()).is_err() {
18081807
debug_assert!(
18091808
false,
18101809
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
18111810
);
1811+
return Err(ChannelError::Close((
1812+
"V2 channel rejected due to sender error".into(),
1813+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
1814+
)));
18121815
}
1816+
None
18131817
} else {
18141818
// TODO(dual_funding): Send event for signing if we've contributed funds.
18151819
// Inform the user that SIGHASH_ALL must be used for all signatures when contributing
@@ -1825,7 +1829,15 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
18251829
// will prevent the funding transaction from being relayed on the bitcoin network and hence being
18261830
// confirmed.
18271831
// </div>
1828-
}
1832+
debug_assert!(
1833+
false,
1834+
"We don't support users providing inputs but somehow we had more than zero inputs",
1835+
);
1836+
return Err(ChannelError::Close((
1837+
"V2 channel rejected due to sender error".into(),
1838+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
1839+
)));
1840+
};
18291841

18301842
context.channel_state = ChannelState::FundingNegotiated;
18311843

0 commit comments

Comments
 (0)