Skip to content

Commit a07fb07

Browse files
committed
Fix for Metadata-HASH comparision
Scripts 01_workOffline.sh and 05c_regStakepoolCert.sh updated to fix the online Metadata-HASH comparision in rare cases with/without a trailing LF at the end of the Metadata.json file.
1 parent 8e2d12a commit a07fb07

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

cardano/mainnet/01_workOffline.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,21 +589,22 @@ case ${transactionType} in
589589
#the one in the currently pool.json file. If they match up, continue. Otherwise exit with an ERROR
590590
#Fetch online metadata.json file from the pool webserver
591591
echo -ne "\e[0mMetadata HASH Check, fetching the MetaData JSON file from \e[32m${poolMetaUrl}\e[0m: "
592-
tmpMetadataJSON=$(curl -sL "${poolMetaUrl}" 2> /dev/null)
592+
tmpMetadataJSON="${tempDir}/tmpmetadata.json"
593+
curl -sL "${poolMetaUrl}" --output "${tmpMetadataJSON}"
593594
if [[ $? -ne 0 ]]; then echo -e "\e[35mERROR, can't fetch the metadata file from the webserver!\e[0m\n"; exit 1; fi
594595
#Check the downloaded data that is a valid JSON file
595-
tmpCheckJSON=$(echo "${tmpMetadataJSON}" | jq . 2> /dev/null)
596+
tmpCheckJSON=$(jq . "${tmpMetadataJSON}" 2> /dev/null)
596597
if [[ $? -ne 0 ]]; then echo -e "\e[35mERROR - Not a valid JSON file on the webserver!\e[0m\n"; exit 1; fi
597598
#Ok, downloaded file is a valid JSON file. So now look into the HASH
598-
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file <(echo "${tmpMetadataJSON}") )
599+
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file "${tmpMetadataJSON}")
599600
checkError "$?"; if [ $? -ne 0 ]; then exit $?; fi
600601
#Compare the HASH now, if they don't match up, output an ERROR message and exit
601602
if [[ ! "${poolMetaHash}" == "${onlineMetaHash}" ]]; then
602603
echo -e "\e[35mERROR - HASH mismatch!\n\nPlease make sure to upload your MetaData JSON file correctly to your webserver!\nPool-Registration aborted! :-(\e[0m\n";
603-
echo -e "\nYour remote file at \e[32m${poolMetaUrl}\e[0m with HASH \e[32m${onlineMetaHash}\e[0m:\n"
604-
echo -e "--- BEGIN ---\e[33m"
605-
echo "${tmpMetadataJSON}"
606-
echo -e "\e[0m--- END ---"
604+
echo -e "\nYour remote file at \e[32m${poolMetaUrl}\e[0m with HASH \e[32m${onlineMetaHash}\e[0m\ndoes not match with your local HASH \e[32m${poolMetaHash}\e[0m:\n"
605+
echo -e "--- BEGIN REMOTE FILE ---\e[33m"
606+
cat "${tmpMetadataJSON}"
607+
echo -e "\e[0m--- END REMOTE FILE ---"
607608
echo -e "\e[0m\n"
608609
exit 1;
609610
else echo -e "\e[32mOK\e[0m\n"; fi

cardano/mainnet/05c_regStakepoolCert.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,29 +162,31 @@ if ${onlineMode}; then
162162
#the one in the currently pool.json file. If they match up, continue. Otherwise exit with an ERROR
163163
#Fetch online metadata.json file from the pool webserver
164164
echo -ne "\e[0mMetadata HASH Check: Fetching the MetaData JSON file from \e[32m${poolMetaUrl}\e[0m ... "
165-
tmpMetadataJSON=$(curl -sL "${poolMetaUrl}" 2> /dev/null)
165+
tmpMetadataJSON="${tempDir}/tmpmetadata.json"
166+
curl -sL "${poolMetaUrl}" --output "${tmpMetadataJSON}"
166167
if [[ $? -ne 0 ]]; then echo -e "\e[33mERROR, can't fetch the metadata file from the webserver!\e[0m\n"; exit 1; fi
167168
#Check the downloaded data that is a valid JSON file
168-
tmpCheckJSON=$(echo "${tmpMetadataJSON}" | jq . 2> /dev/null)
169+
tmpCheckJSON=$(jq . "${tmpMetadataJSON}" 2> /dev/null)
169170
if [[ $? -ne 0 ]]; then echo -e "\e[33mERROR - Not a valid JSON file on the webserver!\e[0m\n"; exit 1; fi
170171
#Ok, downloaded file is a valid JSON file. So now look into the HASH
171-
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file <(echo "${tmpMetadataJSON}") )
172+
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file "${tmpMetadataJSON}")
172173
checkError "$?"; if [ $? -ne 0 ]; then exit $?; fi
173174
#Compare the HASH now, if they don't match up, output an ERROR message and exit
174175
if [[ ! "${poolMetaHash}" == "${onlineMetaHash}" ]]; then
175176
echo -e "\e[33mERROR - HASH mismatch!\n\nPlease make sure to upload your MetaData JSON file correctly to your webserver!\nPool-Registration aborted! :-(\e[0m\n";
176177
echo -e "Your local \e[32m${poolFile}.metadata.json\e[0m with HASH \e[32m${poolMetaHash}\e[0m:\n"
177-
echo -e "--- BEGIN ---"
178-
cat ${poolFile}.metadata.json
179-
echo -e "--- END ---\n\n"
178+
echo -e "--- BEGIN LOCAL FILE ---"
179+
cat "${poolFile}.metadata.json"
180+
echo -e "--- END LOCAL FILE ---\n\n"
180181
echo -e "Your remote file at \e[32m${poolMetaUrl}\e[0m with HASH \e[32m${onlineMetaHash}\e[0m:\n"
181-
echo -e "--- BEGIN ---\e[35m"
182-
echo "${tmpMetadataJSON}"
183-
echo -e "\e[0m--- END ---"
182+
echo -e "--- BEGIN REMOTE FILE ---\e[35m"
183+
cat "${tmpMetadataJSON}"
184+
echo -e "\e[0m--- END REMOTE FILE ---"
184185
echo -e "\e[0m\n"
185186
exit 1;
186187
else echo -e "\e[32mOK\e[0m\n"; fi
187188
#Ok, HASH is the same, continue
189+
rm ${tmpMetadataJSON} 2> /dev/null
188190

189191
fi; #onlinemode
190192

cardano/testnet/01_workOffline.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,21 +589,22 @@ case ${transactionType} in
589589
#the one in the currently pool.json file. If they match up, continue. Otherwise exit with an ERROR
590590
#Fetch online metadata.json file from the pool webserver
591591
echo -ne "\e[0mMetadata HASH Check, fetching the MetaData JSON file from \e[32m${poolMetaUrl}\e[0m: "
592-
tmpMetadataJSON=$(curl -sL "${poolMetaUrl}" 2> /dev/null)
592+
tmpMetadataJSON="${tempDir}/tmpmetadata.json"
593+
curl -sL "${poolMetaUrl}" --output "${tmpMetadataJSON}"
593594
if [[ $? -ne 0 ]]; then echo -e "\e[35mERROR, can't fetch the metadata file from the webserver!\e[0m\n"; exit 1; fi
594595
#Check the downloaded data that is a valid JSON file
595-
tmpCheckJSON=$(echo "${tmpMetadataJSON}" | jq . 2> /dev/null)
596+
tmpCheckJSON=$(jq . "${tmpMetadataJSON}" 2> /dev/null)
596597
if [[ $? -ne 0 ]]; then echo -e "\e[35mERROR - Not a valid JSON file on the webserver!\e[0m\n"; exit 1; fi
597598
#Ok, downloaded file is a valid JSON file. So now look into the HASH
598-
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file <(echo "${tmpMetadataJSON}") )
599+
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file "${tmpMetadataJSON}")
599600
checkError "$?"; if [ $? -ne 0 ]; then exit $?; fi
600601
#Compare the HASH now, if they don't match up, output an ERROR message and exit
601602
if [[ ! "${poolMetaHash}" == "${onlineMetaHash}" ]]; then
602603
echo -e "\e[35mERROR - HASH mismatch!\n\nPlease make sure to upload your MetaData JSON file correctly to your webserver!\nPool-Registration aborted! :-(\e[0m\n";
603-
echo -e "\nYour remote file at \e[32m${poolMetaUrl}\e[0m with HASH \e[32m${onlineMetaHash}\e[0m:\n"
604-
echo -e "--- BEGIN ---\e[33m"
605-
echo "${tmpMetadataJSON}"
606-
echo -e "\e[0m--- END ---"
604+
echo -e "\nYour remote file at \e[32m${poolMetaUrl}\e[0m with HASH \e[32m${onlineMetaHash}\e[0m\ndoes not match with your local HASH \e[32m${poolMetaHash}\e[0m:\n"
605+
echo -e "--- BEGIN REMOTE FILE ---\e[33m"
606+
cat "${tmpMetadataJSON}"
607+
echo -e "\e[0m--- END REMOTE FILE ---"
607608
echo -e "\e[0m\n"
608609
exit 1;
609610
else echo -e "\e[32mOK\e[0m\n"; fi

cardano/testnet/05c_regStakepoolCert.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,29 +162,31 @@ if ${onlineMode}; then
162162
#the one in the currently pool.json file. If they match up, continue. Otherwise exit with an ERROR
163163
#Fetch online metadata.json file from the pool webserver
164164
echo -ne "\e[0mMetadata HASH Check: Fetching the MetaData JSON file from \e[32m${poolMetaUrl}\e[0m ... "
165-
tmpMetadataJSON=$(curl -sL "${poolMetaUrl}" 2> /dev/null)
165+
tmpMetadataJSON="${tempDir}/tmpmetadata.json"
166+
curl -sL "${poolMetaUrl}" --output "${tmpMetadataJSON}"
166167
if [[ $? -ne 0 ]]; then echo -e "\e[33mERROR, can't fetch the metadata file from the webserver!\e[0m\n"; exit 1; fi
167168
#Check the downloaded data that is a valid JSON file
168-
tmpCheckJSON=$(echo "${tmpMetadataJSON}" | jq . 2> /dev/null)
169+
tmpCheckJSON=$(jq . "${tmpMetadataJSON}" 2> /dev/null)
169170
if [[ $? -ne 0 ]]; then echo -e "\e[33mERROR - Not a valid JSON file on the webserver!\e[0m\n"; exit 1; fi
170171
#Ok, downloaded file is a valid JSON file. So now look into the HASH
171-
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file <(echo "${tmpMetadataJSON}") )
172+
onlineMetaHash=$(${cardanocli} ${subCommand} stake-pool metadata-hash --pool-metadata-file "${tmpMetadataJSON}")
172173
checkError "$?"; if [ $? -ne 0 ]; then exit $?; fi
173174
#Compare the HASH now, if they don't match up, output an ERROR message and exit
174175
if [[ ! "${poolMetaHash}" == "${onlineMetaHash}" ]]; then
175176
echo -e "\e[33mERROR - HASH mismatch!\n\nPlease make sure to upload your MetaData JSON file correctly to your webserver!\nPool-Registration aborted! :-(\e[0m\n";
176177
echo -e "Your local \e[32m${poolFile}.metadata.json\e[0m with HASH \e[32m${poolMetaHash}\e[0m:\n"
177-
echo -e "--- BEGIN ---"
178-
cat ${poolFile}.metadata.json
179-
echo -e "--- END ---\n\n"
178+
echo -e "--- BEGIN LOCAL FILE ---"
179+
cat "${poolFile}.metadata.json"
180+
echo -e "--- END LOCAL FILE ---\n\n"
180181
echo -e "Your remote file at \e[32m${poolMetaUrl}\e[0m with HASH \e[32m${onlineMetaHash}\e[0m:\n"
181-
echo -e "--- BEGIN ---\e[35m"
182-
echo "${tmpMetadataJSON}"
183-
echo -e "\e[0m--- END ---"
182+
echo -e "--- BEGIN REMOTE FILE ---\e[35m"
183+
cat "${tmpMetadataJSON}"
184+
echo -e "\e[0m--- END REMOTE FILE ---"
184185
echo -e "\e[0m\n"
185186
exit 1;
186187
else echo -e "\e[32mOK\e[0m\n"; fi
187188
#Ok, HASH is the same, continue
189+
rm ${tmpMetadataJSON} 2> /dev/null
188190

189191
fi; #onlinemode
190192

0 commit comments

Comments
 (0)