Skip to content

Follow-ups for #4014 #4023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6984,10 +6984,12 @@ where
.and_then(|funding_negotiation| funding_negotiation.as_funding())
.expect("Funding must exist for negotiated pending splice");
let transaction_number = self.holder_commitment_point.current_transaction_number();
let commitment_point = self
.holder_commitment_point
.current_point()
.expect("current should be set after receiving the initial commitment_signed");
let commitment_point = self.holder_commitment_point.current_point().ok_or_else(|| {
debug_assert!(false);
ChannelError::close(
"current_point should be set for channels initiating splicing".to_owned(),
)
})?;
let (holder_commitment_tx, _) = self.context.validate_commitment_signed(
pending_splice_funding,
transaction_number,
Expand Down Expand Up @@ -10574,7 +10576,7 @@ where
if self.holder_commitment_point.current_point().is_none() {
return Err(APIError::APIMisuseError {
err: format!(
"Channel {} cannot be spliced, commitment point needs to be advanced once",
"Channel {} cannot be spliced until a payment is routed",
self.context.channel_id(),
),
});
Expand Down Expand Up @@ -10682,7 +10684,7 @@ where
// TODO(splicing): Add check that we are the quiescence acceptor

if self.holder_commitment_point.current_point().is_none() {
return Err(ChannelError::Warn(format!(
return Err(ChannelError::WarnAndDisconnect(format!(
"Channel {} commitment point needs to be advanced once before spliced",
self.context.channel_id(),
)));
Expand Down Expand Up @@ -13835,13 +13837,28 @@ where
}

// If we're restoring this channel for the first time after an upgrade, then we require that the
// signer be available so that we can immediately populate the current commitment point. Channel
// signer be available so that we can immediately populate the next commitment point. Channel
// restoration will fail if this is not possible.
let holder_commitment_point =
let holder_commitment_point = {
let current_point = holder_commitment_point_current_opt.or_else(|| {
if holder_commitment_next_transaction_number == INITIAL_COMMITMENT_NUMBER {
None
} else {
// If the current point is not available then splicing can't be initiated
// until the next point is advanced and becomes the current point.
holder_signer
.get_per_commitment_point(
holder_commitment_next_transaction_number + 1,
&secp_ctx,
)
.ok()
}
});

match (holder_commitment_point_next_opt, holder_commitment_point_pending_next_opt) {
(Some(next_point), pending_next_point) => HolderCommitmentPoint {
next_transaction_number: holder_commitment_next_transaction_number,
current_point: None,
current_point,
next_point,
pending_next_point,
},
Expand All @@ -13861,12 +13878,13 @@ where
);
HolderCommitmentPoint {
next_transaction_number: holder_commitment_next_transaction_number,
current_point: holder_commitment_point_current_opt,
current_point,
next_point,
pending_next_point: Some(pending_next_point),
}
},
};
}
};

Ok(FundedChannel {
funding: FundingScope {
Expand Down
Loading