├── 01-installation.md ├── 02-wallet.md ├── 03-stats.md ├── 04-network.md ├── 05-summary.md └── README.md /01-installation.md: -------------------------------------------------------------------------------- 1 | 01 Installation 2 | === 3 | 4 | What is Bitcoin? 5 | --- 6 | It's the first p2p currency. 7 | 8 | * transactions 9 | * P2P 10 | * blocks 11 | * miners 12 | * blockchain 13 | 14 | What is Bitcoin Core? 15 | --- 16 | * continuation of the work of 17 | Bitcoin's creator 18 | * what does it do? 19 | * p2p 20 | * consensus 21 | * wallet 22 | * rpc 23 | 24 | Why run a full node? 25 | --- 26 | * personal wallet 27 | * merchant 28 | * API 29 | 30 | Specific use case 31 | --- 32 | * there's a satoshi square 33 | everyday at 33c3 34 | * want to use most secure and 35 | private wallet available 36 | * => smartphone + ssh + Bitcoin Core 37 | 38 | Where do you run it? 39 | --- 40 | * not very powerful machine required 41 | * but not really raspberry pi either 42 | * ARM: cubox, odroid 43 | * 4GB of RAM 44 | * full blockchain: big harddrive, 45 | disk possible 46 | * preparing the host (example) 47 | * full disk encryption 48 | * set date 49 | * firewall 50 | * systemd service 51 | 52 | How do you get it? 53 | --- 54 | * download binary from bitcoin.org 55 | * `wget https://bitcoin.org/bin/bitcoin-core-0.16.0/bitcoin-0.16.0-x86_64-linux-gnu.tar.gz` 56 | * `wget https://bitcoin.org/bin/bitcoin-core-0.16.0/SHA256SUMS.asc` 57 | * verify signatures with gpg 58 | * sign my key to get a trust path 59 | * gitian deterministic builds 60 | * https://github.com/bitcoin-core/gitian.sigs 61 | * source code releases on github 62 | 63 | Starting up bitcoind 64 | --- 65 | * bitcoind is the daemon 66 | * connects to peers 67 | * downloads and verifies new blocks 68 | * initial block download (IBD) 69 | * 27h on the-donald 70 | * on reasonably fast hardware < 8h 71 | * relays blocks and transactions 72 | 73 | bitcoin-cli 74 | --- 75 | * talks to bitcoind using JSON-RPC 76 | * `alias bc="bitcoin-cli"` 77 | * `bc -getinfo | egrep "\"version\"|balance|blocks|connections|errors"` 78 | * `bc help` 79 | * `bc help sendtoaddress` 80 | 81 | bitcoin-qt 82 | --- 83 | * GUI 84 | * ? 85 | * I don't use such things 86 | 87 | Configuration 88 | --- 89 | * the .bitcoin folder 90 | * bitcoin.conf 91 | * blocks/ 92 | * `cat .bitcoin/debug.log | egrep "receive version message|UpdateTip|Connect total" | tail -n 100` 93 | * `alias bd="bitcoind"` 94 | * arguments 95 | * `bd ... -help` 96 | * `bd ... -testnet` and `bc ... -regtest` 97 | * different p2p network and blockchain 98 | * `bd ... -debug` 99 | * `bd ... -dbcache=3000` 100 | * (for faster IBD) 101 | 102 | Resources 103 | --- 104 | * https://bitcoin.org/en/developer-documentation 105 | * https://en.bitcoin.it/wiki/ 106 | * https://bitcoin.stackexchange.com/ 107 | -------------------------------------------------------------------------------- /02-wallet.md: -------------------------------------------------------------------------------- 1 | 02 Wallet 2 | === 3 | 4 | Example: Buy bitcoins 5 | --- 6 | * get new address and print QR code 7 | ``` 8 | ADDR=`bc getnewaddress` 9 | qrencode -m 1 -t ansi256 bitcoin:$ADDR 10 | ``` 11 | 12 | * check if coins are received 13 | ``` 14 | bc getreceivedbyaddress $ADDR 0 15 | bc getreceivedbyaddress $ADDR 1 16 | ``` 17 | 18 | * polling is not the smartest way to do this 19 | * `bd ... -walletnotify='echo %s >> ~/wallet.txt'` 20 | * `bd ... -zmqpubrawblock=` 21 | 22 | Example: Sell bitcoins 23 | --- 24 | ``` 25 | bc sendtoaddress
26 | ``` 27 | 28 | Transaction info 29 | --- 30 | * `bc listtransactions` 31 | * `bc gettransaction | egrep "confirmation|fee" ` 32 | * list your addresses 33 | * `bc getaddressesbyaccount ""` 34 | 35 | Backup 36 | --- 37 | * `~/.bitcoin/wallet.dat` contains 38 | * master seed 39 | * addr and tx metadata 40 | * backup: turn off bitcoind and copy wallet.dat 41 | * restore: copy saved wallet.dat back 42 | * start with `bd ... -rescan` 43 | * `bc getnewaddress` 44 | * encryption 45 | * either `bc encryptwallet` 46 | * metadata not encrypted 47 | * or manual 48 | 49 | Offline signing 50 | --- 51 | * means that signing key is not on machine 52 | connected to the internet 53 | * with Bitcoin Core 54 | * https://people.xiph.org/~greg/signdemo.txt 55 | * https://github.com/rustyrussell/bitcoin-storage-guide 56 | * or hardware wallets 57 | * ledger 58 | * trezor 59 | * digital bitbox 60 | 61 | Transactions 62 | --- 63 | * `bc getrawtransaction` 64 | * requires `bd ... -txindex` 65 | * `bc getrawtransaction f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16 1` 66 | * can't look up "addresses", as there is 67 | no index for it 68 | 69 | * an exemplary transaction subgraph 70 | ``` 71 | +------------+ 72 | | out0 +---+ 73 | +------------+ | +------------+ 74 | TxA +----> in0 out0 | 75 | | | 76 | +----> in1 | 77 | +------------+ | +------------+ 78 | | out0 +---+ TxC 79 | | | 80 | | out1 | 81 | +------------+ 82 | TxB 83 | ``` 84 | 85 | "Raw" transaction interface 86 | --- 87 | * useful for 88 | * spending multisig 89 | * multisig: f.e. need 2 of 3 keys to 90 | spend 91 | * creating 92 | `bc createmultisig 1 '["$PK1", "$PK2"]'` 93 | * offline signing 94 | * control over which exact coins 95 | to spend 96 | 97 | * `bc listunspent` 98 | * `bc createrawtransaction` 99 | * don't forget to add change! 100 | * `bc signrawtransaction` 101 | * `bc submitrawtransaction` 102 | 103 | * even more control with the bitcoin-tx tool 104 | 105 | Create m-of-n multisig 106 | --- 107 | * `bc getnewaddress` 108 | * find pubkey with `bc validateaddress
` and broadcast to signers 109 | * all signers: `bc addmultisigaddress m '["pubKey_1", ..., "pubKey_n"]'` 110 | 111 | Spend m-of-n multisig 112 | --- 113 | * `bc createrawtransaction '[{"txid": "multisig_output_txid", "vout": vout, "nValue": value}]' '{"destination_address": value}'` 114 | * `bc signrawtransaction ` 115 | * pass signature to next signer until complete 116 | * `bc sendrawtransaction ` 117 | 118 | -------------------------------------------------------------------------------- /03-stats.md: -------------------------------------------------------------------------------- 1 | 03 Blockchain and Mempool 2 | === 3 | 4 | Blocks 5 | --- 6 | * `GENESIS=`bc getblockhash 0` ` 7 | * `bc getblock $GENESIS | egrep "confirmations|tx|\"size\"|height|\"time\""` 8 | * `bc getblock $GENESIS false | xxd -r -p` 9 | 10 | Blockchain 11 | --- 12 | * `bc getblockchaininfo | jq ".bip9_softforks"` 13 | * `bc getmininginfo | grep networkhashps` 14 | * "pruning" 15 | * only save the last n MB of blocks 16 | * `bd ... -prune=n` 17 | 18 | Mempool 19 | --- 20 | * mempool consists of known transactions 21 | not (yet) in a block 22 | * `bc getmempoolinfo` 23 | * `bd ... -blocksonly` 24 | * no tx relay, no mempool, 25 | no compact blocks 26 | * `bd ... -minrelaytxfee=0.0001` 27 | * can prevent gossip spam 28 | * txfee 29 | * `FEEPERKB=`bc estimatefee 3` ` 30 | * `python -c "print 960 * $FEEPERKB * 1.0/4, 'approx. USD per median tx'"` 31 | -------------------------------------------------------------------------------- /04-network.md: -------------------------------------------------------------------------------- 1 | 04 Network 2 | === 3 | 4 | Network 5 | --- 6 | * `bc getpeerinfo | egrep 'subver|inbound'` 7 | * `bc addnode` 8 | * `bc setban` 9 | * https://0bin.net/paste/ZFEAihJLl8AQRaBx#M8xZGuMyYKZWhjfNLOX4pQsraQys2IedFPr60rB3rJi 10 | 11 | Setting Network Limits 12 | --- 13 | * check bandwidth usage 14 | * `vnstat -d` 15 | * `bd ... -listen=0` 16 | * `bd ... -maxconnections=20` 17 | * `bd ... -maxuploadtarget=500` 18 | * `bd ... -blocksonly` 19 | 20 | 21 | Tor 22 | --- 23 | * https://github.com/bitcoin/bitcoin/blob/master/doc/tor.md 24 | * install tor 25 | * run behind Tor proxy 26 | * `bd ... -proxy=127.0.0.1:9050` 27 | 28 | Run a bitcoin hidden service 29 | --- 30 | * add to torrc 31 | ``` 32 | HiddenServiceDir /var/lib/tor/bitcoin-service/ 33 | HiddenServicePort 8333 127.0.0.1:8333 34 | ``` 35 | 36 | * `ONION=`cat /var/lib/tor/bitcoin-service/hostname` ` 37 | * `bd ... -proxy=127.0.0.1:9050` 38 | * `bd ... -listen=1` 39 | * listen despite proxy 40 | * `bd ... -listenonion=0` 41 | * no ephemeral HS 42 | * `bd ... -externalip=$ONION` 43 | * `bd ... -bind=127.0.0.1` 44 | * otherwise still allowing non-Tor 45 | 46 | * `bc getnetworkinfo` 47 | 48 | Ephemeral Hidden services 49 | --- 50 | * configure tor control port 51 | -------------------------------------------------------------------------------- /05-summary.md: -------------------------------------------------------------------------------- 1 | 05 Summary 2 | === 3 | 1. install a bitcoin node 4 | 2. play around with 5 | * `bd ... -regtest` 6 | * or `bd ... -testnet` 7 | 3. sell your goods and services for bitcoin 8 | .... 9 | 10 | * next steps for my node 11 | * joinmarket for increasing your privacy 12 | * and soon lightningd for near instant txs 13 | and reduced fees 14 | * come to the 33c3 bitcoin assembly 15 | * handout: **https://github.com/jonasnick/bitcoin-node** 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | How to Run a Bitcoin Node 2 | === 3 | 4 | **https://github.com/jonasnick/bitcoin-node** 5 | 6 | 1. [installation](01-installation.md) 7 | 2. [wallet](02-wallet.md) 8 | 3. [blockchain & mempool](03-stats.md) 9 | 4. [network](04-network.md) 10 | 5. [summary](05-summary.md) 11 | --------------------------------------------------------------------------------