@@ -186,10 +186,6 @@ pub(crate) trait TxBuilder {
186186 fn commit_tx_fee_sat (
187187 & self , feerate_per_kw : u32 , nondust_htlc_count : usize , channel_type : & ChannelTypeFeatures ,
188188 ) -> u64 ;
189- fn subtract_non_htlc_outputs (
190- & self , is_outbound_from_holder : bool , value_to_self_after_htlcs : u64 ,
191- value_to_remote_after_htlcs : u64 , channel_type : & ChannelTypeFeatures ,
192- ) -> ( u64 , u64 ) ;
193189 fn build_commitment_transaction < L : Deref > (
194190 & self , local : bool , commitment_number : u64 , per_commitment_point : & PublicKey ,
195191 channel_parameters : & ChannelTransactionParameters , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -443,36 +439,6 @@ impl TxBuilder for SpecTxBuilder {
443439 ) -> u64 {
444440 commit_tx_fee_sat ( feerate_per_kw, nondust_htlc_count, channel_type)
445441 }
446- fn subtract_non_htlc_outputs (
447- & self , is_outbound_from_holder : bool , value_to_self_after_htlcs : u64 ,
448- value_to_remote_after_htlcs : u64 , channel_type : & ChannelTypeFeatures ,
449- ) -> ( u64 , u64 ) {
450- let total_anchors_sat = if channel_type. supports_anchors_zero_fee_htlc_tx ( ) {
451- ANCHOR_OUTPUT_VALUE_SATOSHI * 2
452- } else {
453- 0
454- } ;
455-
456- let mut local_balance_before_fee_msat = value_to_self_after_htlcs;
457- let mut remote_balance_before_fee_msat = value_to_remote_after_htlcs;
458-
459- // We MUST use saturating subs here, as the funder's balance is not guaranteed to be greater
460- // than or equal to `total_anchors_sat`.
461- //
462- // This is because when the remote party sends an `update_fee` message, we build the new
463- // commitment transaction *before* checking whether the remote party's balance is enough to
464- // cover the total anchor sum.
465-
466- if is_outbound_from_holder {
467- local_balance_before_fee_msat =
468- local_balance_before_fee_msat. saturating_sub ( total_anchors_sat * 1000 ) ;
469- } else {
470- remote_balance_before_fee_msat =
471- remote_balance_before_fee_msat. saturating_sub ( total_anchors_sat * 1000 ) ;
472- }
473-
474- ( local_balance_before_fee_msat, remote_balance_before_fee_msat)
475- }
476442 fn build_commitment_transaction < L : Deref > (
477443 & self , local : bool , commitment_number : u64 , per_commitment_point : & PublicKey ,
478444 channel_parameters : & ChannelTransactionParameters , secp_ctx : & Secp256k1 < secp256k1:: All > ,
@@ -541,13 +507,12 @@ impl TxBuilder for SpecTxBuilder {
541507 . unwrap ( )
542508 . checked_sub ( remote_htlc_total_msat)
543509 . unwrap ( ) ;
544- let ( local_balance_before_fee_msat, remote_balance_before_fee_msat) = self
545- . subtract_non_htlc_outputs (
546- channel_parameters. is_outbound_from_holder ,
547- value_to_self_after_htlcs_msat,
548- value_to_remote_after_htlcs_msat,
549- & channel_parameters. channel_type_features ,
550- ) ;
510+ let ( local_balance_before_fee_msat, remote_balance_before_fee_msat) = subtract_addl_outputs (
511+ channel_parameters. is_outbound_from_holder ,
512+ value_to_self_after_htlcs_msat,
513+ value_to_remote_after_htlcs_msat,
514+ & channel_parameters. channel_type_features
515+ ) . unwrap ( ) ;
551516
552517 // We MUST use saturating subs here, as the funder's balance is not guaranteed to be greater
553518 // than or equal to `commit_tx_fee_sat`.
0 commit comments