#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum Error {
#[error("an account is a did:nostr identifier (did:nostr:<64 hex>)")]
Account,
#[error("an amount is a whole number of satoshis")]
Amount,
#[error("a ledger has a name of up to 80 characters")]
Name,
#[error("not a Web Ledger with a genesis")]
NotALedger,
#[error("the ledger's hash is not the hash of its genesis")]
HashMismatch,
#[error("a deposit is an outpoint txid:vout")]
Outpoint,
#[error("a transfer moves at least one satoshi")]
ZeroTransfer,
#[error("{account}… has {has} sat, not {wanted}")]
Insufficient {
account: String,
has: u64,
wanted: u64,
},
#[error("a withdrawal is at least 546 sat")]
WithdrawalTooSmall,
#[error("ledgerHash is the ledger's 32-byte hash")]
DepositLedgerHash,
#[error("ledgerHash is the ledger's hash")]
RequestLedgerHash,
#[error("op is join, withdraw or transfer")]
Op,
#[error("a withdrawal or transfer names where to")]
NoDestination,
#[error("not a request (kind 3700)")]
NotARequest,
#[error("the request does not verify")]
Unverified,
#[error("a request for another ledger")]
OtherLedger,
#[error("a request has an op and an id")]
OpAndId,
#[error("a payout is at least 546 sat")]
PayoutTooSmall,
#[error("rate 1 to 1000 sat/vB")]
Rate,
#[error("the deposits held ({held} sat) do not cover {amount} sat and the fee")]
NotCovered {
held: u64,
amount: u64,
},
#[error("input {input} did not pass the script check ({reason}); nothing was paid")]
ScriptCheck {
input: usize,
reason: String,
},
#[error("the signed payout is {vsize} vB, so its fee of {fee} sat is below {rate} sat/vB; nothing was paid")]
FeeBelowRate {
vsize: u64,
fee: u64,
rate: u64,
},
#[error("{0}")]
Key(&'static str),
#[error("no address for that script under prefix {0:?}")]
Address(String),
#[error("{what}: {reason}")]
Encoding {
what: &'static str,
reason: String,
},
#[error("input {input}: {reason}")]
Sighash {
input: usize,
reason: &'static str,
},
#[error("event: {0}")]
Event(String),
#[error("not a ledger (kind 30333)")]
NotALedgerEvent,
#[error("the ledger event's content is not a ledger: {0}")]
LedgerContent(String),
#[error("a ledger event that is not the operator's own copy of this ledger")]
NotTheOperators,
}
pub type Result<T> = core::result::Result<T, Error>;