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

payjoin / rust-payjoin / 14668859162

25 Apr 2025 04:11PM UTC coverage: 82.032% (+0.1%) from 81.936%
14668859162

Pull #642

github

web-flow
Merge d3108b324 into 64d411c5a
Pull Request #642: Duplicate proposals catch in ns1r

118 of 138 new or added lines in 3 files covered. (85.51%)

2 existing lines in 1 file now uncovered.

5433 of 6623 relevant lines covered (82.03%)

698.3 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::uri::ShortId;
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<ShortId>, Box<ShortId>),
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 psbt: {}\n right psbt: {}",
2✔
39
                current_psbt, incoming_psbt
2✔
40
            ),
2✔
41
            IdenticalProposalError::IdenticalContexts(current_context, incoming_context) => write!(
2✔
42
                f,
2✔
43
                "Two sender contexts are identical\n left id: {}\n right id: {}",
2✔
44
                current_context, incoming_context
2✔
45
            ),
2✔
46
        }
47
    }
4✔
48
}
49

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

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

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