Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dual funding extension, needed also for splicing: begin_interactive_funding_tx_construction #3443

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

optout21
Copy link
Contributor

@optout21 optout21 commented Dec 5, 2024

Add these two methods to the current dual funding implementation:
begin_interactive_funding_tx_construction()
calculate_change_output_value()

These changes are in the pipeline for dual funding implementation, and needed for dual funding negotiation during splicing, in #3444 .

@dunxen
Copy link
Contributor

dunxen commented Dec 5, 2024

Makes sense to get this this in so it can unblock you as #2302 will still take time. Is this much different from what is in #2302/any of the splicing PRs?

@jkczyz jkczyz self-requested a review December 5, 2024 15:22
@optout21
Copy link
Contributor Author

optout21 commented Dec 5, 2024

TODO: I need to run a comparison against current version of dual funding WIP

@optout21 optout21 force-pushed the splicing-dual-reqs2 branch 2 times, most recently from 4f7e41b to 0448cf9 Compare December 6, 2024 15:20
@optout21
Copy link
Contributor Author

optout21 commented Dec 6, 2024

Did the following:

  • break up maybe_add_funding_change_output() into two: one part for determining if a change needs to be added, and the other to actually add it
  • moved need_to_add_funding_change_output() into interactivetxs.rs
  • added unit tests for need_to_add_funding_change_output()

@optout21 optout21 changed the title [Draft] Dual funding extension needed for Splicing, begin_interactive_funding_tx_construction Dual funding extension needed for Splicing, begin_interactive_funding_tx_construction Dec 6, 2024
@optout21 optout21 marked this pull request as ready for review December 6, 2024 15:23
@optout21 optout21 changed the title Dual funding extension needed for Splicing, begin_interactive_funding_tx_construction Dual funding extension needed also for splicing: begin_interactive_funding_tx_construction Dec 6, 2024
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from 0448cf9 to 0e47819 Compare December 6, 2024 15:43
lightning/src/ln/interactivetxs.rs Outdated Show resolved Hide resolved
lightning/src/ln/interactivetxs.rs Show resolved Hide resolved
lightning/src/ln/interactivetxs.rs Outdated Show resolved Hide resolved
lightning/src/ln/interactivetxs.rs Show resolved Hide resolved
@optout21 optout21 requested a review from dunxen December 6, 2024 16:39
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from 48e0518 to 9e44d2b Compare December 6, 2024 16:41
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from 9e44d2b to b7e7a34 Compare December 9, 2024 07:20
@optout21 optout21 requested a review from dunxen December 9, 2024 07:22
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

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

Could you update the commit message with the rationale for the change? (i.e., specifically how it will be used in splicing)

lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from 70fde13 to b1ae668 Compare December 11, 2024 16:49
@optout21
Copy link
Contributor Author

Review comments addressed, all resolved from my side (left a few open for visibility)

@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from b1ae668 to 86f9680 Compare December 11, 2024 16:56
@optout21 optout21 requested a review from jkczyz December 11, 2024 16:57
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from 86f9680 to a379f1d Compare December 11, 2024 19:37
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 50.95238% with 103 lines in your changes missing coverage. Please review.

Project coverage is 88.36%. Comparing base (aa2c6fe) to head (c186145).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channel.rs 0.00% 103 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3443      +/-   ##
==========================================
- Coverage   88.44%   88.36%   -0.09%     
==========================================
  Files         149      149              
  Lines      113330   113532     +202     
  Branches   113330   113532     +202     
==========================================
+ Hits       100238   100320      +82     
- Misses      10621    10739     +118     
- Partials     2471     2473       +2     

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

@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from a379f1d to 9256a47 Compare December 14, 2024 12:40
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from 9256a47 to 5194458 Compare January 6, 2025 09:57
@optout21
Copy link
Contributor Author

optout21 commented Jan 6, 2025

Rebased.

@jkczyz jkczyz requested a review from wpaulino January 6, 2025 18:35
}

let mut funding_inputs_prev_outputs: Vec<&TxOut> = Vec::with_capacity(funding_inputs.len());
// Check that vouts exist for each TxIn in provided transactions.
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems better suited as a validation check when we construct the DualFundingChannelContext.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this also check the txid of the txin matches the transaction's?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I will check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check makes sense when we obtain the prev TxOut's from the full prev transactions.
I considered the case when in DualFundingChannelContext we would store only the TxOut's, and check and obtain at creation, but the full txs are needed later.
As a middle ground I extracted the logic of checking and extracting into a helper method in DualFundingChannelContext , that can be called when the TxOut's are needed.
Also CC @dunxen

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to do the same validation for the counterparty's provided inputs, I wonder if we already have code for that, or if we can use this new one there now?

lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
}

// Add output for funding tx
let mut funding_outputs = Vec::new();
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the spec allows you to specify additional outputs here as part of the interactive negotiation, which would be included here. I noticed we don't seem to track/request these from the user though, is this something we're not planning to support? cc @dunxen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's planned, but not in this PR.

lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/interactivetxs.rs Show resolved Hide resolved
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch 2 times, most recently from fce05cb to fbde31f Compare January 9, 2025 11:13
@optout21
Copy link
Contributor Author

optout21 commented Jan 9, 2025

Rebased (post Inbound/OutboundV2Channel merge #3498 )

@optout21 optout21 changed the title Dual funding extension needed also for splicing: begin_interactive_funding_tx_construction Dual funding extension, needed also for splicing: begin_interactive_funding_tx_construction Jan 9, 2025
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from 665be4e to c9aa52f Compare January 15, 2025 20:13
@optout21 optout21 force-pushed the splicing-dual-reqs2 branch from c9aa52f to c186145 Compare January 17, 2025 17:16
let remaining_value =
total_input_satoshis.saturating_sub(our_contribution).saturating_sub(fees_sats);

if remaining_value <= holder_dust_limit_satoshis {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check remaining_value < 0 so that we can bail and return an insufficient funds error to the user?

self.dual_funding_context.funding_feerate_sat_per_1000_weight,
self.context.holder_dust_limit_satoshis,
) {
let change_script = signer_provider.get_destination_script(self.context.channel_keys_id).map_err(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we allow the user to specify their own change address if they wish to

@optout21 optout21 added weekly goal Someone wants to land this this week and removed weekly goal Someone wants to land this this week labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants