lnrpc/invoicesrpc: only try to add hop hints if we have channels

This commit is contained in:
Olaoluwa Osuntokun 2020-08-11 17:48:14 -07:00
parent f6d6d6609f
commit 174faa7955
No known key found for this signature in database
GPG Key ID: BC13F65E2DC84465

@ -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.