0% found this document useful (0 votes)
12 views118 pages

Module-3 Bit Coin Introduction

The document provides an introduction to Bitcoin, detailing its origins, underlying technology, and key components such as digital keys, addresses, transactions, and the blockchain. It explains how Bitcoin operates as a decentralized digital currency and the processes involved in sending payments, including transaction validation by miners. Additionally, it discusses the roles of private and public keys, transaction fees, and the importance of the consensus mechanism in maintaining the Bitcoin network.

Uploaded by

athmika.cs22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views118 pages

Module-3 Bit Coin Introduction

The document provides an introduction to Bitcoin, detailing its origins, underlying technology, and key components such as digital keys, addresses, transactions, and the blockchain. It explains how Bitcoin operates as a decentralized digital currency and the processes involved in sending payments, including transaction validation by miners. Additionally, it discusses the roles of private and public keys, transaction fees, and the importance of the consensus mechanism in maintaining the Bitcoin network.

Uploaded by

athmika.cs22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 118

MODULE-3

Bit Coin Introduction

Dr. Poornima B V
Assistant Professor,
Computer Science and Engineering,
Sahyadri College of Engineering and Management,
Adyar, Mangalore-575007.
Email: [email protected]
1
Introducing Bitcoin
• Bitcoin is the first application of blockchain technology.
• In 2008, Bitcoin was introduced through a paper called, Bitcoin: A Peer-to-Peer
Electronic Cash System.
• Bitcoin is built on decades of cryptographic research such as the research in Merkle
trees, hash functions, public key cryptography, and digital signatures.
• The original idea behind Bitcoin was to develop an e-cash system which requires no
trusted third party and users can be anonymous.
• If regulations require Know Your Customer (KYC) checks and detailed information
about business transactions to facilitate regulatory process then it might be too
much information to share and as a result Bitcoin may not be attractive anymore to
some.

3
Bitcoin definition

• Bitcoin can be defined in various ways; it's a protocol, a digital currency, and a
platform.
• It is a combination of peer-to-peer network, protocols, software that facilitate
the creation and usage of the digital currency named bitcoin.
• Nodes in this peer-to-peer network talk to each other using the Bitcoin protocol.
• Note that Bitcoin with a capital B is used to refer to the Bitcoin protocol, whereas
bitcoin with a lowercase b is used to refer to bitcoin, the currency.

7
• Decentralization of currency was made possible for the first time with the
invention of bitcoin.
• Double spending problem arises when, for example, a user sends coins to two
different users at the same time and they are verified independently as valid
transactions.
• The double spending problem is resolved in Bitcoin by using a distributed ledger
(blockchain) where every transaction is recorded permanently and by
implementing transaction validation and confirmation mechanism.
Bitcoin – a bird's-eye view
First, let us see that what the main components of a Bitcoin network are. Bitcoin is
composed of the elements listed here.
1. Digital keys
2. Addresses
3. Transactions
4. Blockchain
5. Miners
6. The Bitcoin network
7. Wallets (client software)

12
Sending a payment to someone (Example)
• First, either the payment is requested from a user by sending his Bitcoin
address to the sender via email or some other means such as SMS, chat
applications or in fact any appropriate communication mechanism.
• The sender can also initiate a transfer to send money to another user. In both
cases, the address of beneficiary is required. As an example, the Blockchain
wallet is shown here where a payment request is created:

14
15
• The sender either enters the receiver's address or scans the QR code that has
the Bitcoin address, amount and optional description encoded in it.
• The wallet application recognizes this QR code and decodes it into something
like Please send <Amount> BTC to the Bitcoin address <receiver's Bitcoin
address>.
• This will look like as shown here with values: Please send 0.00033324 BTC to
the Bitcoin address 1JzouJCVmMQBmTcd8K4Y5BP36gEFNn1ZJ3.

16
• This is also shown in the screenshot presented here:

17
• This transaction is digitally signed using the private key of the sender
before broadcasting it. From a user's point of view, once the QR code is
decoded the transaction will appear similar to what is shown in the
following screenshot:

18
19
• At this stage, the transaction has been constructed, signed and sent out to the
Bitcoin network.
• This transaction will be picked up by miners to be verified and included in the
block.
• Also note that in the preceding screenshot, confirmation is pending for this
transaction.
• These confirmations will start to appear as soon as the transaction is verified,
included in the block, and mined.

20
21
Transaction flow visualization (Blockchain.info)

22
The payment transaction in the Bitcoin network can be divided into the following steps:

1. Transaction starts with a sender signing the transaction with their


private key
2. Transaction is serialized so that it can be transmitted over the network
3. Transaction is broadcasted to the network
4. Miners listening for the transactions picks up the transaction
5. Transaction are verified for their validity by the miners
6. Transaction are added to the candidate/proposed block for mining
7. Once mined, the result is broadcasted to all nodes on the Bitcoin
network

23
Summary

• 1. How Bitcoins Are Generated


• 2. Who Controls Bitcoin?
• 3. What Is the Value of Bitcoin?
• 4. How to Purchase Bitcoin?
• 5. Is Bitcoin Legal?
Bitcoin is Controlled By:
• The Code (Bitcoin Protocol)
• Open-source software (e.g., Bitcoin Core) defines the rules.
• Anyone can read, propose changes, or run the software.
• The Community (Consensus-Based System)
• Decisions about updates or changes are made by:
• Developers
• Miners
• Node operators
• Users
• All must agree on rule changes (this is called consensus).
• Miners
• They maintain and secure the network by verifying transactions and adding
blocks.
• But they can’t make arbitrary changes—everyone must agree.
• Nodes
• These are thousands of computers around the world that store a full copy of
the Bitcoin blockchain.
• They verify every transaction and block based on the rules of the protocol.
Digital keys and addresses
• On the Bitcoin network, possession of bitcoins and transfer of value via transactions is
reliant upon private keys, public keys, and addresses.
• Elliptic Curve Cryptography (ECC) is used to generate public and private key pairs in the
Bitcoin network.

27
Private keys in Bitcoin
• Private keys are required to be kept safe and normally resides only on the owner's
side. Private keys are used to digitally sign the transactions proving the ownership of
the bitcoins.
• Private keys are fundamentally 256-bit numbers randomly chosen in the range.
• Any randomly chosen 256-bit number from 0x1 to 0xFFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 is a valid
private key.
• Private keys are usually encoded using Wallet Import Format (WIF) in order to
make them easier to copy and use. It is a way to represent the full size private key in a
different format. WIF can be converted into a private key and vice versa.

28
• The following is an example of a private key:
A3ED7EC8A03667180D01FB4251A546C2B9F2FE33507C68B7D9D4E1FA571419520
1
• When it is converted into WIF format it looks like this:
L2iN7umV7kbr6LuCmgM27rBnptGbDVc8g4ZBm6EbgTPQXnj1RCZP

29
Public keys in Bitcoin
• Public keys exist on the blockchain and all network participants can see it.
• Public keys are derived from private keys due to their special mathematical
relationship with the private keys.
• Once a transaction signed with the private key is broadcasted on the Bitcoin
network, public keys are used by the nodes to verify that the transaction has indeed
been signed with the corresponding private key. This process of verification proves
the ownership of the bitcoin.
• A public key is 256-bits in length. Public keys can be represented in an uncompressed
or compressed format.
• Public keys are fundamentally x and y coordinates on an elliptic curve.

30
Addresses in Bitcoin
• A bitcoin address is created by taking the corresponding public key of a private key
and hashing it twice, first with the SHA-256 algorithm and then with RIPEMD-160.
• The resultant 160-bit hash is then prefixed with a version number and finally encoded
with a Base58Check encoding scheme.
• The bitcoin addresses are 26-35 characters long and begin with digit 1 or 3.
• A typical bitcoin address looks like a string shown here:
1ANAguGG8bikEv2fYsTBnRUmx7QUcK58wt

31
• A Bitcoin address is a unique identifier used to receive Bitcoin payments. It acts
like a bank account number but is generated cryptographically.
• Format: A Bitcoin address is typically 26-35 characters long and consists of letters
and numbers.
Types of Addresses:
• P2PKH (Pay-to-PubKey Hash): Starts with 1 (e.g.,
1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa).
• P2SH (Pay-to-Script Hash): Starts with 3 (e.g.,
3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy).Bech32 (SegWit Address):
• Starts with bc1 (e.g., bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf0hl0).
• Private & Public Keys: A Bitcoin address is derived from a public key, which in turn
is generated from a private key. The private key must be kept secure, as it allows
access to the Bitcoin associated with that address.
• Use: A Bitcoin address is used to send and receive BTC. Once used, it’s
recommended to generate a new address for better privacy.
• This is also commonly encoded in a QR code for easy distribution. The QR code of
the preceding bitcoin address is shown in the following screenshot:

QR code of a bitcoin address


1ANAguGG8bikEv2fYsTBnRUmx7QUcK58wt

34
Vanity addresses
• As bitcoin addresses are based on base-58 encoding, it is possible to generate
addresses that contain human readable messages. An example is shown as
follows:

A vanity address in Bitcoin is a type of Bitcoin address that includes a custom, user-defined pattern or
text at the beginning of the address. This pattern can be anything you choose, like a name, word, or any
combination of characters, making the address more recognizable or personalized.
• Vanity addresses are generated using a purely brute-force method.
• An example of a paper wallet with vanity address is shown in the following
screenshot:
Multi-signature addresses

• As the name implies, these addresses require multiple private keys. In practical
terms, it means that in order to release the coins a certain set of signatures is
required. This is also known as M-of-N MultiSig.
• Here M represents threshold or the minimum number of signatures required
from N number of keys to release the bitcoins.

A multi-signature (multi-sig) address in Bitcoin is a type of address that requires


multiple private keys to authorize a transaction. This adds an extra layer of security,
making it harder for a single person to control the funds.
Transactions
• Transactions are at the core of the bitcoin ecosystem.
• Transactions can be as simple as just sending some bitcoins to a bitcoin address, or it
can be quite complex depending on the requirements.
• Each transaction is composed of at least one input and output.

38
• Inputs can be thought of as coins being spent that have been created in a
previous transaction and outputs as coins being created.
• If a transaction is to send coins to some other user (a bitcoin address), then it
needs to be signed by the sender with their private key and a reference is also
required to the previous transaction in order to show the origin of the coins.
• Transactions are not encrypted and are publicly visible in the blockchain. Blocks
are made up of transactions and these can be viewed using any online
blockchain explorer.
The transaction life cycle
1. A user/sender sends a transaction using wallet software or some other
interface.
2. The wallet software signs the transaction using the sender's private key.
3. The transaction is broadcasted to the Bitcoin network using a flooding algorithm.

40
4. Mining nodes (miners) who are listening for the transactions verify and include
this transaction in the next block to be mined. Just before the transactions are
placed in the block they are placed in a special memory buffer called transaction
pool.
5. Mining starts, which is a process by which the blockchain is secured and new
coins are generated as a reward for the miners who spend appropriate
computational resources.
6. Once a miner solves the PoW problem it broadcasts the newly mined block to
the network.
• The nodes verify the block and propagate the block further, and confirmations
start to generate.
• Finally, the confirmations start to appear in the receiver's wallet and after
approximately three confirmations, the transaction is considered finalized and
confirmed.
• However, three to six is just a recommended number; the transaction can be
considered final even after the first confirmation.
• The key idea behind waiting for six confirmations is that the probability of
double spending is virtually eliminated after three confirmations.

42
Transaction life-cycle in Blockchain
43
Transaction fee

• Transaction fees are charged by the miners.

• The fee charged is dependent upon the size and weight of the transaction.

• Transaction fees are calculated by subtracting the sum of the inputs and the sum of the
outputs.

• A simple formula can be used:


fee = sum(inputs) - sum(outputs)
• The fees are used as an incentive for miners to encourage them to include a user
transaction in the block the miners are creating.
• All transactions end up in the memory pool, from where miners pick up transactions
based on their priority to include them in the proposed block.

45
• A transaction with a higher fee will be picked up sooner by the miners.

• There are different rules based on which fee is calculated for various types of actions,
such as sending transactions, inclusion in blocks, and relaying by nodes.

• Fees are not fixed by the Bitcoin protocol and are not mandatory; even a transaction
with no fee will be processed in due course but may take a very long time.

• This is however no longer practical due to the high volume of transactions and
competing investors on the Bitcoin network, therefore it is advisable to provide a fee
always.

46
• The time for transaction confirmation usually ranges from 10 minutes to over 12
hours in some cases.

• Transaction time is dependent on transaction fees and network activity.

• If the network is very busy then naturally transactions will take longer to process and
if you pay a higher fee then your transaction is more likely to be picked by miners first
due to additional incentive of the higher fee.

47
Transaction pools

• Also known as memory pools, these pools are basically created in local memory
(computer RAM) by nodes in order to maintain a temporary list of transactions
that are not yet confirmed in a block.
• Transactions are included in a block after passing verification and based on their
priority.
The transaction data structure
• A transaction at a high level contains metadata, inputs, and outputs. Transactions
are combined to create a block.
The script language

• Bitcoin uses a simple stack-based language called script to describe how bitcoins
can be spent and transferred.
• It is not Turing complete and has no loops to avoid any undesirable effects of
long-running/hung scripts on the Bitcoin network.
• This scripting language is based on a Forth programming language like syntax and
uses a reverse polish notation in which every operand is followed by its
operators. It is evaluated from the left to the right using a Last In, First Out (LIFO)
stack.
• Scripts use various opcodes or instructions to define their operation. Opcodes are
also known as words, commands, or functions.
Types of transactions
Types of transactions
• Standard transactions are evaluated using IsStandard() and IsStandardTx() tests
and only standard transactions that pass the test are generally allowed to be
mined or broadcasted on the Bitcoin network.
• Pay to Public Key Hash (P2PKH): P2PKH is the most commonly used transaction
type and is used to send transactions to the bitcoin addresses. The format of the
transaction is shown as follows:
ScriptPubKey: OP_DUP OP_HASH160 <pubKeyHash>
OP_EQUALVERIFY OP_CHECKSIG
ScriptSig: <sig> <pubKey>
• The ScriptPubKey and ScriptSig parameters are concatenated together and
executed.

54
• MultiSig (Pay to MultiSig): M-of-N MultiSig transaction script is a complex type of
script where it is possible to construct a script that required multiple signatures to
be valid in order to redeem a transaction. Various complex transactions such as
escrow and deposits can be built using this script.
The template is shown here:
ScriptPubKey: <m> <pubKey> [<pubKey> . . . ] <n> OP_CHECKMULTISIG
ScriptSig: 0 [<sig > . . . <sign>]
• Pay to Pubkey: This script is a very simple script that is commonly used in coin
base transactions. It is now obsolete and was used in an old version of bitcoin. The
public key is stored within the script in this case, and the unlocking script is
required to sign the transaction with the private key.
The template is shown as follows:
<PubKey> OP_CHECKSIG

55
• Null data/OP_RETURN: This script is used to store arbitrary data on the blockchain for a
fee. The limit of the message is 40 bytes. The output of this script is unredeemable
because OP_RETURN will fail the validation in any case. ScriptSig is not required in this
case.
The template is very simple and is shown as follows:
OP_RETURN <data>

56
A P2PKH script execution

57
Coinbase transactions

• A coinbase transaction or generation transaction is always created by a miner and


is the first transaction in a block.
• It is used to create new coins. It includes a special field, also called coinbase,
which acts as an input to the coinbase transaction.
• This transaction also allows up to 100 bytes of arbitrary data that can be used to
store arbitrary data.
• A coinbase transaction input has the same number of fields as usual transaction
input, but the structure contains coinbase data size and coinbase data fields
instead of unlocking script size and unlocking script fields.
• Also, it does not have a reference pointer to the previous transaction.
• This structure is shown in the following table:
Contracts

• As defined in the Bitcoin core developer guide, contracts are basically transactions that
use the Bitcoin system to enforce a financial agreement.
• This is a simple definition but has far-reaching consequences as it allows users to design
complex contracts that can be used in many real-world scenarios.
• Contracts allow the development of a completely decentralized, independent, and
reduced risk platform.
• Various contracts, such as escrow, arbitration, and micropayment channels, can be built
using the Bitcoin scripting language.
The structure of a block
• As shown in the following diagram, blockchain is a chain of blocks where each
block is linked to its previous block by referencing the previous block header's
hash.
• This linking makes sure that no transaction can be modified unless the block that
records it and all blocks that follow it are also modified.
• The first block is not linked to any previous block and is known as the genesis
block
A visualization of the blockchain, block, block header, transactions and scripts
• The preceding diagram shows a high-level overview of the Bitcoin blockchain.
• On the left-hand side blocks are shown starting from top to bottom. Each block
contains transactions and block headers which are further magnified on the right-
hand side.
• On the top, first, block header is expanded to show various elements within the
block header.
• Then on the right-hand side the Merkle root element of the block header is
shown in magnified view which shows that how Merkle root is calculated.
The genesis block

• This is the first block in the Bitcoin blockchain.


• The genesis block was hardcoded in the bitcoin core software.
• Bitcoin provides protection against double spending by enforcing strict rules on
transaction verification and via mining.
• Block height is the number of blocks before a particular block in the blockchain.
• The current height (as of March 6, 2018) of the blockchain is 512,328 blocks.
• PoW is used to secure the blockchain.
• Each block contains one or more transactions, out of which the first transaction is a
coinbase transaction.

70
71
72
Mining

• Mining is a process by which new blocks are added to the blockchain.


• Blocks contain transactions that are validated via the mining process by mining nodes
on the Bitcoin network.
• Blocks, once mined and verified are added to the blockchain which keeps the
blockchain growing.
• This process is resource-intensive due to the requirements of PoW where miners
compete in order to find a number which is less than the difficulty target of the
network.
• This difficulty in finding the correct value (also called sometimes the mathematical
puzzle) is there to ensure that the required resources have been spent by miners
before a new proposed block can be accepted.

73
74
Proof of Work (PoW)

• This is a proof that enough computational resources have been spent in order to
build a valid block.
• PoW is based on the idea that a random node is selected every time to create a new
block.
• In this model, nodes compete with each other in order to be selected in proportion
to their computing capacity. The following equation sums up the PoW requirement in
bitcoin:
• H ( N || P_hash || Tx || Tx || . . . Tx) < Target
• Where N is a nonce, P_hash is a hash of the previous block, Tx represents
transactions in the block, and Target is the target network difficulty value. This
means that the hash of the previously mentioned concatenated fields should be less
than the target hash value.

75
The Bitcoin network

• The Bitcoin network is a peer-to-peer network where nodes exchange transactions and
blocks.
• There are different types of nodes on the network. There are two main types of nodes,
full nodes and SPV nodes.
• Full nodes, as the name implies, are implementations of Bitcoin core clients performing
the wallet, miner, full blockchain storage, and network routing functions.
• Simple Payment Verification (SPV) nodes or lightweight clients perform only wallet and
network routing functionality.
• The latest version of Bitcoin protocol is 70015 and was introduced with Bitcoin core
client 0.13.2.

76
• The Bitcoin network is identified by its different magic values. A list is shown as
follows:

Magic values are used to indicate the message origin network


• The most commonly used protocol messages and their explanation are listed as
follows:
• version: This is the first message that a node sends out to the network,
advertising its version and block count. The remote node then replies with the
same information and the connection is then established.
• verack: This is the response of the version message accepting the connection
request.
• inv: This is used by nodes to advertise their knowledge of blocks and transactions.
getdata: This is a response to inv, requesting a single block or transaction
identified by its hash.
• getblocks: This returns an inv packet containing the list of all blocks starting after
the last known hash or 500 blocks.
• getheaders: This is used to request block headers in a specified range.
• tx: This is used to send a transaction as a response to the getdata protocol
message.
• block: This sends a block in response to the getdata protocol message.
• headers: This packet returns up to 2,000 block headers as a reply to the
getheaders request.
• getaddr: This is sent as a request to get information about known peers.
• addr: This provides information about nodes on the network. It contains the
number of addresses and address list in the form of IP address and port number.
• First, the client sends a protocol message version that contains various fields,
such as version, services, timestamp, network address, nonce, and some other
fields.
• The remote node responds with its own version message followed by the verack
message exchange between both nodes, indicating that the connection has been
established.
• After this, getaddr and addr messages are exchanged to find the peers that the
client does not know.
• Meanwhile, either of the nodes can send a ping message to see whether the
connection is still active.
• The getaddr and addr messages are the types defined in the Bitcoin protocol. This
process is shown in the following protocol diagram:
• The preceding network protocol sequence diagram shows communication
between two Bitcoin nodes during initial connectivity.
• NODE A is shown on the left side and NODE B on the right.
• First, NODE A starts the connection by sending the version message which
contains version number and current time to the remote peer NODE B.
• NODE B then responds with its own version message containing the version
number and current time.
• NODE A and NODE B then exchange a verack message indicating that the
connection has been successfully established.
• After the connection is successful the peers can exchange getaddr and addr
messages to discover other peers on the network.
Wallets
• The wallet software is used to store private or public keys and Bitcoin address.
• It performs various functions, such as receiving and sending bitcoins.
• Private keys are generated by randomly choosing a 256-bit number by wallet software.
• Private keys are used by wallets to sign the outgoing transactions.
• In Bitcoin, there are different types of wallets that can be used to store private keys. As a
software program, they also provide some functions to the users to manage and carry out
transactions on the Bitcoin network.

85
• Bitcoin wallets are the tools that allow you to interact with the Bitcoin blockchain.
They are essential for:
• Storing Bitcoin securely.
• Sending and receiving Bitcoin by signing transactions.
• Managing multiple addresses for privacy.
• Tracking balances and transaction history.
• Providing security for your private keys.
• Backing up and recovering your wallet in case of device loss or damage.
Non-deterministic wallets

• These wallets contain randomly generated private keys and are also called just a bunch
of key wallets.
• The Bitcoin core client generates some keys when first started and generates keys as and
when required.
• Managing a large number of keys is very difficult and an error-prone process can lead to
theft and loss of coins.
• Non-deterministic wallet is a type of cryptocurrency wallet that generates a new
private key each time a transaction is made.
• This adds an extra layer of security, as the private keys are not reused, making it harder
for hackers to gain access to the wallet.
• When a user creates a non-deterministic wallet, a random number generator is used to
generate private keys. Each time a new transaction is initiated, a new private key is
created, providing additional security for the user’s funds.

87
Deterministic wallets
In this type of wallet, keys are derived out of a seed value via hash functions.
This seed number is generated randomly and is commonly represented by human-
readable mnemonic code words.
Mnemonic code words are defined in BIP 39, a Bitcoin improvement proposal for
mnemonic code for generating deterministic keys. This BIP is available at
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki.
This phrase can be used to recover all keys and makes private key management
comparatively easier.
Hierarchical Deterministic wallets

A hierarchical deterministic (HD) wallet is a digital wallet commonly used to store


the digital keys for holders of cryptocurrencies such as Bitcoin and Ethereum.
Anyone with a copy of both the public and password-like private key can control the
cryptocurrency in the account.
To prevent hacking these keys must be randomly generated and backed up in the
wallet.
HD wallets enable a series of key pairs to be created from one random seed,
providing convenience and manageability as well as high-level security.

89
Hardware wallets

• Another method is to use a tamper-resistant device to store keys.


• This tamper-resistant device can be custom built or with the advent of NFC-enabled
phones, this can also be a Secure Element (SE) in NFC Near field communication
phones.
• Trezor and Ledger wallets (various types) are the most commonly used Bitcoin hardware
wallets.
Trezor wallet

90
Brain wallets

• The master private key can also be derived from the hash of passwords that are
memorized.
• The key idea is that this passphrase is used to derive the private key and if used in HD
wallets, this can result in a full HD wallet that is derived from a single memorized
password
• This method is prone to password guessing and brute force attacks but techniques such as
key stretching can be used to slow down the progress made by the attacker.

91
Online wallets

• Online wallets, as the name implies, are stored entirely online and are provided as a
service usually via the cloud.
• They provide a web interface to the users to manage their wallets and perform various
functions such as making and receiving payments.
• They are easy to use but imply that the user trusts the online wallet service provider.
• An example of online wallet is GreenAddress

92
Mobile wallets

• Mobile wallets, as the name suggests, are installed on mobile devices.


• They can provide various methods to make payments, most notably the ability to use
smartphone cameras to scan QR codes quickly and make payments.
• Mobile wallets are available for the Android platform and iOS, for example,
Blockchain, breadwallet, Copay, and Jaxx.

93
94
Wallet Type Description Security Backup Example

Randomly generates private keys for


Non-Deterministic Wallet Lower (requires backup of all keys) Backup every key separately Any non-deterministic wallet
each address

Uses a single seed to generate all


Deterministic Wallet Moderate (depends on seed safety) Backup the seed phrase Bitcoin Core, Electrum
private keys

Generates private keys from a single


HD Wallet High (easy to back up, derived keys) Backup master seed (12-24 words) Ledger, Trezor, Electrum
master seed in a tree-like structure

Stores private keys offline in a


Hardware Wallet Very High (offline) Backup seed phrase or recovery key Ledger Nano S, Trezor
physical device

Uses a passphrase you remember to


Brain Wallet Low (easy to forget or guess) No physical backup required Brainwallet.org
generate the private key

Web-based wallet, private keys


Online Wallet Low (vulnerable to hacking) Backup seed (sometimes) Coinbase, Blockchain.info
stored on a third-party server

Wallet app for smartphones or Moderate (depends on device


Mobile Wallet Backup seed or password Trust Wallet, Exodus
tablets security)
Bitcoin payments

• Bitcoins can be accepted as payments using various techniques.


• Bitcoin is not recognized as a legal currency in many jurisdictions, but it is
increasingly being accepted as a payment method by many online merchants and
ecommerce websites.
• There are a number of ways in which buyers can pay the business that accepts
bitcoins.

96
Generally, these solutions work by following these steps:

1.The sales person enters the amount of money to be charged in currency, for example,
US Dollars
2.Once the value is entered in the system the terminal prints a receipt with QR code on it
and other relevant information such as amount.
3.The customer can then scan this QR code using their mobile Bitcoin wallet to send the
payment to the Bitcoin address of the seller embedded within the QR code
4.Once the payment is received on the designated Bitcoin address, a receipt is printed out
as a physical evidence of sale

97
Innovation in Bitcoin
Bitcoin has undergone many changes and still evolving into a more and more
robust and better system by addressing various weaknesses in the system.
These improvement proposals are usually made in the form of BIPs or
fundamentally new versions of Bitcoin protocols resulting in a new network
altogether.
Bitcoin Improvement Proposals (BIPs)

• Standard BIP: Used to describe the major changes that have a major impact on the
Bitcoin system, for example, block size changes, network protocol changes, or
transaction verification changes.
• Process BIP: A major difference between standard and process BIPs is that standard
BIPs cover protocol changes, whereas process BIPs usually deal with proposing a
change in a process that is outside the core Bitcoin protocol. These are implemented
only after a consensus among bitcoin users.
• Informational BIP: These are usually used to just advise or record some
information about the Bitcoin ecosystem, such as design issues.

99
Advanced protocols

• what are the various advanced protocols that have been suggested or
implemented for improving the Bitcoin protocol.
• Transaction throughput is one of the critical issues that need to be addressed.
Inherently, the Bitcoin network can only process from approximately 3 to 7
transactions per second which is a tiny number as compared to other financial
networks, such as Visa which can process approximately, on average, 24,000
transactions per second.
• PayPal can process approximately 200 transactions per second whereas Ethereum
can process up to on average 20.
• As Bitcoin Network grew exponentially over the last few years, these issues
started to grow even further.
• The difference of processing speed is also shown below in a graph which shows
the scale of difference between Bitcoin and other networks' transaction speeds.
Bitcoin investment and buying and selling bitcoins

• There are many online exchanges where users can buy and sell bitcoins.
• This is a big business on the internet now and it offers bitcoin trading, spread betting,
margin trading, and various other choices.
• Traders can buy bitcoins or trade by opening long or short positions to make a profit
when bitcoin's price goes up or down.
• Several other features, such as exchanging bitcoins for other virtual currencies, are also
possible, and many online bitcoin exchanges provide this function.
• Advanced market data, trading strategies, charts, and relevant data to support traders
is also available.
• An example is shown from CEX (https://cex.io) here. Other exchanges offer similar types
of services.
Bitcoin installation

• The Bitcoin Core client can be installed from


https://bitcoin.org/en/download.
• This is available for different architectures and platforms ranging
from x86 Windows to ARM Linux.

106
Setting up a Bitcoin node

• A sample run of the Bitcoin Core installation on Ubuntu is shown


here; for other platforms, you can get details from
https://bitcoin.org/en/:
• Bitcoind
This is the core client software that can be run as a daemon, and it
provides the JSON RPC interface.
• Bitcoin-cli
This is the command line feature-rich tool to interact with the daemon;
the daemon then interacts with the blockchain and performs various
functions.
Bitcoin-cli calls only JSON-RPC functions and does not perform any
actions on its own on the blockchain.

107
• Bitcoin-qt

108
Setting up a Bitcoin node
Setting up the source code
• The Bitcoin source code can be downloaded and compiled if users wish to
participate in the Bitcoin code or for learning purpose. The git command can be
used to download the Bitcoin source code:
$ sudo apt-get install git
$ mkdir bcsource
$ cd bcsource
$ git clone https://github.com/bitcoin/bitcoin.git
Cloning into 'bitcoin'...
remote: Counting objects: 78960, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 78960 (delta 0), reused 0 (delta 0), pack-reused 78957
Receiving objects: 100% (78960/78960), 72.53 MiB | 1.85 MiB/s, done.
Resolving deltas: 100% (57908/57908), done.
Checking connectivity... done.

111
• Change the directory to bitcoin:
$ cd bitcoin
• After the preceding steps are completed, the code can be compiled:
$ ./autogen.sh
$ ./configure.sh
$ make
$ sudo make install

112
Starting up a node in testnet
• The bitcoin node can be started in the testnet mode if you want to test the Bitcoin
network and run an experiment. The command line to start up testnet is as follows:
bitcoind --testnet -daemon
bitcoin-cli –testnet <command>
bitcoin-qt --testnet

113
Starting up a node in regtest

• The regtest mode (regression testing mode) can be used to create a


local blockchain for testing purposes.
• The following commands can be used to start up a node in the
regtest mode:
$ bitcoind -regtest -daemon
Bitcoin server starting
• After block generation, the balance can be viewed as follows:
$ bitcoin-cli -regtest getbalance
8750.00000000
• The node can be stopped using this:
$ bitcoin-cli -regtest stop
Bitcoin server stopping
114
Experimenting with Bitcoin-cli
Bitcoin programming and the command line interface

• Bitcoin programming is a very rich field now. The Bitcoin Core client exposes
various JSON RPC commands that can be used to construct raw transactions and
perform other functions via custom scripts or programs.
• Also, the command-line tool, Bitcoin-cli, is available, which makes use of the
JSON-RPC interface and provides a rich toolset to work with Bitcoin.
• Various libraries are available for bitcoin programming.
1.Libbitcoin: Available at https://libbitcoin.dyne.org/ and provides powerful
command-line utilities and clients
2.Pycoin: Available at https://github.com/richardkiss/pycoin, is a library for
Python
3.Bitcoinj: This library is available at https://bitcoinj.github.io/ and is
implemented in Java

118

You might also like