Skip to content

Instantly share code, notes, and snippets.

@dnldd
Forked from davecgh/dcrdsimnetsetup8nodes.sh
Last active July 6, 2018 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnldd/a3c608c379f5021518d233e5c67e18e2 to your computer and use it in GitHub Desktop.
Save dnldd/a3c608c379f5021518d233e5c67e18e2 to your computer and use it in GitHub Desktop.
script to create a sample 3 node decred simnet network
#!/bin/sh
set -e
SIMNET_NODES_ROOT=~/dcrdsimnetnodes
MASTERNODE_ADDR=127.0.0.1:19555
NODE1_ADDR=127.0.0.1:19501
NODE2_ADDR=127.0.0.1:19502
RPCUSER="USER"
RPCPASS="PASS"
WALLET_SEED="b280922d2cffda44648346412c5ec97f429938105003730414f10b01e1402eac"
WALLET_MINING_ADDR="SsWKp7wtdTZYabYFYSc9cnxhwFEjA5g4pFc" # NOTE: This must be changed if the seed is changed.
mkdir -p "${SIMNET_NODES_ROOT}/"{master,1,2,wallet}
# masternode.conf
cat > "${SIMNET_NODES_ROOT}/masternode.conf" <<EOF
rpcuser=${RPCUSER}
rpcpass=${RPCPASS}
simnet=1
logdir=${SIMNET_NODES_ROOT}/master/log
datadir=${SIMNET_NODES_ROOT}/master/data
listen=${MASTERNODE_ADDR}
connect=${NODE1_ADDR}
connect=${NODE2_ADDR}
miningaddr=${WALLET_MINING_ADDR}
EOF
# node1.conf
cat > "${SIMNET_NODES_ROOT}/node1.conf" <<EOF
simnet=1
logdir=${SIMNET_NODES_ROOT}/1/log
datadir=${SIMNET_NODES_ROOT}/1/data
listen=${NODE1_ADDR}
connect=${MASTERNODE_ADDR}
connect=${NODE2_ADDR}
EOF
# node2.conf
cat > "${SIMNET_NODES_ROOT}/node2.conf" <<EOF
simnet=1
logdir=${SIMNET_NODES_ROOT}/2/log
datadir=${SIMNET_NODES_ROOT}/2/data
listen=${NODE2_ADDR}
connect=${MASTERNODE_ADDR}
connect=${NODE1_ADDR}
EOF
# dcrctl.conf
cat > "${SIMNET_NODES_ROOT}/dcrctl.conf" <<EOF
simnet=1
rpcuser=${RPCUSER}
rpcpass=${RPCPASS}
EOF
# dcrwallet.conf
cat > "${SIMNET_NODES_ROOT}/dcrwallet.conf" <<EOF
simnet=1
username=${RPCUSER}
password=${RPCPASS}
appdata=${SIMNET_NODES_ROOT}/wallet
promptpass=1
enablevoting=1
enableticketbuyer=1
ticketbuyer.nospreadticketpurchases=1
ticketbuyer.maxperblock=5
EOF
# dcrctlw.conf
cat > "${SIMNET_NODES_ROOT}/dcrctlw.conf" <<EOF
simnet=1
wallet=1
rpcuser=${RPCUSER}
rpcpass=${RPCPASS}
rpccert=${SIMNET_NODES_ROOT}/wallet/rpc.cert
EOF
echo "Launch the dcrd simnet instances with the following config files:"
echo "dcrd -C ${SIMNET_NODES_ROOT}/masternode.conf"
echo "dcrd -C ${SIMNET_NODES_ROOT}/node1.conf"
echo "dcrd -C ${SIMNET_NODES_ROOT}/node2.conf"
echo ""
echo "Create the wallet -- MAKE SURE TO USE THE PRINTED SEED!!!"
echo "dcrwallet -C ${SIMNET_NODES_ROOT}/dcrwallet.conf --create"
echo "Seed: ${WALLET_SEED}"
echo ""
echo "Launch the wallet:"
echo "dcrwallet -C ${SIMNET_NODES_ROOT}/dcrwallet.conf"
echo ""
echo "To interface with the master dcrd node via dcrctl:"
echo "dcrctl -C ${SIMNET_NODES_ROOT}/dcrctl.conf <command>"
echo ""
echo "To interface with the wallet via dcrctl:"
echo "dcrctl -C ${SIMNET_NODES_ROOT}/dcrctlw.conf <command>"
echo ""
echo "To generate blocks with the CPU miner via dcrctl:"
echo "dcrctl -C ${SIMNET_NODES_ROOT}/dcrctl.conf generate 1"
echo ""
echo "NOTE: Because the simnet difficulty is so low, the blocks will be found"
echo "faster than the tickets can be purchased during the initial bringup, so"
echo "it is recommended to generate enough blocks to reach the voting height"
echo "with a script that sleeps after each block is generated as follows:"
echo ""
echo "for i in \$(seq 1 1 144); do dcrctl -C ${SIMNET_NODES_ROOT}/dcrctl.conf generate 1; sleep 1; done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment