Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 32 additions & 16 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ on: [push, pull_request]

name: CI

permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:

build-test:
Expand All @@ -17,30 +21,41 @@ 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:
Expand Down Expand Up @@ -82,13 +97,14 @@ jobs:
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ build: fmt
test:
cargo test --all-features --tests

# checks before pushing
pre-push:
cargo test --features default
cargo test --no-default-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
Expand Down
27 changes: 24 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ pub enum BDKCliError {

#[cfg(feature = "sqlite")]
#[error("Rusqlite error: {0}")]
RusqliteError(#[from] bdk_wallet::rusqlite::Error),
RusqliteError(Box<bdk_wallet::rusqlite::Error>),

#[cfg(feature = "redb")]
#[error("Redb StoreError: {0}")]
RedbStoreError(#[from] bdk_redb::error::StoreError),
RedbStoreError(Box<bdk_redb::error::StoreError>),

#[cfg(feature = "redb")]
#[error("Redb dabtabase error: {0}")]
RedbDatabaseError(#[from] bdk_redb::redb::DatabaseError),
RedbDatabaseError(Box<bdk_redb::redb::DatabaseError>),

#[error("Serde json error: {0}")]
SerdeJson(#[from] serde_json::Error),
Expand Down Expand Up @@ -147,3 +147,24 @@ impl From<ExtractTxError> for BDKCliError {
BDKCliError::PsbtExtractTxError(Box::new(value))
}
}

#[cfg(feature = "redb")]
impl From<bdk_redb::error::StoreError> for BDKCliError {
fn from(err: bdk_redb::error::StoreError) -> Self {
BDKCliError::RedbStoreError(Box::new(err))
}
}

#[cfg(feature = "redb")]
impl From<bdk_redb::redb::DatabaseError> for BDKCliError {
fn from(err: bdk_redb::redb::DatabaseError) -> Self {
BDKCliError::RedbDatabaseError(Box::new(err))
}
}

#[cfg(feature = "sqlite")]
impl From<bdk_wallet::rusqlite::Error> for BDKCliError {
fn from(err: bdk_wallet::rusqlite::Error) -> Self {
BDKCliError::RusqliteError(Box::new(err))
}
}
1 change: 1 addition & 0 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ pub fn handle_wallets_subcommand(datadir: &Path, pretty: bool) -> Result<String,
.wallets
.iter()
.map(|(name, wallet_config)| {
#[allow(unused_mut)]
let mut wallet_json = json!({
"name": name,
"network": wallet_config.network,
Expand Down
15 changes: 5 additions & 10 deletions src/payjoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> PayjoinManager<'a> {
let persister = payjoin::persist::NoopSessionPersister::<ReceiverSessionEvent>::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(
Expand Down Expand Up @@ -275,7 +275,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())),
}
}

Expand Down Expand Up @@ -305,8 +305,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}"
)));
}
}
Expand Down Expand Up @@ -609,16 +608,12 @@ impl<'a> PayjoinManager<'a> {
return Err(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()));
}
return Err(ImplementationError::from("Cannot find the transaction in the mempool or the blockchain"));
Err(ImplementationError::from("Cannot find the transaction in the mempool or the blockchain"))
},
|outpoint| {
let utxo = self.wallet.get_utxo(outpoint);
Expand Down
8 changes: 4 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub(crate) enum BlockchainClient {
},

#[cfg(feature = "cbf")]
KyotoClient { client: KyotoClientHandle },
KyotoClient { client: Box<KyotoClientHandle> },
}

/// Handle for the Kyoto client after the node has been started.
Expand Down Expand Up @@ -195,7 +195,7 @@ pub(crate) fn new_blockchain_client(
}
#[cfg(feature = "esplora")]
ClientType::Esplora => {
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,
Expand Down Expand Up @@ -245,10 +245,10 @@ pub(crate) fn new_blockchain_client(
);

BlockchainClient::KyotoClient {
client: KyotoClientHandle {
client: Box::new(KyotoClientHandle {
requester,
update_subscriber: tokio::sync::Mutex::new(update_subscriber),
},
}),
}
}
};
Expand Down
Loading