use std::collections::{HashMap, hash_map};
use std::sync::RwLock;
-use std::ops::Deref;
+use core::ops::Deref;
/// An implementation of [`chain::Watch`] for monitoring channels.
///
use util::events::Event;
use std::collections::{HashMap, HashSet};
-use std::{cmp, mem};
+use core::{cmp, mem};
use std::io::Error;
-use std::ops::Deref;
+use core::ops::Deref;
use std::sync::Mutex;
/// An update generated by the underlying Channel itself which contains some new information the
/// then we allow the `ChannelManager` to send a `ChannelMonitorUpdate` with this update ID,
/// with the update providing said payment preimage. No other update types are allowed after
/// force-close.
-pub const CLOSED_CHANNEL_UPDATE_ID: u64 = std::u64::MAX;
+pub const CLOSED_CHANNEL_UPDATE_ID: u64 = core::u64::MAX;
impl Writeable for ChannelMonitorUpdate {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
fn read<R: ::std::io::Read>(r: &mut R) -> Result<Self, DecodeError> {
let update_id: u64 = Readable::read(r)?;
let len: u64 = Readable::read(r)?;
- let mut updates = Vec::with_capacity(cmp::min(len as usize, MAX_ALLOC_SIZE / ::std::mem::size_of::<ChannelMonitorUpdateStep>()));
+ let mut updates = Vec::with_capacity(cmp::min(len as usize, MAX_ALLOC_SIZE / ::core::mem::size_of::<ChannelMonitorUpdateStep>()));
for _ in 0..len {
updates.push(Readable::read(r)?);
}
for &(ref htlc, _, _) in holder_tx.htlc_outputs.iter() {
if let Some(transaction_output_index) = htlc.transaction_output_index {
- claim_requests.push(ClaimRequest { absolute_timelock: ::std::u32::MAX, aggregable: false, outpoint: BitcoinOutPoint { txid: holder_tx.txid, vout: transaction_output_index as u32 },
+ claim_requests.push(ClaimRequest { absolute_timelock: ::core::u32::MAX, aggregable: false, outpoint: BitcoinOutPoint { txid: holder_tx.txid, vout: transaction_output_index as u32 },
witness_data: InputMaterial::HolderHTLC {
preimage: if !htlc.offered {
if let Some(preimage) = self.payment_preimages.get(&htlc.payment_hash) {
fn is_paying_spendable_output<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) where L::Target: Logger {
let mut spendable_output = None;
for (i, outp) in tx.output.iter().enumerate() { // There is max one spendable output for any channel tx, including ones generated by us
- if i > ::std::u16::MAX as usize {
+ if i > ::core::u16::MAX as usize {
// While it is possible that an output exists on chain which is greater than the
// 2^16th output in a given transaction, this is only possible if the output is not
// in a lightning transaction and was instead placed there by some third party who
use ln::msgs::UnsignedChannelAnnouncement;
use std::collections::HashSet;
-use std::sync::atomic::{AtomicUsize, Ordering};
+use core::sync::atomic::{AtomicUsize, Ordering};
use std::io::Error;
use ln::msgs::{DecodeError, MAX_VALUE_MSAT};
/// onchain output detection for which a corresponding delayed_payment_key must be derived.
pub fn derive_channel_keys(&self, channel_value_satoshis: u64, params: &[u8; 32]) -> InMemorySigner {
let chan_id = byte_utils::slice_to_be64(¶ms[0..8]);
- assert!(chan_id <= std::u32::MAX as u64); // Otherwise the params field wasn't created by us
+ assert!(chan_id <= core::u32::MAX as u64); // Otherwise the params field wasn't created by us
let mut unique_start = Sha256::engine();
unique_start.input(params);
unique_start.input(&self.seed);
fn get_channel_signer(&self, _inbound: bool, channel_value_satoshis: u64) -> Self::Signer {
let child_ix = self.channel_child_index.fetch_add(1, Ordering::AcqRel);
- assert!(child_ix <= std::u32::MAX as usize);
+ assert!(child_ix <= core::u32::MAX as usize);
let mut id = [0; 32];
id[0..8].copy_from_slice(&byte_utils::be64_to_array(child_ix as u64));
id[8..16].copy_from_slice(&byte_utils::be64_to_array(self.starting_time_nanos as u64));
pub script_pubkey: Script,
}
-impl<T: Listen> Listen for std::ops::Deref<Target = T> {
+impl<T: Listen> Listen for core::ops::Deref<Target = T> {
fn block_connected(&self, block: &Block, height: u32) {
(**self).block_connected(block, height);
}
}
}
-impl<T: std::ops::Deref, U: std::ops::Deref> Listen for (T, U)
+impl<T: core::ops::Deref, U: core::ops::Deref> Listen for (T, U)
where
T::Target: Listen,
U::Target: Listen,
#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))] extern crate test;
extern crate bitcoin;
+extern crate core;
#[cfg(any(test, feature = "_test_utils"))] extern crate hex;
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] extern crate regex;
use bitcoin::secp256k1::Error as SecpError;
use bitcoin::secp256k1;
-use std::cmp;
+use core::cmp;
use ln::chan_utils;
use util::transaction_utils::sort_outputs;
use ln::channel::INITIAL_COMMITMENT_NUMBER;
use std::io::Read;
-use std::ops::Deref;
+use core::ops::Deref;
use chain;
// Maximum size of a serialized HTLCOutputInCommitment
use util::config::{UserConfig,ChannelConfig};
use util::scid_utils::scid_from_parts;
-use std;
-use std::{cmp,mem,fmt};
-use std::ops::Deref;
+use core::{cmp,mem,fmt};
+use core::ops::Deref;
#[cfg(any(test, feature = "fuzztarget"))]
use std::sync::Mutex;
use bitcoin::hashes::hex::ToHex;
// on-chain ChannelsMonitors during block rescan. Ideally we'd figure out a way to drop
// these, but for now we just have to treat them as normal.
- let mut pending_idx = std::usize::MAX;
+ let mut pending_idx = core::usize::MAX;
for (idx, htlc) in self.pending_inbound_htlcs.iter().enumerate() {
if htlc.htlc_id == htlc_id_arg {
assert_eq!(htlc.payment_hash, payment_hash_calc);
break;
}
}
- if pending_idx == std::usize::MAX {
+ if pending_idx == core::usize::MAX {
return Err(ChannelError::Ignore("Unable to find a pending HTLC which matched the given HTLC ID".to_owned()));
}
// on-chain ChannelsMonitors during block rescan. Ideally we'd figure out a way to drop
// these, but for now we just have to treat them as normal.
- let mut pending_idx = std::usize::MAX;
+ let mut pending_idx = core::usize::MAX;
for (idx, htlc) in self.pending_inbound_htlcs.iter().enumerate() {
if htlc.htlc_id == htlc_id_arg {
match htlc.state {
pending_idx = idx;
}
}
- if pending_idx == std::usize::MAX {
+ if pending_idx == core::usize::MAX {
return Err(ChannelError::Ignore("Unable to find a pending HTLC which matched the given HTLC ID".to_owned()));
}
let mut key_data = VecWriter(Vec::new());
self.holder_signer.write(&mut key_data)?;
- assert!(key_data.0.len() < std::usize::MAX);
- assert!(key_data.0.len() < std::u32::MAX as usize);
+ assert!(key_data.0.len() < core::usize::MAX);
+ assert!(key_data.0.len() < core::u32::MAX as usize);
(key_data.0.len() as u32).write(writer)?;
writer.write_all(&key_data.0[..])?;
use util::logger::Logger;
use util::errors::APIError;
-use std::{cmp, mem};
+use core::{cmp, mem};
use std::collections::{HashMap, hash_map, HashSet};
use std::io::{Cursor, Read};
use std::sync::{Arc, Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard};
-use std::sync::atomic::{AtomicUsize, Ordering};
-use std::time::Duration;
+use core::sync::atomic::{AtomicUsize, Ordering};
+use core::time::Duration;
#[cfg(any(test, feature = "allow_wallclock_use"))]
use std::time::Instant;
-use std::ops::Deref;
+use core::ops::Deref;
use bitcoin::hashes::hex::ToHex;
// We hold various information about HTLC relay in the HTLC objects in Channel itself:
// be absurd. We ensure this by checking that at least 500 (our stated public contract on when
// broadcast_node_announcement panics) of the maximum-length addresses would fit in a 64KB
// message...
- const HALF_MESSAGE_IS_ADDRS: u32 = ::std::u16::MAX as u32 / (NetAddress::MAX_LEN as u32 + 1) / 2;
+ const HALF_MESSAGE_IS_ADDRS: u32 = ::core::u16::MAX as u32 / (NetAddress::MAX_LEN as u32 + 1) / 2;
#[deny(const_err)]
#[allow(dead_code)]
// ...by failing to compile if the number of addresses that would be half of a message is
mod tests {
use ln::channelmanager::PersistenceNotifier;
use std::sync::Arc;
- use std::sync::atomic::{AtomicBool, Ordering};
+ use core::sync::atomic::{AtomicBool, Ordering};
use std::thread;
- use std::time::Duration;
+ use core::time::Duration;
#[test]
fn test_wait_timeout() {
//! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
//! [messages]: crate::ln::msgs
-use std::{cmp, fmt};
-use std::marker::PhantomData;
+use core::{cmp, fmt};
+use core::marker::PhantomData;
use bitcoin::bech32;
use bitcoin::bech32::{Base32Len, FromBase32, ToBase32, u5, WriteBase32};
use bitcoin::secp256k1::key::PublicKey;
-use std::cell::RefCell;
+use core::cell::RefCell;
use std::rc::Rc;
use std::sync::Mutex;
-use std::mem;
+use core::mem;
use std::collections::HashMap;
pub const CHAN_CONFIRM_DEPTH: u32 = 10;
}
pub fn create_chan_between_nodes_with_value_confirm<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>, tx: &Transaction) -> ((msgs::FundingLocked, msgs::AnnouncementSignatures), [u8; 32]) {
- let conf_height = std::cmp::max(node_a.best_block_info().1 + 1, node_b.best_block_info().1 + 1);
+ let conf_height = core::cmp::max(node_a.best_block_info().1 + 1, node_b.best_block_info().1 + 1);
create_chan_between_nodes_with_value_confirm_first(node_a, node_b, tx, conf_height);
confirm_transaction_at(node_a, tx, conf_height);
connect_blocks(node_a, CHAN_CONFIRM_DEPTH - 1);
use regex;
use std::collections::{BTreeSet, HashMap, HashSet};
-use std::default::Default;
+use core::default::Default;
use std::sync::Mutex;
use ln::functional_test_utils::*;
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
-use std::{cmp, fmt};
-use std::fmt::Debug;
+use core::{cmp, fmt};
+use core::fmt::Debug;
use std::io::Read;
use util::events::MessageSendEventsProvider;
use util::byte_utils;
use std::collections::HashMap;
-use std::cmp;
-use std::ops::Deref;
-use std::mem::replace;
+use core::cmp;
+use core::ops::Deref;
+use core::mem::replace;
const MAX_ALLOC_SIZE: usize = 64*1024;
0u8 => Ok(None),
1u8 => {
let vlen: u64 = Readable::read(reader)?;
- let mut ret = Vec::with_capacity(cmp::min(vlen as usize, MAX_ALLOC_SIZE / ::std::mem::size_of::<Option<(usize, Signature)>>()));
+ let mut ret = Vec::with_capacity(cmp::min(vlen as usize, MAX_ALLOC_SIZE / ::core::mem::size_of::<Option<(usize, Signature)>>()));
for _ in 0..vlen {
ret.push(match Readable::read(reader)? {
0u8 => None,
let mut key_data = VecWriter(Vec::new());
self.signer.write(&mut key_data)?;
- assert!(key_data.0.len() < std::usize::MAX);
- assert!(key_data.0.len() < std::u32::MAX as usize);
+ assert!(key_data.0.len() < core::usize::MAX);
+ assert!(key_data.0.len() < core::u32::MAX as usize);
(key_data.0.len() as u32).write(writer)?;
writer.write_all(&key_data.0[..])?;
log_trace!(logger, "Updating claims view at height {} with {} matched transactions and {} claim requests", height, txn_matched.len(), claimable_outpoints.len());
let mut new_claims = Vec::new();
let mut aggregated_claim = HashMap::new();
- let mut aggregated_soonest = ::std::u32::MAX;
+ let mut aggregated_soonest = ::core::u32::MAX;
// Try to aggregate outputs if their timelock expiration isn't imminent (absolute_timelock
// <= CLTV_SHARED_CLAIM_BUFFER) and they don't require an immediate nLockTime (aggregable).
use bitcoin::secp256k1::Secp256k1;
use bitcoin::secp256k1::key::SecretKey;
-use std::default::Default;
+use core::default::Default;
use std::io;
use ln::functional_test_utils::*;
use bitcoin::secp256k1;
use std::io::Cursor;
-use std::ops::Deref;
+use core::ops::Deref;
pub(super) struct OnionKeys {
#[cfg(test)]
/// Maximum Lightning message data length according to
/// [BOLT-8](https://github.com/lightningnetwork/lightning-rfc/blob/v1.0/08-transport.md#lightning-message-specification)
/// and [BOLT-1](https://github.com/lightningnetwork/lightning-rfc/blob/master/01-messaging.md#lightning-message-format):
-pub const LN_MAX_MSG_LEN: usize = ::std::u16::MAX as usize; // Must be equal to 65535
+pub const LN_MAX_MSG_LEN: usize = ::core::u16::MAX as usize; // Must be equal to 65535
// Sha256("Noise_XK_secp256k1_ChaChaPoly_SHA256")
const NOISE_CK: [u8; 32] = [0x26, 0x40, 0xf5, 0x2e, 0xeb, 0xcd, 0x9e, 0x88, 0x29, 0x58, 0x95, 0x1c, 0x79, 0x42, 0x50, 0xee, 0xdb, 0x28, 0x00, 0x2c, 0x05, 0xd7, 0xdc, 0x2e, 0xa0, 0xf1, 0x95, 0x40, 0x60, 0x42, 0xca, 0xf1];
#[test]
fn max_msg_len_limit_value() {
assert_eq!(LN_MAX_MSG_LEN, 65535);
- assert_eq!(LN_MAX_MSG_LEN, ::std::u16::MAX as usize);
+ assert_eq!(LN_MAX_MSG_LEN, ::core::u16::MAX as usize);
}
#[test]
use std::collections::{HashMap,hash_map,HashSet,LinkedList};
use std::sync::{Arc, Mutex};
-use std::sync::atomic::{AtomicUsize, Ordering};
-use std::{cmp, error, hash, fmt, mem};
-use std::ops::Deref;
+use core::sync::atomic::{AtomicUsize, Ordering};
+use core::{cmp, hash, fmt, mem};
+use core::ops::Deref;
+use std::error;
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::hashes::sha256::HashEngine as Sha256Engine;
use bitcoin::secp256k1::Secp256k1;
use bitcoin::secp256k1::key::{SecretKey, PublicKey};
- use std;
use std::sync::{Arc, Mutex};
- use std::sync::atomic::Ordering;
+ use core::sync::atomic::Ordering;
#[derive(Clone)]
struct FileDescriptor {
}
}
impl Eq for FileDescriptor { }
- impl std::hash::Hash for FileDescriptor {
- fn hash<H: std::hash::Hasher>(&self, hasher: &mut H) {
+ impl core::hash::Hash for FileDescriptor {
+ fn hash<H: core::hash::Hasher>(&self, hasher: &mut H) {
self.fd.hash(hasher)
}
}
use bitcoin::hash_types::BlockHash;
use std::collections::HashMap;
-use std::mem;
+use core::mem;
use ln::functional_test_utils::*;
}
}
-impl ::std::fmt::Display for MessageType {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+impl ::core::fmt::Display for MessageType {
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
write!(f, "{}", self.0)
}
}
#[test]
fn read_unknown_message() {
- let buffer = &byte_utils::be16_to_array(::std::u16::MAX);
+ let buffer = &byte_utils::be16_to_array(::core::u16::MAX);
let mut reader = ::std::io::Cursor::new(buffer);
let message = read(&mut reader).unwrap();
match message {
- Message::Unknown(MessageType(::std::u16::MAX)) => (),
- _ => panic!("Expected message type {}; found: {}", ::std::u16::MAX, message.type_id()),
+ Message::Unknown(MessageType(::core::u16::MAX)) => (),
+ _ => panic!("Expected message type {}; found: {}", ::core::u16::MAX, message.type_id()),
}
}
let mut buffer = Vec::new();
assert!(write(&message, &mut buffer).is_ok());
- let type_length = ::std::mem::size_of::<u16>();
+ let type_length = ::core::mem::size_of::<u16>();
let (type_bytes, payload_bytes) = buffer.split_at(type_length);
assert_eq!(byte_utils::slice_to_be16(type_bytes), msgs::Pong::TYPE);
assert_eq!(payload_bytes, &ENCODED_PONG[type_length..]);
use util::events::{MessageSendEvent, MessageSendEventsProvider};
use util::scid_utils::{block_from_scid, scid_from_parts, MAX_SCID_BLOCK};
-use std::{cmp, fmt};
+use core::{cmp, fmt};
use std::sync::{RwLock, RwLockReadGuard};
-use std::sync::atomic::{AtomicUsize, Ordering};
+use core::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use std::collections::BTreeMap;
use std::collections::btree_map::Entry as BtreeEntry;
-use std::ops::Deref;
+use core::ops::Deref;
use bitcoin::hashes::hex::ToHex;
/// The maximum number of extra bytes which we do not understand in a gossip message before we will
fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent> {
let mut ret = Vec::new();
let mut pending_events = self.pending_events.lock().unwrap();
- std::mem::swap(&mut ret, &mut pending_events);
+ core::mem::swap(&mut ret, &mut pending_events);
ret
}
}
use util::ser::{Writeable, Readable};
use util::logger::Logger;
-use std::cmp;
+use core::cmp;
use std::collections::{HashMap, BinaryHeap};
-use std::ops::Deref;
+use core::ops::Deref;
/// A hop in a route
#[derive(Clone, PartialEq)]
pub(super) fn random_init_seed() -> u64 {
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
- use std::hash::{BuildHasher, Hasher};
+ use core::hash::{BuildHasher, Hasher};
let seed = std::collections::hash_map::RandomState::new().build_hasher().finish();
println!("Using seed of {}", seed);
seed
#[cfg(not(feature = "fuzztarget"))]
mod real_chacha {
- use std::cmp;
+ use core::cmp;
use util::byte_utils::{slice_to_le32, le32_to_array};
#[derive(Clone, Copy, PartialEq, Eq)]
#[allow(non_camel_case_types)]
struct u32x4(pub u32, pub u32, pub u32, pub u32);
- impl ::std::ops::Add for u32x4 {
+ impl ::core::ops::Add for u32x4 {
type Output = u32x4;
fn add(self, rhs: u32x4) -> u32x4 {
u32x4(self.0.wrapping_add(rhs.0),
self.3.wrapping_add(rhs.3))
}
}
- impl ::std::ops::Sub for u32x4 {
+ impl ::core::ops::Sub for u32x4 {
type Output = u32x4;
fn sub(self, rhs: u32x4) -> u32x4 {
u32x4(self.0.wrapping_sub(rhs.0),
self.3.wrapping_sub(rhs.3))
}
}
- impl ::std::ops::BitXor for u32x4 {
+ impl ::core::ops::BitXor for u32x4 {
type Output = u32x4;
fn bitxor(self, rhs: u32x4) -> u32x4 {
u32x4(self.0 ^ rhs.0, self.1 ^ rhs.1, self.2 ^ rhs.2, self.3 ^ rhs.3)
}
}
- impl ::std::ops::Shr<u32x4> for u32x4 {
+ impl ::core::ops::Shr<u32x4> for u32x4 {
type Output = u32x4;
fn shr(self, rhs: u32x4) -> u32x4 {
u32x4(self.0 >> rhs.0, self.1 >> rhs.1, self.2 >> rhs.2, self.3 >> rhs.3)
}
}
- impl ::std::ops::Shl<u32x4> for u32x4 {
+ impl ::core::ops::Shl<u32x4> for u32x4 {
type Output = u32x4;
fn shl(self, rhs: u32x4) -> u32x4 {
u32x4(self.0 << rhs.0, self.1 << rhs.1, self.2 << rhs.2, self.3 << rhs.3)
#[cfg(test)]
mod test {
- use std::iter::repeat;
+ use core::iter::repeat;
use super::ChaCha20;
use ln::{chan_utils, msgs};
use chain::keysinterface::{Sign, InMemorySigner, BaseSign};
-use std::cmp;
+use core::cmp;
use std::sync::{Mutex, Arc};
use bitcoin::blockdata::transaction::{Transaction, SigHashType};
//! Error types live here.
-use std::fmt;
+use core::fmt;
/// Indicates an error on the client's part (usually some variant of attempting to use too-low or
/// too-high values)
use bitcoin::secp256k1::key::PublicKey;
-use std::time::Duration;
+use core::time::Duration;
/// An Event which you should probably take some action in response to.
///
//! The second one, client-side by implementing check against Record Level field.
//! Each module may have its own Logger or share one.
-use std::cmp;
-use std::fmt;
+use core::cmp;
+use core::fmt;
static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE"];
use routing::router::Route;
use ln::chan_utils::HTLCType;
-use std;
-
pub(crate) struct DebugPubKey<'a>(pub &'a PublicKey);
-impl<'a> std::fmt::Display for DebugPubKey<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+impl<'a> core::fmt::Display for DebugPubKey<'a> {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
for i in self.0.serialize().iter() {
write!(f, "{:02x}", i)?;
}
}
pub(crate) struct DebugBytes<'a>(pub &'a [u8]);
-impl<'a> std::fmt::Display for DebugBytes<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+impl<'a> core::fmt::Display for DebugBytes<'a> {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
for i in self.0 {
write!(f, "{:02x}", i)?;
}
}
pub(crate) struct DebugFundingChannelId<'a>(pub &'a Txid, pub u16);
-impl<'a> std::fmt::Display for DebugFundingChannelId<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+impl<'a> core::fmt::Display for DebugFundingChannelId<'a> {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
for i in (OutPoint { txid: self.0.clone(), index: self.1 }).to_channel_id().iter() {
write!(f, "{:02x}", i)?;
}
}
pub(crate) struct DebugFundingInfo<'a, T: 'a>(pub &'a (OutPoint, T));
-impl<'a, T> std::fmt::Display for DebugFundingInfo<'a, T> {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+impl<'a, T> core::fmt::Display for DebugFundingInfo<'a, T> {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
DebugBytes(&(self.0).0.to_channel_id()[..]).fmt(f)
}
}
}
pub(crate) struct DebugRoute<'a>(pub &'a Route);
-impl<'a> std::fmt::Display for DebugRoute<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+impl<'a> core::fmt::Display for DebugRoute<'a> {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
for (idx, p) in self.0.paths.iter().enumerate() {
writeln!(f, "path {}:", idx)?;
for h in p.iter() {
}
pub(crate) struct DebugTx<'a>(pub &'a Transaction);
-impl<'a> std::fmt::Display for DebugTx<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+impl<'a> core::fmt::Display for DebugTx<'a> {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
if self.0.input.len() >= 1 && self.0.input.iter().any(|i| !i.witness.is_empty()) {
if self.0.input.len() == 1 && self.0.input[0].witness.last().unwrap().len() == 71 &&
(self.0.input[0].sequence >> 8*3) as u8 == 0x80 {
}
pub(crate) struct DebugSpendable<'a>(pub &'a SpendableOutputDescriptor);
-impl<'a> std::fmt::Display for DebugSpendable<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+impl<'a> core::fmt::Display for DebugSpendable<'a> {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
match self.0 {
&SpendableOutputDescriptor::StaticOutput { ref outpoint, .. } => {
write!(f, "StaticOutput {}:{} marked for spending", outpoint.txid, outpoint.index)?;
#[cfg(test)]
mod test {
- use std::str::FromStr;
+ use core::str::FromStr;
use util::message_signing::{sign, recover_pk, verify};
use bitcoin::secp256k1::key::ONE_KEY;
use bitcoin::secp256k1::{PublicKey, Secp256k1};
// This is a port of Andrew Moons poly1305-donna
// https://github.com/floodyberry/poly1305-donna
-use std::cmp::min;
+use core::cmp::min;
use util::byte_utils::{slice_to_le32, le32_to_array};
#[derive(Clone, Copy)]
#[cfg(test)]
mod test {
- use std::iter::repeat;
+ use core::iter::repeat;
use util::poly1305::Poly1305;
use std::io::{Read, Write};
use std::collections::HashMap;
-use std::hash::Hash;
+use core::hash::Hash;
use std::sync::Mutex;
-use std::cmp;
+use core::cmp;
use bitcoin::secp256k1::Signature;
use bitcoin::secp256k1::key::{PublicKey, SecretKey};
use bitcoin::consensus::Encodable;
use bitcoin::hashes::sha256d::Hash as Sha256dHash;
use bitcoin::hash_types::{Txid, BlockHash};
-use std::marker::Sized;
+use core::marker::Sized;
use ln::msgs::DecodeError;
use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use util::byte_utils;
use regex;
-use std::time::Duration;
+use core::time::Duration;
use std::sync::{Mutex, Arc};
-use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
-use std::{cmp, mem};
+use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
+use core::{cmp, mem};
use std::collections::{HashMap, HashSet, VecDeque};
use chain::keysinterface::InMemorySigner;
}
}
-impl std::fmt::Debug for OnRegisterOutput {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for OnRegisterOutput {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("OnRegisterOutput")
.field("outpoint", &self.outpoint())
.field("script_pubkey", self.script_pubkey())
use ln::msgs::MAX_VALUE_MSAT;
-use std::cmp::Ordering;
+use core::cmp::Ordering;
pub fn sort_outputs<T, C : Fn(&T, &T) -> Ordering>(outputs: &mut Vec<(TxOut, T)>, tie_breaker: C) {
outputs.sort_unstable_by(|a, b| {