Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Rework ChannelManager::funding_transaction_signed by wpaulino · Pull Request #4257 · lightningdevkit/rust-lightning · GitHub
Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Rework ChannelManager::funding_transaction_signed by wpaulino · Pull Request #4257 · lightningdevkit/rust-lightning · GitHub
Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Rework ChannelManager::funding_transaction_signed by wpaulino · Pull Request #4257 · lightningdevkit/rust-lightning · GitHub
Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Rework ChannelManager::funding_transaction_signed by wpaulino · Pull Request #4257 · lightningdevkit/rust-lightning · GitHub
Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Rework ChannelManager::funding_transaction_signed by wpaulino · Pull Request #4257 · lightningdevkit/rust-lightning · GitHub
Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Rework ChannelManager::funding_transaction_signed by wpaulino · Pull Request #4257 · lightningdevkit/rust-lightning · GitHub
Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Rework ChannelManager::funding_transaction_signed by wpaulino · Pull Request #4257 · lightningdevkit/rust-lightning · GitHub
Skip to content

Rework ChannelManager::funding_transaction_signed - #4257

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework
Jan 20, 2026
Merged

Rework ChannelManager::funding_transaction_signed#4257
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
wpaulino:funding-transaction-signed-rework

Conversation

@wpaulino

Copy link
Copy Markdown
Contributor

Previously, we'd emit a FundingTransactionReadyForSigning event once the initial commitment_signed is exchanged for a splicing/dual-funding attempt and require users to call back with their signed inputs using ChannelManager::funding_transaction_signed. While this approach worked in practice, it prevents us from abandoning a splice if we cannot or no longer wish to sign as the splice has already been committed to by this point.

This commit reworks the API such that this is now possible. After exchanging tx_complete, we will no longer immediately send our initial commitment_signed. We will now emit the
FundingTransactionReadyForSigning event and wait for the user to call back before releasing both our initial commitment_signed and our tx_signatures. As a result, the event is now persisted, as there is only one possible path in which it is generated. Note that we continue to only emit the event if a local contribution to negotiated transaction was made.

Future work will expose a cancellation API such that we can abandon splice attempts safely (we can just force close the channel with dual-funding).

@wpaulinowpaulino added this to the 0.3 milestone Dec 3, 2025
@wpaulino
wpaulino requested a review from jkczyzDecember 3, 2025 18:47
@wpaulinowpaulino self-assigned this Dec 3, 2025
@ldk-reviews-bot

ldk-reviews-bot commented Dec 3, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 61719cf to 135605fCompareDecember 3, 2025 19:35
@codecov

codecovBot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.49664% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (c5d7b13) to head (e502ce3).
⚠️ Report is 30 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channel.rs81.32%23 Missing and 8 partials ⚠️
lightning/src/ln/splicing_tests.rs0.00%23 Missing ⚠️
lightning/src/ln/channelmanager.rs78.02%18 Missing and 2 partials ⚠️
lightning/src/events/mod.rs87.50%0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4257 +/- ##
==========================================
+ Coverage 86.59% 86.60% +0.01% 
==========================================
Files 158 158 Lines 102368 102376 +8 Branches 102368 102376 +8 ==========================================
+ Hits 88641 88659 +18 + Misses 11313 11297 -16 - Partials 2414 2420 +6 
FlagCoverage Δ
fuzzing36.99% <16.77%> (+0.05%)⬆️
tests85.89% <80.72%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment on lines -6475 to -6476
Some(channel) => match channel.as_funded_mut() {
Some(chan) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we can write a FundingTransactionReadyForSigning for dual funding, but upon restart the channel will be forgotten as it will still be considered pending. So calling funding_transaction_signed will fail in that case. Is this a problem? Or should we at least note this in the docs?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the docs that it can happen

Comment threadlightning/src/ln/channel.rs Outdated
Comment threadlightning/src/ln/channel.rs Outdated
@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

Comment threadlightning/src/ln/channel.rs Outdated
Comment on lines +2167 to +2168
// TODO(splicing): Support async signing
.ok_or("Failed to compute commitment_signed signatures".to_owned())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I thought you said this was supporting async signing :p

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
));
}
if channel.context().is_connected() {
if let Some(commit_sig) = commit_sig {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that checks that we avoid sending the commit sigs here if the funding_transaction_signed call comes in before the monitor is persisted (async)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually send our commit sig immediately after funding_transaction_signed, there's no reason to wait for the monitor persist to complete first. We just have to make sure we don't process a counterparty one before it completes.

Previously, we'd emit a `FundingTransactionReadyForSigning` event once
the initial `commitment_signed` is exchanged for a splicing/dual-funding
attempt and require users to call back with their signed inputs using
`ChannelManager::funding_transaction_signed`. While this approach worked
in practice, it prevents us from abandoning a splice if we cannot or no
longer wish to sign as the splice has already been committed to by this
point.
This commit reworks the API such that this is now possible. After
exchanging `tx_complete`, we will no longer immediately send our initial
`commitment_signed`. We will now emit the
`FundingTransactionReadyForSigning` event and wait for the user to call
back before releasing both our initial `commitment_signed` and our
`tx_signatures`. As a result, the event is now persisted, as there is
only one possible path in which it is generated. Note that we continue
to only emit the event if a local contribution to negotiated transaction
was made.
Future work will expose a cancellation API such that we can abandon
splice attempts safely (we can just force close the channel with
dual-funding).
We delay processing it until the user manually approves the splice via
`Channel::funding_transaction_signed`, as otherwise, there would be a
[`ChannelMonitorUpdateStep::RenegotiatedFunding`] committed that we
would need to undo if they no longer wish to proceed.
Note that this doesn't need to be done with dual-funded channels as
there is no equivalent monitor update for them.
@wpaulino
wpaulinoforce-pushed the funding-transaction-signed-rework branch from 135605f to e502ce3CompareJanuary 14, 2026 22:20
ref unsigned_transaction,
} => {
48u8.write(writer)?;
write_tlv_fields!(writer, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleh, I'm really not a fan of this. We're really trying hard to write less in ChannelManager right now, it would be really nice to automatically regenerate this on startup if were in a state where we're waiting on the user to sign a funding tx.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only generated in one place (internal_tx_complete) where we already incur a write, so it shouldn't matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less about I/O and more about what happens if we don't write a ChannelManager at all.


// Handling a monitor update requires dropping peer state locks, so we use the labeled loop
// as a goto statement.
'peer_loop: loop {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm also pretty unexcited for yet more loops over all the peers and channels (especially that might change channel state and commit monitors!) called from get_and_clear_pending_msg_events. Somewhat less urgently cause obviously this already exists, but get_and_clear_pending_msg_events is really supposed to be super responsive and quick, and monitors absolutely wreck that. Is there really no way to pass messages back when we're ready to generate them rather than in a separate caller called every millisecond?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction. Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it as part of ChannelManager::funding_transaction_signed, but I wasn't happy with it there due to the two possible error paths: an APIError due to user API misuse, and a ChannelError while processing things that could result in a force close. I can give it another go if you'd like to see how that looks, otherwise this logic needs to live somewhere that happens shortly after without user and counterparty interaction.

Even if its a bit messy that does seem better - delaying message fetching for a sync monitor update isn't ideal :/

Two other candidates could be get_and_clear_pending_events and timer_tick_occurred (but this might not be ideal given we're under quiescence if we just missed the tick).

Nah, I think get_and_clear_pending_msg_events would be better, I mean we do wipe the holding cell in there already, so its not like its great...tho I'm currently looking to see how easy it is to remove...

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldk-node needs an update pr now.

@TheBlueMatt
TheBlueMatt merged commit 99247a9 into lightningdevkit:mainJan 20, 2026
19 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Gah FFS. I thought I had the #4261 tab open...I did not. I accidentally hit merge on this and had to force-push it back. Sorry about that. I guess github now mandates a new PR 😭

@wpaulino
wpaulino deleted the funding-transaction-signed-rework branch January 22, 2026 17:44
@jkczyzjkczyz mentioned this pull request Mar 19, 2026
50 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@wpaulino@ldk-reviews-bot@TheBlueMatt@jkczyz