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

payjoin / rust-payjoin / 14538321428

18 Apr 2025 04:30PM UTC coverage: 81.931% (+0.1%) from 81.835%
14538321428

Pull #642

github

web-flow
Merge 10093ba0c into 3b23dcaf5
Pull Request #642: Duplicate proposals catch in ns1r

117 of 137 new or added lines in 3 files covered. (85.4%)

2 existing lines in 1 file now uncovered.

5432 of 6630 relevant lines covered (81.93%)

697.54 hits per line

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

52.63
/payjoin/src/receive/multiparty/error.rs
1
use core::fmt;
2
use std::error;
3

4
use crate::receive;
5

6
#[derive(Debug)]
7
pub struct MultipartyError(InternalMultipartyError);
8

9
#[derive(Debug)]
10
pub(crate) enum InternalMultipartyError {
11
    /// Not enough proposals
12
    NotEnoughProposals,
13
    /// Duplicate proposals
14
    IdenticalProposals(IdenticalProposalError),
15
    /// Proposal version not supported
16
    ProposalVersionNotSupported(usize),
17
    /// Optimistic merge not supported
18
    OptimisticMergeNotSupported,
19
    /// Bitcoin Internal Error
20
    BitcoinExtractTxError(Box<bitcoin::psbt::ExtractTxError>),
21
    /// Input in Finalized Proposal is missing witness or script_sig
22
    InputMissingWitnessOrScriptSig,
23
    /// Failed to combine psbts
24
    FailedToCombinePsbts(bitcoin::psbt::Error),
25
}
26

27
#[derive(Debug)]
28
pub enum IdenticalProposalError {
29
    IdenticalPsbts(Box<bitcoin::Psbt>, Box<bitcoin::Psbt>),
30
    IdenticalContexts(Box<receive::v2::UncheckedProposal>, Box<receive::v2::UncheckedProposal>),
31
}
32

33
impl std::fmt::Display for IdenticalProposalError {
34
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4✔
35
        match self {
4✔
36
            IdenticalProposalError::IdenticalPsbts(current_psbt, incoming_psbt) => write!(
2✔
37
                f,
2✔
38
                "Two sender psbts are identical\n left: {}\n right: {}",
2✔
39
                current_psbt, incoming_psbt
2✔
40
            ),
2✔
41
            #[cfg(feature = "v2")]
42
            IdenticalProposalError::IdenticalContexts(current_context, incoming_context) => write!(
2✔
43
                f,
2✔
44
                "Two sender contexts are identical\n left: {:?}\n right: {:?}",
2✔
45
                current_context.context, incoming_context.context
2✔
46
            ),
2✔
47
        }
48
    }
4✔
49
}
50

51
impl From<InternalMultipartyError> for MultipartyError {
52
    fn from(e: InternalMultipartyError) -> Self { MultipartyError(e) }
6✔
53
}
54

55
impl fmt::Display for MultipartyError {
56
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6✔
57
        match &self.0 {
6✔
58
            InternalMultipartyError::NotEnoughProposals => write!(f, "Not enough proposals"),
2✔
59
            InternalMultipartyError::IdenticalProposals(e) =>
4✔
60
                write!(f, "More than one identical participant: {}", e),
4✔
61
            InternalMultipartyError::ProposalVersionNotSupported(v) =>
×
62
                write!(f, "Proposal version not supported: {}", v),
×
63
            InternalMultipartyError::OptimisticMergeNotSupported =>
64
                write!(f, "Optimistic merge not supported"),
×
65
            InternalMultipartyError::BitcoinExtractTxError(e) =>
×
66
                write!(f, "Bitcoin extract tx error: {:?}", e),
×
67
            InternalMultipartyError::InputMissingWitnessOrScriptSig =>
68
                write!(f, "Input in Finalized Proposal is missing witness or script_sig"),
×
69
            InternalMultipartyError::FailedToCombinePsbts(e) =>
×
70
                write!(f, "Failed to combine psbts: {:?}", e),
×
71
        }
72
    }
6✔
73
}
74

75
impl error::Error for MultipartyError {
76
    fn source(&self) -> Option<&(dyn error::Error + 'static)> {
×
77
        match &self.0 {
×
78
            InternalMultipartyError::NotEnoughProposals => None,
×
NEW
79
            InternalMultipartyError::IdenticalProposals(_) => None,
×
80
            InternalMultipartyError::ProposalVersionNotSupported(_) => None,
×
81
            InternalMultipartyError::OptimisticMergeNotSupported => None,
×
82
            InternalMultipartyError::BitcoinExtractTxError(e) => Some(e),
×
83
            InternalMultipartyError::InputMissingWitnessOrScriptSig => None,
×
84
            InternalMultipartyError::FailedToCombinePsbts(e) => Some(e),
×
85
        }
86
    }
×
87
}
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