The difficulty is the search space size.
A difficulty of 173346595075428800 means that you have a probability of 1/173346595075428800 to find the result after 1 try.
After n tries, you can compute the probability to reach the desired address by using Bernoulli.
P(n) = 1-(1-1/173346595075428800)^n
I am asking because I have scanned the range of keys being the number given by Diff, but I have not found a solution.
1. What is the remainder of the range that I should scan to find the answer?
2. The fact that I did not find the correct key despite this is not the reason for the error in the code?
I already answered to you: difficulty is not the range you should scan to find the solution at 100% : you have in the above example
P(173346595075428800) = 1-(1-1/173346595075428800)^173346595075428800 = 0.63 --> 63% ( = 1-1/e), not 100%!
That means that only 2 times each 3 you will find the solution in a range = difficulty.