@@ -509,7 +509,7 @@ pub(super) struct Channel<Signer: Sign> {
509
509
510
510
inbound_handshake_limits_override : Option < ChannelHandshakeLimits > ,
511
511
512
- user_id : u64 ,
512
+ user_id : u128 ,
513
513
514
514
channel_id : [ u8 ; 32 ] ,
515
515
channel_state : u32 ,
@@ -902,7 +902,7 @@ impl<Signer: Sign> Channel<Signer> {
902
902
// Constructors:
903
903
pub fn new_outbound < K : Deref , F : Deref > (
904
904
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 ,
906
906
outbound_scid_alias : u64
907
907
) -> Result < Channel < Signer > , APIError >
908
908
where K :: Target : KeysInterface < Signer = Signer > ,
@@ -1102,7 +1102,7 @@ impl<Signer: Sign> Channel<Signer> {
1102
1102
/// Assumes chain_hash has already been checked and corresponds with what we expect!
1103
1103
pub fn new_from_req < K : Deref , F : Deref , L : Deref > (
1104
1104
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 ,
1106
1106
outbound_scid_alias : u64
1107
1107
) -> Result < Channel < Signer > , ChannelError >
1108
1108
where K :: Target : KeysInterface < Signer = Signer > ,
@@ -4482,7 +4482,7 @@ impl<Signer: Sign> Channel<Signer> {
4482
4482
4483
4483
/// Gets the "user_id" value passed into the construction of this channel. It has no special
4484
4484
/// 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 {
4486
4486
self . user_id
4487
4487
}
4488
4488
@@ -5173,7 +5173,7 @@ impl<Signer: Sign> Channel<Signer> {
5173
5173
/// should be sent back to the counterparty node.
5174
5174
///
5175
5175
/// [`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 {
5177
5177
if self . is_outbound ( ) {
5178
5178
panic ! ( "Tried to send accept_channel for an outbound channel?" ) ;
5179
5179
}
@@ -6002,7 +6002,11 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
6002
6002
6003
6003
write_ver_prefix ! ( writer, SERIALIZATION_VERSION , MIN_SERIALIZATION_VERSION ) ;
6004
6004
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) ?;
6006
6010
6007
6011
// Version 1 deserializers expected to read parts of the config object here. Version 2
6008
6012
// 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> {
6249
6253
6250
6254
let channel_ready_event_emitted = Some ( self . channel_ready_event_emitted ) ;
6251
6255
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
+
6252
6261
write_tlv_fields ! ( writer, {
6253
6262
( 0 , self . announcement_sigs, option) ,
6254
6263
// minimum_depth and counterparty_selected_channel_reserve_satoshis used to have a
@@ -6272,6 +6281,7 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
6272
6281
( 19 , self . latest_inbound_scid_alias, option) ,
6273
6282
( 21 , self . outbound_scid_alias, required) ,
6274
6283
( 23 , channel_ready_event_emitted, option) ,
6284
+ ( 25 , user_id_high_opt, option) ,
6275
6285
} ) ;
6276
6286
6277
6287
Ok ( ( ) )
@@ -6285,7 +6295,10 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
6285
6295
let ( keys_source, serialized_height) = args;
6286
6296
let ver = read_ver_prefix ! ( reader, SERIALIZATION_VERSION ) ;
6287
6297
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) ?;
6289
6302
6290
6303
let mut config = Some ( LegacyChannelConfig :: default ( ) ) ;
6291
6304
if ver == 1 {
@@ -6531,6 +6544,8 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
6531
6544
let mut outbound_scid_alias = None ;
6532
6545
let mut channel_ready_event_emitted = None ;
6533
6546
6547
+ let mut user_id_high_opt: Option < u64 > = None ;
6548
+
6534
6549
read_tlv_fields ! ( reader, {
6535
6550
( 0 , announcement_sigs, option) ,
6536
6551
( 1 , minimum_depth, option) ,
@@ -6548,6 +6563,7 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
6548
6563
( 19 , latest_inbound_scid_alias, option) ,
6549
6564
( 21 , outbound_scid_alias, option) ,
6550
6565
( 23 , channel_ready_event_emitted, option) ,
6566
+ ( 25 , user_id_high_opt, option) ,
6551
6567
} ) ;
6552
6568
6553
6569
if let Some ( preimages) = preimages_opt {
@@ -6584,6 +6600,15 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
6584
6600
let mut secp_ctx = Secp256k1 :: new ( ) ;
6585
6601
secp_ctx. seeded_randomize ( & keys_source. get_secure_random_bytes ( ) ) ;
6586
6602
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
+
6587
6612
Ok ( Channel {
6588
6613
user_id,
6589
6614
0 commit comments