`
`1
`
`CRUSOE 1009
`
`
`
`Bitcoin Essentials
`
`Gain insights into Bitcoin, a cryptocurrency and
`a powerful technology, to optimize your Bitcoin
`mining techniques
`
`Albert Szmigielski
`
`BIRMINGHAM - MUMBAI
`
`www.allitebooks.com
`
`2
`
`
`
`Bitcoin Essentials
`
`Copyright © 2016 Packt Publishing
`
`All rights reserved. No part of this book may be reproduced, stored in a retrieval
`system, or transmitted in any form or by any means, without the prior written
`permission of the publisher, except in the case of brief quotations embedded in
`critical articles or reviews.
`
`Every effort has been made in the preparation of this book to ensure the accuracy
`of the information presented. However, the information contained in this book is
`sold without warranty, either express or implied. Neither the author, nor Packt
`Publishing, and its dealers and distributors will be held liable for any damages
`caused or alleged to be caused directly or indirectly by this book.
`
`Packt Publishing has endeavored to provide trademark information about all of the
`companies and products mentioned in this book by the appropriate use of capitals.
`However, Packt Publishing cannot guarantee the accuracy of this information.
`
`First published: February 2016
`
`Production reference: 1170216
`
`Published by Packt Publishing Ltd.
`Livery Place
`35 Livery Street
`Birmingham B3 2PB, UK.
`
`ISBN 978-1-78528-197-6
`
`www.packtpub.com
`
`www.allitebooks.com
`
`3
`
`
`
`Credits
`
`Author
`Albert Szmigielski
`
`Reviewer
`Kevin M. Fitzgerald
`
`Commissioning Editor
`Edward Bowkett
`
`Project Coordinator
`Judie Jose
`
`Proofreader
`Safis Editing
`
`Indexer
`Priya Sane
`
`Acquisition Editor
`Ruchita Bhansali
`
`Production Coordinator
`Shantanu N. Zagade
`
`Content Development Editor
`Sanjeet Rao
`
`Cover Work
`Shantanu N. Zagade
`
`Technical Editor
`Saurabh Malhotra
`
`Copy Editor
`Sneha Singh
`
`www.allitebooks.com
`
`4
`
`
`
`About the Author
`
`Albert Szmigielski is a thinker, a computing scientist, a software engineer, and a
`blockchain professional. He holds a BSc in Computer Science and an MSc in Digital
`Currency. He has been involved in a number of start-ups and software projects. He
`believes in a decentralized, distributed nature of storing information, and hence has
`an interest in Bitcoin and blockchain technology.
`
`Albert is a researcher at CryptoIQ and a mentor at the Blockchain Institute.
`He frequently contributes to his blog at blog.cryptoIQ.ca.
`
`I would like to thank Carla Miller for her support and general
`feedback. I would also like to thank my family; they give meaning to
`my life.
`
`www.allitebooks.com
`
`5
`
`
`
`About the Reviewer
`
`Kevin M. Fitzgerald is the platform architect for Okanjo.com. He has well over
`a decade of development experience in education, medical systems, and start-ups.
`He has been tinkering with the Web since dial-up modems went mainstream.
`
`He is active in the Open Source community and has contributed to the Mono project
`and also to Umbraco communities. He continues to be active on GitHub, working
`with the latest technologies and projects. He has also contributed to the book WebGL
`Game Development by Sumeet Arora.
`He and his wife, Luciana, are celebrating their seventh year of marriage and enjoy
`long walks on the beach with their daughter, Rosalia, talking about Node.js, C#,
`and Bitcoin.
`
`www.allitebooks.com
`
`6
`
`
`
`www.PacktPub.com
`
`eBooks, discount offers, and more
`
`Did you know that Packt offers eBook versions of every book published, with PDF
`and ePub files available? You can upgrade to the eBook version at www.PacktPub.com
`and as a print book customer, you are entitled to a discount on the eBook copy. Get in
`touch with us at customercare@packtpub.com for more details.
`
`At www.PacktPub.com, you can also read a collection of free technical articles, sign
`up for a range of free newsletters and receive exclusive discounts and offers on Packt
`books and eBooks.
`
`TM
`
`https://www2.packtpub.com/books/subscription/packtlib
`
`Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
`book library. Here, you can search, access, and read Packt's entire library of books.
`
`Why subscribe?
`• Fully searchable across every book published by Packt
`• Copy and paste, print, and bookmark content
`• On demand and accessible via a web browser
`
`www.allitebooks.com
`
`7
`
`
`
`Table of Contents
`
`v
`1
`1
`2
`2
`3
`3
`12
`13
`13
`14
`14
`14
`15
`15
`23
`25
`25
`29
`31
`32
`32
`32
`33
`34
`35
`
`Preface
`Chapter 1: Bitcoin Wallets and Mining Software
`Bitcoin wallets
`What is a Bitcoin wallet?
`Why do we need Bitcoin wallets?
`Types of wallets
`Software wallets
`Hardware wallets
`Full wallet versus thin client
`Hosted wallets
`Wallet security
`Mining software
`The need for mining software
`What does mining software do?
`Which mining software to choose?
`Summary
`Chapter 2: CPU Mining
`Mining with Bitcoin Core
`Mining software
`Let's start mining
`Pros and cons of mining
`Pros of mining
`Cons of mining
`Best practices when mining with CPUs
`Profitability of mining
`Summary
`
`[ i ]
`
`www.allitebooks.com
`
`8
`
`
`
`37
`37
`38
`39
`40
`40
`42
`44
`45
`46
`46
`46
`47
`48
`49
`49
`50
`51
`51
`52
`52
`53
`54
`55
`55
`55
`56
`56
`57
`57
`58
`59
`61
`62
`62
`62
`62
`64
`67
`69
`
`Table of Contents
`Chapter 3: GPU Mining
`Setting up a GPU for mining
`Drivers
`Mining software
`Windows installation instructions
`Linux installation instructions
`Let's start mining
`Multiple GPU setup
`Mining on a GPU
`Pros and cons of GPU mining
`Pros of GPU mining
`Cons of GPU mining
`Best practices when mining with GPUs
`Benchmarks of mining speeds with different GPUs
`GPU versus CPU mining
`Profitability of GPU mining
`Summary
`Chapter 4: FPGA Mining
`Setup and installation of the required software
`Mining software
`Linux installation instructions
`Windows installation instructions
`Let's start mining
`What happens when mining on a FPGA
`Pros and cons of FPGA mining
`Pros of FPGA mining
`Cons of FPGA mining
`Best practices when mining with FPGAs
`Benchmarks of mining speeds with different FPGAs
`FPGA versus GPU and CPU mining
`Profitability of FPGA mining
`Summary
`Chapter 5: ASIC Mining
`Setting up mining software
`Drivers
`Mining software
`Installing cgminer on Linux
`Installing cgminer on Windows
`Let's start mining
`What happens when mining on a ASIC
`
`[ ii ]
`
`www.allitebooks.com
`
`9
`
`
`
`Table of Contents
`70
`70
`70
`71
`72
`73
`73
`74
`75
`75
`76
`78
`79
`82
`83
`84
`85
`85
`85
`86
`86
`87
`87
`90
`90
`90
`90
`91
`91
`91
`92
`94
`94
`95
`95
`96
`96
`97
`
`Pros and cons of ASIC mining
`Pros of ASIC mining
`Cons of ASIC mining
`Best practices when mining with ASICs
`Benchmarks of mining speeds with different ASICs
`ASIC versus FPGA, GPU, and CPU mining
`Profitability of ASIC mining
`Summary
`Chapter 6: Solo Versus Pool Mining
`Solo mining
`Setting up a wallet for solo mining
`Setting up mining software for solo mining
`Setting up mining software for pool mining
`Pool mining discussion
`Mining pools
`Choosing a pool
`Solo versus pool mining
`Profitability
`Majority attack on Bitcoin
`51% attack
`Summary
`Chapter 7: Large Scale Mining
`Large Scale Mining overview
`Large Scale Mining challenges
`Inexpensive and reliable electricity
`Good network connectivity
`Access to latest hardware
`Stable political climate
`Bitcoin exchange rate
`Cooling of mining hardware
`Large Scale Mining operations
`BitFury
`KnC Miner
`21 INC
`Mega Big Power
`Genesis Mining
`Other mine operators
`Summary
`
`[ iii ]
`
`www.allitebooks.com
`
`10
`
`
`
`99
`99
`100
`100
`100
`101
`101
`101
`101
`102
`102
`102
`103
`103
`103
`103
`104
`104
`104
`104
`105
`105
`106
`106
`107
`109
`
`Table of Contents
`Chapter 8: The Future of Bitcoin Mining
`Overview of the current state of mining
`Further centralization of mining
`Hardware arms race
`Halving of the reward
`Consolidation, mergers, and acquisitions
`Bitcoin exchange rate
`Quantum computing and mining
`Cracking the security of SHA-256
`Centralization by region
`Governments adopting cryptocurrencies
`Decentralization of mining
`Mining chips everywhere
`21 INC and the Bitcoin Computer
`Mining devices as a source of heat
`The end of the ASIC arms race is near
`Decentralized mining is key
`Elimination of PoW
`Inefficiency of PoW
`Replacement of PoW
`Can we do without mining?
`Replacing or eliminating mining
`Efficiency of mining
`Possible ways that mining may change
`Summary
`Index
`
`[ iv ]
`
`11
`
`
`
`Preface
`
`Surely, by now you have heard of the phenomenon called Bitcoin. Is it digital money,
`is it a payment system, is it a network, or is it something else? The answer is yes
`to all the previous questions. Bitcoin is all of those and more. In this book, we will
`concentrate on the mining aspect of Bitcoin. Mining is how new bitcoins are created
`and how transactions are accepted into the Bitcoin blockchain. We will show you
`how to mine for yourself, if you are interested. We explain step-by-step what is
`necessary and how to do it. CPU, GPU, FPGA, and ASIC mining is also discussed.
`We will examine solo mining and pool mining. We will spend a little bit of time
`taking a look at large mining operations. Finally, we will speculate what the future
`may look like in the mining world of Bitcoin.
`
`What this book covers
`
`Chapter 1, Bitcoin Wallets and Mining Software, gives an overview of Bitcoin wallets:
`hardware, software, full and thin clients. The chapter also discusses mining software.
`Chapter 2, CPU Mining, looks at Bitcoin mining using a CPU. It covers everything you
`need to get started.
`Chapter 3, GPU Mining, concentrates on GPU mining. It covers GPU driver setup,
`mining software setup, and it touches upon practical mining issues. Examples
`are included.
`Chapter 4, FPGA Mining, examines FPGA mining, including software, drivers, and a
`discussion of best practices.
`Chapter 5, ASIC Mining, looks at ASIC mining in detail. We set up the software that is
`needed to mine and we show you practical examples of mining with ASICS.
`Chapter 6, Solo Versus Pool Mining, explains solo and pool mining and weighs the pros
`and cons of both ways of mining.
`
`[ v ]
`
`12
`
`
`
`Preface
`
`Chapter 7, Large Scale Mining, looks at mining as a business. There are a handful
`companies that decided to mine for profit. They represent the bleeding edge in
`mining techniques.
`Chapter 8, The Future of Bitcoin Mining, speculates how mining may evolve in the
`future. We look at the possibility of mining becoming more centralized and the
`possibility of mining becoming decentralized.
`
`What you need for this book
`
`You will need a computer, preferably running Linux, but Windows and OS X is fine
`as well. You will also need an internet connection. If you'd like to try mining with
`a GPU, FPGA, or ASIC, you would need to have one (or more) of those hardware
`pieces. All software is open source and can be downloaded from the internet. We
`provide links in the chapters to the required software.
`
`Who this book is for
`
`If you have never mined before, this book will ensure that you know what mining
`is all about. If you are familiar with Bitcoin mining, then it will help you to optimize
`your mining operations at a deeper level. A basic understanding of computers and
`operating systems is assumed and some familiarity with cryptocurrency basics
`would be an added advantage.
`
`Conventions
`
`In this book, you will find a number of text styles that distinguish between different
`kinds of information. Here are some examples of these styles and an explanation of
`their meaning.
`
`Code words in text, database table names, folder names, filenames, file extensions,
`pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "
`Execute the getmininginfo command in the console of the Bitcoin Core wallet."
`
`Any command-line input or output is written as follows:
`
`./minerd --url <poolurl:port> --userpass <USERNAME.WORKER:PASSWORD>
`-a<algorithm>
`
`[ vi ]
`
`13
`
`
`
`New terms and important words are shown in bold. Words that you see on
`the screen, for example, in menus or dialog boxes, appear in the text like this:
`"Now click on the Help menu and select Debug Window."
`
`Preface
`
`Warnings or important notes appear in a box like this.
`
`Tips and tricks appear like this.
`
`Reader feedback
`
`Feedback from our readers is always welcome. Let us know what you think about
`this book—what you liked or disliked. Reader feedback is important for us as it helps
`us develop titles that you will really get the most out of.
`
`To send us general feedback, simply e-mail feedback@packtpub.com, and mention
`the book's title in the subject of your message.
`
`If there is a topic that you have expertise in and you are interested in either writing
`or contributing to a book, see our author guide at www.packtpub.com/authors.
`
`Customer support
`
`Now that you are the proud owner of a Packt book, we have a number of things to
`help you to get the most from your purchase.
`
`Downloading the color images of this book
`We also provide you with a PDF file that has color images of the screenshots/
`diagrams used in this book. The color images will help you better understand the
`changes in the output. You can download this file from http://www.packtpub.com/
`sites/default/files/downloads/BitcoinEssentials_ColorImages.pdf.
`
`[ vii ]
`
`14
`
`
`
`Preface
`
`Errata
`Although we have taken every care to ensure the accuracy of our content, mistakes
`do happen. If you find a mistake in one of our books—maybe a mistake in the text or
`the code—we would be grateful if you could report this to us. By doing so, you can
`save other readers from frustration and help us improve subsequent versions of this
`book. If you find any errata, please report them by visiting http://www.packtpub.
`com/submit-errata, selecting your book, clicking on the Errata Submission Form
`link, and entering the details of your errata. Once your errata are verified, your
`submission will be accepted and the errata will be uploaded to our website or added
`to any list of existing errata under the Errata section of that title.
`
`To view the previously submitted errata, go to https://www.packtpub.com/books/
`content/support and enter the name of the book in the search field. The required
`information will appear under the Errata section.
`
`Piracy
`Piracy of copyrighted material on the Internet is an ongoing problem across all
`media. At Packt, we take the protection of our copyright and licenses very seriously.
`If you come across any illegal copies of our works in any form on the Internet, please
`provide us with the location address or website name immediately so that we can
`pursue a remedy.
`
`Please contact us at copyright@packtpub.com with a link to the suspected
`pirated material.
`
`We appreciate your help in protecting our authors and our ability to bring
`you valuable content.
`
`Questions
`If you have a problem with any aspect of this book, you can contact us at
`questions@packtpub.com, and we will do our best to address the problem.
`
`[ viii ]
`
`15
`
`
`
`Bitcoin Wallets and
`Mining Software
`
`In this chapter, we will take a look at the various Bitcoin wallets available, explore
`the mining software that is currently available, review the functions that Bitcoin
`wallets perform, and why we need them. We will take a brief look at both software
`and hardware wallets. The difference between full wallets and thin client wallets
`will also be explored. We will also touch upon hosted wallets and look into
`wallet security.
`
`Next, we will take a brief look at mining software and examine why the software is
`needed and what it does. Finally, we will quickly review what mining software is
`available to us and which software we should use. Keep in mind that the material
`presented in this chapter will be brief and serve only as a review of the basics:
`
`• Bitcoin wallets
`• Types of wallets
`• Wallet security
`• Mining software
`
`Bitcoin wallets
`
`In this section, we will take a closer look at Bitcoin wallets. We will define what a
`wallet is and explain why we need a wallet. We will look at the types of wallets
`available. There are software and hardware wallets, full wallets, and the so-called
`thin wallets. There are also hosted wallets that are run by companies for the users'
`convenience. We will look at the most popular wallet called Bitcoin Core; finally,
`we will touch upon wallet security.
`
`[ 1 ]
`
`16
`
`
`
`Bitcoin Wallets and Mining Software
`
`What is a Bitcoin wallet?
`A Bitcoin wallet (sometimes called a client) is a software that facilitates performing
`bitcoin transactions. Wallets come in different flavors. The most capable of them are
`called full clients. They can perform bitcoin transactions and act as a gateway to the
`Bitcoin network. Full clients also store a copy of the Bitcoin block chain locally.
`An example of a full client is the Bitcoin Core software application.
`
`Definition
`Block chain: The Bitcoin database that stores all the transaction data is
`called a block chain. The transactions are grouped together in batches for
`efficiency reasons. A batch is called a block and each block (except for the
`first, called genesis block) has a link to the previous block. This linking
`together of blocks is the chain part of the block chain.
`
`A wallet allows us to send (spend) and receive bitcoins. These are the main
`transactions that most users will perform. Most importantly, a wallet stores your
`secret private keys, so that you can access the bitcoins you own. The name "wallet"
`is slightly misleading. The wallet actually does not store bitcoins directly. All the
`bitcoins are stored on the block chain and the wallet software simply allows you to
`transact with the bitcoins that the private keys stored in the wallet have control over.
`In simpler terms, wallets store private keys. Those keys are tied to bitcoins on the
`block chain and therefore you can send them to another address.
`
`A wallet also allows us to look into the Bitcoin network and see additional details.
`It allows us to see information about the Bitcoin network, the block chain, mining,
`and the wallet in general. We will go over these in later chapters.
`
`Why do we need Bitcoin wallets?
`As mentioned earlier, wallets facilitate Bitcoin transactions. Without them, moving
`bitcoins from one address to another would be impossible. It is worth noting that a
`wallet is a fundamental piece of Bitcoin software. A wallet is the required software
`in order for the Bitcoin network to exist.
`
`Without the ability to transfer bitcoins, the system would not be very useful. In the
`original wallet called bitcoind, the transactions had to be put together manually.
`Later on, the wallet software was expanded and updated to make transaction
`creation seem like a breeze. Since wallets connect us to the Bitcoin network, they
`are also needed in mining operations. While mining, it is the wallet software that
`communicates with the Bitcoin network. It watches out for new blocks, so that if a
`new block is found by some other participant, our mining software can stop working
`on the now solved block and move on to the next.
`
`[ 2 ]
`
`17
`
`
`
`Chapter 1
`
`The transactions that our mining software will put in a candidate block also come
`from the wallet. In addition, wallets verify found blocks and propagate transactions
`that come onto the network.
`
`Types of wallets
`
`Wallets have come a long way since the original came out in 2009. There are now
`software wallets, hardware wallets, paper wallets, hosted wallets, and, of course,
`there are innovative companies who constantly think up new ways to create wallets.
`
`Software wallets
`There are a variety of software wallets. For an up-to-date list of the most popular
`wallets, see https://bitcoin.org/en/choose-your-wallet. We will concentrate
`here on the Bitcoin Core software application. At the time of writing this book,
`the current version is 0.11.2. You can always check the latest version here:
`https://bitcoin.org/en/download.
`
`If you do not have Bitcoin Core installed and you would like to mine solo (solo
`mining will be explained in Chapter 6, Solo Versus Pool Mining), it would be a good
`idea to download and install it. Make sure that you have sufficient space on your
`hard drive for the block chain, which currently (Feb 2016) is about 55 GB. Once you
`install Bitcoin Core, it will proceed to download the block chain, which may take a
`while. When you open the software, you will be greeted with the following screen:
`
`Fig. 1.1: The Bitcoin Core wallet.
`
`[ 3 ]
`
`18
`
`
`
`Bitcoin Wallets and Mining Software
`
`As you can see, the client is downloading the block chain by synchronizing with
`the Bitcoin network. There are tabs to send and receive bitcoins. There is also a
`Transactions tab, under which you can find a history of all transactions performed
`with the wallet.
`
`Fig. 1.2: Send tab in the Bitcoin Core wallet.
`
`The Send tab can be used to transfer the bitcoins you control to another address.
`It requires a destination Bitcoin address and the amount you wish to transfer. If
`your wallet is password-protected (more on securing your wallet later), you will be
`prompted to enter it.
`
`[ 4 ]
`
`19
`
`
`
`Chapter 1
`
`Fig. 1.3: Receive tab in the Bitcoin Core wallet.
`
`The Receive screen, on entering the relevant information and pressing Request
`payment, will generate a QR code and a URI that can be sent out or posted online.
`
`Fig. 1.4: Request payment screen, generated by Bitcoin Core
`
`[ 5 ]
`
`www.allitebooks.com
`
`20
`
`
`
`Bitcoin Wallets and Mining Software
`
`The Transactions tab lists all the transactions tied to the private keys that the wallet
`is storing.
`
`Fig. 1.5: The Transactions tab in Bitcoin Core
`
`The functions described in the preceding section are the basic wallet transaction
`types, but what is more interesting is the information we can get about the network
`through the Bitcoin console. The console can be accessed by going to the Help menu
`and selecting Debug window.
`
`Fig. 1.6: Debug window of Bitcoin Core
`
`[ 6 ]
`
`21
`
`
`
`Select the Console tab and you will be able to obtain a trove of information about the
`Bitcoin network and about Bitcoin's block chain. To see a list of possible commands,
`type help into the console and press Enter. You will be presented with a long list
`of commands that have been grouped in categories. A complete overview of the
`commands is beyond the scope of this book. However, we will take a look at some
`of them.
`
`Chapter 1
`
`[ 7 ]
`
`22
`
`
`
`Bitcoin Wallets and Mining Software
`
`[ 8 ]
`
`23
`
`
`
`Chapter 1
`
`Fig. 1.7: A listing of all available commands
`
`[ 9 ]
`
`24
`
`
`
`Bitcoin Wallets and Mining Software
`
`Perhaps, the most interesting to us will be the getmininginfo command. Typing it
`into the console yields the following:
`
`Fig. 1.8: The getmininginfo command
`
`As we can see, the command returns the last block number, current mining difficulty,
`network hashing speed, and some other information as well. There are websites that
`check this information for each block and offer graphs to visualize the data. They
`are called block explorers and there are many of them. The most popular perhaps
`is http://blockchain.info.
`
`[ 10 ]
`
`25
`
`
`
`You can find out more information about any command by typing help followed
`by the command name. For example, to find out more about the getmininginfo
`command, we will type help getmininginfo:
`
`Chapter 1
`
`Fig. 1.9: Getting more information about a command: help getmininginfo
`
`[ 11 ]
`
`26
`
`
`
`Bitcoin Wallets and Mining Software
`
`Another interesting command from a mining point of view is the getblockchaininfo
`command. The following screenshot shows us the output and the help data on
`that command:
`
`Fig. 1.10: Output of the getblockchain info command and help getblockchain info
`
`Hardware wallets
`Hardware wallets are a relatively new addition to the array of Bitcoin wallets
`available. They are not required for mining purposes, but are great for keeping your
`bitcoins safe. The two most popular solutions on the market are Trezor and Ledger
`wallets. We encourage you to take a look at their respective websites, if you think
`you can benefit from a hardware wallet.
`
`[ 12 ]
`
`27
`
`
`
`Chapter 1
`
`Outside resources
`Trezor website: https://www.bitcointrezor.com/
`Ledger website: https://www.ledgerwallet.com/
`
`The major advantage of hardware wallets over software ones is their security.
`They are not affected by computer viruses designed to attack software wallets.
`They are offline for a majority of the time (online only to compose a transaction).
`They also enjoy an advantage over paper wallets, as a result of being interactive
`versus importing the whole wallet, as in the case of a paper wallet.
`
`Full wallet versus thin client
`Any wallet that stores the entire block chain database is regarded as a full wallet,
`Bitcoin Core is one example. Sometimes there just aren't enough resources available
`to download and store the complete block chain. This could be due to bandwidth
`restrictions, storage limitations, or perhaps just an unwillingness to run the
`full wallet.
`
`There are wallets available that do not download the entire block chain. This is
`obviously required for mobile computers with limited storage, such as smart phones
`and tablets and other Internet-of-things devices. These types of wallets are called thin
`clients. They use a procedure called Simplified Payment Verification (SPV) to avoid
`having a full copy of the block chain. SPV is not important for mining purposes, but
`every miner should at least know that the security of an SPV wallet is not as tight as
`the security of a full wallet.
`
`Hosted wallets
`There are a number of companies that offer hosted wallet services. This means that
`you do not need to download or install any software and of course downloading the
`block chain is also not required. There is a trade-off when you use a hosted wallet.
`You are giving away a part of the security that comes with running your own wallet
`in exchange for convenience.
`
`However, as these hosted wallet companies are maturing and becoming big,
`their ways of securing bitcoins may be better than that of a single user. The risk
`of insolvency is then the biggest risk to a hosted wallet user. If the company goes
`bankrupt, then the funds stored in their hosted wallets will most likely not be
`recoverable. Just like with a traditional bank, deposits are liabilities of the bank and
`in the case of failure, depositors would only be able to recover the portion of their
`deposits that is insured by the government. We are not aware of any such insurance
`schemes available to hosted wallet providers.
`[ 13 ]
`
`28
`
`
`
`Bitcoin Wallets and Mining Software
`
`Wallet security
`Securing your wallet is a serious matter. With Bitcoin being deflationary, the value
`of the cryptocurrency is expected to rise in the long term. Therefore, making sure
`that your funds are only accessible to you is a worthwhile undertaking. Your online
`wallet should be encrypted and password-protected. Furthermore, you should
`back-up your password protected wallet to multiple locations.
`To encrypt your wallet, select Encrypt Wallet from the Settings menu in Bitcoin
`Core and then follow the rest of the instructions. Please remember to choose a
`very strong password.
`
`Make sure to use upper- and lower-case characters; also add
`some special characters and make the password long (min. 10
`characters). It is also possible to make a passphrase out of ten
`(or more) random words. It will be beneficial if those words are
`not in a dictionary (use misspellings or combination words).
`Finally, it is a good idea to only keep a small amount of bitcoins
`in your online wallet. The bulk of your holdings should be kept
`offline. A full discussion of securing your wallet is impossible
`here. We do encourage you to find resources online to educate
`yourself more about this topic.
`
`Mining software
`
`Let's now look at mining software. At the very beginning, mining software was
`built into the wallet software. Mining used only a single core of a CPU back then.
`Nowadays, there are a variety of devices that can perform the mining function. As
`such, there is some software needed to coordinate and manage the work done by
`these devices.
`
`The need for mining software
`As mentioned earlier, mining software coordinates and manages the work of
`different mining devices. In order for mining to move beyond utilizing a single
`core of a CPU, software was needed that could manage the work that multiple cores
`perform. This is to make sure that they do not do redundant work; hence, mining
`software was born. Later on, mining moved onto a multitude of devices and the
`need for a management software became even more apparent.
`
`[ 14 ]
`
`29
`
`
`
`Chapter 1
`
`What does mining software do?
`Bitcoin mining is basically a guessing game. The software constructs a candidate
`block. A candidate block includes the hash of the previous (last) block and it also
`includes transactions taken from the pending transaction pool. Finally, it includes
`the most important piece, called a nonce. A nonce is basically a counter. The software
`constructs the candidate block and then hashes it. If the result does not meet the
`difficulty criteria, then the nonce is incremented and another hash is taken.
`
`Mining devices can make billions and even trillions of these hashes per second.
`When a successful hash is found, the software submits the solved block to the
`network for verification. We call this guessing rather than solving because solving
`implies a method other than repeated guessing and checking if it is correct.
`
`Which mining software to choose?
`There are a variety of different software miners. A good comprehensive list can be
`found at: https://en.bitcoin.it/wiki/Mining_software. The two most popular
`miners are cgminer and bfgminer; both are open source and can be downloaded
`from GitHub. Here, we will concentrate on cgminer.
`
`Cgminer can be downloaded from a variety of sources on the Internet. We
`recommend going directly to the developer's website: http://ck.kolivas.org/
`apps/cgminer/.
`
`Cgminer is available for Windows and Linux systems and it can also be built from
`source for Mac OS; there are also third party providers that host a compiled Mac
`OS version on their websites. Download the appropriate version for your system.
`Installation on Windows systems is straightforward. As an example, we are going to
`use cgminer version 3.7.2. This is the last version to support GPU mining; keep this
`in mind if you want to mine with your GPUs. (We will further discuss the versions of
`cgminer in the chapters on mining with specific devices.)
`
`Defintion
`GPU: Graphics Processing Unit is a processor designed specifically
`for processing and displaying graphics on a computer screen.
`
`[ 15 ]
`
`www.allitebooks.com
`
`30
`
`
`
`Bitcoin Wallets and Mining Software
`
`Once you have cgminer installed, you may want to verify it by running the
`cgminer -n command in your terminal (also called command prompt in
`Windows). The output will look similar to this:
`
`Fig. 1.11: Output from the cgminer -n command
`
`It lists the required software (OpenCL in our case) and confirms that cgminer found
`some hardware in your system that it can use to mine. In our case, it is an AMD R9
`Radeon GPU.
`
`Now would be a good time to start cgminer and familiarize ourselves with the basic
`features. In order to run cgminer, we need to tell it where to get work from. This
`means a mining pool or your local wallet if you are mining solo (more on this will
`follow in the chapters on mining solo or with a pool).
`
`Definition
`Mining pool: Bitcoin mining is very competitive and in order to have
`a better chance at being successful, individual miners combine their
`resources together and form groups, also called pools. Such a combined
`mining group is called a mining pool. A quick Internet search will show
`that there are a number of mining pools out there.
`
`If you are already registered with a pool, run the following command to start mining:
`
`cgminer -o <http://pool:port> -u <username> -p <password>
`
`This tells cgminer to connect to the specified pool with the specified credentials (of
`course, replace the values in the angle brackets with your own pool information).
`
`[ 16 ]
`
`31
`
`
`
`If successful, cgminer will start and display the following screen:
`
`Chapter 1
`
`Fig. 1.12: Starting cgminer
`
`As we can see, cgminer is running and it is connected to the pool we specified.
`
`We will now briefly review the options that cgminer offers while it's running.
`
`[ 17 ]
`
`32
`
`
`
`Bitcoin Wallets and Mining Software
`
`There are menu items for: Pool management, GPU management, Settings, and
`Display options. Let's examine them a little more closely. To get into a menu item,
`simply press the letter that corresponds to the item in question. The letters are
`wrapped in square brackets to indicate that they can be selected.
`The following is the screenshot of Pool management:
`
`Fig. 1.13: Po