github.com/turingchain2020/turingchain@v1.1.21/build/wallet-init.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  function SendToPrivacyExec() {
     4      name=$1
     5      fromAdd=$2
     6      execAdd=$3
     7      note=$4
     8      amount=$5
     9      #sudo docker exec -it $name ./turingchain-cli send coins transfer -k $fromAdd -t $execAdd -n $note -a $amount
    10      result=$($name send coins transfer -k "${fromAdd}" -t "${execAdd}" -n "${note}" -a "${amount}")
    11      echo "hash : $result"
    12  }
    13  
    14  function pub2priv() {
    15      name=$1
    16      fromAdd=$2
    17      priAdd=$3
    18      note=$4
    19      amount=$5
    20      #sudo docker exec -it $name ./turingchain-cli privacy pub2priv -f $fromAdd -p $priAdd -a $amount -n $note
    21      result=$($name privacy pub2priv -f "${fromAdd}" -p "${priAdd}" -a "${amount}" -n "${note}" | jq -r ".hash")
    22      echo "hash : $result"
    23  }
    24  
    25  function showPrivacyExec() {
    26      name=$1
    27      fromAdd=$2
    28      printf '==========showPrivacyExec name=%s addr=%s==========\n' "${name}" "${fromAdd}"
    29      result=$($name account balance -e privacy -a "${fromAdd}" | jq -r ".balance")
    30      printf 'balance %s \n' "${result}"
    31  }
    32  
    33  function showPrivacyBalance() {
    34      name=$1
    35      fromAdd=$2
    36      printf '==========showPrivacyBalance name=%s addr=%s==========\n' "${name}" "${fromAdd}"
    37      result=$($name privacy showpai -a "${fromAdd}" -d 0 | jq -r ".AvailableAmount")
    38      printf 'AvailableAmount %s \n' "${result}"
    39  }
    40  
    41  function init() {
    42      echo "=========== # start set wallet 1 ============="
    43      echo "=========== # save seed to wallet ============="
    44      result=$(./turingchain-cli seed save -p 1314fuzamei -s "tortoise main civil member grace happy century convince father cage beach hip maid merry rib" | jq ".isok")
    45      if [ "${result}" = "false" ]; then
    46          echo "save seed to wallet error seed, result: ${result}"
    47          exit 1
    48      fi
    49  
    50      sleep 2
    51  
    52      echo "=========== # unlock wallet ============="
    53      result=$(./turingchain-cli wallet unlock -p 1314fuzamei -t 0 | jq ".isok")
    54      if [ "${result}" = "false" ]; then
    55          exit 1
    56      fi
    57  
    58      sleep 2
    59  
    60      echo "=========== # import private key transfer ============="
    61      result=$(./turingchain-cli account import_key -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944 -l transfer | jq ".label")
    62      echo "${result}"
    63      if [ -z "${result}" ]; then
    64          exit 1
    65      fi
    66  
    67      sleep 2
    68  
    69      echo "=========== # import private key mining ============="
    70      result=$(./turingchain-cli account import_key -k 4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01 -l mining | jq ".label")
    71      echo "${result}"
    72      if [ -z "${result}" ]; then
    73          exit 1
    74      fi
    75  
    76      sleep 2
    77      echo "=========== # set auto mining ============="
    78      result=$(./turingchain-cli wallet auto_mine -f 1 | jq ".isok")
    79      if [ "${result}" = "false" ]; then
    80          exit 1
    81      fi
    82  
    83      echo "=========== # end set wallet 1 ============="
    84  
    85  }
    86  
    87  init
    88  
    89  #构建隐私交易
    90  #    sleep 20
    91  #    name="./turingchain-cli"
    92  #    fromAdd="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
    93  #    execAdd="1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd"
    94  #    note="test"
    95  #    amount=100
    96  #    SendToPrivacyExec "${name}" $fromAdd $execAdd $note $amount
    97  #
    98  #    sleep 30
    99  #
   100  #    fromAdd="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
   101  #    priAdd="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
   102  #    note="pub2priv_test"
   103  #    amount=10
   104  #    pub2priv "${name}" $fromAdd $priAdd $note $amount
   105  #
   106  #
   107  #    fromAdd="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
   108  #    showPrivacyExec "${name}" $fromAdd
   109  #
   110  #    fromAdd="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
   111  #    showPrivacyBalance "${name}" $fromAdd
   112  #
   113  #    fromAdd="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
   114  #    showPrivacyBalance "${name}" $fromAdd