Commit graph

185 commits

Author SHA1 Message Date
bitromortac
c478f8227a terminal: gate wallet-ready status on lnd's actual RPC readiness
readyChan/unlockChan only guarantee lnd's gRPC listener socket is bound,
not that lnd's RPC interceptor has left WAITING_TO_START. Callers that
poll litd's status (itest's WaitForLNDWalletReady, litcli status, the UI)
could observe "Wallet Ready" and then immediately hit a "waiting to
start, RPC services not available" error, which was the root cause of a
flake in TestLightningTerminal/.../terminal_stateless_init_mode (CI run
29286599979, PR #1322). Poll lnd's StateService, which is exempt from
both the macaroon and RPC-readiness checks, until it reports leaving
WAITING_TO_START before advertising the wallet as ready.
2026-07-16 09:53:44 +00:00
Viktor Torstensson
edbd4f51b4
Merge pull request #1330 from ViktorT-11/2026-06-stop-lnd-on-mig-prompt-abort
[sql-77] terminal: shut down LiT when declining the SQL migration prompt
2026-06-17 00:44:44 +02:00
Viktor Torstensson
42c3105537
terminal: thread a context into postgresDatabaseExists 2026-06-16 21:45:47 +02:00
Viktor Torstensson
d9b8d6d4b8
terminal: shut down on declined SQL migration
Treat a declined kvdb-to-SQL migration prompt as a startup-abort
condition that shuts litd down fully. This prevents litd from leaving
the status server running after the operator refuses the migration
prompt.

The reason why this is motivated, is that `litd` at this stage of the
startup process will not be ready to handle an `litcli stop` RPC call.
2026-06-16 20:49:23 +02:00
Viktor Torstensson
9016bbb3d2
multi: confirm kvdb migration at startup
Prompt before automatically migrating legacy kvdb state to SQL when
litd starts with a SQL backend and active bbolt data is still present.

Detect prior migrations by checking for the SQL tombstone marker so
already-migrated stores can start without prompting. Add unit coverage
for the prompt flow and wire stdin through the itest harness so the
migration restart path can acknowledge the prompt automatically.
2026-06-08 21:11:51 +02:00
Viktor Torstensson
3da4a600fa
terminal: add NewStores to the Config struct
Make the `NewStores` function into a struct member of the `Config`
struct, as the choice of database backend is now part of the production
configuration.
2026-06-08 11:23:59 +02:00
Viktor Torstensson
f90f468a32
multi: add dev kvdb to sql code migration
Add the necessary code to trigger the kvdb to sql code migration in dev
builds.
2026-05-14 11:38:35 +02:00
Viktor Torstensson
51f33086be
firewall: add request logger disable flag
This introduces a new firewall.request-logger.disable config option to
completely disable request logging. When disabled, the request logger
interceptor is not instantiated, avoiding all logging overhead including
database writes and request processing.

This is implemented as a separate disable flag rather than adding a new
log level because the goal is to bypass the logging system entirely for
performance reasons, not just filter events. A log level would still
process and filter each request through the interceptor.

The change also adds validation to ensure autopilot remains enabled only
when request logging is active, since autopilot relies on action logs
for rule enforcement and auditing.
2026-02-12 17:14:01 +01:00
ffranr
a0e63124c0
multi: reformat long lines for readability
- Replace occurrences of `// nolint:lll` with `// nolint:ll` across
  files for consistency.
- Reformat multiline strings, comments, and function parameters to
  improve clarity and adhere to style guidelines.
- Add `// nolint:ll` comments where necessary to prevent linter
  warnings.
2025-12-09 16:12:03 +00:00
Boris Nagaev
ed3a247e65
terminal: use BlockUntilChainNotifier 2025-11-14 14:47:04 -03:00
George Tsagkarelis
537ed05776
build: bump lnd, lndclient, tapd, loop 2025-10-15 11:07:21 +02:00
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
3700cb4542
terminal: separate basic and full LND client setup
In the upcoming actions migration, we will need to fetch LND's macaroons
prior creating litd's stores, and therefore we need to connect to LND
prior to creating the stores.

To avoid having to wait for LND to fully sync before creating the stores
(and, by extension, Litd's RPC servers), we separate the basic LND
client setup from the full LND client setup. Only the full setup
requires a fully synced LND.
2025-09-01 10:30:20 +02:00
Viktor Tigerström
a779761f5c
terminal: setup LND prior to stores
In the upcoming actions migration, we need fetch LNDs macaroons prior to
initializing the stores, as the macaroons will be required during the
migration.

This requires that we setup the connection to LND before we initialize
the stores, as we can only fetch the macaroons after the LND connection
is established.

This commit refactors the litd startup process, so that the stores are
initialized after the LND connection is established.
2025-09-01 10:30:19 +02:00
Viktor Tigerström
9e9140e197
terminal: separate session RPC server init & start
Similar to how the previous commit separated the initialization and
starting of the account RPC server, this commit separates the
initialization and starting of the sessions RPC server.
2025-09-01 10:30:19 +02:00
Viktor Tigerström
d52b4565f2
multi: separate account RPC server init & start
In the upcoming actions migration, we need fetch LNDs macaroons prior to
initializing the stores, as the macaroons will be required during the
migration.

This requires that we setup the connection to LND before we initialize
the stores, as we can only fetch the macaroons after the LND connection
is established.

In preparation of doing so, we cannot reference the stores when
initializing/creating the accounts RPC server object, as we do so prior
to setting up the LND connection.

This commit therefore refactors the accounts RPC server so that we
separate the initializing from the starting of the RPC server, and only
require the store reference during the actual startup of the RPC server.

Note that we still keep the init of the accounts RPC server reference
prior to setting up the LND connection, as not doing so would require
that we'd refactor the registering of `GrpcSubserver`s in a more complex
and in a less elegant way.
2025-09-01 10:30:19 +02:00
Viktor Tigerström
a79187f84e
terminal: add clarifying comment for LND startup
As it's quite confusing by just looking at `litd` codebase that LND will
execute `litd`'s `RegisterGrpcSubserver` function during the setup of
the LND connection, we add a comment to clarify this.
2025-08-21 16:33:37 +02:00
Elle Mouton
89b807c3bb
lit: plug the SQL actions DB into the dev build 2025-05-30 10:57:00 +02:00
Oliver Gugger
02f9160ba1
terminal: bump lnd minimum version to v0.19.0-beta 2025-05-21 19:25:30 +02:00
Elle
329b939aa6
Merge pull request #1034 from ViktorTigerstrom/2025-04-include-commit-hash
Add `commit_hash`  field to `GetInfo` response
2025-05-16 12:26:02 +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
c1ee884626
multi: let most ActionDB methods take a context 2025-05-09 16:16:34 +02:00
Elle Mouton
b9ad66471d
multi+refactor: remove unnecessary type alias
Remove the `NewPrivacyMapDB` type alias. It is not needed.
2025-04-22 06:10:48 +02:00
Elle Mouton
c7e82b55c6
firewalldb+lit: plug in SQL privacy mapper 2025-04-22 06:10:48 +02:00
Viktor Tigerström
2d3efee7df
multi: expose Proxy service over LNC
Previously, the `Proxy` service was not accessible over LNC, as we did
not want to expose the `stop` and `bakesupermacaroon` endpoints over
LNC. This also meant that the `getinfo` endpoint was not accessible over
LNC. As we now have demand to expose the `getinfo` endpoint over LNC, we
have decided to expose the `Proxy` service over LNC, and let the user
fine-tune the access to the `stop` and `bakesupermacaroon` endpoints
via the macaroon for the LNC session instead.
2025-04-11 20:03:35 +02:00
Elle Mouton
71718e8868
lit: make sure to always close stores on errored start-up
Ensure that if any store init in the `stores` struct creation fails,
then any successful stores are still closed during shutdown.
2025-04-03 16:27:02 +02:00
Elle Mouton
261c547622
firewalldb: add DB struct and Start/Stop methods
In this commit, we add a `DB` struct in the `firewalldb` package. This
struct will be responsible for housing abstract implementations of the
various stores in the `firewalldb`. For now, we start with just the
RulesDB. We also add Start&Stop methods for the struct in preparation
for future additions here - for now, these do nothing.

In the main LiT setup, we move the firewall.BoltDB and the new
firewalldb.DB to the `stores` struct and implement them in the two
`config_` files. For now, both varients create the Bbolt version of the
firewallDB and this is used to init the `firewalldb.DB` struct. This
will be changed in future commits where we will add a sql
implementation.
2025-04-03 09:02:47 +02:00
Elle Mouton
5026e66e7c
firewalldb: rename DB to BoltDB
In preparation for a db-backend agnostic DB struct along with a SQL
implementation of the various stores in the package which will be housed
under a struct named `SQLDB`.
2025-04-03 09:02:47 +02:00
George Tsagkarelis
443b5f4170
Merge pull request #998 from lightninglabs/lnd-19
multi: update LiT and all deps to use LND 0.19
2025-03-26 18:29:21 +01:00
Elle Mouton
dbec9da31b
multi: update LND and friends
This commit updates:
- LND
- pool
- loop
- taproot-assets
- faraday
- lighting-node-connect
- aperture
- lndclient
- btclog

We start using the new btclog v2 library and the associated breaking
changes in the lnd/build package.

With this commit, we deprecate the `--remote.lit-maxlogfiles` and
`--remote.lit-maxlogfilesize` options and introduce new logging options
under the `--remote.lit-logging` namespace.

Finally, the LND update introduced a new `MaxBlocksMinedPerTest`
variable in the `lntest` package that we now need to override in order
for our itests to pass.
2025-03-26 09:20:52 -05:00
Elle Mouton
6dbf880341
multi: plug in sessions SQL DB
Let LiTd support a SQL db for the sessions store under the `dev` build
tag. This can be used via itests.
2025-03-25 16:58:02 +02:00
Elle Mouton
2717aa0bc2
session+terminal: give session Store access to the accounts store
When we link a session to an account, we want to be able to validate
that the account actually does exist. So in preparation for that, we
first give the session store access to the accounts store.
2025-03-04 13:43:13 +02:00
Elle Mouton
b6891b4b38
itest: run itests against chosen backend
Add the ability to specify the db backend to run use for accounts when
running itests.

With this commit, you can run something like: `make itest
dbbackend=sqlite`.
2025-02-21 11:18:35 -03:00
Elle Mouton
8c4d17c6d8
session: add a clock to the DB 2025-02-11 19:22:07 +02:00
Elle
c0e85e0f24
Merge pull request #968 from ellemouton/sql10Sessions2
[sql-10] sessions: decouple super macaroon helpers from `sessions` package
2025-02-11 19:10:32 +02:00
Elle Mouton
29f6db7de6
lit: use db.Store interface instead of raw DB pointer
Give the sessionRpcServer access to the session store via the
session.Store interface instead of the raw DB pointer. This will make it
possible to swop out the implementation (which is currently bbolt) with
something else such as a SQL implementation. We move the responsibility
of closing the DB to the main LiT server.
2025-02-11 13:11:55 +02:00
Elle Mouton
4d22dfb7e9
multi: refactor to not use session.MacaroonRecipe outside the package
In this commit, we refactor various uses of the session.MacaroonRecipe
type outside of the session package. This is to decouple the baking of a
super macaroon from the sessions package and will help avoid import
cycles in future.
2025-02-09 10:45:10 +02:00
Elle Mouton
832fbad1c5
lit+macaroons: move BakeSuperMacaroons helper
Move this helper to the new macaroons package.
2025-02-09 10:39:51 +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
88e4f2e5ed
session: rename DB to BoltStore
To better reflect the DB backing the CRUD and to prepare for a new
`SQLStore` type.
2025-02-09 07:01:11 +02:00
Oliver Gugger
9faa4a8388
terminal: bump minimum lnd version to v0.18.5-beta
Before, this minimum version was driven by tapd. But we should keep the
minimum required version up to date in litd as well.
2025-01-30 09:41:49 +01:00
Elle Mouton
42a4c826cf
accounts: use clock.Clock
In this commit, we use the clock.Clock type instead of directly calling
time.Now().
2025-01-23 08:24:21 +02:00
Elle Mouton
82eeadd819
accounts: pass Store impl to NewService
We want to be able to pass different DB implementations to NewService.
In preparation for this, we make it implementation agnostic by letting
it take a `Store` instead of constructing one itself.

This this change, we also let LiT handle the closing of the accounts
Store instead of the accounts service
2025-01-16 09:19:04 +02:00
Elle Mouton
0407505e6c
autopilotserver: thread context through 2025-01-13 09:29:43 +02:00
Elle Mouton
1a30bdb83a
accounts: thread context through to accounts 2025-01-13 09:29:29 +02:00
Elle Mouton
83a3209a32
rpcmiddleware: thread context through to Start 2025-01-13 09:29:22 +02:00
Elle Mouton
0503cfd433
session_rpcsever: thread context through 2025-01-13 07:03:28 +02:00
Elle Mouton
1fc0e6f16d
terminal: use ctx instead of interceptor 2025-01-13 07:03:28 +02:00
Elle Mouton
db45e3afe3
terminal: thread one context through 2025-01-13 06:53:02 +02:00
Oliver Gugger
3f9a63876a
litd: allow faster startup by making re-try configurable
This change will speed up integration tests by not waiting a full 5
seconds before re-trying the connection to lnd if it fails the first
time.
2024-12-19 21:21:39 +01:00