@@ -509,7 +509,7 @@ pub(super) struct Channel<Signer: Sign> {
509509
510510 inbound_handshake_limits_override : Option < ChannelHandshakeLimits > ,
511511
512- user_id : u64 ,
512+ user_id : u128 ,
513513
514514 channel_id : [ u8 ; 32 ] ,
515515 channel_state : u32 ,
@@ -902,7 +902,7 @@ impl<Signer: Sign> Channel<Signer> {
902902 // Constructors:
903903 pub fn new_outbound < K : Deref , F : Deref > (
904904 fee_estimator : & LowerBoundedFeeEstimator < F > , keys_provider : & K , counterparty_node_id : PublicKey , their_features : & InitFeatures ,
905- channel_value_satoshis : u64 , push_msat : u64 , user_id : u64 , config : & UserConfig , current_chain_height : u32 ,
905+ channel_value_satoshis : u64 , push_msat : u64 , user_id : u128 , config : & UserConfig , current_chain_height : u32 ,
906906 outbound_scid_alias : u64
907907 ) -> Result < Channel < Signer > , APIError >
908908 where K :: Target : KeysInterface < Signer = Signer > ,
@@ -1102,7 +1102,7 @@ impl<Signer: Sign> Channel<Signer> {
11021102 /// Assumes chain_hash has already been checked and corresponds with what we expect!
11031103 pub fn new_from_req < K : Deref , F : Deref , L : Deref > (
11041104 fee_estimator : & LowerBoundedFeeEstimator < F > , keys_provider : & K , counterparty_node_id : PublicKey , their_features : & InitFeatures ,
1105- msg : & msgs:: OpenChannel , user_id : u64 , config : & UserConfig , current_chain_height : u32 , logger : & L ,
1105+ msg : & msgs:: OpenChannel , user_id : u128 , config : & UserConfig , current_chain_height : u32 , logger : & L ,
11061106 outbound_scid_alias : u64
11071107 ) -> Result < Channel < Signer > , ChannelError >
11081108 where K :: Target : KeysInterface < Signer = Signer > ,
@@ -4482,7 +4482,7 @@ impl<Signer: Sign> Channel<Signer> {
44824482
44834483 /// Gets the "user_id" value passed into the construction of this channel. It has no special
44844484 /// meaning and exists only to allow users to have a persistent identifier of a channel.
4485- pub fn get_user_id ( & self ) -> u64 {
4485+ pub fn get_user_id ( & self ) -> u128 {
44864486 self . user_id
44874487 }
44884488
@@ -5173,7 +5173,7 @@ impl<Signer: Sign> Channel<Signer> {
51735173 /// should be sent back to the counterparty node.
51745174 ///
51755175 /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
5176- pub fn accept_inbound_channel ( & mut self , user_id : u64 ) -> msgs:: AcceptChannel {
5176+ pub fn accept_inbound_channel ( & mut self , user_id : u128 ) -> msgs:: AcceptChannel {
51775177 if self . is_outbound ( ) {
51785178 panic ! ( "Tried to send accept_channel for an outbound channel?" ) ;
51795179 }
@@ -6002,7 +6002,11 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
60026002
60036003 write_ver_prefix ! ( writer, SERIALIZATION_VERSION , MIN_SERIALIZATION_VERSION ) ;
60046004
6005- self . user_id . write ( writer) ?;
6005+ // `user_id` used to be a single u64 value. In order to remain backwards compatible with
6006+ // versions prior to 0.0.113, the u128 is serialized as two separate u64 values. We write
6007+ // the low bytes now and the optional high bytes later.
6008+ let user_id_low = self . user_id as u64 ;
6009+ user_id_low. write ( writer) ?;
60066010
60076011 // Version 1 deserializers expected to read parts of the config object here. Version 2
60086012 // deserializers (0.0.99) now read config through TLVs, and as we now require them for
@@ -6249,6 +6253,11 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
62496253
62506254 let channel_ready_event_emitted = Some ( self . channel_ready_event_emitted ) ;
62516255
6256+ // `user_id` used to be a single u64 value. In order to remain backwards compatible with
6257+ // versions prior to 0.0.113, the u128 is serialized as two separate u64 values. Therefore,
6258+ // we write the high bytes as an option here.
6259+ let user_id_high_opt = Some ( ( self . user_id >> 64 ) as u64 ) ;
6260+
62526261 write_tlv_fields ! ( writer, {
62536262 ( 0 , self . announcement_sigs, option) ,
62546263 // minimum_depth and counterparty_selected_channel_reserve_satoshis used to have a
@@ -6272,6 +6281,7 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
62726281 ( 19 , self . latest_inbound_scid_alias, option) ,
62736282 ( 21 , self . outbound_scid_alias, required) ,
62746283 ( 23 , channel_ready_event_emitted, option) ,
6284+ ( 25 , user_id_high_opt, option) ,
62756285 } ) ;
62766286
62776287 Ok ( ( ) )
@@ -6285,7 +6295,10 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
62856295 let ( keys_source, serialized_height) = args;
62866296 let ver = read_ver_prefix ! ( reader, SERIALIZATION_VERSION ) ;
62876297
6288- let user_id = Readable :: read ( reader) ?;
6298+ // `user_id` used to be a single u64 value. In order to remain backwards compatible with
6299+ // versions prior to 0.0.113, the u128 is serialized as two separate u64 values. We read
6300+ // the low bytes now and the high bytes later.
6301+ let user_id_low: u64 = Readable :: read ( reader) ?;
62896302
62906303 let mut config = Some ( LegacyChannelConfig :: default ( ) ) ;
62916304 if ver == 1 {
@@ -6531,6 +6544,8 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
65316544 let mut outbound_scid_alias = None ;
65326545 let mut channel_ready_event_emitted = None ;
65336546
6547+ let mut user_id_high_opt: Option < u64 > = None ;
6548+
65346549 read_tlv_fields ! ( reader, {
65356550 ( 0 , announcement_sigs, option) ,
65366551 ( 1 , minimum_depth, option) ,
@@ -6548,6 +6563,7 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
65486563 ( 19 , latest_inbound_scid_alias, option) ,
65496564 ( 21 , outbound_scid_alias, option) ,
65506565 ( 23 , channel_ready_event_emitted, option) ,
6566+ ( 25 , user_id_high_opt, option) ,
65516567 } ) ;
65526568
65536569 if let Some ( preimages) = preimages_opt {
@@ -6584,6 +6600,15 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
65846600 let mut secp_ctx = Secp256k1 :: new ( ) ;
65856601 secp_ctx. seeded_randomize ( & keys_source. get_secure_random_bytes ( ) ) ;
65866602
6603+ // `user_id` used to be a single u64 value. In order to remain backwards
6604+ // compatible with versions prior to 0.0.113, the u128 is serialized as two
6605+ // separate u64 values.
6606+ let user_id = if let Some ( user_id_high) = user_id_high_opt {
6607+ user_id_low as u128 + ( ( user_id_high as u128 ) << 64 )
6608+ } else {
6609+ user_id_low as u128
6610+ } ;
6611+
65876612 Ok ( Channel {
65886613 user_id,
65896614
0 commit comments