From 174faa795587a6bc614af68b71cca1688a0f22c7 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 11 Aug 2020 17:48:14 -0700 Subject: [PATCH] lnrpc/invoicesrpc: only try to add hop hints if we have channels --- lnrpc/invoicesrpc/addinvoice.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lnrpc/invoicesrpc/addinvoice.go b/lnrpc/invoicesrpc/addinvoice.go index d7172a5b..afa7e708 100644 --- a/lnrpc/invoicesrpc/addinvoice.go +++ b/lnrpc/invoicesrpc/addinvoice.go @@ -255,14 +255,16 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig, return nil, nil, fmt.Errorf("could not fetch all channels") } - // We'll restrict the number of individual route hints - // to 20 to avoid creating overly large invoices. - const numMaxHophints = 20 - hopHints := selectHopHints( - amtMSat, cfg, openChannels, numMaxHophints, - ) + if len(openChannels) > 0 { + // We'll restrict the number of individual route hints + // to 20 to avoid creating overly large invoices. + const numMaxHophints = 20 + hopHints := selectHopHints( + amtMSat, cfg, openChannels, numMaxHophints, + ) - options = append(options, hopHints...) + options = append(options, hopHints...) + } } // Set our desired invoice features and add them to our list of options.