From ee66e7a20c50eb2cac4ce3f3d2bd43cd3fd79354 Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Sun, 13 Oct 2024 19:14:43 +0300 Subject: [PATCH] additional check for keys in genesis added, purely experimented feature Signed-off-by: Uncle Stinky --- scripts/starter.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/scripts/starter.sh b/scripts/starter.sh index 507342d..2003976 100755 --- a/scripts/starter.sh +++ b/scripts/starter.sh @@ -46,12 +46,27 @@ sanity_check() { echo "[+] inspected account id for $3: $account_id" num_keys=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | wc -l) num_types=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | grep $3 | wc -l) - if [ ! $num_keys = 1 ] || [ ! $num_types = 1 ]; then + if [ $num_keys = 1 ] && [ $num_types = 1 ]; then + echo "[+] local $3 key found in 'ghosties' with correct key type" + else echo "[-] inspected account id not found on 'ghosties' file or wrong key type" exit 1 fi } +genesis_check() { + secret_seed=$(ghost key inspect --scheme="$1" "$2" | grep "Secret seed" | awk '{ print $3 }') + account_id=$(ghost key inspect --scheme="$1" "$2" | grep "Account ID" | awk '{ print $3 }') + + num_keys=$(grep ${account_id:2} "$PROJECT_FOLDER/service/chain-specs/casper.json" | wc -l) + if [ ! $num_keys = 0 ]; then + echo "[+] found in genesis block" + else + echo "[-] not yet in genesis block" + fi + echo +} + extract_seed() { name_with_spaces=$(echo $1 | tr '-' ' ') read -p "[?] path to the file with $name_with_spaces: (default: /etc/ghost/$1) " seed_path @@ -351,13 +366,11 @@ fi if [ $CHECK_KEYS = true ]; then seed=$(extract_seed "wallet-key") sanity_check "sr25519" $seed "wallet" - echo "[+] local wallet key found in 'ghosties' with correct key type" - echo + genesis_check "sr25519" $seed "wallet" seed=$(extract_seed "stash-key") sanity_check "sr25519" $seed "stash" - echo "[+] local stash key from found in 'ghosties' with correct key type" - echo + genesis_check "sr25519" $seed "stash" seed=$(extract_seed "session-key") if [ $INSERT_KEYS = true ]; then @@ -373,8 +386,7 @@ if [ $CHECK_KEYS = true ]; then fi sanity_check $scheme "$seed//$type" $type - echo "[+] inspected account id found in 'ghosties' file with correct key type" - + genesis_check $scheme "$seed//$type" $type if [ $INSERT_KEYS = true ]; then echo "[+] trying to make an 'author_insertKey' RPC call to $rpc_endpoint..." curl --location $rpc_endpoint \