use chain::transaction::OutPoint;
use util::{transaction_utils,rng};
use util::sha2::Sha256;
-use util::logger::{Logger, Record};
+use util::logger::Logger;
use util::errors::APIError;
use std;
use util::{byte_utils, events, internal_traits, rng};
use util::sha2::Sha256;
use util::chacha20poly1305rfc::ChaCha20;
-use util::logger::{Logger, Record};
+use util::logger::Logger;
use util::errors::APIError;
use crypto;
use ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep};
use util::byte_utils;
use util::events::{EventsProvider,Event};
-use util::logger::{Logger, Record};
+use util::logger::Logger;
use std::collections::{HashMap,LinkedList};
use std::sync::{Arc, Mutex};
use std::fmt;
+/// Indicates an error on the client's part (usually some variant of attempting to use too-low or
+/// too-high values)
pub enum APIError {
+ /// Indicates the API was wholly misused (see err for more). Cases where these can be returned
+ /// are documented, but generally indicates some precondition of a function was violated.
APIMisuseError {err: &'static str},
+ /// Due to a high feerate, we were unable to complete the request.
+ /// For example, this may be returned if the feerate implies we cannot open a channel at the
+ /// requested value, but opening a larger channel would succeed.
FeeRateTooHigh {err: String, feerate: u64},
}
impl fmt::Debug for APIError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
APIError::APIMisuseError {ref err} => f.write_str(err),
APIError::FeeRateTooHigh {ref err, ref feerate} => write!(f, "{} feerate: {}", err, feerate)
}
- }
+ }
}
#[cfg(test)]
mod tests {
- use util::logger::{Logger, Level, Record};
+ use util::logger::{Logger, Level};
use util::test_utils::TestLogger;
use std::sync::{Arc};
macro_rules! log_internal {
($self: ident, $lvl:expr, $($arg:tt)+) => (
- &$self.logger.log(&Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
+ &$self.logger.log(&::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
);
}