Skip to content
New issue

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

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

Already on GitHub? # to your account

[bug]: tries to spent already spent outputs from FCs - CommitmentToRemoteConfirmed in recovery mode #9471

Open
xmrk-btc opened this issue Feb 1, 2025 · 3 comments
Labels
bug Unintended code behaviour

Comments

@xmrk-btc
Copy link

xmrk-btc commented Feb 1, 2025

Background

My old crashed node is running in recovery mode, and repeatedly tries to spend already spent outputs. It constructs a transaction with multiple inputs, some of which are spent, so the transaction is invalid. This happens because I used chantools to close and sweep some channels, so I guess lnd doesn't expect channels to be closed by external tool.

I think lnd should be more permissive especially in recovery mode. The fix seems almost trivial, just check whether the output is spent, or perhaps if you are worried about performance, check inputs only if the transaction is rejected. I'd also like to see which channels haven't been fully resolved (as output of lncli pendingchannels), taking into account such external actions as closing with chantools. Currently, I think pendingchannels returns all channels which were open at the moment of crash (I am not sure, I only checked the channel count and it is too high.)

Few examples of spent outputs which lnd tries to spend again:
bc37f08100db7a6cb40c1d0c0f3aab7becc93d5c2eb64adf41a9b11a56fc7542:3 CommitmentToRemoteConfirmed
d2d95e807b9065098b444f16329540b34bf599e132ffc956250c1dfb74ae30ae:1 CommitmentNoDelayTweakless
43a284419986060bdd71d88753cf2e5c39acf377df466fbd591b789797610e38:0 CommitmentAnchor

Your environment

  • version of lnd: 0.18.4 (but also happened with 0.17.something)
  • bitcoind: 0.28
@xmrk-btc xmrk-btc added bug Unintended code behaviour needs triage labels Feb 1, 2025
@xmrk-btc
Copy link
Author

xmrk-btc commented Feb 2, 2025

This is basically point 6 of #8680 (comment). So I guess I have to wait until version 0.19.0.

@GeorgeTsagk
Copy link
Collaborator

Hi @xmrk-btc , thanks for opening this issue

If I understand correctly, there's no funds at risk as you recovered manually. The issue is only about LND trying to spend something that it can't. Correct?

@xmrk-btc
Copy link
Author

Well, probably no funds at risk. I think I have recovered all recoverable funds, but the problem is I am not sure. And I hoped lnd would manage all that.

I first started with chantools sweepremoteclosed , then it had problem sweeping funds (I think it was timelock which had not expired yet, so different from this lnd issue). So I switched to lnd, and ran into this issue.
After your comment, I tried chantools sweepremoteclosed again, and successfully recovered some funds, and it says it cannot recover more.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Unintended code behaviour
Projects
None yet
Development

No branches or pull requests

2 participants