Merge pull request #1033 from stevenroose/close-offline
rpcserver: Clarify failure closing offline channel
This commit is contained in:
commit
e30881a14c
@ -30,7 +30,7 @@ type InvoiceDatabase interface {
|
|||||||
// |
|
// |
|
||||||
// | (Switch) (Switch) (Switch)
|
// | (Switch) (Switch) (Switch)
|
||||||
// | Alice <-- channel link --> Bob <-- channel link --> Carol
|
// | Alice <-- channel link --> Bob <-- channel link --> Carol
|
||||||
// |
|
// |
|
||||||
// | - - - - - - - - - - - - - TCP - - - - - - - - - - - - - - -
|
// | - - - - - - - - - - - - - TCP - - - - - - - - - - - - - - -
|
||||||
// |
|
// |
|
||||||
// | (Peer) (Peer) (Peer)
|
// | (Peer) (Peer) (Peer)
|
||||||
|
@ -1284,8 +1284,8 @@ func (s *Switch) htlcForwarder() {
|
|||||||
chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint)
|
||||||
link, ok := s.linkIndex[chanID]
|
link, ok := s.linkIndex[chanID]
|
||||||
if !ok {
|
if !ok {
|
||||||
req.Err <- errors.Errorf("channel with "+
|
req.Err <- errors.Errorf("no peer for channel with "+
|
||||||
"chan_id=%x not found", chanID[:])
|
"chan_id=%x", chanID[:])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ const (
|
|||||||
// within the network. The ChannelID is computed using the outpoint of the
|
// within the network. The ChannelID is computed using the outpoint of the
|
||||||
// funding transaction (the txid, and output index). Given a funding output 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
|
// 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
|
type ChannelID [32]byte
|
||||||
|
|
||||||
// ConnectionWideID is an all-zero ChannelID, which is used to represent a
|
// ConnectionWideID is an all-zero ChannelID, which is used to represent a
|
||||||
|
10
rpcserver.go
10
rpcserver.go
@ -1071,6 +1071,16 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} 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
|
// Based on the passed fee related parameters, we'll determine
|
||||||
// an appropriate fee rate for the cooperative closure
|
// an appropriate fee rate for the cooperative closure
|
||||||
// transaction.
|
// transaction.
|
||||||
|
Loading…
Reference in New Issue
Block a user