funding+htlcswitch: dynamically update short chan id of existing link

In this commit, we fix an existing bug that would result in some
payments getting “stuck”. This would happen if one side restarted
before the channel was fully locked in. In this case, since upon
re-connection, the link will get added to the switch with a *short
channel ID of zero*. If A then tries to make a multi-hop payment
through B, B will fail to forward the payment, as it’ll mistakenly
think that the payment originated from a local-subsystem as the channel
ID is zero. A short channel ID of zero is used to map local payments
back to their caller.

With fix this by allowing the funding manager to dynamically update the
short channel ID of a link after it discovers the short channel ID.

In this commit, we fix a second instance of reported “stuck” payments
by users.
This commit is contained in:
Olaoluwa Osuntokun
2018-02-03 18:14:09 -08:00
parent 71a837630a
commit 30dbbd69a0
7 changed files with 145 additions and 14 deletions

7
lnd.go
View File

@ -42,6 +42,7 @@ import (
"github.com/lightningnetwork/lnd/macaroons"
"github.com/lightningnetwork/lnd/walletunlocker"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
)
@ -370,6 +371,12 @@ func lndMain() error {
return delay
},
WatchNewChannel: server.chainArb.WatchNewChannel,
ReportShortChanID: func(chanPoint wire.OutPoint,
sid lnwire.ShortChannelID) error {
cid := lnwire.NewChanIDFromOutPoint(&chanPoint)
return server.htlcSwitch.UpdateShortChanID(cid, sid)
},
})
if err != nil {
return err