@@ -406,10 +406,12 @@ pub(super) enum RAACommitmentOrder {
406
406
// Note this is only exposed in cfg(test):
407
407
pub ( super ) struct ChannelHolder < Signer : Sign > {
408
408
pub ( super ) by_id : HashMap < [ u8 ; 32 ] , Channel < Signer > > ,
409
- /// SCIDs (and outbound SCID aliases) to the real channel id. Outbound SCID aliases are added
410
- /// here once the channel is available for normal use, with SCIDs being added once the funding
411
- /// transaction is confirmed at the channel's required confirmation depth.
412
- pub ( super ) short_to_id : HashMap < u64 , [ u8 ; 32 ] > ,
409
+ /// SCIDs (and outbound SCID aliases) -> `counterparty_node_id`s and `channel_id`s.
410
+ ///
411
+ /// Outbound SCID aliases are added here once the channel is available for normal use, with
412
+ /// SCIDs being added once the funding transaction is confirmed at the channel's required
413
+ /// confirmation depth.
414
+ pub ( super ) short_to_id : HashMap < u64 , ( PublicKey , [ u8 ; 32 ] ) > ,
413
415
/// SCID/SCID Alias -> forward infos. Key of 0 means payments received.
414
416
///
415
417
/// Note that because we may have an SCID Alias as the key we can have two entries per channel,
@@ -1412,12 +1414,12 @@ macro_rules! send_channel_ready {
1412
1414
} ) ;
1413
1415
// Note that we may send a `channel_ready` multiple times for a channel if we reconnect, so
1414
1416
// we allow collisions, but we shouldn't ever be updating the channel ID pointed to.
1415
- let outbound_alias_insert = $short_to_id. insert( $channel. outbound_scid_alias( ) , $channel. channel_id( ) ) ;
1416
- assert!( outbound_alias_insert. is_none( ) || outbound_alias_insert. unwrap( ) == $channel. channel_id( ) ,
1417
+ let outbound_alias_insert = $short_to_id. insert( $channel. outbound_scid_alias( ) , ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ) ;
1418
+ assert!( outbound_alias_insert. is_none( ) || outbound_alias_insert. unwrap( ) == ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ,
1417
1419
"SCIDs should never collide - ensure you weren't behind the chain tip by a full month when creating channels" ) ;
1418
1420
if let Some ( real_scid) = $channel. get_short_channel_id( ) {
1419
- let scid_insert = $short_to_id. insert( real_scid, $channel. channel_id( ) ) ;
1420
- assert!( scid_insert. is_none( ) || scid_insert. unwrap( ) == $channel. channel_id( ) ,
1421
+ let scid_insert = $short_to_id. insert( real_scid, ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ) ;
1422
+ assert!( scid_insert. is_none( ) || scid_insert. unwrap( ) == ( $channel. get_counterparty_node_id ( ) , $channel . channel_id( ) ) ,
1421
1423
"SCIDs should never collide - ensure you weren't behind the chain tip by a full month when creating channels" ) ;
1422
1424
}
1423
1425
}
@@ -2223,7 +2225,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2223
2225
break Some ( ( "Don't have available channel for forwarding as requested." , 0x4000 | 10 , None ) ) ;
2224
2226
}
2225
2227
} ,
2226
- Some ( id ) => Some ( id. clone ( ) ) ,
2228
+ Some ( ( _cp_id , id ) ) => Some ( id. clone ( ) ) ,
2227
2229
} ;
2228
2230
let ( chan_update_opt, forwardee_cltv_expiry_delta) = if let Some ( forwarding_id) = forwarding_id_opt {
2229
2231
let chan = channel_state. as_mut ( ) . unwrap ( ) . by_id . get_mut ( & forwarding_id) . unwrap ( ) ;
@@ -2404,7 +2406,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2404
2406
2405
2407
let id = match channel_lock. short_to_id . get ( & path. first ( ) . unwrap ( ) . short_channel_id ) {
2406
2408
None => return Err ( APIError :: ChannelUnavailable { err : "No channel available with first hop!" . to_owned ( ) } ) ,
2407
- Some ( id ) => id. clone ( ) ,
2409
+ Some ( ( _cp_id , id ) ) => id. clone ( ) ,
2408
2410
} ;
2409
2411
2410
2412
macro_rules! insert_outbound_payment {
@@ -2932,7 +2934,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2932
2934
for ( short_chan_id, mut pending_forwards) in channel_state. forward_htlcs . drain ( ) {
2933
2935
if short_chan_id != 0 {
2934
2936
let forward_chan_id = match channel_state. short_to_id . get ( & short_chan_id) {
2935
- Some ( chan_id) => chan_id. clone ( ) ,
2937
+ Some ( ( _cp_id , chan_id) ) => chan_id. clone ( ) ,
2936
2938
None => {
2937
2939
for forward_info in pending_forwards. drain ( ..) {
2938
2940
match forward_info {
@@ -3349,7 +3351,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3349
3351
self . process_background_events ( ) ;
3350
3352
}
3351
3353
3352
- 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 > ) {
3354
+ 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 > ) {
3353
3355
if !chan. is_outbound ( ) { return ( true , NotifyOption :: SkipPersist , Ok ( ( ) ) ) ; }
3354
3356
// If the feerate has decreased by less than half, don't bother
3355
3357
if new_feerate <= chan. get_feerate ( ) && new_feerate * 2 > chan. get_feerate ( ) {
@@ -3965,7 +3967,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3965
3967
//TODO: Delay the claimed_funds relaying just like we do outbound relay!
3966
3968
let channel_state = & mut * * channel_state_lock;
3967
3969
let chan_id = match channel_state. short_to_id . get ( & prev_hop. short_channel_id ) {
3968
- Some ( chan_id) => chan_id. clone ( ) ,
3970
+ Some ( ( _cp_id , chan_id) ) => chan_id. clone ( ) ,
3969
3971
None => {
3970
3972
return ClaimFundsFromHop :: PrevHopForceClosed
3971
3973
}
@@ -4887,7 +4889,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4887
4889
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
4888
4890
let channel_state = & mut * channel_state_lock;
4889
4891
let chan_id = match channel_state. short_to_id . get ( & msg. contents . short_channel_id ) {
4890
- Some ( chan_id) => chan_id. clone ( ) ,
4892
+ Some ( ( _cp_id , chan_id) ) => chan_id. clone ( ) ,
4891
4893
None => {
4892
4894
// It's not a local channel
4893
4895
return Ok ( NotifyOption :: SkipPersist )
@@ -5669,8 +5671,8 @@ where
5669
5671
// using the real SCID at relay-time (i.e. enforce option_scid_alias
5670
5672
// then), and if the funding tx is ever un-confirmed we force-close the
5671
5673
// channel, ensuring short_to_id is always consistent.
5672
- let scid_insert = short_to_id. insert ( real_scid, channel. channel_id ( ) ) ;
5673
- assert ! ( scid_insert. is_none( ) || scid_insert. unwrap( ) == channel. channel_id( ) ,
5674
+ let scid_insert = short_to_id. insert ( real_scid, ( channel. get_counterparty_node_id ( ) , channel . channel_id ( ) ) ) ;
5675
+ assert ! ( scid_insert. is_none( ) || scid_insert. unwrap( ) == ( channel. get_counterparty_node_id ( ) , channel . channel_id( ) ) ,
5674
5676
"SCIDs should never collide - ensure you weren't behind by a full {} blocks when creating channels" ,
5675
5677
fake_scid:: MAX_SCID_BLOCKS_FROM_NOW ) ;
5676
5678
}
@@ -6713,7 +6715,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
6713
6715
} else {
6714
6716
log_info ! ( args. logger, "Successfully loaded channel {}" , log_bytes!( channel. channel_id( ) ) ) ;
6715
6717
if let Some ( short_channel_id) = channel. get_short_channel_id ( ) {
6716
- short_to_id. insert ( short_channel_id, channel. channel_id ( ) ) ;
6718
+ short_to_id. insert ( short_channel_id, ( channel. get_counterparty_node_id ( ) , channel . channel_id ( ) ) ) ;
6717
6719
}
6718
6720
by_id. insert ( channel. channel_id ( ) , channel) ;
6719
6721
}
@@ -6972,7 +6974,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
6972
6974
return Err ( DecodeError :: InvalidValue ) ;
6973
6975
}
6974
6976
if chan. is_usable ( ) {
6975
- if short_to_id. insert ( chan. outbound_scid_alias ( ) , * chan_id) . is_some ( ) {
6977
+ if short_to_id. insert ( chan. outbound_scid_alias ( ) , ( chan . get_counterparty_node_id ( ) , * chan_id) ) . is_some ( ) {
6976
6978
// Note that in rare cases its possible to hit this while reading an older
6977
6979
// channel if we just happened to pick a colliding outbound alias above.
6978
6980
log_error ! ( args. logger, "Got duplicate outbound SCID alias; {}" , chan. outbound_scid_alias( ) ) ;
0 commit comments