#!/bin/bash

sudo apt-get update && sudo apt-get upgrade -y

cd $HOME

wget "https://bitcoinnew.org/bitcoinnew-qt-linux.tar.gz" -O bitcoinnew-qt-linux.tar.gz

mkdir $HOME/Desktop/BitcoinNew

tar -xzvf bitcoinnew-qt-linux.tar.gz --directory $HOME/Desktop/BitcoinNew

mkdir $HOME/.bitcoinnew

cat << EOF > $HOME/.bitcoinnew/bitcoinnew.conf
rpcuser=rpc_bitcoinnew
rpcpassword=dR2oBQ3K1zYMZQtJFZeAerhWxaJ5Lqeq9J2
rpcbind=127.0.0.1
rpcallowip=127.0.0.1
listen=1
server=1
addnode=148.72.152.63
addnode=85.10.148.5
addnode=node4.bitcoinnew.org
EOF

cat << EOF > $HOME/Desktop/BitcoinNew/start_wallet.sh
#!/bin/bash
SCRIPT_PATH=\`pwd\`;
cd \$SCRIPT_PATH
./bitcoinnew-qt
EOF

chmod +x $HOME/Desktop/BitcoinNew/start_wallet.sh

cat << EOF > $HOME/Desktop/BitcoinNew/mine.sh
#!/bin/bash
SCRIPT_PATH=\`pwd\`;
cd \$SCRIPT_PATH
while :
do
./bitcoinnew-cli generatetoaddress 1 \$(./bitcoinnew-cli getnewaddress)
done
EOF

chmod +x $HOME/Desktop/BitcoinNew/mine.sh
    
exec $HOME/Desktop/BitcoinNew/bitcoinnew-qt &

sleep 15

cd $HOME/Desktop/BitcoinNew/

clear

exec $HOME/Desktop/BitcoinNew/mine.sh