2021-03-05 21:30:51 +03:00
|
|
|
// Copyright 2021 The Grin Developers
|
2019-02-13 18:05:19 +03:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
//! Implementation specific error types
|
|
|
|
use crate::core::libtx;
|
|
|
|
use crate::keychain;
|
|
|
|
use crate::libwallet;
|
2019-10-14 22:24:09 +03:00
|
|
|
use crate::util::secp;
|
2020-01-24 16:02:09 +03:00
|
|
|
use grin_wallet_util::OnionV3AddressError;
|
2019-02-13 18:05:19 +03:00
|
|
|
|
|
|
|
/// Wallet errors, mostly wrappers around underlying crypto or I/O errors.
|
2022-07-28 12:21:45 +03:00
|
|
|
#[derive(Clone, thiserror::Error, Eq, PartialEq, Debug)]
|
|
|
|
pub enum Error {
|
2019-02-13 18:05:19 +03:00
|
|
|
/// LibTX Error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("LibTx Error")]
|
|
|
|
LibTX(#[from] libtx::Error),
|
2019-02-13 18:05:19 +03:00
|
|
|
|
|
|
|
/// LibWallet Error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("LibWallet Error: {0}")]
|
|
|
|
LibWallet(#[from] libwallet::Error),
|
2019-02-13 18:05:19 +03:00
|
|
|
|
|
|
|
/// Keychain error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Keychain error")]
|
|
|
|
Keychain(#[from] keychain::Error),
|
2019-02-13 18:05:19 +03:00
|
|
|
|
2020-01-24 16:02:09 +03:00
|
|
|
/// Onion V3 Address Error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Onion V3 Address Error")]
|
|
|
|
OnionV3Address(#[from] OnionV3AddressError),
|
2020-01-24 16:02:09 +03:00
|
|
|
|
2022-02-03 18:33:41 +03:00
|
|
|
/// Error when obfs4proxy is not in the user path if TOR brigde is enabled
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Unable to find obfs4proxy binary in your path; {}", _0)]
|
2022-02-03 18:33:41 +03:00
|
|
|
Obfs4proxyBin(String),
|
|
|
|
|
|
|
|
/// Error the bridge input is in bad format
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Bridge line is in bad format; {}", _0)]
|
2022-02-03 18:33:41 +03:00
|
|
|
BridgeLine(String),
|
|
|
|
|
2019-02-13 18:05:19 +03:00
|
|
|
/// Error when formatting json
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("IO error")]
|
2019-02-13 18:05:19 +03:00
|
|
|
IO,
|
|
|
|
|
2019-10-14 22:24:09 +03:00
|
|
|
/// Secp Error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Secp error")]
|
|
|
|
Secp(#[from] secp::Error),
|
2019-10-14 22:24:09 +03:00
|
|
|
|
2019-02-13 18:05:19 +03:00
|
|
|
/// Error when formatting json
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Serde JSON error")]
|
2019-02-13 18:05:19 +03:00
|
|
|
Format,
|
|
|
|
|
|
|
|
/// Wallet seed already exists
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Wallet seed file exists: {}", _0)]
|
2019-02-13 18:05:19 +03:00
|
|
|
WalletSeedExists(String),
|
|
|
|
|
|
|
|
/// Wallet seed doesn't exist
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Wallet seed doesn't exist error")]
|
2019-02-13 18:05:19 +03:00
|
|
|
WalletSeedDoesntExist,
|
|
|
|
|
2019-06-04 18:48:04 +03:00
|
|
|
/// Wallet seed doesn't exist
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Wallet doesn't exist at {}. {}", _0, _1)]
|
2019-06-04 18:48:04 +03:00
|
|
|
WalletDoesntExist(String, String),
|
|
|
|
|
2019-02-13 18:05:19 +03:00
|
|
|
/// Enc/Decryption Error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Enc/Decryption error (check password?)")]
|
2019-02-13 18:05:19 +03:00
|
|
|
Encryption,
|
|
|
|
|
|
|
|
/// BIP 39 word list
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("BIP39 Mnemonic (word list) Error")]
|
2019-02-13 18:05:19 +03:00
|
|
|
Mnemonic,
|
|
|
|
|
|
|
|
/// Command line argument error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("{}", _0)]
|
2019-02-13 18:05:19 +03:00
|
|
|
ArgumentError(String),
|
|
|
|
|
2022-02-03 18:33:41 +03:00
|
|
|
/// Tor Bridge error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Tor Bridge Error: {}", _0)]
|
2022-02-03 18:33:41 +03:00
|
|
|
TorBridge(String),
|
|
|
|
|
|
|
|
/// Tor Proxy error
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Tor Proxy Error: {}", _0)]
|
2022-02-03 18:33:41 +03:00
|
|
|
TorProxy(String),
|
|
|
|
|
2019-10-14 22:24:09 +03:00
|
|
|
/// Generating ED25519 Public Key
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Error generating ed25519 secret key: {}", _0)]
|
2019-10-14 22:24:09 +03:00
|
|
|
ED25519Key(String),
|
|
|
|
|
|
|
|
/// Checking for onion address
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Address is not an Onion v3 Address: {}", _0)]
|
2019-11-28 17:34:27 +03:00
|
|
|
NotOnion(String),
|
2019-10-14 22:24:09 +03:00
|
|
|
|
2019-02-13 18:05:19 +03:00
|
|
|
/// Other
|
2022-07-28 12:21:45 +03:00
|
|
|
#[error("Generic error: {}", _0)]
|
2019-02-13 18:05:19 +03:00
|
|
|
GenericError(String),
|
|
|
|
}
|