|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Script for creating keys for a cardano pool (SPO) / Tests only |
| 4 | +## Inspired from https://docs.cardano.org/development-guidelines/operating-a-stake-pool/creating-a-stake-pool |
| 5 | + |
| 6 | +# Import prelude |
| 7 | +. $(dirname -- "$0")/_prelude.sh |
| 8 | + |
| 9 | +# Create keys and addresses |
| 10 | +## Create payment keypair |
| 11 | +CARDANO_CLI_CMD address key-gen \s |
| 12 | +--verification-key-file ${POOL_ARTIFACTS_DIR}/payment.vkey \ |
| 13 | +--signing-key-file ${POOL_ARTIFACTS_DIR}/payment.skey |
| 14 | + |
| 15 | +## Create stake keypair |
| 16 | +CARDANO_CLI_CMD stake-address key-gen \ |
| 17 | +--verification-key-file ${POOL_ARTIFACTS_DIR}/stake.vkey \ |
| 18 | +--signing-key-file ${POOL_ARTIFACTS_DIR}/stake.skey |
| 19 | + |
| 20 | +## Create payment address |
| 21 | +CARDANO_CLI_CMD address build \ |
| 22 | +--payment-verification-key-file ${POOL_ARTIFACTS_DIR}/payment.vkey \ |
| 23 | +--stake-verification-key-file ${POOL_ARTIFACTS_DIR}/stake.vkey \ |
| 24 | +--out-file ${POOL_ARTIFACTS_DIR}/payment.addr \ |
| 25 | +--testnet-magic $NETWORK_MAGIC |
| 26 | + |
| 27 | +## Create stake address |
| 28 | +CARDANO_CLI_CMD stake-address build \ |
| 29 | +--stake-verification-key-file ${POOL_ARTIFACTS_DIR}/stake.vkey \ |
| 30 | +--out-file ${POOL_ARTIFACTS_DIR}/stake.addr \ |
| 31 | +--testnet-magic $NETWORK_MAGIC |
| 32 | + |
| 33 | +# 2. Generate your stake pool keys |
| 34 | +## Generate Cold Keys and a Cold_counter |
| 35 | +CARDANO_CLI_CMD node key-gen \ |
| 36 | +--cold-verification-key-file ${POOL_ARTIFACTS_DIR}/cold.vkey \ |
| 37 | +--cold-signing-key-file ${POOL_ARTIFACTS_DIR}/cold.skey \ |
| 38 | +--operational-certificate-issue-counter-file ${POOL_ARTIFACTS_DIR}/opcert.counter |
| 39 | + |
| 40 | +## Generate VRF Key pair |
| 41 | +CARDANO_CLI_CMD node key-gen-VRF \ |
| 42 | +--verification-key-file ${POOL_ARTIFACTS_DIR}/vrf.vkey \ |
| 43 | +--signing-key-file ${POOL_ARTIFACTS_DIR}/vrf.skey |
| 44 | + |
| 45 | +## Generate the KES Key pair |
| 46 | +CARDANO_CLI_CMD node key-gen-KES \ |
| 47 | +--verification-key-file ${POOL_ARTIFACTS_DIR}/kes.vkey \ |
| 48 | +--signing-key-file ${POOL_ARTIFACTS_DIR}/kes.skey |
| 49 | + |
| 50 | +## Generate the Operational Certificate |
| 51 | +### Compute KES period |
| 52 | +SLOT=$(CARDANO_CLI_CMD query tip --testnet-magic $NETWORK_MAGIC | jq .slot) |
| 53 | +SLOTS_KES_PERIOD=$(cat $GENESIS_FILE | jq .slotsPerKESPeriod) |
| 54 | +KES_PERIOD=`expr $SLOT / $SLOTS_KES_PERIOD` |
| 55 | + |
| 56 | +### Generate Operational Certificate |
| 57 | +CARDANO_CLI_CMD node issue-op-cert \ |
| 58 | +--kes-verification-key-file ${POOL_ARTIFACTS_DIR}/kes.vkey \ |
| 59 | +--cold-signing-key-file ${POOL_ARTIFACTS_DIR}/cold.skey \ |
| 60 | +--operational-certificate-issue-counter ${POOL_ARTIFACTS_DIR}/opcert.counter \ |
| 61 | +--kes-period $KES_PERIOD \ |
| 62 | +--out-file ${POOL_ARTIFACTS_DIR}/opcert.cert |
| 63 | + |
| 64 | +### Create a registration certificate |
| 65 | +CARDANO_CLI_CMD stake-address registration-certificate \ |
| 66 | +--stake-verification-key-file ${POOL_ARTIFACTS_DIR}/stake.vkey \ |
| 67 | +--out-file ${POOL_ARTIFACTS_DIR}/stake.cert |
| 68 | + |
| 69 | +### Compute Pool Id |
| 70 | +POOL_ID=$(CARDANO_CLI_CMD stake-pool id --cold-verification-key-file ${POOL_ARTIFACTS_DIR}/cold.vkey) |
| 71 | +echo $POOL_ID > ${POOL_ARTIFACTS_DIR_PREFIX}${POOL_ARTIFACTS_DIR}/pool-id.txt |
| 72 | +echo POOL_ID=$POOL_ID |
| 73 | + |
| 74 | +### Send funds to / Check utxo payment address |
| 75 | +echo Send funds to "$(cat ${POOL_ARTIFACTS_DIR_PREFIX}${POOL_ARTIFACTS_DIR}/payment.addr)" at https://docs.cardano.org/cardano-testnet/tools/faucet |
| 76 | +while true |
| 77 | +do |
| 78 | + UTXO_ROWS_NUMBER=`expr $(CARDANO_CLI_CMD query utxo --address $(cat ${POOL_ARTIFACTS_DIR_PREFIX}${POOL_ARTIFACTS_DIR}/payment.addr) --testnet-magic $NETWORK_MAGIC 2> /dev/null | wc -l) - 2` |
| 79 | + if [ $UTXO_ROWS_NUMBER -gt 0 ] ; then |
| 80 | + echo ">>>> Funds Received!" |
| 81 | + break |
| 82 | + else |
| 83 | + echo ">>>> Waiting for Funds..." |
| 84 | + sleep 10 |
| 85 | + fi |
| 86 | +done |
0 commit comments