Uh oh!
There was an error while loading. Please reload this page.
Add Shared Input support in interactive TX construction - #3842
Conversation
👋 Thanks for assigning @wpaulino as a reviewer! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ldk-reviews-bot
commented
Jun 14, 2025
1 similar comment
ldk-reviews-bot
commented
Jun 14, 2025
ldk-reviews-bot
commented
Jun 16, 2025
1 similar comment
ldk-reviews-bot
commented
Jun 16, 2025
optout21
commented
Jun 16, 2025
I managed to do it: first I refactored the shared output support as discussed, then added shared input support in a similar style. Although this PR does not include spicing, I also checked the changes with splicing (shared input is used there). |
166e364 to
b2e0da8CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
optout21
commented
Jun 17, 2025
@wpaulino thanks for the comments. I will process them (I've re-requested review accidentally, please ignore that). |
ldk-reviews-bot
commented
Jun 18, 2025
1 similar comment
ldk-reviews-bot
commented
Jun 18, 2025
ldk-reviews-bot
commented
Jun 19, 2025
Uh oh!
There was an error while loading. Please reload this page.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #3842 +/- ##
==========================================
+ Coverage 89.72% 90.10% +0.38%
==========================================
Files 164 165 +1 Lines 133359 132400 -959 Branches 133359 132400 -959 ==========================================
- Hits 119651 119296 -355 + Misses 11037 10728 -309 + Partials 2671 2376 -295 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Review comments addressed, some minor (doc) changes applied. |
ldk-reviews-bot
commented
Jul 5, 2025
ldk-reviews-bot
commented
Jul 5, 2025
ldk-reviews-bot
commented
Jul 7, 2025
ldk-reviews-bot
commented
Jul 7, 2025
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| if is_initiator { | ||
| our_funding_inputs_weight = | ||
| our_funding_inputs_weight.saturating_add(estimate_input_weight(output).to_wu()); | ||
| } else { | ||
| return Err(AbortReason::PrevTxOutInvalid); | ||
| our_funding_inputs_weight.saturating_add(P2WSH_INPUT_WEIGHT_LOWER_BOUND); |
There was a problem hiding this comment.
As a reader of the method though, it seems clearer to keep all the additional weight tracking when we're the initiator in one place.
Uh oh!
There was an error while loading. Please reload this page.
commented
Jul 9, 2025
🔔 12th Reminder Hey @dunxen! This PR has been waiting for your review. |
left a comment
There was a problem hiding this comment.
Taking this PR on since @optout21 is unavailable for a week.
Uh oh!
There was an error while loading. Please reload this page.
| if is_initiator { | ||
| our_funding_inputs_weight = | ||
| our_funding_inputs_weight.saturating_add(estimate_input_weight(output).to_wu()); | ||
| } else { | ||
| return Err(AbortReason::PrevTxOutInvalid); | ||
| our_funding_inputs_weight.saturating_add(P2WSH_INPUT_WEIGHT_LOWER_BOUND); |
There was a problem hiding this comment.
I ended up moving this since doing so is more consistent with how the shared output is included in the weight. That is, shared output weight is not included in our_funding_outputs_weight, so including the shared input in our_funding_inputs_weight is not consistent.
Uh oh!
There was an error while loading. Please reload this page.
| script_pubkey: funding.get_funding_redeemscript().to_p2wsh(), | ||
| }; | ||
| let interactive_tx_constructor = Some(InteractiveTxConstructor::new( |
There was a problem hiding this comment.
Pre-existing, but it looks like we shouldn't be initializing a constructor now, and should be relying on begin_interactive_funding_tx_construction to do it instead. Let's leave it for a follow-up.
Uh oh!
There was an error while loading. Please reload this page.
This simplifies tracking separately the expected and actual shared output. In the initiator case, we can just provide the shared output separately, instead of including it within other outputs, and marking which one is the output. We can use the same field for the intended shared output in the initiator case, and the expected one in the acceptor case.
In interactivetxs, add support for shared inputs, similar to shared outputs. A shared input is optional, and is used in case of splicing to add the current funding as an input.
Uh oh!
There was an error while loading. Please reload this page.
commented
Jul 12, 2025
commented
Jul 14, 2025
commented
Jul 14, 2025
Instead of calculating the fee for the entire weight contributed by the counterparty, each portion of the weight was calculated individually before summed. That caused a rounding error that is avoided by summing the weights first.
Uh oh!
There was an error while loading. Please reload this page.
commented
Jul 15, 2025
Merging with one approval since @jkczyz took over and his is implicit. |
In interactive TX construction, add support for shared input:
Additionally, the
prevtxfield of theTxAddInputmessage is changed to Optional, as it should not be set for the shared input (it cannot, as the full funding transaction is not stored on the acceptor side) (spec discussion: lightning/bolts#1160 (comment))To be used by splicing, see #3736 .
Note: this PR does not include splicing negotiation.