Commit graph

3 commits

Author SHA1 Message Date
sputn1ck
43df8e2d7d scripting: fix LND RPC authentication using lndclient wrappers
This commit fixes LND RPC authentication by switching from raw gRPC
clients to lndclient wrappers that provide proper macaroon authentication.

Changes:
- Update LNDClients to use lndclient.LightningClient and
  lndclient.RouterClient instead of raw gRPC clients
- Add getRawLightningClient() and getRawRouterClient() helpers that use
  RawClientWithMacAuth() for authenticated raw client access
- Update all 21 LND builtin methods to use the new pattern
- Add InMemoryStore implementation for testing
- Wire up LND clients in terminal.go after LND connects
- Fix integration test function signatures

All 7 scripts integration tests now pass:
- scripts_basic_crud
- scripts_validation
- scripts_execution
- scripts_kv_store
- scripts_lnd_access
- scripts_builtins
- scripts_kv_builtins
2026-01-30 23:28:52 +01:00
sputn1ck
7b9c2419e7 scripting: add LND RPC bindings and integration tests
This commit adds:

1. LND RPC bindings (scripting/builtins_lnd.go):
   - get_info, get_node_info
   - list_channels, channel_balance, pending_channels, closed_channels
   - update_channel_policy
   - wallet_balance, list_unspent, new_address, send_coins
   - add_invoice, lookup_invoice, list_invoices, decode_pay_req
   - send_payment, list_payments
   - list_peers, connect_peer, disconnect_peer
   - forwarding_history, estimate_fee

2. Integration tests (itest/litd_scripts_test.go):
   - testScriptBasicCRUD: Tests create, read, update, delete operations
   - testScriptValidation: Tests script syntax validation
   - testScriptExecution: Tests script execution with arguments
   - testScriptKVStore: Tests KV store RPC operations
   - testScriptWithLNDAccess: Tests scripts calling LND RPCs
   - testScriptBuiltins: Tests standard builtins (now, json_encode, etc.)
   - testScriptWithKVBuiltins: Tests KV builtins from scripts

3. Test registration in litd_test_list_on_test.go
2026-01-30 23:28:52 +01:00
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