htlcswitch: notify local receive settles
This commit is contained in:
parent
6bd0de257a
commit
71fdd755b4
@ -1208,10 +1208,7 @@ func (l *channelLink) processHtlcResolution(resolution invoices.HtlcResolution,
|
|||||||
l.log.Debugf("received settle resolution for %v"+
|
l.log.Debugf("received settle resolution for %v"+
|
||||||
"with outcome: %v", circuitKey, res.Outcome)
|
"with outcome: %v", circuitKey, res.Outcome)
|
||||||
|
|
||||||
return l.settleHTLC(
|
return l.settleHTLC(res.Preimage, htlc.pd)
|
||||||
res.Preimage, htlc.pd.HtlcIndex,
|
|
||||||
htlc.pd.SourceRef,
|
|
||||||
)
|
|
||||||
|
|
||||||
// For htlc failures, we get the relevant failure message based
|
// For htlc failures, we get the relevant failure message based
|
||||||
// on the failure resolution and then fail the htlc.
|
// on the failure resolution and then fail the htlc.
|
||||||
@ -2950,15 +2947,15 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// settleHTLC settles the HTLC on the channel.
|
// settleHTLC settles the HTLC on the channel.
|
||||||
func (l *channelLink) settleHTLC(preimage lntypes.Preimage, htlcIndex uint64,
|
func (l *channelLink) settleHTLC(preimage lntypes.Preimage,
|
||||||
sourceRef *channeldb.AddRef) error {
|
pd *lnwallet.PaymentDescriptor) error {
|
||||||
|
|
||||||
hash := preimage.Hash()
|
hash := preimage.Hash()
|
||||||
|
|
||||||
l.log.Infof("settling htlc %v as exit hop", hash)
|
l.log.Infof("settling htlc %v as exit hop", hash)
|
||||||
|
|
||||||
err := l.channel.SettleHTLC(
|
err := l.channel.SettleHTLC(
|
||||||
preimage, htlcIndex, sourceRef, nil, nil,
|
preimage, pd.HtlcIndex, pd.SourceRef, nil, nil,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to settle htlc: %v", err)
|
return fmt.Errorf("unable to settle htlc: %v", err)
|
||||||
@ -2976,10 +2973,21 @@ func (l *channelLink) settleHTLC(preimage lntypes.Preimage, htlcIndex uint64,
|
|||||||
// remote peer.
|
// remote peer.
|
||||||
l.cfg.Peer.SendMessage(false, &lnwire.UpdateFulfillHTLC{
|
l.cfg.Peer.SendMessage(false, &lnwire.UpdateFulfillHTLC{
|
||||||
ChanID: l.ChanID(),
|
ChanID: l.ChanID(),
|
||||||
ID: htlcIndex,
|
ID: pd.HtlcIndex,
|
||||||
PaymentPreimage: preimage,
|
PaymentPreimage: preimage,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Once we have successfully settled the htlc, notify a settle event.
|
||||||
|
l.cfg.HtlcNotifier.NotifySettleEvent(
|
||||||
|
HtlcKey{
|
||||||
|
IncomingCircuit: channeldb.CircuitKey{
|
||||||
|
ChanID: l.ShortChanID(),
|
||||||
|
HtlcID: pd.HtlcIndex,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
HtlcEventTypeReceive,
|
||||||
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user