ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.81k stars 889 forks source link

The payment return ' Could not find a route ' when run ' lightning-cli pay blot-11 ' #1369

Closed laziobird closed 6 years ago

laziobird commented 6 years ago

Issue and Steps to Reproduce

I have create two lightning node by using c-lightning A:

/mnt/lightning/cli/lightning-cli getinfo
{
  "id": "03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c", 
  "port": 9735, 
  "address": [
  ], 
  "version": "v0.5.2-2016-11-21-2512-gb0c2e3c", 
  "blockheight": 1292539, 
  "network": "testnet"
}

B:

{
  "id": "02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b", 
  "port": 9735, 
  "address": [
  ], 
  "version": "v0.5.2-2016-11-21-2512-gb0c2e3c", 
  "blockheight": 1292539, 
  "network": "testnet"
}

There is a chanel between A and B:

`
lightning-cli fundchannel  02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b  12000000
{
  "tx": "02000000000101a53368936ef03bf6474841d0d19960f743ecf5a5d9fe5cb232013afb64bab9fa0100000017160014a1849981b924876091a8c721535e754b5f2137d9ffffffff02001bb70000000000220020498efaf26b0eebdf72f16d7927e3dace29100910f0abdcf2e3723b7bd1e71202cfd44302000000001600148ea3b5f8a447c153911d391c2af8dec4291579810247304402205e1dc1d70599e48f2f9ff913ce179e835a52ccb7413a48803ed730b505a3bef5022043e6390a34351045f33ad94dfefc769ddf60f34c86762fb3921c1a8dff20e1960121026243bc75577e2071a5ebfb4a9fb413acd5bbc6279dfb115f634c0b79f050189000000000", 
  "txid": "440753b221e36b8bd25051be70bfb7579197dc0107d577cfd6e4adf56ae96906", 
  "channel_id": "0669e96af5ade4d6cf77d50701dc979157b7bf70be5150d28b6be321b2530744"
}
`

The channel infomations:

/mnt/lightning/cli/lightning-cli listpeers

{
  "peers": [
    {
      "id": "02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b", 
      "connected": true, 
      "netaddr": [
        "47.98.45.23:9735"
      ], 
      "alias": "VIOLETBOUNCE-11-21-2512-gb0c2e3c", 
      "color": "02c286", 
      "channels": [
        {
          "state": "CHANNELD_NORMAL", 
          "owner": "lightning_channeld", 
          "short_channel_id": "1292524:21:0", 
          "channel_id": "0669e96af5ade4d6cf77d50701dc979157b7bf70be5150d28b6be321b2530744", 
          "funding_txid": "440753b221e36b8bd25051be70bfb7579197dc0107d577cfd6e4adf56ae96906", 
          "msatoshi_to_us": 12000000000, 
          "msatoshi_to_us_min": 12000000000, 
          "msatoshi_to_us_max": 12000000000, 
          "msatoshi_total": 12000000000, 
          "dust_limit_satoshis": 546, 
          "max_htlc_value_in_flight_msat": 18446744073709551615, 
          "their_channel_reserve_satoshis": 0, 
          "our_channel_reserve_satoshis": 120000, 
          "channel_reserve_satoshis": 0, 
          "spendable_msatoshi": 11880000000, 
          "htlc_minimum_msat": 0, 
          "their_to_self_delay": 6, 
          "our_to_self_delay": 6, 
          "to_self_delay": 6, 
          "max_accepted_htlcs": 483, 
          "status": [
            "CHANNELD_NORMAL:Funding transaction locked."
          ], 
          "in_payments_offered": 0, 
          "in_msatoshi_offered": 0, 
          "in_payments_fulfilled": 0, 
          "in_msatoshi_fulfilled": 0, 
          "out_payments_offered": 0, 
          "out_msatoshi_offered": 0, 
          "out_payments_fulfilled": 0, 
          "out_msatoshi_fulfilled": 0
        }
      ]
    }
  ]
}

First: I create a invoice in Node A

/mnt/lightning/cli/lightning-cli invoice 100 three  for47.98.45.23To100
{
  "payment_hash": "93b311d5e67bea768b375a79eb58aff3cb4e1cd739fbbf21c7d9d29ccd88cd43", 
  "expiry_time": 1523542249, 
  "expires_at": 1523542249, 
  "bolt11": "lntb1n1pdv7kkepp5jwe3r40x0048dzehtfu7kk907095u8xh88am7gw8m8ffenvge4psdqlvehhydph9cunst35x5hryv65ducnqvqcqpxqjsy68qvhjgmct3jtmyzjh08xapw64vv4ejjjcsqtks5u25t0ccyjm6ctwd7n7mmccuzeu3n78g9q8jsunsldpfqf4pvjkqz4j6zpcqpjfpsen"
}

/mnt/lightning/cli/lightning-cli decodepay   lntb1n1pdv7kkepp5jwe3r40x0048dzehtfu7kk907095u8xh88am7gw8m8ffenvge4psdqlvehhydph9cunst35x5hryv65ducnqvqcqpxqjsy68qvhjgmct3jtmyzjh08xapw64vv4ejjjcsqtks5u25t0ccyjm6ctwd7n7mmccuzeu3n78g9q8jsunsldpfqf4pvjkqz4j6zpcqpjfpsen
{
  "currency": "tb", 
  "timestamp": 1523538649, 
  "created_at": 1523538649, 
  "expiry": 3600, 
  "payee": "03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c", 
  "msatoshi": 100, 
  "description": "for47.98.45.23To100", 
  "min_final_cltv_expiry": 6, 
  "payment_hash": "93b311d5e67bea768b375a79eb58aff3cb4e1cd739fbbf21c7d9d29ccd88cd43", 
  "signature": "3044022004a04d1c0cbc91bc2e325ec8295de73742ed558cae652962005da14e2a8b7e300220496f585b9be9fb7bc6382cf233f1d0501e50e4e1f685204d42c95802acb420e0"
}

Secord:In node B, i pay paymenturl to Node A . The result is like this :

/mnt/lightning/cli/lightning-cli  pay lntb1n1pdv7kkepp5jwe3r40x0048dzehtfu7kk907095u8xh88am7gw8m8ffenvge4psdqlvehhydph9cunst35x5hryv65ducnqvqcqpxqjsy68qvhjgmct3jtmyzjh08xapw64vv4ejjjcsqtks5u25t0ccyjm6ctwd7n7mmccuzeu3n78g9q8jsunsldpfqf4pvjkqz4j6zpcqpjfpsen
{ "code" : 205, "message" : "Could not find a route", "data" : 
{
  "getroute_tries": 2, 
  "sendpay_tries": 1, 
  "failures": [
    {
      "type": "FAIL_PAYMENT_REPLY", 
      "erring_index": 0, 
      "failcode": 4103, 
      "erring_node": "02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b", 
      "erring_channel": "1292524:21:0", 
      "route": [
        {
          "id": "03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c", 
          "channel": "1292524:21:0", 
          "msatoshi": 100, 
          "delay": 6
        }
      ]
    }
  ]
} }

The log of node B is this

2018-04-12T13:15:29.718Z lightning_gossipd(3434): Trying to find a route from 02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b to 03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c for 100 msatoshi
2018-04-12T13:15:29.718Z lightning_gossipd(3434): REPLY WIRE_GOSSIP_GETROUTE_REPLY with 0 fds
2018-04-12T13:15:29.718Z lightningd(3426): pay(0x21b54d0): sendpay via route: us -> 1292524:21:0 (100msat, 6blk) -> 03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c
2018-04-12T13:15:29.719Z lightningd(3426): Sending 100 over 1 hops to deliver 100
2018-04-12T13:15:29.719Z lightningd(3426): lightning_channeld-03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c chan #2: balance = 18446744073709551516, fee is 0, reserve is 120000000
2018-04-12T13:15:29.719Z lightningd(3426): lightning_channeld-03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c chan #2: Adding HTLC 0 msat=100 cltv=1292550 gave CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED
2018-04-12T13:15:29.719Z lightningd(3426): lightning_channeld-03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c chan #2: REPLY WIRE_CHANNEL_OFFER_HTLC_REPLY with 0 fds
2018-04-12T13:15:29.719Z lightningd(3426): Reporting route failure to gossipd: 0x1007 (WIRE_TEMPORARY_CHANNEL_FAILURE) node 02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b channel 1292524:21:0 update 
2018-04-12T13:15:29.719Z lightningd(3426): pay(0x21b54d0): Try another route
2018-04-12T13:15:29.744Z lightning_gossipd(3434): Received routing failure 0x1007 (WIRE_TEMPORARY_CHANNEL_FAILURE), erring node 02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b, channel 1292524:21:0
2018-04-12T13:15:29.744Z lightning_gossipd(3434): Trying to find a route from 02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b to 03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c for 100 msatoshi
2018-04-12T13:15:29.744Z lightning_gossipd(3434): find_route: No route to 03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c
2018-04-12T13:15:29.744Z lightning_gossipd(3434): REPLY WIRE_GOSSIP_GETROUTE_REPLY with 0 fds

getinfo output

cdecker commented 6 years ago

We debugged this together on Slack and found that the issue is the channel direction was opposite to the payment direction, i.e., the sender did not own any funds on that channel.

laziobird commented 6 years ago

It still happens that even the sender has some funds on this channel

 /mnt/lightning/cli/lightning-cli listfunds
{
  "outputs": [
    {
      "txid": "9c068e2ab43de874966fe88a573084627d79a5d68329877f1dc594ea331390e1", 
      "output": 1, 
      "value": 46836371, 
      "address": "tb1qv6fz3ssjjk0sraa66j232c5mgkjgwqn0we3w3m", 
      "status": "confirmed"
    }
  ], 
  "channels": [
    {
      "peer_id": "03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134", 
      "short_channel_id": "1292519:126:0", 
      "channel_sat": 12000000, 
      "channel_total_sat": 12000000, 
      "funding_txid": "9c068e2ab43de874966fe88a573084627d79a5d68329877f1dc594ea331390e1"
    }, 
    {
      "peer_id": "03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c", 
      "short_channel_id": "1292524:21:0", 
      "channel_sat": 10224, 
      "channel_total_sat": 12000000, 
      "funding_txid": "440753b221e36b8bd25051be70bfb7579197dc0107d577cfd6e4adf56ae96906"
    }
  ]
}
root@iZbp1fvxo1vhii2annlbsoZ:~#  /mnt/lightning/cli/lightning-cli  pay  lntb10n1pdv77xapp50mdqh8mh62t9s6rmqc3ujtxqayezjw2hqns9hetzjj9lgfrk792qdp8veex7mf5x5hryv65ducnvwpwxy6rvnmxxycrqvqcqpxsnzefm9q5lcj7570thtuagksccv65nsft9wt6ksrqtqep2n6u249v72yzk02rszyj4wd959ghkz9kp6j660f4gu3v8la3qcn3k0d00qqwcvrde
{ "code" : 205, "message" : "Could not find a route", "data" : 
{
  "getroute_tries": 2, 
  "sendpay_tries": 1, 
  "failures": [
    {
      "type": "FAIL_PAYMENT_REPLY", 
      "erring_index": 0, 
      "failcode": 4103, 
      "erring_node": "02c286fc1c87fdc636c152406752cc75ee791450f0f17b8df1da40d24865d8670b", 
      "erring_channel": "1292524:21:0", 
      "route": [
        {
          "id": "03853aae7448f14f67823a57c9f104054349d077ebe96c125ec20a715cdbe0e07c", 
          "channel": "1292524:21:0", 
          "msatoshi": 1001, 
          "delay": 6
        }
      ]
    }
  ]
} }

The invoice from receiver

root@iZbp15g4p48awj8vzjkk1tZ:~# /mnt/lightning/cli/lightning-cli invoice 1000 12  from45.23To168.146Of1000
{
  "payment_hash": "7eda0b9f77d29658687b0623c92cc0e93229395704e05be562948bf42476f154", 
  "expiry_time": 1523549933, 
  "expires_at": 1523549933, 
  "bolt11": "lntb10n1pdv77xapp50mdqh8mh62t9s6rmqc3ujtxqayezjw2hqns9hetzjj9lgfrk792qdp8veex7mf5x5hryv65ducnvwpwxy6rvnmxxycrqvqcqpxsnzefm9q5lcj7570thtuagksccv65nsft9wt6ksrqtqep2n6u249v72yzk02rszyj4wd959ghkz9kp6j660f4gu3v8la3qcn3k0d00qqwcvrde"
}
ZmnSCPxj commented 6 years ago

Can you dump listpeers and look at the spendable_msatoshi field of the channel? That is the amount of money you can actually spend on that channel without violating the our_channel_reserve_satoshis value.

There is a channel reserve that we need to respect; we might start out with less than the reserve, but once we own a value we should not go to a lower value (i.e. spend) if the lower value would be less than the reserve. So please notice spendable_msatoshi first.