<p>You basically answered the question already yourself. Besides the 1% channel reserve you as the funder are responsible for paying onchain fees in case you need to force close the channel by spending the commitment transaction. </p>

<p>C Lightning (and lightning nodes in general) are rather overestimating onchain fees as they cannot rely on the fact that the fees that where taken when the commitment transaction was signed will work in the future if force closing of the channel takes place. </p>

<p>Look for example at <a href="https://www.smartbit.com.au/tx/e32135315ec147bb27f771b2e15c7178ea573afd16cd4970bf814c9b18bc46e3" rel="noreferrer">this transaction</a> in which my c Lightning node had a channel to test the lightning app (running lnd) and a cross implementation bug produced a forced channel close. You can see that I paid about 100 satoshis per byte in fees resulting in 18312 satoshis. This is the same ballpark number as the value which you describe here. (looking at the mempool this number sounds realistically to me) </p>

<p>Things you can do</p>

<ol>
<li>Don't force close channels (fees will be much smaller with mutual closes, since the fee is more accurate and only one tx is needed) </li>
<li>Have bigger channels then the relative fee is not so high</li>
<li>Look at the code where fees are set. Propose better strategies in the c Lightning issue tracker or provide an api to set / read them. (as far as I remember there is currently no api for that) </li>
<li>You cannot even do too much as the fees being used are negotiated between you and your channel partner. If the channel partner starts out with a really high fee there is hardly anything you can do to defend against this. </li>
</ol>

<p>Btw welcome to the rabbit hole of onchain fees with lightning. Doing this for a while now I realized it is one of the most subtle and present challenges that we are facing. </p>

CC BY-SA 4.0
2019-07-20T11:27:54.850Z
Thanks for the informative and comprehensive answer! From reading those Lightning 101 tutorials, I falsely assumed on-chain fee was something negligible as long as the channel is open. The force-close txfee is really a trap for our young players ;-) I will try to always remember that each outgoing channel has a nonspendable txfee on my side and avoid creating too-small channels in the future...
比尔盖子
CC BY-SA 4.0
2019-07-19T06:46:01.963Z
2019-07-19T06:46:01.963Z
Rene Pickhardt
<p>Today I was attempting to send a Lightning Network payment via c-lightning, version <code>v0.7.1-64-gbb30104</code>, using a channel I established in 2018. Strangely, my payment kept failing even if the destination was routable. Finally, I noticed the reason was a relatively large disparity between  <code>spendable_msat</code> and <code>msatoshi_to_us</code>.</p>

<pre><code>"msatoshi_to_us" : 49947931,
"to_us_msat" : "49947930msat",
"msatoshi_to_us_min" : 49947930,
"min_to_us_msat" : "49947930msat",
"msatoshi_to_us_max" : 50000000,
"max_to_us_msat" : "50000000msat",
"msatoshi_total" : 50000000,
"total_msat" : "50000000msat",
"dust_limit_satoshis" : 546,
"dust_limit_msat" : "546000msat",
"max_htlc_value_in_flight_msat" : 18446744073709551615,
"max_total_htlc_in_msat" : "18446744073709551615msat",
"their_channel_reserve_satoshis" : 546,
"their_reserve_msat" : "546000msat",
"our_channel_reserve_satoshis" : 546,
"our_reserve_msat" : "546000msat",
"spendable_msatoshi" : 35617930,
"spendable_msat" : "35617930msat",
"htlc_minimum_msat" : 0,
"minimum_htlc_in_msat" : "0msat",
"their_to_self_delay" : 144,
"our_to_self_delay" : 144,
"max_accepted_htlcs" : 483,
"status" : [
  "CHANNELD_NORMAL:Reconnected, and reestablished.",
  "CHANNELD_NORMAL:Funding transaction locked. Channel announced."
],
</code></pre>

<p>As you see, my "spendable_msatoshi" is much lower than "msatoshi_to_us", a difference of 14373070 msatoshis. Even considering "their_reserve_msat" and "our_reserve_msat", it can only explain an amount of 1092000 msatoshis, or ~7% of the unspendable fund, where does the rest go?</p>

<p>Why does this even occur? And what should I do to fix it?</p>

<p>I tried reading the <a href="https://github.com/ElementsProject/lightning/blob/54ce4ed1cf4007ac8754c5bb640c4afdbdbc3934/lightningd/peer_control.c#L683" rel="nofollow noreferrer">source code of c-lightning</a>, and clearly HTLC and transaction fee is also deduced from "spendable_msat", however, those values are invisible in <code>lightning-cli listpeers</code> and I still cannot determine the reason.</p>

<pre><code>/* Compute how much we can send via this channel. */
if (!amount_msat_sub_sat(&amp;spendable,
             channel-&gt;our_msat,
             channel-&gt;channel_info.their_config.channel_reserve))
    spendable = AMOUNT_MSAT(0);

/* Take away any currently-offered HTLCs. */
subtract_offered_htlcs(channel, &amp;spendable);

/* If we're funder, subtract txfees we'll need to spend this */
if (channel-&gt;funder == LOCAL) {
    if (!amount_msat_sub_sat(&amp;spendable, spendable,
                 commit_txfee(channel, spendable)))
        spendable = AMOUNT_MSAT(0);
}

/* We can't offer an HTLC less than the other side will accept. */
if (amount_msat_less(spendable,
             channel-&gt;channel_info.their_config.htlc_minimum))
    spendable = AMOUNT_MSAT(0);

/* We can't offer an HTLC over the max payment threshold either. */
if (amount_msat_greater(spendable, get_chainparams(ld)-&gt;max_payment))
    spendable = get_chainparams(ld)-&gt;max_payment;

json_add_amount_msat_compat(response, spendable,
                "spendable_msatoshi", "spendable_msat");
json_add_amount_msat_compat(response,
                channel-&gt;our_config.htlc_minimum,
                "htlc_minimum_msat",
                "minimum_htlc_in_msat");
</code></pre>

<lightning-network><core-lightning>
Why is my "spendable_msat" much lower than "msatoshi_to_us"?
比尔盖子
# Why is my "spendable_msat" much lower than "msatoshi_to_us"?

(Asked by: username_0 on 2019-07-19)

Today I was attempting to send a Lightning Network payment via c-lightning, version `v0.7.1-64-gbb30104`, using a channel I established in 2018. Strangely, my payment kept failing even if the destination was routable. Finally, I noticed the reason was a relatively large disparity between `spendable_msat` and `msatoshi_to_us`.

```
"msatoshi_to_us" : 49947931,
"to_us_msat" : "49947930msat",
"msatoshi_to_us_min" : 49947930,
"min_to_us_msat" : "49947930msat",
"msatoshi_to_us_max" : 50000000,
"max_to_us_msat" : "50000000msat",
"msatoshi_total" : 50000000,
"total_msat" : "50000000msat",
"dust_limit_satoshis" : 546,
"dust_limit_msat" : "546000msat",
"max_htlc_value_in_flight_msat" : 18446744073709551615,
"max_total_htlc_in_msat" : "18446744073709551615msat",
"their_channel_reserve_satoshis" : 546,
"their_reserve_msat" : "546000msat",
"our_channel_reserve_satoshis" : 546,
"our_reserve_msat" : "546000msat",
"spendable_msatoshi" : 35617930,
"spendable_msat" : "35617930msat",
"htlc_minimum_msat" : 0,
"minimum_htlc_in_msat" : "0msat",
"their_to_self_delay" : 144,
"our_to_self_delay" : 144,
"max_accepted_htlcs" : 483,
"status" : [
  "CHANNELD_NORMAL:Reconnected, and reestablished.",
  "CHANNELD_NORMAL:Funding transaction locked. Channel announced."
],

```

As you see, my "spendable\_msatoshi" is much lower than "msatoshi\_to\_us", a difference of 14373070 msatoshis. Even considering "their\_reserve\_msat" and "our\_reserve\_msat", it can only explain an amount of 1092000 msatoshis, or ~7% of the unspendable fund, where does the rest go?

Why does this even occur? And what should I do to fix it?

I tried reading the [source code of c-lightning](https://github.com/ElementsProject/lightning/blob/54ce4ed1cf4007ac8754c5bb640c4afdbdbc3934/lightningd/peer_control.c#L683), and clearly HTLC and transaction fee is also deduced from "spendable\_msat", however, those values are invisible in `lightning-cli listpeers` and I still cannot determine the reason.

```
/* Compute how much we can send via this channel. */
if (!amount_msat_sub_sat(&spendable,
             channel->our_msat,
             channel->channel_info.their_config.channel_reserve))
    spendable = AMOUNT_MSAT(0);

/* Take away any currently-offered HTLCs. */
subtract_offered_htlcs(channel, &spendable);

/* If we're funder, subtract txfees we'll need to spend this */
if (channel->funder == LOCAL) {
    if (!amount_msat_sub_sat(&spendable, spendable,
                 commit_txfee(channel, spendable)))
        spendable = AMOUNT_MSAT(0);
}

/* We can't offer an HTLC less than the other side will accept. */
if (amount_msat_less(spendable,
             channel->channel_info.their_config.htlc_minimum))
    spendable = AMOUNT_MSAT(0);

/* We can't offer an HTLC over the max payment threshold either. */
if (amount_msat_greater(spendable, get_chainparams(ld)->max_payment))
    spendable = get_chainparams(ld)->max_payment;

json_add_amount_msat_compat(response, spendable,
                "spendable_msatoshi", "spendable_msat");
json_add_amount_msat_compat(response,
                channel->our_config.htlc_minimum,
                "htlc_minimum_msat",
                "minimum_htlc_in_msat");

```

**Tags:** lightning-network, core-lightning


---

## 1 answers

### Answer by username_1 on 2019-07-19. Score: 8 | Accepted answer

You basically answered the question already yourself. Besides the 1% channel reserve you as the funder are responsible for paying onchain fees in case you need to force close the channel by spending the commitment transaction.

C Lightning (and lightning nodes in general) are rather overestimating onchain fees as they cannot rely on the fact that the fees that where taken when the commitment transaction was signed will work in the future if force closing of the channel takes place.

Look for example at [this transaction](https://www.smartbit.com.au/tx/e32135315ec147bb27f771b2e15c7178ea573afd16cd4970bf814c9b18bc46e3) in which my c Lightning node had a channel to test the lightning app (running lnd) and a cross implementation bug produced a forced channel close. You can see that I paid about 100 satoshis per byte in fees resulting in 18312 satoshis. This is the same ballpark number as the value which you describe here. (looking at the mempool this number sounds realistically to me)

Things you can do

1. Don't force close channels (fees will be much smaller with mutual closes, since the fee is more accurate and only one tx is needed)
2. Have bigger channels then the relative fee is not so high
3. Look at the code where fees are set. Propose better strategies in the c Lightning issue tracker or provide an api to set / read them. (as far as I remember there is currently no api for that)
4. You cannot even do too much as the fees being used are negotiated between you and your channel partner. If the channel partner starts out with a really high fee there is hardly anything you can do to defend against this.

Btw welcome to the rabbit hole of onchain fees with lightning. Doing this for a while now I realized it is one of the most subtle and present challenges that we are facing.

> **Comments:**
> **username_0**: Thanks for the informative and comprehensive answer! From reading those Lightning 101 tutorials, I falsely assumed on-chain fee was something negligible as long as the channel is open. The force-close txfee is really a trap for our young players ;-) I will try to always remember that each outgoing channel has a nonspendable txfee on my side and avoid creating too-small channels in the future...  

---

