-
Notifications
You must be signed in to change notification settings - Fork 144
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
base: main
Are you sure you want to change the base?
Changes from all commits
3d8d042
9e6114b
f1a0a79
c8e0713
9a8a938
b8ca9c4
88be9ce
cf78007
328bdc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1647,7 +1647,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 to bump its fee" | ||
| ); | ||
| return Err(Error::ChannelSplicingFailed); | ||
| } | ||
|
|
@@ -1770,7 +1770,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 to bump its fee" | ||
| ); | ||
| return Err(Error::ChannelSplicingFailed); | ||
|
jkczyz marked this conversation as resolved.
|
||
| } | ||
|
|
@@ -1807,6 +1807,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( | ||
|
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. Is the plan for ldk-node to eventually monitor pending splice candidates and automatically bump them? It seems a bit awkward to make users/applications notice that a pending splice is stuck and manually call this API.
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. Wonder how this method can be used to bump the fee much higher and not only to the next step. Invoke repeatedly while they monitor what the current pending splice fee rate is? |
||
| &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. | ||
| /// | ||
|
|
||
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.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.
Fixed the message, but I'm not sure it justifies a new error type. Callers will be able to check
SpliceDetailsonce lightningdevkit/rust-lightning#4687 is included. @tnull Any preference?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.
Should that be added to the 0.3 milestone?
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.
Yeah, added.