Merge pull request #1033 from stevenroose/close-offline

rpcserver: Clarify failure closing offline channel
This commit is contained in:
Olaoluwa Osuntokun 2018-04-06 12:20:30 -07:00 committed by GitHub
commit e30881a14c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View File

@ -30,7 +30,7 @@ type InvoiceDatabase interface {
// |
// | (Switch) (Switch) (Switch)
// | Alice <-- channel link --> Bob <-- channel link --> Carol
// |
// |
// | - - - - - - - - - - - - - TCP - - - - - - - - - - - - - - -
// |
// | (Peer) (Peer) (Peer)

View File

@ -1284,8 +1284,8 @@ func (s *Switch) htlcForwarder() {
chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint)
link, ok := s.linkIndex[chanID]
if !ok {
req.Err <- errors.Errorf("channel with "+
"chan_id=%x not found", chanID[:])
req.Err <- errors.Errorf("no peer for channel with "+
"chan_id=%x", chanID[:])
continue
}

View File

@ -22,6 +22,8 @@ const (
// within the network. The ChannelID is computed using the outpoint of the
// funding transaction (the txid, and output index). Given a funding output the
// ChannelID can be calculated by XOR'ing the big-endian serialization of the
// txid and the big-endian serialization of the output index, truncated to
// 2 bytes.
type ChannelID [32]byte
// ConnectionWideID is an all-zero ChannelID, which is used to represent a

View File

@ -1071,6 +1071,16 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
}
})
} else {
// If the link is not known by the switch, we cannot gracefully close
// the channel.
channelID := lnwire.NewChanIDFromOutPoint(chanPoint)
if _, err := r.server.htlcSwitch.GetLink(channelID); err != nil {
rpcsLog.Debugf("Trying to non-force close offline channel with "+
"chan_point=%v", chanPoint)
return fmt.Errorf("unable to gracefully close channel while peer "+
"is offline (try force closing it instead): %v", err)
}
// Based on the passed fee related parameters, we'll determine
// an appropriate fee rate for the cooperative closure
// transaction.