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

payjoin / rust-payjoin / 17841014742

18 Sep 2025 08:48PM UTC coverage: 79.013% (-5.6%) from 84.625%
17841014742

Pull #1091

github

web-flow
Merge 7d8163a27 into 0859949d5
Pull Request #1091: Add pki-https feature to prevent local cert validation on all-features

3 of 4 new or added lines in 1 file covered. (75.0%)

539 existing lines in 9 files now uncovered.

7556 of 9563 relevant lines covered (79.01%)

486.06 hits per line

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

92.31
/payjoin-cli/src/app/mod.rs
1
use std::collections::HashMap;
2

3
use anyhow::Result;
4
use payjoin::bitcoin::psbt::Psbt;
5
use payjoin::bitcoin::{self, Address, Amount, FeeRate};
6
use tokio::signal;
7
use tokio::sync::watch;
8

9
pub mod config;
10
pub mod wallet;
11
use crate::app::config::Config;
12
use crate::app::wallet::BitcoindWallet;
13

14
#[cfg(feature = "v1")]
15
pub(crate) mod v1;
16
#[cfg(feature = "v2")]
17
pub(crate) mod v2;
18

19
#[async_trait::async_trait]
20
pub trait App: Send + Sync {
21
    async fn new(config: Config) -> Result<Self>
22
    where
23
        Self: Sized;
24
    fn wallet(&self) -> BitcoindWallet;
25
    async fn send_payjoin(&self, bip21: &str, fee_rate: FeeRate) -> Result<()>;
26
    async fn receive_payjoin(&self, amount: Amount) -> Result<()>;
27
    #[cfg(feature = "v2")]
28
    async fn resume_payjoins(&self) -> Result<()>;
29
    #[cfg(feature = "v2")]
30
    async fn history(&self) -> Result<()>;
31

32
    fn create_original_psbt(
1✔
33
        &self,
1✔
34
        address: &Address,
1✔
35
        amount: Amount,
1✔
36
        fee_rate: FeeRate,
1✔
37
    ) -> Result<Psbt> {
1✔
38
        // wallet_create_funded_psbt requires a HashMap<address: String, Amount>
39
        let mut outputs = HashMap::with_capacity(1);
1✔
40
        outputs.insert(address.to_string(), amount);
1✔
41

42
        self.wallet().create_psbt(outputs, fee_rate, true)
1✔
43
    }
1✔
44

45
    fn process_pj_response(&self, psbt: Psbt) -> Result<bitcoin::Txid> {
1✔
46
        tracing::debug!("Proposed psbt: {psbt:#?}");
1✔
47

48
        let signed = self.wallet().process_psbt(&psbt)?;
1✔
49
        let tx = signed.extract_tx()?;
1✔
50

51
        let txid = self.wallet().broadcast_tx(&tx)?;
1✔
52

53
        println!("Payjoin sent. TXID: {txid}");
1✔
54
        Ok(txid)
1✔
55
    }
1✔
56
}
57

58
fn http_agent(_config: &Config) -> Result<reqwest::Client> {
1✔
59
    #[cfg(all(not(feature = "pki-https"), feature = "_manual-tls"))]
60
    {
61
        Ok(http_agent_builder(_config.root_certificate.as_ref())?.build()?)
1✔
62
    }
63

64
    #[cfg(feature = "pki-https")]
65
    {
NEW
66
        Ok(reqwest::Client::new())
×
67
    }
68
}
1✔
69

70
#[cfg(all(not(feature = "pki-https"), feature = "_manual-tls"))]
71
fn http_agent_builder(
1✔
72
    root_cert_path: Option<&std::path::PathBuf>,
1✔
73
) -> Result<reqwest::ClientBuilder> {
1✔
74
    let mut builder = reqwest::ClientBuilder::new().use_rustls_tls();
1✔
75

76
    if let Some(root_cert_path) = root_cert_path {
1✔
77
        let cert_der = std::fs::read(root_cert_path)?;
1✔
78
        builder =
1✔
79
            builder.add_root_certificate(reqwest::tls::Certificate::from_der(cert_der.as_slice())?)
1✔
80
    }
×
81
    Ok(builder)
1✔
82
}
1✔
83

84
async fn handle_interrupt(tx: watch::Sender<()>) {
2✔
85
    if let Err(e) = signal::ctrl_c().await {
2✔
86
        eprintln!("Error setting up Ctrl-C handler: {e}");
×
87
    }
1✔
88
    let _ = tx.send(());
1✔
89
}
1✔
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