Commit graph

54 commits

Author SHA1 Message Date
sputn1ck
5cf25ca624 scripting: add Starlark scripting system for LiT automation
This commit introduces a comprehensive Starlark scripting system that
enables custom automation with access to all subdaemon RPCs (lnd, loop,
pool, faraday, taproot-assets). Scripts use native LND macaroons for
permission enforcement.

Key features:
- Starlark execution engine with sandboxed resource limits
- Standard builtins: print, log, sleep, now, json_encode/decode
- HTTP GET requests with URL allowlisting
- Persistent KV store with bucket-based permissions
- LND event subscriptions for long-running daemon scripts
- Script CRUD operations with macaroon baking
- Execution history and running script tracking
- Complete CLI commands (litcli scripts ...)

Database schema:
- scripts: Store script definitions with macaroon permissions
- script_executions: Audit trail for script runs
- script_kv_store: Persistent key-value storage for scripts
- running_scripts: Track currently running scripts

Security model:
- Each script has an LND macaroon baked with specific permissions
- RPC calls from scripts include this macaroon in the header
- LND/subdaemons validate permissions natively
- URL and bucket allowlists validated at runtime
2026-01-30 23:28:52 +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
George Tsagkarelis
dd90147d63
litcli: update payinvoice for multirfq
With the introduction of multi-rfq send in taproot assets (see related
PR https://github.com/lightninglabs/taproot-assets/pull/1613) we
extended the behavior of the SendPayment RPC slightly.

Now we may not specify an RFQ peer in order for a list of peers to be
created & used automatically. When that happens, we will return multiple
quotes over the RPC.

The content of this commit changes our client wrapper around the
handling of the payment result. Previously we'd expect for exactly a
single quote to be returned over the stream (for the single defined
peer). Now we read all of the quotes that are returned in the new quotes
array field of the RPC. To maintain backwards compatibility we also kept
the previous single-quote RPC field, which we make sure to only read
once now that we read both fields (avoid a duplicate quote from
appearing in the logs).
2025-10-30 10:52:45 +01:00
George Tsagkarelis
a2625731d0
litcli: update description for rfq pubkey field
With the latest version of tapd we no longer require the rfq field to be
set. If left unset then AddInvoice/SendPayment will automatically
acquire quotes in order for the operation to be carried out.
2025-10-30 10:51:01 +01:00
Oliver Gugger
d3e9d2782c
cmd/litcli: add payment flags back
Some flags that didn't make sense were removed when cleaning up the
keysend usecase, but some of them are still useful and we add them back.
2025-06-05 16:34:43 +02:00
George Tsagkarelis
17ab5e21dd
cmd: ln addinvoice supports sat/msat amount 2025-05-20 13:03:52 +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
Oliver Gugger
04381c6484
cmd: add --group_key CLI flag to all channel commands 2025-05-15 12:01:57 +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
Oliver Gugger
33bc532ce0
mod+subservers: use taprpc module 2025-05-02 11:05:12 +02:00
Elle
9e5578cf2d
Merge pull request #974 from ViktorTigerstrom/2025-02-credit-debit-accounts-impl
accounts: Add credit and debit account functionality
2025-04-01 13:13:43 +02:00
Viktor Tigerström
0c520cef18
multi: add accounts u --new_balance deprecation
This commit adds a deprecation notice regarding the
`accounts update --new_balance` flag. This flag will be removed in the
next major release of lit.
2025-03-31 02:45:53 +02:00
Viktor Tigerström
5a02019161
litcli: add accounts credit & debit commands
This commit implements the `credit` and `debit` commands in `litcli`,
allowing users to increase or decrease the balance of an existing
off-chain account, respectively.
2025-03-31 02:18:57 +02:00
gcaracuel
b2f2ea048a
litcli: Global flags to accept ENV vars overrides. 2025-03-24 09:23:14 +01: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
76250ca835
litcli: use cancellable contexts
In this commit, we use the signal.Interceptor to cancel the contexts we
use for our CLI calls.
2025-01-13 09:29:53 +02:00
Oliver Gugger
7ed8ff1a39
cmd/litcli: add ln sub commands for custom channels 2024-12-19 21:21:39 +01:00
Elle Mouton
b4f8224c54
multi: use ReadOnly param of BakeSuperMacaroon 2024-10-14 15:48:18 +02:00
bitromortac
c352fa08bd
litcli: add privacy flags to feature registration
Adds support for overriding defaul privacy flags for non-default feature
configurations.
2024-04-25 14:49:47 +02:00
Viktor Tigerström
6bc86e5425
Merge pull request #634 from bitromortac/per-feature-restrictions
autopilot: generic rules per feature
2024-02-12 15:54:32 +01:00
bitromortac
34eeb2ae05
litcli: session registration with generic rules
This commit adds generic feature rule flags. Legacy flags
`channel-restrict-list` and `peer-restrict-list` are deprecated.
2024-02-07 12:52:01 +01:00
Viktor Tigerström
e5737436cd
accounts + main: allow new accounts with 0 balance 2024-02-01 11:22:08 +02:00
Oliver Gugger
d3413ae637
accounts+cmd/litcli: fix formatting 2024-01-03 11:14:51 +01:00
Brian
c39cd3cde9
main: make cmd documentation coherent 2023-10-31 07:07:15 -06:00
Oliver Gugger
322a96133d
multi: fix linter issues 2023-10-03 19:52:02 +02:00
Oliver Gugger
b3c0d0e9b1
multi: bump lnd to v0.17.0-beta 2023-10-03 19:51:57 +02:00
Elle Mouton
4e2ec08767
cmd/litcli: commands for status server
Note that the client connection for these commands does not require a
macaroon.
2023-09-22 11:59:25 +02:00
Elle Mouton
143876d1ec
litcli: prepare for a client connection without a macaroon
In preparation for an upcoming commit where litcli commands for the
Status server are added, the `getClientConn` method is updated with a
`noMac` parameter. If true, them the connection will be made without a
macaroon.
2023-09-22 11:59:24 +02:00
bitromortac
6e30ecaa69
litcli+rpcserver: session registration with config
We add command line flags to litcli in order to be able to submit
feature configurations when registering a session.
2023-09-01 08:03:21 +02:00
Elle Mouton
5882a21df8
multi: allow client to link autopilot sessions 2023-08-30 12:34:29 +02:00
Elle Mouton
60c10bd91d
multi: use group ID for PrivacyMapConversion query 2023-08-30 12:34:29 +02:00
Elle Mouton
bd9a99c5d4
multi: allow querying actions by group ID 2023-08-30 12:34:29 +02:00
Oliver Gugger
cbc0e819c5
cmd/litcli: update account CLI with label changes 2023-07-26 18:37:49 +02:00
Elle Mouton
ec77c5483d
cmd/litcli: add bakesupermacaroon command 2023-06-20 08:10:54 +02:00
Elle Mouton
c5dc10ccab
cmd/litcli: add super macaroon helper commands
In this commit, a `supermacrootkey` helper command is added which lets a
user generate a random root key ID for a super macaroon along with an
`issupermacaroon` command that allows a users to easily confirm if a
macaroon is considered a super macaroon or not. Neither of these
commands require a connection to LiTd.
2023-06-20 08:10:53 +02:00
Elle Mouton
de3e492d41
cmd/litcli: improve autopilot docs and add list command 2023-03-20 12:14:24 +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
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
d3cab70928
cmd/litcli: create account sessions
Create LNC account sessions through litcli
2023-02-13 19:33:55 +02:00
Elle Mouton
ab347dd6f1
multi: add privacy mapper conversion helper 2023-01-27 06:47:13 +02:00
Elle Mouton
6de34a89e2
litcli: add lit-autopilot commands 2023-01-27 06:47:13 +02:00
Elle Mouton
164ade0e8c
multi: expose Actions
This commit adds a Lit grpc service and uses it to expose a ListActions
method. Litcli is also updated to make use of this method.
2023-01-27 06:47:12 +02:00
Oliver Gugger
c7fb004378
cmd/litcli: add account commands 2022-12-02 10:06:51 +01:00
Elle Mouton
15cd1bdef9
multi: support regex URIs
With this commit, a user can now specify a regex when specifying custom
permissions for an LNC session. This regex will be used to select
permissions for URIs that match the regex.
2022-11-29 12:32:14 +02:00
Elle Mouton
61792bf8db
litcli: update to allow for custom URI list 2022-10-26 12:59:28 +02:00
Oliver Gugger
a144cfea63
cmd/litcli: refactor client conn
As a preparation to add more litd specific RPCs, we refactor the client
connection to use the generic interface instead of a specific type.
2022-10-19 10:57:17 +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
bcf80064d4
cmd/litcli: fix tls cert path
Currently, if in lnd-remote mode, the tls cert path will be constructed
to be in the network directory which it should not be.
2022-06-05 10:51:31 +02:00
Elle Mouton
ee25096bff
litcli: add app version 2022-04-19 20:41:51 +02:00
Oliver Gugger
a37b56393e
cmd/litcli: change default session expiry to 3 months
The default expiry of one hour was way too short for anything practical
and we increase it to 90 days which is almost three months.
The user can still override this value manually by specifying the flag.
2022-02-23 09:48:50 +01:00