@@ -326,6 +326,7 @@ pub(super) struct Channel {
326
326
//implied by BREAKDOWN_TIMEOUT: our_to_self_delay: u16,
327
327
their_max_accepted_htlcs : u16 ,
328
328
//implied by OUR_MAX_HTLCS: our_max_accepted_htlcs: u16,
329
+ minimum_depth : u32 ,
329
330
330
331
their_funding_pubkey : Option < PublicKey > ,
331
332
their_revocation_basepoint : Option < PublicKey > ,
@@ -413,11 +414,6 @@ impl Channel {
413
414
CONF_TARGET
414
415
}
415
416
416
- fn derive_maximum_minimum_depth ( _channel_value_satoshis_msat : u64 , _value_to_self_msat : u64 ) -> u32 {
417
- const CONF_TARGET : u32 = 12 ; //TODO: Should be much higher
418
- CONF_TARGET * 2
419
- }
420
-
421
417
// Constructors:
422
418
pub fn new_outbound ( fee_estimator : & FeeEstimator , keys_provider : & Arc < KeysInterface > , their_node_id : PublicKey , channel_value_satoshis : u64 , push_msat : u64 , announce_publicly : bool , user_id : u64 , logger : Arc < Logger > ) -> Result < Channel , APIError > {
423
419
let chan_keys = keys_provider. get_channel_keys ( false ) ;
@@ -498,6 +494,7 @@ impl Channel {
498
494
our_htlc_minimum_msat : Channel :: derive_our_htlc_minimum_msat ( feerate) ,
499
495
their_to_self_delay : 0 ,
500
496
their_max_accepted_htlcs : 0 ,
497
+ minimum_depth : 0 , // Filled in in accept_channel
501
498
502
499
their_funding_pubkey : None ,
503
500
their_revocation_basepoint : None ,
@@ -662,6 +659,7 @@ impl Channel {
662
659
our_htlc_minimum_msat : Channel :: derive_our_htlc_minimum_msat ( msg. feerate_per_kw as u64 ) ,
663
660
their_to_self_delay : msg. to_self_delay ,
664
661
their_max_accepted_htlcs : msg. max_accepted_htlcs ,
662
+ minimum_depth : Channel :: derive_minimum_depth ( msg. funding_satoshis * 1000 , msg. push_msat ) ,
665
663
666
664
their_funding_pubkey : Some ( msg. funding_pubkey ) ,
667
665
their_revocation_basepoint : Some ( msg. revocation_basepoint ) ,
@@ -1290,9 +1288,6 @@ impl Channel {
1290
1288
if msg. htlc_minimum_msat >= ( self . channel_value_satoshis - msg. channel_reserve_satoshis ) * 1000 {
1291
1289
return Err ( ChannelError :: Close ( "Minimum htlc value is full channel value" ) ) ;
1292
1290
}
1293
- if msg. minimum_depth > Channel :: derive_maximum_minimum_depth ( self . channel_value_satoshis * 1000 , self . value_to_self_msat ) {
1294
- return Err ( ChannelError :: Close ( "minimum_depth too large" ) ) ;
1295
- }
1296
1291
if msg. to_self_delay > MAX_LOCAL_BREAKDOWN_TIMEOUT {
1297
1292
return Err ( ChannelError :: Close ( "They wanted our payments to be delayed by a needlessly long period" ) ) ;
1298
1293
}
@@ -1320,6 +1315,7 @@ impl Channel {
1320
1315
self . their_htlc_minimum_msat = msg. htlc_minimum_msat ;
1321
1316
self . their_to_self_delay = msg. to_self_delay ;
1322
1317
self . their_max_accepted_htlcs = msg. max_accepted_htlcs ;
1318
+ self . minimum_depth = msg. minimum_depth ;
1323
1319
self . their_funding_pubkey = Some ( msg. funding_pubkey ) ;
1324
1320
self . their_revocation_basepoint = Some ( msg. revocation_basepoint ) ;
1325
1321
self . their_payment_basepoint = Some ( msg. payment_basepoint ) ;
@@ -2708,7 +2704,7 @@ impl Channel {
2708
2704
self . channel_monitor . last_block_hash = self . last_block_connected ;
2709
2705
if self . funding_tx_confirmations > 0 {
2710
2706
self . funding_tx_confirmations += 1 ;
2711
- if self . funding_tx_confirmations == Channel :: derive_minimum_depth ( self . channel_value_satoshis * 1000 , self . value_to_self_msat ) as u64 {
2707
+ if self . funding_tx_confirmations == self . minimum_depth as u64 {
2712
2708
let need_commitment_update = if non_shutdown_state == ChannelState :: FundingSent as u32 {
2713
2709
self . channel_state |= ChannelState :: OurFundingLocked as u32 ;
2714
2710
true
@@ -2785,7 +2781,7 @@ impl Channel {
2785
2781
}
2786
2782
}
2787
2783
if Some ( header. bitcoin_hash ( ) ) == self . funding_tx_confirmed_in {
2788
- self . funding_tx_confirmations = Channel :: derive_minimum_depth ( self . channel_value_satoshis * 1000 , self . value_to_self_msat ) as u64 - 1 ;
2784
+ self . funding_tx_confirmations = self . minimum_depth as u64 - 1 ;
2789
2785
}
2790
2786
self . last_block_connected = header. bitcoin_hash ( ) ;
2791
2787
self . channel_monitor . last_block_hash = self . last_block_connected ;
@@ -2851,7 +2847,7 @@ impl Channel {
2851
2847
max_htlc_value_in_flight_msat : Channel :: get_our_max_htlc_value_in_flight_msat ( self . channel_value_satoshis ) ,
2852
2848
channel_reserve_satoshis : Channel :: get_our_channel_reserve_satoshis ( self . channel_value_satoshis ) ,
2853
2849
htlc_minimum_msat : self . our_htlc_minimum_msat ,
2854
- minimum_depth : Channel :: derive_minimum_depth ( self . channel_value_satoshis * 1000 , self . value_to_self_msat ) ,
2850
+ minimum_depth : self . minimum_depth ,
2855
2851
to_self_delay : BREAKDOWN_TIMEOUT ,
2856
2852
max_accepted_htlcs : OUR_MAX_HTLCS ,
2857
2853
funding_pubkey : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . funding_key ) ,
@@ -3482,6 +3478,7 @@ impl Writeable for Channel {
3482
3478
self . our_htlc_minimum_msat . write ( writer) ?;
3483
3479
self . their_to_self_delay . write ( writer) ?;
3484
3480
self . their_max_accepted_htlcs . write ( writer) ?;
3481
+ self . minimum_depth . write ( writer) ?;
3485
3482
3486
3483
write_option ! ( self . their_funding_pubkey) ;
3487
3484
write_option ! ( self . their_revocation_basepoint) ;
@@ -3655,6 +3652,7 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
3655
3652
let our_htlc_minimum_msat = Readable :: read ( reader) ?;
3656
3653
let their_to_self_delay = Readable :: read ( reader) ?;
3657
3654
let their_max_accepted_htlcs = Readable :: read ( reader) ?;
3655
+ let minimum_depth = Readable :: read ( reader) ?;
3658
3656
3659
3657
let their_funding_pubkey = read_option ! ( ) ;
3660
3658
let their_revocation_basepoint = read_option ! ( ) ;
@@ -3731,6 +3729,7 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
3731
3729
our_htlc_minimum_msat,
3732
3730
their_to_self_delay,
3733
3731
their_max_accepted_htlcs,
3732
+ minimum_depth,
3734
3733
3735
3734
their_funding_pubkey,
3736
3735
their_revocation_basepoint,
0 commit comments