thiserror 2.0, cargo update

This commit is contained in:
Luke Parker
2024-12-08 21:55:37 -05:00
parent 3192370484
commit 18897978d0
35 changed files with 645 additions and 667 deletions

View File

@@ -21,7 +21,7 @@ workspace = true
[dependencies]
std-shims = { path = "../../../common/std-shims", version = "^0.1.1", default-features = false }
thiserror = { version = "1", default-features = false, optional = true }
thiserror = { version = "2", default-features = false }
zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] }
@@ -61,7 +61,7 @@ monero-simple-request-rpc = { path = "../rpc/simple-request", default-features =
std = [
"std-shims/std",
"thiserror",
"thiserror/std",
"zeroize/std",

View File

@@ -18,7 +18,7 @@ workspace = true
[dependencies]
std-shims = { path = "../../../../common/std-shims", version = "^0.1.1", default-features = false }
thiserror = { version = "1", default-features = false, optional = true }
thiserror = { version = "2", default-features = false }
zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] }
@@ -40,7 +40,7 @@ serde_json = { version = "1", default-features = false, features = ["alloc"] }
std = [
"std-shims/std",
"thiserror",
"thiserror/std",
"zeroize/std",

View File

@@ -199,29 +199,25 @@ pub enum Network {
}
/// Errors when decoding an address.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
pub enum AddressError {
/// The address had an invalid (network, type) byte.
#[cfg_attr(feature = "std", error("invalid byte for the address's network/type ({0})"))]
#[error("invalid byte for the address's network/type ({0})")]
InvalidTypeByte(u8),
/// The address wasn't a valid Base58Check (as defined by Monero) string.
#[cfg_attr(feature = "std", error("invalid address encoding"))]
#[error("invalid address encoding")]
InvalidEncoding,
/// The data encoded wasn't the proper length.
#[cfg_attr(feature = "std", error("invalid length"))]
#[error("invalid length")]
InvalidLength,
/// The address had an invalid key.
#[cfg_attr(feature = "std", error("invalid key"))]
#[error("invalid key")]
InvalidKey,
/// The address was featured with unrecognized features.
#[cfg_attr(feature = "std", error("unknown features"))]
#[error("unknown features")]
UnknownFeatures(u64),
/// The network was for a different network than expected.
#[cfg_attr(
feature = "std",
error("different network ({actual:?}) than expected ({expected:?})")
)]
#[error("different network ({actual:?}) than expected ({expected:?})")]
DifferentNetwork {
/// The Network expected.
expected: Network,

View File

@@ -18,7 +18,7 @@ workspace = true
[dependencies]
std-shims = { path = "../../../../common/std-shims", version = "^0.1.1", default-features = false }
thiserror = { version = "1", default-features = false, optional = true }
thiserror = { version = "2", default-features = false }
subtle = { version = "^2.4", default-features = false }
zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] }
@@ -34,7 +34,7 @@ hex = { version = "0.4", default-features = false, features = ["std"] }
std = [
"std-shims/std",
"thiserror",
"thiserror/std",
"subtle/std",
"zeroize/std",

View File

@@ -106,20 +106,19 @@ const POLYSEED_KEYGEN_ITERATIONS: u32 = 10000;
const COIN: u16 = 0;
/// An error when working with a Polyseed.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
pub enum PolyseedError {
/// The seed was invalid.
#[cfg_attr(feature = "std", error("invalid seed"))]
#[error("invalid seed")]
InvalidSeed,
/// The entropy was invalid.
#[cfg_attr(feature = "std", error("invalid entropy"))]
#[error("invalid entropy")]
InvalidEntropy,
/// The checksum did not match the data.
#[cfg_attr(feature = "std", error("invalid checksum"))]
#[error("invalid checksum")]
InvalidChecksum,
/// Unsupported feature bits were set.
#[cfg_attr(feature = "std", error("unsupported features"))]
#[error("unsupported features")]
UnsupportedFeatures,
}

View File

@@ -18,7 +18,7 @@ workspace = true
[dependencies]
std-shims = { path = "../../../../common/std-shims", version = "^0.1.1", default-features = false }
thiserror = { version = "1", default-features = false, optional = true }
thiserror = { version = "2", default-features = false }
zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] }
rand_core = { version = "0.6", default-features = false }
@@ -33,7 +33,7 @@ monero-primitives = { path = "../../primitives", default-features = false, featu
std = [
"std-shims/std",
"thiserror",
"thiserror/std",
"zeroize/std",
"rand_core/std",

View File

@@ -26,19 +26,18 @@ const SEED_LENGTH: usize = 24;
const SEED_LENGTH_WITH_CHECKSUM: usize = 25;
/// An error when working with a seed.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
pub enum SeedError {
#[cfg_attr(feature = "std", error("invalid seed"))]
#[error("invalid seed")]
/// The seed was invalid.
InvalidSeed,
/// The checksum did not match the data.
#[cfg_attr(feature = "std", error("invalid checksum"))]
#[error("invalid checksum")]
InvalidChecksum,
/// The deprecated English language option was used with a checksum.
///
/// The deprecated English language option did not include a checksum.
#[cfg_attr(feature = "std", error("deprecated English language option included a checksum"))]
#[error("deprecated English language option included a checksum")]
DeprecatedEnglishWithChecksum,
}

View File

@@ -67,14 +67,13 @@ impl Timelocked {
}
/// Errors when scanning a block.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
pub enum ScanError {
/// The block was for an unsupported protocol version.
#[cfg_attr(feature = "std", error("unsupported protocol version ({0})"))]
#[error("unsupported protocol version ({0})")]
UnsupportedProtocol(u8),
/// The ScannableBlock was invalid.
#[cfg_attr(feature = "std", error("invalid scannable block ({0})"))]
#[error("invalid scannable block ({0})")]
InvalidScannableBlock(&'static str),
}

View File

@@ -140,48 +140,44 @@ impl InternalPayment {
}
/// An error while sending Monero.
#[derive(Clone, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Clone, PartialEq, Eq, Debug, thiserror::Error)]
pub enum SendError {
/// The RingCT type to produce proofs for this transaction with weren't supported.
#[cfg_attr(feature = "std", error("this library doesn't yet support that RctType"))]
#[error("this library doesn't yet support that RctType")]
UnsupportedRctType,
/// The transaction had no inputs specified.
#[cfg_attr(feature = "std", error("no inputs"))]
#[error("no inputs")]
NoInputs,
/// The decoy quantity was invalid for the specified RingCT type.
#[cfg_attr(feature = "std", error("invalid number of decoys"))]
#[error("invalid number of decoys")]
InvalidDecoyQuantity,
/// The transaction had no outputs specified.
#[cfg_attr(feature = "std", error("no outputs"))]
#[error("no outputs")]
NoOutputs,
/// The transaction had too many outputs specified.
#[cfg_attr(feature = "std", error("too many outputs"))]
#[error("too many outputs")]
TooManyOutputs,
/// The transaction did not have a change output, and did not have two outputs.
///
/// Monero requires all transactions have at least two outputs, assuming one payment and one
/// change (or at least one dummy and one change). Accordingly, specifying no change and only
/// one payment prevents creating a valid transaction
#[cfg_attr(feature = "std", error("only one output and no change address"))]
#[error("only one output and no change address")]
NoChange,
/// Multiple addresses had payment IDs specified.
///
///o
/// Only one payment ID is allowed per transaction.
#[cfg_attr(feature = "std", error("multiple addresses with payment IDs"))]
#[error("multiple addresses with payment IDs")]
MultiplePaymentIds,
/// Too much arbitrary data was specified.
#[cfg_attr(feature = "std", error("too much data"))]
#[error("too much data")]
TooMuchArbitraryData,
/// The created transaction was too large.
#[cfg_attr(feature = "std", error("too large of a transaction"))]
#[error("too large of a transaction")]
TooLargeTransaction,
/// This transaction could not pay for itself.
#[cfg_attr(
feature = "std",
error(
"not enough funds (inputs {inputs}, outputs {outputs}, necessary_fee {necessary_fee:?})"
)
#[error(
"not enough funds (inputs {inputs}, outputs {outputs}, necessary_fee {necessary_fee:?})"
)]
NotEnoughFunds {
/// The amount of funds the inputs contributed.
@@ -195,20 +191,17 @@ pub enum SendError {
necessary_fee: Option<u64>,
},
/// This transaction is being signed with the wrong private key.
#[cfg_attr(feature = "std", error("wrong spend private key"))]
#[error("wrong spend private key")]
WrongPrivateKey,
/// This transaction was read from a bytestream which was malicious.
#[cfg_attr(
feature = "std",
error("this SignableTransaction was created by deserializing a malicious serialization")
)]
#[error("this SignableTransaction was created by deserializing a malicious serialization")]
MaliciousSerialization,
/// There was an error when working with the CLSAGs.
#[cfg_attr(feature = "std", error("clsag error ({0})"))]
#[error("clsag error ({0})")]
ClsagError(ClsagError),
/// There was an error when working with FROST.
#[cfg(feature = "multisig")]
#[cfg_attr(feature = "std", error("frost error {0}"))]
#[error("frost error {0}")]
FrostError(FrostError),
}

View File

@@ -10,8 +10,7 @@ use crate::{
};
/// An error while working with a ViewPair.
#[derive(Clone, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Clone, PartialEq, Eq, Debug, thiserror::Error)]
pub enum ViewPairError {
/// The spend key was torsioned.
///
@@ -20,7 +19,7 @@ pub enum ViewPairError {
// CLSAG seems to support it if the challenge does a torsion clear, FCMP++ should ship with a
// torsion clear, yet it's not worth it to modify CLSAG sign to generate challenges until the
// torsion clears and ensure spendability (nor can we reasonably guarantee that in the future)
#[cfg_attr(feature = "std", error("torsioned spend key"))]
#[error("torsioned spend key")]
TorsionedSpendKey,
}

View File

@@ -18,7 +18,7 @@ workspace = true
[dependencies]
std-shims = { path = "../../../../common/std-shims", version = "^0.1.1", default-features = false }
thiserror = { version = "1", default-features = false, optional = true }
thiserror = { version = "2", default-features = false }
zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] }
rand_core = { version = "0.6", default-features = false }
@@ -36,7 +36,7 @@ curve25519-dalek = { version = "4", default-features = false, features = ["alloc
std = [
"std-shims/std",
"thiserror",
"thiserror/std",
"zeroize/std",
"rand_core/std",

View File

@@ -11,20 +11,19 @@ use original::{SeedError as OriginalSeedError, Seed as OriginalSeed};
use polyseed::{PolyseedError, Polyseed};
/// An error from working with seeds.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
pub enum SeedError {
/// The seed was invalid.
#[cfg_attr(feature = "std", error("invalid seed"))]
#[error("invalid seed")]
InvalidSeed,
/// The entropy was invalid.
#[cfg_attr(feature = "std", error("invalid entropy"))]
#[error("invalid entropy")]
InvalidEntropy,
/// The checksum did not match the data.
#[cfg_attr(feature = "std", error("invalid checksum"))]
#[error("invalid checksum")]
InvalidChecksum,
/// Unsupported features were enabled.
#[cfg_attr(feature = "std", error("unsupported features"))]
#[error("unsupported features")]
UnsupportedFeatures,
}