diff --git a/README.md b/README.md index 852191c..4b417f7 100644 --- a/README.md +++ b/README.md @@ -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! @@ -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. @@ -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 diff --git a/btc_node.sh b/btc_node.sh index 24a2583..02eb8a6 100755 --- a/btc_node.sh +++ b/btc_node.sh @@ -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 diff --git a/lib/bitcoind.sh b/lib/bitcoind.sh index 9703b4c..11eb753 100644 --- a/lib/bitcoind.sh +++ b/lib/bitcoind.sh @@ -29,6 +29,7 @@ function purgingBlockchain() { # Starting a fresh bitcoin daemon instance ###################################### function startBitcoind() { + ${BR_START} & ${BR} ${BR_OPTS} &> ${LOG_FILE} & echo $! > ${PID_FILE} @@ -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 diff --git a/lib/colors.sh b/lib/colors.sh index e301060..748c742 100644 --- a/lib/colors.sh +++ b/lib/colors.sh @@ -23,4 +23,3 @@ function echoyellow() { function echocyan() { echo -n $(__colortext "$1" "36") } - diff --git a/lib/spending.sh b/lib/spending.sh index 54044ac..71a0dff 100644 --- a/lib/spending.sh +++ b/lib/spending.sh @@ -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 } @@ -38,5 +38,4 @@ function showWalletBalance() { function randomInteger() { echo $((RANDOM%10+1)) -} - +} \ No newline at end of file