@@ -408,7 +408,7 @@ pub(super) struct ChannelHolder<Signer: Sign> {
408
408
/// SCIDs (and outbound SCID aliases) to the real channel id. Outbound SCID aliases are added
409
409
/// here once the channel is available for normal use, with SCIDs being added once the funding
410
410
/// transaction is confirmed at the channel's required confirmation depth.
411
- pub ( super ) short_to_id : HashMap < u64 , [ u8 ; 32 ] > ,
411
+ pub ( super ) short_to_id : HashMap < u64 , ( PublicKey , [ u8 ; 32 ] ) > ,
412
412
/// SCID/SCID Alias -> forward infos. Key of 0 means payments received.
413
413
///
414
414
/// Note that because we may have an SCID Alias as the key we can have two entries per channel,
@@ -1411,12 +1411,12 @@ macro_rules! send_channel_ready {
1411
1411
} ) ;
1412
1412
// Note that we may send a `channel_ready` multiple times for a channel if we reconnect, so
1413
1413
// we allow collisions, but we shouldn't ever be updating the channel ID pointed to.
1414
- let outbound_alias_insert = $short_to_id. insert( $channel. outbound_scid_alias( ) , $channel. channel_id( ) ) ;
1415
- assert!( outbound_alias_insert. is_none( ) || outbound_alias_insert. unwrap( ) == $channel. channel_id( ) ,
1414
+ let outbound_alias_insert = $short_to_id. insert( $channel. outbound_scid_alias( ) , ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ) ;
1415
+ assert!( outbound_alias_insert. is_none( ) || outbound_alias_insert. unwrap( ) == ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ,
1416
1416
"SCIDs should never collide - ensure you weren't behind the chain tip by a full month when creating channels" ) ;
1417
1417
if let Some ( real_scid) = $channel. get_short_channel_id( ) {
1418
- let scid_insert = $short_to_id. insert( real_scid, $channel. channel_id( ) ) ;
1419
- assert!( scid_insert. is_none( ) || scid_insert. unwrap( ) == $channel. channel_id( ) ,
1418
+ let scid_insert = $short_to_id. insert( real_scid, ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ) ;
1419
+ assert!( scid_insert. is_none( ) || scid_insert. unwrap( ) == ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ,
1420
1420
"SCIDs should never collide - ensure you weren't behind the chain tip by a full month when creating channels" ) ;
1421
1421
}
1422
1422
}
@@ -2220,7 +2220,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2220
2220
break Some ( ( "Don't have available channel for forwarding as requested." , 0x4000 | 10 , None ) ) ;
2221
2221
}
2222
2222
} ,
2223
- Some ( id ) => Some ( id. clone ( ) ) ,
2223
+ Some ( ( _cp_id , id ) ) => Some ( id. clone ( ) ) ,
2224
2224
} ;
2225
2225
let ( chan_update_opt, forwardee_cltv_expiry_delta) = if let Some ( forwarding_id) = forwarding_id_opt {
2226
2226
let chan = channel_state. as_mut ( ) . unwrap ( ) . by_id . get_mut ( & forwarding_id) . unwrap ( ) ;
@@ -2401,7 +2401,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2401
2401
2402
2402
let id = match channel_lock. short_to_id . get ( & path. first ( ) . unwrap ( ) . short_channel_id ) {
2403
2403
None => return Err ( APIError :: ChannelUnavailable { err : "No channel available with first hop!" . to_owned ( ) } ) ,
2404
- Some ( id ) => id. clone ( ) ,
2404
+ Some ( ( _cp_id , id ) ) => id. clone ( ) ,
2405
2405
} ;
2406
2406
2407
2407
macro_rules! insert_outbound_payment {
@@ -2935,7 +2935,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2935
2935
for ( short_chan_id, mut pending_forwards) in channel_state. forward_htlcs . drain ( ) {
2936
2936
if short_chan_id != 0 {
2937
2937
let forward_chan_id = match channel_state. short_to_id . get ( & short_chan_id) {
2938
- Some ( chan_id) => chan_id. clone ( ) ,
2938
+ Some ( ( _cp_id , chan_id) ) => chan_id. clone ( ) ,
2939
2939
None => {
2940
2940
for forward_info in pending_forwards. drain ( ..) {
2941
2941
match forward_info {
@@ -3352,7 +3352,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3352
3352
self . process_background_events ( ) ;
3353
3353
}
3354
3354
3355
- fn update_channel_fee ( & self , short_to_id : & mut HashMap < u64 , [ u8 ; 32 ] > , pending_msg_events : & mut Vec < events:: MessageSendEvent > , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < Signer > , new_feerate : u32 ) -> ( bool , NotifyOption , Result < ( ) , MsgHandleErrInternal > ) {
3355
+ fn update_channel_fee ( & self , short_to_id : & mut HashMap < u64 , ( PublicKey , [ u8 ; 32 ] ) > , pending_msg_events : & mut Vec < events:: MessageSendEvent > , chan_id : & [ u8 ; 32 ] , chan : & mut Channel < Signer > , new_feerate : u32 ) -> ( bool , NotifyOption , Result < ( ) , MsgHandleErrInternal > ) {
3356
3356
if !chan. is_outbound ( ) { return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ; }
3357
3357
// If the feerate has decreased by less than half, don't bother
3358
3358
if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
@@ -3965,7 +3965,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3965
3965
//TODO: Delay the claimed_funds relaying just like we do outbound relay!
3966
3966
let channel_state = & mut * * channel_state_lock;
3967
3967
let chan_id = match channel_state. short_to_id . get ( & prev_hop. short_channel_id ) {
3968
- Some ( chan_id) => chan_id. clone ( ) ,
3968
+ Some ( ( _cp_id , chan_id) ) => chan_id. clone ( ) ,
3969
3969
None => {
3970
3970
return ClaimFundsFromHop :: PrevHopForceClosed
3971
3971
}
@@ -4867,7 +4867,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4867
4867
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
4868
4868
let channel_state = & mut * channel_state_lock;
4869
4869
let chan_id = match channel_state. short_to_id . get ( & msg. contents . short_channel_id ) {
4870
- Some ( chan_id) => chan_id. clone ( ) ,
4870
+ Some ( ( _cp_id , chan_id) ) => chan_id. clone ( ) ,
4871
4871
None => {
4872
4872
// It's not a local channel
4873
4873
return Ok ( NotifyOption :: SkipPersist )
@@ -6689,7 +6689,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
6689
6689
} else {
6690
6690
log_info ! ( args. logger, "Successfully loaded channel {}" , log_bytes!( channel. channel_id( ) ) ) ;
6691
6691
if let Some ( short_channel_id) = channel. get_short_channel_id ( ) {
6692
- short_to_id. insert ( short_channel_id, channel. channel_id ( ) ) ;
6692
+ short_to_id. insert ( short_channel_id, ( channel. get_counterparty_node_id ( ) , channel . channel_id ( ) ) ) ;
6693
6693
}
6694
6694
by_id. insert ( channel. channel_id ( ) , channel) ;
6695
6695
}
@@ -6948,7 +6948,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
6948
6948
return Err ( DecodeError :: InvalidValue ) ;
6949
6949
}
6950
6950
if chan. is_usable ( ) {
6951
- if short_to_id. insert ( chan. outbound_scid_alias ( ) , * chan_id) . is_some ( ) {
6951
+ if short_to_id. insert ( chan. outbound_scid_alias ( ) , ( chan . get_counterparty_node_id ( ) , * chan_id) ) . is_some ( ) {
6952
6952
// Note that in rare cases its possible to hit this while reading an older
6953
6953
// channel if we just happened to pick a colliding outbound alias above.
6954
6954
log_error ! ( args. logger, "Got duplicate outbound SCID alias; {}" , chan. outbound_scid_alias( ) ) ;
0 commit comments