Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #!/bin/bash
  2. # Need following config in dash.conf
  3. ## server=1
  4. ## rpcuser=AnythingYoulike
  5. ## rpcpassword=AnyPassword
  6. #
  7. # Open your wallet and unlock before run the script :)
  8. #
  9. # Suggestion for Loop `while true; do ./sum_mined.sh || break; done`
  10. #
  11. # Define the command
  12. DASH_CMD="/home/thelazier/bin/dash-cli"
  13. DASH_DIR="/home/thelazier/DashData"
  14. DASH_TX="/home/thelazier/bin/dash-tx"
  15. DASH_CLI="$DASH_CMD -datadir=$DASH_DIR"
  16.  
  17. # Address **** Your Address ****
  18. TARGET_ADDR="XbDbC3LmKy9VrsFcV9m7BjdsEJtaKPDjTo"
  19.  
  20. # Get current block
  21. v_blocks=$($DASH_CLI getinfo|grep -iw blocks| cut -d: -f2|cut -d, -f1|awk -e '{print $1}')
  22.  
  23. # Get unspent vouts
  24. $DASH_CLI listunspent 555 $v_blocks [\"$TARGET_ADDR\"] > listunspent.json
  25. pr -mJt \
  26. <(grep -o ".*: .*," listunspent.json | grep -iw txid | cut -d: -f2| cut -d '"' -f2|awk -e '{print $1}') \
  27. <(grep -o ".*: .*," listunspent.json | grep -iw vout | cut -d: -f2| cut -d, -f1|awk -e '{print $1}') \
  28. <(grep -o ".*: .*," listunspent.json | grep -iw amount | cut -d: -f2 | cut -d, -f1|awk -e '{print $1}') \
  29. | awk -e '{print $1":"$2","$3}' |sort -t, -k2 -n > listunspent.in
  30. v_outs=$(cat listunspent.in |cut -d, -f1|awk -e '{print "in="$1}'|head -$v_numvin)
  31. if [ -z "$v_outs" ]; then exit 1; fi
  32.  
  33. # Get amounts
  34. v_amnt=$(cat listunspent.in |cut -d, -f2|head -$v_numvin |paste -sd'+'|xargs -i perl -e 'print '{})
  35. if [ -z "$v_amnt" ]; then exit 1; fi
  36.  
  37. # Get rawtx
  38. v_rawtx=$($DASH_TX -create $v_outs outaddr=$v_amnt:$TARGET_ADDR)
  39. if [ -z "$v_rawtx" ]; then exit 1; fi
  40.  
  41. # Sign tx
  42. v_sign_tx=$($DASH_CLI signrawtransaction $v_rawtx|grep -iw hex|cut -d'"' -f4)
  43. if [ -z "$v_sign_tx" ]; then exit 1; fi
  44.  
  45. # Send Tx
  46. v_txid=$($DASH_CLI sendrawtransaction $v_sign_tx )
  47. if [ -z "$v_txid" ]; then exit 1; fi
  48.  
  49. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement