Skip to content

Commit e47a231

Browse files
authored
Merge pull request #4575 from wpaulino/funding-contribution-builder-manual-inputs
Support manually selecting inputs consuming their entire value
2 parents 4d6528c + dcca939 commit e47a231

3 files changed

Lines changed: 1270 additions & 361 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use crate::ln::channelmanager::{
5757
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
5858
};
5959
use crate::ln::funding::{
60-
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput, PriorContribution,
60+
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
6161
};
6262
use crate::ln::interactivetxs::{
6363
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
@@ -12536,6 +12536,16 @@ where
1253612536
});
1253712537
}
1253812538

12539+
let spliceable_balance = self.get_next_splice_out_maximum(&self.funding).map_err(|e| {
12540+
APIError::ChannelUnavailable {
12541+
err: format!(
12542+
"Channel {} cannot be spliced at this time: {}",
12543+
self.context.channel_id(),
12544+
e
12545+
),
12546+
}
12547+
})?;
12548+
1253912549
let (min_rbf_feerate, prior_contribution) = if self.is_rbf_compatible().is_err() {
1254012550
// Channel can never RBF (e.g., zero-conf).
1254112551
(None, None)
@@ -12568,16 +12578,7 @@ where
1256812578
.as_ref()
1256912579
.and_then(|pending_splice| pending_splice.contributions.last())
1257012580
{
12571-
let spliceable_balance = self
12572-
.get_next_splice_out_maximum(&self.funding)
12573-
.map_err(|e| APIError::ChannelUnavailable {
12574-
err: format!(
12575-
"Channel {} cannot be spliced at this time: {}",
12576-
self.context.channel_id(),
12577-
e
12578-
),
12579-
})?;
12580-
Some(PriorContribution::new(prior.clone(), spliceable_balance))
12581+
Some(prior.clone())
1258112582
} else {
1258212583
None
1258312584
}
@@ -12599,7 +12600,12 @@ where
1259912600
satisfaction_weight: EMPTY_SCRIPT_SIG_WEIGHT + FUNDING_TRANSACTION_WITNESS_WEIGHT,
1260012601
};
1260112602

12602-
Ok(FundingTemplate::new(Some(shared_input), min_rbf_feerate, prior_contribution))
12603+
Ok(FundingTemplate::new(
12604+
Some(shared_input),
12605+
min_rbf_feerate,
12606+
prior_contribution,
12607+
spliceable_balance,
12608+
))
1260312609
}
1260412610

1260512611
/// Returns whether this channel can ever RBF, independent of splice state.

0 commit comments

Comments
 (0)