From 8d414782f88c40e4b8d1658ab7ddf95b57d7ca1f Mon Sep 17 00:00:00 2001 From: Richard Portsmith Date: Mon, 12 Feb 2018 21:07:39 -0500 Subject: [PATCH 1/5] improves build to work with latest bitcoin version --- btc_node.sh | 4 +++- lib/bitcoind.sh | 4 +++- lib/colors.sh | 1 - lib/spending.sh | 7 +++---- 4 files changed, 9 insertions(+), 7 deletions(-) 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..37f3255 100644 --- a/lib/bitcoind.sh +++ b/lib/bitcoind.sh @@ -29,6 +29,8 @@ function purgingBlockchain() { # Starting a fresh bitcoin daemon instance ###################################### function startBitcoind() { + ${BR_STOP} & + ${BR_START} & ${BR} ${BR_OPTS} &> ${LOG_FILE} & echo $! > ${PID_FILE} @@ -45,7 +47,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 From f6c0cd10dba459c2b8a1e1d6c6f1f71b9bbf5be7 Mon Sep 17 00:00:00 2001 From: Richard Portsmith Date: Mon, 12 Feb 2018 21:11:15 -0500 Subject: [PATCH 2/5] removes stop script from bitcoind --- lib/bitcoind.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/bitcoind.sh b/lib/bitcoind.sh index 37f3255..11eb753 100644 --- a/lib/bitcoind.sh +++ b/lib/bitcoind.sh @@ -29,7 +29,6 @@ function purgingBlockchain() { # Starting a fresh bitcoin daemon instance ###################################### function startBitcoind() { - ${BR_STOP} & ${BR_START} & ${BR} ${BR_OPTS} &> ${LOG_FILE} & echo $! > ${PID_FILE} From b15303e3b7b1d2478de266bb335a974ffa77501e Mon Sep 17 00:00:00 2001 From: Richard Portsmith Date: Mon, 12 Feb 2018 21:14:31 -0500 Subject: [PATCH 3/5] updates readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 852191c..62cf770 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ 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 ## From 181ce6f05b898226f64dc1ae1bebf9d39d15ae19 Mon Sep 17 00:00:00 2001 From: Richard Portsmith Date: Mon, 12 Feb 2018 21:15:51 -0500 Subject: [PATCH 4/5] updates readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62cf770..2ad6819 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ https://bitcoin.org/en/download ## 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! From b01c89143d7f6e5e6d5e3dfd901fa9f97c00d22f Mon Sep 17 00:00:00 2001 From: Richard Portsmith Date: Mon, 12 Feb 2018 21:20:25 -0500 Subject: [PATCH 5/5] updates readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2ad6819..4b417f7 100644 --- a/README.md +++ b/README.md @@ -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