The price of bitcoin has hit its highest level in more than two years due to a rule written in the cryptocurrency's code which could tighten its supply and as it becomes a safe-haven bet amid broader macroeconomic worries.

Bitcoin briefly broke the $700 barrier on Monday, the highest since February 2014. In the last month, the price of digital currency has risen over 51 percent.

An upcoming shift in the fundamental code governing the digital currency is said to be behind the spike. There is a finite supply of 21 million coins that will ever be released. Bitcoins are created by a process known as "mining". This involves people using computers to solve complex mathematical puzzles in order for a bitcoin transaction to go through. When this problem is solved, the miner is awarded with bitcoins.

But over the course of a bitcoin's life which began in 2008 as a white paper before coming into existence in 2009, these mathematical problems get harder. And the reward offered to miners is set to reduce sometime next month. At the beginning, the reward for mining was 50 bitcoin per "block" – which is a group of transactions. It then fell to 25 bitcoins in 2012. It is now set to half again, thus reducing the supply growth of bitcoin. The process is known as "halving" and was written in the original code for bitcoin.

With fewer bitcoin coming into the system, the price has risen with increased trading activity.

"We are seeing very high trading volumes," Bobby Lee, chief executive of BTCC, one of the largest bitcoin exchanges in the world based in China, told CNBC by phone on Monday.

"The block halving will dramatically decrease the bitcoin being added as we approach 75 percent of all bitcoin issued. People understand that in this world of ever expanding assets and printing of money, we have something that's fixed and limited in issuance. It gives a decent alternative for people who want to hold assets that can have sustained purchasing power."

Bitcoin has typically been a very volatile currency and the price has even surged to over $1,216 in 2013. But the cryptocurrency has been gaining more legitimacy with policymakers talking about its potential and the U.S. Commodity Futures Trading Commission last year classed it as a commodity.

At times, bitcoin has managed to act as a safe-haven asset. The digital currency found some support last year when Greece was close to default. Concerns over the health of the Chinese economy and the prospect of a further depreciation of the yuan have also helped support bitcoin, Lee said.

"It's kind of a mess worldwide in terms of economy and all different asset classes," Lee told CNBC.

Clarification: This article has been amended to reflect the date when bitcoin began trading.