@@ -2119,8 +2119,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2119
2119
} ,
2120
2120
} ;
2121
2121
2122
- let pending_forward_info = match next_hop {
2123
- onion_utils :: Hop :: Receive ( next_hop_data ) => {
2122
+ macro_rules! get_recv_pending_htlc_status {
2123
+ ( $hop_data : expr ) => { {
2124
2124
// OUR PAYMENT!
2125
2125
// final_expiry_too_soon
2126
2126
// We have to have some headroom to broadcast on chain if we have the preimage, so make sure
@@ -2132,15 +2132,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2132
2132
return_err!( "The final CLTV expiry is too soon to handle" , 17 , & [ 0 ; 0 ] ) ;
2133
2133
}
2134
2134
// final_incorrect_htlc_amount
2135
- if next_hop_data . amt_to_forward > msg. amount_msat {
2135
+ if $hop_data . amt_to_forward > msg. amount_msat {
2136
2136
return_err!( "Upstream node sent less than we were supposed to receive in payment" , 19 , & byte_utils:: be64_to_array( msg. amount_msat) ) ;
2137
2137
}
2138
- // final_incorrect_cltv_expiry
2139
- if next_hop_data. outgoing_cltv_value != msg. cltv_expiry {
2140
- return_err ! ( "Upstream node set CLTV to the wrong value" , 18 , & byte_utils:: be32_to_array( msg. cltv_expiry) ) ;
2141
- }
2142
2138
2143
- let routing = match next_hop_data . format {
2139
+ let routing = match $hop_data . format {
2144
2140
msgs:: OnionHopDataFormat :: Legacy { .. } => return_err!( "We require payment_secrets" , 0x4000 |0x2000 |3 , & [ 0 ; 0 ] ) ,
2145
2141
msgs:: OnionHopDataFormat :: NonFinalNode { .. } => return_err!( "Got non final data with an HMAC of 0" , 0x4000 | 22 , & [ 0 ; 0 ] ) ,
2146
2142
msgs:: OnionHopDataFormat :: FinalNode { payment_data, keysend_preimage } => {
@@ -2181,9 +2177,19 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2181
2177
routing,
2182
2178
payment_hash: msg. payment_hash. clone( ) ,
2183
2179
incoming_shared_secret: shared_secret,
2184
- amt_to_forward : next_hop_data . amt_to_forward ,
2185
- outgoing_cltv_value : next_hop_data . outgoing_cltv_value ,
2180
+ amt_to_forward: $hop_data . amt_to_forward,
2181
+ outgoing_cltv_value: $hop_data . outgoing_cltv_value,
2186
2182
} )
2183
+ } }
2184
+ }
2185
+
2186
+ let pending_forward_info = match next_hop {
2187
+ onion_utils:: Hop :: Receive ( next_hop_data) => {
2188
+ // final_incorrect_cltv_expiry
2189
+ if next_hop_data. outgoing_cltv_value != msg. cltv_expiry {
2190
+ return_err ! ( "Upstream node set CLTV to the wrong value" , 18 , & byte_utils:: be32_to_array( msg. cltv_expiry) ) ;
2191
+ }
2192
+ get_recv_pending_htlc_status ! ( next_hop_data)
2187
2193
} ,
2188
2194
onion_utils:: Hop :: Forward { next_hop_data, next_hop_hmac, new_packet_bytes } => {
2189
2195
let mut new_pubkey = msg. onion_routing_packet . public_key . unwrap ( ) ;
0 commit comments