@@ -129,20 +129,22 @@ pub(super) enum PendingHTLCStatus {
129129 Fail ( HTLCFailureMsg ) ,
130130}
131131
132- pub ( super ) enum HTLCForwardInfo {
133- AddHTLC {
134- forward_info : PendingHTLCInfo ,
132+ pub ( super ) struct PendingAddHTLCInfo {
133+ pub ( super ) forward_info : PendingHTLCInfo ,
134+
135+ // These fields are produced in `forward_htlcs()` and consumed in
136+ // `process_pending_htlc_forwards()` for constructing the
137+ // `HTLCSource::PreviousHopData` for failed and forwarded
138+ // HTLCs.
139+ //
140+ // Note that this may be an outbound SCID alias for the associated channel.
141+ prev_short_channel_id : u64 ,
142+ prev_htlc_id : u64 ,
143+ prev_funding_outpoint : OutPoint ,
144+ }
135145
136- // These fields are produced in `forward_htlcs()` and consumed in
137- // `process_pending_htlc_forwards()` for constructing the
138- // `HTLCSource::PreviousHopData` for failed and forwarded
139- // HTLCs.
140- //
141- // Note that this may be an outbound SCID alias for the associated channel.
142- prev_short_channel_id : u64 ,
143- prev_htlc_id : u64 ,
144- prev_funding_outpoint : OutPoint ,
145- } ,
146+ pub ( super ) enum HTLCForwardInfo {
147+ AddHTLC ( PendingAddHTLCInfo ) ,
146148 FailHTLC {
147149 htlc_id : u64 ,
148150 err_packet : msgs:: OnionErrorPacket ,
@@ -3149,9 +3151,13 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
31493151 ( ) => {
31503152 for forward_info in pending_forwards. drain( ..) {
31513153 match forward_info {
3152- HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info: PendingHTLCInfo {
3153- routing, incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value } ,
3154- prev_funding_outpoint } => {
3154+ HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3155+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint,
3156+ forward_info: PendingHTLCInfo {
3157+ routing, incoming_shared_secret, payment_hash, amt_to_forward,
3158+ outgoing_cltv_value
3159+ }
3160+ } ) => {
31553161 macro_rules! failure_handler {
31563162 ( $msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr, $next_hop_unknown: expr) => {
31573163 log_info!( self . logger, "Failed to accept/forward incoming HTLC: {}" , $msg) ;
@@ -3252,11 +3258,14 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
32523258 let mut fail_htlc_msgs = Vec :: new ( ) ;
32533259 for forward_info in pending_forwards. drain ( ..) {
32543260 match forward_info {
3255- HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info : PendingHTLCInfo {
3261+ HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3262+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint ,
3263+ forward_info : PendingHTLCInfo {
32563264 routing : PendingHTLCRouting :: Forward {
32573265 onion_packet, ..
3258- } , incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value } ,
3259- prev_funding_outpoint } => {
3266+ } , incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value
3267+ } ,
3268+ } ) => {
32603269 log_trace ! ( self . logger, "Adding HTLC from short id {} with payment_hash {} to channel with short id {} after delay" , prev_short_channel_id, log_bytes!( payment_hash. 0 ) , short_chan_id) ;
32613270 let htlc_source = HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
32623271 short_channel_id : prev_short_channel_id,
@@ -3377,9 +3386,12 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
33773386 } else {
33783387 for forward_info in pending_forwards. drain ( ..) {
33793388 match forward_info {
3380- HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info : PendingHTLCInfo {
3381- routing, incoming_shared_secret, payment_hash, amt_to_forward, .. } ,
3382- prev_funding_outpoint } => {
3389+ HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3390+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint,
3391+ forward_info : PendingHTLCInfo {
3392+ routing, incoming_shared_secret, payment_hash, amt_to_forward, ..
3393+ }
3394+ } ) => {
33833395 let ( cltv_expiry, onion_payload, payment_data, phantom_shared_secret) = match routing {
33843396 PendingHTLCRouting :: Receive { payment_data, incoming_cltv_expiry, phantom_shared_secret } => {
33853397 let _legacy_hop_data = Some ( payment_data. clone ( ) ) ;
@@ -5089,12 +5101,12 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
50895101 PendingHTLCRouting :: ReceiveKeysend { .. } => 0 ,
50905102 } ) {
50915103 hash_map:: Entry :: Occupied ( mut entry) => {
5092- entry. get_mut ( ) . push ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id , prev_funding_outpoint ,
5093- prev_htlc_id, forward_info } ) ;
5104+ entry. get_mut ( ) . push ( HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
5105+ prev_short_channel_id , prev_funding_outpoint , prev_htlc_id, forward_info } ) ) ;
50945106 } ,
50955107 hash_map:: Entry :: Vacant ( entry) => {
5096- entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id , prev_funding_outpoint ,
5097- prev_htlc_id, forward_info } ) ) ;
5108+ entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
5109+ prev_short_channel_id , prev_funding_outpoint , prev_htlc_id, forward_info } ) ) ) ;
50985110 }
50995111 }
51005112 }
@@ -6681,18 +6693,20 @@ impl_writeable_tlv_based_enum!(HTLCFailReason,
66816693 } ,
66826694; ) ;
66836695
6696+ impl_writeable_tlv_based ! ( PendingAddHTLCInfo , {
6697+ ( 0 , forward_info, required) ,
6698+ ( 2 , prev_short_channel_id, required) ,
6699+ ( 4 , prev_htlc_id, required) ,
6700+ ( 6 , prev_funding_outpoint, required) ,
6701+ } ) ;
6702+
66846703impl_writeable_tlv_based_enum ! ( HTLCForwardInfo ,
6685- ( 0 , AddHTLC ) => {
6686- ( 0 , forward_info, required) ,
6687- ( 2 , prev_short_channel_id, required) ,
6688- ( 4 , prev_htlc_id, required) ,
6689- ( 6 , prev_funding_outpoint, required) ,
6690- } ,
66916704 ( 1 , FailHTLC ) => {
66926705 ( 0 , htlc_id, required) ,
66936706 ( 2 , err_packet, required) ,
6694- } ,
6695- ; ) ;
6707+ } ;
6708+ ( 0 , AddHTLC )
6709+ ) ;
66966710
66976711impl_writeable_tlv_based ! ( PendingInboundPayment , {
66986712 ( 0 , payment_secret, required) ,
0 commit comments