diff --git a/lnclient/lnd/lnd.go b/lnclient/lnd/lnd.go index 7a59bbc9..032664a4 100644 --- a/lnclient/lnd/lnd.go +++ b/lnclient/lnd/lnd.go @@ -241,7 +241,31 @@ func (svc *LNDService) MakeInvoice(ctx context.Context, amount int64, descriptio expiry = lnclient.DEFAULT_INVOICE_EXPIRY } - resp, err := svc.client.AddInvoice(ctx, &lnrpc.Invoice{ValueMsat: amount, Memo: description, DescriptionHash: descriptionHashBytes, Expiry: expiry, Private: true}) + addInvoiceRequest := &lnrpc.Invoice{ + ValueMsat: amount, + Memo: description, + DescriptionHash: descriptionHashBytes, + Expiry: expiry, + } + + channels, err := svc.ListChannels(ctx) + if err != nil { + return nil, err + } + + hasPublicChannels := false + for _, channel := range channels { + if channel.Active && channel.Public { + hasPublicChannels = true + } + } + + // if there is not even one public channel, use private channel hints in the invoice + if !hasPublicChannels { + addInvoiceRequest.Private = true + } + + resp, err := svc.client.AddInvoice(ctx, addInvoiceRequest) if err != nil { return nil, err