Use core replacements for std members
[rust-lightning] / lightning / src / ln / onion_utils.rs
index 08e9e6a88cecb6f30bd6824a41da493b243f72b7..07686a214e23c90c3e1166bca19580da55309777 100644 (file)
@@ -1,4 +1,14 @@
-use ln::channelmanager::{PaymentHash, PaymentSecret, HTLCSource};
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+use ln::{PaymentHash, PaymentSecret};
+use ln::channelmanager::HTLCSource;
 use ln::msgs;
 use routing::router::RouteHop;
 use util::byte_utils;
@@ -18,7 +28,7 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
 use bitcoin::secp256k1;
 
 use std::io::Cursor;
-use std::ops::Deref;
+use core::ops::Deref;
 
 pub(super) struct OnionKeys {
        #[cfg(test)]
@@ -297,8 +307,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);
@@ -440,10 +450,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
@@ -468,7 +478,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
 
 #[cfg(test)]
 mod tests {
-       use ln::channelmanager::PaymentHash;
+       use ln::PaymentHash;
        use ln::features::{ChannelFeatures, NodeFeatures};
        use routing::router::{Route, RouteHop};
        use ln::msgs;