[bug]: Ghost UTXO (unconfirmed balance) after unsuccessful attempts to publish a sweep tx or due to collected anchors #7420
Replies: 2 comments 4 replies
-
Hi, I have a similar issue. In this case, I've got many unconfirmed UTXO's possibly all linked to the same problem you describe here. The problem seems to start with the force-closed of a channel i opened usinb balance of satoshis. Apparently the force-closed tx (locally closed, possibly due to expired HTLC’s) does not appear in my list of transactions, but I can track it down as I have the opening tx. if I track it down in the mempool, this force-closed tx does not appear as force-close in the description, but as multisig 2 of 2. That is weird. And is also weird that it does not appear in my list of tx’s. Did you have the same issue, that the force-close tx did not appear in your tx list? Now, the first tx with 0 confirmations in my list is apparently a doubled tx from the I guess is one of the anchors from that force-closed. And from here onwards, I seem to be having a lot of unconfirmed tx's with 136 and 147 sats and subsequently a lot of ghost UTXO's. If i want to resolve the issue, do you think i should just publish the hex of the force-closed tx that does not appear in my list of tx's? lncli wallet publishtx |
Beta Was this translation helpful? Give feedback.
-
same problem here. i have posted here. |
Beta Was this translation helpful? Give feedback.
-
There are two types of ghost UTXO:
The following section deals with case no. 2 and provides an easy solution to resolve the ghost UTXO problem.
TL;DR:
Rebroadcast the raw tx of the channel force close which led to the ghost UTXO. Enter
lncli wallet publishtx <hex_tx of FC>
to manually update lnd's utxo list.Either use https://mempool.space entering the FC transaction hash to find the hex_tx (click on the red circle to reveal your hex_tx like in the picture) or you use the command
lncli listchaintxns | grep -a37 "<tx_hash of FC>"
to search for the raw_tx_hex if you know the tx_hash of your FC.If you don't know your transaction id, then use https://amboss.space to find the correct FC transaction hash (enter your node's pubkey, click on the
Closed Channels
section, search for the interesting FC, click onChannel ID
, there you click on the hash termedClosing Transaction
). Clicking on this hash links you to mempool.space where you find your hex_tx (red circle).03/10/2023
Once again, I have encountered a third failed sweep transaction in a row - now without collected anchor - leading to the creation of a ghost UTXO. You can find the FC transaction here: https://mempool.space/tx/fdbe4fe8bc7a7d710e85b8ce89255f84082e044a97fad1865acc727d820d3280
Node using: lnd v.0.16.0.rc1 and bitcoind 24.0.1
After examining lnd.log, I discovered what is causing the ghost UTXO. When an attempt to sweep an anchor of a force-closed channel is unsuccessful, a ghost UTXO may develop that cannot be published in the mempool due to high fees or being purged because of a full mempool. In general, LND transfers the FC anchor to the node's wallet by binding it to an unspent UTXO, which waits to be confirmed to a new UTXO. However, if confirmation fails after 10 attempts to publish to the mempool, LND drops the anchor, but the sweep transaction created by LND remains as a ghost UTXO for unknown reasons. Although the LND log may suggest otherwise, the lncli unspent command still shows the UTXO as unconfirmed. Is this related to a taproot problem?
The solution to remove the ghost UTXO is to manually publish the original hex transaction of the force close with
lncli wallet publishtx <hex tx of FC>
which returns a transaction ID and resolves the issue. The anchor is correctly accounted as a confirmed unspent UTXO without anchor sats (147 sats) to the node's wallet.Here are three suggestions:
Lnd.log using grep "SWPR"
Ghost utxo has been resolved by using the original transaction hex code of the force closed channel:
03/04/2023: Now using lnd 0.16.0.rc1
Another FC, another sweep. Again the anchor is collected by someone else. Lnd does not realize that the utxo is already accounted to the own wallet.
https://mempool.space/tx/ae9f2e338ee337df795d8ca1956bfd84589a2cf8c4201c7b9dfe27ab1d8bd75b
What I did to solve the problem:
I went a transaction before:
https://mempool.space/tx/d858c7a8dfca0659e626dce3cfd73afafdb7911b065086951450f36c68d2f63a
Took the transaction hex
https://mempool.space/api/tx/d858c7a8dfca0659e626dce3cfd73afafdb7911b065086951450f36c68d2f63a/hex
and broadcasted it with
lncli wallet publishtx <transaction hex>
Problem solved. LND realized now that the utxo is part of the node's wallet and now the missing / ghost UTXO is confirmed.
I would ask the developers of lnd to fix this behaviour that if the anchor of a FC is collected by someone else, that lnd nevertheless performs an update of the apparently unconfirmed utxo.
02/24/2023:
I think with the update of lnd 0.16.0.rc1 the bug of not detecting an already spent UTXO created with an external tool has been fixed:#7243
Using lnd version 0.15.5-beta and bitcoind 24.0.1
TL;DR
After a forced close channel lnd showed me an unconfirmed balance which allegedly did not enter the mempool. The channel was created with bos open-group.
The unconfirmed balance came from a remaiming sweep of expired htlcs of the FC.
The anchor of this sweep was lost respectively collected by someone else due to a RBF maneuver with changing the owner of the lightning anchor. With the missing anchor lnd did not realize that the remaining utxo was already spent and reported erroneously this over 4 days as unconfirmed balance until I broadcasted manually the transaction hash of the remaining transaction. Lnd then realized that the utxo was already spent and updated the onchain balance correctly.
Resolution of this problem:
lnd should check if the lightning anchor still belongs to the node, check if the utxo was already spent and correct the wrongly reported unconfirmed balance without manual intervention.
============= Here the report and according logs ==============
113966 sats not confirmed.
Likely related to #6241 and #7104
I think the last issue #7104 helped me to understand what is the problem of lost anchors ...
The persistent display of an unconfirmed balance began when a force closed of a channel was initiated due to expired htlcs:
https://mempool.space/tx/1ed22f68f4ec7badbc790f52cf2883cf092c1f9d4dddf90327636f68a1b61aba
As you can see the force close resulted in 4 outputs: The amount 0,03218734 BTC minus fee went to me. The amount of 0,0007662 BTC went to the other peer, and then two lightning anchors remained, one going to the other peer, and the other one which should normally go to my node, was snatched away by a anchor fee collector script.
https://mempool.space/address/bc1qps4jrqrxf6n34yeqmulp2w9dvp5xa0w0gaqpn7ew5vkw9r8ene2slpakxr
As you can see in the above command there are two previous outpoints:
1ed22f68f4ec7badbc790f52cf2883cf092c1f9d4dddf90327636f68a1b61aba:0 (is_our_output: false)
b82a0f2b1697177e345e6930ecd498207bd9baa505880bb73ca9909ca747ea2e:0 (is_our_output: true)
This is the lnd.log output of how the sweep 2c8e74cb1e4d76d260b1abb25464b6a56416683718bc74fc790578c555c4fd1c is generated out of the two outpoints and should enter the mempool:
However the commitment anchor of 1ed22f68f4ec7badbc790f52cf2883cf092c1f9d4dddf90327636f68a1b61aba:0 seems not belong to my node any more - as it was snatched away - and the transaction 2c8e74cb1e4d76d260b1abb25464b6a56416683718bc74fc790578c555c4fd1c did not enter the mempool.
https://mempool.space/tx/2c8e74cb1e4d76d260b1abb25464b6a56416683718bc74fc790578c555c4fd1c
The expired htlcs remained as unconfirmed balance and unspent utxo on my node until I decided to rebroadcast the hex encoded raw transaction because it has never entered the mempool.
As next step I entered following command:
However lncli says that it was already spent. So I used bitcoin-cli alternatively:
Same error, already spent.
Checking for pendingsweeps revealed this:
Wow, the unconfirmed balance is not found any more! But instead lnd found this new=old previously mentioned transaction b82a0f2b1697177e345e6930ecd498207bd9baa505880bb73ca9909ca747ea2e which is now listed and correctly assigned to my wallet as confirmed balance. Originally 113966 sats unconfirmed - fee of 147 sats = 113819 confirmed sats
Beta Was this translation helpful? Give feedback.
All reactions