  We review the so called selfish mining strategy in the Bitcoin network and
compare its profitability to honest mining.We build a rigorous profitability
model for repetition games. The time analysis of the attack has been ignored in
the previous literature based on a Markov model,but is critical. Using
martingale's techniques and Doob Stopping Time Theorem we compute the expected
duration of attack cycles. We discover a remarkable property of the bitcoin
network: no strategy is more profitable than the honest strategy before a
difficulty adjustment. So selfish mining can only become profitable afterwards,
thus it is an attack on the difficulty adjustment algorithm. We propose an
improvement of Bitcoin protocol making it immune to selfish mining attacks. We
also study miner's attraction to selfish mining pools. We calculate the
expected duration time before profit for the selfish miner, a computation that
is out of reach by the previous Markov models.
