@@ -142,6 +142,7 @@ pub(super) struct PendingAddHTLCInfo {
142
142
prev_short_channel_id : u64 ,
143
143
prev_htlc_id : u64 ,
144
144
prev_funding_outpoint : OutPoint ,
145
+ prev_user_channel_id : u128 ,
145
146
}
146
147
147
148
pub ( super ) enum HTLCForwardInfo {
@@ -3025,7 +3026,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3025
3026
3026
3027
let mut new_events = Vec :: new ( ) ;
3027
3028
let mut failed_forwards = Vec :: new ( ) ;
3028
- let mut phantom_receives: Vec < ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 ) > ) > = Vec :: new ( ) ;
3029
+ let mut phantom_receives: Vec < ( u64 , OutPoint , u128 , Vec < ( PendingHTLCInfo , u64 ) > ) > = Vec :: new ( ) ;
3029
3030
let mut handle_errors = Vec :: new ( ) ;
3030
3031
{
3031
3032
let mut forward_htlcs = HashMap :: new ( ) ;
@@ -3038,7 +3039,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3038
3039
for forward_info in pending_forwards. drain( ..) {
3039
3040
match forward_info {
3040
3041
HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3041
- prev_short_channel_id, prev_htlc_id, prev_funding_outpoint,
3042
+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id ,
3042
3043
forward_info: PendingHTLCInfo {
3043
3044
routing, incoming_shared_secret, payment_hash, outgoing_amt_msat,
3044
3045
outgoing_cltv_value, incoming_amt_msat: _
@@ -3104,7 +3105,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3104
3105
match next_hop {
3105
3106
onion_utils:: Hop :: Receive ( hop_data) => {
3106
3107
match self . construct_recv_pending_htlc_info( hop_data, incoming_shared_secret, payment_hash, outgoing_amt_msat, outgoing_cltv_value, Some ( phantom_shared_secret) ) {
3107
- Ok ( info) => phantom_receives. push( ( prev_short_channel_id, prev_funding_outpoint, vec![ ( info, prev_htlc_id) ] ) ) ,
3108
+ Ok ( info) => phantom_receives. push( ( prev_short_channel_id, prev_funding_outpoint, prev_user_channel_id , vec![ ( info, prev_htlc_id) ] ) ) ,
3108
3109
Err ( ReceiveError { err_code, err_data, msg } ) => failed_payment!( msg, err_code, err_data, Some ( phantom_shared_secret) )
3109
3110
}
3110
3111
} ,
@@ -3147,7 +3148,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3147
3148
for forward_info in pending_forwards. drain ( ..) {
3148
3149
match forward_info {
3149
3150
HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3150
- prev_short_channel_id, prev_htlc_id, prev_funding_outpoint ,
3151
+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id : _ ,
3151
3152
forward_info : PendingHTLCInfo {
3152
3153
incoming_shared_secret, payment_hash, outgoing_amt_msat, outgoing_cltv_value,
3153
3154
routing : PendingHTLCRouting :: Forward { onion_packet, .. } , incoming_amt_msat : _,
@@ -3274,7 +3275,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3274
3275
for forward_info in pending_forwards. drain ( ..) {
3275
3276
match forward_info {
3276
3277
HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
3277
- prev_short_channel_id, prev_htlc_id, prev_funding_outpoint,
3278
+ prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id ,
3278
3279
forward_info : PendingHTLCInfo {
3279
3280
routing, incoming_shared_secret, payment_hash, outgoing_amt_msat, ..
3280
3281
}
@@ -3369,12 +3370,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3369
3370
log_bytes!( payment_hash. 0 ) , total_value, $payment_data. total_msat) ;
3370
3371
fail_htlc!( claimable_htlc, payment_hash) ;
3371
3372
} else if total_value == $payment_data. total_msat {
3373
+ let prev_channel_id = prev_funding_outpoint. to_channel_id( ) ;
3372
3374
htlcs. push( claimable_htlc) ;
3373
3375
new_events. push( events:: Event :: PaymentReceived {
3374
3376
receiver_node_id: Some ( receiver_node_id) ,
3375
3377
payment_hash,
3376
3378
purpose: purpose( ) ,
3377
3379
amount_msat: total_value,
3380
+ via_channel_id: Some ( prev_channel_id) ,
3381
+ via_user_channel_id: Some ( prev_user_channel_id) ,
3378
3382
} ) ;
3379
3383
payment_received_generated = true ;
3380
3384
} else {
@@ -3413,11 +3417,14 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3413
3417
hash_map:: Entry :: Vacant ( e) => {
3414
3418
let purpose = events:: PaymentPurpose :: SpontaneousPayment ( preimage) ;
3415
3419
e. insert ( ( purpose. clone ( ) , vec ! [ claimable_htlc] ) ) ;
3420
+ let prev_channel_id = prev_funding_outpoint. to_channel_id ( ) ;
3416
3421
new_events. push ( events:: Event :: PaymentReceived {
3417
3422
receiver_node_id : Some ( receiver_node_id) ,
3418
3423
payment_hash,
3419
3424
amount_msat : outgoing_amt_msat,
3420
3425
purpose,
3426
+ via_channel_id : Some ( prev_channel_id) ,
3427
+ via_user_channel_id : Some ( prev_user_channel_id) ,
3421
3428
} ) ;
3422
3429
} ,
3423
3430
hash_map:: Entry :: Occupied ( _) => {
@@ -4389,13 +4396,13 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4389
4396
commitment_update : Option < msgs:: CommitmentUpdate > , order : RAACommitmentOrder ,
4390
4397
pending_forwards : Vec < ( PendingHTLCInfo , u64 ) > , funding_broadcastable : Option < Transaction > ,
4391
4398
channel_ready : Option < msgs:: ChannelReady > , announcement_sigs : Option < msgs:: AnnouncementSignatures > )
4392
- -> Option < ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 ) > ) > {
4399
+ -> Option < ( u64 , OutPoint , u128 , Vec < ( PendingHTLCInfo , u64 ) > ) > {
4393
4400
let mut htlc_forwards = None ;
4394
4401
4395
4402
let counterparty_node_id = channel. get_counterparty_node_id ( ) ;
4396
4403
if !pending_forwards. is_empty ( ) {
4397
4404
htlc_forwards = Some ( ( channel. get_short_channel_id ( ) . unwrap_or ( channel. outbound_scid_alias ( ) ) ,
4398
- channel. get_funding_txo ( ) . unwrap ( ) , pending_forwards) ) ;
4405
+ channel. get_funding_txo ( ) . unwrap ( ) , channel . get_user_id ( ) , pending_forwards) ) ;
4399
4406
}
4400
4407
4401
4408
if let Some ( msg) = channel_ready {
@@ -5056,8 +5063,8 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5056
5063
}
5057
5064
5058
5065
#[ inline]
5059
- fn forward_htlcs ( & self , per_source_pending_forwards : & mut [ ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 ) > ) ] ) {
5060
- for & mut ( prev_short_channel_id, prev_funding_outpoint, ref mut pending_forwards) in per_source_pending_forwards {
5066
+ fn forward_htlcs ( & self , per_source_pending_forwards : & mut [ ( u64 , OutPoint , u128 , Vec < ( PendingHTLCInfo , u64 ) > ) ] ) {
5067
+ for & mut ( prev_short_channel_id, prev_funding_outpoint, prev_user_channel_id , ref mut pending_forwards) in per_source_pending_forwards {
5061
5068
let mut forward_event = None ;
5062
5069
if !pending_forwards. is_empty ( ) {
5063
5070
let mut forward_htlcs = self . forward_htlcs . lock ( ) . unwrap ( ) ;
@@ -5072,11 +5079,11 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5072
5079
} ) {
5073
5080
hash_map:: Entry :: Occupied ( mut entry) => {
5074
5081
entry. get_mut ( ) . push ( HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
5075
- prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, forward_info } ) ) ;
5082
+ prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_user_channel_id , forward_info } ) ) ;
5076
5083
} ,
5077
5084
hash_map:: Entry :: Vacant ( entry) => {
5078
5085
entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC ( PendingAddHTLCInfo {
5079
- prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, forward_info } ) ) ) ;
5086
+ prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_user_channel_id , forward_info } ) ) ) ;
5080
5087
}
5081
5088
}
5082
5089
}
@@ -5135,21 +5142,22 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5135
5142
raa_updates. finalized_claimed_htlcs ,
5136
5143
chan. get ( ) . get_short_channel_id ( )
5137
5144
. unwrap_or ( chan. get ( ) . outbound_scid_alias ( ) ) ,
5138
- chan. get ( ) . get_funding_txo ( ) . unwrap ( ) ) )
5145
+ chan. get ( ) . get_funding_txo ( ) . unwrap ( ) ,
5146
+ chan. get ( ) . get_user_id ( ) ) )
5139
5147
} ,
5140
5148
hash_map:: Entry :: Vacant ( _) => break Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
5141
5149
}
5142
5150
} ;
5143
5151
self . fail_holding_cell_htlcs ( htlcs_to_fail, msg. channel_id , counterparty_node_id) ;
5144
5152
match res {
5145
5153
Ok ( ( pending_forwards, mut pending_failures, finalized_claim_htlcs,
5146
- short_channel_id, channel_outpoint) ) =>
5154
+ short_channel_id, channel_outpoint, user_channel_id ) ) =>
5147
5155
{
5148
5156
for failure in pending_failures. drain ( ..) {
5149
5157
let receiver = HTLCDestination :: NextHopChannel { node_id : Some ( * counterparty_node_id) , channel_id : channel_outpoint. to_channel_id ( ) } ;
5150
5158
self . fail_htlc_backwards_internal ( failure. 0 , & failure. 1 , failure. 2 , receiver) ;
5151
5159
}
5152
- self . forward_htlcs ( & mut [ ( short_channel_id, channel_outpoint, pending_forwards) ] ) ;
5160
+ self . forward_htlcs ( & mut [ ( short_channel_id, channel_outpoint, user_channel_id , pending_forwards) ] ) ;
5153
5161
self . finalize_claims ( finalized_claim_htlcs) ;
5154
5162
Ok ( ( ) )
5155
5163
} ,
@@ -6127,7 +6135,7 @@ where
6127
6135
}
6128
6136
}
6129
6137
6130
- impl < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref >
6138
+ impl < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref >
6131
6139
ChannelMessageHandler for ChannelManager < M , T , K , F , L >
6132
6140
where M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
6133
6141
T :: Target : BroadcasterInterface ,
@@ -6799,6 +6807,7 @@ impl_writeable_tlv_based_enum!(HTLCFailReason,
6799
6807
6800
6808
impl_writeable_tlv_based ! ( PendingAddHTLCInfo , {
6801
6809
( 0 , forward_info, required) ,
6810
+ ( 1 , prev_user_channel_id, ( default_value, 0 ) ) ,
6802
6811
( 2 , prev_short_channel_id, required) ,
6803
6812
( 4 , prev_htlc_id, required) ,
6804
6813
( 6 , prev_funding_outpoint, required) ,
0 commit comments