youni

Terrad: Beautiful Address Generator

Sep 6th, 2022
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.70 KB | Cryptocurrency | 0 0
  1. #!/bin/sh
  2.  
  3. ## Terra address generator
  4. ##   Search addresses with a word.
  5. ##
  6. ## ATTENTION! Cannot run two processes in parallel,
  7. ##   causes inode issue: "Too many open files"
  8. ##   and also swap exaustion.
  9.  
  10.  
  11. ## Config
  12.  
  13. word1='yyyy'
  14. word2=''
  15.  
  16. n=5 #how much addresses to find
  17.  
  18. #where to search
  19. #  1 - search word1 in any place
  20. #  2 - search word1 in the begining only, straight after terra1
  21. #  3 - search word1 in end only
  22. #  4 - search word1 in the begining and word2 in the end simultaniously
  23. where=2
  24.  
  25.  
  26. ## Main code starts here
  27.  
  28. case $where in
  29.     1) echo Search '"'$word1'"' in any place;;
  30.     2) echo Search '"'$word1'"' in the begining only, straight after terra1;;
  31.     3) echo Search '"'$word1'"' in the end;;
  32.     4) echo Search '"'$word1'"' in the beginning and '"'$word2'"' in the end simultaniously;;
  33. esac
  34.  
  35. while [ $n -gt 0 ]; do
  36.     found='false'
  37.     s=$(terrad keys add 1 --dry-run 2>&1)
  38.     address=$(echo "$s" | head -4 | tail -1 | sed -e 's/.*address: \([0-9a-z]*\)/\1/')
  39.     #echo $address
  40.     case $where in
  41.         1)
  42.             #echo Search '"'$word1'"' in any place
  43.             [ -z "${address##*$word1*}" ] && found='true'
  44.             ;;
  45.         2)
  46.             #echo Search '"'$word1'"' in the begining only, straight after terra1
  47.             [ -z "${address##terra1$word1*}" ] && found='true' && echo found
  48.             ;;
  49.         3)
  50.             #echo Search '"'$word1'"' in the end
  51.             [ -z "${address##*$word1}" ] && found='true'
  52.             ;;
  53.         4)
  54.             #echo Search '"'$word1'"' in the beginning and '"'$word2'"' in the end simultaniously
  55.             [ -z "${address##terra1$word1*$word2}" ] && found='true'
  56.             ;;
  57.     esac
  58.     if [ "$found" = 'true' ]; then
  59.         echo $address >> terra.log
  60.         echo "$s" | tail -1 >> terra.log
  61.         echo '' >> terra.log
  62.         n=$((n-1))
  63.         echo address stored
  64.     fi
  65. done
Advertisement
Add Comment
Please, Sign In to add comment