Skip to content

Conversation

@dunxen
Copy link
Contributor

@dunxen dunxen commented Apr 15, 2025

We introduce a ChannelManager::accept_inbound_channel_with_contribution
method allowing contributing to the overall channel capacity of an inbound
dual-funded channel by contributing inputs.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Apr 15, 2025

👋 Thanks for assigning @wpaulino 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.

@dunxen dunxen force-pushed the 2025-04-contributeinputs branch from e22fa33 to fabbf86 Compare April 25, 2025 18:20
@dunxen dunxen force-pushed the 2025-04-contributeinputs branch 4 times, most recently from c42f3d0 to 186d66b Compare May 12, 2025 10:51
@dunxen dunxen force-pushed the 2025-04-contributeinputs branch from 186d66b to c7d8e89 Compare May 19, 2025 11:07
@dunxen dunxen force-pushed the 2025-04-contributeinputs branch from c7d8e89 to 540b8a7 Compare June 12, 2025 08:40
@wpaulino
Copy link
Contributor

Looks like this needs a rebase after #3637

@dunxen dunxen force-pushed the 2025-04-contributeinputs branch from 540b8a7 to 94bf848 Compare June 13, 2025 05:35
@dunxen
Copy link
Contributor Author

dunxen commented Jun 13, 2025

Looks like this needs a rebase after #3637

ugh right!

@wpaulino
Copy link
Contributor

Don't the first three commits need to be dropped?

@dunxen dunxen force-pushed the 2025-04-contributeinputs branch 2 times, most recently from 67504f0 to 9f276d8 Compare June 17, 2025 10:40
@dunxen
Copy link
Contributor Author

dunxen commented Jun 17, 2025

Just needs node reload tests but it can still get some initial review.

@dunxen dunxen force-pushed the 2025-04-contributeinputs branch from 9f276d8 to 60f58b1 Compare June 17, 2025 16:26
script_pubkey: funding.get_funding_redeemscript().to_p2wsh(),
};

// Optionally add change output
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this already be covered by begin_interactive_funding_tx_construction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh indeed. begin_interactive_funding_tx_construction was modified to include that in a previous pre-splicing work. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated to use the new FundingNegotiationContext::into_interactive_tx_constructor. However, since this consumes self, I had to make FundingNegotiationContext an Option. Also, added some helpers to avoid unwrap. Unfortunately, it cannot be avoided for locktime, but maybe the two Options can be replaced with the FundingNegotiation enum or a dedicated one. @wpaulino Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding locktime, maybe we just throw it in UnfundedChannelContext or directly in PendingV2Channel? Using FundingNegotiation may not be ideal given it has a variant (AwaitingSignatures) where the locktime is no longer available, even though we'd never have a PendingV2Channel in that state.

Copy link
Contributor

@jkczyz jkczyz Nov 21, 2025

Choose a reason for hiding this comment

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

As mentioned offline, I added a fixup to store the locktime directly in PendingV2Channel. Using UnfundedChannelContext won't work since it is used for v1 channels, too. I considered passing the locktime to the relevant method (get_open_channel_v2) after constructing the channel. However, that method is called in some other places, too.

};

// Optionally add change output
let change_script = signer_provider.get_destination_script(context.channel_keys_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe let the user optionally provide a change address along with their inputs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

@jkczyz jkczyz self-requested a review June 18, 2025 18:19
@wpaulino
Copy link
Contributor

Since the FundingTransactionReadyForSigning work is also relevant for splicing (though it will need some minor additional changes), maybe we should split it up from the inbound contribution work, so that we can unblock testing on the splicing side once #3736 lands.

@ldk-reviews-bot
Copy link

🔔 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

🔔 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.

@dunxen
Copy link
Contributor Author

dunxen commented Jun 24, 2025

Since the FundingTransactionReadyForSigning work is also relevant for splicing (though it will need some minor additional changes), maybe we should split it up from the inbound contribution work, so that we can unblock testing on the splicing side once #3736 lands.

Agreed. Apologies for the late response. Back home now. I'll split it into a separate PR and we can discuss changes.

@ldk-reviews-bot
Copy link

🔔 3rd 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.

@dunxen dunxen force-pushed the 2025-04-contributeinputs branch 2 times, most recently from 9a2a5ce to 8006303 Compare June 27, 2025 07:19
@codecov
Copy link

codecov bot commented Jun 27, 2025

Codecov Report

❌ Patch coverage is 96.96133% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.61%. Comparing base (9150bc8) to head (fe940d6).

Files with missing lines Patch % Lines
lightning/src/ln/dual_funding_tests.rs 97.96% 5 Missing and 1 partial ⚠️
lightning/src/ln/channel.rs 91.66% 0 Missing and 3 partials ⚠️
lightning/src/ln/channelmanager.rs 90.90% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3735      +/-   ##
==========================================
+ Coverage   89.32%   89.61%   +0.29%     
==========================================
  Files         180      181       +1     
  Lines      138176   138525     +349     
  Branches   138176   138525     +349     
==========================================
+ Hits       123424   124141     +717     
+ Misses      12137    11774     -363     
+ Partials     2615     2610       -5     
Flag Coverage Δ
fuzzing 33.65% <10.00%> (+0.03%) ⬆️
tests 89.00% <96.96%> (+0.29%) ⬆️

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

🔔 4th 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

🔔 11th Reminder

Hey @jkczyz @wpaulino! 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.

@dunxen
Copy link
Contributor Author

dunxen commented Oct 18, 2025

Sorry, long time. This needs a super rebase. I see #1621 was closed. Do we need another issue for dual-funding tracking?

@jkczyz
Copy link
Contributor

jkczyz commented Oct 20, 2025

Sorry, long time. This needs a super rebase. I see #1621 was closed. Do we need another issue for dual-funding tracking?

Yeah, probably best to use a fresh issue than re-open an older one that's accumulated the splicing work.

@jkczyz jkczyz force-pushed the 2025-04-contributeinputs branch from c059e03 to fe940d6 Compare November 11, 2025 22:40
@jkczyz
Copy link
Contributor

jkczyz commented Nov 11, 2025

Rebased! Will take over the PR from here 🫡

@dunxen
Copy link
Contributor Author

dunxen commented Nov 16, 2025

Rebased! Will take over the PR from here 🫡

Thanks, @jkczyz! I will be able to give some review this week. Blocked out some space for it.

@dunxen
Copy link
Contributor Author

dunxen commented Nov 17, 2025

Just looked through the docs/comments and hope they are still valid since this PR was opened.

dunxen and others added 2 commits November 20, 2025 11:30
…annel

We introduce a `ChannelManager::accept_inbound_channel_with_contribution`
method allowing contributing to the overall channel capacity of an inbound
dual-funded channel by contributing inputs.
Comment on lines 9871 to 9872
/// portion of the channel value. Our contribution will be calculated as the total value of these
/// inputs minus the fees we need to cover for the interactive funding transaction. The witness
Copy link
Contributor

Choose a reason for hiding this comment

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

This actually isn't accurate. The contribution is given by our_funding_satoshis, while funding_inputs must have enough for that plus any fees. The remaining value should go to change. Updated the docs accordingly.

script_pubkey: funding.get_funding_redeemscript().to_p2wsh(),
};

// Optionally add change output
Copy link
Contributor

Choose a reason for hiding this comment

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

Updated to use the new FundingNegotiationContext::into_interactive_tx_constructor. However, since this consumes self, I had to make FundingNegotiationContext an Option. Also, added some helpers to avoid unwrap. Unfortunately, it cannot be avoided for locktime, but maybe the two Options can be replaced with the FundingNegotiation enum or a dedicated one. @wpaulino Thoughts?

};

// Optionally add change output
let change_script = signer_provider.get_destination_script(context.channel_keys_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

@jkczyz jkczyz force-pushed the 2025-04-contributeinputs branch from fe940d6 to ed4d8a5 Compare November 20, 2025 17:32
@jkczyz jkczyz requested a review from wpaulino November 20, 2025 17:33
jkczyz and others added 2 commits November 20, 2025 19:30
We can now run through the case where the acceptor contributes to an
inbound channel, with either more value in inputs, or less value, leading
to a different `tx_signatures` exchange order.

We also cannot use dummy P2WPKH funding inputs and witnesses anymore as
`funding_transaction_signed` internally verifies signatures. Hence, we
create external keypairs that we can create outputs for and sign with.
@jkczyz jkczyz force-pushed the 2025-04-contributeinputs branch from ed4d8a5 to 9a04ed0 Compare November 21, 2025 23:06
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @wpaulino! 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

🔔 2nd Reminder

Hey @wpaulino! 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

🔔 3rd Reminder

Hey @wpaulino! 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

🔔 4th Reminder

Hey @wpaulino! 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

🔔 5th Reminder

Hey @wpaulino! 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

🔔 6th Reminder

Hey @wpaulino! 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

🔔 7th Reminder

Hey @wpaulino! 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

🔔 8th Reminder

Hey @wpaulino! 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 on lines +14197 to +14198
funding_negotiation_context: None,
interactive_tx_constructor: Some(interactive_tx_constructor),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to reuse FundingNegotiation here, but it seems unclear whether the last AwaitingSignatures state can be adapted to the initial dual funding state


// TODO(dual_funding): Use real node and API for creating V2 channels as initiator when available,
// instead of manually constructing messages.
fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just drop these until we can use the real API?

pub fn accept_inbound_channel_with_contribution(
&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey,
user_channel_id: u128, config_overrides: Option<ChannelConfigOverrides>,
our_funding_contribution: Amount, funding_inputs: Vec<FundingTxInput>,
Copy link
Contributor

Choose a reason for hiding this comment

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

We're also allowed to include outputs, behaving similar to the mixed mode splice, so maybe it's worth waiting until we figure that out in #4261 so we can adopt it here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants