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

tari-project / tari / 16123384529

07 Jul 2025 05:11PM UTC coverage: 64.327% (-7.6%) from 71.89%
16123384529

push

github

web-flow
chore: new release v4.9.0-pre.0 (#7289)

Description
---
new release esmeralda

77151 of 119935 relevant lines covered (64.33%)

227108.34 hits per line

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

0.0
/base_layer/wallet/src/error.rs
1
// Copyright 2019. The Tari Project
2
//
3
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
// following conditions are met:
5
//
6
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
// disclaimer.
8
//
9
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
// following disclaimer in the documentation and/or other materials provided with the distribution.
11
//
12
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13
// products derived from this software without specific prior written permission.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22

23
use diesel::result::Error as DieselError;
24
use log::SetLoggerError;
25
use serde_json::Error as SerdeJsonError;
26
use tari_common::exit_codes::{ExitCode, ExitError};
27
use tari_common_sqlite::error::SqliteStorageError;
28
use tari_comms::{
29
    connectivity::ConnectivityError,
30
    multiaddr,
31
    peer_manager::{node_id::NodeIdError, PeerManagerError},
32
};
33
use tari_contacts::contacts_service::error::ContactsServiceError;
34
use tari_core::transactions::{
35
    transaction_components::TransactionError,
36
    transaction_key_manager::error::KeyManagerServiceError,
37
};
38
use tari_key_manager::error::KeyManagerError;
39
use tari_p2p::{initialization::CommsInitializationError, services::liveness::error::LivenessError};
40
use tari_service_framework::{reply_channel::TransportChannelError, ServiceInitializationError};
41
use tari_utilities::{hex::HexError, ByteArrayError};
42
use thiserror::Error;
43

44
use crate::{
45
    base_node_service::error::BaseNodeServiceError,
46
    connectivity_service::WalletConnectivityError,
47
    output_manager_service::error::OutputManagerError,
48
    storage::database::DbKey,
49
    transaction_service::error::TransactionServiceError,
50
};
51

52
#[derive(Debug, Error)]
53
pub enum WalletError {
54
    #[error("Argument supplied `{argument}` has an invalid value: {value}. {message}")]
55
    ArgumentError {
56
        argument: String,
57
        value: String,
58
        message: String,
59
    },
60
    #[error("Comms initialization error: `{0}`")]
61
    CommsInitializationError(#[from] CommsInitializationError),
62
    #[error("Output manager error: `{0}`")]
63
    OutputManagerError(#[from] OutputManagerError),
64
    #[error("Transaction service error: `{0}`")]
65
    TransactionServiceError(#[from] TransactionServiceError),
66
    #[error("Peer manager error: `{0}`")]
67
    PeerManagerError(#[from] PeerManagerError),
68
    #[error("Multiaddr error: `{0}`")]
69
    MultiaddrError(#[from] multiaddr::Error),
70
    #[error("Wallet storage error: `{0}`")]
71
    WalletStorageError(#[from] WalletStorageError),
72
    #[error("Set logger error: `{0}`")]
73
    SetLoggerError(#[from] SetLoggerError),
74
    #[error("Contacts service error: `{0}`")]
75
    ContactsServiceError(#[from] ContactsServiceError),
76
    #[error("Liveness service error: `{0}`")]
77
    LivenessServiceError(#[from] LivenessError),
78
    #[error("Connectivity error: `{0}`")]
79
    ConnectivityError(#[from] ConnectivityError),
80
    #[error("Failed to initialize services: {0}")]
81
    ServiceInitializationError(#[from] ServiceInitializationError),
82
    #[error("Base Node Service error: {0}")]
83
    BaseNodeServiceError(#[from] BaseNodeServiceError),
84
    #[error("Node ID error: `{0}`")]
85
    NodeIdError(#[from] NodeIdError),
86
    #[error("Error performing wallet recovery: '{0}'")]
87
    WalletRecoveryError(String),
88
    #[error("Shutdown Signal Received")]
89
    Shutdown,
90
    #[error("Transaction Error: {0}")]
91
    TransactionError(#[from] TransactionError),
92
    #[error("Byte array error")]
93
    ByteArrayError(String),
94
    #[error("Utxo Scanner Error: {0}")]
95
    UtxoScannerError(String),
96
    #[error("Key manager error: `{0}`")]
97
    KeyManagerError(#[from] KeyManagerError),
98
    #[error("Key manager service error: `{0}`")]
99
    KeyManagerServiceError(#[from] KeyManagerServiceError),
100
    #[error("Transport channel error: `{0}`")]
101
    TransportChannelError(#[from] TransportChannelError),
102
    #[error("Unexpected API Response while calling method `{method}` on `{api}`")]
103
    UnexpectedApiResponse { method: String, api: String },
104
    #[error("Public address not set for this wallet")]
105
    PublicAddressNotSet,
106
    #[error("Wallet connectivity error: `{0}`")]
107
    WalletConnectivityError(#[from] WalletConnectivityError),
108
    #[error("Invalid http node url: `{0}`")]
109
    InvalidHttpNodeUrl(String),
110
}
111

112
pub const LOG_TARGET: &str = "minotari::application";
113
impl From<ByteArrayError> for WalletError {
114
    fn from(err: ByteArrayError) -> Self {
×
115
        Self::ByteArrayError(err.to_string())
×
116
    }
×
117
}
118

119
impl From<WalletError> for ExitError {
120
    fn from(err: WalletError) -> Self {
×
121
        log::error!(target: LOG_TARGET, "{}", err);
×
122
        Self::new(ExitCode::WalletError, err.to_string())
×
123
    }
×
124
}
125

126
#[derive(Debug, Error)]
127
pub enum WalletStorageError {
128
    #[error("Tried to insert an output that already exists in the database")]
129
    DuplicateContact,
130
    #[error("This write operation is not supported for provided DbKey")]
131
    OperationNotSupported,
132
    #[error("Error converting a type: `{0}`")]
133
    ConversionError(String),
134
    #[error("Could not find all values specified for batch operation")]
135
    ValuesNotFound,
136
    #[error("Db Path does not exist")]
137
    DbPathDoesNotExist,
138
    #[error("Serde json error: `{0}`")]
139
    SerdeJsonError(#[from] SerdeJsonError),
140
    #[error("Diesel R2d2 error: `{0}`")]
141
    DieselR2d2Error(#[from] SqliteStorageError),
142
    #[error("Diesel error: `{0}`")]
143
    DieselError(#[from] DieselError),
144
    #[error("Diesel connection error: `{0}`")]
145
    DieselConnectionError(#[from] diesel::ConnectionError),
146
    #[error("Database migration error")]
147
    DatabaseMigrationError(String),
148
    #[error("Value not found: `{}`", .0.to_key_string())]
149
    ValueNotFound(DbKey),
150
    #[error("Burnt proof not found: `{0}`")]
151
    BurntProofNotFound(u32),
152
    #[error("Unexpected result: `{0}`")]
153
    UnexpectedResult(String),
154
    #[error("Blocking task spawn error: `{0}`")]
155
    BlockingTaskSpawnError(String),
156
    #[error("File error: `{0}`")]
157
    FileError(String),
158
    #[error("The storage path was invalid unicode or not supported by the host OS")]
159
    InvalidUnicodePath,
160
    #[error("Hex error: `{0}`")]
161
    HexError(String),
162
    #[error("Invalid Encryption Cipher was provided to database")]
163
    InvalidEncryptionCipher,
164
    #[error("Invalid passphrase was provided")]
165
    InvalidPassphrase,
166
    #[error("Missing Nonce in encrypted data")]
167
    MissingNonce,
168
    #[error("Aead error: `{0}`")]
169
    AeadError(String),
170
    #[error("Wallet db is already encrypted and cannot be encrypted until the previous encryption is removed")]
171
    AlreadyEncrypted,
172
    #[error("Byte array error: `{0}`")]
173
    ByteArrayError(String),
174
    #[error("Cannot acquire exclusive file lock, another instance of the application is already running")]
175
    CannotAcquireFileLock,
176
    #[error("Database file cannot be a root path")]
177
    DatabasePathIsRootPath,
178
    #[error("IO Error: `{0}`")]
179
    IoError(#[from] std::io::Error),
180
    #[error("No password provided for encrypted wallet")]
181
    NoPasswordError,
182
    #[error("Deprecated operation error")]
183
    DeprecatedOperation,
184
    #[error("Key Manager Error: `{0}`")]
185
    KeyManagerError(#[from] KeyManagerError),
186
    #[error("Recovery Seed Error: {0}")]
187
    RecoverySeedError(String),
188
    #[error("Bad encryption version: `{0}`")]
189
    BadEncryptionVersion(String),
190
}
191

192
impl From<HexError> for WalletStorageError {
193
    fn from(err: HexError) -> Self {
×
194
        WalletStorageError::HexError(err.to_string())
×
195
    }
×
196
}
197

198
impl From<ByteArrayError> for WalletStorageError {
199
    fn from(e: ByteArrayError) -> Self {
×
200
        WalletStorageError::ByteArrayError(e.to_string())
×
201
    }
×
202
}
203

204
impl From<WalletStorageError> for ExitError {
205
    fn from(err: WalletStorageError) -> Self {
×
206
        use WalletStorageError::{InvalidPassphrase, NoPasswordError};
207
        match err {
×
208
            NoPasswordError | InvalidPassphrase => ExitCode::IncorrectOrEmptyPassword.into(),
×
209
            e => ExitError::new(ExitCode::WalletError, e),
×
210
        }
211
    }
×
212
}
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