use std::collections::BTreeSet;
use thiserror::Error;
use crate::UniquePubkey;
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug, Error)]
pub enum Error {
#[error("Double spend attempted with cashnotes: {0:?}")]
DoubleSpendAttemptedForCashNotes(BTreeSet<UniquePubkey>),
#[error("Invalid address type")]
InvalidAddressType,
#[error("Total price exceed possible token amount")]
TotalPriceTooHigh,
#[error("Failed to send tokens due to {0}")]
CouldNotSendMoney(String),
#[error("Failed to receive transfer due to {0}")]
CouldNotReceiveMoney(String),
#[error("Failed to verify transfer validity in the network {0}")]
CouldNotVerifyTransfer(String),
#[error("Unconfirmed transactions still persist even after retries")]
UnconfirmedTxAfterRetries,
#[error("Main pub key doesn't match the key found when loading wallet from path: {0:#?}")]
PubKeyMismatch(std::path::PathBuf),
#[error("Main pub key not found: {0:#?}")]
PubkeyNotFound(std::path::PathBuf),
#[error("Failed to parse bls key")]
FailedToParseBlsKey,
#[error("Could not decode hex string to key")]
FailedToDecodeHexToKey,
#[error("Could not serialize main key to hex: {0}")]
FailedToHexEncodeKey(String),
#[error("Could not encode cashnote to hex")]
FailedToHexEncodeCashNote,
#[error("Failed to decypher transfer with our key, maybe it was not for us")]
FailedToDecypherTransfer,
#[error("No ongoing payment found for address")]
NoPaymentForAddress,
#[error("Transfer error: {0}")]
Transfer(#[from] crate::Error),
#[error("Bls error: {0}")]
Bls(#[from] bls::error::Error),
#[error("MsgPack serialisation error:: {0}")]
Serialisation(#[from] rmp_serde::encode::Error),
#[error("MsgPack deserialisation error:: {0}")]
Deserialisation(#[from] rmp_serde::decode::Error),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}