fundingmanager: cancel reservation if unable to send initial msg to peer

This commit is contained in:
Johan T. Halseth 2018-02-23 11:11:01 +01:00
parent ff1dc2bbd4
commit b0d1be282c
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
1 changed files with 11 additions and 2 deletions

View File

@ -2436,8 +2436,17 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
ChannelFlags: channelFlags,
}
if err := f.cfg.SendToPeer(peerKey, &fundingOpen); err != nil {
fndgLog.Errorf("Unable to send funding request message: %v", err)
msg.err <- err
e := fmt.Errorf("Unable to send funding request message: %v",
err)
fndgLog.Errorf(e.Error())
// Since we were unable to send the initial message to the peer
// and start the funding flow, we'll cancel this reservation.
if _, err := f.cancelReservationCtx(peerKey, chanID); err != nil {
fndgLog.Errorf("unable to cancel reservation: %v", err)
}
msg.err <- e
return
}
}