#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Allocations already available")]
AllocationsAlreadyAvailable,
#[error("Asset with id {asset_id} not found")]
AssetNotFound {
asset_id: String,
},
#[error("Batch transfer with TXID {txid} not found")]
BatchTransferNotFound {
txid: String,
},
#[error("Cannot change online object")]
CannotChangeOnline,
#[error("Transfer cannot be deleted")]
CannotDeleteTransfer,
#[error("Transfer cannot be set to failed status")]
CannotFailTransfer,
#[error("Electrum error: {details}")]
Electrum {
details: String,
},
#[error("Failed bdk sync: {details}")]
FailedBdkSync {
details: String,
},
#[error("Failed broadcast: {details}")]
FailedBroadcast {
details: String,
},
#[error("Failed issuance. Register status: {details}")]
FailedIssuance {
details: String,
},
#[error("The file already exists: {path}")]
FileAlreadyExists {
path: String,
},
#[error("I/O error: {details}")]
IO {
details: String,
},
#[error("Data is inconsistent ({details}). Please check its integrity.")]
Inconsistency {
details: String,
},
#[error("Inexistent data directory")]
InexistentDataDir,
#[error("Insufficient allocations")]
InsufficientAllocationSlots,
#[error("Insufficient bitcoin funds: needed '{needed}', available '{available}'")]
InsufficientBitcoins {
needed: u64,
available: u64,
},
#[error("Insufficient spendable funds for asset: {asset_id}")]
InsufficientSpendableAssets {
asset_id: String,
},
#[error("Insufficient total funds for asset: {asset_id}")]
InsufficientTotalAssets {
asset_id: String,
},
#[error("Internal error: {details}")]
Internal {
details: String,
},
#[error("Address error: {details}")]
InvalidAddress {
details: String,
},
#[error("Amount 0 is invalid")]
InvalidAmountZero,
#[error("Invalid asset ID: {asset_id}")]
InvalidAssetID {
asset_id: String,
},
#[error("Invalid bitcoin keys")]
InvalidBitcoinKeys,
#[error("Invalid bitcoin network: {network}")]
InvalidBitcoinNetwork {
network: String,
},
#[error("Invalid blinded UTXO: {details}")]
InvalidBlindedUTXO {
details: String,
},
#[error("The provided recipient ID is neither a blinded UTXO or a script")]
InvalidRecipientID,
#[error("Invalid transport endpoint: {details}")]
InvalidTransportEndpoint {
details: String,
},
#[error("Invalid transport endpoints: {details}")]
InvalidTransportEndpoints {
details: String,
},
#[error("Invalid description: {details}")]
InvalidDescription {
details: String,
},
#[error("Invalid electrum server: {details}")]
InvalidElectrum {
details: String,
},
#[error("Invalid fee rate: {details}")]
InvalidFeeRate {
details: String,
},
#[error("Invalid file path: {file_path}")]
InvalidFilePath {
file_path: String,
},
#[error("Invalid invoice: {details}")]
InvalidInvoice {
details: String,
},
#[error("Invalid invoice data: {details}")]
InvalidInvoiceData {
details: String,
},
#[error("Invalid mnemonic error: {details}")]
InvalidMnemonic {
details: String,
},
#[error("Invalid name: {details}")]
InvalidName {
details: String,
},
#[error("Invalid precision: {details}")]
InvalidPrecision {
details: String,
},
#[error("Invalid PSBT: {details}")]
InvalidPsbt {
details: String,
},
#[error("Invalid pubkey: {details}")]
InvalidPubkey {
details: String,
},
#[error("Invalid script: {details}")]
InvalidScript {
details: String,
},
#[error("Invalid ticker: {details}")]
InvalidTicker {
details: String,
},
#[error("Invalid vanilla keychain")]
InvalidVanillaKeychain,
#[error("Issuance request with no provided amounts")]
NoIssuanceAmounts,
#[error("No valid transport endpoint found")]
NoValidTransportEndpoint,
#[error("Wallet is offline. Hint: call go_online")]
Offline,
#[error("Output below the dust limit")]
OutputBelowDustLimit,
#[error("Proxy error: {details}")]
Proxy {
details: String,
},
#[error("Recipient ID already used")]
RecipientIDAlreadyUsed,
#[error("Recipient ID duplicated")]
RecipientIDDuplicated,
#[error("Trying to issue too many assets")]
TooHighIssuanceAmounts,
#[error("Transfer with recipient ID {recipient_id} not found")]
TransferNotFound {
recipient_id: String,
},
#[error("Unknown RGB interface: {interface}")]
UnknownRgbInterface {
interface: String,
},
#[error("Unknown RGB schema: {schema_id}")]
UnknownRgbSchema {
schema_id: String,
},
#[error("Backup version not supported")]
UnsupportedBackupVersion {
version: String,
},
#[error("Transport type is not supported")]
UnsupportedTransportType,
#[error("Invoice type is not supported")]
UnsupportedInvoice,
#[error("Operation not allowed on watch only wallet")]
WatchOnly,
#[error("The provided password is incorrect")]
WrongPassword,
}
#[derive(Debug, thiserror::Error)]
pub enum InternalError {
#[error("Aead error: {0}")]
AeadError(String),
#[error("API error: {0}")]
Api(#[from] reqwest::Error),
#[error("Invalid backup path")]
BackupInvalidPath(#[from] std::io::Error),
#[error("Base64 decode error: {0}")]
Base64Decode(#[from] base64::DecodeError),
#[error("Error from bdk: {0}")]
Bdk(#[from] bdk::Error),
#[error("Cannot query rgb-node")]
CannotQueryRgbNode,
#[error("Database error: {0}")]
Database(#[from] sea_orm::DbErr),
#[error("Encode error: {0}")]
Encode(#[from] bitcoin::consensus::encode::Error),
#[error("Hash error: {0}")]
HashError(#[from] scrypt::password_hash::Error),
#[error("Infallible error: {0}")]
Infallible(#[from] std::convert::Infallible),
#[error("No password hash returned")]
NoPasswordHashError,
#[error("PSBT parse error: {0}")]
PsbtParse(#[from] bdk::bitcoin::psbt::PsbtParseError),
#[error("Restore directory is not empty")]
RestoreDirNotEmpty,
#[error("RGB builder error: {0}")]
RgbBuilder(#[from] rgbstd::interface::BuilderError),
#[error("RGB consigner error: {0}")]
RgbConsigner(String),
#[error("RGB DBC PSBT error: {0}")]
RgbDbcPsbtError(#[from] rgbwallet::psbt::DbcPsbtError),
#[error("RGB inventory error: {0}")]
RgbInventory(String),
#[error("RGB inventory data error: {0}")]
RgbInventoryData(String),
#[error("RGB load error: {0}")]
RgbLoad(#[from] rgbstd::containers::LoadError),
#[error("RGB PSBT error: {0}")]
RgbPsbtError(String),
#[error("RGB runtime error: {0}")]
RgbRuntime(#[from] rgb::RuntimeError),
#[error("RGB stash error: {0}")]
RgbStash(#[from] rgbstd::persistence::StashError<std::convert::Infallible>),
#[error("Seal parse error: {0}")]
SealParse(#[from] bp::seals::txout::explicit::ParseError),
#[error("Serde JSON error: {0}")]
SerdeJSON(#[from] serde_json::Error),
#[error("Strip prefix error: {0}")]
StripPrefix(#[from] std::path::StripPrefixError),
#[error("System time error: {0}")]
SystemTime(#[from] std::time::SystemTimeError),
#[error("Unexpected error")]
Unexpected,
#[error("Zip error: {0}")]
ZipError(#[from] zip::result::ZipError),
}
impl From<bdk::keys::bip39::Error> for Error {
fn from(e: bdk::keys::bip39::Error) -> Self {
Error::InvalidMnemonic {
details: e.to_string(),
}
}
}
impl From<bdk::bitcoin::address::Error> for Error {
fn from(e: bdk::bitcoin::address::Error) -> Self {
Error::InvalidAddress {
details: e.to_string(),
}
}
}
impl From<bdk::bitcoin::bip32::Error> for Error {
fn from(e: bdk::bitcoin::bip32::Error) -> Self {
Error::InvalidPubkey {
details: e.to_string(),
}
}
}
impl From<bdk::bitcoin::psbt::PsbtParseError> for Error {
fn from(e: bdk::bitcoin::psbt::PsbtParseError) -> Self {
Error::InvalidPsbt {
details: e.to_string(),
}
}
}
impl From<electrum_client::Error> for Error {
fn from(e: electrum_client::Error) -> Self {
Error::Electrum {
details: e.to_string(),
}
}
}
impl From<rgbstd::persistence::ConsignerError<std::convert::Infallible, std::convert::Infallible>>
for InternalError
{
fn from(
e: rgbstd::persistence::ConsignerError<std::convert::Infallible, std::convert::Infallible>,
) -> Self {
InternalError::RgbConsigner(e.to_string())
}
}
impl From<rgbstd::persistence::InventoryDataError<std::convert::Infallible>> for InternalError {
fn from(e: rgbstd::persistence::InventoryDataError<std::convert::Infallible>) -> Self {
InternalError::RgbInventoryData(e.to_string())
}
}
impl From<rgbstd::persistence::InventoryError<std::convert::Infallible>> for InternalError {
fn from(e: rgbstd::persistence::InventoryError<std::convert::Infallible>) -> Self {
InternalError::RgbInventory(e.to_string())
}
}
impl From<rgbwallet::psbt::RgbPsbtError> for InternalError {
fn from(e: rgbwallet::psbt::RgbPsbtError) -> Self {
InternalError::RgbPsbtError(e.to_string())
}
}
impl From<rgbwallet::TransportParseError> for Error {
fn from(e: rgbwallet::TransportParseError) -> Self {
Error::InvalidTransportEndpoint {
details: e.to_string(),
}
}
}
impl From<reqwest::Error> for Error {
fn from(e: reqwest::Error) -> Self {
Error::Proxy {
details: e.to_string(),
}
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::IO {
details: e.to_string(),
}
}
}
impl From<InternalError> for Error {
fn from(e: InternalError) -> Self {
Error::Internal {
details: e.to_string(),
}
}
}