Commit Graph

127 Commits

Author SHA1 Message Date
Oliver Gugger
ea8fe6f3f3
mod+lnrpc: bump google.golang.org/protobuf to v1.30.0 2023-05-11 22:52:00 +02:00
Eval EXEC
cbcbddfe29
rpcserver: add time_lock_delta overflow check 2023-03-23 21:34:12 +08:00
Elle Mouton
2fd4f3f180
go.mod+lnrpc+github: point to latest kvdb changes
Use kvdb package v1.4.1. This update also forced the protobuf version to
be bumped which required `make rpc` to be run to update the generated
files. This also required a bump in the github pinned dependencies
config for the grpc and protobuf libs.
2023-01-25 14:03:00 +02:00
positiveblue
8563e1f409
channeldb/invoices: add IsAMP and IsKeysend helpers
The only way to know if an invoice is AMP, Keysend, etc is to look at
its shape/characteristics. This commit adds a couple of helper functions
to encapsulate the logic of these checks.

If all these types cannot intersect: an invoice cannot be AMP and
Keysend or Keysend and Bolt12, etc it could be useful to add an extra
field to store this information instead of relying on checking how the
invoice looks like.
2023-01-20 03:43:39 -08:00
positiveblue
5ff5225245
multi: break invoice depenency on channeldb
Now that we have the new package `lnd/channeldb/models` we can invert the
depenency between `channeldb` and `invoices`.

- Move all the invoice related types and errors to the
`invoices` package.

- Ensure that all the packages dealing with invoices use the types and
  interfaces defined in the `invoices` package.

- Implement the InvoiceDB interface (defined in `lnd/invoices`) in
  channeldb.

- Add new mock for InterfaceDB.

- `InvoiceRegistery` tests are now in its own subpacakge (they need to
  import both invoices & channeldb). This is temporary until we can
  decouple them.
2023-01-16 07:31:09 -08:00
bruwbird
71f2615190
lnrpc: update invoice request expiry comment 2023-01-12 09:17:34 +09:00
Tommy Volk
372333fd2b
lnrpc: clarify proto documentation for Invoice 2022-12-05 20:01:27 +08:00
Oliver Gugger
e7170ef819
Merge pull request #7135 from st4rgut24/revise-addinvoice-help-text
revise help text for addinvoice lncli command
2022-11-18 18:43:58 +01:00
alpeb-btc
eefe1c816e
lnrpc+cmd: clarify docs about addinvoice no-amount hop hints
Add additional comment to `lnclic addinvoice`'s `--private` flag warning
about including a large number of private channel hints when using zero
ammounts.

Also added a comment to the `private` field in the `Invoice` proto
message.
2022-11-12 05:01:10 -05:00
alpeb-btc
0cae501009
lnrpc: provide hop hints when adding an invoice with no amount
With this change we allow adding hop hints when adding an invoice, even
if its amount is zero.

A couple of new unit test case have been added, and the
`testInvoiceRoutingHints` itest was expanded to account for this
scenario.
2022-11-12 05:01:10 -05:00
alpeb-btc
e68ae33c9a
lnrpc: refactor populateHopHintsTestCases in addinvoice_test.go
Extract into a separate function the steps to set up the two-channel
mock, to be reused in other cases.
2022-11-12 05:01:09 -05:00
alpeb-btc
143111e368
lnrpc: fix typos in addinvoice_test.go 2022-11-12 05:01:09 -05:00
st4rgut24
8d6d1564c0 cli: revise help text for addinvoice lncli command [skip ci] 2022-11-11 14:31:04 -08:00
positiveblue
4b0bc9a7c6
invoicesrpc: unit tests for invoice hop hints 2022-09-30 06:55:16 -07:00
positiveblue
fbe79811cf
invoicesrpc: refactor addinvocie hop hint selection
In order to reduce the number of calls to the db we try to process as
few channels as we can + try to not do extra work for each of them.

- First fetch all the channels. Then, filter all the public ones and
  sort the potential candidates by remote balance.

- Filter out each potential candidate as soon as possible.

- Only check the alias if the channel supports scid aliases.

- Because we sort the channels by remote balance, we will hit the
  target amount, if possible, as soon as we can.

We do not want to leak information about our remote balances, so we
shuffle the hop hints (the forced ones go always first) so the invoice
receiver does not know which channels have more balance than others.
2022-09-30 06:55:10 -07:00
positiveblue
0e803172d6
style: format invoicesrpc/addinvoice.go 2022-09-28 02:19:55 -07:00
Evan Kaloudis
981f8969b4
lnrpc/gen_protos.sh: remove js build tag 2022-09-07 18:32:05 -04:00
Olaoluwa Osuntokun
b3998ddb5c
lnrpc: re-compile protos w/ Go 1.19 2022-08-24 11:43:00 -05:00
yyforyongyu
0735522194
multi: fix make fmt 2022-08-23 22:10:24 +08:00
Martin Habovštiak
b4647bc37f doc: Deprecation reason of settled on Invoice
This documents how to deal with `settled` being deprecated. It took me quite a bit of digging without such documentation.

[skip ci]
2022-08-02 11:04:01 +02:00
eugene
0ba67015da
rpcserver+invoicesrpc: alias-aware AddInvoice,AddHoldInvoice rpc
AddInvoice,AddHoldInvoice now issue invoices that include our
peer's aliases. Some extra sanity checks are included to ensure we
don't leak our confirmed SCID for a private channel.
2022-07-07 17:10:29 -04:00
ErikEk
26ba01a5cb doc: subscribe/cancel/lookup invoices rest 2022-06-26 07:15:27 +02:00
priyanshiiit
1e0a271ddb lnrpc: improves invoice documentation [skip ci] 2022-06-14 15:56:36 +05:30
positiveblue
d4021c5aca
lnrpc: fix log.go files
The `log.go` file of each subserver is a copy and paste of the others.
All of them have the same typo, an extra space in a comment, and the
the definition of a function not used anywhere.
2022-04-01 18:12:59 -07:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger
895a2e497b
multi: formatting and comment fixes 2022-02-10 11:02:02 +01:00
Oliver Gugger
dfdc2bff8b
multi: run gosimports 2022-02-10 11:02:01 +01:00
carla
0092c731e5
lnrpc: limit hop hint selection in both passes by amount + count
Previously, we'd always add up to the maximum number of hop hints
(and beyond!) when selecting hop hints in our first pass. This
change updates hop hint selection to always stick to our hop hint
limit, and to the "hop hint factor" that we scale our invoices by.

This change will result in selecting fewer channels in our first
pass if their total inbound capacity reaches our hop hint factor.
This prevents us from revealing as many private channels as
before, but has the downside of providing fewer options for
payers.
2022-02-07 09:04:30 +02:00
carla
5836d58a99
lnrpc: add unit test covering too many hop hints 2022-02-07 09:03:10 +02:00
carla
714a1fb05c
invoicerpc: move hop hint to constant and add tests to select hop hint 2022-01-27 15:09:21 +02:00
carla
80bf4bf014
invoicerpc: return hop hints from select hop hint rather than functions
Update SelectHopHints to return a set of hop hints that can be
converted to route hints / functional options by the caller. This
change allows external code to call SelectHopHints to get a set of
route hints and use them as it likes, rather than limiting the
return value to functional options for invoice creation.
2022-01-27 15:09:20 +02:00
carla
00a47740c8
invoicesrpc: pass in specialized config for select hop hints 2022-01-27 15:09:19 +02:00
carla
56e83de9ef
invoicesrpc: add HopHintInfo decoupling hop hint from channel internals 2022-01-27 15:09:18 +02:00
yyforyongyu
df2ecd6bc5
invoices: refactor invoice subscriptions to avoid blocking
This commit fixes a potential blocking when notifying invoice updates.
When a new subscription client is created followed by an immediate
cancel, it's likely the client will be removed from the registry's
map(noop) and then added to its map again. This subscription will then
be kept in registry until lnd is restarted. Another more serious issue
is when multiple subscriptions are made for the same invoice, when the
above case happens, other subscriptions may never send invoice updates
because a previous client has a stopped notification queue that blocks
following notifications.
2021-12-15 02:38:51 +08:00
Olaoluwa Osuntokun
698b5a8079
lnrpc: populate new AmpInvoiceState field in CreateRPCInvoice 2021-10-28 15:50:20 -07:00
Olaoluwa Osuntokun
d8ce00e016
lnrpc/invoicesrpc: expose new lookup modifier to LookupInvoiceV2 2021-10-28 15:50:17 -07:00
Olaoluwa Osuntokun
8299d632e8
lnrpc/invoicesrpc: add new invoice ref LookupInvoiceV2 method
In this commit, we add a new `LookupInvoiceV2` method attached to the
invoice RPC sub-server. Compared to the existing version, this version
allows an invoice to be looked up by an invoice ref. This enables users
to query an AMP invoice based on a specific _set ID_, so they can get
the information related to the set of cumulative settles to that
invoices.
2021-10-28 15:49:25 -07:00
Oliver Gugger
8b7c88537c
multi: refactor SignDigestCompact into SignMessageCompact
To make it possible to use a remote lnrpc server as a signer for our
wallet, we need to change our main interface to sign the message instead
of the message's digest. Otherwise we'd need to alter the
lnrpc.SignMessage RPC to accept a digest instead of only the message
which has security implications.
2021-10-08 12:06:52 +02:00
Oliver Gugger
692ea25295
Merge pull request #5642 from guggero/in-memory-graph
In-memory graph cache for faster pathfinding
2021-10-04 11:20:23 +02:00
Oliver Gugger
0b4e03f5fc
multi: add golang 1.17 compatible build tags
With go 1.17 a change to the build flags was implemented:
https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md

The formatter now automatically adds the forward-compatible build tag
format and the linter checks for them, so we need to include them in our
code.
2021-09-29 17:31:37 -07:00
Andras Banki-Horvath
11cf4216e4
multi: move all channelstate operations to ChannelStateDB 2021-09-29 17:00:03 +02:00
Harsha Goli
e4891a98fd
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.
2021-09-06 15:39:53 -07:00
Oliver Gugger
ea8c0abaaf
Merge pull request #5601 from guggero/falafel-js-stubs
lnrpc: add JSON stubs for interacting with lnrpc from a WASM context
2021-08-05 09:37:25 +02:00
Oliver Gugger
9138c8abac
multi: rename local and remote chan DBs
As a preparation to not have a local and remote version of the database
around anymore, we rename the variables into what their actual function
is. In case of the RPC server we even directly use the channel graph
instead of the DB instance. This should allow us to extract the channel
graph into its own, separate database (perhaps with better access
characteristics) in the future.
2021-08-04 14:55:50 +02:00
Oliver Gugger
702f0d7ced
lnrpc: generate JSON/WASM client stubs 2021-08-03 13:44:36 +02:00
Oliver Gugger
dd749fe580
lnrpc: update grpc-gateway library to v2 2021-07-27 13:09:59 +02:00
Oliver Gugger
235efc04e4
docs+lnrpc: rename rpc.proto to lightning.proto
To avoid a naming conflict with etcd, we rename our very generic
rpc.proto to lightning.proto to match the service name that's declared
within. This will break many external tutorials and possibly also our
API docs but the change needs to be done eventually.
2021-07-27 12:59:56 +02:00
Oliver Gugger
4a0025c1b7
lnrpc: split REST annotations into service files
As a preparation for the migration to the grpc-gateway/v2 library we
declare each service's REST annotations in its own file. This is
optional in the v1 library but mandatory in v2.
2021-07-27 12:59:52 +02:00
ErikEk
850dee37ee invoices: return payment address from addholdinvoice 2021-07-19 17:05:03 +02:00
Conner Fromknecht
4bb6cc9cee
lnrpc/addinvoice: bump default LND invoice timeouts
Increases the default MPP expiry from 1 hour to 1 day. For the new AMP
invoices, we increase the interval to 1 month. The longer time frames
for AMP invoices is used so that the invoice can be pseudo reused as
implemented in the prior commit.

The BOLT 11 default of 1 hour is still preserved whenever the field is
missing in the payment request itself, but as of this commit the field
will always be set by lnd.
2021-05-28 09:30:06 -07:00