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

payjoin / rust-payjoin / 14908012592

08 May 2025 01:44PM UTC coverage: 82.072% (+0.02%) from 82.057%
14908012592

Pull #684

github

web-flow
Merge 3c94839b7 into 7f2765642
Pull Request #684: Add derive macros to cli config

0 of 8 new or added lines in 1 file covered. (0.0%)

45 existing lines in 8 files now uncovered.

5475 of 6671 relevant lines covered (82.07%)

693.68 hits per line

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

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

4
use crate::uri::ShortId;
5
use crate::Version;
6

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

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

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

34
impl std::fmt::Display for IdenticalProposalError {
35
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4✔
36
        match self {
4✔
37
            IdenticalProposalError::IdenticalPsbts(current_psbt, incoming_psbt) => write!(
2✔
38
                f,
2✔
39
                "Two sender psbts are identical\n left psbt: {current_psbt}\n right 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: {current_context}\n right id: {incoming_context}"
2✔
44
            ),
2✔
45
        }
46
    }
4✔
47
}
48

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

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

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