Advertisement
Gryph_The_Grey

v0.7.0CSP.sh

Dec 9th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Disclaimer:
  4. #
  5. # The following use of shell script is for demonstration and understanding
  6. # only, it should *NOT* be used at scale or for any sort of serious
  7. # deployment, and is solely used for learning how the node and blockchain
  8. # works, and how to interact with everything.
  9. #
  10. # It also asumes that `jcli` is in the same folder with the script.
  11. #
  12. # Scenario:
  13. # Configure 1 stake pool having as owner the provided account address (secret key)
  14. #
  15. # Tutorials can be found here: https://github.com/input-output-hk/shelley-testnet/wiki
  16.  
  17. ### CONFIGURATION
  18. CLI="jcli"
  19. COLORS=1
  20. ADDRTYPE="--testing"
  21.  
  22. if [ $# -ne 2 ]; then
  23. echo "usage: $0 <REST-LISTEN-PORT> <ACCOUNT_SK>"
  24. echo " <REST-PORT> The REST Listen Port set in node-config.yaml file (EX: 3101)"
  25. echo " <SOURCE-SK> The Secret key of the Source address"
  26. exit 1
  27. fi
  28.  
  29. REST_PORT="$1"
  30. ACCOUNT_SK="$2"
  31.  
  32. REST_URL="http://127.0.0.1:${REST_PORT}/api"
  33. BLOCK0_HASH=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'block0Hash:' | sed -e 's/^[[:space:]]*//' | sed -e 's/block0Hash: //')
  34. FEE_CONSTANT=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'constant:' | sed -e 's/^[[:space:]]*//' | sed -e 's/constant: //')
  35. FEE_COEFFICIENT=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'coefficient:' | sed -e 's/^[[:space:]]*//' | sed -e 's/coefficient: //')
  36. FEE_CERTIFICATE=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'certificate:' | sed -e 's/^[[:space:]]*//' | sed -e 's/certificate: //')
  37.  
  38. ACCOUNT_PK=$(echo ${ACCOUNT_SK} | $CLI key to-public)
  39. ACCOUNT_ADDR=$($CLI address account ${ADDRTYPE} ${ACCOUNT_PK})
  40.  
  41. echo "================Create Stake Pool================="
  42. echo "REST_PORT: ${REST_PORT}"
  43. echo "ACCOUNT_SK: ${ACCOUNT_SK}"
  44. echo "BLOCK0_HASH: ${BLOCK0_HASH}"
  45. echo "FEE_CONSTANT: ${FEE_CONSTANT}"
  46. echo "FEE_COEFFICIENT: ${FEE_COEFFICIENT}"
  47. echo "FEE_CERTIFICATE: ${FEE_CERTIFICATE}"
  48. echo "=================================================="
  49.  
  50. echo " ##1. Create VRF keys"
  51. POOL_VRF_SK=$($CLI key generate --type=Curve25519_2HashDH)
  52. POOL_VRF_PK=$(echo ${POOL_VRF_SK} | $CLI key to-public)
  53.  
  54. echo POOL_VRF_SK: ${POOL_VRF_SK}
  55. echo POOL_VRF_PK: ${POOL_VRF_PK}
  56.  
  57. echo " ##2. Create KES keys"
  58. POOL_KES_SK=$($CLI key generate --type=SumEd25519_12)
  59. POOL_KES_PK=$(echo ${POOL_KES_SK} | $CLI key to-public)
  60.  
  61. echo POOL_KES_SK: ${POOL_KES_SK}
  62. echo POOL_KES_PK: ${POOL_KES_PK}
  63.  
  64. echo " ##3. Create the Stake Pool certificate using above VRF and KEY public keys"
  65. $CLI certificate new stake-pool-registration --kes-key ${POOL_KES_PK} --vrf-key ${POOL_VRF_PK} --owner ${ACCOUNT_PK} --serial 1010101010 --start-validity 0 --management-threshold 1 >stake_pool.cert
  66.  
  67. cat stake_pool.cert
  68.  
  69. echo " ##5. Send the signed Stake Pool certificate to the blockchain"
  70. ./send-certificate.sh stake_pool.cert ${REST_PORT} ${ACCOUNT_SK}
  71.  
  72. echo " ##6. Retrieve your stake pool id (NodeId)"
  73. cat stake_pool.cert | $CLI certificate get-stake-pool-id | tee stake_pool.id
  74.  
  75. NODE_ID=$(cat stake_pool.id)
  76.  
  77. echo "The Node ID is: ${NODE_ID}"
  78.  
  79. echo " ##7. Creating the node_secret.yaml file"
  80. #define the template.
  81. cat > node_secret.yaml << EOF
  82. genesis:
  83. sig_key: ${POOL_KES_SK}
  84. vrf_key: ${POOL_VRF_SK}
  85. node_id: ${NODE_ID}
  86. EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement