Guest User

Untitled

a guest
Oct 6th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Tmux setup for running an spv wallet. This creates two wallets (connected to
  4. # the same master node): one using regular RPC mode with the ticketbuyer and
  5. # voting enabled and a second one with SPV enabled. It receives some coins
  6. # after block 32.
  7. #
  8. # The spv wallet is created in the "spv" dir.
  9.  
  10. set -e
  11.  
  12. SESSION="dcrd-spv"
  13. NODES_ROOT=~/dcrdsimnetnodes
  14. RPCUSER="USER"
  15. RPCPASS="PASS"
  16. WALLET_SEED="b280922d2cffda44648346412c5ec97f429938105003730414f10b01e1402eac"
  17. WALLET_MINING_ADDR="SsWKp7wtdTZYabYFYSc9cnxhwFEjA5g4pFc" # NOTE: This must be changed if the seed is changed.
  18.  
  19. SPV_WALLET_SEED="1111111111111111111111111111111111111111111111111111111111111111"
  20.  
  21.  
  22. if [ -d "${NODES_ROOT}" ] ; then
  23. rm -R "${NODES_ROOT}"
  24. fi
  25.  
  26. mkdir -p "${NODES_ROOT}/"{master,wallet,spv}
  27.  
  28. #############################
  29. # Config Files
  30. #############################
  31.  
  32. cat > "${NODES_ROOT}/dcrd.conf" <<EOF
  33. rpcuser=${RPCUSER}
  34. rpcpass=${RPCPASS}
  35. simnet=1
  36. logdir=./log
  37. datadir=./data
  38. txindex=1
  39. ; debuglevel=TXMP=TRACE,MINR=TRACE,CHAN=TRACE
  40. EOF
  41.  
  42. cat > "${NODES_ROOT}/dcrctl.conf" <<EOF
  43. rpcuser=${RPCUSER}
  44. rpcpass=${RPCPASS}
  45. simnet=1
  46. EOF
  47.  
  48. cat > "${NODES_ROOT}/wallet/wallet.conf" <<EOF
  49. username = ${RPCUSER}
  50. password = ${RPCPASS}
  51. simnet = 1
  52. logdir = ./log
  53. appdata = ./data
  54. pass = 123
  55. enablevoting = 1
  56. enableticketbuyer = 1
  57. ticketbuyer.nospreadticketpurchases = 1
  58. ticketbuyer.maxperblock = 5
  59. ; ticketbuyer.minfee = 0.002
  60. EOF
  61.  
  62. cat > "${NODES_ROOT}/spv/wallet.conf" <<EOF
  63. username = ${RPCUSER}
  64. password = ${RPCPASS}
  65. simnet = 1
  66. logdir = ./log
  67. appdata = ./data
  68. pass = 123
  69. spv = 1
  70. spvconnect = 127.0.0.1:19555
  71. rpclisten = 127.0.0.1:19567
  72. nogrpc = 1
  73. EOF
  74.  
  75.  
  76. #############################
  77. # Scripts
  78. #############################
  79.  
  80. # Master Node
  81.  
  82. cat > "${NODES_ROOT}/master/ctl" <<EOF
  83. #!/bin/sh
  84. dcrctl -C ../dcrctl.conf \$*
  85. EOF
  86. chmod +x "${NODES_ROOT}/master/ctl"
  87.  
  88. cat > "${NODES_ROOT}/master/mine" <<EOF
  89. #!/bin/sh
  90. NUM=1
  91. case \$1 in
  92. ''|*[!0-9]*) ;;
  93. *) NUM=\$1 ;;
  94. esac
  95.  
  96. for i in \$(seq \$NUM) ; do
  97. dcrctl -C ../dcrctl.conf generate 1
  98. sleep 0.3
  99. done
  100. EOF
  101. chmod +x "${NODES_ROOT}/master/mine"
  102.  
  103.  
  104. # RPC Wallet
  105.  
  106. cat > "${NODES_ROOT}/wallet/ctl" <<EOF
  107. #!/bin/sh
  108. dcrctl -C ../dcrctl.conf --wallet -c ./data/rpc.cert \$*
  109. EOF
  110. chmod +x "${NODES_ROOT}/wallet/ctl"
  111.  
  112. cat > "${NODES_ROOT}/wallet/tickets" <<EOF
  113. #!/bin/sh
  114. NUM=1
  115. case \$1 in
  116. ''|*[!0-9]*) ;;
  117. *) NUM=\$1 ;;
  118. esac
  119.  
  120. ./ctl purchaseticket default 999999 1 \`./ctl getnewaddress\` \$NUM
  121. EOF
  122. chmod +x "${NODES_ROOT}/wallet/tickets"
  123.  
  124. cat > "${NODES_ROOT}/wallet/xfer" <<EOF
  125. #!/bin/sh
  126. ./ctl sendtoaddress \`./ctl getnewaddress\` 0.1
  127. EOF
  128. chmod +x "${NODES_ROOT}/wallet/xfer"
  129.  
  130.  
  131. # SPV Wallet
  132.  
  133. cat > "${NODES_ROOT}/spv/ctl" <<EOF
  134. #!/bin/sh
  135. dcrctl -C ../dcrctl.conf --wallet -c ./data/rpc.cert --walletrpcserver 127.0.0.1:19567 \$*
  136. EOF
  137. chmod +x "${NODES_ROOT}/spv/ctl"
  138.  
  139.  
  140.  
  141. #############################
  142. # Windows
  143. #############################
  144.  
  145. cd ${NODES_ROOT} && tmux -2 new-session -d -s $SESSION
  146.  
  147. tmux rename-window -t $SESSION:0 'prompt'
  148.  
  149. tmux new-window -t $SESSION:1 -n 'master'
  150. tmux split-window -v
  151. tmux select-pane -t 0
  152. tmux send-keys "cd master" C-m
  153. tmux send-keys "dcrd -C ../dcrd.conf --listen 127.0.0.1:19555 --miningaddr=${WALLET_MINING_ADDR}" C-m
  154. tmux resize-pane -D 10
  155. tmux select-pane -t 1
  156. tmux send-keys "cd master" C-m
  157.  
  158. sleep 3
  159. tmux send-keys "./ctl generate 32" C-m
  160.  
  161.  
  162. tmux new-window -t $SESSION:2 -n 'rpc-wallet'
  163. tmux split-window -v
  164. tmux select-pane -t 0
  165. tmux resize-pane -D 10
  166. tmux send-keys "cd wallet" C-m
  167. tmux send-keys "dcrwallet -C ./wallet.conf --create" C-m
  168. sleep 2
  169. tmux send-keys "123" C-m "123" C-m "n" C-m "y" C-m
  170. sleep 1
  171. tmux send-keys "${WALLET_SEED}" C-m C-m
  172. tmux send-keys "dcrwallet -C ./wallet.conf" C-m
  173. tmux select-pane -t 1
  174. tmux send-keys "cd wallet" C-m "sleep 25" C-m
  175. tmux send-keys "./ctl sendtoaddress Ssoaqgx4ecmHX54LqrUXgqi6miUFxP9iUvc 1000" C-m
  176.  
  177. tmux new-window -t $SESSION:3 -n 'spv-wallet'
  178. tmux split-window -v
  179. tmux select-pane -t 0
  180. tmux resize-pane -D 10
  181. tmux send-keys "cd spv" C-m
  182. tmux send-keys "dcrwallet -C ./wallet.conf --create" C-m
  183. sleep 2
  184. tmux send-keys "123" C-m "123" C-m "n" C-m "y" C-m
  185. sleep 1
  186. tmux send-keys "${SPV_WALLET_SEED}" C-m C-m
  187. tmux send-keys "dcrwallet -C ./wallet.conf" C-m
  188. tmux select-pane -t 1
  189. tmux send-keys "cd spv" C-m
  190.  
  191.  
  192. # Attach to session
  193.  
  194. tmux attach-session -t $SESSION
Add Comment
Please, Sign In to add comment