-
Notifications
You must be signed in to change notification settings - Fork 145
Add splice RBF support #888
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
Open
jkczyz
wants to merge
7
commits into
lightningdevkit:main
Choose a base branch
from
jkczyz:2026-04-splicing-payment-using-tx-type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
557d906
Add rbf_channel API for fee-bumping pending splices
jkczyz 9cbdb06
f - Rename rbf_channel to bump_channel_funding_fee
jkczyz b91de23
Tie funding payment status transitions to Lightning lifecycle events
jkczyz 248ad8f
f - Preserve funding details when a splice candidate is replaced
jkczyz 7b7647b
f - Reject on-chain RBF of funding and splice payments
jkczyz 511d194
f - Rename persist_pending to persist_pending_payment
jkczyz bec7723
Persist payment transaction data without blocking LDK
jkczyz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1595,7 +1595,7 @@ impl Node { | |
| if funding_template.prior_contribution().is_some() { | ||
| log_error!( | ||
| self.logger, | ||
| "Failed to splice channel: a prior splice contribution is pending" | ||
| "Failed to splice channel: a prior splice contribution is pending; use bump_channel_funding_fee instead" | ||
| ); | ||
| return Err(Error::ChannelSplicingFailed); | ||
| } | ||
|
|
@@ -1716,7 +1716,7 @@ impl Node { | |
| if funding_template.prior_contribution().is_some() { | ||
| log_error!( | ||
| self.logger, | ||
| "Failed to splice channel: a prior splice contribution is pending" | ||
| "Failed to splice channel: a prior splice contribution is pending; use bump_channel_funding_fee instead" | ||
| ); | ||
| return Err(Error::ChannelSplicingFailed); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| } | ||
|
|
@@ -1753,6 +1753,73 @@ impl Node { | |
| } | ||
| } | ||
|
|
||
| /// Replace a pending splice's funding transaction with a higher-feerate version. | ||
| /// | ||
| /// If a prior splice negotiation is pending, this bumps its feerate via RBF. The prior | ||
| /// contribution is reused when possible; otherwise, coin selection is re-run. | ||
| /// | ||
| /// # Experimental API | ||
| /// | ||
| /// This API is experimental and may change in the future. | ||
| pub fn bump_channel_funding_fee( | ||
| &self, user_channel_id: &UserChannelId, counterparty_node_id: PublicKey, | ||
| ) -> Result<(), Error> { | ||
| let open_channels = | ||
| self.channel_manager.list_channels_with_counterparty(&counterparty_node_id); | ||
| if let Some(channel_details) = | ||
| open_channels.iter().find(|c| c.user_channel_id == user_channel_id.0) | ||
| { | ||
| let min_feerate = | ||
| self.fee_estimator.estimate_fee_rate(ConfirmationTarget::ChannelFunding); | ||
| let max_feerate = FeeRate::from_sat_per_kwu(min_feerate.to_sat_per_kwu() * 3 / 2); | ||
|
|
||
| let funding_template = self | ||
| .channel_manager | ||
| .splice_channel(&channel_details.channel_id, &counterparty_node_id) | ||
| .map_err(|e| { | ||
| log_error!(self.logger, "Failed to RBF channel: {:?}", e); | ||
| Error::ChannelSplicingFailed | ||
| })?; | ||
|
|
||
| if funding_template.min_rbf_feerate().is_none() { | ||
| log_error!(self.logger, "Failed to RBF channel: no pending splice to replace"); | ||
| return Err(Error::ChannelSplicingFailed); | ||
| } | ||
|
|
||
| let contribution = self | ||
| .runtime | ||
| .block_on(funding_template.rbf_prior_contribution( | ||
| None, | ||
| max_feerate, | ||
| Arc::clone(&self.wallet), | ||
| )) | ||
| .map_err(|e| { | ||
| log_error!(self.logger, "Failed to RBF channel: {}", e); | ||
| Error::ChannelSplicingFailed | ||
| })?; | ||
|
|
||
| self.channel_manager | ||
| .funding_contributed( | ||
| &channel_details.channel_id, | ||
| &counterparty_node_id, | ||
| contribution, | ||
| None, | ||
| ) | ||
| .map_err(|e| { | ||
| log_error!(self.logger, "Failed to RBF channel: {:?}", e); | ||
| Error::ChannelSplicingFailed | ||
| }) | ||
| } else { | ||
| log_error!( | ||
| self.logger, | ||
| "Channel not found for user_channel_id {} and counterparty {}", | ||
| user_channel_id, | ||
| counterparty_node_id | ||
| ); | ||
| Err(Error::ChannelSplicingFailed) | ||
| } | ||
| } | ||
|
|
||
| /// Manually sync the LDK and BDK wallets with the current chain state and update the fee rate | ||
| /// cache. | ||
| /// | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says use
rbf_channelinstead but that function doesn't let us change the amount in/out. Some likeuse rbf_channel to bump feewould be more accurate. Also would be nice if this had a separate error.