Use alloc for no_std builds
[rust-lightning] / lightning / src / ln / onion_utils.rs
index c6bd92f5bc1238f3b702a327f43682f51ccc1f2c..f80fd676c75d14397ac2e4c693f64cc3b2fffa50 100644 (file)
@@ -7,7 +7,8 @@
 // You may not use this file except in accordance with one or both of these
 // licenses.
 
-use ln::channelmanager::{PaymentHash, PaymentSecret, HTLCSource};
+use ln::{PaymentHash, PaymentSecret};
+use ln::channelmanager::HTLCSource;
 use ln::msgs;
 use routing::router::RouteHop;
 use util::byte_utils;
@@ -26,8 +27,9 @@ use bitcoin::secp256k1::Secp256k1;
 use bitcoin::secp256k1::ecdh::SharedSecret;
 use bitcoin::secp256k1;
 
+use prelude::*;
 use std::io::Cursor;
-use std::ops::Deref;
+use core::ops::Deref;
 
 pub(super) struct OnionKeys {
        #[cfg(test)]
@@ -306,8 +308,8 @@ pub(super) fn build_failure_packet(shared_secret: &[u8], failure_type: u16, fail
        };
        let mut packet = msgs::DecodedOnionErrorPacket {
                hmac: [0; 32],
-               failuremsg: failuremsg,
-               pad: pad,
+               failuremsg,
+               pad,
        };
 
        let mut hmac = HmacEngine::<Sha256>::new(&um);
@@ -449,10 +451,10 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
 
                                                let (description, title) = errors::get_onion_error_description(error_code);
                                                if debug_field_size > 0 && err_packet.failuremsg.len() >= 4 + debug_field_size {
-                                                       log_warn!(logger, "Onion Error[{}({:#x}) {}({})] {}", title, error_code, debug_field, log_bytes!(&err_packet.failuremsg[4..4+debug_field_size]), description);
+                                                       log_warn!(logger, "Onion Error[from {}: {}({:#x}) {}({})] {}", route_hop.pubkey, title, error_code, debug_field, log_bytes!(&err_packet.failuremsg[4..4+debug_field_size]), description);
                                                }
                                                else {
-                                                       log_warn!(logger, "Onion Error[{}({:#x})] {}", title, error_code, description);
+                                                       log_warn!(logger, "Onion Error[from {}: {}({:#x})] {}", route_hop.pubkey, title, error_code, description);
                                                }
                                        } else {
                                                // Useless packet that we can't use but it passed HMAC, so it
@@ -477,7 +479,8 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
 
 #[cfg(test)]
 mod tests {
-       use ln::channelmanager::PaymentHash;
+       use prelude::*;
+       use ln::PaymentHash;
        use ln::features::{ChannelFeatures, NodeFeatures};
        use routing::router::{Route, RouteHop};
        use ln::msgs;