X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannel.rs;h=5d0c3dd4d57b2510239bd6aeda3d78912b3543e5;hb=4d914b5b36eadb7bbbe61d03bcab31e1cbf2c72b;hp=0e304f3074524f56a537681279c558e685a9354d;hpb=49c9f1885dd7a564c0c78ad5f73ea4792c0171a8;p=rust-lightning diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 0e304f30..5d0c3dd4 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -509,7 +509,7 @@ pub(super) struct Channel { inbound_handshake_limits_override: Option, - user_id: u64, + user_id: u128, channel_id: [u8; 32], channel_state: u32, @@ -902,7 +902,7 @@ impl Channel { // Constructors: pub fn new_outbound( fee_estimator: &LowerBoundedFeeEstimator, keys_provider: &K, counterparty_node_id: PublicKey, their_features: &InitFeatures, - channel_value_satoshis: u64, push_msat: u64, user_id: u64, config: &UserConfig, current_chain_height: u32, + channel_value_satoshis: u64, push_msat: u64, user_id: u128, config: &UserConfig, current_chain_height: u32, outbound_scid_alias: u64 ) -> Result, APIError> where K::Target: KeysInterface, @@ -1102,7 +1102,7 @@ impl Channel { /// Assumes chain_hash has already been checked and corresponds with what we expect! pub fn new_from_req( fee_estimator: &LowerBoundedFeeEstimator, keys_provider: &K, counterparty_node_id: PublicKey, their_features: &InitFeatures, - msg: &msgs::OpenChannel, user_id: u64, config: &UserConfig, current_chain_height: u32, logger: &L, + msg: &msgs::OpenChannel, user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L, outbound_scid_alias: u64 ) -> Result, ChannelError> where K::Target: KeysInterface, @@ -4482,7 +4482,7 @@ impl Channel { /// Gets the "user_id" value passed into the construction of this channel. It has no special /// meaning and exists only to allow users to have a persistent identifier of a channel. - pub fn get_user_id(&self) -> u64 { + pub fn get_user_id(&self) -> u128 { self.user_id } @@ -5178,7 +5178,7 @@ impl Channel { /// should be sent back to the counterparty node. /// /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel - pub fn accept_inbound_channel(&mut self, user_id: u64) -> msgs::AcceptChannel { + pub fn accept_inbound_channel(&mut self, user_id: u128) -> msgs::AcceptChannel { if self.is_outbound() { panic!("Tried to send accept_channel for an outbound channel?"); } @@ -6007,7 +6007,11 @@ impl Writeable for Channel { write_ver_prefix!(writer, SERIALIZATION_VERSION, MIN_SERIALIZATION_VERSION); - self.user_id.write(writer)?; + // `user_id` used to be a single u64 value. In order to remain backwards compatible with + // versions prior to 0.0.113, the u128 is serialized as two separate u64 values. We write + // the low bytes now and the optional high bytes later. + let user_id_low = self.user_id as u64; + user_id_low.write(writer)?; // Version 1 deserializers expected to read parts of the config object here. Version 2 // deserializers (0.0.99) now read config through TLVs, and as we now require them for @@ -6254,6 +6258,11 @@ impl Writeable for Channel { let channel_ready_event_emitted = Some(self.channel_ready_event_emitted); + // `user_id` used to be a single u64 value. In order to remain backwards compatible with + // versions prior to 0.0.113, the u128 is serialized as two separate u64 values. Therefore, + // we write the high bytes as an option here. + let user_id_high_opt = Some((self.user_id >> 64) as u64); + write_tlv_fields!(writer, { (0, self.announcement_sigs, option), // minimum_depth and counterparty_selected_channel_reserve_satoshis used to have a @@ -6277,6 +6286,7 @@ impl Writeable for Channel { (19, self.latest_inbound_scid_alias, option), (21, self.outbound_scid_alias, required), (23, channel_ready_event_emitted, option), + (25, user_id_high_opt, option), }); Ok(()) @@ -6290,7 +6300,10 @@ impl<'a, K: Deref> ReadableArgs<(&'a K, u32)> for Channel< ReadableArgs<(&'a K, u32)> for Channel< = None; + read_tlv_fields!(reader, { (0, announcement_sigs, option), (1, minimum_depth, option), @@ -6553,6 +6568,7 @@ impl<'a, K: Deref> ReadableArgs<(&'a K, u32)> for Channel< ReadableArgs<(&'a K, u32)> for Channel<