diff --git a/btcp_old_node_setup.sh b/btcp_basic_node.sh similarity index 84% rename from btcp_old_node_setup.sh rename to btcp_basic_node.sh index ce8031e..812d878 100755 --- a/btcp_old_node_setup.sh +++ b/btcp_basic_node.sh @@ -60,21 +60,6 @@ cd btcp-explorer # Install Insight API / UI (Explorer) (Headless) ../node_modules/bitcore-node-btcp/bin/bitcore-node install BTCPrivate/insight-api-btcp BTCPrivate/insight-ui-btcp -# !!! OPTIONAL [TODO present cli options] Install store-demo -cd ~ -git clone https://github.com/BTCPrivate/store-demo -cd btcp-explorer/node_modules -ln -s ~/store-demo - -# !!! OPTIONAL [TODO present cli options] Install address-watch -cd ~ -git clone https://github.com/BTCPrivate/address-watch -cd btcp-explorer/node_modules -ln -s ~/address-watch - -# Create config file for Bitcore -# !!! OPTIONAL TODO add store-demo and address-watch to services as specified - # Create config file for Bitcore cat << EOF > bitcore-node.json { diff --git a/build_btcp.sh b/btcp_daemon_only.sh similarity index 100% rename from build_btcp.sh rename to btcp_daemon_only.sh diff --git a/btcp_node_setup.sh b/btcp_explorer_upgrade.sh similarity index 78% rename from btcp_node_setup.sh rename to btcp_explorer_upgrade.sh index e30b897..fce207b 100755 --- a/btcp_node_setup.sh +++ b/btcp_explorer_upgrade.sh @@ -24,8 +24,8 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -# Install node v9, or v4 for <=4.0 -nvm install v9 #v4 +# Install node v9 +nvm install v9 # Fetch BTCP + Build from source ./build_btcp.sh @@ -39,12 +39,13 @@ npm install npm-run-all -g cd ~ + mkdir btcp-bitcore-node cd btcp-bitcore-node # Install Bitcore (Headless) -nvm use v9 #v4 -npm install ch4ot1c/bitcore-node # or #4.0-btcp for daemon-compatible(?) +nvm use v9 +npm install ch4ot1c/bitcore-node # or branch 4.0-btcp (?) # Create Bitcore Node ./node_modules/bitcore-node/bin/bitcore-node create btcp-node @@ -57,6 +58,7 @@ cd btcp-node cd node_modules npm install ch4ot1c/insight-api ch4ot1c/insight --save +# Service Installation Instructions from BitPay site (for newer versions of bitcore/bitcore-node, wip): # !!! OPTIONAL [TODO present cli options] Install store-demo #cd ~ #git clone https://github.com/BTCPrivate/store-demo @@ -72,39 +74,7 @@ npm install ch4ot1c/insight-api ch4ot1c/insight --save # Create config file for Bitcore # !!! OPTIONAL TODO add store-demo and address-watch to services as specified -# Create config file for Bitcore -: ' -# daemon (4.0) (bitcoind, as opposed to bcoin) -cat << EOF > bitcore-node.json -{ - "network": "livenet", - "port": 8001, - "services": [ - "bitcoind", - "insight-api", - "insight-ui", - "web" - ], - "servicesConfig": { - "bitcoind": { - "spawn": { - "datadir": "$HOME/.btcprivate", - "exec": "$HOME/BitcoinPrivate/src/btcpd" - } - }, - "insight-ui": { - "apiPrefix": "api", - "routePrefix": "" - }, - "insight-api": { - "routePrefix": "api" - } - } -} -EOF -' - -# daemon (5.0) (bcoin) +# daemon (5.0) (uses bcoin) # optional - add bitcore-wallet-service cat << EOF > bitcore-node.json { @@ -150,7 +120,7 @@ EOF echo "To start the daemon and all services, run:" -echo "./start.sh" +echo "bitcore start" echo "\n" echo "To view the explorer in your browser - http://server_ip:8001" echo "For https, we recommend you route through Cloudflare." diff --git a/btcp_v5_node_setup.sh b/btcp_node_v5.sh similarity index 97% rename from btcp_v5_node_setup.sh rename to btcp_node_v5.sh index 823b188..7a222d0 100755 --- a/btcp_v5_node_setup.sh +++ b/btcp_node_v5.sh @@ -42,12 +42,13 @@ npm install -g BTCPrivate/bitcore # -- Bitcore -- bitcore create btcp -#bitcore install ... +#bitcore install ch4ot1c/insight-api ch4ot1c/insight +# (BTCPrivate/bitcore-wallet-service, BTCPrivate/store-demo, BTCPrivate/address-watch) cd btcp -# TODO set generated package.json's refs to ch4ot1c/ npm install +# bitcored (bitpay website approach): # !!! OPTIONAL [TODO present cli options] Install store-demo #cd ~ #git clone https://github.com/BTCPrivate/store-demo @@ -59,13 +60,9 @@ npm install #git clone https://github.com/BTCPrivate/address-watch #cd btcp-explorer/node_modules #ln -s ~/address-watch - # !!! OPTIONAL [TODO present cli options] Install bitcore-wallet-service -#bitcore install ch4ot1c/insight-api ch4ot1c/insight -# (BTCPrivate/bitcore-wallet-service, BTCPrivate/store-demo, BTCPrivate/address-watch) - # Create config file for Bitcore cat << EOF > bitcore-node.json { diff --git a/btcp_store_demo.sh b/btcp_store_demo.sh new file mode 100755 index 0000000..b5552b3 --- /dev/null +++ b/btcp_store_demo.sh @@ -0,0 +1,181 @@ +#!/bin/bash + +# BTCP Bitcore API + Explorer + Store / AddressWatch Demo + +# !!! EC2 - Make sure port 8001 is in your security group + +install_ubuntu() { + +# Get Ubuntu Dependencies +sudo apt-get update + +sudo apt-get -y install \ + build-essential pkg-config libc6-dev m4 g++-multilib \ + autoconf libtool ncurses-dev unzip git python \ + zlib1g-dev wget bsdmainutils automake + +# Install ZeroMQ libraries (Bitcore) +sudo apt-get -y install libzmq3-dev + +} + + +make_swapfile() { + +# You must have enough memory for the installation to succeed. + +PREV=$PWD +cd / +sudo dd if=/dev/zero of=swapfile bs=1M count=3000 +sudo mkswap swapfile +sudo chmod 0600 /swapfile +sudo swapon swapfile +echo "/swapfile none swap sw 0 0" | sudo tee -a etc/fstab > /dev/null +cd $PREV + +} + +clone_and_build_btcp() { + +# Clone latest Bitcoin Private source, and checkout explorer-btcp +git clone -b explorer-btcp https://github.com/BTCPrivate/BitcoinPrivate + +# Fetch BTCP/Zcash ceremony params +./BitcoinPrivate/btcputil/fetch-params.sh + +# Build Bitcoin Private +./BitcoinPrivate/btcputil/build.sh -j$(nproc) + +# Make initial, empty btcprivate.conf if needed +if [ ! -e ~/.btcprivate/btcprivate.conf ] +then + touch ~/.btcprivate/btcprivate.conf +fi + +} + +install_nvm_npm() { + +# Install npm +sudo apt-get -y install npm + +# Install nvm (npm version manager) +wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash + +# Set up nvm +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Install node v4 +nvm install v4 +nvm use v4 +nvm alias default v4 + +} + +# MongoDB dependency for bitcore-wallet-service: + +install_mongodb() { + +sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 +# Ubuntu >= 16; for prior versions, see mongodb website +echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list +sudo apt-get update +sudo apt-get install -y mongodb-org + +# Make initial empty db dir +sudo mkdir -p /data/db + +} + + +install_bitcore() { + +# Install Bitcore (Headless) +npm install BTCPrivate/bitcore-node-btcp + +# Create Bitcore Node +./node_modules/bitcore-node-btcp/bin/bitcore-node create btcp-explorer +cd btcp-explorer + +# Install Insight API / UI (Explorer) (Headless) +../node_modules/bitcore-node-btcp/bin/bitcore-node install BTCPrivate/insight-api-btcp BTCPrivate/insight-ui-btcp BTCPrivate/store-demo +# (BTCPrivate/address-watch) (BTCPrivate/bitcore-wallet-service (untested)) + + +# Create config file for Bitcore +cat << EOF > bitcore-node.json +{ + "network": "livenet", + "port": 8001, + "services": [ + "bitcoind", + "insight-api-btcp", + "insight-ui-btcp", + "store-demo", + "web" + ], + "servicesConfig": { + "bitcoind": { + "spawn": { + "datadir": "$HOME/.btcprivate", + "exec": "$HOME/BitcoinPrivate/src/btcpd" + } + }, + "insight-ui-btcp": { + "apiPrefix": "api", + "routePrefix": "" + }, + "insight-api-btcp": { + "routePrefix": "api" + } + } +} +EOF + +} + +# -- Begin Fetching + Building -- +cd ~ + +echo "Begin Setup." +echo "" + +install_ubuntu + +echo "" +echo "Can we make you a 3gb swapfile? EC2 Micro needs it because it takes a lot of memory to build BTCP." +echo "" +read -r -p "[y/N] " response +case "$response" in + [yY][eE][sS]|[yY]) + make_swapfile + clone_and_build_btcp + ;; + *) + clone_and_build_btcp + ;; +esac + + +install_nvm_npm + +#install_mongodb + +install_bitcore + +echo "Complete." +echo "" + +# Verify that nvm is exported +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +echo "To start mongodb for bitcore-wallet-service, run 'mongod &'" +echo "To start the bitcore-node, run:" +echo "cd ~/btcp-explorer; nvm use v4; ./node_modules/bitcore-node-btcp/bin/bitcore-node start" +echo "" +echo "To view the explorer in your browser - http://server_ip:8001" +echo "For https, we recommend you route through Cloudflare. bitcore-node also supports it via the config; provide certs." diff --git a/start.sh b/start_v5.sh similarity index 54% rename from start.sh rename to start_v5.sh index 363a5f1..cf1af9c 100755 --- a/start.sh +++ b/start_v5.sh @@ -6,8 +6,9 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion # Start Bitcore Services (and Daemon) -nvm use v9 #v4 +# For >= 5.0 (bitpay website instructions) +nvm use v9; bitcored + +# For earlier versions: +# cd btcp-explorer; nvm use v4; ./node_modules/bitcore-node/bin/bitcore-node start -./node_modules/bitcore-node/bin/bitcore-node start -# (run this from where you ran `bitcore create x` (btcp-bitcore-node)) -# (or, if set up like the >= 5.0 bitpay website instructions, just `bitcored`)