neogeno / shango-lightning-wallet

Shango Lightning Wallet
66 stars 4 forks source link

Error opening channel to a non-connected peer #24

Closed bjarnemagnussen closed 6 years ago

bjarnemagnussen commented 6 years ago

When trying to open a channel with a peer that Shango/LND is not already connected to, it will give an error message the first time saying: 2: ERROR from GRPC Stream for openChannel: peer is not connected NodeKey(pubkey). But it will often succeed when I directly thereafter again press the button to open the channel with the same peer.

I have now also configured Shango to use my own LND instance to check the log of LND. When I reproduce this behaviour from above, LND shows the following in the log:

lnd[]: [ERR] RPCS: unable to open channel to NodeKey(pubkey): peer is not connected NodeKey(pubkey)
lnd[]: [INF] SRVR: Established connection to: IP:Port

So LND first tries to open the channel to the peer but only knows its pubkey, which may not be enough. First after this try it connects to the peer using the provided IP:Port. It would probably be better if Shango first tries to establish the connection to the peer and then after a success tries to open the channel.

Expected Behavior

The new channel should be opened with the first try.

Current Behavior

Shango tries to open the channel without a connection to the peer and gives an error message. If I thereafter press the button to open the exact same channel again it will often succeed, because Shango/LND opened a connection to the peer in the background after the first try of opening the channel first.

Possible Solution or Best way to handle this problem

I am not sure if the GRPC command openChannel that is used can also receive the connection information (IP:port) just like the RPC command openchannel can. Otherwise maybe always use a call to connectPeer first and after the response is positive try to open the channel.

Steps to Reproduce

I selected peers from https://1ml.com/testnet to test it.

  1. Find a peer that Shango is not connected to (run lncli openchannel "pubkey" amount push_amount to see if the error message is [lncli] rpc error: code = Unknown desc = peer is not connected NodeKey(pubkey)
  2. Try to open a channel with this peer in Shango using the complete information of the peer: pubkey@IP:Port.
  3. Shango will give an error message.
  4. Try to open the exact same channel. Often Shango will now be able to open the channel because the only thing missing was the direct connection to the peer before opening the channel.
neogeno commented 6 years ago

Fixed in build 18