<p>You opened a 1 million Satoshi channel and send 500 sats to the other side. The protocol requires a 1%channel reserve kept on both sides for the penalty mechanism to always have enough collateral. This one percent is ignored initially if you never had that much balance (e. G. On new channels) but is the reason why you can't send sats unless you met the 1% threshold.</p>
<p>Send another 9501 sats (9501000msats) and you should see that you can spend 1 satoshi</p>

CC BY-SA 4.0
2021-06-16T14:21:07.560Z
I mixed up sats and msats. I meant to balance the channel 50/50, but `openchannel` uses sats and `pay` uses msats.
gijswijs
CC BY-SA 4.0
2021-06-16T08:34:03.497Z
2021-06-16T08:34:03.497Z
Rene Pickhardt
<p>The python test script below (using the pyln-testing library) opens a channel between <code>l1</code> and <code>l2</code>, and then the funder (<code>l1</code>) pays half of the channel's capacity to <code>l2</code>.
After this payment 'l2' wants to make a smaller payment to <code>l1</code>, but this payment fails for reasons I will explain below the script.</p>
<h2>Test script</h2>
<pre><code>from pyln.testing.fixtures import *  # noqa: F401, F403
from pyln.testing.utils import wait_for, DEVELOPER
import unittest

@unittest.skipIf(not DEVELOPER, &quot;gossip is too slow if we're not in developer mode&quot;)
def test_two_way_payment(node_factory):
    &quot;&quot;&quot;Send a payment to and fro
    l1 ---- l2
    &quot;&quot;&quot;
    opts = [{},{}]
    l1, l2 = node_factory.get_nodes(2, opts=opts)
    
    capacity=10**6

    l1.openchannel(l2, capacity=capacity)
    
    # Now wait for gossip to settle and l1 to learn the topology
    wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 2)

     # Get all channels balanced (by paying money to the other node)
    l1.pay(l2, capacity // 2)
    l1.wait_for_htlcs()

    print(&quot;LISTPEERS L2: {}\n&quot;.format(l2.rpc.listpeers()))

    l2.pay(l1, capacity // 20)
    l2.wait_for_htlcs()
</code></pre>
<p>The script above fails with the error below</p>
<h2>Error</h2>
<pre><code>Fail: pyln.client.lightning.RpcError: RPC call failed: method: waitsendpay, payload: {'payment_hash': '6d1281627828720bd86cb2815f222a8c0106545d7d4f972e5ec5324133163224'}, error: {'code': 204, 'message': 'failed: WIRE_TEMPORARY_CHANNEL_FAILURE (WIRE_TEMPORARY_CHANNEL_FAILURE: Capacity exceeded - HTLC fee: 7964sat)', 'data': {'id': 1, 'payment_hash': '6d1281627828720bd86cb2815f222a8c0106545d7d4f972e5ec5324133163224', 'destination': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'msatoshi': 50000, 'amount_msat': 50000msat, 'msatoshi_sent': 50000, 'amount_sent_msat': 50000msat, 'created_at': 1623829593, 'status': 'failed', 'erring_index': 0, 'failcode': 4103, 'failcodename': 'WIRE_TEMPORARY_CHANNEL_FAILURE', 'erring_node': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'erring_channel': '1x1x1', 'erring_direction': 0}}
</code></pre>
<h2>Listpeers</h2>
<p>If I lift some information out of the <code>listpeers</code> rpc call for <code>l2</code> I can understand why the payment wouldn't work:</p>
<pre><code>'msatoshi_to_us': 500000
[...]
'spendable_msatoshi': 0
</code></pre>
<p>What I don't understand is <em>why</em> 'spendable_msatoshi' would be zero. It can't be because of the channel reserve. I don't think it can be because of enormously overestimating the on-chain fees (in case of a forced close) because the l2 isn't the funder.</p>
<p>What am I missing/not understanding here?</p>

<core-lightning><unit-test>
pyln.testing channel's spendable_msatoshi remains 0 in the direction towards the funder, regardless of balance
gijswijs
# pyln.testing channel's spendable_msatoshi remains 0 in the direction towards the funder, regardless of balance

(Asked by: username_0 on 2021-06-16)

The python test script below (using the pyln-testing library) opens a channel between `l1` and `l2`, and then the funder (`l1`) pays half of the channel's capacity to `l2`.
After this payment 'l2' wants to make a smaller payment to `l1`, but this payment fails for reasons I will explain below the script.

## Test script

```
from pyln.testing.fixtures import *  # noqa: F401, F403
from pyln.testing.utils import wait_for, DEVELOPER
import unittest

@unittest.skipIf(not DEVELOPER, "gossip is too slow if we're not in developer mode")
def test_two_way_payment(node_factory):
    """Send a payment to and fro
    l1 ---- l2
    """
    opts = [{},{}]
    l1, l2 = node_factory.get_nodes(2, opts=opts)
    
    capacity=10**6

    l1.openchannel(l2, capacity=capacity)
    
    # Now wait for gossip to settle and l1 to learn the topology
    wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 2)

     # Get all channels balanced (by paying money to the other node)
    l1.pay(l2, capacity // 2)
    l1.wait_for_htlcs()

    print("LISTPEERS L2: {}\n".format(l2.rpc.listpeers()))

    l2.pay(l1, capacity // 20)
    l2.wait_for_htlcs()

```

The script above fails with the error below

## Error

```
Fail: pyln.client.lightning.RpcError: RPC call failed: method: waitsendpay, payload: {'payment_hash': '6d1281627828720bd86cb2815f222a8c0106545d7d4f972e5ec5324133163224'}, error: {'code': 204, 'message': 'failed: WIRE_TEMPORARY_CHANNEL_FAILURE (WIRE_TEMPORARY_CHANNEL_FAILURE: Capacity exceeded - HTLC fee: 7964sat)', 'data': {'id': 1, 'payment_hash': '6d1281627828720bd86cb2815f222a8c0106545d7d4f972e5ec5324133163224', 'destination': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'msatoshi': 50000, 'amount_msat': 50000msat, 'msatoshi_sent': 50000, 'amount_sent_msat': 50000msat, 'created_at': 1623829593, 'status': 'failed', 'erring_index': 0, 'failcode': 4103, 'failcodename': 'WIRE_TEMPORARY_CHANNEL_FAILURE', 'erring_node': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'erring_channel': '1x1x1', 'erring_direction': 0}}

```

## Listpeers

If I lift some information out of the `listpeers` rpc call for `l2` I can understand why the payment wouldn't work:

```
'msatoshi_to_us': 500000
[...]
'spendable_msatoshi': 0

```

What I don't understand is *why* 'spendable\_msatoshi' would be zero. It can't be because of the channel reserve. I don't think it can be because of enormously overestimating the on-chain fees (in case of a forced close) because the l2 isn't the funder.

What am I missing/not understanding here?

**Tags:** core-lightning, unit-test


---

## 1 answers

### Answer by username_1 on 2021-06-16. Score: 2

You opened a 1 million Satoshi channel and send 500 sats to the other side. The protocol requires a 1%channel reserve kept on both sides for the penalty mechanism to always have enough collateral. This one percent is ignored initially if you never had that much balance (e. G. On new channels) but is the reason why you can't send sats unless you met the 1% threshold.

Send another 9501 sats (9501000msats) and you should see that you can spend 1 satoshi

> **Comments:**
> **username_0**: I mixed up sats and msats. I meant to balance the channel 50/50, but `openchannel` uses sats and `pay` uses msats.  

---

