This guide will help you set up your development environment for working with the CDK repository.
Before you begin, ensure you have:
Clone your forked repository:
git clone https://github.com/YOUR-USERNAME/cdk.git
cd cdk
CDK uses Nix for building, CI, and managing dev environment.
Note: only Nix (the language & package manager) and not the NixOS (the Linux distribution) is needed.
Nix can be installed on any Linux distribution and macOS.
While Nix is preferred as it ensures a consistent and reproducible environment for all developers, it is not strictly required to use Nix to build CDK.
You have 2 options to install nix:
Example:
> nix --version
nix (Nix) 2.9.1
The exact version might be different.
If you installed Nix using the "determinate installer" you can skip this step. If you used the "official installer", edit either ~/.config/nix/nix.conf or /etc/nix/nix.conf and add:
experimental-features = nix-command flakes
If the Nix installation is in multi-user mode, don’t forget to restart the nix-daemon.
While Nix is preferred as it ensures a consistent and reproducible environment for all developers, it is not strictly required to use Nix to build CDK. You can also set up your environment manually.
To build CDK without Nix, you'll need to install Rust manually:
Install rustup by following the instructions at https://www.rust-lang.org/tools/install
Once rustup is installed, you can install the required Rust version:
rustup install stable
rustup default stable
Install required tools:
# For building cdk-mintd, you'll need protobuf compiler
# On Ubuntu/Debian:
sudo apt install protobuf-compiler
# On macOS with Homebrew:
brew install protobuf
# On other systems, please refer to your package manager or
# https://grpc.io/docs/protoc-installation/
To build the CDK command-line interface:
cargo build --bin cdk-cli --release
To run cdk-cli directly without building:
cargo run --bin cdk-cli -- --help
To build the CDK mint server:
cargo build --bin cdk-mintd --release
To run cdk-mintd directly without building:
cargo run --bin cdk-mintd
Note: For cdk-mintd, you need to have the protobuf compiler installed as it's required for some dependencies.
nix develop -c $SHELL
For testing and development, CDK provides a complete regtest environment with Bitcoin, Lightning Network nodes, and CDK mints.
just regtest # Starts full environment with mprocs TUI
This provides:
See REGTEST_GUIDE.md for complete documentation including:
just build
just test
just itest REDB/SQLITE/MEMORY
NOTE: if this command fails on macos change the nix channel to unstable (in the flake.nix file modify nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; to nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";)
just format
just clippy
just final-check
Branch Management
mainfeature/new-feature or fix/bug-descriptionCommit Messages
feat:, fix:, docs:, chore:, etc.Testing
nix-collect-garbage -dCDK uses an automated backport bot to help maintain stable release branches. This section explains how the backport process works.
The backport bot creates pull requests to backport merged changes from main to stable release branches. You control which branches to backport to by adding labels to your PR.
Available Target Branches:
v0.10.xv0.11.xv0.12.xv0.13.xTo backport a PR to specific stable branches, add labels to your PR before or after merging:
Label Format:
backport v0.13.x - backports to v0.13.x branchbackport v0.12.x - backports to v0.12.x branchExample Workflow:
mainbackport v0.13.x to the PRWhen to Add Labels:
Sometimes the backport bot cannot automatically create a backport PR due to merge conflicts or other issues. When this happens:
backportManual Backporting Process:
# Checkout the target stable branch
git checkout v0.13.x
git pull origin v0.13.x
# Create a new branch for the backport
git checkout -b backport-pr-NUMBER-to-v0.13.x
# Cherry-pick the commits from the original PR
git cherry-pick COMMIT_HASH
# Resolve any conflicts if they occur
# Then push and create a PR
git push origin backport-pr-NUMBER-to-v0.13.x
Not all changes should be backported to stable branches. Don't add backport labels for:
If a backport isn't appropriate, simply don't add the backport label to the PR.
Refer to the LICENSE file in the repository for terms of use and distribution.