From e1e3cb4a7678bb0649d904ddf8dd70bc493d629f Mon Sep 17 00:00:00 2001 From: Vihiga Tyonum Date: Tue, 6 Jan 2026 11:10:25 +0100 Subject: [PATCH 1/5] ci: update cont_integration workflow - update actions/checkout to v6 - add separate job for clippy - automate manual caching in the build-test job - replace actions-r/toolchain with actions-rust- lang/setup-rust-toolchain for toolchain setup - update wasm job and replace build with check --- .github/workflows/cont_integration.yml | 99 +++++++++++++------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 91496638..90878f3a 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -2,6 +2,10 @@ on: [push, pull_request] name: CI +permissions: + contents: read +env: + CARGO_TERM_COLOR: always jobs: build-test: @@ -17,78 +21,71 @@ jobs: - --all-features steps: - name: Checkout - uses: actions/checkout@v4 - - name: Generate cache key - run: echo "${{ matrix.rust }} ${{ matrix.features }}" | tee .cache_key - - name: Cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} + uses: actions/checkout@v6 - name: Setup Rust Toolchain - uses: actions-rs/toolchain@v1 + uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: ${{ matrix.rust }} profile: minimal override: true components: rustfmt, clippy + cache: true - name: Build run: cargo build ${{ matrix.features }} - - name: Clippy - run: cargo clippy -- -D warnings - name: Test run: cargo test ${{ matrix.features }} + clippy: + name: Clippy (${{ matrix.features }}) + runs-on: ubuntu-latest + strategy: + matrix: + features: + - --no-default-features + - --all-features + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + components: clippy + cache: true + - name: Run Clippy + run: cargo clippy ${{ matrix.features }} --all-targets -- -D warnings -# TODO: fix or remove this -# wasm-build: -# name: Build WASM -# runs-on: ubuntu-20.04 -# env: -# CC: clang-10 -# CFLAGS: -I/usr/include -# steps: -# - name: Checkout -# uses: actions/checkout@v4 -# - name: Generate cache key -# run: echo "Build WASM" | tee .cache_key -# - name: Cache -# uses: actions/cache@v4 -# with: -# path: | -# ~/.cargo/registry -# ~/.cargo/git -# target -# key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} -# # Install a recent version of clang that supports wasm32 -# - run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1 -# - run: sudo apt-get update || exit 1 -# - run: sudo apt-get install -y libclang-common-10-dev clang-10 libc6-dev-i386 || exit 1 -# - name: Set default toolchain -# run: rustup default stable -# - name: Set profile -# run: rustup set profile minimal -# - name: Add target wasm32 -# run: rustup target add wasm32-unknown-unknown -# - name: Update toolchain -# run: rustup update -# - name: Build -# run: cargo build --target wasm32-unknown-unknown --no-default-features --features esplora,compiler,dev-getrandom-wasm - + wasm-build: + name: Check WASM + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + cache: true + target: wasm32-unknown-unknown + - name: Check WASM + run: cargo check --target wasm32-unknown-unknown --no-default-features --features esplora,compiler fmt: name: Rust fmt runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Rust Toolchain - uses: actions-rs/toolchain@v1 + uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable profile: minimal override: true components: rustfmt, clippy + cache: true - name: Check fmt run: cargo fmt --all -- --check From 55ae95807ca5bbcfaf336f141fe0635840c22ac4 Mon Sep 17 00:00:00 2001 From: Vihiga Tyonum Date: Tue, 6 Jan 2026 12:50:38 +0100 Subject: [PATCH 2/5] chore: fix clippy warnings --- src/error.rs | 27 ++++++++++++++++++++++++--- src/payjoin/mod.rs | 31 +++++++++++++++++-------------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/error.rs b/src/error.rs index 064a928d..0a50347e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -59,15 +59,15 @@ pub enum BDKCliError { #[cfg(feature = "sqlite")] #[error("Rusqlite error: {0}")] - RusqliteError(#[from] bdk_wallet::rusqlite::Error), + RusqliteError(Box), #[cfg(feature = "redb")] #[error("Redb StoreError: {0}")] - RedbStoreError(#[from] bdk_redb::error::StoreError), + RedbStoreError(Box), #[cfg(feature = "redb")] #[error("Redb dabtabase error: {0}")] - RedbDatabaseError(#[from] bdk_redb::redb::DatabaseError), + RedbDatabaseError(Box), #[error("Serde json error: {0}")] SerdeJson(#[from] serde_json::Error), @@ -119,3 +119,24 @@ impl From for BDKCliError { BDKCliError::PsbtExtractTxError(Box::new(value)) } } + +#[cfg(feature = "redb")] +impl From for BDKCliError { + fn from(err: bdk_redb::error::StoreError) -> Self { + BDKCliError::RedbStoreError(Box::new(err)) + } +} + +#[cfg(feature = "redb")] +impl From for BDKCliError { + fn from(err: bdk_redb::redb::DatabaseError) -> Self { + BDKCliError::RedbDatabaseError(Box::new(err)) + } +} + +#[cfg(feature = "sqlite")] +impl From for BDKCliError { + fn from(err: bdk_wallet::rusqlite::Error) -> Self { + BDKCliError::RusqliteError(Box::new(err)) + } +} diff --git a/src/payjoin/mod.rs b/src/payjoin/mod.rs index f5e1274c..38eed7e9 100644 --- a/src/payjoin/mod.rs +++ b/src/payjoin/mod.rs @@ -75,7 +75,7 @@ impl<'a> PayjoinManager<'a> { let persister = payjoin::persist::NoopSessionPersister::::default(); let checked_max_fee_rate = max_fee_rate - .map(|rate| FeeRate::from_sat_per_kwu(rate)) + .map(FeeRate::from_sat_per_kwu) .unwrap_or(FeeRate::BROADCAST_MIN); let receiver = payjoin::receive::v2::ReceiverBuilder::new( @@ -296,7 +296,7 @@ impl<'a> PayjoinManager<'a> { .await } ReceiveSession::HasReplyableError(error) => self.handle_error(error, persister).await, - ReceiveSession::Closed(_) => return Err(Error::Generic("Session closed".to_string())), + ReceiveSession::Closed(_) => Err(Error::Generic("Session closed".to_string())), } } @@ -333,8 +333,7 @@ impl<'a> PayjoinManager<'a> { } Err(e) => { return Err(Error::Generic(format!( - "Error occurred when polling for Payjoin proposal from the directory: {}", - e.to_string() + "Error occurred when polling for Payjoin proposal from the directory: {e}" ))); } } @@ -633,20 +632,24 @@ impl<'a> PayjoinManager<'a> { let check_result = receiver .check_payment( |txid| { - let Some(tx_details) = self.wallet.tx_details(txid) else { - return Err(ImplementationError::from("Cannot find the transaction in the mempool or the blockchain")); - }; + let tx_details = self.wallet.tx_details(txid) + .ok_or(ImplementationError::from( + "Cannot find the transaction in the mempool or the blockchain" + ))?; - let is_seen = match tx_details.chain_position { - bdk_wallet::chain::ChainPosition::Confirmed { .. } => true, - bdk_wallet::chain::ChainPosition::Unconfirmed { first_seen: Some(_), .. } => true, - _ => false - }; + let is_seen = matches!( + tx_details.chain_position, + bdk_wallet::chain::ChainPosition::Confirmed { .. } + | bdk_wallet::chain::ChainPosition::Unconfirmed { first_seen: Some(_), .. } + ); if is_seen { - return Ok(Some(tx_details.tx.as_ref().clone())); + Ok(Some(tx_details.tx.as_ref().clone())) + } else { + Err(ImplementationError::from( + "Cannot find the transaction in the mempool or the blockchain" + )) } - return Err(ImplementationError::from("Cannot find the transaction in the mempool or the blockchain")); }, |outpoint| { let utxo = self.wallet.get_utxo(outpoint); From 658df5968dfe0199948ac06af278cf5c33a06aa3 Mon Sep 17 00:00:00 2001 From: Vihiga Tyonum Date: Tue, 6 Jan 2026 12:51:32 +0100 Subject: [PATCH 3/5] ci: add prepush checks that mirrors ci workflow --- .github/workflows/cont_integration.yml | 51 ++++++++++++++++++-------- Justfile | 12 ++++++ 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 90878f3a..727f042b 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -57,22 +57,41 @@ jobs: - name: Run Clippy run: cargo clippy ${{ matrix.features }} --all-targets -- -D warnings - wasm-build: - name: Check WASM - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v6 - - name: Install Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - cache: true - target: wasm32-unknown-unknown - - name: Check WASM - run: cargo check --target wasm32-unknown-unknown --no-default-features --features esplora,compiler +# TODO: fix or remove this +# wasm-build: +# name: Build WASM +# runs-on: ubuntu-20.04 +# env: +# CC: clang-10 +# CFLAGS: -I/usr/include +# steps: +# - name: Checkout +# uses: actions/checkout@v4 +# - name: Generate cache key +# run: echo "Build WASM" | tee .cache_key +# - name: Cache +# uses: actions/cache@v4 +# with: +# path: | +# ~/.cargo/registry +# ~/.cargo/git +# target +# key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} +# # Install a recent version of clang that supports wasm32 +# - run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1 +# - run: sudo apt-get update || exit 1 +# - run: sudo apt-get install -y libclang-common-10-dev clang-10 libc6-dev-i386 || exit 1 +# - name: Set default toolchain +# run: rustup default stable +# - name: Set profile +# run: rustup set profile minimal +# - name: Add target wasm32 +# run: rustup target add wasm32-unknown-unknown +# - name: Update toolchain +# run: rustup update +# - name: Build +# run: cargo build --target wasm32-unknown-unknown --no-default-features --features esplora,compiler,dev-getrandom-wasm + fmt: name: Rust fmt runs-on: ubuntu-latest diff --git a/Justfile b/Justfile index 48425958..06296819 100644 --- a/Justfile +++ b/Justfile @@ -25,6 +25,18 @@ build: fmt test: cargo test --all-features --tests +# checks before pushing +pre-push: + cargo build --features default + cargo test --features default + cargo build --no-default-features + cargo test --no-default-features + cargo build --all-features + cargo test --all-features + cargo clippy --no-default-features --all-targets -- -D warnings + cargo clippy --all-features --all-targets -- -D warnings + cargo fmt --all -- --check + # clean the project target directory clean: cargo clean From c5414dd421d3cce31519d157de64e4b25d9aedaa Mon Sep 17 00:00:00 2001 From: Vihiga Tyonum Date: Sun, 8 Feb 2026 05:45:21 +0100 Subject: [PATCH 4/5] ci: Update audit workflow and `bytes` dependency - Add `tool-version` parameter in audit workflow that forces the `actions-rust-lang/audit` to download and use a version that supports CVSS 4.0. - update a transitive dependency `bytes` to v1.11. 1 that fixes `RUSTSEC-2026-0007` security vulnerability Fixes #239 --- .github/workflows/audit.yml | 3 ++- Cargo.lock | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 4faea52c..93806d53 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -13,7 +13,8 @@ jobs: security_audit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: actions-rust-lang/audit@v1 with: token: ${{ secrets.GITHUB_TOKEN }} + tool-version: 0.22.1 diff --git a/Cargo.lock b/Cargo.lock index 98036e68..562d7683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -569,9 +569,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" From 169890fc1159228cb8ad33ad0b6a076852fee9c8 Mon Sep 17 00:00:00 2001 From: Vihiga Tyonum Date: Sun, 8 Feb 2026 06:26:42 +0100 Subject: [PATCH 5/5] CI: Fix clippy issues --- src/handlers.rs | 1 + src/utils.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/handlers.rs b/src/handlers.rs index 1f867b41..749dddce 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -1156,6 +1156,7 @@ pub fn handle_wallets_subcommand(datadir: &Path, pretty: bool) -> Result { - let client = bdk_esplora::esplora_client::Builder::new(&url).build_async()?; + let client = bdk_esplora::esplora_client::Builder::new(url).build_async()?; BlockchainClient::Esplora { client: Box::new(client), parallel_requests: wallet_opts.parallel_requests,