@@ -54,7 +54,6 @@ use chain::keysinterface::{Sign, KeysInterface, KeysManager, InMemorySigner, Rec
54
54
use util:: config:: { UserConfig , ChannelConfig } ;
55
55
use util:: events:: { EventHandler , EventsProvider , MessageSendEvent , MessageSendEventsProvider , ClosureReason , HTLCDestination } ;
56
56
use util:: { byte_utils, events} ;
57
- use util:: crypto:: sign;
58
57
use util:: wakers:: { Future , Notifier } ;
59
58
use util:: scid_utils:: fake_scid;
60
59
use util:: ser:: { BigSize , FixedLengthReader , Readable , ReadableArgs , MaybeReadable , Writeable , Writer , VecWriter } ;
@@ -764,10 +763,6 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
764
763
/// keeping additional state.
765
764
probing_cookie_secret : [ u8 ; 32 ] ,
766
765
767
- /// Used to track the last value sent in a node_announcement "timestamp" field. We ensure this
768
- /// value increases strictly since we don't assume access to a time source.
769
- last_node_announcement_serial : AtomicUsize ,
770
-
771
766
/// The highest block timestamp we've seen, which is usually a good guess at the current time.
772
767
/// Assuming most miners are generating blocks with reasonable timestamps, this shouldn't be
773
768
/// very far in the past, and can only ever be up to two hours in the future.
@@ -1617,7 +1612,6 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1617
1612
1618
1613
probing_cookie_secret : keys_manager. get_secure_random_bytes ( ) ,
1619
1614
1620
- last_node_announcement_serial : AtomicUsize :: new ( 0 ) ,
1621
1615
highest_seen_timestamp : AtomicUsize :: new ( 0 ) ,
1622
1616
1623
1617
per_peer_state : RwLock :: new ( HashMap :: new ( ) ) ,
@@ -2928,80 +2922,6 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2928
2922
} )
2929
2923
}
2930
2924
2931
- #[ allow( dead_code) ]
2932
- // Messages of up to 64KB should never end up more than half full with addresses, as that would
2933
- // be absurd. We ensure this by checking that at least 100 (our stated public contract on when
2934
- // broadcast_node_announcement panics) of the maximum-length addresses would fit in a 64KB
2935
- // message...
2936
- const HALF_MESSAGE_IS_ADDRS : u32 = :: core:: u16:: MAX as u32 / ( NetAddress :: MAX_LEN as u32 + 1 ) / 2 ;
2937
- #[ deny( const_err) ]
2938
- #[ allow( dead_code) ]
2939
- // ...by failing to compile if the number of addresses that would be half of a message is
2940
- // smaller than 100:
2941
- const STATIC_ASSERT : u32 = Self :: HALF_MESSAGE_IS_ADDRS - 100 ;
2942
-
2943
- /// Regenerates channel_announcements and generates a signed node_announcement from the given
2944
- /// arguments, providing them in corresponding events via
2945
- /// [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
2946
- /// on-chain. This effectively re-broadcasts all channel announcements and sends our node
2947
- /// announcement to ensure that the lightning P2P network is aware of the channels we have and
2948
- /// our network addresses.
2949
- ///
2950
- /// `rgb` is a node "color" and `alias` is a printable human-readable string to describe this
2951
- /// node to humans. They carry no in-protocol meaning.
2952
- ///
2953
- /// `addresses` represent the set (possibly empty) of socket addresses on which this node
2954
- /// accepts incoming connections. These will be included in the node_announcement, publicly
2955
- /// tying these addresses together and to this node. If you wish to preserve user privacy,
2956
- /// addresses should likely contain only Tor Onion addresses.
2957
- ///
2958
- /// Panics if `addresses` is absurdly large (more than 100).
2959
- ///
2960
- /// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
2961
- pub fn broadcast_node_announcement ( & self , rgb : [ u8 ; 3 ] , alias : [ u8 ; 32 ] , mut addresses : Vec < NetAddress > ) {
2962
- let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2963
-
2964
- if addresses. len ( ) > 100 {
2965
- panic ! ( "More than half the message size was taken up by public addresses!" ) ;
2966
- }
2967
-
2968
- // While all existing nodes handle unsorted addresses just fine, the spec requires that
2969
- // addresses be sorted for future compatibility.
2970
- addresses. sort_by_key ( |addr| addr. get_id ( ) ) ;
2971
-
2972
- let announcement = msgs:: UnsignedNodeAnnouncement {
2973
- features : NodeFeatures :: known ( ) ,
2974
- timestamp : self . last_node_announcement_serial . fetch_add ( 1 , Ordering :: AcqRel ) as u32 ,
2975
- node_id : self . get_our_node_id ( ) ,
2976
- rgb, alias, addresses,
2977
- excess_address_data : Vec :: new ( ) ,
2978
- excess_data : Vec :: new ( ) ,
2979
- } ;
2980
- let msghash = hash_to_message ! ( & Sha256dHash :: hash( & announcement. encode( ) [ ..] ) [ ..] ) ;
2981
- let node_announce_sig = sign ( & self . secp_ctx , & msghash, & self . our_network_key ) ;
2982
-
2983
- let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
2984
- let channel_state = & mut * channel_state_lock;
2985
-
2986
- let mut announced_chans = false ;
2987
- for ( _, chan) in channel_state. by_id . iter ( ) {
2988
- if chan. get_signed_channel_announcement ( self . get_our_node_id ( ) , self . genesis_hash . clone ( ) , self . best_block . read ( ) . unwrap ( ) . height ( ) ) . is_some ( )
2989
- && self . get_channel_update_for_broadcast ( chan) . is_ok ( )
2990
- {
2991
- announced_chans = true ;
2992
- }
2993
- }
2994
-
2995
- if announced_chans {
2996
- channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastNodeAnnouncement {
2997
- msg : msgs:: NodeAnnouncement {
2998
- signature : node_announce_sig,
2999
- contents : announcement
3000
- } ,
3001
- } ) ;
3002
- }
3003
- }
3004
-
3005
2925
/// Atomically updates the [`ChannelConfig`] for the given channels.
3006
2926
///
3007
2927
/// Once the updates are applied, each eligible channel (advertised with a known short channel
@@ -5780,7 +5700,6 @@ where
5780
5700
}
5781
5701
}
5782
5702
}
5783
- max_time ! ( self . last_node_announcement_serial) ;
5784
5703
max_time ! ( self . highest_seen_timestamp) ;
5785
5704
let mut payment_secrets = self . pending_inbound_payments . lock ( ) . unwrap ( ) ;
5786
5705
payment_secrets. retain ( |_, inbound_payment| {
@@ -6132,7 +6051,6 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
6132
6051
& events:: MessageSendEvent :: SendChannelReestablish { ref node_id, .. } => node_id != counterparty_node_id,
6133
6052
& events:: MessageSendEvent :: SendChannelAnnouncement { ref node_id, .. } => node_id != counterparty_node_id,
6134
6053
& events:: MessageSendEvent :: BroadcastChannelAnnouncement { .. } => true ,
6135
- & events:: MessageSendEvent :: BroadcastNodeAnnouncement { .. } => true ,
6136
6054
& events:: MessageSendEvent :: BroadcastChannelUpdate { .. } => true ,
6137
6055
& events:: MessageSendEvent :: SendChannelUpdate { ref node_id, .. } => node_id != counterparty_node_id,
6138
6056
& events:: MessageSendEvent :: HandleError { ref node_id, .. } => node_id != counterparty_node_id,
@@ -6237,6 +6155,10 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
6237
6155
let _ = self . force_close_channel_with_peer ( & msg. channel_id , counterparty_node_id, Some ( & msg. data ) , true ) ;
6238
6156
}
6239
6157
}
6158
+
6159
+ fn provided_node_features ( & self ) -> NodeFeatures {
6160
+ NodeFeatures :: known ( )
6161
+ }
6240
6162
}
6241
6163
6242
6164
const SERIALIZATION_VERSION : u8 = 1 ;
@@ -6659,7 +6581,10 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> Writeable f
6659
6581
}
6660
6582
}
6661
6583
6662
- ( self . last_node_announcement_serial . load ( Ordering :: Acquire ) as u32 ) . write ( writer) ?;
6584
+ // Prior to 0.0.111 we tracked node_announcement serials here, however that now happens in
6585
+ // `PeerManager`, and thus we simply write the `highest_seen_timestamp` twice, which is
6586
+ // likely to be identical.
6587
+ ( self . highest_seen_timestamp . load ( Ordering :: Acquire ) as u32 ) . write ( writer) ?;
6663
6588
( self . highest_seen_timestamp . load ( Ordering :: Acquire ) as u32 ) . write ( writer) ?;
6664
6589
6665
6590
( pending_inbound_payments. len ( ) as u64 ) . write ( writer) ?;
@@ -6978,7 +6903,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
6978
6903
}
6979
6904
}
6980
6905
6981
- let last_node_announcement_serial : u32 = Readable :: read ( reader) ?;
6906
+ let _last_node_announcement_serial : u32 = Readable :: read ( reader) ?; // Only used < 0.0.111
6982
6907
let highest_seen_timestamp: u32 = Readable :: read ( reader) ?;
6983
6908
6984
6909
let pending_inbound_payment_count: u64 = Readable :: read ( reader) ?;
@@ -7239,7 +7164,6 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
7239
7164
our_network_pubkey,
7240
7165
secp_ctx,
7241
7166
7242
- last_node_announcement_serial : AtomicUsize :: new ( last_node_announcement_serial as usize ) ,
7243
7167
highest_seen_timestamp : AtomicUsize :: new ( highest_seen_timestamp as usize ) ,
7244
7168
7245
7169
per_peer_state : RwLock :: new ( per_peer_state) ,
0 commit comments