mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
rpc: update SubscribeInvoices to send backlog ntfns, also send add ntfns
This commit is contained in:
parent
7917fd2ab0
commit
892a413be3
16
rpcserver.go
16
rpcserver.go
@ -2854,14 +2854,24 @@ func (r *rpcServer) ListInvoices(ctx context.Context,
|
||||
func (r *rpcServer) SubscribeInvoices(req *lnrpc.InvoiceSubscription,
|
||||
updateStream lnrpc.Lightning_SubscribeInvoicesServer) error {
|
||||
|
||||
invoiceClient := r.server.invoices.SubscribeNotifications()
|
||||
invoiceClient := r.server.invoices.SubscribeNotifications(
|
||||
req.AddIndex, req.SettleIndex,
|
||||
)
|
||||
defer invoiceClient.Cancel()
|
||||
|
||||
for {
|
||||
select {
|
||||
// TODO(roasbeef): include newly added invoices?
|
||||
case settledInvoice := <-invoiceClient.SettledInvoices:
|
||||
case newInvoice := <-invoiceClient.NewInvoices:
|
||||
rpcInvoice, err := createRPCInvoice(newInvoice)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := updateStream.Send(rpcInvoice); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case settledInvoice := <-invoiceClient.SettledInvoices:
|
||||
rpcInvoice, err := createRPCInvoice(settledInvoice)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user