-
Notifications
You must be signed in to change notification settings - Fork 121
Add basic CLAUDE.md file
#771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tnull
wants to merge
2
commits into
lightningdevkit:main
Choose a base branch
from
tnull:2026-01-add-claude-md
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Development Rules | ||
|
|
||
| - Always ensure tests pass before committing. | ||
| - Run `cargo fmt --all` after every code change | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it need a version specified?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think so, default |
||
| - Never add new dependencies unless explicitly requested | ||
| - Please always disclose the use of any AI tools in commit messages and PR descriptions | ||
| - When adding new `.rs` files, please ensure to always add the licensing header as found in all other files. | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| LDK-Node is a self-custodial Lightning Network node library built on top of **LDK** (Lightning Development Kit) for Lightning functionality and **BDK** (Bitcoin Development Kit) for on-chain wallet operations. It provides a simple, ready-to-go interface for building Lightning applications with language bindings for Swift, Kotlin, and Python via UniFFI. | ||
|
|
||
| ### Core Components | ||
|
|
||
| | Component | Location | Responsibility | | ||
| |-----------|----------|----------------| | ||
| | `Node` | `src/lib.rs` | Central abstraction containing all subsystems; entry point for API | | ||
| | `Builder` | `src/builder.rs` | Fluent configuration interface for constructing `Node` instances | | ||
| | `Wallet` | `src/wallet/` | BDK-based on-chain wallet with SQLite persistence | | ||
| | `ChainSource` | `src/chain/` | Chain data abstraction (Esplora, Electrum, Bitcoin Core) | | ||
| | `EventHandler` | `src/event.rs` | Translates LDK events to user-facing `Node` events | | ||
| | `PaymentStore` | `src/payment/store.rs` | Persistent payment tracking with status and metadata | | ||
|
|
||
| ### Module Organization | ||
|
|
||
| | Module | Purpose | | ||
| |--------|---------| | ||
| | `payment/` | Payment processing (BOLT11, BOLT12, on-chain, spontaneous, unified) | | ||
| | `wallet/` | On-chain wallet abstraction, serialization, persistence | | ||
| | `chain/` | Chain data sources, wallet syncing, transaction broadcasting | | ||
| | `io/` | Persistence layer (`SQLiteStore`, `VssStore`, KV-store utilities) | | ||
| | `liquidity.rs` | Liquidity provider integration (LSPS1/LSPS2) | | ||
| | `connection.rs` | Peer connection management and reconnection logic | | ||
| | `gossip.rs` | Gossip data source management (RGS, P2P) | | ||
| | `graph.rs` | Network graph querying and channel/node information | | ||
| | `types.rs` | Type aliases for LDK components (`ChannelManager`, `PeerManager`, etc.) | | ||
| | `ffi/` | UniFFI bindings for cross-language support | | ||
|
|
||
| ### Key Design Patterns | ||
|
|
||
| - **Arc-based Shared Ownership**: Extensive use of `Arc` for thread-safe shared components enabling background task spawning | ||
| - **Event-Driven Architecture**: Events flow from LDK → `EventHandler` → `EventQueue` → User application | ||
| - **Trait-based Abstraction**: `KVStore`/`KVStoreSync` for storage, `ChainSource` for chain backends, `StorableObject` for persistence | ||
| - **Builder Pattern**: Fluent configuration with sensible defaults and validation during build phase | ||
| - **Background Tasks**: Multiple categories (wallet sync, gossip updates, peer reconnection, fee updates, event processing) | ||
|
|
||
| ### Lifecycle | ||
|
|
||
| **Startup (`node.start()`)**: Acquires lock → starts chain source → updates fee rates → spawns background sync tasks → sets up gossip/listeners/peer reconnection → starts event processor → marks running | ||
|
|
||
| **Shutdown (`node.stop()`)**: Acquires lock → signals stop → aborts cancellable tasks → waits for background tasks → disconnects peers → persists final state | ||
|
|
||
| ### Type Aliases (from `types.rs`) | ||
|
|
||
| Key LDK type aliases used throughout the codebase: | ||
| - `ChannelManager` - LDK channel management | ||
| - `ChainMonitor` - LDK chain monitoring | ||
| - `PeerManager` - LDK peer connections | ||
| - `OnionMessenger` - LDK onion messaging | ||
| - `Router` - LDK pathfinding (`DefaultRouter`) | ||
| - `Scorer` - Combined probabilistic + external scoring | ||
| - `Graph` - `NetworkGraph` | ||
| - `Sweeper` - `OutputSweeper` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.