Search notes:

Bitcoin

Bitcoin: an electronic peer to peer version of money. Bitcoins can be sent from buyer to seller without the overhead of financial institutions.
It also solves the problem of double spending without using a »man in the middle« (such as a financial institution).
Bitcoin is based on cryptographic proof rather than trust.
Bitcoin has three main components:
Because bitcoin is decentralized and has no government, (central-!) bank or company regulating it, there is nobody than can prevent the payment to anyone nor does anyone need someone's permission to send bitcoins. This is a good thing.

Fundamental Principles

There will never be more than 21 million bitcoins.
No organization (such as governments!) must be able to reject (censor?) valid txs from being confirmed or to prevent someone to use the network (be it as user, node, miner etc.)
Source code is open source.
No one should have to identify himself with his/her name when using bitcoin.
No bitcoins are special, rather, they're all equal.
Confirmed blocks cannot be changed. The history of the blockchain cannot be changed, either.

Achieving decentralization

The following five questions need to be addressed:
See Narayanan, Bonneau, Felten, Miller, Goldfeder: Bitcoin and Cryptocurrency Techologies, p. 52.

Proving the ownership of a bitcoin

The bitcoin technology allows someone to prove he is actually in possession of a specific bitcoin.
In order to do that, they have to send their public address, signed with their private key.
If this message can be decoded, the ownership of their account is proven. Then it's possible to check the balance and the transaction history.

Upgrading the Bitcoin network

There are four ways to upgrade the Bitcoin network (for example to handle more transactions, improve scalability etc.):

Misc

No encryption

Although called a crypto currency, there is no encryption in Bitcoin: nothing needs to be encrypted (but it uses cryptographic hash functions)

Hash functions

Bitcoin uses two cryptographic hash functions:
  • SHA-256
  • RIPEMD160 (RACE Integrity Primitives Evaluation Message Digest)

Keys and addresses

The public key is derived from the private key using elliptic curve multiplication.
Appliying a cryptographic hash function to the public key produces the address.

Historic snippets

The earliest ideas of applying cryptography to cash came from David Chaum in 1983.
1988, along with Fiat and Naor, proposed offline electronic cash.
A paper by Okamoto and Ohta describe Merkle trees to subdivide coins.
Nakamoto started programming on Bitcoin around May 2007.
Nakamoto's last known signal was recorded April 23, 2011 when in an eMail to Mike Hearn he wrote I've moved on to other things.
Compare Printeton bitcoin book, p. 9 ff

Bitcoin systems/networks

The main network is where people trade goods and servces. Default port: 8333. Network id: main.
The public test network. It is reset from time to time. Default port: 18333. Network id: test. Bitcoins for testing (faucets) can be acquired from http://tpfaucet.appspot.com or https://testnet.coinfaucet.eu/en/
The regression test (network). It is not public with a minimum diffuclty. Default port: 18444. Network id: regtest.

Mempool («Memory pool»)

A mempool is the queue of pending and unconfirmed transactions of a given node on the network
Because every node maintains its own mempool, there is no global mempool.

Bitcoin Improval Proposal (BIP)

BIPs are Bitcoin Improval Proposals.
A BIP is a design document
  • providing information to the Bitcoin community, or
  • describing a new feature for Bitcoin or its processes or environment.
BIPs are used to
  • propose new features,
  • collect community input on an issue
  • document design decisions that have gone into Bitcoin
There are three kinds of BIP:
  • Standards Track BIP
  • Informational BIP
  • Process BIP (like Standards Track BIPs but apply to areas other than the Bitcoin protocol itself)
The typical path through the various states («status field») of a BIP (Draft, Proposed, Final/Active, Deferred, Rejected, Withdrawn, Replaced, Obsolete) is outlined in BIP 2.
A BIP is formally accepted if its status is Final or Active.
BIPs are maintained as text files in a versioned repository (which I believe to be github.com/bitcoin/bips) , thus, their revision history is the historical record of the feature proposal.
Interesting, IMHO, BIPs include
BIP 39 Mnemonic code for generating deterministic keys. Definition of 2024 words. The first 4 letters of each of these words are different (where space counts as a letter (add is not the same as addict)
BIP 64 Bitcoin XT fork?
BIP 101 Increase of the block size
BIP 141 Segregated Witness (Consensus layer)
Compare BIPs with bLIPs.

Lightning

Lightning is a protocol for making fast payments with Bitcoin using a network of channels.

Basis of Lightning Technology (BOLT)

The Basis of Lightning Technology (BOLT) documents describe a layer-2 protocol for off-chain bitcoin transfer by mutual cooperation, relying on on-chain transactions for enforcement if necessary.

Bitcoin Lightning Improvement Proposal (bLIP)

A bLIP is a design document providing information to the Lightning community, or describing a new feature for the Lightning Network.
Compare bLIPs with BIPs.

Misc

The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness.

bitcoin.info REST API

Some examples for the Blockchain Data API offered by blockchain.com (via blockchain.info?).
Downloading the information for a block with the bitcoin.info REST API because the JSON file is rather large (approx 7 MB):
$ curl -s https://blockchain.info/rawblock/875049 -o /tmp/bitcoin-block-875049.json
Extract some information pertaining to the block
$ jq -r  '
  ["Block index"   , .block_index ],
  ["Height"        , .height],
  ["Size"          , .size],
  ["Time"          , (.time | todateiso8601)],
  ["Version"       , .ver],                     # seems to be a flag field
  ["Weight"        , .weight],
  ["Fee"           , .fee],
  ["hash"          , .hash],
  ["Nonce"         , .nonce],
  ["Main chain"    , .main_chain],
  ["Merkle root"   , .mrkl_root],
  ["nof Trx"       , .n_tx],
  ["Next block[0]" , .next_block[0]],
  ["Prev block"    , .prev_block] |
     @tsv' \
     /tmp/bitcoin-block-875049.json   |
  column -ts $'\t'

Block index    875049
Height         875049
Size           1542584
Time           2024-12-16T19:45:11Z
Version        1073676288
Weight         3993407
Fee            10052973
hash           0000000000000000000256360f807b002c9a993db921212a9700c5805f30ca82
nonce          847395996
main chain     true
merkle root    f6ea21c6e23ec74b65a079a97c283a9f96daffc7734b84a05ffddde303f5f588
nof trx        3822
next block[0]  000000000000000000023703272844fe1d2b713deaf69d8f5fa97835fb079e0e
prev block     0000000000000000000185d0f248f6aefecf5ae2acc0a12398eed5f76f8b79e4
The version is a bit field:
$ printf "%x\n" 1073676288
3fff0000
Display the block's first transaction:
$ jq -r  '.tx[0]' /tmp/bitcoin-block-875049.json
…
Show an address's balance:
$ curl -s https://blockchain.info/balance?active=33TbzA5AMiTKUCmeVEdsnTj3GiVXuavCAH | jq
{
  "33TbzA5AMiTKUCmeVEdsnTj3GiVXuavCAH": {
    "final_balance": 640863808,
    "n_tx": 2179,
    "total_received": 728660071967
  }
}
Unspent outputs:
$ curl -s https://blockchain.info/unspent?active=33TbzA5AMiTKUCmeVEdsnTj3GiVXuavCAH | jq
Unconfirmed transactions
$ curl -s https://blockchain.info/unconfirmed-transactions?format=json | jq

Links

Searching for blocks, addresses and transactions: bitcoinchain.com.
https://coin.dance/
https://bitcoin.sipa.be/

TODO

See also

account, Bitcoin address, blockchain, block, Buying bitcoins, clients, consensus rules, coin, fork, Bitcoin mining, node, nonce, proof of work, scripting language, Timestamp-server, transactions, wallet
/etc/bitcoin
Crypto Currencies
Bitcoin in Switzerland

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759399669, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/Crypto-Currencies/Bitcoin/index(339): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78