@@ -666,13 +666,10 @@ where
666
666
output : vec ! [ ] ,
667
667
} ;
668
668
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;
676
673
let total_input_amount = must_spend_amount
677
674
+ coin_selection. confirmed_utxos . iter ( ) . map ( |utxo| utxo. output . value ) . sum ( ) ;
678
675
@@ -748,11 +745,8 @@ where
748
745
unsigned_tx_weight + 2 /* wit marker */ + total_satisfaction_weight;
749
746
// Our estimate should be within a 1% error margin of the actual weight and we should
750
747
// 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) ;
756
750
757
751
let expected_package_fee = Amount :: from_sat ( fee_for_weight (
758
752
package_target_feerate_sat_per_1000_weight,
@@ -825,19 +819,15 @@ where
825
819
) ?;
826
820
827
821
#[ 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;
834
826
#[ 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;
841
831
842
832
self . process_coin_selection ( & mut htlc_tx, & coin_selection) ;
843
833
@@ -891,11 +881,8 @@ where
891
881
let expected_signed_tx_weight = unsigned_tx_weight + total_satisfaction_weight;
892
882
// Our estimate should be within a 1% error margin of the actual weight and we should
893
883
// 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) ;
899
886
900
887
let expected_signed_tx_fee =
901
888
fee_for_weight ( target_feerate_sat_per_1000_weight, signed_tx_weight) ;
0 commit comments