Quick and dirty -- create stake pool ###################
# HERE BE FUN DRAGONS -- last updated ~ Wed Oct 2 23:58:28 UTC 2019
###################

# THIS IS THE OFFICIAL DOC I FOLLOWED

# *NOTE*
# these instructions have only been tested on linux machines

# PRE-REQ
# You will need to have test ADA in an account -- Get testnet ADA
# You will need to have setup your node for this... sort of -- Setup Shelley Node

# create a working dir for the pool, set a var
mkdir ~/pub_testnet01/pools
cd ~/pub_testnet01/pools
APIURL="http://127.0.0.1:3101/api"

# create vrf key pair
jcli key generate --type=Curve25519_2HashDH > pool-vrf.sk
cat pool-vrf.sk | jcli key to-public > pool-vrf.pk

# create kes key pair
jcli key generate --type=SumEd25519_12 > pool-kes.sk
cat pool-kes.sk | jcli key to-public > pool-kes.pk

# create pool cert
jcli certificate new stake-pool-registration \
    --kes-key $(cat pool-kes.pk) \
    --vrf-key $(cat pool-vrf.pk) \
    --owner $(cat ~/pub_testnet01/accounts/account.pk) \
    --start-validity 0 \
    --management-threshold 1 \
    --serial 1010101010 > stake_pool.cert

# sign stake pool cert
cat stake_pool.cert | jcli certificate sign ~/pub_testnet01/accounts/account.sk > stake_pool.signcert

# get and save pool id
cat stake_pool.cert | jcli certificate get-stake-pool-id | tee stake_pool.id

# copy the template script from repo
# - edit the script to update the values for this testnet
cp ~/src/jormungandr/scripts/faucet-send-certificate.shtempl ~/pub_testnet01/pools/faucet-send-certificate.sh
vi ~/pub_testnet01/pools/faucet-send-certificate.sh

from:
### TEMPLATE
FAUCET_SK="####FAUCET_SK####"
BLOCK0_HASH="####BLOCK0_HASH####"
REST_URL="####REST_URL####"
CLI="####CLI####"
COLORS=####COLORS####
FEE_CONSTANT=####FEE_CONSTANT####
FEE_CERTIFICATE=####FEE_CERTIFICATE####
FEE_COEFFICIENT=####FEE_COEFFICIENT####
ADDRTYPE="####ADDRTYPE####"

to:
### TEMPLATE
FAUCET_SK=$(cat /path-to/pub_testnet01/accounts/account.sk)
BLOCK0_HASH="adbdd5ede31637f6c9bad5c271eec0bc3d0cb9efb86a5b913bb55cba549d0770"
REST_URL="http://127.0.0.1:3101/api"
CLI=`which jcli`
COLORS=0
FEE_CONSTANT=1000
FEE_CERTIFICATE=10000
FEE_COEFFICIENT=50
ADDRTYPE="--testing"

# send the signed cert to the chain
# - this will output a string of chars which can be tracked as the fragment_id
bash faucet-send-certificate.sh stake_pool.signcert
YOUR_ID

# check to see the status of the fragment_id # - you may see other fargment_ids but you should see yours too
jcli rest v0 message logs -h ${APIURL}
---
- fragment_id: YOUR_ID
  last_updated_at: "2019-10-02T00:53:46.545923293+00:00"
  received_at: "2019-10-02T00:53:46.545923232+00:00"
  received_from: Rest
  status: Pending

# check your pool shows up in this
# - this will probably take until the next epoch (daily)
jcli rest v0 stake-pools get -h ${APIURL}
---
- 00c30e95ba85e4ece4a1b4a3b80c57c2e2d050367e7b0a5a8c646fd36735a1ac
- 7ab9cf75901e76b47ff7ed641d54386308dbd41db0065c8d0e9ff59baaf07cbe
- 25a46ca840894ebb337e1256a6d39c7f7b25f3b7bcd9db34ce12dda573bfcf0f
- aaeb9592744040ebf93d62892fa15e1ec8b3f609f5bd5b0232e412ab09fd7c46
- 4a05a6ad4e6bca02166ee2cab757d442b11f5231e6a96e4f0ed466cf1b3480d7
- 8c3192458a1d88ec2bb096329ef67db031c539c0759c1e7956302985a4efb86c
- edda68db1acfb83b06b5f83e268b06e066a8c05f4eaba5b479acca423ec5db2d
- 0128b3c6f22e271558f3583e927fa1a171bc7db4cea5f132a005d82d81df878d
- 2fa5db57f81c75126b6349f429370e277ed86c351e7e68beda34de41458937f6
- 6d8509b50dc9612f6db5f899f2b24d486479b61f158fd7cb9a271553c923018a
- b371c9090517bd93d2756f0434a4a2a4bcaa768f3d5d5156a7a9dcda7ceec2fa
.... the list may be longer

# once you see your node in that list you can restart your instance appending --secret
# create a file called ~/pub_testnet01/pools/node_secret.yaml (filename doesnt matter)
genesis:
  sig_key: contents of pool-kes.sk
  vrf_key: contents of pool-vrf.sk
  node_id: contents of stake_pool.id

# now you can restart the node
jormungandr --config /path-to/pub_testnet01/node_config.yaml --genesis-block-hash adbdd5ede31637f6c9bad5c271eec0bc3d0cb9efb86a5b913bb55cba549d0770 --secret /path-to/pub_testnet01/pools/node_secret.yaml

# NEXT STEP: Delegate to your stake pool!

# The Lovelace Community Pool is a no fee staking pool run by @kyleo
# Join us on Telegram

# If this was useful and you can/want to support us, our donation address is:
Ae2tdPwUPEYw3rz8KGHbnTusd9QWQ8ePhogEWkm1agugTtW51skA59DrKe8