|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +LDK Server is a Lightning Network node daemon built on LDK Node, exposing a REST API via Protocol Buffers with TLS and HMAC-based API key authentication. |
| 8 | + |
| 9 | +## Build Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +cargo build # Build all crates |
| 13 | +cargo build --release # Production build (LTO enabled) |
| 14 | +cargo test # Run all tests |
| 15 | +cargo test --all-features # Run tests with all features |
| 16 | +cargo fmt --all # Format code |
| 17 | +cargo fmt --all -- --check # Check formatting |
| 18 | +cargo clippy --all-features -- -D warnings # Lint (CI uses this on MSRV) |
| 19 | +RUSTFLAGS="--cfg genproto" cargo build -p ldk-server-protos # Regenerate protobuf files |
| 20 | +``` |
| 21 | + |
| 22 | +## Running |
| 23 | + |
| 24 | +```bash |
| 25 | +cargo run --bin ldk-server ./ldk-server/ldk-server-config.toml |
| 26 | +``` |
| 27 | + |
| 28 | +## Workspace Structure |
| 29 | + |
| 30 | +- **ldk-server** - Main daemon server (entry point: `src/main.rs`) |
| 31 | +- **ldk-server-cli** - CLI client using clap |
| 32 | +- **ldk-server-client** - Reqwest-based client library |
| 33 | +- **ldk-server-protos** - Protocol buffer definitions and generated Rust code |
| 34 | + |
| 35 | +## Architecture |
| 36 | + |
| 37 | +**Key Components:** |
| 38 | +- `ldk-server/src/service.rs` - HTTP service with HMAC authentication |
| 39 | +- `ldk-server/src/api/` - Individual endpoint handlers (bolt11_send, open_channel, etc.) |
| 40 | +- `ldk-server/src/io/persist/` - SQLite-based persistence with pagination |
| 41 | +- `ldk-server/src/io/events/` - Event publishing (Noop or RabbitMQ) |
| 42 | +- `ldk-server/src/util/` - Config parsing, TLS, logging, proto adapters |
| 43 | + |
| 44 | +**Protocol Buffers:** |
| 45 | +- Proto files: `ldk-server-protos/src/proto/` (api.proto, types.proto, events.proto, error.proto) |
| 46 | +- Generated code: `ldk-server-protos/src/` (api.rs, types.rs, events.rs, error.rs) |
| 47 | +- Regenerate with: `RUSTFLAGS="--cfg genproto" cargo build -p ldk-server-protos` |
| 48 | + |
| 49 | +**Adding a New API Endpoint:** |
| 50 | +1. Define request/response messages in `ldk-server-protos/src/proto/api.proto` |
| 51 | +2. Regenerate protos: `RUSTFLAGS="--cfg genproto" cargo build -p ldk-server-protos` |
| 52 | +3. Create handler in `ldk-server/src/api/` (follow existing patterns) |
| 53 | +4. Add route in `ldk-server/src/service.rs` |
| 54 | +5. Add CLI command in `ldk-server-cli/src/main.rs` |
| 55 | + |
| 56 | +**Configuration:** |
| 57 | +- Config template with all options: `ldk-server/ldk-server-config.toml` |
| 58 | +- When updating config options, also update the tests in `ldk-server/src/util/config.rs` |
| 59 | + |
| 60 | +## Feature Flags |
| 61 | + |
| 62 | +- `events-rabbitmq` - Enable RabbitMQ event publishing |
| 63 | +- `experimental-lsps2-support` - Experimental LSPS2 liquidity provider support |
| 64 | +- `integration-tests-events-rabbitmq` - RabbitMQ integration tests |
| 65 | + |
| 66 | +## Code Style |
| 67 | + |
| 68 | +- MSRV: Rust 1.85.0 |
| 69 | +- Hard tabs, max width 100 chars |
| 70 | +- Imports grouped: std, external crates, local crates |
| 71 | + |
| 72 | +## Development Rules |
| 73 | + |
| 74 | +- Run `cargo fmt --all` after every code change |
| 75 | +- Never add new dependencies unless explicitly requested |
| 76 | +- Include Co-Authored-By Claude in commit messages for AI-generated code |
0 commit comments