lnd icon indicating copy to clipboard operation
lnd copied to clipboard

Set correct sweep transaction ID on 1st Stage Incoming HTLC resolutions

Open bjarnemagnussen opened this issue 3 years ago • 1 comments

Change Description

Currently the sweep transaction id shown as resolutions for 1st stage incoming HTLCs in force closed channel summaries is wrong. The reason is that due to the sweeper it is not possible upfront to know the transaction ID as the actual selected inputs are unknown and hence the report should be updated accordingly.

This PR uses the correct sweep transaction ID from the information provided by htlcResolution.ClaimOutpoint and when the second-level HTLC is swept makes sure that this value is "retrospectively" updated accordingly. Furthermore, for the reporting the outpoint being consumed is also set accordingly.

Note: A bit unrelated to this issue I also have added a commit that corrects the label produced for the sweep transaction that claims the incoming HTLC, as it was producing the closechannel label instead of the sweep label.

Steps to Test

This issue only arises on 1st stage incoming HTLC resolutions.

To reproduce the issue with two nodes, A and B:

  • Let A open a channel with B, e.g. A$ lncli openchannel <pubKeyB> 500000.
  • Let B create a hold-invoice, e.g. B$ lncli addholdinvoice 34affc1885f5a94b9d0b7c4c000d665d62a98ee3ccda1a5aa2207bdc3cf3b75e --amt 50000.
  • Let A pay the invoice, e.g. A$ lncli payinvoice <invoice>. This creates the inflight HTLC that can be verified with A$ lncli listchannels.
  • Now let B force close the channel, e.g. B$ lncli closechannel <txid> <txindex> --force.
  • Then also settle the invoice on B, e.g. B$ settleinvoice ed969942912154795f3d99d4928fad57a75a5a616c7f363527eca9c580c77d9f.
  • Now mine blocks accordingly as e.g. shown in the response of B$ lncli pendingchannels for B to create the resolutions.
  • After the channel has been completely closed the sweep transaction ID shown for B via B$ lncli closedchannels will be wrong for the 1st stage incoming HTLC resolution.

bjarnemagnussen avatar Jan 30 '22 10:01 bjarnemagnussen

@bjarnemagnussen, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar Sep 19 '22 18:09 lightninglabs-deploy

@bjarnemagnussen, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar Nov 14 '22 22:11 lightninglabs-deploy

@bjarnemagnussen, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar Jul 25 '23 11:07 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Jul 28 '23 13:07 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Jul 28 '23 14:07 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Jul 28 '23 15:07 lightninglabs-deploy