From e4891a98fd8388bffaaf8788cca7644829487181 Mon Sep 17 00:00:00 2001 From: Harsha Goli Date: Mon, 6 Sep 2021 15:36:49 -0700 Subject: [PATCH 1/2] invoicesrpc: expose selectHopHints selectHopHints is the function which constructs hophints otherwise found in an invoice created with the private flag. In this commit, we expose that functionality a little more to workaround needing to create an invoice to retrieve routing hints. Of course, this is not a perfect solution as the functionality is exposed exclusively to go users. --- lnrpc/invoicesrpc/addinvoice.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lnrpc/invoicesrpc/addinvoice.go b/lnrpc/invoicesrpc/addinvoice.go index 2d782a67f..4e88ae0c1 100644 --- a/lnrpc/invoicesrpc/addinvoice.go +++ b/lnrpc/invoicesrpc/addinvoice.go @@ -391,7 +391,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig, // We'll restrict the number of individual route hints // to 20 to avoid creating overly large invoices. numMaxHophints := 20 - len(forcedHints) - hopHints := selectHopHints( + hopHints := SelectHopHints( amtMSat, cfg, filteredChannels, numMaxHophints, ) @@ -553,12 +553,12 @@ func addHopHint(hopHints *[]func(*zpay32.Invoice), ) } -// selectHopHints will select up to numMaxHophints from the set of passed open +// SelectHopHints will select up to numMaxHophints from the set of passed open // channels. The set of hop hints will be returned as a slice of functional // options that'll append the route hint to the set of all route hints. // // TODO(roasbeef): do proper sub-set sum max hints usually << numChans -func selectHopHints(amtMSat lnwire.MilliSatoshi, cfg *AddInvoiceConfig, +func SelectHopHints(amtMSat lnwire.MilliSatoshi, cfg *AddInvoiceConfig, openChannels []*channeldb.OpenChannel, numMaxHophints int) []func(*zpay32.Invoice) { From 8720b8f6577bfa3be4a641b93cff25177dcbb516 Mon Sep 17 00:00:00 2001 From: Harsha Goli Date: Tue, 7 Sep 2021 14:43:36 -0700 Subject: [PATCH 2/2] docs: update release-notes-0.14.0.md --- docs/release-notes/release-notes-0.14.0.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/release-notes-0.14.0.md b/docs/release-notes/release-notes-0.14.0.md index 89194b4f3..b0d34d326 100644 --- a/docs/release-notes/release-notes-0.14.0.md +++ b/docs/release-notes/release-notes-0.14.0.md @@ -152,6 +152,10 @@ you. into projects that are compiled to WASM binaries. [That problem was fixed by guarding those syscalls with build tags](https://github.com/lightningnetwork/lnd/pull/5526). +* The only way to retrieve hophints for a given node was to create an invoice + with the `addInvoice` rpc interface. However, now the function has been + [exposed in the go package `invoicesrpc`](https://github.com/lightningnetwork/lnd/pull/5697). + ## Code Health ### Code cleanup, refactor, typo fixes @@ -256,6 +260,7 @@ change](https://github.com/lightningnetwork/lnd/pull/5613). * de6df1re * ErikEk * Eugene Siegel +* Harsha Goli * Martin Habovstiak * Oliver Gugger * Wilmer Paulino