DEV Community

Orion
Orion

Posted on

Bitcoin Notes

Bitcoin Blockchain

Introduction to Bitcoin

  • First digital currency instant transfer
  • cannot be printed, but computed by computers around the world

2 Major Operations:

  • Transaction Management: Transferring of coins from one address to another.
  • Currency Generation: Regulating the monetary value

Bitcoin supply is limited at 21 Million Coins to boost value.

  • The rate of block creation is adjusted every 2016 blocks. (2 weeks to mine = 2016 blocks)
  • The number of Bitcoins generated per block decreases by 50% every 210,000 blocks.

How to get a bitcoin

  • must have a digital wallet
  • buy online, create account on a exchange (coinbase)
  • buy bitcoin with cash. Sites like LocalBitcoins.org help find people who are near to exchange Bitcoins for cash. ATMS are available as well.

Buying Bitcoins from exchange

  1. Choose an exchange
  2. Set up an account
  3. connect bank account
  4. Select amount.

Best Bitcoin exchanges

  • Coinbase
  • SpectroCoin
  • Indacoin
  • Kraken
  • LocalBitcoins

Wallets

  • digital wallets where private keys are used to access bitcoin addresses and signatures for transactions. Bitcoins are stored anywhere, but a private key matched to every bitcoin address which can be saved in the bitcoin wallet. They facilitate to the transactions

Types of wallets

  1. Software wallet -installed on the computer to store the private key
  2. Web wallet - online wallet
  3. hardware wallet - store private keys on storage devices
  4. Brain wallet- computer generates a seed phrase for you to remember.
  5. Mobile Wallets- run as apps storing your private keys to pay directly from your phone.

Great wallets.

  • Jaxx.io

- Exodus.io

Where to spend bitcoins

  • spending online: household items, giftcards, video games
  • spending offline: food, travel,

Places to spend bitcoins

  • Overstock.com
  • Shopify stores
  • Cheapair
  • Expedia
  • eGifter
  • Reeds jewelers
  • newegg
  • Dish network
  • Microsoft

Double-Spending Problem: Spending the same BTC in more than one transaction. To prevent this all transaction details are sent to many nodes on the network. Blockchain ensures that any modification will lead to recomputing the blocks.

Pseudonymity in Bitcoin: is the near-anonymous state in which users have disguised identities and do not disclose their true identities.

  • Bitcoin is a permissionless blockchain where you don't need to set up and account.
  • public and private keys are generated by the wallet
  • the address acts as an identified or pseudonym of a users transaction

Bitcoin Address: corresponds to a public base based on ECDSA (Elliptic Curve Digital Signature Algorithm). A wallet can have many addresses and can be used for transactions.

Bitcoin Transactions (UTXOs): Unspent Transaction Output is the fundamental building block of Bitcoin.

BTC transaction structure:

  1. Input- This is a record of which BTC address was used to send the bitcoins to the receiver in the first place
  2. Amount - This is the amount of BTC that the sender sends to the receiver.
  3. Output- This is sent to the sender's address as change.

Transactions (input/output)

  • transactions can be represented in the form of a series of inputs and outputs.

BTC Script: Features

  • scripts are embedded into their inputs and outputs
  • uses a language like "Forth"
  • records a list of instructions with each transactions
  • it composed of opcodes
  • BTCscript describes how the person can access the BTC if they want to spend it.
  • BTC Script is Turing incomplete

BTC Script Construction:

  • Transaction input: { scriptSig
  • Transaction Output { scriptPubKey

BTC Script Instructions

  • script is a list of instructions which is recorded with each transactions
  • language is small
  • consist of 256 opcodes out of which 15 are disabled and 75 are reserved.
  • each instruction is one byte
  • Opcodes have the following: constants, flow control, stack, bitwise logic, arithmetic, crypto, locktime, pseudo-words, and reserved words.

Evaluating Transaction Script

  • Step by step exe of the combined script which will prove this is a valid transaction.

BTC Network:

  • an ad hoc network with random topology
  • protocol runs on TCP 8333
  • new nodes are treated equally in bitcoin network
  • new nodes can join the network anytime, and the non responsive nodes are removed after 3 hours.

BTC Network Node: Consist of 4 functions

  1. wallet
  2. Miner
  3. Full Blockchain
  4. Network routing node

Types of Nodes

  1. Reference Client (BTC Core)
  2. Full Blockchain Node
  3. Solo Miner
  4. Lightweight (SPV wallet)
  5. Pool Protocol Servers
  6. Mining Node
  7. Lightweight (SPV)

Joining Bitcoin Network

  • Seed nodes have the list of addresses
  • Joining nodes ask for the list of addresses from the seed node. It also picks up an address from the list and joins the network.

Mining Process

  • BTC are created by the process of mining
  • Autonomous check of every transaction
  • Independent aggregation of transaction into new blocks
  • Independent confirmation of new blocks by each node.
  • Independent selection by every node of the chain with the most cumulative computation.
  • Autonomous-Check of Transactions:
  • Independent Aggregation of Transactions:
  • Mining Puzzle:

(Electricity + computational = reward)

  • Choosing the greatest difficulty chain, all nodes in the long run accomplish a wide consensus.
  • Brief errors between chains are settled in the long run as more POW is included by broadening one of the conceivable chains
  • mining nodes vote with their mining power by picking which chain to extend by mining the next block.

Top comments (0)