@@ -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,14 @@ 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 {
3261
+ HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3262
+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint ,
3263
+ forward_info : PendingHTLCInfo {
3256
3264
routing : PendingHTLCRouting :: Forward {
3257
3265
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
+ } ) => {
3260
3269
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
3270
let htlc_source = HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
3262
3271
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
3377
3386
} else {
3378
3387
for forward_info in pending_forwards. drain ( ..) {
3379
3388
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
+ } ) => {
3383
3395
let ( cltv_expiry, onion_payload, payment_data, phantom_shared_secret) = match routing {
3384
3396
PendingHTLCRouting :: Receive { payment_data, incoming_cltv_expiry, phantom_shared_secret } => {
3385
3397
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
5089
5101
PendingHTLCRouting :: ReceiveKeysend { .. } => 0 ,
5090
5102
} ) {
5091
5103
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 } ) ) ;
5094
5106
} ,
5095
5107
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 } ) ) ) ;
5098
5110
}
5099
5111
}
5100
5112
}
@@ -6681,18 +6693,20 @@ impl_writeable_tlv_based_enum!(HTLCFailReason,
6681
6693
} ,
6682
6694
; ) ;
6683
6695
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
+
6684
6703
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
6704
( 1 , FailHTLC ) => {
6692
6705
( 0 , htlc_id, required) ,
6693
6706
( 2 , err_packet, required) ,
6694
- } ,
6695
- ; ) ;
6707
+ } ;
6708
+ ( 0 , AddHTLC )
6709
+ ) ;
6696
6710
6697
6711
impl_writeable_tlv_based ! ( PendingInboundPayment , {
6698
6712
( 0 , payment_secret, required) ,
0 commit comments