Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ blockchain, but improves the understanding of how a decentralized ledger works.
Installation of the official bitcoin core implementation from
https://bitcoin.org/en/download

~$ BITCOIN_VERSION=0.9.3 # You may want to change this value to the current version.
~$ wget https://bitcoin.org/bin/${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-linux.tar.gz
~$ tar xf bitcoin-${BITCOIN_VERSION}-linux.tar.gz
~$ BITCOIN_VERSION=0.15.1 # You may want to change this value to the current version.
~$ wget https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
~$ tar xf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
# Change 64 to 32 for 32bit architecture
~$ mv bitcoin-${BITCOIN_VERSION}-linux/bin/64/* /usr/local/bin
~$ mv bitcoin-${BITCOIN_VERSION}-linux/bin/* /usr/local/bin

## Quickstart ##

Setup your private blockchain in regtest mode and mine 50 BTC. In this
version we assume that `bitcoind` is installed. Try `bitcoind help`. Future
version we assume that `bitcoind` is installed. Try `bitcoin-cli -help`. Future
versions will install bitcoin-core automatically, if necessary.

**Attention:** The previous blockchain, with related wallet, will be deleted!
Expand Down Expand Up @@ -108,9 +108,9 @@ Switch to new console and let the bitcoind running. We generate 101 new blocks
(starting from the genesis block), in order to be able to access the first one
and get 50 BTC.

~$ bitcoind -regtest setgenerate 101
~$ bitcoin-cli -regtest generate 101
... # Wait until all blocks are generated, ~1 minute
~$ bitcoind -regtest getbalance
~$ bitcoin-cli -regtest getbalance
50.00000000 # <= You should see that or at least a number bigger then zero.

**Congratulations!** You have now your first BTC that you can spent.
Expand All @@ -120,10 +120,10 @@ Where to go from here? Please read further how to spent this BTC and how to make

## Preparing your working environment ##

We don't want to type each time `bitcoind -regtest`. The command `br` is easier
We don't want to type each time `bitcoin-cli -regtest`. The command `br` is easier
to type and easy to remember: The beginning letters of the command.

~$ echo 'alias br="bitcoind -regtest"' >> ~/.bashrc; source ~/.bashrc
~$ echo 'alias br="bitcoin-cli -regtest"' >> ~/.bashrc; source ~/.bashrc
~$ br getbalance


Expand Down
4 changes: 3 additions & 1 deletion btc_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
######################################
# Configuration
######################################
BR="bitcoind -regtest"
BR_START="bitcoind -regtest -daemon"
BR_STOP="bitcoin-cli -regtest stop"
BR="bitcoin-cli -regtest"
BR_OPTS="-printtoconsole -externalip=127.0.0.1"

SLEEP_TIME=7
Expand Down
3 changes: 2 additions & 1 deletion lib/bitcoind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function purgingBlockchain() {
# Starting a fresh bitcoin daemon instance
######################################
function startBitcoind() {
${BR_START} &
${BR} ${BR_OPTS} &> ${LOG_FILE} &
echo $! > ${PID_FILE}

Expand All @@ -45,7 +46,7 @@ function startBitcoind() {
######################################
function miningFirstBTC() {
echocyan "[MINING] Mining Bitcoin. Please be patient for ~1 minute"; echo
${BR} setgenerate true 101
${BR} generate 101

BALANCE=$(${BR} getbalance)
echocyan "[WALLET] Your current balance: \e[1m\e[7m${BALANCE} BTC\e[0m"; echo
Expand Down
1 change: 0 additions & 1 deletion lib/colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ function echoyellow() {
function echocyan() {
echo -n $(__colortext "$1" "36")
}

7 changes: 3 additions & 4 deletions lib/spending.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function donateRandomAmount() {

function generateBlock() {
echocyan "[INFO] Generating new block!"; echo
${BR} setgenerate true
${BR} generate 1

blk_hash=$(${BR} getbestblockhash)
blk=$(${BR} getblock $blk_hash)
txsize=$(ruby -rjson -e "puts JSON.parse('$blk')['tx'].size")
txsize=$(ruby -rjson -e "puts JSON.parse('$blk')['tx'].size")
echocyan "\t|-> Block Hash: ${blk_hash}";echo
echocyan "\t|-> TRX Number: ${txsize}";echo
}
Expand All @@ -38,5 +38,4 @@ function showWalletBalance() {

function randomInteger() {
echo $((RANDOM%10+1))
}

}