additional check for keys in genesis added, purely experimented feature

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2024-10-13 19:14:43 +03:00
parent bd70db94e5
commit ee66e7a20c
Signed by: st1nky
GPG Key ID: 016064BD97603B40

View File

@ -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 \