Coinbase, the San Francisco-based exchange, has explained how it discovered and then foiled an attack on its network and averted the potential loss of millions of dollars worth of cryptocurrencies.