refactor: cdk MSRV

This commit is contained in:
thesimplekid
2024-08-31 23:15:19 +01:00
parent 5f87df2cef
commit 1eb14703a5
35 changed files with 690 additions and 868 deletions

View File

@@ -2,28 +2,44 @@ name: CI
on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
name: Format
self-care:
name: Flake self-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo fmt --all -- --config format_code_in_doc_comments=true --check
- uses: actions/checkout@v4
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v7
with:
fail-mode: true
build:
name: Build
pre-commit-checks:
name: "Pre-commit checks: cargo fmt, typos"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Pre-commit checks
run: nix develop -i -L .#stable --command pre-commit run --all-files
clippy:
name: "Stable build, clippy and test"
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: stable
build-args:
[
-p cdk,
@@ -37,41 +53,90 @@ jobs:
-p cdk-lnd,
-p cdk-phoenixd,
-p cdk-strike,
-p cdk-lnbits
-p cdk-lnbits,
-p cdk-integration-tests,
-p cdk-fake-wallet,
--bin cdk-cli,
--bin cdk-mintd,
--bin cdk-mintd
]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Install protobuf
run: sudo apt-get install -y protobuf-compiler
- name: Set default toolchain
run: rustup default ${{ matrix.rust.version }}
- name: Set profile
run: rustup set profile minimal && rustup component add clippy
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build ${{ matrix.build-args }}
run: nix develop -i -L .#stable --command cargo build ${{ matrix.build-args }}
- name: Clippy
run: cargo clippy ${{ matrix.build-args }} -- -D warnings
run: nix develop -i -L .#stable --command cargo clippy ${{ matrix.build-args }} -- -D warnings
- name: Test
run: nix develop -i -L .#stable --command cargo test ${{ matrix.build-args }}
build-wasm:
name: Build WASM
msrv-build:
name: "MSRV build"
runs-on: ubuntu-latest
strategy:
matrix:
build-args:
[
-p cdk,
-p cdk --no-default-features,
-p cdk --no-default-features --features wallet,
-p cdk --no-default-features --features mint,
-p cdk-axum,
-p cdk-strike,
-p cdk-lnbits,
-p cdk-phoenixd
-p cdk-fake-wallet
-p cdk-cln
]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build
run: nix develop -i -L .#msrv --command cargo build ${{ matrix.build-args }}
db-msrv-build:
name: "DB MSRV build"
runs-on: ubuntu-latest
strategy:
matrix:
build-args:
[
-p cdk-sqlite
-p cdk-redb
]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build
run: nix develop -i -L .#db_shell --command cargo build ${{ matrix.build-args }}
check-wasm:
name: Check WASM
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: stable
- stable
target:
- wasm32-unknown-unknown
build-args:
[
-p cdk,
@@ -80,53 +145,41 @@ jobs:
-p cdk-js
]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-wasm32-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Set default toolchain
run: rustup default ${{ matrix.rust.version }}
- name: Add WASM
run: rustup target add wasm32-unknown-unknown
- name: Set profile
run: rustup set profile minimal && rustup component add clippy
- name: Build
run: cargo build ${{ matrix.build-args }} --target wasm32-unknown-unknown
- name: Clippy
run: cargo clippy ${{ matrix.build-args }} --target wasm32-unknown-unknown -- -D warnings
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build cdk and binding
run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
run-examples:
name: Run Examples
check-wasm-msrv:
name: Check WASM
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: stable
- msrv
target:
- wasm32-unknown-unknown
build-args:
[
mint-token,
p2pk,
proof-selection,
wallet
-p cdk,
-p cdk --no-default-features,
-p cdk --no-default-features --features wallet,
]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-wasm32-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Set default toolchain
run: rustup default ${{ matrix.rust.version }}
- name: Run
run: cargo run --example ${{ matrix.build-args }}
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build cdk wasm
run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}

View File

@@ -1,82 +0,0 @@
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
jobs:
build:
name: Build
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Build on ${{ matrix.host }}
run: 'nix flake check -L .#
'
strategy:
matrix:
host:
- macos-x86_64
- macos-aarch64
- linux
include:
- host: linux
runs-on: ubuntu-latest
timeout: 60
- host: macos-x86_64
runs-on: macos-12
timeout: 60
- host: macos-aarch64
runs-on: macos-14
timeout: 60
timeout-minutes: ${{ matrix.timeout }}
flake:
name: Flake self-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v5
with:
fail-mode: true
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Cargo Cache
uses: actions/cache@v3
with:
key: ${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
path: ~/.cargo
- name: Commit Check
run: '# run the same check that git `pre-commit` hook does
nix develop --ignore-environment .#lint --command ./misc/git-hooks/pre-commit
'
name: CI
'on':
merge_group:
branches:
- master
- main
pull_request:
branches:
- master
- main
push:
branches:
- master
- main
tags:
- v*
workflow_dispatch: {}
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

View File

@@ -1,35 +0,0 @@
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
jobs:
flakehub-publish:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || ''
}}
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Flakehub Push
uses: DeterminateSystems/flakehub-push@main
with:
name: ${{ github.repository }}
tag: ${{ inputs.tag }}
visibility: public
name: Publish to Flakehub
'on':
push:
tags:
- v?[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:
inputs:
tags:
description: The existing tag to publish to FlakeHub
required: true
type: string
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

View File

@@ -1,38 +0,0 @@
name: test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: stable
build-args:
[
-p cdk,
-p cdk-integration-tests,
]
steps:
- name: Checkout Crate
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Set default toolchain
run: rustup default ${{ matrix.rust.version }}
- name: Test
run: cargo test ${{ matrix.build-args }}

1
.pre-commit-config.yaml Symbolic link
View File

@@ -0,0 +1 @@
/nix/store/0nnfmi5rkin522yp2df1cqzx6g0ls4al-pre-commit-config.json

View File

@@ -1,5 +0,0 @@
group_imports = "StdExternalCrate"
wrap_comments = true
format_code_in_doc_comments = true
imports_granularity = "Module"
edition = "2021"

View File

@@ -9,7 +9,7 @@ resolver = "2"
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.70.0" # MSRV
rust-version = "1.63.0" # MSRV
version = "0.3.0"
[workspace.metadata]
@@ -21,44 +21,9 @@ repository = "https://github.com/cashubtc/cdk"
license-file = "LICENSE"
keywords = ["bitcoin", "e-cash", "cashu"]
[workspace.dependencies]
async-trait = "0.1.74"
anyhow = "1"
axum = "0.7.5"
bitcoin = { version = "0.30", default-features = false } # lightning-invoice uses v0.30
bip39 = "2.0"
clap = { version = "4.4.8", features = ["derive", "env", "default"] }
cdk = { version = "0.3", path = "./crates/cdk", default-features = false }
cdk-rexie = { version = "0.3", path = "./crates/cdk-rexie", default-features = false }
cdk-sqlite = { version = "0.3", path = "./crates/cdk-sqlite", default-features = false }
cdk-redb = { version = "0.3", path = "./crates/cdk-redb", default-features = false }
cdk-cln = { version = "0.3", path = "./crates/cdk-cln", default-features = false }
cdk-lnbits = { version = "0.3", path = "./crates/cdk-lnbits", default-features = false }
cdk-phoenixd = { version = "0.3", path = "./crates/cdk-phoenixd", default-features = false }
cdk-axum = { version = "0.3", path = "./crates/cdk-axum", default-features = false }
cdk-fake-wallet = { version = "0.3", path = "./crates/cdk-fake-wallet", default-features = false }
cdk-strike = { version = "0.3", path = "./crates/cdk-strike", default-features = false }
cdk-lnd = { version = "0.3", path = "./crates/cdk-lnd", default-features = false }
tokio = { version = "1", default-features = false }
thiserror = "1"
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
serde-wasm-bindgen = "0.6.5"
futures = { version = "0.3.28", default-feature = false }
web-sys = { version = "0.3.69", default-features = false, features = ["console"] }
uuid = { version = "1", features = ["v4"] }
lightning-invoice = { version = "0.31", features = ["serde"] }
tower-http = { version = "0.5.2", features = ["cors"] }
home = "0.5.9"
rand = "0.8.5"
url = "2.3"
[profile]
[profile.ci]
inherits = "dev"
incremental = false
debug = "line-tables-only"
lto = "off"

View File

@@ -59,6 +59,8 @@ The project is split up into several crates in the `crates/` directory:
| [16][16] | Animated QR codes | :x: |
| [17][17] | WebSocket subscriptions | :construction: |
MSRV
## Bindings
Experimental bindings can be found in the [bindings](./bindings/) folder.

View File

@@ -1,11 +1,11 @@
[package]
name = "cdk-js"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
license.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "Cashu Development Kit JS Bindings"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -13,13 +13,13 @@ description = "Cashu Development Kit JS Bindings"
crate-type = ["lib", "cdylib"]
[dependencies]
cdk = { workspace = true, features = ["wallet"] }
cdk-rexie = { workspace = true, features = ["wallet"] }
cdk = { path = "../../crates/cdk", features = ["wallet"] }
cdk-rexie = { path = "../../crates/cdk-rexie", features = ["wallet"] }
console_error_panic_hook = "0.1"
js-sys = "0.3"
serde-wasm-bindgen.workspace = true
serde_json.workspace = true
serde.workspace = true
serde_json = "1"
serde-wasm-bindgen = "0.6.5"
serde = { version = "1", default-features = false, features = ["derive"] }
wasm-bindgen = { version = "0.2.92", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.41"
web-sys.workspace = true
web-sys = { version = "0.3.69", default-features = false, features = ["console"] }

View File

@@ -1,19 +1,19 @@
[package]
name = "cdk-axum"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
license.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "Cashu CDK axum webserver"
[dependencies]
anyhow.workspace = true
async-trait.workspace = true
axum.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
tokio.workspace = true
tower-http.workspace = true
tracing.workspace = true
futures.workspace = true
anyhow = "1"
async-trait = "0.1"
axum = "0.6.20"
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
tokio = { version = "1", default-features = false }
tower-http = { version = "0.4.4", features = ["cors"] }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
futures = { version = "0.3.28", default-features = false }

View File

@@ -58,8 +58,9 @@ pub async fn create_mint_router(
Ok(mint_router)
}
/// CDK Mint State
#[derive(Clone)]
struct MintState {
pub struct MintState {
ln: HashMap<LnKey, Arc<dyn MintLightning<Err = cdk_lightning::Error> + Send + Sync>>,
mint: Arc<Mint>,
mint_url: MintUrl,

View File

@@ -1,32 +1,32 @@
[package]
name = "cdk-cli"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
description = "Cashu cli wallet built on CDK"
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow.workspace = true
bip39.workspace = true
cdk = { workspace = true, default-features = false, features = ["wallet"] }
cdk-redb = { workspace = true, default-features = false, features = ["wallet"] }
cdk-sqlite = { workspace = true, default-features = false, features = ["wallet"] }
clap.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
rand.workspace = true
home.workspace = true
anyhow = "1"
bip39 = "2.0"
cdk = { path = "../cdk", default-features = false, features = ["wallet"] }
cdk-redb = { path = "../cdk-redb", default-features = false, features = ["wallet"] }
cdk-sqlite = { path = "../cdk-sqlite", default-features = false, features = ["wallet"] }
clap = { version = "4.4.8", features = ["derive", "env", "default"] }
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
rand = "0.8.5"
home = "0.5.5"
nostr-sdk = { version = "0.33.0", default-features = false, features = [
"nip04",
"nip44"
]}
url.workspace = true
url = "2.3"

View File

@@ -1,21 +1,21 @@
[package]
name = "cdk-cln"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "CDK ln backend for cln"
[dependencies]
async-trait.workspace = true
bitcoin.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
async-trait = "0.1"
bitcoin = { version = "0.30", default-features = false } # lightning-invoice uses v0.30
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
cln-rpc = "0.1.9"
futures.workspace = true
tokio.workspace = true
tracing.workspace = true
thiserror.workspace = true
uuid.workspace = true
futures = { version = "0.3.28", default-features = false }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
thiserror = "1"
uuid = { version = "1", features = ["v4"] }

View File

@@ -1,24 +1,24 @@
[package]
name = "cdk-fake-wallet"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
description = "CDK ln backend for cln"
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "CDK fake ln backend"
[dependencies]
async-trait.workspace = true
bitcoin.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
futures.workspace = true
tokio.workspace = true
tracing.workspace = true
thiserror.workspace = true
uuid.workspace = true
lightning-invoice.workspace = true
async-trait = "0.1.74"
bitcoin = { version = "0.30", default-features = false } # lightning-invoice uses v0.30
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
futures = { version = "0.3.28", default-features = false }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
thiserror = "1"
uuid = { version = "1", features = ["v4"] }
lightning-invoice = { version = "0.31", features = ["serde"] }
lightning = "0.0.123"
tokio-stream = "0.1.15"
rand.workspace = true
rand = "0.8.5"

View File

@@ -1,31 +1,31 @@
[package]
name = "cdk-integration-tests"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
description = "Core Cashu Development Kit library implementing the Cashu protocol"
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
[features]
[dependencies]
axum.workspace = true
rand.workspace = true
bip39 = { workspace = true, features = ["rand"] }
anyhow.workspace = true
cdk = { workspace = true, features = ["mint", "wallet"] }
cdk-axum.workspace = true
cdk-fake-wallet.workspace = true
tower-http.workspace = true
futures.workspace = true
axum = "0.6.20"
rand = "0.8.5"
bip39 = { version = "2.0", features = ["rand"] }
anyhow = "1"
cdk = { path = "../cdk", features = ["mint", "wallet"] }
cdk-axum = { path = "../cdk-axum"}
cdk-fake-wallet = { path = "../cdk-fake-wallet" }
tower-http = { version = "0.4.4", features = ["cors"] }
futures = { version = "0.3.28", default-features = false }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true, features = [
tokio = { version = "1", features = [
"rt-multi-thread",
"time",
"macros",
@@ -33,18 +33,15 @@ tokio = { workspace = true, features = [
] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { workspace = true, features = ["rt", "macros", "sync", "time"] }
tokio = { version = "1", features = ["rt", "macros", "sync", "time"] }
getrandom = { version = "0.2", features = ["js"] }
instant = { version = "0.1", features = ["wasm-bindgen", "inaccurate"] }
[dev-dependencies]
axum.workspace = true
rand.workspace = true
bip39 = { workspace = true, features = ["rand"] }
anyhow.workspace = true
cdk = { workspace = true, features = ["mint", "wallet"] }
cdk-axum.workspace = true
cdk-fake-wallet.workspace = true
tower-http.workspace = true
# cdk-redb.workspace = true
# cdk-sqlite.workspace = true
rand = "0.8.5"
bip39 = { version= "2.0", features = ["rand"] }
anyhow = "1"
cdk = { path = "../cdk", features = ["mint", "wallet"] }
cdk-axum = { path = "../cdk-axum" }
cdk-fake-wallet = { path = "../cdk-fake-wallet" }
tower-http = { version = "0.4.4", features = ["cors"] }

View File

@@ -115,11 +115,14 @@ pub async fn start_mint(
}
});
}
let listener =
tokio::net::TcpListener::bind(format!("{}:{}", LISTEN_ADDR, LISTEN_PORT)).await?;
println!("Starting mint");
axum::serve(listener, mint_service).await?;
axum::Server::bind(
&format!("{}:{}", LISTEN_ADDR, LISTEN_PORT)
.as_str()
.parse()?,
)
.serve(mint_service.into_make_service())
.await?;
Ok(())
}

View File

@@ -1,22 +1,22 @@
[package]
name = "cdk-lnbits"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "CDK ln backend for lnbits"
[dependencies]
async-trait.workspace = true
anyhow.workspace = true
axum.workspace = true
bitcoin.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
futures.workspace = true
tokio.workspace = true
tracing.workspace = true
thiserror.workspace = true
lnbits-rs = "0.1.0"
async-trait = "0.1"
anyhow = "1"
axum = "0.6.20"
bitcoin = { version = "0.30", default-features = false } # lightning-invoice uses v0.30
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
futures = { version = "0.3.28", default-features = false }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
thiserror = "1"
lnbits-rs = "0.2.0"

View File

@@ -1,20 +1,19 @@
[package]
name = "cdk-lnd"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
description = "CDK ln backend for lnd"
[dependencies]
async-trait.workspace = true
anyhow.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
async-trait = "0.1"
anyhow = "1"
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
fedimint-tonic-lnd = "0.2.0"
futures.workspace = true
tokio.workspace = true
tracing.workspace = true
thiserror.workspace = true
futures = { version = "0.3.28", default-features = false }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
thiserror = "1"

14
crates/cdk-lnd/README.md Normal file
View File

@@ -0,0 +1,14 @@
## Minimum Supported Rust Version (MSRV)
The `cdk` library should always compile with any combination of features on Rust **1.66.0**.
To build and test with the MSRV you will need to pin the below dependency versions:
```shell
cargo update -p home --precise 0.5.5
cargo update -p prost --precise 0.12.3
cargo update -p prost-types --precise 0.12.3
cargo update -p prost-build --precise 0.12.3
cargo update -p prost-derive --precise 0.12.3
```

View File

@@ -1,36 +1,36 @@
[package]
name = "cdk-mintd"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "CDK mint binary"
[dependencies]
anyhow.workspace = true
axum.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
cdk-redb = { workspace = true, default-features = false, features = ["mint"] }
cdk-sqlite = { workspace = true, default-features = false, features = ["mint"] }
cdk-cln = { workspace = true, default-features = false }
cdk-lnbits = { workspace = true, default-features = false }
cdk-phoenixd = { workspace = true, default-features = false }
cdk-lnd = { workspace = true, default-features = false }
cdk-fake-wallet = { workspace = true, default-features = false }
cdk-strike.workspace = true
cdk-axum = { workspace = true, default-features = false }
anyhow = "1"
axum = "0.6.20"
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
cdk-redb = { path = "../cdk-redb", default-features = false, features = ["mint"] }
cdk-sqlite = { path = "../cdk-sqlite", default-features = false, features = ["mint"] }
cdk-cln = { path = "../cdk-cln", default-features = false }
cdk-lnbits = { path = "../cdk-lnbits", default-features = false }
cdk-phoenixd = { path = "../cdk-phoenixd", default-features = false }
cdk-lnd = { path = "../cdk-lnd", default-features = false }
cdk-fake-wallet = { path = "../cdk-fake-wallet", default-features = false }
cdk-strike = { path = "../cdk-strike" }
cdk-axum = { path = "../cdk-axum", default-features = false }
config = { version = "0.13.3", features = ["toml"] }
clap.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
futures.workspace = true
serde.workspace = true
bip39.workspace = true
tower-http = { version = "0.5.2", features = ["cors"] }
lightning-invoice.workspace = true
home.workspace = true
url.workspace = true
clap = { version = "4.4.8", features = ["derive", "env", "default"] }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
futures = { version = "0.3.28", default-features = false }
serde = { version = "1", default-features = false, features = ["derive"] }
bip39 = "2.0"
tower-http = { version = "0.4.4", features = ["cors"] }
lightning-invoice = { version = "0.31", features = ["serde"] }
home = "0.5.5"
url = "2.3"

View File

@@ -480,10 +480,13 @@ async fn main() -> anyhow::Result<()> {
});
}
let listener =
tokio::net::TcpListener::bind(format!("{}:{}", listen_addr, listen_port)).await?;
axum::serve(listener, mint_service).await?;
axum::Server::bind(
&format!("{}:{}", listen_addr, listen_port)
.as_str()
.parse()?,
)
.serve(mint_service.into_make_service())
.await?;
Ok(())
}

View File

@@ -1,24 +1,23 @@
[package]
name = "cdk-phoenixd"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "CDK ln backend for phoenixd"
[dependencies]
async-trait.workspace = true
anyhow.workspace = true
axum.workspace = true
bitcoin.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
futures.workspace = true
tokio.workspace = true
tracing.workspace = true
thiserror.workspace = true
phoenixd-rs = "0.2.0"
# phoenixd-rs = { path = "../../../../phoenixd-rs" }
uuid.workspace = true
async-trait = "0.1"
anyhow = "1"
axum = "0.6.20"
bitcoin = { version = "0.30", default-features = false } # lightning-invoice uses v0.30
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
futures = { version = "0.3.28", default-features = false }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
thiserror = "1"
phoenixd-rs = "0.3.0"
uuid = { version = "1", features = ["v4"] }

View File

@@ -1,13 +1,13 @@
[package]
name = "cdk-redb"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
description = "Redb storage backend for CDK"
license.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.66.0" # MSRV
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@@ -16,12 +16,12 @@ mint = ["cdk/mint"]
wallet = ["cdk/wallet"]
[dependencies]
async-trait.workspace = true
cdk = { workspace = true, default-features = false }
async-trait = "0.1"
cdk = { path = "../cdk", default-features = false }
redb = "2.1.0"
tokio.workspace = true
thiserror.workspace = true
tracing.workspace = true
serde.workspace = true
serde_json.workspace = true
lightning-invoice.workspace = true
tokio = { version = "1", default-features = false }
thiserror = "1"
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
lightning-invoice = { version = "0.31", features = ["serde"] }

View File

@@ -1,13 +1,13 @@
[package]
name = "cdk-rexie"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
description = "Indexdb storage backend for CDK in the browser"
license.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@@ -16,11 +16,11 @@ wallet = ["cdk/wallet"]
[dependencies]
rexie = "0.6.0"
cdk = { workspace = true, default-features = false }
async-trait.workspace = true
tokio.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
serde-wasm-bindgen.workspace = true
web-sys.workspace = true
cdk = { path = "../cdk", default-features = false }
async-trait = "0.1.74"
tokio = { version = "1", default-features = false }
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
thiserror = "1"
serde-wasm-bindgen = "0.6.5"
web-sys = { version = "0.3.69", default-features = false, features = ["console"] }

View File

@@ -1,13 +1,13 @@
[package]
name = "cdk-sqlite"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
description = "SQLite storage backend for CDK"
license.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.66.0" # MSRV
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@@ -16,16 +16,16 @@ mint = ["cdk/mint"]
wallet = ["cdk/wallet"]
[dependencies]
async-trait.workspace = true
cdk = { workspace = true, default-features = false }
bitcoin.workspace = true
async-trait = "0.1"
cdk = { path = "../cdk", default-features = false }
bitcoin = { version = "0.30", default-features = false } # lightning-invoice uses v0.30
sqlx = { version = "0.6.3", default-features = false, features = ["runtime-tokio-rustls", "sqlite", "macros", "migrate"] }
thiserror.workspace = true
tokio = { workspace = true, features = [
thiserror = "1"
tokio = { version = "1", features = [
"time",
"macros",
"sync",
] }
tracing.workspace = true
serde_json.workspace = true
lightning-invoice.workspace = true
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
serde_json = "1"
lightning-invoice = { version = "0.31", features = ["serde"] }

View File

@@ -1,23 +1,23 @@
[package]
name = "cdk-strike"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
description = "CDK ln backend for Strike api"
[dependencies]
async-trait.workspace = true
anyhow.workspace = true
axum.workspace = true
bitcoin.workspace = true
cdk = { workspace = true, default-features = false, features = ["mint"] }
futures.workspace = true
tokio.workspace = true
tracing.workspace = true
thiserror.workspace = true
uuid.workspace = true
strike-rs = "0.2.3"
async-trait = "0.1"
anyhow = "1"
axum = "0.6.20"
bitcoin = { version = "0.30", default-features = false } # lightning-invoice uses v0.30
cdk = { path = "../cdk", default-features = false, features = ["mint"] }
futures = { version = "0.3.28", default-features = false }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
thiserror = "1"
uuid = { version = "1", features = ["v4"] }
strike-rs = "0.3.0"

View File

@@ -1,32 +1,33 @@
[package]
name = "cdk"
version = { workspace = true }
version = "0.3.0"
edition = "2021"
authors = ["CDK Developers"]
description = "Core Cashu Development Kit library implementing the Cashu protocol"
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true # MSRV
license.workspace = true
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
license = "MIT"
[features]
default = ["mint", "wallet"]
mint = ["dep:futures"]
wallet = ["dep:reqwest"]
bench = []
[dependencies]
async-trait.workspace = true
anyhow.workspace = true
async-trait = "0.1"
anyhow = { version = "1.0.43", features = ["backtrace"] }
base64 = "0.22" # bitcoin uses v0.13 (optional dep)
bitcoin = { workspace = true, features = [
bitcoin = { version= "0.30", features = [
"serde",
"rand",
"rand-std",
] } # lightning-invoice uses v0.30
ciborium = { version = "0.2.2", default-features = false, features = ["std"] }
lightning-invoice.workspace = true
lightning-invoice = { version = "0.31", features = ["serde"] }
once_cell = "1.19"
regex = "1"
reqwest = { version = "0.12", default-features = false, features = [
@@ -35,17 +36,21 @@ reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls-native-roots",
"socks",
], optional = true }
serde.workspace = true
serde_json.workspace = true
serde_with = "3.4"
tracing.workspace = true
thiserror.workspace = true
futures = { workspace = true, optional = true }
url.workspace = true
uuid.workspace = true
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
serde_with = "3.1"
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
thiserror = "1"
futures = { version = "0.3.28", default-features = false, optional = true }
url = "2.3"
uuid = { version = "1", features = ["v4"] }
# -Z minimal-versions
sync_wrapper = "0.1.2"
bech32 = "0.9.1"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true, features = [
tokio = { version = "1", features = [
"rt-multi-thread",
"time",
"macros",
@@ -53,7 +58,7 @@ tokio = { workspace = true, features = [
] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { workspace = true, features = ["rt", "macros", "sync", "time"] }
tokio = { version = "1", features = ["rt", "macros", "sync", "time"] }
getrandom = { version = "0.2", features = ["js"] }
instant = { version = "0.1", features = ["wasm-bindgen", "inaccurate"] }
@@ -74,14 +79,10 @@ name = "proof-selection"
required-features = ["wallet"]
[dev-dependencies]
rand.workspace = true
bip39.workspace = true
anyhow.workspace = true
rand = "0.8.5"
bip39 = "2.0"
criterion = "0.5.1"
[[bench]]
name = "dhke_benchmarks"
harness = false
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bench)'] }

View File

@@ -81,6 +81,23 @@ async fn main() {
See more examples in the [examples](./examples) folder.
## Minimum Supported Rust Version (MSRV)
The `cdk` library should always compile with any combination of features on Rust **1.63.0**.
To build and test with the MSRV you will need to pin the below dependency versions:
```shell
cargo update -p half --precise 2.2.1
cargo update -p tokio --precise 1.38.1
cargo update -p reqwest --precise 0.12.4
cargo update -p serde_with --precise 3.1.0
cargo update -p regex --precise 1.9.6
cargo update -p backtrace --precise 0.3.58
# For wasm32-unknown-unknown target
cargo update -p bumpalo --precise 3.12.0
```
## License

View File

@@ -660,9 +660,10 @@ impl Mint {
let keysets = self.keysets.read().await;
let keyset = keysets.get(keyset_id).ok_or(Error::UnknownKeySet)?;
let Some(key_pair) = keyset.keys.get(amount) else {
// No key for amount
return Err(Error::AmountKey);
let key_pair = match keyset.keys.get(amount) {
Some(key_pair) => key_pair,
None => return Err(Error::AmountKey),
};
let c = sign_message(&key_pair.secret_key, blinded_secret)?;
@@ -877,8 +878,10 @@ impl Mint {
self.ensure_keyset_loaded(&proof.keyset_id).await?;
let keysets = self.keysets.read().await;
let keyset = keysets.get(&proof.keyset_id).ok_or(Error::UnknownKeySet)?;
let Some(keypair) = keyset.keys.get(&proof.amount) else {
return Err(Error::AmountKey);
let keypair = match keyset.keys.get(&proof.amount) {
Some(key_pair) => key_pair,
None => return Err(Error::AmountKey),
};
verify_message(&keypair.secret_key, proof.c, proof.secret.as_bytes())?;

View File

@@ -150,7 +150,7 @@ mod tests {
}
}
#[cfg(bench)]
#[cfg(feature = "bench")]
mod benches {
use test::{black_box, Bencher};

View File

@@ -123,7 +123,7 @@ mod tests {
}
}
#[cfg(bench)]
#[cfg(feature = "bench")]
mod benches {
use super::*;
use crate::test::{black_box, Bencher};

318
flake.lock generated
View File

@@ -1,93 +1,18 @@
{
"nodes": {
"android-nixpkgs": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils_3",
"nixpkgs": [
"flakebox",
"nixpkgs"
]
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1719001124,
"narHash": "sha256-JXrMwYlQarZPyjN5UkD4fS9mrHSE1PUa7P//1Z5Sqr0=",
"owner": "tadfisher",
"repo": "android-nixpkgs",
"rev": "7fa1348249564e43185d3053f579f9fa923d46cc",
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "tadfisher",
"repo": "android-nixpkgs",
"rev": "7fa1348249564e43185d3053f579f9fa923d46cc",
"type": "github"
}
},
"crane": {
"inputs": {
"nixpkgs": [
"flakebox",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717383740,
"narHash": "sha256-559HbY4uhNeoYvK3H6AMZAtVfmR3y8plXZ1x6ON/cWU=",
"owner": "ipetkov",
"repo": "crane",
"rev": "b65673fce97d277934488a451724be94cc62499a",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"rev": "b65673fce97d277934488a451724be94cc62499a",
"type": "github"
}
},
"devshell": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"flakebox",
"android-nixpkgs",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717408969,
"narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=",
"owner": "numtide",
"repo": "devshell",
"rev": "1ebbe68d57457c8cae98145410b164b5477761f4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"flakebox",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1717827974,
"narHash": "sha256-ixopuTeTouxqTxfMuzs6IaRttbT8JqRW5C9Q/57WxQw=",
"owner": "nix-community",
"repo": "fenix",
"rev": "ab655c627777ab5f9964652fe23bbb1dfbd687a8",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
@@ -109,95 +34,34 @@
"type": "github"
}
},
"flake-utils_2": {
"gitignore": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"inputs": {
"systems": [
"flakebox",
"systems"
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flakebox": {
"inputs": {
"android-nixpkgs": "android-nixpkgs",
"crane": "crane",
"fenix": "fenix",
"flake-utils": "flake-utils_4",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_4"
},
"locked": {
"lastModified": 1723222819,
"narHash": "sha256-qjnbsopwTlnjKxjSbtchRm+kMP87FAmN0xIHLf7dQWw=",
"owner": "rustshop",
"repo": "flakebox",
"rev": "703a23a027b853d7fff36182b5875cd7d82b264a",
"type": "github"
},
"original": {
"owner": "rustshop",
"repo": "flakebox",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1724727824,
"narHash": "sha256-0XH9MJk54imJm+RHOLTUJ7e+ponLW00tw5ke4MTVa1Y=",
"lastModified": 1725001927,
"narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "36bae45077667aff5720e5b3f1a5458f51cf0776",
"rev": "6e99f2a27d600612004fbd2c3282d614bfee6421",
"type": "github"
},
"original": {
@@ -207,27 +71,84 @@
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"flakebox": "flakebox",
"nixpkgs": "nixpkgs"
}
},
"rust-analyzer-src": {
"flake": false,
"nixpkgs-stable": {
"locked": {
"lastModified": 1717583671,
"narHash": "sha256-+lRAmz92CNUxorqWusgJbL9VE1eKCnQQojglRemzwkw=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "48bbdd6a74f3176987d5c809894ac33957000d19",
"lastModified": 1720386169,
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1719082008,
"narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9693852a2070b398ee123a329e68f0dab5526681",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1724857454,
"narHash": "sha256-Qyl9Q4QMTLZnnBb/8OuQ9LSkzWjBU1T5l5zIzTxkkhk=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "4509ca64f1084e73bc7a721b20c669a8d4c5ebe6",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1725243956,
"narHash": "sha256-0A5ZP8uDCyBdYUzayZfy6JFdTefP79oZVAjyqA/yuSI=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "a10c8092d5f82622be79ed4dd12289f72011f850",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
@@ -245,51 +166,6 @@
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

192
flake.nix
View File

@@ -1,62 +1,176 @@
{
description = "Cashu Development Kit";
description = "CDK Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flakebox = {
url = "github:rustshop/flakebox";
inputs.nixpkgs.follows = "nixpkgs";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = { self, nixpkgs, flakebox, flake-utils }:
outputs = { self, nixpkgs, rust-overlay, flake-utils, pre-commit-hooks, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { system = system; };
overlays = [ (import rust-overlay) ];
lib = pkgs.lib;
flakeboxLib = flakebox.lib.${system} { };
rustSrc = flakeboxLib.filterSubPaths {
root = builtins.path {
name = "cdk";
path = ./.;
};
paths = [ "crates/*" ];
stdenv = pkgs.stdenv;
isDarwin = stdenv.isDarwin;
libsDarwin = with pkgs; lib.optionals isDarwin [
# Additional darwin specific inputs can be set here
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
# Dependencies
pkgs = import nixpkgs {
inherit system overlays;
};
targetsStd = flakeboxLib.mkStdTargets { };
toolchainsStd = flakeboxLib.mkStdToolchains { };
toolchainNative = flakeboxLib.mkFenixToolchain {
targets = (pkgs.lib.getAttrs [ "default" "wasm32-unknown" ] targetsStd);
# Toolchains
# latest stable
stable_toolchain = pkgs.rust-bin.stable.latest.default.override {
targets = [ "wasm32-unknown-unknown" ]; # wasm
};
commonArgs = {
buildInputs = [ pkgs.openssl ] ++ lib.optionals pkgs.stdenv.isDarwin
[ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ];
nativeBuildInputs = [ pkgs.pkg-config ];
# MSRV stable
msrv_toolchain = pkgs.rust-bin.stable."1.63.0".default.override {
targets = [ "wasm32-unknown-unknown" ]; # wasm
};
outputs = (flakeboxLib.craneMultiBuild { toolchains = toolchainsStd; })
(craneLib':
let
craneLib = (craneLib'.overrideArgs {
pname = "flexbox-multibuild";
src = rustSrc;
}).overrideArgs commonArgs;
in
rec {
workspaceDeps = craneLib.buildWorkspaceDepsOnly { };
workspaceBuild =
craneLib.buildWorkspace { cargoArtifacts = workspaceDeps; };
});
# DB MSRV stable
db_msrv_toolchain = pkgs.rust-bin.stable."1.66.0".default.override {
targets = [ "wasm32-unknown-unknown" ]; # wasm
};
# Nighly for creating lock files
nightly_toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
# Common inputs
envVars = { };
buildInputs = with pkgs; [
# Add additional build inputs here
git
pkg-config
curl
just
protobuf3_20
nixpkgs-fmt
rust-analyzer
] ++ libsDarwin;
# WASM deps
WASMInputs = with pkgs; [
];
nativeBuildInputs = with pkgs; [
# Add additional build inputs here
] ++ lib.optionals isDarwin [
# Additional darwin specific native inputs can be set here
];
in
{
devShells = flakeboxLib.mkShells {
toolchain = toolchainNative;
packages = [ ];
nativeBuildInputs = with pkgs; [ wasm-pack sqlx-cli protobuf3_20 ];
checks = {
# Pre-commit checks
pre-commit-check =
let
# this is a hack based on https://github.com/cachix/pre-commit-hooks.nix/issues/126
# we want to use our own rust stuff from oxalica's overlay
_rust = pkgs.rust-bin.stable.latest.default;
rust = pkgs.buildEnv {
name = _rust.name;
inherit (_rust) meta;
buildInputs = [ pkgs.makeWrapper ];
paths = [ _rust ];
pathsToLink = [ "/" "/bin" ];
postBuild = ''
for i in $out/bin/*; do
wrapProgram "$i" --prefix PATH : "$out/bin"
done
'';
};
});
in
pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
rustfmt = {
enable = true;
entry = lib.mkForce "${rust}/bin/cargo-fmt fmt --all -- --config format_code_in_doc_comments=true --check --color always";
};
nixpkgs-fmt.enable = true;
typos.enable = true;
commitizen.enable = true; # conventional commits
};
};
};
devShells =
let
# pre-commit-checks
_shellHook = (self.checks.${system}.pre-commit-check.shellHook or "");
# devShells
msrv = pkgs.mkShell ({
shellHook = "
${_shellHook}
cargo update -p half --precise 2.2.1
cargo update -p tokio --precise 1.38.1
cargo update -p reqwest --precise 0.12.4
cargo update -p serde_with --precise 3.1.0
cargo update -p regex --precise 1.9.6
cargo update -p backtrace --precise 0.3.58
# For wasm32-unknown-unknown target
cargo update -p bumpalo --precise 3.12.0
";
buildInputs = buildInputs ++ WASMInputs ++ [ msrv_toolchain ];
inherit nativeBuildInputs;
} // envVars);
stable = pkgs.mkShell ({
shellHook = "${_shellHook}";
buildInputs = buildInputs ++ WASMInputs ++ [ stable_toolchain ];
inherit nativeBuildInputs;
} // envVars);
db_shell = pkgs.mkShell ({
shellHook = "
${_shellHook}
cargo update -p half --precise 2.2.1
cargo update -p home --precise 0.5.5
cargo update -p tokio --precise 1.38.1
cargo update -p serde_with --precise 3.1.0
# cargo update -p prost-derive --precise 0.12.3
# cargo update -p prost --precise 0.12.3
# cargo update -p prost-build --precise 0.12.3
# cargo update -p prost-types --precise 0.12.3
";
buildInputs = buildInputs ++ WASMInputs ++ [ db_msrv_toolchain ];
inherit nativeBuildInputs;
} // envVars);
nightly = pkgs.mkShell ({
shellHook = "${_shellHook}";
buildInputs = buildInputs ++ [ nightly_toolchain ];
inherit nativeBuildInputs;
} // envVars);
in
{
inherit msrv stable nightly db_shell;
default = msrv;
};
}
);
}

View File

@@ -1,16 +1,13 @@
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
import "./misc/justfile.custom.just"
alias b := build
alias c := check
alias t := test
[private]
default:
@just --list
final-check: format clippy test
# run `cargo build` on everything
build *ARGS="--workspace --all-targets":
@@ -21,7 +18,6 @@ build *ARGS="--workspace --all-targets":
fi
cargo build {{ARGS}}
# run `cargo check` on everything
check *ARGS="--workspace --all-targets":
#!/usr/bin/env bash
@@ -31,17 +27,6 @@ check *ARGS="--workspace --all-targets":
fi
cargo check {{ARGS}}
# run all checks recommended before opening a PR
final-check: lint clippy
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
just test
# run code formatters
format:
#!/usr/bin/env bash
@@ -50,15 +35,7 @@ format:
cd {{invocation_directory()}}
fi
cargo fmt --all
nixpkgs-fmt $(git ls-files | grep "\.nix$")
# run lints (git pre-commit hook)
lint:
#!/usr/bin/env bash
set -euo pipefail
env NO_STASH=true $(git rev-parse --git-common-dir)/hooks/pre-commit
nixpkgs-fmt $(echo **.nix)
# run tests
test: build
@@ -69,52 +46,15 @@ test: build
fi
cargo test
# run and restart on changes
watch *ARGS="-x run":
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
env RUST_LOG=${RUST_LOG:-debug} cargo watch {{ARGS}}
# run `cargo clippy` on everything
clippy *ARGS="--locked --offline --workspace --all-targets":
cargo clippy {{ARGS}} -- --deny warnings --allow deprecated
cargo clippy {{ARGS}}
# run `cargo clippy --fix` on everything
clippy-fix *ARGS="--locked --offline --workspace --all-targets":
cargo clippy {{ARGS}} --fix
# run `semgrep`
semgrep:
env SEMGREP_ENABLE_VERSION_CHECK=0 \
semgrep --error --no-rewrite-rule-ids --config .config/semgrep.yaml
# check typos
[no-exit-message]
typos *PARAMS:
#!/usr/bin/env bash
set -eo pipefail
export FLAKEBOX_GIT_LS
FLAKEBOX_GIT_LS="$(git ls-files)"
export FLAKEBOX_GIT_LS_TEXT
FLAKEBOX_GIT_LS_TEXT="$(echo "$FLAKEBOX_GIT_LS" | grep -v -E "^db/|\.(png|ods|jpg|jpeg|woff2|keystore|wasm|ttf|jar|ico)\$")"
if ! echo "$FLAKEBOX_GIT_LS_TEXT" | typos {{PARAMS}} --file-list - --force-exclude ; then
>&2 echo "Typos found: Valid new words can be added to '.typos.toml'"
return 1
fi
# fix all typos
[no-exit-message]
typos-fix-all:
typos-fix:
just typos -w
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

View File

@@ -3,9 +3,3 @@ max_width = 100
newline_style = "Auto"
reorder_imports = true
reorder_modules = true
reorder_impl_items = false
indent_style = "Block"
normalize_comments = false
imports_granularity = "Module"
group_imports = "StdExternalCrate"
format_code_in_doc_comments = true