lnd icon indicating copy to clipboard operation
lnd copied to clipboard

[bug]: Funds stuck on Force Close Channel with negative blocks till maturity

Open Deivids1990 opened this issue 1 year ago • 8 comments

Background

For some reason my LND force closed two channels a few days ago. After waiting for block maturity the limbo balance doesn't show in my wallet and blocks till maturity shows a negative value. I'm looking for some guidance how to sweep the funds to my onchain wallet

Your environment

  • LND 0.18.0-beta commit=v0.18.0-beta
  • operating system: umbrel OS 1.2.2
  • Bitcoin Core 0.27 on the same machine, fully synced

Expected behaviour

Funds to appear in the wallet after maturity

Actual behaviour

Funds remain stuck, the UTXO doesn't show in my onchain wallet. Below is the output of lncli pendingchannels:

{ "total_limbo_balance": "1561852", "pending_open_channels": [], "pending_closing_channels": [], "pending_force_closing_channels": [ { "channel": { "remote_node_pub": "0373eab8f43b0710549ddccc19ac7824ab6aea7655f4c15f4bc93b63df5db8fa48", "channel_point": "9519c139773629a13c6ad66003963e0a948e0f47d533f8a9f3391c664002882c:1", "capacity": "1000000", "local_balance": "336035", "remote_balance": "462084", "local_chan_reserve_sat": "0", "remote_chan_reserve_sat": "0", "initiator": "INITIATOR_LOCAL", "commitment_type": "ANCHORS", "num_forwarding_packages": "0", "chan_status_flags": "", "private": false, "memo": "" }, "closing_txid": "11c50d04b7caf87c31fc0fa5ef5c5e42b2fdfbb91047415f205b6eec12186d70", "limbo_balance": "61852", "maturity_height": 0, "blocks_til_maturity": 0, "recovered_balance": "330", "pending_htlcs": [ { "incoming": false, "amount": "61852", "outpoint": "f115f57bd5c7dd76532619a4d0e907f8273e243f1794e2c403cf10d58c5aec36:0", "maturity_height": 857354, "blocks_til_maturity": -384, "stage": 2 } ], "anchor": "RECOVERED" }, { "channel": { "remote_node_pub": "026165850492521f4ac8abd9bd8088123446d126f648ca35e60f88177dc149ceb2", "channel_point": "7fd88e06d8163c6000abd90ca5b48a8e639971c331fa3de0cb05fbe5f601abd7:0", "capacity": "3000000", "local_balance": "1466490", "remote_balance": "30526", "local_chan_reserve_sat": "0", "remote_chan_reserve_sat": "0", "initiator": "INITIATOR_LOCAL", "commitment_type": "ANCHORS", "num_forwarding_packages": "0", "chan_status_flags": "", "private": false, "memo": "" }, "closing_txid": "94e3e491741ec3d9cbf7047cf2ca73ddb100b8176098b135881569066c310a34", "limbo_balance": "1500000", "maturity_height": 0, "blocks_til_maturity": 0, "recovered_balance": "0", "pending_htlcs": [ { "incoming": false, "amount": "1500000", "outpoint": "81d3676fded8000a3b5620593230394c5fc199af9a09980584b68db23fc8ebf1:0", "maturity_height": 857027, "blocks_til_maturity": -711, "stage": 1 } ], "anchor": "LOST" } ], "waiting_close_channels": []

Deivids1990 avatar Aug 21 '24 09:08 Deivids1990

The first channel should have been swept by you lightning node already:

See https://mempool.space/tx/11c50d04b7caf87c31fc0fa5ef5c5e42b2fdfbb91047415f205b6eec12186d70, and your htlc (61852sats) https://mempool.space/tx/c4e50921d3804e43ec20f3ca625ca05dbce181aa5ee3d1d2119059d43fe4a66a#vin=0

For the second channel(closing tx https://mempool.space/tx/94e3e491741ec3d9cbf7047cf2ca73ddb100b8176098b135881569066c310a34), your 1500000 sat output has not been swept yet, as the maturity height 857027 has just been reached, so it should be swept in the next hours.

sputn1ck avatar Aug 21 '24 09:08 sputn1ck

That's the issue, they have not been swept and the sats are missing in the wallet balance.

For the first TX, the 61852 sats are not there.

For the second, you mention the maturity height "has just been reached" but that was more than 700 blocks ago. Shouldn't it have been swept already?

Deivids1990 avatar Aug 21 '24 09:08 Deivids1990

This doc can be helpful if you want to accelerate the sweeping process.

Without logs it's hard to tell, but in general when the HTLC is in stage two, lnd will ease on the sweeping by using a lower feerate, and the blocks_til_maturity is no longer relevant here since it's already been spent via the second stage tx. For the second channel, it looks like there's no corresponding incoming HTLC there? If so then the sweeper will also try to sweep it slowly to save fees.

yyforyongyu avatar Aug 21 '24 09:08 yyforyongyu

Hi yong,

thanks a lot for that doc! It was useful. I have tried accelerating with with both transactions, without success:

I tried:

  1. lncli wallet bumpfee --conf_target=5 --budget=21000 f115f57bd5c7dd76532619a4d0e907f8273e243f1794e2c403cf10d58c5aec36:0 --immediate
  2. lncli wallet bumpfee --conf_target=5 --budget=21000 81d3676fded8000a3b5620593230394c5fc199af9a09980584b68db23fc8ebf1:0 --immediate

Output (in both cases): [lncli] rpc error: code = Unknown desc = the passed output does not belong to the wallet

What does that tell me about my issue?

Also please let me know how can I provide logs if that may help

Deivids1990 avatar Aug 21 '24 09:08 Deivids1990

Hi @Deivids1990,

use lncli wallet pendingsweeps to get the real output you need to bump and also more information about the current sweeping status.

Then use the outpoint mentioned there to bump the fee.

ziggie1984 avatar Aug 21 '24 11:08 ziggie1984

example:

lncli wallet pendingsweeps
{
	"pending_sweeps": [
		{
			"outpoint": "31f196c9e84da703d668d0f2fa440b368685e9208d27ef7359990b98cffabdbd:0",
			"witness_type": "COMMITMENT_ANCHOR",
			"amount_sat": 330,
			"sat_per_vbyte": 0,
			"broadcast_attempts": 0,
			"requested_sat_per_vbyte": 0,
			"immediate": false,
			"budget": 330,
			"deadline_height": 1195,
			"next_broadcast_height": 0,
			"requested_conf_target": 0,
			"force": false
		},
		{
			"outpoint": "b680bceabe59d44dc7147996885bfb2c6d530c22794c062edca971e368087e91:0",
			"witness_type": "COMMITMENT_ANCHOR",
			"amount_sat": 330,
			"sat_per_vbyte": 0,
			"broadcast_attempts": 0,
			"requested_sat_per_vbyte": 0,
			"immediate": false,
			"budget": 330,
			"deadline_height": 1195,
			"next_broadcast_height": 0,
			"requested_conf_target": 0,
			"force": false
		}
	]
}

there is a small inaccuracy in the outpoint listed under pendingchannels see the explanation here:

https://github.com/lightningnetwork/lnd/pull/8369

ziggie1984 avatar Aug 21 '24 11:08 ziggie1984

Thanks for the help. I did as you suggested and got the right outpoint to use. I was able to execute both commands and get the output "status": "Successfully registered rbf-tx with sweeper"

I soon after could see both TXs on the mempool and I have waited for them both to get confirmed. That happened few minutes ago. The result:

  1. The first with 61852 sats in limbo was swept correctly, and now I can see the sats in my wallet. (bump TX: https://mempool.space/tx/d4f16456610957414f66e63c6ff33970c1da9dd80924130ebdfd8a976a62ac7f)
  2. The second with 1,5M sats in limbo is still not appearing. (bump TX: https://mempool.space/tx/c064c4adc00d22fab28eed61d8363d59f4a5b0108517ea1dce91ccb7ae98c63b)

lncli wallet pendingsweeps now shows no sweeps at all anymore. lncli pendingchannels still shows that second channel as pending force close:

"total_limbo_balance": "1500000", "pending_open_channels": [], "pending_closing_channels": [], "pending_force_closing_channels": [ { "channel": { "remote_node_pub": "026165850492521f4ac8abd9bd8088123446d126f648ca35e60f88177dc149ceb2", "channel_point": "7fd88e06d8163c6000abd90ca5b48a8e639971c331fa3de0cb05fbe5f601abd7:0", "capacity": "3000000", "local_balance": "1466490", "remote_balance": "30526", "local_chan_reserve_sat": "0", "remote_chan_reserve_sat": "0", "initiator": "INITIATOR_LOCAL", "commitment_type": "ANCHORS", "num_forwarding_packages": "0", "chan_status_flags": "", "private": false, "memo": "" }, "closing_txid": "94e3e491741ec3d9cbf7047cf2ca73ddb100b8176098b135881569066c310a34", "limbo_balance": "1500000", "maturity_height": 0, "blocks_til_maturity": 0, "recovered_balance": "0", "pending_htlcs": [ { "incoming": false, "amount": "1500000", "outpoint": "81d3676fded8000a3b5620593230394c5fc199af9a09980584b68db23fc8ebf1:0", "maturity_height": 858111, "blocks_til_maturity": 358, "stage": 2 } ], "anchor": "LOST" } ], "waiting_close_channels": []

Any more insights what to try as next step to recover those 1,5M?

Deivids1990 avatar Aug 21 '24 11:08 Deivids1990

Any more insights what to try as next step to recover those 1,5M?

They are in stage 2 sweeping, which means you now need to wait for the sequence-number lock to expiry:

"blocks_til_maturity": 358,
"stage": 2

after 358 blocks you should see a new sweep registered in your pendingsweeps cmd.

ziggie1984 avatar Aug 21 '24 11:08 ziggie1984

Closing based on the above. If the funds haven't been swept yet, feel free to re-open.

Roasbeef avatar Oct 01 '24 00:10 Roasbeef