You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated SCRIPT - 15_calidusPoolKey.sh
- The newly introduced script 15 has now two new functions:
* You can now QUERY your pool-id or your calidus-id
* You can now simply sign via ed25519 signing method
Examples:
15_calidusPoolKey.sh query all
... to get all current calidus key registrations
15_calidusPoolKey.sh query mypool
15_calidusPoolKey.sh query pool1w83ux7vrwafrsuz044knxl9xxtr38q5jj2l3p28fl3g26faqqwg
... to get results for your selected pool
15_calidusPoolKey.sh query mycalidus
15_calidusPoolKey.sh query calidus15xcc3mphdwu8amrx9m6v9v4552pugr2gcsj4m8arjmx3zwc8yf8ng
... to get results for your selected calidus key
15_calidusPoolKey.sh sign myKey "hello world"
... to sign the message-text "hello world" with your calidus key
if [ -f"${calidusRegistrationFile}" ];thenecho -e "\e[35mError - ${calidusRegistrationFile} already exists, please delete it first if you wanna overwrite it !\e[0m\n";exit 1;fi
213
227
214
228
echo -e "\e[0mGenerating the Calidus-Registration-MetadataFile(JSON): \e[32m${calidusRegistrationFile}\e[0m"
if ${offlineMode}; then echo -e "\e[35mYou have to be in ONLINE MODE to do this!\e[0m\n"; exit 1; fi
456
+
#Query only possible if not offline mode
457
+
if ${offlineMode}; then echo -e "\e[35mYou have to be in ONLINE MODE to do this!\e[0m\n"; exit 1; fi
458
+
459
+
#Check about input parameters
460
+
if [[ ${paramCnt} -ne 2 ]]; then echo -e "\e[35mIncorrect parameter count!\e[0m\n"; showUsage; exit 1; fi
461
+
462
+
paramValue=${allParameters[1]} #get the parameter behind "query". that can be a calidus public key hex, calidus-pool-key in bech format, a calidus-key.vkey file, a pool-id in bech format or a pool.node.vkey file
463
+
464
+
#Check if its a Calidus-ID in Bech-Format
465
+
if [[ "${paramValue:0:8}" == "calidus1" && ${#paramValue} -eq 61 ]]; then #parameter is most likely a calidus id in bech format
466
+
echo -ne "\e[0mCheck if given Calidus Bech-ID\e[32m ${paramValue}\e[0m is valid ..."
467
+
calidusIdHex=$(${bech32_bin}2> /dev/null <<<"${paramValue,,}") #will have returncode 0 if the bech was valid
468
+
if [[ $? -ne 0 || ${calidusIdHex:0:2} != "a1" ]]; then echo -e "\n\n\e[91mERROR - \"${paramValue}\" is not a valid Calidus-ID.\e[0m"; exit 1; fi
469
+
echo -e "\e[32m OK\e[0m\n"
470
+
calidusIdBech=${paramValue,,}
471
+
searchType="Calidus ID";
472
+
473
+
#Check if its a Calidus-ID file with a Bech-ID
474
+
elif [[ -f "${paramValue}.calidus.id" ]]; then #parameter is a Calidus ID file, containing a bech32 id
475
+
echo -ne "\e[0mReading from Calidus-ID-File\e[32m ${paramValue}.calidus.id\e[0m ..."
if [ $? -ne 0 ]; then echo -e "\n\n\e[35mERROR - Could not read from file \"${paramValue}.pool.id\"\e[0m"; exit 1; fi
517
+
#check if the content is a valid pool hex
518
+
if [[ ! "${poolIdHex,,}" =~ ^([[:xdigit:]]{56})$ ]]; then echo -e "\n\e[91mERROR - Content of Pool-ID File '${paramValue}.pool.id' is not a valid Pool-ID hex!\n\e[0m"; exit 1; fi
checkError "$?"; if [ $? -ne 0 ]; then echo -e "\n\n\e[91mERROR - Could not convert the the Pool-ID File \"${paramValue}.pool.id\" into a Bech Pool-ID.\e[0m\n"; exit 1; fi
522
+
echo -e "\e[32m OK\e[0m\n"
523
+
searchType="Pool ID";
524
+
525
+
#Check if its a node Vkey File
526
+
elif [ -f "${paramValue}.node.vkey" ]; then #there is a node.vkey file present, try to use this
527
+
echo -ne "\e[0mConverting the Pool Vkey-File \e[32m${paramValue}.node.vkey\e[0m into a Pool-ID ... "
if [[ ! "${poolIdHex,,}" =~ ^([[:xdigit:]]{56})$ ]]; then echo -e "\n\n\e[91mERROR - Could not convert the given Pool Vkey-File \"${paramValue}.node.vkey\" into a Bech Pool-ID.\e[0m\n"; exit 1; fi
checkError "$?"; if [ $? -ne 0 ]; then echo -e "\n\n\e[91mERROR - Could not convert the given Pool Vkey-File \"${paramValue}.node.vkey\" into a Bech Pool-ID.\e[0m\n"; exit 1; fi
537
+
echo -e "\e[32mOK\e[0m\n"
538
+
searchType="Pool ID";
539
+
540
+
#Query all entries
541
+
elif [[ "${paramValue,,}" == "all" ]]; then #query all entries
if [ $? -ne 0 ]; then echo -e "\e[91mSORRY - Query via Koios-API (${koiosAPI}) failed, not a JSON response.\e[0m\n"; exit 1; fi; #reponse is not a json file
if ! [[ -f "${calidusKeyName}.calidus.skey" ]]; then echo -e "\e[35mError - ${calidusKeyName}.calidus.skey does not exist, please create the key first using option 'new cli ${calidusKeyName}' !\e[0m\n"; exit 1; fi
648
+
649
+
#Get the Text Message to sign
650
+
messageText="${allParameters[2]}"
651
+
652
+
echo -e "\e[0mSign a Message-Text with the Calidus-Secret-Key '\e[32m${calidusKeyName}\e[0m'\n"
653
+
echo -e "\e[0mMessage-Text to sign: '\e[94m${messageText}\e[0m'\n"
654
+
655
+
#Check the cardano-signer binary existance and version
656
+
if ! exists "${cardanosigner}"; then
657
+
#Try the one in the scripts folder
658
+
if [[ -f "${scriptDir}/cardano-signer" ]]; then cardanosigner="${scriptDir}/cardano-signer";
659
+
else majorError "Path ERROR - Path to the 'cardano-signer' binary is not correct or 'cardano-singer' binaryfile is missing!\nYou can find it here: https://github.com/gitmachtl/cardano-signer/releases\nThis is needed to generate the signed Metadata. Also please check your 00_common.sh or common.inc settings."; exit 1; fi
if [[ $? -ne 0 ]]; then echo -e "\e[35mERROR - This script needs a working 'cardano-signer' binary. Please make sure you have it present with with the right path in '00_common.sh' !\e[0m\n\n"; exit 1; fi
if [[ $? -ne 0 ]]; then majorError "Version ${cardanosignerVersion} ERROR - Please use a cardano-signer version ${minCardanoSignerVersion} or higher !\nOld versions are not compatible, please upgrade - thx."; exit 1; fi
666
+
667
+
#Read in the Secret key and decrypt it if needed
668
+
skeyJSON=$(read_skeyFILE "${calidusKeyName}.calidus.skey"); if [ $? -ne 0 ]; then echo -e "\e[35m${skeyJSON}\e[0m\n"; exit 1; else echo -e "\e[32mOK\e[0m\n"; fi
669
+
670
+
#Sign the messageText
671
+
echo -e "\e[0mSigning with Cardano-Signer Version: \e[32m${cardanosignerVersion}\e[0m\n";
if [[ "${signature//[![:xdigit:]]}" != "${signature}" || "${signature}" == "" ]]; then echo -e "\n\e[35mERROR - Could not generate the Signature.\e[0m\n"; exit 1; fi
0 commit comments