Bitcoins – Pools and Mining

Exclusive offer: get 50% off this eBook here
Raspberry Pi Server Essentials

Raspberry Pi Server Essentials — Save 50%

Transform your Raspberry Pi into a server for hosting websites, games, or even your Bitcoin network with this book and ebook

£11.99    £6.00
by Piotr J. Kula | February 2014 | Networking & Telephony Open Source Web Development

This article by Piotr J. Kula, author of the book Raspberry Pi Server Essentials, will illustrate the concept of cryptographic currencies, and we will try and understand what Bitcoin is. We will set up a wallet and learn how to send and receive coins.

In this article, we will cover the following topics:

  • Installing Bitcoind
  • Bitcoin wallet
  • Creating a Bitcoin address
  • Mining for Bitcoins
  • Mining with ASICMiner

(For more resources related to this topic, see here.)

Installing Bitcoind

Bitcoind is the software that connects you to other nodes in the network. There is no single point of failure, and the more nodes there are the faster and more secure the network becomes. Peers are rewarded with a transaction fee for the first validation of a transaction and are assigned randomly.

After installing Bitcoind by using the following command, we have to synchronize it with the network, which means downloading millions of transactions exceeding a gigabyte in size to your Pi.

sudo apt-get install bitcoind

Before running the background daemon, you need to consider changing the data directory as the database files can take up many gigabytes of space. Mount a new storage place and always start Bitcoind with the following line:

bitcoind –datadir /mnt/HDD/bitcoin –daemon

After a few minutes, you can type in the following basic commands. You will need to wait until the entire block chain data is downloaded before you can do anything useful. During this time, the Pi might become less responsive, use a lot of bandwidth, and create a large amount of data in the data directory. This can take up to 12 hours.

bitcoind getinfo
bitcoind getblockcount

If you already have most of the block chain data downloaded on another computer, you can just copy all the data to the Pi. You can even have the same wallet and addresses in both locations. It is not recommended though, as that means it's twice as easy for hackers to get your wallet. Always encrypt your wallet with a very strong password and keep the password and wallet backup in a safe, offline place—like CDs or USB drives. If you lose the password, you lose access to the wallet, forever.

Bitcoin wallet

You need to generate addresses where other people can send you funds. Theoretically, you can generate an unlimited number of addresses, but practically managing all those addresses would become difficult. Bitcoin, by default, allows you to have a hundred addresses. You always get a default wallet address, which counts as the first address, and this address will receive network fees if you process any transactions for the first time.

Cryptocurrency transactions cannot be reversed. Sending coins to the incorrect address means your coins will be lost forever. On the other hand, it also protects you if you are receiving coins from somebody else, as they cannot reverse the transaction.

These addresses are globally unique, and can never be generated by anybody else in the universe or beyond it. It can get stolen by hackers or viruses, though. Imagine losing your wallet in real life. Unless a kind person returns it to you, the contents of that wallet will be lost forever.

You can back up your wallet file, but you should store it on any two USB flash drives or CDs, and store it in a safety deposit box at home or in the bank. You should never be tempted to copy your wallet to any kind of online storage or backup services, especially if it's unencrypted.

Creating a Bitcoin address

These examples will work with the command line, as you can re-use them to display data on your web server. All online wallets use the Bitcoind API to generate addresses and manage your wallet. As a word of warning, you should never use online wallet services as almost all of them have been hacked, resulting in massive numbers of coins getting stolen.

You can download the Bitcoin-QT client and run it in X if you prefer an easy way to manage your wallet.

The following command lines will create a new receiving address and then list all your addresses:

bitcoind getnewaddress
bitcoind listaccounts

Receiving Bitcoins

As long as you know your address, people can send you Bitcoins. You do not need to have Bitcoind running all the time as the transactions are processes and are stored in the network. It is just very important to keep a backup of your wallet.dat file if you want to send the Bitcoins somewhere else, like an online exchange.

Sending Bitcoins

As long as you have coins in your wallet, you can easily send coins to another address by using the sendtoaddress command followed by the address and the amount. Here is an example sending 0.01 Bitcoins to the author's tip jar:

bitcoind sendtoaddress 126HA8L1dP7fr7ECu2oEMtz6JpDRnzqp9N 0.01

You will get a response, which is a transaction ID. If you do not, the transaction has failed. You need to have at least 0.0001 Bitcoins reserved for the transaction fees. If you are sending large amounts of coins, this transaction fee will also become more expensive.

The value of Bitcoins

In July 2010, the value of Bitcoin was below 1 USD. Investing in Bitcoins was very controversial and a huge risk, since it was difficult to predict if the currency would be accepted or rejected by the community. As of writing this article, the Bitcoin value has exceeded 1100 USD.

You can search the Internet and find interesting articles on early adopters mining Bitcoins, or buying a few hundred dollars and leaving their wallets lying around. Just like one person in the UK who threw away his hard drive with 7500 BTC stored on it. After going public, thousands of people flocked to the public dump ground to search for the hard drive. Other stories include a student who invested a few hundred dollars in 2010, and sold them for hundreds of thousands of dollars. With such large amounts, it is important to consult your local TAX authority or council.

The trend seems to be that the more people find out about Bitcoins and the more media publicity it gets, the higher the value of the currency rises. This also looks like it applies to alternative currencies such as Litecoin.

Summary

We have seen what Bitcoin is. We have seen what are the uses of Bitcoins and also it's value. We have also seen how to send and receive Bitcoins. I hope this has given you a better idea about what Bitcoins really are.

Resources for Article:


Further resources on this subject:


Raspberry Pi Server Essentials Transform your Raspberry Pi into a server for hosting websites, games, or even your Bitcoin network with this book and ebook
Published: February 2014
eBook Price: £11.99
Book Price: £18.99
See more
Select your format and quantity:

About the Author :


Piotr J. Kula

Piotr J. Kula developed an interest in computers when he was six years old. He was introduced to the world of technology by his father who came from an electronics engineering background. Piotr has lived, studied, and gained experience in three countries. Today, he is a Microsoft Certified Professional and works with reputed companies offering complex software solutions. In his spare time, he enjoys working on electrical engineering projects and also enjoys doing some home improvement projects with his wife.

Books From Packt


Raspberry Pi Networking Cookbook
Raspberry Pi Networking Cookbook

Raspberry Pi Home Automation with Arduino
Raspberry Pi Home Automation with Arduino

Instant Raspberry Pi Gaming [Instant]
Instant Raspberry Pi Gaming [Instant]

Raspberry Pi Cookbook for Python Programmers
Raspberry Pi Cookbook for Python Programmers

Raspberry Pi Super Cluster
Raspberry Pi Super Cluster

 Raspberry Pi for Secret Agents
Raspberry Pi for Secret Agents

Raspberry Pi Media Center
Raspberry Pi Media Center

Learning FuelPHP for Effective PHP Development
Learning FuelPHP for Effective PHP Development


Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software