use util::events;
use util::events::EventHandler;
+use prelude::*;
use std::collections::{HashMap, hash_map};
use std::sync::RwLock;
use core::ops::Deref;
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))]
pub fn get_and_clear_pending_events(&self) -> Vec<events::Event> {
use util::events::EventsProvider;
- let events = std::cell::RefCell::new(Vec::new());
+ let events = core::cell::RefCell::new(Vec::new());
let event_handler = |event| events.borrow_mut().push(event);
self.process_pending_events(&event_handler);
events.into_inner()
use util::byte_utils;
use util::events::Event;
+use prelude::*;
use std::collections::{HashMap, HashSet};
use core::{cmp, mem};
use std::io::Error;
use bitcoin::secp256k1::Secp256k1;
use std::sync::{Arc, Mutex};
use chain::keysinterface::InMemorySigner;
+ use prelude::*;
#[test]
fn test_prune_preimages() {
use ln::chan_utils::{HTLCOutputInCommitment, make_funding_redeemscript, ChannelPublicKeys, HolderCommitmentTransaction, ChannelTransactionParameters, CommitmentTransaction};
use ln::msgs::UnsignedChannelAnnouncement;
+use prelude::*;
use std::collections::HashSet;
use core::sync::atomic::{AtomicUsize, Ordering};
use std::io::Error;
use chain::keysinterface::Sign;
use chain::transaction::{OutPoint, TransactionData};
+use prelude::*;
+
pub mod chaininterface;
pub mod chainmonitor;
pub mod channelmonitor;
use util::ser::{Readable, ReadableArgs, Writer, Writeable, VecWriter};
use util::byte_utils;
+use prelude::*;
use std::collections::HashMap;
use core::cmp;
use core::ops::Deref;
use util::logger::Logger;
use util::ser::{Readable, Writer, Writeable};
-use std::cmp;
-use std::mem;
-use std::ops::Deref;
+use core::cmp;
+use core::mem;
+use core::ops::Deref;
const MAX_ALLOC_SIZE: usize = 64*1024;
#![cfg_attr(all(any(test, feature = "_test_utils"), feature = "unstable"), feature(test))]
#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))] extern crate test;
+extern crate alloc;
extern crate bitcoin;
extern crate core;
#[cfg(any(test, feature = "_test_utils"))] extern crate hex;
pub mod chain;
pub mod ln;
pub mod routing;
+
+mod prelude {
+ pub use alloc::{vec, vec::Vec, string::String};
+}
\ No newline at end of file
use bitcoin::secp256k1::Error as SecpError;
use bitcoin::secp256k1;
+use prelude::*;
use core::cmp;
use ln::chan_utils;
use util::transaction_utils::sort_outputs;
mod tests {
use super::CounterpartyCommitmentSecrets;
use hex;
+ use prelude::*;
#[test]
fn test_per_commitment_storage() {
use util::test_utils;
+use prelude::*;
use std::collections::HashMap;
// If persister_fail is true, we have the persister return a PermanentFailure
use util::config::{UserConfig,ChannelConfig};
use util::scid_utils::scid_from_parts;
+use prelude::*;
use core::{cmp,mem,fmt};
use core::ops::Deref;
#[cfg(any(test, feature = "fuzztarget"))]
use bitcoin::hashes::Hash;
use bitcoin::hash_types::{Txid, WPubkeyHash};
use std::sync::Arc;
+ use prelude::*;
struct TestFeeEstimator {
fee_est: u32
use util::logger::Logger;
use util::errors::APIError;
+use prelude::*;
use core::{cmp, mem};
-use std::cell::RefCell;
+use core::cell::RefCell;
use std::collections::{HashMap, hash_map, HashSet};
use std::io::{Cursor, Read};
use std::sync::{Arc, Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard};
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))]
pub fn get_and_clear_pending_events(&self) -> Vec<events::Event> {
- let events = std::cell::RefCell::new(Vec::new());
+ let events = core::cell::RefCell::new(Vec::new());
let event_handler = |event| events.borrow_mut().push(event);
self.process_pending_events(&event_handler);
events.into_inner()
//! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
//! [messages]: crate::ln::msgs
+use prelude::*;
use core::{cmp, fmt};
use core::marker::PhantomData;
use util::ser::{Readable, Writeable, Writer};
mod sealed {
+ use prelude::*;
use ln::features::Features;
/// The context in which [`Features`] are applicable. Defines which features are required and
use bitcoin::secp256k1::key::PublicKey;
+use prelude::*;
use core::cell::RefCell;
use std::rc::Rc;
use std::sync::Mutex;
use regex;
-use std::collections::{BTreeSet, HashMap, HashSet};
+use prelude::*;
+use alloc::collections::BTreeSet;
+use std::collections::{HashMap, HashSet};
use core::default::Default;
use std::sync::Mutex;
#[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
pub struct PaymentSecret(pub [u8;32]);
+use prelude::*;
use bitcoin::bech32;
use bitcoin::bech32::{Base32Len, FromBase32, ToBase32, WriteBase32, u5};
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
+use prelude::*;
use core::{cmp, fmt};
use core::fmt::Debug;
use std::io::Read;
}
mod fuzzy_internal_msgs {
+ use prelude::*;
use ln::PaymentSecret;
// These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
use bitcoin::secp256k1::{Secp256k1, Message};
+ use prelude::*;
use std::io::Cursor;
#[test]
use bitcoin::secp256k1::Secp256k1;
use bitcoin::secp256k1::key::SecretKey;
+use prelude::*;
use core::default::Default;
use std::io;
use bitcoin::secp256k1::ecdh::SharedSecret;
use bitcoin::secp256k1;
+use prelude::*;
use std::io::Cursor;
use core::ops::Deref;
#[cfg(test)]
mod tests {
+ use prelude::*;
use ln::PaymentHash;
use ln::features::{ChannelFeatures, NodeFeatures};
use routing::router::{Route, RouteHop};
// You may not use this file except in accordance with one or both of these
// licenses.
+use prelude::*;
+
use ln::msgs::LightningError;
use ln::msgs;
use util::logger::Logger;
use routing::network_graph::NetGraphMsgHandler;
-use std::collections::{HashMap,hash_map,HashSet,LinkedList};
+use prelude::*;
+use alloc::collections::LinkedList;
+use std::collections::{HashMap,hash_map,HashSet};
use std::sync::{Arc, Mutex};
use core::sync::atomic::{AtomicUsize, Ordering};
use core::{cmp, hash, fmt, mem};
use bitcoin::secp256k1::Secp256k1;
use bitcoin::secp256k1::key::{SecretKey, PublicKey};
+ use prelude::*;
use std::sync::{Arc, Mutex};
use core::sync::atomic::Ordering;
use bitcoin::blockdata::block::{Block, BlockHeader};
use bitcoin::hash_types::BlockHash;
+use prelude::*;
use std::collections::HashMap;
use core::mem;
mod tests {
use super::*;
use util::byte_utils;
+ use prelude::*;
// Big-endian wire encoding of Pong message (type = 19, byteslen = 2).
const ENCODED_PONG: [u8; 6] = [0u8, 19u8, 0u8, 2u8, 0u8, 0u8];
use util::events::{MessageSendEvent, MessageSendEventsProvider};
use util::scid_utils::{block_from_scid, scid_from_parts, MAX_SCID_BLOCK};
+use prelude::*;
+use alloc::collections::{BTreeMap, btree_map::Entry as BtreeEntry};
use core::{cmp, fmt};
use std::sync::{RwLock, RwLockReadGuard};
use core::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
-use std::collections::BTreeMap;
-use std::collections::btree_map::Entry as BtreeEntry;
use core::ops::Deref;
use bitcoin::hashes::hex::ToHex;
use bitcoin::secp256k1::key::{PublicKey, SecretKey};
use bitcoin::secp256k1::{All, Secp256k1};
+ use prelude::*;
use std::sync::Arc;
fn create_net_graph_msg_handler() -> (Secp256k1<All>, NetGraphMsgHandler<Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>) {
use util::ser::{Writeable, Readable};
use util::logger::Logger;
+use prelude::*;
+use alloc::collections::BinaryHeap;
use core::cmp;
-use std::collections::{HashMap, BinaryHeap};
+use std::collections::HashMap;
use core::ops::Deref;
/// A hop in a route
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
use bitcoin::secp256k1::{Secp256k1, All};
+ use prelude::*;
use std::sync::Arc;
// Using the same keys for LN and BTC ids
use super::*;
use util::logger::{Logger, Record};
+ use prelude::*;
use test::Bencher;
struct DummyLogger {}
#[cfg(test)]
mod test {
+ use prelude::*;
use core::iter::repeat;
use super::ChaCha20;
use ln::{chan_utils, msgs};
use chain::keysinterface::{Sign, InMemorySigner, BaseSign};
+use prelude::*;
use core::cmp;
use std::sync::{Mutex, Arc};
//! Error types live here.
+use alloc::string::String;
use core::fmt;
/// Indicates an error on the client's part (usually some variant of attempting to use too-low or
use bitcoin::secp256k1::key::PublicKey;
+use prelude::*;
use core::time::Duration;
-use std::ops::Deref;
+use core::ops::Deref;
/// An Event which you should probably take some action in response to.
///
//! https://lightning.readthedocs.io/lightning-signmessage.7.html
//! https://api.lightning.community/#signmessage
+use prelude::*;
use crate::util::zbase32;
use bitcoin::hashes::{sha256d, Hash};
use bitcoin::secp256k1::recovery::{RecoverableSignature, RecoveryId};
#[cfg(test)]
mod test {
+ use prelude::*;
use core::iter::repeat;
use util::poly1305::Poly1305;
//! A very simple serialization framework which is used to serialize/deserialize messages as well
//! as ChannelsManagers and ChannelMonitors.
+use prelude::*;
use std::io::{Read, Write};
use std::collections::HashMap;
use core::hash::Hash;
#[cfg(test)]
mod tests {
+ use prelude::*;
use std::io::{Cursor, Read};
use ln::msgs::DecodeError;
use util::ser::{Readable, Writeable, HighZeroBytesDroppedVarInt, VecWriter};
use regex;
+use prelude::*;
use core::time::Duration;
use std::sync::{Mutex, Arc};
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use ln::msgs::MAX_VALUE_MSAT;
+use prelude::*;
use core::cmp::Ordering;
pub fn sort_outputs<T, C : Fn(&T, &T) -> Ordering>(outputs: &mut Vec<(TxOut, T)>, tie_breaker: C) {
use hex::decode;
+ use alloc::vec;
+
#[test]
fn sort_output_by_value() {
let txout1 = TxOut {
* at your option.
*/
+use prelude::*;
+
const ALPHABET: &'static [u8] = b"ybndrfg8ejkmcpqxot1uwisza345h769";
/// Encodes some bytes as a zbase32 string