@@ -1798,8 +1798,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1798
1798
} ,
1799
1799
} ;
1800
1800
1801
- let pending_forward_info = match next_hop {
1802
- onion_utils :: Hop :: Receive ( next_hop_data ) => {
1801
+ macro_rules! get_recv_pending_htlc_status {
1802
+ ( $hop_data : expr ) => { {
1803
1803
// OUR PAYMENT!
1804
1804
// final_expiry_too_soon
1805
1805
// We have to have some headroom to broadcast on chain if we have the preimage, so make sure
@@ -1811,15 +1811,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1811
1811
return_err!( "The final CLTV expiry is too soon to handle" , 17 , & [ 0 ; 0 ] ) ;
1812
1812
}
1813
1813
// final_incorrect_htlc_amount
1814
- if next_hop_data . amt_to_forward > msg. amount_msat {
1814
+ if $hop_data . amt_to_forward > msg. amount_msat {
1815
1815
return_err!( "Upstream node sent less than we were supposed to receive in payment" , 19 , & byte_utils:: be64_to_array( msg. amount_msat) ) ;
1816
1816
}
1817
- // final_incorrect_cltv_expiry
1818
- if next_hop_data. outgoing_cltv_value != msg. cltv_expiry {
1819
- return_err ! ( "Upstream node set CLTV to the wrong value" , 18 , & byte_utils:: be32_to_array( msg. cltv_expiry) ) ;
1820
- }
1821
1817
1822
- let routing = match next_hop_data . format {
1818
+ let routing = match $hop_data . format {
1823
1819
msgs:: OnionHopDataFormat :: Legacy { .. } => return_err!( "We require payment_secrets" , 0x4000 |0x2000 |3 , & [ 0 ; 0 ] ) ,
1824
1820
msgs:: OnionHopDataFormat :: NonFinalNode { .. } => return_err!( "Got non final data with an HMAC of 0" , 0x4000 | 22 , & [ 0 ; 0 ] ) ,
1825
1821
msgs:: OnionHopDataFormat :: FinalNode { payment_data, keysend_preimage } => {
@@ -1860,9 +1856,19 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1860
1856
routing,
1861
1857
payment_hash: msg. payment_hash. clone( ) ,
1862
1858
incoming_shared_secret: shared_secret,
1863
- amt_to_forward : next_hop_data . amt_to_forward ,
1864
- outgoing_cltv_value : next_hop_data . outgoing_cltv_value ,
1859
+ amt_to_forward: $hop_data . amt_to_forward,
1860
+ outgoing_cltv_value: $hop_data . outgoing_cltv_value,
1865
1861
} )
1862
+ } }
1863
+ }
1864
+
1865
+ let pending_forward_info = match next_hop {
1866
+ onion_utils:: Hop :: Receive ( next_hop_data) => {
1867
+ // final_incorrect_cltv_expiry
1868
+ if next_hop_data. outgoing_cltv_value != msg. cltv_expiry {
1869
+ return_err ! ( "Upstream node set CLTV to the wrong value" , 18 , & byte_utils:: be32_to_array( msg. cltv_expiry) ) ;
1870
+ }
1871
+ get_recv_pending_htlc_status ! ( next_hop_data)
1866
1872
} ,
1867
1873
onion_utils:: Hop :: Forward { next_hop_data, next_hop_hmac, new_packet_bytes } => {
1868
1874
let mut new_pubkey = msg. onion_routing_packet . public_key . unwrap ( ) ;
0 commit comments