Skip to content

Commit d866be5

Browse files
committed
Update 2025-02 - cli10.4.0 and enhanced stake-key queries
About this update: cardano-cli 10.4.0.0 introduced a breaking change in the `stake-address-info` query. this update addresses this update and also brings more query details and enhanced security for stakekey deregistration. - 00_common.sh // was updated to query govActionDeposits via koios in light mode. also the govAction query was refined to only return active proposals - 01_claimRewards.sh // shows more information about the stake-address: if there are rewards, if there is a pool delegation, if there is a drep delegation, if the stakeaddress is used in a governance action deposit. in conway era (protocolversion10) there is now a check that rewards can only be claimed if the address is delegated to a drep - 01_queryAddress.sh & 03c_checkStakingAddrOnChain.sh // shows more information about the stake-address: if there are rewards, if there is a pool delegation, if there is a drep delegation, if the stakeaddress is used in a governance action deposit. in case it is used in gov actions, a list of the actions will be listed - 08a_genStakingAddrRetireCert.sh // has now the same enhanced outputs about the stakeaddress as 01_queryAddress.sh. in order to protect funds, there is a double-check included if the stakeaddress is used as the deposit refund address in an ongoing governance action. if this is the case, the script will prevent the user from generating a stake-address-retirement certificate. - new minimum version of cardano-cli is now 10.4.0.0 - new minimum version of cardano-signer is now 1.22.0 (needed for CIP8/30 witnesses in governance metadata) - cardano-signer binary was updated to v1.22.1
1 parent 46459c7 commit d866be5

7 files changed

+565
-299
lines changed

cardano/mainnet/00_common.sh

+61-34
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,15 @@ if [[ "${adahandleAPI: -1}" == "/" ]]; then adahandleAPI=${adahandleAPI%?}; fi #
325325
if [[ "${magicparam}" == "" || ${addrformat} == "" || ${byronToShelleyEpochs} == "" ]]; then majorError "The 'magicparam', 'addrformat' or 'byronToShelleyEpochs' is not set!\nOr maybe you have set the wrong parameter network=\"${network}\" ?\nList of preconfigured network-names: ${networknames}"; exit 1; fi
326326

327327
#Don't allow to overwrite the needed Versions, so we set it after the overwrite part
328-
minCliVersion="10.2.0" #minimum allowed cli version for this script-collection version
329-
maxCliVersion="10.3.99" #maximum allowed cli version, 99.99.9 = no limit so far
328+
minCliVersion="10.4.0" #minimum allowed cli version for this script-collection version
329+
maxCliVersion="99.99.9" #maximum allowed cli version, 99.99.9 = no limit so far
330330
minNodeVersion="10.1.4" #minimum allowed node version for this script-collection version
331331
maxNodeVersion="99.99.9" #maximum allowed node version, 99.99.9 = no limit so far
332-
minLedgerCardanoAppVersion=${ENV_MINLEDGERCARDANOAPPVERSION:-"7.1.1"} #minimum version for the cardano-app on the Ledger HW-Wallet
332+
minLedgerCardanoAppVersion=${ENV_MINLEDGERCARDANOAPPVERSION:-"7.1.4"} #minimum version for the cardano-app on the Ledger HW-Wallet
333333
minTrezorCardanoAppVersion="2.7.2" #minimum version for the firmware on the Trezor HW-Wallet
334334
minKeystoneCardanoAppVersion="1.7.7" #minimum version for the firmware on the Keystone HW-Wallet
335-
minHardwareCliVersion="1.15.0" #minimum version for the cardano-hw-cli
336-
minCardanoSignerVersion="1.20.1" #minimum version for the cardano-signer binary
335+
minHardwareCliVersion="1.17.0" #minimum version for the cardano-hw-cli
336+
minCardanoSignerVersion="1.22.0" #minimum version for the cardano-signer binary
337337
minCatalystToolboxVersion="0.5.0" #minimum version for the catalyst-toolbox binary
338338

339339
#Defaults - Variables and Constants
@@ -1558,38 +1558,65 @@ queryLight_stakeAddressInfo() { #${1} = stakeaddress(bech) to query
15581558
if [ $? -ne 0 ]; then echo -e "Query via Koios-API (${koiosAPI}) failed, not a JSON response."; exit 1; fi; #reponse is not a json file
15591559

15601560
#check if the stakeAddress is registered, if not, return an empty array
1561-
if [[ $(jq -r ".[0].status" <<< "${responseJSON}" 2> /dev/null) != "registered" ]]; then
1562-
printf "[]"; #stakeAddress not registered on chain, return an empty array
1563-
else
1561+
if [[ $(jq -r ".[0].status" <<< "${responseJSON}" 2> /dev/null) != "registered" ]]; then printf "[]"; exit 0; fi #stakeAddress not registered on chain, return an empty array
15641562

1565-
local delegation; local rewardAccountBalance; local delegationDeposit; local voteDelegation; #define local variables so we can read it in one go with the next jq command
1566-
{ read delegation; read rewardAccountBalance; read delegationDeposit; read voteDelegation; } <<< $(jq -r ".[0].delegated_pool // \"null\", .[0].rewards_available // \"null\", .[0].deposit // \"null\", .[0].delegated_drep // \"null\"" <<< "${responseJSON}" 2> /dev/null)
1563+
#get the first values
1564+
local delegation; local rewardAccountBalance; local delegationDeposit; local voteDelegation; #define local variables so we can read it in one go with the next jq command
1565+
{ read delegation; read rewardAccountBalance; read delegationDeposit; read voteDelegation; } <<< $(jq -r ".[0].delegated_pool // \"null\", .[0].rewards_available // \"null\", .[0].deposit // \"null\", .[0].delegated_drep // \"null\"" <<< "${responseJSON}" 2> /dev/null)
15671566

1568-
#deposit value, always 2000000 lovelaces until conway
1569-
if [[ ${delegationDeposit} == null ]]; then delegationDeposit=2000000; fi
1567+
#Do another query to get all the proposals this stakeaddress is set as the deposit return address
1568+
errorcnt=0
1569+
error=-1
1570+
while [[ ${errorcnt} -lt 5 && ${error} -ne 0 ]]; do #try a maximum of 5 times to request the information via koios API
1571+
error=0
1572+
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/proposal_list?return_address=eq.${addr}&dropped_epoch=is.null&enacted_epoch=is.null&expired_epoch=is.null&select=proposal_tx_hash,proposal_index,deposit,return_address,dropped_epoch,enacted_epoch,expired_epoch" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" 2> /dev/null)
1573+
if [ $? -ne 0 ]; then error=1; fi;
1574+
errorcnt=$(( ${errorcnt} + 1 ))
1575+
done
1576+
if [[ ${error} -ne 0 ]]; then echo -e "Query of the Koios-API via curl failed, tried 5 times."; exit 1; fi; #curl query failed
15701577

1571-
#convert from CIP129 to regular format if its a normal drep delegation
1572-
if [[ "${voteDelegation}" == "drep1"* ]]; then voteDelegation=$(convert_actionCIP1292Bech ${voteDelegation}); fi
1578+
#Split the response string into JSON content and the HTTP-ResponseCode
1579+
if [[ "${response}" =~ (.*)---spo-scripts---([0-9]*)* ]]; then
1580+
local responseJSON="${BASH_REMATCH[1]}"
1581+
local responseCode="${BASH_REMATCH[2]}"
1582+
else
1583+
echo -e "Query of the Koios-API via curl failed. Could not separate Content and ResponseCode."; exit 1; #curl query failed
1584+
fi
15731585

1574-
#convert bech-voteDelegation into keyHash-/scriptHAsh-voteDelegation
1575-
case "${voteDelegation}" in
1576-
"drep1"*) voteDelegation="keyHash-$(${bech32_bin} <<< ${voteDelegation})"
1577-
;;
1578-
"drep_script1"*) voteDelegation="scriptHash-$(${bech32_bin} <<< ${voteDelegation})"
1579-
;;
1580-
"drep_always_abstain") voteDelegation="alwaysAbstain"
1581-
;;
1582-
"drep_always_no_confidence")
1583-
voteDelegation="alwaysNoConfidence"
1584-
;;
1585-
*) voteDelegation="null"
1586-
;;
1587-
esac
1586+
#Check the responseCode
1587+
case ${responseCode} in
1588+
"200" ) ;; #all good, continue
1589+
* ) echo -e "HTTP Response code: ${responseCode}"; exit 1; #exit with a failure and the http response code
1590+
esac;
15881591

1589-
jsonRet="[ { \"address\": \"${addr}\", \"stakeDelegation\": \"${delegation}\", \"delegationDeposit\": ${delegationDeposit}, \"rewardAccountBalance\": ${rewardAccountBalance}, \"voteDelegation\": \"${voteDelegation}\" } ]" #compose a json like the cli output
1590-
#return the composed json
1591-
printf "${jsonRet}"
1592-
fi
1592+
#generate the govActionsDeposits
1593+
govActionDeposits=$(jq -r '(map ({ "\(.proposal_tx_hash)#\(.proposal_index)": .deposit }) | add) // {}' <<< ${responseJSON} 2> /dev/null)
1594+
if [ $? -ne 0 ]; then echo -e "Query via Koios-API (${koiosAPI}) failed, not a JSON response."; exit 1; fi; #reponse is not a json file
1595+
1596+
#deposit value, always 2000000 lovelaces until conway
1597+
if [[ ${delegationDeposit} == null ]]; then delegationDeposit=2000000; fi
1598+
1599+
#convert from CIP129 to regular format if its a normal drep delegation
1600+
if [[ "${voteDelegation}" == "drep1"* ]]; then voteDelegation=$(convert_actionCIP1292Bech ${voteDelegation}); fi
1601+
1602+
#convert bech-voteDelegation into keyHash-/scriptHAsh-voteDelegation
1603+
case "${voteDelegation}" in
1604+
"drep1"*) voteDelegation="keyHash-$(${bech32_bin} <<< ${voteDelegation})"
1605+
;;
1606+
"drep_script1"*) voteDelegation="scriptHash-$(${bech32_bin} <<< ${voteDelegation})"
1607+
;;
1608+
"drep_always_abstain") voteDelegation="alwaysAbstain"
1609+
;;
1610+
"drep_always_no_confidence")
1611+
voteDelegation="alwaysNoConfidence"
1612+
;;
1613+
*) voteDelegation="null"
1614+
;;
1615+
esac
1616+
1617+
jsonRet="[ { \"address\": \"${addr}\", \"stakeDelegation\": \"${delegation}\", \"stakeRegistrationDeposit\": ${delegationDeposit}, \"rewardAccountBalance\": ${rewardAccountBalance}, \"voteDelegation\": \"${voteDelegation}\", \"govActionDeposits\": ${govActionDeposits} } ]" #compose a json like the cli output
1618+
#return the composed json
1619+
printf "${jsonRet}"
15931620

15941621
unset jsonRet response responseCode responseJSON addr error errorcnt
15951622

@@ -1767,10 +1794,10 @@ queryLight_actionState() { #for filtering, ${1} = govActionUTXO, ${2} = govActio
17671794
error=0
17681795
case "${voterID}" in
17691796
"drep"*|"cc_hot"*|"pool"*) #a voterID was given, so do a filtering directly via koios on the given bech voterID
1770-
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/voter_proposal_list?_voter_id=${voterID}&dropped_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
1797+
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/voter_proposal_list?_voter_id=${voterID}&dropped_epoch=is.null&enacted_epoch=is.null&expired_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
17711798
;;
17721799
*) #no voterID was given, do a query for the complete proposal list
1773-
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/proposal_list?dropped_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
1800+
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/proposal_list?dropped_epoch=is.null&enacted_epoch=is.null&expired_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
17741801
;;
17751802
esac
17761803
if [ $? -ne 0 ]; then error=1; fi;

0 commit comments

Comments
 (0)