Commit graph

84 commits

Author SHA1 Message Date
Elle Mouton
fb5863e38c
multi: wait for lnd with a configurable timeout during SQL migration
The kvdb-to-SQL data migration polls lnd's ListMacaroonIDs RPC, which
only becomes available once lnd reaches its "RPC active" state. On
nodes with a large channel/graph state, lnd can take well over a
minute to get there after the wallet is unlocked, which exceeded the
previous fixed 60-second (120 x 500ms) poll budget and caused the
migration - and therefore litd startup - to fail permanently,
requiring a manual restart.

Replace the fixed attempt cap with a wait bounded by the new
--lndreadytimeout config option, defaulting to a generous 10 minutes,
while still aborting early if the daemon is shutting down. The wait
happens inside the migration's SQL write transaction, so it is kept
bounded rather than unbounded as a safety backstop.
2026-07-29 15:47:47 -07:00
cyberguru1
d3e51fac17
config: add super macaroon startup flags and path validation
Introduce configuration flags to enable baking a super macaroon on
startup. Add --bake-super-macaroon (none, read-only, read-write) and
--super-macaroon-path.

Also add validation logic to ensure that the configured super macaroon
path ends with the expected '.macaroon' suffix, rejecting startup early
otherwise.
2026-07-27 06:08:48 -05:00
Viktor Torstensson
3c035fe862
Merge pull request #1337 from 0xfandom/fix/1091-litd-version
Some checks failed
CI / frontend tests on macOS-latest (push) Has been cancelled
CI / frontend tests on ubuntu-latest (push) Has been cancelled
CI / frontend tests on windows-latest (push) Has been cancelled
CI / backend build on macOS-latest (push) Has been cancelled
CI / backend build on ubuntu-latest (push) Has been cancelled
CI / backend build on windows-latest (push) Has been cancelled
CI / cross compilation (push) Has been cancelled
CI / cross compilation-1 (push) Has been cancelled
CI / cross compilation-2 (push) Has been cancelled
CI / RPC proto compilation check (push) Has been cancelled
CI / check commits (push) Has been cancelled
CI / Sqlc check (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / run unit tests (push) Has been cancelled
CI / run unit tests-1 (push) Has been cancelled
CI / run unit tests-2 (push) Has been cancelled
CI / run unit tests-3 (push) Has been cancelled
CI / build itest binaries (push) Has been cancelled
CI / check release notes updated (push) Has been cancelled
CI / integration test (push) Has been cancelled
CI / integration test-1 (push) Has been cancelled
CI / integration test-2 (push) Has been cancelled
config: make litd -V report litd version
2026-07-08 19:33:35 +02:00
0xfandom
bcdbe68fa1 config: make litd -V report litd's own version
The `-V` flag inherited from lnd printed the integrated lnd version
(`build.Version()`) instead of litd's own version, while litd's own
`--version` flag already reported the correct value via RichVersion().
Consolidate both flags so either one prints litd's version.

Fixes #1091

Signed-off-by: 0xfandom <kashyapshivank01@gmail.com>
2026-06-30 11:59:39 +05:30
Viktor Torstensson
42c3105537
terminal: thread a context into postgresDatabaseExists 2026-06-16 21:45:47 +02:00
Viktor Torstensson
6d2bf233e8
config: block startup on mixed SQL backends
Reject `litd` startup when another SQL database exists than the selected
SQL `databasebackend` choice.

When starting with the `databasebackend` config flag set to `postgres`,
we check whether an `sqlite` database file exists at the default path
and fail startup if it does. When starting with `sqlite`, we instead
check whether `postgres` database configuration has been provided and,
if so, whether a database exists at the configured `postgres`
connection parameters.

This prevents accidental switches between SQL backends. This is
especially important because allowing such a switch would retrigger the
KVDB-to-SQL migration for the newly configured SQL backend. In that
scenario, the data would already have been migrated previously, meaning
the migration source would be stale and could result in outdated data
being imported. Additionally, it would create two divergent copies of
the data across separate SQL backends. Since we do not support
migrations between SQL backends, recovering from such a situation would
not be possible.
2026-06-16 21:45:47 +02:00
Viktor Torstensson
371d22ad8e
terminal: enable skipping migration prompt
Add a config option and env variable which allows users to skip the
migration confirmation prompt. This is useful for users who which are
running in a non-interactive environment, and does not have access to
pass input to stdin.
2026-06-08 21:11:51 +02:00
Viktor Torstensson
d1cc192434
multi: ensure kvdb -> SQL mig uses correct db folders
The kvdb accounts db is specifically set to be created in the same
folder as the macaroon path, while the sessions and rules db are created
in the network folder.

That means that users which have set a custom macaroon path, can have
an accounts db in a separate folder than the sessions and rules db.
In order to ensure that the migration from kvdb to SQL uses the correct
db folders, we need to make sure that the migration code uses the same
logic as the creation of the db logic.
2026-06-08 11:23:59 +02:00
Viktor Torstensson
93f6aa9e2c
terminal: add db config nil checks 2026-06-08 11:23:59 +02:00
Viktor Torstensson
b09fd2852a
terminal: create sqlite db directory from configured path
Create the SQLite database directory from
c.Sqlite.DatabaseFileName instead of the generic network directory.

This ensures startup uses the final validated SQLite path, including
cases where loadAndValidateConfig has already overridden the
database file location to point at the correct network-specific
directory.
2026-06-08 11:23:59 +02:00
Viktor Torstensson
a1283e3353
terminal: register SQL store cleanup before migrations
Move the SQLite and Postgres BaseDB close handlers to immediately
after the SQL store is created.

This ensures the cleanup function is registered even if the
subsequent migration or store initialization steps fail, avoiding
leaked SQL handles on early returns.
2026-06-08 11:23:59 +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
68718a5c59
multi: Don't backup Sqlite database file on mig
As the SQL migrations prior to the kvdb to SQL migration was never live
in production, we can safely assume that the sql database is empty prior
to the kvdb to sql migration.

Therefore, it is not necessary that we create an backup of the sqlite
database for every migration that exists for the time being.
As the sqldb/v2 intentionally doesn't delete the backup file when a
migration has been completed (as this is intentional behaviour for tapd)
and the package so far doesn't support any option to delete the backup
file, this otherwise creates multiple unnecessary backup files for
users.

Once the sqldb/v2 does support making deletion of the backup file
possible, or once we add another sql migration, we need to toggle the
backup behaviour for the sql migrations on again.
2026-06-08 11:23:58 +02:00
Viktor Torstensson
d59e75514b
terminal: Make sqlite the default db backend
Change the default database backend from bbolt to SQLite now that SQL
backends are exposed through the main configuration path.

This will trigger the kvdb to SQL migration automatically for users who
have not specifically set their database backend to bbolt.

Note that once the kvdb to sql migration is complete, the user's bbolt
database will be tombstoned.
2026-06-08 11:23:58 +02:00
Viktor Torstensson
aabf8b08e9
terminal: remove DevConfig.Validate params
As the `DevConfig.Validate` params are no longer used in the Validate
method, we can remove them from the method signature.
2026-06-08 11:23:58 +02:00
Viktor Torstensson
66e9d3c46d
terminal: move databasebackend option to Config
Move the database backend selection from the `dev` config file into the
main `Config` struct, i.e. into production.

This will enable an sql database backend to be used in production.
2026-06-08 11:23:58 +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
Bob Smith
2685477b45
config: add testnet4 network option 2025-07-30 13:08:06 -04: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
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
7a091fc773
config: introduce the concept of DevConfig
In this commit, we introduce a DevConfig struct which is embedded in the
main lit Config struct. It is defined in two separate files that are
made mutually exclusive using the `dev` build tag. The idea of this
struct is that it allows us to expose additional config options to LiT
if we build in a development environment such as our itests. In other
words, we will be able to start developing features and testing them
before making them available to users via the production build.

As of this commit, both implementations of the struct are the same.
2025-02-21 11:17:21 -03:00
Elle Mouton
a22689ce16
golangci: enable line length linter 2025-02-13 15:50:48 +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
Oliver Gugger
a027e4051d
litd: register tapd as aux component of lnd
This commit represents the main integration between lnd running in
integrated mode and tapd providing auxiliary components for custom
channels.
2024-12-19 21:21:38 +01:00
Elle Mouton
e5e97f6708
config: add signet network option 2024-11-19 09:12:57 +02:00
Oliver Gugger
ab137035c6
docs: move previous item to correct category 2024-11-08 10:29:15 +01:00
Oliver Gugger
8790d3b3e2
config+terminal: allow configuring of lnd RPC timeout 2024-11-08 10:29:15 +01:00
Oliver Gugger
05fc878191
config: disable internal GRPC logger by default
The GRPC connection logger is very verbose and normally not very useful.
So it leads to more confusion and unnecessary log bloat than it actually
helps to debug things.
So we disable it by default, meaning that if GRPC=<level> doesn't appear
in the log level config string, we add GRPC=off.
That means we can still manually turn it on by adding ,GRPC=info to the
log config (e.g. --lnd.debuglevel=debug,GRPC=info).
2024-11-07 10:20:11 +01:00
Elle Mouton
2fc07fffee
lit: add a statelessInit bool in the config
So that it is easy to check elsewhere if we are in this mode.
2024-10-14 15:48:18 +02:00
Elle Mouton
2669c87f98
config: add version flag
This commit adds a new '--version' flag to litd.
2024-08-28 15:32:34 +02:00
Oliver Gugger
d627a2826d
config: update description of --httpslisten flag
Fixes #798 by specifying what is running on the main litd HTTPS port.
2024-07-18 13:02:21 +02:00
Viktor Tigerström
064bcd2488
terminal: add tlsextraip & tlsextradomain to conf
This commit adds the `tlsextraip` and `tlsextradomain` config fields to
the LiT config. This allows users to specify additional IPs and domains
to be included in the TLS certificate.
2024-06-24 23:59:03 +02:00
jamaljsr
cdbf3f70fc
config: allow taproot-assets-mode to be remote 2023-10-19 13:32:32 -05:00
Viktor Tigerström
c06a9579b7
multi: bump taproot-assets, loop & LNC
Bump taproot-assets to version `v0.3.0-alpha` and loop to `v0.26.4-beta`
and lightning-node-connect to `v0.2.7-alpha`.
2023-10-18 18:45:17 +02:00
Viktor Tigerström
20fa2c0915
terminal: add disable accounts service cfg option 2023-09-28 13:09:33 +02:00
Elle Mouton
fb7f313c80
multi: add "disable" mode for all subservers
Just like for the Taproot Assets subserver, we add the option to disable
the Loop, Pool and Faraday subservers.
2023-09-22 11:55:16 +02:00
Elle Mouton
c2e34d7138
config: fix macaroon path construction
Fix the macaroon path construction so that even if the network is not
mainnet, the path gets constructed correctly from a user specified
"--lit.dir" flag.
2023-07-17 10:55:30 +02:00
positiveblue
8e469d89d0
config: run taproot assets subserver by default
By default the taproot assets subserver will start in integrated mode
like the rest of subservers. An execption is if we are running in
"mainnet" where we want it disabled because it is not yet supported.

Users won't be able to start the sub-server in "mainnet" even if they
set the `--taproot-assets-mode=` flag.
2023-05-16 17:00:20 +02:00
positiveblue
219a9ccb85
multi: new disable mode for the taproot assets subserver
Enable to start litd with taproot asset subserver disabled.
The default mode for the new sub-server is "Disabled"
Add coverage in itests for flows with some subservers disabled (based on
Elle's #537)
2023-05-16 17:00:19 +02:00
positiveblue
4be6ffb31f
multi: Add Taproot Assets subserver 2023-05-16 16:59:28 +02:00
Elle Mouton
daab70c040
config: register subserver loggers before validation
Ensure that all of Lit's subserver loggers have been registered _before_
the config is validated. This will allow users to use the
`--lnd.debuglevel` flag to set Lit specific subserever logger levels.
2023-05-03 08:51:45 +02:00
Elle Mouton
d02749a5a1
subservers: add new package to manage the lit subservers 2023-05-01 00:15:56 -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
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
2c25ba48ca
multi: always use Lit's TLS cert
In this commit, we remove Lit's dependency on LND's tls cert in
integrated mode. With this commit, even if Lit is started in integrated
mode, it will create its own tls cert to use for serving the webserver.
2023-02-23 07:35:22 -08:00
Elle Mouton
8e61eb90da
multi: make request logger level configurable 2023-02-13 19:33:55 +02:00
Elle Mouton
683cdbd566
terminal: init the autopilot client 2023-01-27 06:47:13 +02:00
Oliver Gugger
c3cad46aa2
multi: fix linter issues 2022-10-19 10:57:18 +02:00
Oliver Gugger
1e8baeef13
multi: use filepath instead of path to work on Windows
This commit fixes an issue with file system paths on Windows. The path
package is only intended to be used with URIs or non file system paths.
For anything OS dependent, filepath should be used instead.
2022-10-13 14:07:41 +02:00