mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-13 18:10:25 +02:00
htlcswitch: add final htlc event to notifier
This commit is contained in:
@@ -14,7 +14,7 @@ func rpcHtlcEvent(htlcEvent interface{}) (*HtlcEvent, error) {
|
||||
var (
|
||||
key htlcswitch.HtlcKey
|
||||
timestamp time.Time
|
||||
eventType htlcswitch.HtlcEventType
|
||||
eventType *htlcswitch.HtlcEventType
|
||||
event isHtlcEvent_Event
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ func rpcHtlcEvent(htlcEvent interface{}) (*HtlcEvent, error) {
|
||||
}
|
||||
|
||||
key = e.HtlcKey
|
||||
eventType = e.HtlcEventType
|
||||
eventType = &e.HtlcEventType
|
||||
timestamp = e.Timestamp
|
||||
|
||||
case *htlcswitch.ForwardingFailEvent:
|
||||
@@ -36,7 +36,7 @@ func rpcHtlcEvent(htlcEvent interface{}) (*HtlcEvent, error) {
|
||||
}
|
||||
|
||||
key = e.HtlcKey
|
||||
eventType = e.HtlcEventType
|
||||
eventType = &e.HtlcEventType
|
||||
timestamp = e.Timestamp
|
||||
|
||||
case *htlcswitch.LinkFailEvent:
|
||||
@@ -57,7 +57,7 @@ func rpcHtlcEvent(htlcEvent interface{}) (*HtlcEvent, error) {
|
||||
}
|
||||
|
||||
key = e.HtlcKey
|
||||
eventType = e.HtlcEventType
|
||||
eventType = &e.HtlcEventType
|
||||
timestamp = e.Timestamp
|
||||
|
||||
case *htlcswitch.SettleEvent:
|
||||
@@ -68,7 +68,20 @@ func rpcHtlcEvent(htlcEvent interface{}) (*HtlcEvent, error) {
|
||||
}
|
||||
|
||||
key = e.HtlcKey
|
||||
eventType = e.HtlcEventType
|
||||
eventType = &e.HtlcEventType
|
||||
timestamp = e.Timestamp
|
||||
|
||||
case *htlcswitch.FinalHtlcEvent:
|
||||
event = &HtlcEvent_FinalHtlcEvent{
|
||||
FinalHtlcEvent: &FinalHtlcEvent{
|
||||
Settled: e.Settled,
|
||||
Offchain: e.Offchain,
|
||||
},
|
||||
}
|
||||
|
||||
key = htlcswitch.HtlcKey{
|
||||
IncomingCircuit: e.CircuitKey,
|
||||
}
|
||||
timestamp = e.Timestamp
|
||||
|
||||
default:
|
||||
@@ -85,18 +98,21 @@ func rpcHtlcEvent(htlcEvent interface{}) (*HtlcEvent, error) {
|
||||
}
|
||||
|
||||
// Convert the htlc event type to a rpc event.
|
||||
switch eventType {
|
||||
case htlcswitch.HtlcEventTypeSend:
|
||||
rpcEvent.EventType = HtlcEvent_SEND
|
||||
if eventType != nil {
|
||||
switch *eventType {
|
||||
case htlcswitch.HtlcEventTypeSend:
|
||||
rpcEvent.EventType = HtlcEvent_SEND
|
||||
|
||||
case htlcswitch.HtlcEventTypeReceive:
|
||||
rpcEvent.EventType = HtlcEvent_RECEIVE
|
||||
case htlcswitch.HtlcEventTypeReceive:
|
||||
rpcEvent.EventType = HtlcEvent_RECEIVE
|
||||
|
||||
case htlcswitch.HtlcEventTypeForward:
|
||||
rpcEvent.EventType = HtlcEvent_FORWARD
|
||||
case htlcswitch.HtlcEventTypeForward:
|
||||
rpcEvent.EventType = HtlcEvent_FORWARD
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown event type: %v", eventType)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown event type: %v",
|
||||
eventType)
|
||||
}
|
||||
}
|
||||
|
||||
return rpcEvent, nil
|
||||
|
Reference in New Issue
Block a user