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

payjoin / rust-payjoin / 17447300776

03 Sep 2025 10:07PM UTC coverage: 85.469% (-0.5%) from 85.94%
17447300776

Pull #947

github

web-flow
Merge aed6dcf41 into e8829f334
Pull Request #947: Add config saving to payjoin-cli

2 of 55 new or added lines in 2 files covered. (3.64%)

6 existing lines in 1 file now uncovered.

8199 of 9593 relevant lines covered (85.47%)

487.32 hits per line

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

80.0
/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 tracing_subscriber::filter::LevelFilter;
7
use tracing_subscriber::EnvFilter;
8

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

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

16
#[tokio::main]
17
async fn main() -> Result<()> {
12✔
18
    let env_filter =
12✔
19
        EnvFilter::builder().with_default_directive(LevelFilter::INFO.into()).from_env_lossy();
12✔
20
    tracing_subscriber::fmt().with_target(true).with_level(true).with_env_filter(env_filter).init();
12✔
21

22
    let cli = Cli::parse();
12✔
23

24
    #[cfg(feature = "v2")]
25
    if cli.set_config {
10✔
NEW
26
        Config::save_config(&cli)?;
×
27
    }
10✔
28
    let config = Config::new(&cli)?;
12✔
29

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

68
    match &cli.command {
12✔
69
        Commands::Send { bip21, fee_rate } => {
5✔
70
            app.send_payjoin(bip21, *fee_rate).await?;
5✔
71
        }
72
        Commands::Receive { amount, .. } => {
4✔
73
            app.receive_payjoin(*amount).await?;
4✔
74
        }
75
        #[cfg(feature = "v2")]
76
        Commands::Resume => {
77
            app.resume_payjoins().await?;
3✔
78
        }
79
    };
80

81
    Ok(())
22✔
82
}
12✔
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