@@ -666,13 +666,10 @@ where
666666 output : vec ! [ ] ,
667667 } ;
668668
669- let total_satisfaction_weight = ANCHOR_INPUT_WITNESS_WEIGHT
670- + EMPTY_SCRIPT_SIG_WEIGHT
671- + coin_selection
672- . confirmed_utxos
673- . iter ( )
674- . map ( |utxo| utxo. satisfaction_weight )
675- . sum :: < u64 > ( ) ;
669+ let input_satisfaction_weight: u64 =
670+ coin_selection. confirmed_utxos . iter ( ) . map ( |utxo| utxo. satisfaction_weight ) . sum ( ) ;
671+ let total_satisfaction_weight =
672+ ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT + input_satisfaction_weight;
676673 let total_input_amount = must_spend_amount
677674 + coin_selection. confirmed_utxos . iter ( ) . map ( |utxo| utxo. output . value ) . sum ( ) ;
678675
@@ -748,11 +745,8 @@ where
748745 unsigned_tx_weight + 2 /* wit marker */ + total_satisfaction_weight;
749746 // Our estimate should be within a 1% error margin of the actual weight and we should
750747 // never underestimate.
751- assert ! (
752- expected_signed_tx_weight >= signed_tx_weight
753- && expected_signed_tx_weight - ( expected_signed_tx_weight / 100 )
754- <= signed_tx_weight
755- ) ;
748+ assert ! ( expected_signed_tx_weight >= signed_tx_weight) ;
749+ assert ! ( expected_signed_tx_weight * 99 / 100 <= signed_tx_weight) ;
756750
757751 let expected_package_fee = Amount :: from_sat ( fee_for_weight (
758752 package_target_feerate_sat_per_1000_weight,
@@ -825,19 +819,15 @@ where
825819 ) ?;
826820
827821 #[ cfg( debug_assertions) ]
828- let total_satisfaction_weight = must_spend_satisfaction_weight
829- + coin_selection
830- . confirmed_utxos
831- . iter ( )
832- . map ( |utxo| utxo. satisfaction_weight )
833- . sum :: < u64 > ( ) ;
822+ let input_satisfaction_weight: u64 =
823+ coin_selection. confirmed_utxos . iter ( ) . map ( |utxo| utxo. satisfaction_weight ) . sum ( ) ;
824+ #[ cfg( debug_assertions) ]
825+ let total_satisfaction_weight = must_spend_satisfaction_weight + input_satisfaction_weight;
834826 #[ cfg( debug_assertions) ]
835- let total_input_amount = must_spend_amount
836- + coin_selection
837- . confirmed_utxos
838- . iter ( )
839- . map ( |utxo| utxo. output . value . to_sat ( ) )
840- . sum :: < u64 > ( ) ;
827+ let input_value: u64 =
828+ coin_selection. confirmed_utxos . iter ( ) . map ( |utxo| utxo. output . value . to_sat ( ) ) . sum ( ) ;
829+ #[ cfg( debug_assertions) ]
830+ let total_input_amount = must_spend_amount + input_value;
841831
842832 self . process_coin_selection ( & mut htlc_tx, & coin_selection) ;
843833
@@ -891,11 +881,8 @@ where
891881 let expected_signed_tx_weight = unsigned_tx_weight + total_satisfaction_weight;
892882 // Our estimate should be within a 1% error margin of the actual weight and we should
893883 // never underestimate.
894- assert ! (
895- expected_signed_tx_weight >= signed_tx_weight
896- && expected_signed_tx_weight - ( expected_signed_tx_weight / 100 )
897- <= signed_tx_weight
898- ) ;
884+ assert ! ( expected_signed_tx_weight >= signed_tx_weight) ;
885+ assert ! ( expected_signed_tx_weight * 99 / 100 <= signed_tx_weight) ;
899886
900887 let expected_signed_tx_fee =
901888 fee_for_weight ( target_feerate_sat_per_1000_weight, signed_tx_weight) ;
0 commit comments