@@ -2139,6 +2139,23 @@ impl HTLCFailReason {
21392139 pub ( super ) fn decode_onion_failure < T : secp256k1:: Signing , L : Logger > (
21402140 & self , secp_ctx : & Secp256k1 < T > , logger : & L , htlc_source : & HTLCSource ,
21412141 ) -> DecodedOnionFailure {
2142+ macro_rules! decoded_onion_failure {
2143+ ( $short_channel_id: expr, $failure_reason: expr, $data: expr) => {
2144+ DecodedOnionFailure {
2145+ network_update: None ,
2146+ payment_failed_permanently: false ,
2147+ short_channel_id: $short_channel_id,
2148+ failed_within_blinded_path: false ,
2149+ hold_times: Vec :: new( ) ,
2150+ #[ cfg( any( test, feature = "_test_utils" ) ) ]
2151+ onion_error_code: Some ( $failure_reason) ,
2152+ #[ cfg( any( test, feature = "_test_utils" ) ) ]
2153+ onion_error_data: Some ( $data. clone( ) ) ,
2154+ #[ cfg( test) ]
2155+ attribution_failed_channel: None ,
2156+ }
2157+ } ;
2158+ }
21422159 match self . 0 {
21432160 HTLCFailReasonRepr :: LightningError { ref err, .. } => {
21442161 process_onion_failure ( secp_ctx, logger, & htlc_source, err. clone ( ) )
@@ -2150,22 +2167,19 @@ impl HTLCFailReason {
21502167 // failures here, but that would be insufficient as find_route
21512168 // generally ignores its view of our own channels as we provide them via
21522169 // ChannelDetails.
2153- if let & HTLCSource :: OutboundRoute { ref path, .. } = htlc_source {
2154- DecodedOnionFailure {
2155- network_update : None ,
2156- payment_failed_permanently : false ,
2157- short_channel_id : Some ( path. hops [ 0 ] . short_channel_id ) ,
2158- failed_within_blinded_path : false ,
2159- hold_times : Vec :: new ( ) ,
2160- #[ cfg( any( test, feature = "_test_utils" ) ) ]
2161- onion_error_code : Some ( * failure_reason) ,
2162- #[ cfg( any( test, feature = "_test_utils" ) ) ]
2163- onion_error_data : Some ( data. clone ( ) ) ,
2164- #[ cfg( test) ]
2165- attribution_failed_channel : None ,
2166- }
2167- } else {
2168- unreachable ! ( ) ;
2170+ match htlc_source {
2171+ & HTLCSource :: OutboundRoute { ref path, .. } => {
2172+ decoded_onion_failure ! (
2173+ ( Some ( path. hops[ 0 ] . short_channel_id) ) ,
2174+ * failure_reason,
2175+ data
2176+ )
2177+ } ,
2178+ & HTLCSource :: TrampolineForward { ref outbound_payment, .. } => {
2179+ debug_assert ! ( outbound_payment. is_none( ) ) ;
2180+ decoded_onion_failure ! ( None , * failure_reason, data)
2181+ } ,
2182+ _ => unreachable ! ( ) ,
21692183 }
21702184 } ,
21712185 }
0 commit comments