@@ -116,6 +116,7 @@ pub(super) struct PendingHTLCInfo {
116
116
payment_hash : PaymentHash ,
117
117
pub ( super ) amt_to_forward : u64 ,
118
118
pub ( super ) outgoing_cltv_value : u32 ,
119
+ pub ( super ) amt_incoming : Option < u64 >
119
120
}
120
121
121
122
#[ derive( Clone ) ] // See Channel::revoke_and_ack for why, tl;dr: Rust bug
@@ -136,7 +137,6 @@ pub(super) struct PendingInterceptedHTLC {
136
137
prev_short_channel_id : u64 ,
137
138
prev_htlc_id : u64 ,
138
139
prev_funding_outpoint : OutPoint ,
139
- prev_htlc_amount : u64
140
140
}
141
141
142
142
pub ( super ) enum HTLCForwardInfo {
@@ -152,7 +152,6 @@ pub(super) enum HTLCForwardInfo {
152
152
prev_short_channel_id : u64 ,
153
153
prev_htlc_id : u64 ,
154
154
prev_funding_outpoint : OutPoint ,
155
- prev_htlc_amount : Option < u64 >
156
155
} ,
157
156
FailHTLC {
158
157
htlc_id : u64 ,
@@ -1374,7 +1373,7 @@ macro_rules! handle_monitor_err {
1374
1373
} else if $resend_commitment { "commitment" }
1375
1374
else if $resend_raa { "RAA" }
1376
1375
else { "nothing" } ,
1377
- ( & $failed_forwards as & Vec <( PendingHTLCInfo , u64 , Option < u64 > ) >) . len( ) ,
1376
+ ( & $failed_forwards as & Vec <( PendingHTLCInfo , u64 ) >) . len( ) ,
1378
1377
( & $failed_fails as & Vec <( HTLCSource , PaymentHash , HTLCFailReason ) >) . len( ) ,
1379
1378
( & $failed_finalized_fulfills as & Vec <HTLCSource >) . len( ) ) ;
1380
1379
if !$resend_commitment {
@@ -1463,7 +1462,7 @@ macro_rules! handle_chan_restoration_locked {
1463
1462
let chanmon_update_is_none = chanmon_update. is_none( ) ;
1464
1463
let counterparty_node_id = $channel_entry. get( ) . get_counterparty_node_id( ) ;
1465
1464
let res = loop {
1466
- let forwards: Vec <( PendingHTLCInfo , u64 , Option < u64 > ) > = $pending_forwards; // Force type-checking to resolve
1465
+ let forwards: Vec <( PendingHTLCInfo , u64 ) > = $pending_forwards; // Force type-checking to resolve
1467
1466
if !forwards. is_empty( ) {
1468
1467
htlc_forwards = Some ( ( $channel_entry. get( ) . get_short_channel_id( ) . unwrap_or( $channel_entry. get( ) . outbound_scid_alias( ) ) ,
1469
1468
$channel_entry. get( ) . get_funding_txo( ) . unwrap( ) , forwards) ) ;
@@ -2146,6 +2145,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2146
2145
payment_hash,
2147
2146
incoming_shared_secret : shared_secret,
2148
2147
amt_to_forward : amt_msat,
2148
+ amt_incoming : Some ( amt_msat) ,
2149
2149
outgoing_cltv_value : hop_data. outgoing_cltv_value ,
2150
2150
} )
2151
2151
}
@@ -2248,6 +2248,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2248
2248
incoming_shared_secret : shared_secret,
2249
2249
amt_to_forward : next_hop_data. amt_to_forward ,
2250
2250
outgoing_cltv_value : next_hop_data. outgoing_cltv_value ,
2251
+ amt_incoming : Some ( msg. amount_msat )
2251
2252
} )
2252
2253
}
2253
2254
} ;
@@ -3137,7 +3138,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3137
3138
..payment. forward_info
3138
3139
} ;
3139
3140
3140
- let mut per_source_pending_forward = vec ! [ ( payment. prev_short_channel_id, payment. prev_funding_outpoint, vec![ ( pending_htlc_info, payment. prev_htlc_id, Some ( payment . prev_htlc_amount ) ) ] ) ] ;
3141
+ let mut per_source_pending_forward = vec ! [ ( payment. prev_short_channel_id, payment. prev_funding_outpoint, vec![ ( pending_htlc_info, payment. prev_htlc_id) ] ) ] ;
3141
3142
self . forward_htlcs ( & mut per_source_pending_forward) ;
3142
3143
Ok ( ( ) )
3143
3144
}
@@ -3153,7 +3154,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3153
3154
3154
3155
let mut new_events = Vec :: new ( ) ;
3155
3156
let mut failed_forwards = Vec :: new ( ) ;
3156
- let mut phantom_receives: Vec < ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 , Option < u64 > ) > ) > = Vec :: new ( ) ;
3157
+ let mut phantom_receives: Vec < ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 ) > ) > = Vec :: new ( ) ;
3157
3158
let mut handle_errors = Vec :: new ( ) ;
3158
3159
{
3159
3160
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
@@ -3166,7 +3167,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3166
3167
None => {
3167
3168
for forward_info in pending_forwards. drain ( ..) {
3168
3169
match forward_info {
3169
- HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info, prev_funding_outpoint, prev_htlc_amount } => {
3170
+ HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info, prev_funding_outpoint } => {
3170
3171
macro_rules! fail_forward {
3171
3172
( $msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr) => {
3172
3173
{
@@ -3206,13 +3207,13 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3206
3207
match next_hop {
3207
3208
onion_utils:: Hop :: Receive ( hop_data) => {
3208
3209
match self . construct_recv_pending_htlc_info ( hop_data, forward_info. incoming_shared_secret , forward_info. payment_hash , forward_info. amt_to_forward , forward_info. outgoing_cltv_value , Some ( phantom_shared_secret) ) {
3209
- Ok ( info) => phantom_receives. push ( ( prev_short_channel_id, prev_funding_outpoint, vec ! [ ( info, prev_htlc_id, prev_htlc_amount ) ] ) ) ,
3210
+ Ok ( info) => phantom_receives. push ( ( prev_short_channel_id, prev_funding_outpoint, vec ! [ ( info, prev_htlc_id) ] ) ) ,
3210
3211
Err ( ReceiveError { err_code, err_data, msg } ) => fail_forward ! ( msg, err_code, err_data, Some ( phantom_shared_secret) )
3211
3212
}
3212
3213
} ,
3213
3214
_ => panic ! ( ) ,
3214
3215
}
3215
- } else if prev_htlc_amount . is_some ( ) && fake_scid:: is_valid_intercept ( & self . fake_scid_rand_bytes , short_chan_id) {
3216
+ } else if forward_info . amt_incoming . is_some ( ) && fake_scid:: is_valid_intercept ( & self . fake_scid_rand_bytes , short_chan_id) {
3216
3217
let intercept_id = InterceptId ( Sha256 :: hash ( & forward_info. incoming_shared_secret ) . into_inner ( ) ) ;
3217
3218
let mut pending_intercepts = self . pending_intercepted_payments . lock ( ) . unwrap ( ) ;
3218
3219
match pending_intercepts. entry ( intercept_id) {
@@ -3222,13 +3223,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3222
3223
prev_short_channel_id,
3223
3224
prev_htlc_id,
3224
3225
prev_funding_outpoint,
3225
- prev_htlc_amount : prev_htlc_amount. unwrap ( )
3226
3226
} ;
3227
3227
entry. insert ( pending_intercepted_payment) ;
3228
3228
new_events. push ( events:: Event :: PaymentIntercepted {
3229
3229
short_channel_id : short_chan_id,
3230
3230
payment_hash : forward_info. payment_hash ,
3231
- inbound_amount_msats : prev_htlc_amount . unwrap ( ) ,
3231
+ inbound_amount_msats : forward_info . amt_incoming . unwrap ( ) ,
3232
3232
expected_outbound_amount_msats : forward_info. amt_to_forward ,
3233
3233
intercept_id
3234
3234
} ) ;
@@ -3263,7 +3263,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3263
3263
HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info : PendingHTLCInfo {
3264
3264
routing : PendingHTLCRouting :: Forward {
3265
3265
onion_packet, ..
3266
- } , incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value } ,
3266
+ } , incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value, .. } ,
3267
3267
prev_funding_outpoint, .. } => {
3268
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) ;
3269
3269
let htlc_source = HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
@@ -5016,27 +5016,27 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
5016
5016
}
5017
5017
5018
5018
#[ inline]
5019
- fn forward_htlcs ( & self , per_source_pending_forwards : & mut [ ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 , Option < u64 > ) > ) ] ) {
5019
+ fn forward_htlcs ( & self , per_source_pending_forwards : & mut [ ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 ) > ) ] ) {
5020
5020
for & mut ( prev_short_channel_id, prev_funding_outpoint, ref mut pending_forwards) in per_source_pending_forwards {
5021
5021
let mut forward_event = None ;
5022
5022
if !pending_forwards. is_empty ( ) {
5023
5023
let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
5024
5024
if channel_state. forward_htlcs . is_empty ( ) {
5025
5025
forward_event = Some ( Duration :: from_millis ( MIN_HTLC_RELAY_HOLDING_CELL_MILLIS ) )
5026
5026
}
5027
- for ( forward_info, prev_htlc_id, prev_htlc_amount ) in pending_forwards. drain ( ..) {
5027
+ for ( forward_info, prev_htlc_id) in pending_forwards. drain ( ..) {
5028
5028
match channel_state. forward_htlcs . entry ( match forward_info. routing {
5029
5029
PendingHTLCRouting :: Forward { short_channel_id, .. } => short_channel_id,
5030
5030
PendingHTLCRouting :: Receive { .. } => 0 ,
5031
5031
PendingHTLCRouting :: ReceiveKeysend { .. } => 0 ,
5032
5032
} ) {
5033
5033
hash_map:: Entry :: Occupied ( mut entry) => {
5034
5034
entry. get_mut ( ) . push ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_funding_outpoint,
5035
- prev_htlc_id, prev_htlc_amount , forward_info } ) ;
5035
+ prev_htlc_id, forward_info } ) ;
5036
5036
} ,
5037
5037
hash_map:: Entry :: Vacant ( entry) => {
5038
5038
entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_funding_outpoint,
5039
- prev_htlc_id, prev_htlc_amount , forward_info } ) ) ;
5039
+ prev_htlc_id, forward_info } ) ) ;
5040
5040
}
5041
5041
}
5042
5042
}
@@ -6426,7 +6426,8 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
6426
6426
( 2 , incoming_shared_secret, required) ,
6427
6427
( 4 , payment_hash, required) ,
6428
6428
( 6 , amt_to_forward, required) ,
6429
- ( 8 , outgoing_cltv_value, required)
6429
+ ( 8 , outgoing_cltv_value, required) ,
6430
+ ( 9 , amt_incoming, option) ,
6430
6431
} ) ;
6431
6432
6432
6433
@@ -6654,7 +6655,6 @@ impl_writeable_tlv_based_enum!(HTLCForwardInfo,
6654
6655
( 2 , prev_short_channel_id, required) ,
6655
6656
( 4 , prev_htlc_id, required) ,
6656
6657
( 6 , prev_funding_outpoint, required) ,
6657
- ( 8 , prev_htlc_amount, option)
6658
6658
} ,
6659
6659
( 1 , FailHTLC ) => {
6660
6660
( 0 , htlc_id, required) ,
0 commit comments