X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Frouter.rs;h=436a37144b459a4e73d03bace511b875b47e4386;hb=15c9f5bd7c885b08717072a79d5a2dc23ec1c376;hp=c72e5cd9ae77577485c9fbecb5bd9bd5bc1904e2;hpb=32ab7a9e4d1200caf5b2e5c9f48c12861dc35fcb;p=rust-lightning diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index c72e5cd9..436a3714 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -20,13 +20,13 @@ use crate::ln::channelmanager::{ChannelDetails, PaymentId}; use crate::ln::features::{BlindedHopFeatures, Bolt11InvoiceFeatures, Bolt12InvoiceFeatures, ChannelFeatures, NodeFeatures}; use crate::ln::msgs::{DecodeError, ErrorAction, LightningError, MAX_VALUE_MSAT}; use crate::offers::invoice::{BlindedPayInfo, Bolt12Invoice}; -use crate::onion_message::{DefaultMessageRouter, Destination, MessageRouter, OnionMessagePath}; +use crate::onion_message::messenger::{DefaultMessageRouter, Destination, MessageRouter, OnionMessagePath}; use crate::routing::gossip::{DirectedChannelInfo, EffectiveCapacity, ReadOnlyNetworkGraph, NetworkGraph, NodeId, RoutingFees}; use crate::routing::scoring::{ChannelUsage, LockableScore, ScoreLookUp}; use crate::sign::EntropySource; use crate::util::ser::{Writeable, Readable, ReadableArgs, Writer}; use crate::util::logger::{Level, Logger}; -use crate::util::chacha20::ChaCha20; +use crate::crypto::chacha20::ChaCha20; use crate::io; use crate::prelude::*; @@ -114,19 +114,14 @@ impl> + Clone, L: Deref, S: Deref, SP: Sized, None => return None, }; let payment_relay: PaymentRelay = match details.counterparty.forwarding_info { - Some(forwarding_info) => forwarding_info.into(), + Some(forwarding_info) => match forwarding_info.try_into() { + Ok(payment_relay) => payment_relay, + Err(()) => return None, + }, None => return None, }; - // Avoid exposing esoteric CLTV expiry deltas - let cltv_expiry_delta = match payment_relay.cltv_expiry_delta { - 0..=40 => 40u32, - 41..=80 => 80u32, - 81..=144 => 144u32, - 145..=216 => 216u32, - _ => return None, - }; - + let cltv_expiry_delta = payment_relay.cltv_expiry_delta as u32; let payment_constraints = PaymentConstraints { max_cltv_expiry: tlvs.payment_constraints.max_cltv_expiry + cltv_expiry_delta, htlc_minimum_msat: details.inbound_htlc_minimum_msat.unwrap_or(0), @@ -2745,7 +2740,7 @@ where L::Target: Logger { } } - // Means we succesfully traversed from the payer to the payee, now + // Means we successfully traversed from the payer to the payee, now // save this path for the payment route. Also, update the liquidity // remaining on the used hops, so that we take them into account // while looking for more paths. @@ -3234,7 +3229,7 @@ mod tests { use crate::offers::invoice::BlindedPayInfo; use crate::util::config::UserConfig; use crate::util::test_utils as ln_test_utils; - use crate::util::chacha20::ChaCha20; + use crate::crypto::chacha20::ChaCha20; use crate::util::ser::{Readable, Writeable}; #[cfg(c_bindings)] use crate::util::ser::Writer; @@ -7842,7 +7837,7 @@ mod tests { fn do_min_htlc_overpay_violates_max_htlc(blinded_payee: bool) { // Test that if overpaying to meet a later hop's min_htlc and causes us to violate an earlier // hop's max_htlc, we don't consider that candidate hop valid. Previously we would add this hop - // to `targets` and build an invalid path with it, and subsquently hit a debug panic asserting + // to `targets` and build an invalid path with it, and subsequently hit a debug panic asserting // that the used liquidity for a hop was less than its available liquidity limit. let secp_ctx = Secp256k1::new(); let logger = Arc::new(ln_test_utils::TestLogger::new()); @@ -8491,7 +8486,7 @@ pub(crate) mod bench_utils { } break; } - // If we couldn't find a path with a higer amount, reduce and try again. + // If we couldn't find a path with a higher amount, reduce and try again. score_amt /= 100; }