• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

payjoin / rust-payjoin / 15323824025

29 May 2025 12:27PM UTC coverage: 84.292% (-0.3%) from 84.553%
15323824025

Pull #703

github

web-flow
Merge 5537853fe into 16f0c20fa
Pull Request #703: Refactor config to use derive macros over builder

116 of 130 new or added lines in 3 files covered. (89.23%)

1 existing line in 1 file now uncovered.

6402 of 7595 relevant lines covered (84.29%)

609.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.72
/payjoin-cli/src/main.rs
1
use anyhow::Result;
2
use app::config::Config;
3
use app::App as AppTrait;
4
use clap::Parser;
5
use cli::{Cli, Commands};
6
use payjoin::bitcoin::FeeRate;
7

8
mod app;
9
mod cli;
10
mod db;
11

12
#[cfg(not(any(feature = "v1", feature = "v2")))]
13
compile_error!("At least one of the features ['v1', 'v2'] must be enabled");
14

15
#[tokio::main]
16
async fn main() -> Result<()> {
8✔
17
    env_logger::init();
8✔
18

8✔
19
    let cli = Cli::parse();
8✔
20
    let config = Config::new(&cli)?;
8✔
21

8✔
22
    #[allow(clippy::if_same_then_else)]
8✔
23
    let app: Box<dyn AppTrait> = if cli.flags.bip78.unwrap_or(false) {
8✔
24
        #[cfg(feature = "v1")]
8✔
25
        {
8✔
26
            Box::new(crate::app::v1::App::new(config)?)
8✔
27
        }
8✔
28
        #[cfg(not(feature = "v1"))]
8✔
29
        {
8✔
30
            anyhow::bail!(
8✔
31
                "BIP78 (v1) support is not enabled in this build. Recompile with --features v1"
8✔
32
            )
8✔
33
        }
8✔
34
    } else if cli.flags.bip77.unwrap_or(false) {
8✔
35
        #[cfg(feature = "v2")]
8✔
36
        {
8✔
37
            Box::new(crate::app::v2::App::new(config)?)
8✔
38
        }
8✔
39
        #[cfg(not(feature = "v2"))]
8✔
40
        {
8✔
41
            anyhow::bail!(
8✔
42
                "BIP77 (v2) support is not enabled in this build. Recompile with --features v2"
×
UNCOV
43
            )
×
44
        }
8✔
45
    } else {
8✔
46
        #[cfg(feature = "v2")]
8✔
47
        {
8✔
48
            Box::new(crate::app::v2::App::new(config)?)
8✔
49
        }
8✔
50
        #[cfg(all(feature = "v1", not(feature = "v2")))]
8✔
51
        {
8✔
52
            Box::new(crate::app::v1::App::new(config)?)
8✔
53
        }
8✔
54
        #[cfg(not(any(feature = "v1", feature = "v2")))]
8✔
55
        {
8✔
56
            anyhow::bail!("No valid version available - must compile with v1 or v2 feature")
8✔
57
        }
8✔
58
    };
8✔
59

8✔
60
    match &cli.command {
8✔
61
        Commands::Send { bip21, fee_rate } => {
8✔
62
            let fee = fee_rate
4✔
63
                .unwrap_or_else(|| FeeRate::from_sat_per_vb(2).unwrap_or(FeeRate::BROADCAST_MIN));
4✔
64
            app.send_payjoin(bip21, fee).await?;
4✔
65
        }
8✔
66
        Commands::Receive { amount, .. } => {
8✔
67
            app.receive_payjoin(*amount).await?;
3✔
68
        }
8✔
69
        #[cfg(feature = "v2")]
8✔
70
        Commands::Resume => {
8✔
71
            app.resume_payjoins().await?;
8✔
72
        }
8✔
73
    };
8✔
74

8✔
75
    Ok(())
8✔
76
}
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc