Skip to content

Commit b1c3e29

Browse files
committed
Introduce FundingBuilder for splice requests
This lets callers easily amend a prior contribution in place and only re-run coin selection when the new request cannot be satisfied with the existing inputs.
1 parent 58f226e commit b1c3e29

2 files changed

Lines changed: 925 additions & 41 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12535,14 +12535,12 @@ where
1253512535
};
1253612536
}
1253712537

12538-
if let Err(e) = contribution.validate().and_then(|()| {
12539-
// For splice-out, our_funding_contribution is adjusted to cover fees if there
12540-
// aren't any inputs.
12541-
let our_funding_contribution = contribution.net_value();
12538+
let our_funding_contribution = contribution.net_value();
12539+
12540+
if let Err(e) =
1254212541
self.validate_splice_contributions(our_funding_contribution, SignedAmount::ZERO)
12543-
}) {
12542+
{
1254412543
log_error!(logger, "Channel {} cannot be funded: {}", self.context.channel_id(), e);
12545-
1254612544
return Err(QuiescentError::FailSplice(self.splice_funding_failed_for(contribution)));
1254712545
}
1254812546

@@ -14104,13 +14102,11 @@ where
1410414102
// funding_contributed and quiescence, reducing the holder's
1410514103
// balance. If invalid, disconnect and return the contribution so
1410614104
// the user can reclaim their inputs.
14107-
if let Err(e) = contribution.validate().and_then(|()| {
14108-
let our_funding_contribution = contribution.net_value();
14109-
self.validate_splice_contributions(
14110-
our_funding_contribution,
14111-
SignedAmount::ZERO,
14112-
)
14113-
}) {
14105+
let our_funding_contribution = contribution.net_value();
14106+
if let Err(e) = self.validate_splice_contributions(
14107+
our_funding_contribution,
14108+
SignedAmount::ZERO,
14109+
) {
1411414110
let failed = self.splice_funding_failed_for(contribution);
1411514111
return Err((
1411614112
ChannelError::WarnAndDisconnect(format!(

0 commit comments

Comments
 (0)