Commit graph

48 commits

Author SHA1 Message Date
George Tsagkarelis
3ccfc5231b
multi: prepare for new non-constant string rule
In preparation for the next commit which bumps golang to a newer
version, we want to make some code changes that would otherwise render
some log-related calls problematic. With go1.24 a new govet rule was
added that disallows non-constant strings (i.e including a tag like
"%s") in calls to printf. See more in the related issue
https://github.com/golang/go/issues/60529.
2025-09-18 12:05:28 +02:00
Viktor Tigerström
e30ac3d0a8
multi: update GetInfoResponse response
Add the `commit_hash` field to the GetInfoResponse. The `commit_hash`
field will contain the most recent commit_hash that the build was based
on. If the build had uncommitted changes, this field will contain the
most recent commit hash, suffixed by "-dirty".

The semantics of the `version` field is also updated to always contain
the most recent semantic version of the litd node, following the
semantic versioning 2.0.0 spec (http://semver.org/).
2025-05-13 12:27:19 +02:00
Elle Mouton
949c0bf7e2
multi: move macaroon helpers to macaroons dir
... and out of the `sessions` directory. This is to avoid import cycles
when we start explicitly linking accounts to sessions.
2025-02-09 10:37:40 +02:00
Elle Mouton
b4f8224c54
multi: use ReadOnly param of BakeSuperMacaroon 2024-10-14 15:48:18 +02:00
Elle Mouton
6bcf19fb8e
rpc_proxy: special case the handling of BakeSuperMacaroon
In this commit, we special case the handling of BakeSuperMacaroon so as
to allow a user to make use of `litcli bakesupermacaroon` while LiT is
running in stateless init mode. The handling is as follows:
- if the call to _LiT's_ BakeSuperMacaroon is made while in stateless
  init mode then we can assume that the macaroon provided is either:
        1) an LND native macaroon which may or may not have the
           necessary permissions for the _LND_
           "/lnrpc.Lightning/BakeMacaroon" call.
        2) a baked macaroon (possibly a super macaroon) which may or may
           not have the permissions to the _LiT_
           "/litrpc.Proxy/BakeSuperMacaroon" call.

For case 1: we check that the provided macaroon has the correct perms.
If it does, then we use LiT's existing connection to LND to bake the
super mac.
For case 2: we have a macaroon that doesnt have LND's bakemac call perms
directly but does have LiT's BakeSuperMac perms. So for this, we treat
the call as normal and verify using LiT's macaroon validator as normal.
2024-10-14 15:48:18 +02:00
Elle Mouton
d3dc753b9b
rpc_proxy: give the proxy access to basicLNDClient 2024-10-14 15:48:18 +02:00
Boris Nagaev
0aed523f73
rpc_proxy: fix typo 2024-07-22 12:29:41 -03:00
Viktor Tigerström
e4c7275ea7
multi: use request overrides in RPC proxy 2024-01-05 03:46:54 +01:00
Viktor Tigerström
ec2a7a39b4
multi: add accounts service to status manager
Add the accounts service to status manager. This will allow us to query
the status of the accounts service and see if it is running or not.
For incoming gRPC requests to the accounts service, we also use the
status manager to check if the accounts service is running or not to
determine if we should let the request through or not.
2023-09-28 13:09:33 +02:00
Elle Mouton
cb804891a2
rpc_proxy: always allow Proxy calls 2023-09-22 11:59:25 +02:00
Elle Mouton
0f53f434d0
rpc_proxy+terminal: add LND and LiT to status server 2023-09-22 11:59:25 +02:00
Elle Mouton
75cfa0b053
rpc_proxy: only allow requests if sub-server is ready 2023-09-22 11:59:25 +02:00
Elle Mouton
6310eedbfc
multi: init status manager
Initialise an instance of the status manager in LightningTerminal.
Register its gRPC and REST endpoints and also add its method to the set
of LiT whitelisted permissions.
2023-09-22 11:59:24 +02:00
Elle Mouton
d856616cec
rpc_proxy+itest: return uniform error for unhandled URI
Currently `basicAuthToMacaroon` returns a different error for an
un-handled URI than is returned for other funcions which first check the
permissions manager to see if a URI is handled. With this commit, we
ensure that the error returned is the same so that the error we assert
on in tests can just be one error.
2023-09-07 11:00:02 +02:00
Elle Mouton
29b11261b9
multi: implement BakeSuperMacaroon method 2023-06-20 08:10:54 +02:00
Elle Mouton
f725c3a959
rpc_proxy: check hasStarted before using lnd connection
In the rpcProxy `makeDirector` method, we need to check if the rpcProxy
has started before making use of the `lndConn`.
2023-05-03 11:01:17 +02:00
Elle Mouton
ba3193b341
rpc_proxy+subservers: error out of GetRemoteConn if not ready
Due to the rpcProxy being started early now, it could be the case that a
call is made to `GetRemoteConn` before the remote connection has
actually been set up. This commit catches this case so that an error can
be returned and a panic avoided.
2023-05-03 10:26:11 +02:00
Elle Mouton
05c5268405
multi: add ReadRemoteMacaroon method to subserver manager 2023-05-03 08:51:44 +02:00
Elle Mouton
9eb01518e6
multi: add MacaroonPath method to subserver manager 2023-05-02 11:49:02 +02:00
Elle Mouton
3ce40f54a1
rpc_proxy: remote subserver remote conn creation
Remove the code for creating remote connections to loop, faraday and
pool subservers from the rpcProxy. This is now handled by the subserver
manager.
2023-05-02 08:39:02 +02:00
positiveblue
c3bc9917fd
subservers: add uri handler helper funcs 2023-05-01 00:48:24 -07:00
Elle Mouton
37b24d59dd
multi: split out LND connection from rpcProxy
Remove the responsibility of creating an LND connection from the
rpcProxy and instead let the main LightningTerminal struct handle it.
All the lnd-connection specific functions are also moved into their own
file.
2023-05-01 00:15:56 -07:00
Elle Mouton
116322d72c
rpc_proxy: add hasStarted method to rpcProxy
Add a `started` variable to the rpcProxy that is used to indicate if the
proxy is ready to handle requests. This is because currently the
webserver is dependent on the rpcProxy to start and we want to be able
to start the webserver without being dependent on the rpcProxy so that
it can be used to handle status requests in a future commit. So with
this commit, we can now saftely start the webserver earlier on and then
if requests come through for the rpcProxy, an error will be displayed to
the user.
2023-05-01 00:15:53 -07:00
Elle Mouton
0ec95086a8
multi: add DisableUI option
Add a new `disableui` config option. If this option is set then the user
no longer needs to set the `uipassword` config option. This also means
that the user will no longer be able to interact with the local UI.
2023-03-17 11:16:22 +02:00
Elle Mouton
dbe62e074a
multi: add StopDaemon method to Lit
In this commit, a new Proxy service is added with a StopDaemon method.
This method can be used to stop the Litd service. This will be useful in
remote-mode itests where we want to restart Litd without also restarting
LND. It also provides a nice way of shutting down Litd in remote-mode.
A GetInfo method is also added to the service which for now just returns
the Litd version. The reason for adding this method now is so that
access to the new Proxy service can be tested in the itests withouth
actually shutting down Litd.
2023-03-17 11:14:24 +02:00
positiveblue
c267ef64eb
multi: update lnd dependency to v0.16.0-beta.rc3
- Bump lnd and other module dependencies.
- Bump Go build version & RPCs
- Refactor itests to use the new lnd itest framework.
2023-03-15 08:36:23 -07:00
Elle Mouton
d41f796f8e
multi: move permissions' manager to perms folder 2022-11-22 17:44:59 +07:00
Elle Mouton
c2eb98db38
multi: add PermissionsManager
In this commit, a new PermissionsManager is added. It handles all the
active permissions that Lit has access to. This moves us away from using
global variables for permission lists. This change might seem overkill
on its own but hugely simplifies the permission management once we add
lnd subserver permissions.
2022-09-01 13:04:06 +02:00
Elle Mouton
7a4d84a21b
cmd/litcli: use macaroon instead of ui password
Remove the use of the UI password from litcl. Use the litd macaroon
instead. Note, this means that in stateless mode, litcli won't have a
macaroon to use on disk and one must be baked specifically.
2022-06-07 11:46:02 +02:00
Elle Mouton
f011bc83ad
multi: validate macaroons for lit calls
Use the new macaroon service to verify LitURI calls.
2022-06-05 10:51:32 +02:00
Oliver Gugger
6104d9ed1f
terminal: register interceptors and RPC server to LNC
When a connection is tunneled through LNC the requests that go to the
daemons running in-process with LiT need to be registered correctly. To
make sure they are also authenticated, the RPC proxy's interceptors also
need to be registered on the LNC gRPC server instance.
But we don't want to allow calls to the LiT session server through LNC
until we have proper macaroon permissions set up for that server.
2022-02-17 16:35:55 +01:00
Oliver Gugger
a8309a9f0b
rpc_proxy: convert super macaroon into daemon mac
If a daemon is running in remote mode, we need to convert a super
macaroon into the daemon specific macaroon before sending it to the
remote daemon, since the super macaroon is issued by lnd and can only
be validated by lnd's macaroon root key.
2022-02-17 15:00:42 +01:00
Oliver Gugger
4e3cb101d5
rpc_proxy: store permission map, simplify interceptors 2022-02-17 15:00:41 +01:00
Oliver Gugger
5d4ae278ef
multi: add super mac validator to proxy 2022-02-17 15:00:41 +01:00
Oliver Gugger
43ed7ed27a
rpc_proxy+litcli: replace dummy string with empty macaroon
To avoid the macaroon parsing to fail in session.IsSuperMacaroon(), we
want the dummy macaroon to be formally valid (meaning, it can be parsed)
but not actually valid (meaning, it will fail the signature verification
since we don't have the root key for it anywhere).
2022-02-17 15:00:40 +01:00
Oliver Gugger
45e15c1bdc
rpc_proxy+terminal: fix error handling with stateless init
This is a follow-up commit that fixes an issue introduced with stateless
init where an error would be interpreted incorrectly.
2021-12-03 22:56:37 +01:00
Oliver Gugger
fadc09a00b
rpc_proxy: add new wrapped error type
To add more context to an error happening in the proxy, we add a wrapped
error type that adds more information about the origin of the error.
2021-12-03 22:56:35 +01:00
Oliver Gugger
b6c98ea3e1
multi: implement LiT gRPC server 2021-11-24 13:44:25 -05:00
Turtle
a25426d374
multi: bake super macaroon in integrated mode
In integrated mode we hook directly into lnd's bufconn listener for any
connections to it. So we don't need any TLS setup and can bake a single
super macaroon that is used for all RPC calls.
2021-11-23 15:28:29 +01:00
Oliver Gugger
0159e0a6a9
multi: add flag to enable REST calls on main listener(s)
Fixes #213 by allowing users to enable REST calls to be made directly to
the main HTTP(S) listener(s). This approach is chosen over spinning up
an additional listener (or multiple, if non-TLS is also needed) just for
REST because it should make everyone's lives easier if only one port
needs to be used. There also shouldn't be any security tradeoff since a
macaroon is still required and all communication happens over TLS
anyway.
2021-04-27 15:28:10 +02:00
Oliver Gugger
945fffe4ce
terminal+rpc_proxy: fix gRPC daemon calls in integrated mode
The call flow diagram wasn't accurate what lead to an incorrect
assumption in the last PR.
In integrated mode, lnd spins up its gRPC server as the main entry point
and the other daemons need to hook into it.
2021-02-26 15:41:14 +01:00
Oliver Gugger
977c63cd85
multi: use same order for daemons everywhere
This is a pure code-moving commit to use the same order of
faraday->loop->pool everywhere we handle the damons.
Only for consistency's sake.
2021-02-18 14:37:37 +01:00
Oliver Gugger
e52141e100
terminal: direct calls to remote daemons
If any of the daemons is configured to be running in remote mode, the
RPC proxy only acts as a gRPC web reverse proxy and just forwards any
requests to the correct backend.
For non-remote daemons the requests shouldn't get to the director in the
first place but instead be handled by the main gRPC server.
2021-02-18 14:37:37 +01:00
Oliver Gugger
71fb8e5e8f
rpc_proxy: prepare dialBackend to be more generic
As a preparation for using the dialBackend function for other
daemons/backends as well, we rename it from dialLnd and add a name
parameter for more specific logs.
2021-02-18 14:37:37 +01:00
Oliver Gugger
6e1803bdee
multi: remove unused error return value
There is no error case left in the lndConnectParams() method so we can
remove the error return type and simplify its use.
2021-02-16 13:39:31 +01:00
Oliver Gugger
d01636af92
multi: only use admin mac or allow single mac
With the new lndclient version we can specify a single, custom macaroon.
We use the admin macaroon as the custom macaroon in the remote
connection case which removes the need to copy all subserver macaroons
to the host where LiT is running. Users baking custom non-admin
macaroons can also specify that directly with a new configuration
option.
2021-01-27 10:28:50 +01:00
Oliver Gugger
26ac69a895
mod+terminal: add pool 2020-11-02 13:17:51 +01:00
Oliver Gugger
df71037904
terminal: extract RPC proxy
To make the purpose and the flow of the RPC proxy more easy to
understand, it is extracted into its own struct and cleaned up.
2020-10-12 15:28:04 +02:00