+// 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::channelmanager::{PaymentHash, PaymentSecret, HTLCSource};
use ln::msgs;
-use ln::router::RouteHop;
+use routing::router::RouteHop;
use util::byte_utils;
use util::chacha20::ChaCha20;
use util::errors::{self, APIError};
use util::ser::{Readable, Writeable, LengthCalculatingWriter};
-use util::logger::{Logger, LogHolder};
+use util::logger::Logger;
use bitcoin::hashes::{Hash, HashEngine};
use bitcoin::hashes::cmp::fixed_time_eq;
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
use bitcoin::hashes::sha256::Hash as Sha256;
-use secp256k1::key::{SecretKey,PublicKey};
-use secp256k1::Secp256k1;
-use secp256k1::ecdh::SharedSecret;
-use secp256k1;
+use bitcoin::secp256k1::key::{SecretKey,PublicKey};
+use bitcoin::secp256k1::Secp256k1;
+use bitcoin::secp256k1::ecdh::SharedSecret;
+use bitcoin::secp256k1;
use std::io::Cursor;
-use std::sync::Arc;
+use std::ops::Deref;
pub(super) struct OnionKeys {
#[cfg(test)]
});
cur_value_msat += hop.fee_msat;
if cur_value_msat >= 21000000 * 100000000 * 1000 {
- return Err(APIError::RouteError{err: "Channel fees overflowed?!"});
+ return Err(APIError::RouteError{err: "Channel fees overflowed?"});
}
cur_cltv += hop.cltv_expiry_delta as u32;
if cur_cltv >= 500000000 {
- return Err(APIError::RouteError{err: "Channel CLTV overflowed?!"});
+ return Err(APIError::RouteError{err: "Channel CLTV overflowed?"});
}
last_short_channel_id = hop.short_channel_id;
}
/// OutboundRoute).
/// Returns update, a boolean indicating that the payment itself failed, and the error code.
#[inline]
-pub(super) fn process_onion_failure<T: secp256k1::Signing>(secp_ctx: &Secp256k1<T>, logger: &Arc<Logger>, htlc_source: &HTLCSource, mut packet_decrypted: Vec<u8>) -> (Option<msgs::HTLCFailChannelUpdate>, bool, Option<u16>, Option<Vec<u8>>) {
+pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &Secp256k1<T>, logger: &L, htlc_source: &HTLCSource, mut packet_decrypted: Vec<u8>) -> (Option<msgs::HTLCFailChannelUpdate>, bool, Option<u16>, Option<Vec<u8>>) where L::Target: Logger {
if let &HTLCSource::OutboundRoute { ref path, ref session_priv, ref first_hop_htlc_msat } = htlc_source {
let mut res = None;
let mut htlc_msat = *first_hop_htlc_msat;
let (description, title) = errors::get_onion_error_description(error_code);
if debug_field_size > 0 && err_packet.failuremsg.len() >= 4 + debug_field_size {
- let log_holder = LogHolder { logger };
- log_warn!(log_holder, "Onion Error[{}({:#x}) {}({})] {}", title, error_code, debug_field, log_bytes!(&err_packet.failuremsg[4..4+debug_field_size]), description);
+ log_warn!(logger, "Onion Error[{}({:#x}) {}({})] {}", title, error_code, debug_field, log_bytes!(&err_packet.failuremsg[4..4+debug_field_size]), description);
}
else {
- let log_holder = LogHolder { logger };
- log_warn!(log_holder, "Onion Error[{}({:#x})] {}", title, error_code, description);
+ log_warn!(logger, "Onion Error[{}({:#x})] {}", title, error_code, description);
}
} else {
// Useless packet that we can't use but it passed HMAC, so it
mod tests {
use ln::channelmanager::PaymentHash;
use ln::features::{ChannelFeatures, NodeFeatures};
- use ln::router::{Route, RouteHop};
+ use routing::router::{Route, RouteHop};
use ln::msgs;
use util::ser::{Writeable, Writer};
use hex;
- use secp256k1::Secp256k1;
- use secp256k1::key::{PublicKey,SecretKey};
+ use bitcoin::secp256k1::Secp256k1;
+ use bitcoin::secp256k1::key::{PublicKey,SecretKey};
use super::OnionKeys;