forked from ghostchain/ghost-node
additional check for keys in genesis added, purely experimented feature
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
bd70db94e5
commit
ee66e7a20c
@ -46,12 +46,27 @@ sanity_check() {
|
|||||||
echo "[+] inspected account id for $3: $account_id"
|
echo "[+] inspected account id for $3: $account_id"
|
||||||
num_keys=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | wc -l)
|
num_keys=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | wc -l)
|
||||||
num_types=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | grep $3 | 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"
|
echo "[-] inspected account id not found on 'ghosties' file or wrong key type"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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() {
|
extract_seed() {
|
||||||
name_with_spaces=$(echo $1 | tr '-' ' ')
|
name_with_spaces=$(echo $1 | tr '-' ' ')
|
||||||
read -p "[?] path to the file with $name_with_spaces: (default: /etc/ghost/$1) " seed_path
|
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
|
if [ $CHECK_KEYS = true ]; then
|
||||||
seed=$(extract_seed "wallet-key")
|
seed=$(extract_seed "wallet-key")
|
||||||
sanity_check "sr25519" $seed "wallet"
|
sanity_check "sr25519" $seed "wallet"
|
||||||
echo "[+] local wallet key found in 'ghosties' with correct key type"
|
genesis_check "sr25519" $seed "wallet"
|
||||||
echo
|
|
||||||
|
|
||||||
seed=$(extract_seed "stash-key")
|
seed=$(extract_seed "stash-key")
|
||||||
sanity_check "sr25519" $seed "stash"
|
sanity_check "sr25519" $seed "stash"
|
||||||
echo "[+] local stash key from found in 'ghosties' with correct key type"
|
genesis_check "sr25519" $seed "stash"
|
||||||
echo
|
|
||||||
|
|
||||||
seed=$(extract_seed "session-key")
|
seed=$(extract_seed "session-key")
|
||||||
if [ $INSERT_KEYS = true ]; then
|
if [ $INSERT_KEYS = true ]; then
|
||||||
@ -373,8 +386,7 @@ if [ $CHECK_KEYS = true ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
sanity_check $scheme "$seed//$type" $type
|
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
|
if [ $INSERT_KEYS = true ]; then
|
||||||
echo "[+] trying to make an 'author_insertKey' RPC call to $rpc_endpoint..."
|
echo "[+] trying to make an 'author_insertKey' RPC call to $rpc_endpoint..."
|
||||||
curl --location $rpc_endpoint \
|
curl --location $rpc_endpoint \
|
||||||
|
Loading…
Reference in New Issue
Block a user