@@ -129,20 +129,22 @@ pub(super) enum PendingHTLCStatus {
129
129
Fail ( HTLCFailureMsg ) ,
130
130
}
131
131
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
+ }
135
145
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 ) ,
146
148
FailHTLC {
147
149
htlc_id : u64 ,
148
150
err_packet : msgs:: OnionErrorPacket ,
@@ -3149,9 +3151,13 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3149
3151
( ) => {
3150
3152
for forward_info in pending_forwards. drain( ..) {
3151
3153
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
+ } ) => {
3155
3161
macro_rules! failure_handler {
3156
3162
( $msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr, $next_hop_unknown: expr) => {
3157
3163
log_info!( self . logger, "Failed to accept/forward incoming HTLC: {}" , $msg) ;
@@ -3252,11 +3258,13 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3252
3258
let mut fail_htlc_msgs = Vec :: new ( ) ;
3253
3259
for forward_info in pending_forwards. drain ( ..) {
3254
3260
match forward_info {
3255
- HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info : PendingHTLCInfo {
3256
- routing : PendingHTLCRouting :: Forward {
3257
- onion_packet, ..
3258
- } , incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value } ,
3259
- prev_funding_outpoint } => {
3261
+ HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3262
+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint ,
3263
+ forward_info : PendingHTLCInfo {
3264
+ incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value,
3265
+ routing : PendingHTLCRouting :: Forward { onion_packet, .. } ,
3266
+ } ,
3267
+ } ) => {
3260
3268
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) ;
3261
3269
let htlc_source = HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
3262
3270
short_channel_id : prev_short_channel_id,
@@ -3377,9 +3385,12 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3377
3385
} else {
3378
3386
for forward_info in pending_forwards. drain ( ..) {
3379
3387
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 } => {
3388
+ HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3389
+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint,
3390
+ forward_info : PendingHTLCInfo {
3391
+ routing, incoming_shared_secret, payment_hash, amt_to_forward, ..
3392
+ }
3393
+ } ) => {
3383
3394
let ( cltv_expiry, onion_payload, payment_data, phantom_shared_secret) = match routing {
3384
3395
PendingHTLCRouting :: Receive { payment_data, incoming_cltv_expiry, phantom_shared_secret } => {
3385
3396
let _legacy_hop_data = Some ( payment_data. clone ( ) ) ;
@@ -5089,12 +5100,12 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5089
5100
PendingHTLCRouting :: ReceiveKeysend { .. } => 0 ,
5090
5101
} ) {
5091
5102
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 } ) ;
5103
+ entry. get_mut ( ) . push ( HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
5104
+ prev_short_channel_id , prev_funding_outpoint , prev_htlc_id, forward_info } ) ) ;
5094
5105
} ,
5095
5106
hash_map:: Entry :: Vacant ( entry) => {
5096
- entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id , prev_funding_outpoint ,
5097
- prev_htlc_id, forward_info } ) ) ;
5107
+ entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
5108
+ prev_short_channel_id , prev_funding_outpoint , prev_htlc_id, forward_info } ) ) ) ;
5098
5109
}
5099
5110
}
5100
5111
}
@@ -6681,18 +6692,20 @@ impl_writeable_tlv_based_enum!(HTLCFailReason,
6681
6692
} ,
6682
6693
; ) ;
6683
6694
6695
+ impl_writeable_tlv_based ! ( PendingAddHTLCInfo , {
6696
+ ( 0 , forward_info, required) ,
6697
+ ( 2 , prev_short_channel_id, required) ,
6698
+ ( 4 , prev_htlc_id, required) ,
6699
+ ( 6 , prev_funding_outpoint, required) ,
6700
+ } ) ;
6701
+
6684
6702
impl_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
- } ,
6691
6703
( 1 , FailHTLC ) => {
6692
6704
( 0 , htlc_id, required) ,
6693
6705
( 2 , err_packet, required) ,
6694
- } ,
6695
- ; ) ;
6706
+ } ;
6707
+ ( 0 , AddHTLC )
6708
+ ) ;
6696
6709
6697
6710
impl_writeable_tlv_based ! ( PendingInboundPayment , {
6698
6711
( 0 , payment_secret, required) ,
0 commit comments