@@ -291,30 +291,6 @@ pub struct ChannelConfig {
291
291
///
292
292
/// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
293
293
pub cltv_expiry_delta : u16 ,
294
- /// Set to announce the channel publicly and notify all nodes that they can route via this
295
- /// channel.
296
- ///
297
- /// This should only be set to true for nodes which expect to be online reliably.
298
- ///
299
- /// As the node which funds a channel picks this value this will only apply for new outbound
300
- /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
301
- ///
302
- /// This cannot be changed after the initial channel handshake.
303
- ///
304
- /// Default value: false.
305
- pub announced_channel : bool ,
306
- /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
307
- /// supports it, they will then enforce the mutual-close output to us matches what we provided
308
- /// at intialization, preventing us from closing to an alternate pubkey.
309
- ///
310
- /// This is set to true by default to provide a slight increase in security, though ultimately
311
- /// any attacker who is able to take control of a channel can just as easily send the funds via
312
- /// lightning payments, so we never require that our counterparties support this option.
313
- ///
314
- /// This cannot be changed after a channel has been initialized.
315
- ///
316
- /// Default value: true.
317
- pub commit_upfront_shutdown_pubkey : bool ,
318
294
/// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
319
295
/// small to claim on-chain.
320
296
///
@@ -363,23 +339,83 @@ impl Default for ChannelConfig {
363
339
forwarding_fee_proportional_millionths : 0 ,
364
340
forwarding_fee_base_msat : 1000 ,
365
341
cltv_expiry_delta : 6 * 12 , // 6 blocks/hour * 12 hours
366
- announced_channel : false ,
367
- commit_upfront_shutdown_pubkey : true ,
368
342
max_dust_htlc_exposure_msat : 5_000_000 ,
369
343
force_close_avoidance_max_fee_satoshis : 1000 ,
370
344
}
371
345
}
372
346
}
373
347
374
- impl_writeable_tlv_based ! ( ChannelConfig , {
375
- ( 0 , forwarding_fee_proportional_millionths, required) ,
376
- ( 1 , max_dust_htlc_exposure_msat, ( default_value, 5_000_000 ) ) ,
377
- ( 2 , cltv_expiry_delta, required) ,
378
- ( 3 , force_close_avoidance_max_fee_satoshis, ( default_value, 1000 ) ) ,
379
- ( 4 , announced_channel, required) ,
380
- ( 6 , commit_upfront_shutdown_pubkey, required) ,
381
- ( 8 , forwarding_fee_base_msat, required) ,
382
- } ) ;
348
+ /// Legacy version of [`ChannelConfig`] that stored the static
349
+ /// [`ChannelHandshakeConfig::announced_channel`] and
350
+ /// [`ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`] fields.
351
+ #[ derive( Copy , Clone , Debug ) ]
352
+ pub ( crate ) struct LegacyChannelConfig {
353
+ pub ( crate ) mutable : ChannelConfig ,
354
+ /// Deprecated but may still be read from. See [`ChannelHandshakeConfig::announced_channel`] to
355
+ /// set this when opening/accepting a channel.
356
+ pub ( crate ) announced_channel : bool ,
357
+ /// Deprecated but may still be read from. See
358
+ /// [`ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`] to set this when
359
+ /// opening/accepting a channel.
360
+ pub ( crate ) commit_upfront_shutdown_pubkey : bool ,
361
+ }
362
+
363
+ impl Default for LegacyChannelConfig {
364
+ fn default ( ) -> Self {
365
+ Self {
366
+ mutable : ChannelConfig :: default ( ) ,
367
+ announced_channel : false ,
368
+ commit_upfront_shutdown_pubkey : true ,
369
+ }
370
+ }
371
+ }
372
+
373
+ impl :: util:: ser:: Writeable for LegacyChannelConfig {
374
+ fn write < W : :: util:: ser:: Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: io:: Error > {
375
+ write_tlv_fields ! ( writer, {
376
+ ( 0 , self . mutable. forwarding_fee_proportional_millionths, required) ,
377
+ ( 1 , self . mutable. max_dust_htlc_exposure_msat, ( default_value, 5_000_000 ) ) ,
378
+ ( 2 , self . mutable. cltv_expiry_delta, required) ,
379
+ ( 3 , self . mutable. force_close_avoidance_max_fee_satoshis, ( default_value, 1000 ) ) ,
380
+ ( 4 , self . announced_channel, required) ,
381
+ ( 6 , self . commit_upfront_shutdown_pubkey, required) ,
382
+ ( 8 , self . mutable. forwarding_fee_base_msat, required) ,
383
+ } ) ;
384
+ Ok ( ( ) )
385
+ }
386
+ }
387
+
388
+ impl :: util:: ser:: Readable for LegacyChannelConfig {
389
+ fn read < R : :: io:: Read > ( reader : & mut R ) -> Result < Self , :: ln:: msgs:: DecodeError > {
390
+ let mut forwarding_fee_proportional_millionths = 0 ;
391
+ let mut max_dust_htlc_exposure_msat = 5_000_000 ;
392
+ let mut cltv_expiry_delta = 0 ;
393
+ let mut force_close_avoidance_max_fee_satoshis = 1000 ;
394
+ let mut announced_channel = false ;
395
+ let mut commit_upfront_shutdown_pubkey = false ;
396
+ let mut forwarding_fee_base_msat = 0 ;
397
+ read_tlv_fields ! ( reader, {
398
+ ( 0 , forwarding_fee_proportional_millionths, required) ,
399
+ ( 1 , max_dust_htlc_exposure_msat, ( default_value, 5_000_000 ) ) ,
400
+ ( 2 , cltv_expiry_delta, required) ,
401
+ ( 3 , force_close_avoidance_max_fee_satoshis, ( default_value, 1000 ) ) ,
402
+ ( 4 , announced_channel, required) ,
403
+ ( 6 , commit_upfront_shutdown_pubkey, required) ,
404
+ ( 8 , forwarding_fee_base_msat, required) ,
405
+ } ) ;
406
+ Ok ( Self {
407
+ mutable : ChannelConfig {
408
+ forwarding_fee_proportional_millionths,
409
+ max_dust_htlc_exposure_msat,
410
+ cltv_expiry_delta,
411
+ force_close_avoidance_max_fee_satoshis,
412
+ forwarding_fee_base_msat,
413
+ } ,
414
+ announced_channel,
415
+ commit_upfront_shutdown_pubkey,
416
+ } )
417
+ }
418
+ }
383
419
384
420
/// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
385
421
///
0 commit comments