This file contains guidelines for agentic coding agents working in the LWK (Liquid Wallet Kit) repository.
When multiple instructions apply, follow this priority order:
- Safety, security, and data integrity
- Correctness and testability
- Repository conventions (style, structure, commit format)
- Performance and speed of execution
If instructions conflict, follow the higher-priority rule and document the tradeoff briefly in your final message.
LWK is a Rust workspace containing libraries for Liquid wallets. It consists of multiple crates:
lwk_wollet- Watch-only wallets based on CT descriptorslwk_signer- Signing operationslwk_jade/lwk_ledger- Hardware wallet integrationslwk_bindings- UniFFI bindings for Python/Kotlin/Swift/C#lwk_common- Shared utilitieslwk_cli- Command line interfacelwk_wasm- WebAssembly bindings- and others
# Build the entire workspace
cargo -q build
# Build specific crate
cargo -q build -p lwk_wollet
# Cross-compile for WASM
cargo -q check --target wasm32-unknown-unknown -p lwk_wollet# Run all tests, including integration tests that spawn executables and Docker containers
cargo -q test
# Run all unit tests, much faster; every unit test should run in less than a second
cargo -q test --lib
# Run tests for specific package
cargo -q test -p lwk_wollet
# Run a single test
cargo -q test -p lwk_wollet test_name_here
# Run bindings tests
cargo -q test -p lwk_bindings --features foreign_bindings
# Build tests without running
cargo -q test --no-run# Format code
cargo -q fmt
# Check formatting
cargo -q fmt --check
# Run clippy
cargo -q clippy --all-features --all-targets -- -D warnings
# Security audit
cargo audit --deny yanked
# Generate documentation
cargo -q doc --no-deps -p lwk_wollet --all-features
RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo +nightly -q doc --all-features --no-depsThe project uses just for complex workflows, some examples include:
just --list # List all recipes
just build-bindings-lib # Build liblwk.so
just python-test-bindings # Test Python bindings
just swift # Build Swift framework (macOS only)
just android # Build Android libs
just kotlin # Generate Kotlin bindings
just mdbook # Build documentationif you're adding a complex flow, please add a just command.
- Rust toolchain: 1.85.0 (specified in
rust-toolchain.toml) - Edition: 2021
- Group imports: std lib → external crates → workspace crates → local modules
- Use
use crate::for local module imports - Re-export commonly used types at crate root (see
lwk_wollet/src/lib.rs)
- Use
thiserrorfor error enums with#[derive(thiserror::Error, Debug)] - Use
#[error(transparent)]for wrapping other errors - Use
#[from]for automatic conversion - Return
Result<T, Error>from public functions - Deny
unwrap()in non-test code:#![cfg_attr(not(test), deny(clippy::unwrap_used))]
- Types:
PascalCase(e.g.,WolletDescriptor,TxBuilder) - Functions/Methods:
snake_case(e.g.,full_scan_with_electrum_client) - Constants:
SCREAMING_SNAKE_CASE(e.g.,LIQUID_SOCKET) - Feature flags:
snake_case(e.g.,foreign_bindings,test_emulator)
- Require docs on public items:
#![warn(missing_docs)] - Use
//!for module-level documentation - Document all public functions with examples where appropriate
- Mark feature-gated items:
#[cfg_attr(docsrs, feature(doc_cfg))]
- Use
pub typealiases for common types (e.g.,pub type BlindingPublicKey = elements::secp256k1_zkp::PublicKey) - Prefer
&strover&Stringin function parameters - Use builder patterns for complex construction (e.g.,
TxBuilder,WolletBuilder) and for constructor with large/unknown number of parameters
Format: context: <description>
- Context: crate/directory name or
ci/fix/feat/docs/refactor - For crates, do not include
lwk_for examplelwk_wollet:use justwollet: - Breaking changes: append
!after context - Title: max 50 chars, imperative mood, no period
- Body: blank line after title, explain "why", use bullet points
- Default features should be minimal but functional
- Group related features logically
- Use
#[cfg(feature = "...")]for conditional compilation - Document feature requirements in crate README
- Unit tests in
#[cfg(test)]modules - Integration tests in
tests/directory - Use
lwk_test_utilfor shared test utilities - E2E tests require Docker environment (Jade emulator, etc.)
- Possible panics, unchecked index array access, unwraps, are allowed in testing code.
- Do not suggest safety improvements (e.g., bounds checks, error handling) for these in tests unless they cause compile/run failures.
- CI Configuration:
.gitlab-ci.yml(GitLab) and.github/workflows/(GitHub) - Nix development:
nix develop .for reproducible environment