Skip to content

Commit 5ca226e

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 fdb8de8 commit 5ca226e

2 files changed

Lines changed: 728 additions & 41 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12532,14 +12532,12 @@ where
1253212532
};
1253312533
}
1253412534

12535-
if let Err(e) = contribution.validate().and_then(|()| {
12536-
// For splice-out, our_funding_contribution is adjusted to cover fees if there
12537-
// aren't any inputs.
12538-
let our_funding_contribution = contribution.net_value();
12535+
let our_funding_contribution = contribution.net_value();
12536+
12537+
if let Err(e) =
1253912538
self.validate_splice_contributions(our_funding_contribution, SignedAmount::ZERO)
12540-
}) {
12539+
{
1254112540
log_error!(logger, "Channel {} cannot be funded: {}", self.context.channel_id(), e);
12542-
1254312541
return Err(QuiescentError::FailSplice(self.splice_funding_failed_for(contribution)));
1254412542
}
1254512543

@@ -14095,13 +14093,11 @@ where
1409514093
// funding_contributed and quiescence, reducing the holder's
1409614094
// balance. If invalid, disconnect and return the contribution so
1409714095
// the user can reclaim their inputs.
14098-
if let Err(e) = contribution.validate().and_then(|()| {
14099-
let our_funding_contribution = contribution.net_value();
14100-
self.validate_splice_contributions(
14101-
our_funding_contribution,
14102-
SignedAmount::ZERO,
14103-
)
14104-
}) {
14096+
let our_funding_contribution = contribution.net_value();
14097+
if let Err(e) = self.validate_splice_contributions(
14098+
our_funding_contribution,
14099+
SignedAmount::ZERO,
14100+
) {
1410514101
let failed = self.splice_funding_failed_for(contribution);
1410614102
return Err((
1410714103
ChannelError::WarnAndDisconnect(format!(

0 commit comments

Comments
 (0)