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

payjoin / rust-payjoin / 16698185129

02 Aug 2025 10:05PM UTC coverage: 85.965% (-0.06%) from 86.023%
16698185129

Pull #913

github

web-flow
Merge b4f1f6252 into a5d82d1df
Pull Request #913: e2e test concurrency fixes

78 of 104 new or added lines in 5 files covered. (75.0%)

33 existing lines in 2 files now uncovered.

8030 of 9341 relevant lines covered (85.97%)

501.94 hits per line

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

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

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

11
pub mod config;
12
pub mod wallet;
13
use crate::app::config::Config;
14
use crate::app::wallet::BitcoindWallet;
15

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

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

32
    fn create_original_psbt(&self, uri: &PjUri, fee_rate: FeeRate) -> Result<Psbt> {
3✔
33
        let amount = uri.amount.ok_or_else(|| anyhow!("please specify the amount in the Uri"))?;
3✔
34

35
        // wallet_create_funded_psbt requires a HashMap<address: String, Amount>
36
        let mut outputs = HashMap::with_capacity(1);
3✔
37
        outputs.insert(uri.address.to_string(), amount);
3✔
38

39
        self.wallet().create_psbt(outputs, fee_rate, true)
3✔
40
    }
3✔
41

42
    fn process_pj_response(&self, psbt: Psbt) -> Result<bitcoin::Txid> {
3✔
43
        log::debug!("Proposed psbt: {psbt:#?}");
3✔
44

45
        let signed = self.wallet().process_psbt(&psbt)?;
3✔
46
        let tx = self.wallet().finalize_psbt(&signed)?;
3✔
47

48
        let txid = self.wallet().broadcast_tx(&tx)?;
3✔
49

50
        println!("Payjoin sent. TXID: {txid}");
3✔
51
        Ok(txid)
3✔
52
    }
3✔
53
}
54

55
#[cfg(feature = "_danger-local-https")]
56
fn http_agent(config: &crate::app::Config) -> Result<reqwest::Client> {
9✔
57
    Ok(http_agent_builder(config.root_certificate.as_ref())?.build()?)
9✔
58
}
9✔
59

60
#[cfg(not(feature = "_danger-local-https"))]
61
fn http_agent(_config: &crate::app::Config) -> Result<reqwest::Client> {
62
    Ok(reqwest::Client::new())
63
}
64

65
#[cfg(feature = "_danger-local-https")]
66
fn http_agent_builder(
9✔
67
    root_cert_path: Option<&std::path::PathBuf>,
9✔
68
) -> Result<reqwest::ClientBuilder> {
9✔
69
    let mut builder = reqwest::ClientBuilder::new().use_rustls_tls();
9✔
70

71
    if let Some(root_cert_path) = root_cert_path {
9✔
72
        let cert_der = std::fs::read(root_cert_path)?;
9✔
73
        builder =
9✔
74
            builder.add_root_certificate(reqwest::tls::Certificate::from_der(cert_der.as_slice())?)
9✔
UNCOV
75
    }
×
76
    Ok(builder)
9✔
77
}
9✔
78

79
async fn handle_interrupt(tx: watch::Sender<()>) {
10✔
80
    if let Err(e) = signal::ctrl_c().await {
10✔
UNCOV
81
        eprintln!("Error setting up Ctrl-C handler: {e}");
×
82
    }
7✔
83
    let _ = tx.send(());
7✔
84
}
7✔
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