Skip to content

Commit

Permalink
Clean up conditional assignment of funding_ready_for_sig_event
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dunxen committed Nov 27, 2024
1 parent e563b9d commit 8d9624f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1801,15 +1801,19 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
},
};

let funding_ready_for_sig_event = None;
if signing_session.local_inputs_count() == 0 {
let funding_ready_for_sig_event = if signing_session.local_inputs_count() == 0 {
debug_assert_eq!(our_funding_satoshis, 0);
if signing_session.provide_holder_witnesses(context.channel_id, Vec::new()).is_err() {
debug_assert!(
false,
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
);
return Err(ChannelError::Close((
"V2 channel rejected due to sender error".into(),
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
)));
}
None
} else {
// TODO(dual_funding): Send event for signing if we've contributed funds.
// Inform the user that SIGHASH_ALL must be used for all signatures when contributing
Expand All @@ -1825,7 +1829,15 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
// will prevent the funding transaction from being relayed on the bitcoin network and hence being
// confirmed.
// </div>
}
debug_assert!(
false,
"We don't support users providing inputs but somehow we had more than zero inputs",
);
return Err(ChannelError::Close((
"V2 channel rejected due to sender error".into(),
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
)));
};

context.channel_state = ChannelState::FundingNegotiated;

Expand Down

0 comments on commit 8d9624f

Please sign in to comment.