rpc: Add PendingOpenChannel to SubscribeChannelEvents

This commit adds PendingOpenChannel to SubscribeChannelEvents stream in
the gRPC API.
This is useful for keeping track of channel openings that Autopilot does.
It can also be used for the non-initator side of a channel opening to keep
track of channel openings.
This commit is contained in:
Hampus Sjöberg committed 2020-01-24 13:48:18 +01:00
1 parent 51d8c11eb5
commit 227e66c469
9 files changed
+720 -644

No files matched your search

+13 -1
View File
@@ -3187,6 +3187,16 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
case e := <-channelEventSub.Updates():
var update *lnrpc.ChannelEventUpdate
switch event := e.(type) {
case channelnotifier.PendingOpenChannelEvent:
update = &lnrpc.ChannelEventUpdate{
Type: lnrpc.ChannelEventUpdate_PENDING_OPEN_CHANNEL,
Channel: &lnrpc.ChannelEventUpdate_PendingOpenChannel{
PendingOpenChannel: &lnrpc.PendingUpdate{
Txid: event.ChannelPoint.Hash[:],
OutputIndex: event.ChannelPoint.Index,
},
},
}
case channelnotifier.OpenChannelEvent:
channel, err := createRPCOpenChannel(r, graph,
event.Channel, true)
@@ -5601,7 +5611,9 @@ func (r *rpcServer) SubscribeChannelBackups(req *lnrpc.ChannelBackupSubscription
switch e.(type) {
// We only care about new/closed channels, so we'll
// skip any events for active/inactive channels.
// skip any events for pending/active/inactive channels.
case channelnotifier.PendingOpenChannelEvent:
continue
case channelnotifier.ActiveChannelEvent:
continue
case channelnotifier.InactiveChannelEvent: