@@ -6407,33 +6407,108 @@ impl_writeable_tlv_based!(ChannelCounterparty, {
64076407 ( 11 , outbound_htlc_maximum_msat, option) ,
64086408} ) ;
64096409
6410- impl_writeable_tlv_based ! ( ChannelDetails , {
6411- ( 1 , inbound_scid_alias, option) ,
6412- ( 2 , channel_id, required) ,
6413- ( 3 , channel_type, option) ,
6414- ( 4 , counterparty, required) ,
6415- ( 5 , outbound_scid_alias, option) ,
6416- ( 6 , funding_txo, option) ,
6417- ( 7 , config, option) ,
6418- ( 8 , short_channel_id, option) ,
6419- ( 10 , channel_value_satoshis, required) ,
6420- ( 12 , unspendable_punishment_reserve, option) ,
6421- ( 14 , user_channel_id, required) ,
6422- ( 16 , balance_msat, required) ,
6423- ( 18 , outbound_capacity_msat, required) ,
6424- // Note that by the time we get past the required read above, outbound_capacity_msat will be
6425- // filled in, so we can safely unwrap it here.
6426- ( 19 , next_outbound_htlc_limit_msat, ( default_value, outbound_capacity_msat. 0 . unwrap( ) as u64 ) ) ,
6427- ( 20 , inbound_capacity_msat, required) ,
6428- ( 22 , confirmations_required, option) ,
6429- ( 24 , force_close_spend_delay, option) ,
6430- ( 26 , is_outbound, required) ,
6431- ( 28 , is_channel_ready, required) ,
6432- ( 30 , is_usable, required) ,
6433- ( 32 , is_public, required) ,
6434- ( 33 , inbound_htlc_minimum_msat, option) ,
6435- ( 35 , inbound_htlc_maximum_msat, option) ,
6436- } ) ;
6410+ impl Writeable for ChannelDetails {
6411+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
6412+ // `user_channel_id` used to be a single u64 value. In order to remain backwards compatible with
6413+ // versions prior to 0.0.113, the u128 is serialized as two separate u64 values.
6414+ let user_channel_id_low = self . user_channel_id as u64 ;
6415+ let user_channel_id_high_opt = Some ( ( self . user_channel_id >> 64 ) as u64 ) ;
6416+ write_tlv_fields ! ( writer, {
6417+ ( 1 , self . inbound_scid_alias, option) ,
6418+ ( 2 , self . channel_id, required) ,
6419+ ( 3 , self . channel_type, option) ,
6420+ ( 4 , self . counterparty, required) ,
6421+ ( 5 , self . outbound_scid_alias, option) ,
6422+ ( 6 , self . funding_txo, option) ,
6423+ ( 7 , self . config, option) ,
6424+ ( 8 , self . short_channel_id, option) ,
6425+ ( 10 , self . channel_value_satoshis, required) ,
6426+ ( 12 , self . unspendable_punishment_reserve, option) ,
6427+ ( 14 , user_channel_id_low, required) ,
6428+ ( 16 , self . balance_msat, required) ,
6429+ ( 18 , self . outbound_capacity_msat, required) ,
6430+ // Note that by the time we get past the required read above, outbound_capacity_msat will be
6431+ // filled in, so we can safely unwrap it here.
6432+ ( 19 , self . next_outbound_htlc_limit_msat, ( default_value, outbound_capacity_msat. 0 . unwrap( ) as u64 ) ) ,
6433+ ( 20 , self . inbound_capacity_msat, required) ,
6434+ ( 22 , self . confirmations_required, option) ,
6435+ ( 24 , self . force_close_spend_delay, option) ,
6436+ ( 26 , self . is_outbound, required) ,
6437+ ( 28 , self . is_channel_ready, required) ,
6438+ ( 30 , self . is_usable, required) ,
6439+ ( 32 , self . is_public, required) ,
6440+ ( 33 , self . inbound_htlc_minimum_msat, option) ,
6441+ ( 35 , self . inbound_htlc_maximum_msat, option) ,
6442+ ( 37 , user_channel_id_high_opt, option) ,
6443+ } ) ;
6444+ Ok ( ( ) )
6445+ }
6446+ }
6447+
6448+ impl Readable for ChannelDetails {
6449+ fn read < R : Read > ( reader : & mut R ) -> Result < Self , DecodeError > {
6450+ init_and_read_tlv_fields ! ( reader, {
6451+ ( 1 , inbound_scid_alias, option) ,
6452+ ( 2 , channel_id, required) ,
6453+ ( 3 , channel_type, option) ,
6454+ ( 4 , counterparty, required) ,
6455+ ( 5 , outbound_scid_alias, option) ,
6456+ ( 6 , funding_txo, option) ,
6457+ ( 7 , config, option) ,
6458+ ( 8 , short_channel_id, option) ,
6459+ ( 10 , channel_value_satoshis, required) ,
6460+ ( 12 , unspendable_punishment_reserve, option) ,
6461+ ( 14 , user_channel_id_low, required) ,
6462+ ( 16 , balance_msat, required) ,
6463+ ( 18 , outbound_capacity_msat, required) ,
6464+ // Note that by the time we get past the required read above, outbound_capacity_msat will be
6465+ // filled in, so we can safely unwrap it here.
6466+ ( 19 , next_outbound_htlc_limit_msat, ( default_value, outbound_capacity_msat. 0 . unwrap( ) as u64 ) ) ,
6467+ ( 20 , inbound_capacity_msat, required) ,
6468+ ( 22 , confirmations_required, option) ,
6469+ ( 24 , force_close_spend_delay, option) ,
6470+ ( 26 , is_outbound, required) ,
6471+ ( 28 , is_channel_ready, required) ,
6472+ ( 30 , is_usable, required) ,
6473+ ( 32 , is_public, required) ,
6474+ ( 33 , inbound_htlc_minimum_msat, option) ,
6475+ ( 35 , inbound_htlc_maximum_msat, option) ,
6476+ ( 37 , user_channel_id_high_opt, option) ,
6477+ } ) ;
6478+
6479+ // `user_channel_id` used to be a single u64 value. In order to remain backwards compatible with
6480+ // versions prior to 0.0.113, the u128 is serialized as two separate u64 values.
6481+ let user_channel_id_low: u64 = user_channel_id_low. 0 . unwrap ( ) ;
6482+ let user_channel_id = user_channel_id_low as u128 +
6483+ ( ( user_channel_id_high_opt. unwrap_or ( 0 as u64 ) as u128 ) << 64 ) ;
6484+
6485+ Ok ( Self {
6486+ inbound_scid_alias,
6487+ channel_id : channel_id. 0 . unwrap ( ) ,
6488+ channel_type,
6489+ counterparty : counterparty. 0 . unwrap ( ) ,
6490+ outbound_scid_alias,
6491+ funding_txo,
6492+ config,
6493+ short_channel_id,
6494+ channel_value_satoshis : channel_value_satoshis. 0 . unwrap ( ) ,
6495+ unspendable_punishment_reserve,
6496+ user_channel_id,
6497+ balance_msat : balance_msat. 0 . unwrap ( ) ,
6498+ outbound_capacity_msat : outbound_capacity_msat. 0 . unwrap ( ) ,
6499+ next_outbound_htlc_limit_msat : next_outbound_htlc_limit_msat. 0 . unwrap ( ) ,
6500+ inbound_capacity_msat : inbound_capacity_msat. 0 . unwrap ( ) ,
6501+ confirmations_required,
6502+ force_close_spend_delay,
6503+ is_outbound : is_outbound. 0 . unwrap ( ) ,
6504+ is_channel_ready : is_channel_ready. 0 . unwrap ( ) ,
6505+ is_usable : is_usable. 0 . unwrap ( ) ,
6506+ is_public : is_public. 0 . unwrap ( ) ,
6507+ inbound_htlc_minimum_msat,
6508+ inbound_htlc_maximum_msat,
6509+ } )
6510+ }
6511+ }
64376512
64386513impl_writeable_tlv_based ! ( PhantomRouteHints , {
64396514 ( 2 , channels, vec_type) ,
0 commit comments