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

payjoin / rust-payjoin / 16922624363

12 Aug 2025 10:41PM UTC coverage: 85.356% (-0.5%) from 85.874%
16922624363

Pull #947

github

web-flow
Merge e6760ab78 into ffeabdd4a
Pull Request #947: Draft:Add config saving to payjoin-cli

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

7 existing lines in 2 files now uncovered.

7461 of 8741 relevant lines covered (85.36%)

533.09 hits per line

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

78.26
/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

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

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

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

18
    let cli = Cli::parse();
10✔
19

20
    #[cfg(feature = "v2")]
21
    if cli.set_config {
8✔
NEW
UNCOV
22
        Config::save_config(&cli)?;
×
23
    }
8✔
24
    let config = Config::new(&cli)?;
10✔
25

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

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

77
    Ok(())
18✔
78
}
10✔
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