lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.67k stars 2.07k forks source link

Commitment transaction fee calcualtion #1110

Closed offerm closed 6 years ago

offerm commented 6 years ago

Background

Unclear Commitment transaction data.

I opened a 100,000 sat channel with a peer. (https://testnet.blockchain.info/tx-index/195790884/0) After confirmations I see:

offerm@OffersLinux:~$ lncli listchannels { "channels": [ { "active": true, "remote_pubkey": "026d2f05b3d01269def3941f79005d62c0ba124d93aa6b81fc200329188a59a49e", "channel_point": "dbf30ae0ab683f9aac8433f35f8fea01e02a9bd83e3071f33995f167b6228d93:0", "chan_id": "1422097344253132800", "capacity": "100000", "local_balance": "95475", "remote_balance": "0", "commit_fee": "4525", "commit_weight": "600", "fee_per_kw": "6250", "unsettled_balance": "0", "total_satoshis_sent": "0", "total_satoshis_received": "0", "num_updates": "0", "pending_htlcs": [ ], "csv_delay": 144, "private": false } ] }

Then I closed the channel https://testnet.blockchain.info/tx-index/195791859

The fee was just 739 sat and I got back 99261 sat. Weight is 549.

This is not in line with the listchannels information.

Impact of this is that I can't maximize the usage of the funds in the channel.

Your environment

lnd version 0.4.1-beta commit=c5dd53f9ddee2b718bd325f605e18d128bbe8c79 Darwin admins-MacBook-Pro-2.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64 btcd version 0.12.0-beta

Steps to reproduce

Open and close a channel on testnet

Expected behaviour

listchannels information should be correct.

Actual behaviour

Paid smaller (order of magnitude) fee and got back more sat.

vegardengen commented 6 years ago

The negotiated commitment fee in listchannels is the fee for a force-close of a channel. On a cooperative close, there is fee negotiation at the time of the closure.

Roasbeef commented 6 years ago

@vegardengen is correct.

Roasbeef commented 6 years ago

Note that it's also possible to set the target fee for a co-op closing transaction on the command line (see lncli closechannel -h). Both sides offer an initial fee when closing, and then negotiate a final fee to agree on.

AndySchroder commented 6 months ago

Who pays the fee if the cooperative close negotiated fee is higher than the commit_fee?