@@ -39,7 +39,7 @@ use util::events::ClosureReason;
3939use util:: ser:: { Readable , ReadableArgs , Writeable , Writer , VecWriter } ;
4040use util:: logger:: Logger ;
4141use util:: errors:: APIError ;
42- use util:: config:: { UserConfig , ChannelConfig , ChannelHandshakeConfig , ChannelHandshakeLimits } ;
42+ use util:: config:: { UserConfig , LegacyChannelConfig , ChannelHandshakeConfig , ChannelHandshakeLimits } ;
4343use util:: scid_utils:: scid_from_parts;
4444
4545use io;
@@ -491,9 +491,9 @@ pub(crate) const MIN_AFFORDABLE_HTLC_COUNT: usize = 4;
491491// Counterparty designates channel data owned by the another channel participant entity.
492492pub ( super ) struct Channel < Signer : Sign > {
493493 #[ cfg( any( test, feature = "_test_utils" ) ) ]
494- pub ( crate ) config : ChannelConfig ,
494+ pub ( crate ) config : LegacyChannelConfig ,
495495 #[ cfg( not( any( test, feature = "_test_utils" ) ) ) ]
496- config : ChannelConfig ,
496+ config : LegacyChannelConfig ,
497497
498498 inbound_handshake_limits_override : Option < ChannelHandshakeLimits > ,
499499
@@ -855,7 +855,7 @@ impl<Signer: Sign> Channel<Signer> {
855855 // available. If it's private, we first try `scid_privacy` as it provides better privacy
856856 // with no other changes, and fall back to `only_static_remotekey`
857857 let mut ret = ChannelTypeFeatures :: only_static_remote_key ( ) ;
858- if !config. channel_options . announced_channel && config. own_channel_config . negotiate_scid_privacy {
858+ if !config. own_channel_config . announced_channel && config. own_channel_config . negotiate_scid_privacy {
859859 ret. set_scid_privacy_required ( ) ;
860860 }
861861 ret
@@ -918,7 +918,7 @@ impl<Signer: Sign> Channel<Signer> {
918918 let mut secp_ctx = Secp256k1 :: new ( ) ;
919919 secp_ctx. seeded_randomize ( & keys_provider. get_secure_random_bytes ( ) ) ;
920920
921- let shutdown_scriptpubkey = if config. channel_options . commit_upfront_shutdown_pubkey {
921+ let shutdown_scriptpubkey = if config. own_channel_config . commit_upfront_shutdown_pubkey {
922922 Some ( keys_provider. get_shutdown_scriptpubkey ( ) )
923923 } else { None } ;
924924
@@ -930,7 +930,13 @@ impl<Signer: Sign> Channel<Signer> {
930930
931931 Ok ( Channel {
932932 user_id,
933- config : config. channel_options . clone ( ) ,
933+
934+ config : LegacyChannelConfig {
935+ mutable : config. channel_options . clone ( ) ,
936+ announced_channel : config. own_channel_config . announced_channel ,
937+ commit_upfront_shutdown_pubkey : config. own_channel_config . commit_upfront_shutdown_pubkey ,
938+ } ,
939+
934940 inbound_handshake_limits_override : Some ( config. peer_channel_config_limits . clone ( ) ) ,
935941
936942 channel_id : keys_provider. get_secure_random_bytes ( ) ,
@@ -1117,7 +1123,6 @@ impl<Signer: Sign> Channel<Signer> {
11171123 delayed_payment_basepoint : msg. delayed_payment_basepoint ,
11181124 htlc_basepoint : msg. htlc_basepoint
11191125 } ;
1120- let mut local_config = ( * config) . channel_options . clone ( ) ;
11211126
11221127 if config. own_channel_config . our_to_self_delay < BREAKDOWN_TIMEOUT {
11231128 return Err ( ChannelError :: Close ( format ! ( "Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks. It must be greater than {}" , config. own_channel_config. our_to_self_delay, BREAKDOWN_TIMEOUT ) ) ) ;
@@ -1182,12 +1187,10 @@ impl<Signer: Sign> Channel<Signer> {
11821187 // Convert things into internal flags and prep our state:
11831188
11841189 if config. peer_channel_config_limits . force_announced_channel_preference {
1185- if local_config . announced_channel != announced_channel {
1190+ if config . own_channel_config . announced_channel != announced_channel {
11861191 return Err ( ChannelError :: Close ( "Peer tried to open channel but their announcement preference is different from ours" . to_owned ( ) ) ) ;
11871192 }
11881193 }
1189- // we either accept their preference or the preferences match
1190- local_config. announced_channel = announced_channel;
11911194
11921195 let holder_selected_channel_reserve_satoshis = Channel :: < Signer > :: get_holder_selected_channel_reserve_satoshis ( msg. funding_satoshis ) ;
11931196 if holder_selected_channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
@@ -1239,7 +1242,7 @@ impl<Signer: Sign> Channel<Signer> {
12391242 }
12401243 } else { None } ;
12411244
1242- let shutdown_scriptpubkey = if config. channel_options . commit_upfront_shutdown_pubkey {
1245+ let shutdown_scriptpubkey = if config. own_channel_config . commit_upfront_shutdown_pubkey {
12431246 Some ( keys_provider. get_shutdown_scriptpubkey ( ) )
12441247 } else { None } ;
12451248
@@ -1254,7 +1257,13 @@ impl<Signer: Sign> Channel<Signer> {
12541257
12551258 let chan = Channel {
12561259 user_id,
1257- config : local_config,
1260+
1261+ config : LegacyChannelConfig {
1262+ mutable : config. channel_options . clone ( ) ,
1263+ announced_channel,
1264+ commit_upfront_shutdown_pubkey : config. own_channel_config . commit_upfront_shutdown_pubkey ,
1265+ } ,
1266+
12581267 inbound_handshake_limits_override : None ,
12591268
12601269 channel_id : msg. temporary_channel_id ,
@@ -4011,7 +4020,7 @@ impl<Signer: Sign> Channel<Signer> {
40114020 // We always add force_close_avoidance_max_fee_satoshis to our normal
40124021 // feerate-calculated fee, but allow the max to be overridden if we're using a
40134022 // target feerate-calculated fee.
4014- cmp:: max ( normal_feerate as u64 * tx_weight / 1000 + self . config . force_close_avoidance_max_fee_satoshis ,
4023+ cmp:: max ( normal_feerate as u64 * tx_weight / 1000 + self . config . mutable . force_close_avoidance_max_fee_satoshis ,
40154024 proposed_max_feerate as u64 * tx_weight / 1000 )
40164025 } else {
40174026 self . channel_value_satoshis - ( self . value_to_self_msat + 999 ) / 1000
@@ -4471,15 +4480,15 @@ impl<Signer: Sign> Channel<Signer> {
44714480 }
44724481
44734482 pub fn get_fee_proportional_millionths ( & self ) -> u32 {
4474- self . config . forwarding_fee_proportional_millionths
4483+ self . config . mutable . forwarding_fee_proportional_millionths
44754484 }
44764485
44774486 pub fn get_cltv_expiry_delta ( & self ) -> u16 {
4478- cmp:: max ( self . config . cltv_expiry_delta , MIN_CLTV_EXPIRY_DELTA )
4487+ cmp:: max ( self . config . mutable . cltv_expiry_delta , MIN_CLTV_EXPIRY_DELTA )
44794488 }
44804489
44814490 pub fn get_max_dust_htlc_exposure_msat ( & self ) -> u64 {
4482- self . config . max_dust_htlc_exposure_msat
4491+ self . config . mutable . max_dust_htlc_exposure_msat
44834492 }
44844493
44854494 pub fn get_feerate ( & self ) -> u32 {
@@ -4566,7 +4575,7 @@ impl<Signer: Sign> Channel<Signer> {
45664575 /// Gets the fee we'd want to charge for adding an HTLC output to this Channel
45674576 /// Allowed in any state (including after shutdown)
45684577 pub fn get_outbound_forwarding_fee_base_msat ( & self ) -> u32 {
4569- self . config . forwarding_fee_base_msat
4578+ self . config . mutable . forwarding_fee_base_msat
45704579 }
45714580
45724581 /// Returns true if we've ever received a message from the remote end for this Channel
@@ -6030,11 +6039,11 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
60306039
60316040 let user_id = Readable :: read ( reader) ?;
60326041
6033- let mut config = Some ( ChannelConfig :: default ( ) ) ;
6042+ let mut config = Some ( LegacyChannelConfig :: default ( ) ) ;
60346043 if ver == 1 {
60356044 // Read the old serialization of the ChannelConfig from version 0.0.98.
6036- config. as_mut ( ) . unwrap ( ) . forwarding_fee_proportional_millionths = Readable :: read ( reader) ?;
6037- config. as_mut ( ) . unwrap ( ) . cltv_expiry_delta = Readable :: read ( reader) ?;
6045+ config. as_mut ( ) . unwrap ( ) . mutable . forwarding_fee_proportional_millionths = Readable :: read ( reader) ?;
6046+ config. as_mut ( ) . unwrap ( ) . mutable . cltv_expiry_delta = Readable :: read ( reader) ?;
60386047 config. as_mut ( ) . unwrap ( ) . announced_channel = Readable :: read ( reader) ?;
60396048 config. as_mut ( ) . unwrap ( ) . commit_upfront_shutdown_pubkey = Readable :: read ( reader) ?;
60406049 } else {
@@ -6926,7 +6935,7 @@ mod tests {
69266935
69276936 let counterparty_node_id = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
69286937 let mut config = UserConfig :: default ( ) ;
6929- config. channel_options . announced_channel = false ;
6938+ config. own_channel_config . announced_channel = false ;
69306939 let mut chan = Channel :: < InMemorySigner > :: new_outbound ( & & feeest, & & keys_provider, counterparty_node_id, & InitFeatures :: known ( ) , 10_000_000 , 100000 , 42 , & config, 0 , 42 ) . unwrap ( ) ; // Nothing uses their network key in this test
69316940 chan. holder_dust_limit_satoshis = 546 ;
69326941 chan. counterparty_selected_channel_reserve_satoshis = Some ( 0 ) ; // Filled in in accept_channel
0 commit comments