Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: .crypto on January 24, 2021, 07:51:53 AM



Title: Closing a Lightning-Channel – Question
Post by: .crypto on January 24, 2021, 07:51:53 AM
There is something, I don‘t fully understand about closing a lightning-channel and I would like to ask you guys, for some help/clarification.

Lets assume the following situation: I open up a Lightning-Channel and load it with some Satoshi. After a while, I want to close that channel. Closing a LN channel requires an on-chain-transaction. Lets assume, exactly at that moment, there is a chain split. Two miners find a block at the same time. One miner adds my transaction to his block, the other doesn't. At this moment, I will see 1 confirmation of this transaction in my wallet, right? Lets assume, the other miner „wins“ at the end and the blockchain will be reorganized. This means, my transaction will go back to the mempool, right? So in my wallet, I will see this transaction as „unconfirmed“, I guess. Normally, my transaction will be included in one of the next blocks. But lets assume the TX fee was too low. I guess, then the TX will stay for a  certain time in the mempool but after some weeks will be wiped out. Does that mean the settlement transaction will be undone and the coins re-appear in my lightning channel? Can I always do a RBF (replace by fee) in this case?


Title: Re: Closing a Lightning-Channel – Question
Post by: vjudeu on January 25, 2021, 07:33:51 AM
Quote
At this moment, I will see 1 confirmation of this transaction in my wallet, right?
It depends which chain you will see. If both, it depends on your wallet, but I suppose it is better to show less confirmations than more if there are possible chain reorganizations.

Quote
This means, my transaction will go back to the mempool, right?
Yes, in the same way as all other transactions from that block that were missing in the winning block, except coinbase of course.

Quote
So in my wallet, I will see this transaction as „unconfirmed“, I guess.
Yes.

Quote
Does that mean the settlement transaction will be undone and the coins re-appear in my lightning channel?
Yes, Lightning Network transactions behave exactly the same as any other on-chain transactions.

Quote
Can I always do a RBF (replace by fee) in this case?
It depends if that transaction was marked as RBF before. If so, then you can safely include more inputs and do RBF transaction by keeping previous inputs and outputs intact and adding new inputs and outputs to increase transaction fee. If no node remember previous transaction, the situation is the same as it would never be broadcasted, but it is difficult to be sure that every single node discarded it, so to be safe you should assume that some nodes still have it. You can also rebroadcast exactly the same transaction, especially if mempool is less congested than before.


Title: Re: Closing a Lightning-Channel – Question
Post by: .crypto on January 25, 2021, 09:01:52 AM
Thank you for your reply.

I think that I got it now, just one small remark to my initial post: In my post I wrote that the transaction will go back to the mempool after the chain that included my TX "lost".

I think this is not 100% correct, because for the "winning chain" it never left the mempool.

So in worst case for me it will look like it was send back to the mempool and in worst case "1 confirmation" will change to "unconfirmed" but in reality nothing changed, it was just not included into the next block.

I think I got it now  :)