X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fonion_utils.rs;h=4b39276c066c77ec5975be569c274081158750ed;hb=e142e4a4e6c856f533ec350ae61c1bbe2a3f20e9;hp=137699521f482b6b186a4375477284a010bc897b;hpb=53f2e2e882c0836ed9a31d1844fa2920f6c91278;p=rust-lightning diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index 13769952..4b39276c 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -14,7 +14,8 @@ use crate::ln::wire::Encode; use crate::routing::gossip::NetworkUpdate; use crate::routing::router::{BlindedTail, Path, RouteHop}; use crate::sign::NodeSigner; -use crate::util::chacha20::{ChaCha20, ChaChaReader}; +use crate::crypto::chacha20::ChaCha20; +use crate::crypto::streams::ChaChaReader; use crate::util::errors::{self, APIError}; use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer, LengthCalculatingWriter}; use crate::util::logger::Logger; @@ -428,6 +429,7 @@ pub(crate) struct DecodedOnionFailure { pub(crate) network_update: Option, pub(crate) short_channel_id: Option, pub(crate) payment_failed_permanently: bool, + pub(crate) failed_within_blinded_path: bool, #[cfg(test)] pub(crate) onion_error_code: Option, #[cfg(test)] @@ -462,6 +464,7 @@ pub(super) fn process_onion_failure( network_update: Option, short_channel_id: Option, payment_failed_permanently: bool, + failed_within_blinded_path: bool, } let mut res: Option = None; let mut htlc_msat = *first_hop_htlc_msat; @@ -487,7 +490,8 @@ pub(super) fn process_onion_failure( error_code_ret = Some(BADONION | PERM | 24); // invalid_onion_blinding error_packet_ret = Some(vec![0; 32]); res = Some(FailureLearnings { - network_update: None, short_channel_id: None, payment_failed_permanently: false + network_update: None, short_channel_id: None, payment_failed_permanently: false, + failed_within_blinded_path: true, }); return }, @@ -519,7 +523,8 @@ pub(super) fn process_onion_failure( } res = Some(FailureLearnings { - network_update: None, short_channel_id: None, payment_failed_permanently: false + network_update: None, short_channel_id: None, payment_failed_permanently: false, + failed_within_blinded_path: true, }); return } @@ -549,7 +554,8 @@ pub(super) fn process_onion_failure( }); let short_channel_id = Some(route_hop.short_channel_id); res = Some(FailureLearnings { - network_update, short_channel_id, payment_failed_permanently: is_from_final_node + network_update, short_channel_id, payment_failed_permanently: is_from_final_node, + failed_within_blinded_path: false }); return } @@ -705,7 +711,8 @@ pub(super) fn process_onion_failure( res = Some(FailureLearnings { network_update, short_channel_id, - payment_failed_permanently: error_code & PERM == PERM && is_from_final_node + payment_failed_permanently: error_code & PERM == PERM && is_from_final_node, + failed_within_blinded_path: false }); let (description, title) = errors::get_onion_error_description(error_code); @@ -716,10 +723,10 @@ pub(super) fn process_onion_failure( } }).expect("Route that we sent via spontaneously grew invalid keys in the middle of it?"); if let Some(FailureLearnings { - network_update, short_channel_id, payment_failed_permanently + network_update, short_channel_id, payment_failed_permanently, failed_within_blinded_path }) = res { DecodedOnionFailure { - network_update, short_channel_id, payment_failed_permanently, + network_update, short_channel_id, payment_failed_permanently, failed_within_blinded_path, #[cfg(test)] onion_error_code: error_code_ret, #[cfg(test)] @@ -730,6 +737,7 @@ pub(super) fn process_onion_failure( // payment not retryable only when garbage is from the final node DecodedOnionFailure { network_update: None, short_channel_id: None, payment_failed_permanently: is_from_final_node, + failed_within_blinded_path: false, #[cfg(test)] onion_error_code: None, #[cfg(test)] @@ -877,6 +885,7 @@ impl HTLCFailReason { network_update: None, payment_failed_permanently: false, short_channel_id: Some(path.hops[0].short_channel_id), + failed_within_blinded_path: false, #[cfg(test)] onion_error_code: Some(*failure_code), #[cfg(test)]