diff --git a/docs/Scripts/cntools-changelog.md b/docs/Scripts/cntools-changelog.md index 2f23c9297..4c0a60443 100644 --- a/docs/Scripts/cntools-changelog.md +++ b/docs/Scripts/cntools-changelog.md @@ -6,6 +6,17 @@ All notable changes to this tool will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [12.0.0] - 2024-01-19 +#### Changed +- Minimum version bumps + - node 8.7.3 + - cardano-hw-cli 1.14.0 + - Ledger 5.0.1 + - Trezor 2.6.4 +- Send > Funds flow updated to ask for Ada amount after tokens and destination to be able to calculate minimum amount valid to send correctly. +#### Fixed +- Minimum utxo calculation changed to use cardano-cli calculation tool (was broken) + ## [11.0.2] - 2023-10-30 #### Fixed - Fix additional Ada printing. Now omits trailing zeros from fraction part of Ada output. diff --git a/files/conway-genesis-guild.json b/files/conway-genesis-guild.json index b5e9b7ead..14d9c0f65 100644 --- a/files/conway-genesis-guild.json +++ b/files/conway-genesis-guild.json @@ -1,3 +1,37 @@ { - "genDelegs": {} -} \ No newline at end of file + "poolVotingThresholds": { + "pvtCommitteeNormal": 0.51, + "pvtCommitteeNoConfidence": 0.51, + "pvtHardForkInitiation": 0.51, + "pvtMotionNoConfidence": 0.51 + }, + "dRepVotingThresholds": { + "dvtMotionNoConfidence": 0.51, + "dvtCommitteeNormal": 0.51, + "dvtCommitteeNoConfidence": 0.51, + "dvtUpdateToConstitution": 0.51, + "dvtHardForkInitiation": 0.51, + "dvtPPNetworkGroup": 0.51, + "dvtPPEconomicGroup": 0.51, + "dvtPPTechnicalGroup": 0.51, + "dvtPPGovGroup": 0.51, + "dvtTreasuryWithdrawal": 0.51 + }, + "committeeMinSize": 0, + "committeeMaxTermLength": 200, + "govActionLifetime": 10, + "govActionDeposit": 1000000000, + "dRepDeposit": 2000000, + "dRepActivity": 20, + "constitution": { + "anchor": { + "url": "", + "dataHash": "0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "committee": { + "members": { + }, + "quorum": 0 + } +} diff --git a/files/topology-guild-p2p.json b/files/topology-guild-p2p.json index e82f9c76e..d82058481 100644 --- a/files/topology-guild-p2p.json +++ b/files/topology-guild-p2p.json @@ -2,7 +2,7 @@ "localRoots": [ { "accessPoints": [ - {"address": "127.0.0.1" ,"port": 7000, "valency": 1,"name": "local"} + {"address": "127.0.0.1" ,"port": 7000, "valency": 1, "name": "local"} ], "advertise": false, "valency": 1 @@ -11,18 +11,18 @@ "publicRoots": [ { "accessPoints": [ - {"address": "209.145.50.190" ,"port": 7001, "valency": 1,"name": "rdlrt"}, - {"address": "95.216.188.94" ,"port": 7000, "valency": 1,"name": "homer"}, - {"address": "relay1-test.ahlnet.nu" ,"port": 2103, "valency": 1,"name": "ahl-1"}, - {"address": "guild-relay.bluecheesestakehouse.com","port": 7000,"valency": 1,"name": "westberg"}, - {"address": "relay-1.stakepool.at","port": 54326,"valency": 1,"name": "atada"}, - {"address": "185.161.193.105","port": 6011,"valency": 1,"name": "clio-1"}, - {"address": "148.72.153.168","port": 18000,"valency": 1,"name": "redo" }, - {"address": "relay.guild.cryptobounty.org","port": 9198,"valency": 1,"name": "bnty1" }, - {"address": "54.93.228.113","port": 4322,"valency": 1,"name": "titan" }, - {"address": "195.201.129.190", "port": 6000, "valency": 1, "name": "damjan"}, - {"address": "relay-guild.adaplus.io", "port": 6000, "valency": 1, "name": "adaplus"}, - {"address": "relays-guild.poolunder.com", "port": 8900, "valency": 1, "name": "TUNDR"} + {"address": "209.145.50.190" ,"port": 7001, "valency": 1, "name": "rdlrt"}, + {"address": "95.216.188.94" ,"port": 7000, "valency": 1, "name": "homer"}, + {"address": "relay1-test.ahlnet.nu" ,"port": 2103, "valency": 1, "name": "ahl-1"}, + {"address": "guild-relay.bluecheesestakehouse.com","port": 7000, "valency": 1, "name": "westberg"}, + {"address": "relay-1.stakepool.at" ,"port": 54326,"valency": 1, "name": "atada"}, + {"address": "185.161.193.105" ,"port": 6011, "valency": 1, "name": "clio-1"}, + {"address": "148.72.153.168" ,"port": 18000,"valency": 1, "name": "redo" }, + {"address": "relay.guild.cryptobounty.org" ,"port": 9198, "valency": 1, "name": "bnty1" }, + {"address": "54.93.228.113" ,"port": 4322, "valency": 1, "name": "titan" }, + {"address": "195.201.129.190" ,"port": 6000, "valency": 1, "name": "damjan"}, + {"address": "relay-guild.adaplus.io" ,"port": 6000, "valency": 1, "name": "adaplus"}, + {"address": "relays-guild.poolunder.com" ,"port": 8900, "valency": 1, "name": "TUNDR"} ], "advertise": false } diff --git a/scripts/cnode-helper-scripts/cncli.sh b/scripts/cnode-helper-scripts/cncli.sh index 269f8f4a8..9a43a047b 100755 --- a/scripts/cnode-helper-scripts/cncli.sh +++ b/scripts/cnode-helper-scripts/cncli.sh @@ -115,7 +115,7 @@ getPoolVrfVkeyCborHex() { } getLedgerData() { # getNodeMetrics expected to have been already run - if ! stake_snapshot=$(${CCLI} query stake-snapshot --stake-pool-id ${POOL_ID} ${NETWORK_IDENTIFIER} 2>&1); then + if ! stake_snapshot=$(${CCLI} ${NETWORK_ERA} query stake-snapshot --stake-pool-id ${POOL_ID} ${NETWORK_IDENTIFIER} 2>&1); then echo "ERROR: stake-snapshot query failed: ${stake_snapshot}" return 1 fi @@ -199,7 +199,7 @@ cncliInit() { [[ ! -f "${CNCLI}" ]] && echo -e "\nERROR: failed to locate cncli executable, please install with 'guild-deploy.sh'\n" && exit 1 CNCLI_VERSION="v$(cncli -V | cut -d' ' -f2)" - if ! versionCheck "5.1.0" "${CNCLI_VERSION}"; then echo "ERROR: cncli ${CNCLI_VERSION} installed, minimum required version is 5.1.0, please upgrade to latest version!"; exit 1; fi + if ! versionCheck "6.0.0" "${CNCLI_VERSION}"; then echo "ERROR: cncli ${CNCLI_VERSION} installed, minimum required version is 6.0.0, please upgrade to latest version!"; exit 1; fi [[ -z "${CNCLI_DIR}" ]] && CNCLI_DIR="${CNODE_HOME}/guild-db/cncli" if ! mkdir -p "${CNCLI_DIR}" 2>/dev/null; then echo "ERROR: Failed to create CNCLI DB directory: ${CNCLI_DIR}"; exit 1; fi @@ -266,8 +266,8 @@ cncliLeaderlog() { [[ ${subarg} != "force" ]] && echo "Node in sync, sleeping for ${SLEEP_RATE}s before running leaderlogs for current epoch" && sleep ${SLEEP_RATE} getNodeMetrics - getEraIdentifier - if [[ ${NETWORK_ERA} = "Babbage" ]]; then consensus="praos"; else consensus="tpraos"; fi + getProtocolParams + if versionCheck "8.0" "${PROT_VERSION}"; then consensus="praos"; else consensus="tpraos"; fi curr_epoch=${epochnum} if [[ $(sqlite3 "${BLOCKLOG_DB}" "SELECT COUNT(*) FROM epochdata WHERE epoch=${curr_epoch};" 2>/dev/null) -eq 1 && ${subarg} != "force" ]]; then echo "Leaderlogs already calculated for epoch ${curr_epoch}, skipping!" @@ -322,8 +322,8 @@ cncliLeaderlog() { while true; do [[ ${subarg} != "force" ]] && sleep ${SLEEP_RATE} getNodeMetrics - getEraIdentifier - if [[ ${NETWORK_ERA} = "Babbage" ]]; then consensus="praos"; else consensus="tpraos"; fi + getProtocolParams + if versionCheck "8.0" "${PROT_VERSION}"; then consensus="praos"; else consensus="tpraos"; fi if ! cncliDBinSync; then # verify that cncli DB is still in sync echo "CNCLI DB out of sync :( [$(printf "%2.4f %%" ${cncli_sync_prog})] ... checking again in ${SLEEP_RATE}s" [[ ${subarg} = force ]] && sleep ${SLEEP_RATE} diff --git a/scripts/cnode-helper-scripts/cntools.library b/scripts/cnode-helper-scripts/cntools.library index 8fd6ca0e3..53e512482 100644 --- a/scripts/cnode-helper-scripts/cntools.library +++ b/scripts/cnode-helper-scripts/cntools.library @@ -11,11 +11,11 @@ # The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) # and this adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) # Major: Any considerable change in the code base, big feature, workflow or breaking change from previous version -CNTOOLS_MAJOR_VERSION=11 +CNTOOLS_MAJOR_VERSION=12 # Minor: Changes and features of minor character that can be applied without breaking existing functionality or workflow CNTOOLS_MINOR_VERSION=0 # Patch: Backwards compatible bug fixes. No additional functionality or major changes -CNTOOLS_PATCH_VERSION=3 +CNTOOLS_PATCH_VERSION=0 CNTOOLS_VERSION="${CNTOOLS_MAJOR_VERSION}.${CNTOOLS_MINOR_VERSION}.${CNTOOLS_PATCH_VERSION}" @@ -39,7 +39,6 @@ if ! mkdir -p "${ASSET_FOLDER}" 2>/dev/null; then myExit 1 "${FG_RED}ERROR${NC}: [[ ${ENABLE_ADVANCED} = "true" ]] && ADVANCED_MODE="true" [[ -z ${CHECK_KES} ]] && CHECK_KES=true [[ -z ${CNTOOLS_LOG} ]] && CNTOOLS_LOG="${LOG_DIR}/cntools-history.log" -getEraIdentifier ############################################################ # library sourced by cntools with common taskes to perform # @@ -468,7 +467,7 @@ selectWallet() { [[ -z ${base_addr} ]] && wallet_dirs+=("${dir}") && continue # ignore and add wallet without extra details getBalance ${base_addr} if getRewardAddress ${dir}; then - delegation_pool_id=$(${CCLI} query stake-address-info ${NETWORK_IDENTIFIER} --address "${reward_addr}" | jq -r '.[0].delegation // empty') + delegation_pool_id=$(${CCLI} ${NETWORK_ERA} query stake-address-info ${NETWORK_IDENTIFIER} --address "${reward_addr}" | jq -r '.[0].delegation // empty') unset poolName if [[ -n ${delegation_pool_id} ]]; then while IFS= read -r -d '' pool; do @@ -852,8 +851,8 @@ getPayAddress() { [[ -f ${payment_addr_file} ]] && pay_addr=$(cat "${payment_addr_file}") && return 0 pay_addr="" if [[ -f "${payment_vk_file}" ]]; then - println ACTION "${CCLI} address build --payment-verification-key-file ${payment_vk_file} --out-file ${payment_addr_file} ${NETWORK_IDENTIFIER}" - if ${CCLI} address build --payment-verification-key-file "${payment_vk_file}" --out-file "${payment_addr_file}" ${NETWORK_IDENTIFIER} 2>/dev/null; then + println ACTION "${CCLI} ${NETWORK_ERA} address build --payment-verification-key-file ${payment_vk_file} --out-file ${payment_addr_file} ${NETWORK_IDENTIFIER}" + if ${CCLI} ${NETWORK_ERA} address build --payment-verification-key-file "${payment_vk_file}" --out-file "${payment_addr_file}" ${NETWORK_IDENTIFIER} 2>/dev/null; then pay_addr=$(cat "${payment_addr_file}") return 0 fi @@ -872,14 +871,14 @@ getBaseAddress() { [[ -f ${base_addr_file} ]] && base_addr=$(cat "${base_addr_file}") && return 0 base_addr="" if [[ -f "${payment_vk_file}" && -f "${stake_vk_file}" ]]; then - println ACTION "${CCLI} address build --payment-verification-key-file ${payment_vk_file} --stake-verification-key-file ${stake_vk_file} --out-file ${base_addr_file} ${NETWORK_IDENTIFIER}" - if ${CCLI} address build --payment-verification-key-file "${payment_vk_file}" --stake-verification-key-file "${stake_vk_file}" --out-file "${base_addr_file}" ${NETWORK_IDENTIFIER} 2>/dev/null; then + println ACTION "${CCLI} ${NETWORK_ERA} address build --payment-verification-key-file ${payment_vk_file} --stake-verification-key-file ${stake_vk_file} --out-file ${base_addr_file} ${NETWORK_IDENTIFIER}" + if ${CCLI} ${NETWORK_ERA} address build --payment-verification-key-file "${payment_vk_file}" --stake-verification-key-file "${stake_vk_file}" --out-file "${base_addr_file}" ${NETWORK_IDENTIFIER} 2>/dev/null; then base_addr=$(cat "${base_addr_file}") return 0 fi elif [[ $# -eq 2 && -f "${1}" && -f "${2}" ]]; then - println ACTION "${CCLI} address build --payment-verification-key-file ${1} --stake-verification-key-file ${2} ${NETWORK_IDENTIFIER}" - base_addr=$(${CCLI} address build --payment-verification-key-file "${1}" --stake-verification-key-file "${2}" ${NETWORK_IDENTIFIER} 2>/dev/null) + println ACTION "${CCLI} ${NETWORK_ERA} address build --payment-verification-key-file ${1} --stake-verification-key-file ${2} ${NETWORK_IDENTIFIER}" + base_addr=$(${CCLI} ${NETWORK_ERA} address build --payment-verification-key-file "${1}" --stake-verification-key-file "${2}" ${NETWORK_IDENTIFIER} 2>/dev/null) fi return 1 } @@ -894,14 +893,14 @@ getRewardAddress() { [[ -f ${stake_addr_file} ]] && reward_addr=$(cat "${stake_addr_file}") && return 0 reward_addr="" if [[ -f "${stake_vk_file}" ]]; then - println ACTION "${CCLI} stake-address build --stake-verification-key-file ${stake_vk_file} --out-file ${stake_addr_file} ${NETWORK_IDENTIFIER}" - if ${CCLI} stake-address build --stake-verification-key-file "${stake_vk_file}" --out-file "${stake_addr_file}" ${NETWORK_IDENTIFIER} 2>/dev/null; then + println ACTION "${CCLI} ${NETWORK_ERA} stake-address build --stake-verification-key-file ${stake_vk_file} --out-file ${stake_addr_file} ${NETWORK_IDENTIFIER}" + if ${CCLI} ${NETWORK_ERA} stake-address build --stake-verification-key-file "${stake_vk_file}" --out-file "${stake_addr_file}" ${NETWORK_IDENTIFIER} 2>/dev/null; then reward_addr=$(cat "${stake_addr_file}") return 0 fi elif [[ -f "${1}" ]]; then - println ACTION "${CCLI} stake-address build --stake-verification-key-file ${1} ${NETWORK_IDENTIFIER}" - reward_addr=$(${CCLI} stake-address build --stake-verification-key-file "${1}" ${NETWORK_IDENTIFIER} 2>/dev/null) + println ACTION "${CCLI} ${NETWORK_ERA} stake-address build --stake-verification-key-file ${1} ${NETWORK_IDENTIFIER}" + reward_addr=$(${CCLI} ${NETWORK_ERA} stake-address build --stake-verification-key-file "${1}" ${NETWORK_IDENTIFIER} 2>/dev/null) fi return 1 } @@ -911,8 +910,8 @@ getRewardAddress() { # Parameters : stake key > path to stake.vkey file # Return : populates ${reward_addr} getRewardAddressFromKey() { - println ACTION "${CCLI} stake-address build --stake-verification-key-file ${1} ${NETWORK_IDENTIFIER}" - reward_addr=$(${CCLI} stake-address build --stake-verification-key-file "${1}" ${NETWORK_IDENTIFIER} 2>/dev/null) + println ACTION "${CCLI} ${NETWORK_ERA} stake-address build --stake-verification-key-file ${1} ${NETWORK_IDENTIFIER}" + reward_addr=$(${CCLI} ${NETWORK_ERA} stake-address build --stake-verification-key-file "${1}" ${NETWORK_IDENTIFIER} 2>/dev/null) } # Command : getAddressInfo [address] @@ -920,8 +919,8 @@ getRewardAddressFromKey() { # Parameters : address > the wallet address to query # Return : populates ${address_info} getAddressInfo() { - println ACTION "${CCLI} address info --address $1" - address_info=$(${CCLI} address info --address $1) + println ACTION "${CCLI} ${NETWORK_ERA} address info --address $1" + address_info=$(${CCLI} ${NETWORK_ERA} address info --address $1) } # Command : getBalance [address] @@ -934,7 +933,7 @@ getBalance() { asset_name_maxlen=5; asset_amount_maxlen=12 tx_in="" - if [[ -z ${1} ]] || ! utxo_raw=$(${CCLI} query utxo ${NETWORK_IDENTIFIER} --address "${1}"); then return 1; fi + if [[ -z ${1} ]] || ! utxo_raw=$(${CCLI} ${NETWORK_ERA} query utxo ${NETWORK_IDENTIFIER} --address "${1}"); then return 1; fi [[ -z ${utxo_raw} ]] && return while IFS= read -r line; do @@ -991,61 +990,19 @@ getAssetsTxOut() { done } -# Command : getMinUTxO [--tx-out string] -# Description : calculate minimum balance needed in source wallet UTxOs for transaction to be valid -# getBalance assumed to be run before -# based on calculations from https://github.com/intersectmbo/cardano-ledger/blob/master/doc/explanations/min-utxo-mary.rst +# Command : getMinUTxO [string] +# Description : calculate minimum balance needed in transaction output to be valid +# : string as passed to --tx-out parameter # Return : populates ${min_utxo_out} getMinUTxO() { - [[ -z ${utxoCostPerWord} ]] && utxoCostPerWord=$(jq -r '.utxoCostPerWord' <<< "${PROT_PARAMS}") - - # chain constants, based on: https://hydra.iohk.io/build/5949624/download/1/shelley-ma.pdf - local k0=2 # coinSize=0 in mary-era, 2 in alonzo-era - local k1=6 - local k2=12 # assetSize=12 - local k3=28 # pidSize=28 - local k4=8 # word=8 bytes - local utxoEntrySizeWithoutVal=27 # 6 + txOutLenNoVal(14) + txInLen(7) - local adaOnlyUTxOSize=$(( utxoEntrySizeWithoutVal + k0 )) - - # New calculation for alonzo-era, static minUTxOValue replaced with utxoCostPerWord calculation - minUTxOValue=$(( utxoCostPerWord * adaOnlyUTxOSize )) - - min_utxo_out=${minUTxOValue} - - # split the tx-out string into the assets - IFS='+' read -ra asset_entry <<< "${1}" - - if [[ ${#asset_entry[@]} -gt 2 ]]; then # contains assets, do calculations. - local idx=2 - declare -A pidCollector=() # holds the list of individual policyIDs - declare -A assetsCollector=() # holds the list of individual assetNumbers - declare -A nameCollector=() # holde the list of individual assetNames(hex format) - - while [[ ${#asset_entry[@]} -gt ${idx} ]]; do - # separate asset amount from hash(policyID.assetName) - IFS=' ' read -ra asset <<< "${asset_entry[${idx}]}" - local asset_hash=${asset[1]} - - # split asset_hash_name into policy ID and asset name(hex) - IFS='.' read -ra asset_split <<< "${asset_hash}" - local asset_hash_policy=${asset_split[0]} - local asset_hash_name=${asset_split[1]} - - # collect the entries in individual lists to sort them later - pidCollector[${asset_hash_policy}]=1 - assetsCollector[${asset_hash_policy}${asset_hash_name}]=1 - [[ -n ${asset_hash_name} ]] && nameCollector[${asset_hash_name}]=1 - - ((idx++)) - done - - local sumAssetNameLengths=$(_len=0;for K in "${!nameCollector[@]}";do ((_len+=$(printf "%s" "$K" | wc -c)));done;echo ${_len}) - local roundupBytesToWords=$(bc <<< "scale=0; ( ${#assetsCollector[@]}*${k2} + ${sumAssetNameLengths} + ${#pidCollector[@]}*${k3} + (${k4}-1) ) / ${k4}") - local tokenBundleSize=$(( k1 + roundupBytesToWords )) - local minAda=$(( $(bc <<< "scale=0; ${minUTxOValue} / ${adaOnlyUTxOSize}") * ( utxoEntrySizeWithoutVal + tokenBundleSize ) )) - [[ ${minAda} -gt ${minUTxOValue} ]] && min_utxo_out=${minAda} - fi + min_utxo_args=( + ${NETWORK_ERA} + transaction calculate-min-required-utxo + --protocol-params-file "${TMP_DIR}"/protparams.json + --tx-out "$1" + ) + println ACTION "${CCLI} ${min_utxo_args[*]}" + min_utxo_out=$([[ "$(${CCLI} "${min_utxo_args[@]}")" =~ ([0-9]+) ]] && echo ${BASH_REMATCH[1]}) } # Command : getRewards [wallet name] @@ -1067,8 +1024,8 @@ getRewards() { # Parameters : stake address > the address from stake.vkey # Return : populates ${reward_lovelace} getRewardsFromAddr() { - println ACTION "${CCLI} query stake-address-info ${NETWORK_IDENTIFIER} --address ${1}" - stake_address_info=$(${CCLI} query stake-address-info ${NETWORK_IDENTIFIER} --address ${1}) + println ACTION "${CCLI} ${NETWORK_ERA} query stake-address-info ${NETWORK_IDENTIFIER} --address ${1}" + stake_address_info=$(${CCLI} ${NETWORK_ERA} query stake-address-info ${NETWORK_IDENTIFIER} --address ${1}) reward_lovelace=0 for reward_entry in $(jq -r '.[] | @base64' <<< "${stake_address_info}"); do _jq() { base64 -d <<< ${reward_entry} | jq -r "${1}"; } @@ -1081,8 +1038,8 @@ getRewardsFromAddr() { # Parameters : wallet name > the name of the wallet isWalletRegistered() { if getRewardAddress $1; then - println ACTION "${CCLI} query stake-address-info ${NETWORK_IDENTIFIER} --address ${reward_addr}" - stake_address_info=$(${CCLI} query stake-address-info ${NETWORK_IDENTIFIER} --address ${reward_addr}) + println ACTION "${CCLI} ${NETWORK_ERA} query stake-address-info ${NETWORK_IDENTIFIER} --address ${reward_addr}" + stake_address_info=$(${CCLI} ${NETWORK_ERA} query stake-address-info ${NETWORK_IDENTIFIER} --address ${reward_addr}) [[ -n "${stake_address_info}" && $(jq -r 'length' <<< ${stake_address_info}) -gt 0 ]] && return 0 fi return 1 @@ -1182,8 +1139,8 @@ registerStakeWallet() { getBaseAddress "${wallet_name}" getBalance ${base_addr} - println ACTION "${CCLI} stake-address registration-certificate --stake-verification-key-file ${stake_vk_file} --out-file ${stake_cert_file}" - if ! ${CCLI} stake-address registration-certificate --stake-verification-key-file "${stake_vk_file}" --out-file "${stake_cert_file}"; then return 1; fi + println ACTION "${CCLI} ${NETWORK_ERA} stake-address registration-certificate --stake-verification-key-file ${stake_vk_file} --out-file ${stake_cert_file}" + if ! ${CCLI} ${NETWORK_ERA} stake-address registration-certificate --stake-verification-key-file "${stake_vk_file}" --out-file "${stake_cert_file}"; then return 1; fi if ! getTTL; then return 1; fi stakeAddressDeposit=$(jq -r '.stakeAddressDeposit' <<< "${PROT_PARAMS}") @@ -1203,6 +1160,7 @@ registerStakeWallet() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -1280,8 +1238,8 @@ deregisterStakeWallet() { wallet_source="base" stake_dereg_file="${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_DEREG_FILENAME}" - println ACTION "${CCLI} stake-address deregistration-certificate --stake-verification-key-file ${stake_vk_file} --out-file ${stake_dereg_file}" - if ! ${CCLI} stake-address deregistration-certificate --stake-verification-key-file "${stake_vk_file}" --out-file "${stake_dereg_file}"; then return 1; fi + println ACTION "${CCLI} ${NETWORK_ERA} stake-address deregistration-certificate --stake-verification-key-file ${stake_vk_file} --out-file ${stake_dereg_file}" + if ! ${CCLI} ${NETWORK_ERA} stake-address deregistration-certificate --stake-verification-key-file "${stake_vk_file}" --out-file "${stake_dereg_file}"; then return 1; fi if ! getTTL; then return 1; fi @@ -1302,6 +1260,7 @@ deregisterStakeWallet() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -1415,6 +1374,7 @@ sendAssets() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -1528,6 +1488,7 @@ delegate() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -1618,6 +1579,7 @@ withdrawRewards() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -1721,6 +1683,7 @@ registerPool() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -1846,6 +1809,7 @@ modifyPool() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -1967,6 +1931,7 @@ deRegisterPool() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -2067,21 +2032,21 @@ rotatePoolKeys() { pool_opcert_file="${POOL_FOLDER}/${pool_name}/${POOL_OPCERT_FILENAME}" if [[ ! -f ${pool_coldkey_vk_file} ]]; then # lets re-generate it from cold signing key - println ACTION "${CCLI} key verification-key --signing-key-file ${pool_coldkey_sk_file} --verification-key-file ${pool_coldkey_vk_file}" - ! ${CCLI} key verification-key --signing-key-file "${pool_coldkey_sk_file}" --verification-key-file "${pool_coldkey_vk_file}" && return 1 + println ACTION "${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file ${pool_coldkey_sk_file} --verification-key-file ${pool_coldkey_vk_file}" + ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${pool_coldkey_sk_file}" --verification-key-file "${pool_coldkey_vk_file}" && return 1 output=$(jq '.description = "Stake Pool Operator Verification Key"' "${pool_coldkey_vk_file}") && jq <<< ${output} > "${pool_coldkey_vk_file}" fi current_kes_period=$(getCurrentKESperiod) echo "${current_kes_period}" > ${pool_saved_kes_start} - println ACTION "${CCLI} node key-gen-KES --verification-key-file ${pool_hotkey_vk_file} --signing-key-file ${pool_hotkey_sk_file}" - ! ${CCLI} node key-gen-KES --verification-key-file "${pool_hotkey_vk_file}" --signing-key-file "${pool_hotkey_sk_file}" && return 1 + println ACTION "${CCLI} ${NETWORK_ERA} node key-gen-KES --verification-key-file ${pool_hotkey_vk_file} --signing-key-file ${pool_hotkey_sk_file}" + ! ${CCLI} ${NETWORK_ERA} node key-gen-KES --verification-key-file "${pool_hotkey_vk_file}" --signing-key-file "${pool_hotkey_sk_file}" && return 1 p_opcert="" if [[ $# -eq 1 ]]; then - println ACTION "${CCLI} node new-counter --cold-verification-key-file ${pool_coldkey_vk_file} --counter-value $1 --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" - ! ${CCLI} node new-counter --cold-verification-key-file "${pool_coldkey_vk_file}" --counter-value $1 --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" && return 1 + println ACTION "${CCLI} ${NETWORK_ERA} node new-counter --cold-verification-key-file ${pool_coldkey_vk_file} --counter-value $1 --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" + ! ${CCLI} ${NETWORK_ERA} node new-counter --cold-verification-key-file "${pool_coldkey_vk_file}" --counter-value $1 --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" && return 1 elif [[ -n ${KOIOS_API} ]]; then ! getPoolID "${pool_name}" && println "ERROR" "\n${FG_RED}ERROR${NC}: failed to get pool ID!\n" && return 1 println ACTION "curl -sSL -f -X POST -H \"Content-Type: application/json\" -d '{\"_pool_bech32_ids\":[\"${pool_id_bech32}\"]}' ${KOIOS_API}/pool_info" @@ -2091,11 +2056,11 @@ rotatePoolKeys() { else new_counter_nbr=0 # null returned = no block on chain for this pool fi - println ACTION "${CCLI} node new-counter --cold-verification-key-file ${pool_coldkey_vk_file} --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" - ! ${CCLI} node new-counter --cold-verification-key-file "${pool_coldkey_vk_file}" --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" && return 1 + println ACTION "${CCLI} ${NETWORK_ERA} node new-counter --cold-verification-key-file ${pool_coldkey_vk_file} --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" + ! ${CCLI} ${NETWORK_ERA} node new-counter --cold-verification-key-file "${pool_coldkey_vk_file}" --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" && return 1 elif [[ -f ${pool_opcert_file} ]]; then - println ACTION "${CCLI} query kes-period-info --op-cert-file ${pool_opcert_file} ${NETWORK_IDENTIFIER}" - if ! kes_period_info=$(${CCLI} query kes-period-info --op-cert-file "${pool_opcert_file}" ${NETWORK_IDENTIFIER}); then + println ACTION "${CCLI} ${NETWORK_ERA} query kes-period-info --op-cert-file ${pool_opcert_file} ${NETWORK_IDENTIFIER}" + if ! kes_period_info=$(${CCLI} ${NETWORK_ERA} query kes-period-info --op-cert-file "${pool_opcert_file}" ${NETWORK_IDENTIFIER}); then println "ERROR" "\n${FG_RED}ERROR${NC}: failed to grab counter from node: [${kes_period_info}]\n" && return 1 fi if old_counter_nbr=$(awk '/{/,0' <<< "${kes_period_info}" | jq -er '.qKesNodeStateOperationalCertificateNumber' 2>/dev/null); then @@ -2103,8 +2068,8 @@ rotatePoolKeys() { else new_counter_nbr=0 # null returned = no block on chain for this pool fi - println ACTION "${CCLI} node new-counter --cold-verification-key-file ${pool_coldkey_vk_file} --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" - ! ${CCLI} node new-counter --cold-verification-key-file "${pool_coldkey_vk_file}" --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" && return 1 + println ACTION "${CCLI} ${NETWORK_ERA} node new-counter --cold-verification-key-file ${pool_coldkey_vk_file} --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" + ! ${CCLI} ${NETWORK_ERA} node new-counter --cold-verification-key-file "${pool_coldkey_vk_file}" --counter-value ${new_counter_nbr} --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" && return 1 else println "ERROR" "\n${FG_RED}ERROR${NC}: op cert file missing and Koios disabled/unavailable. Unable to get current on-chain counter value!\n" && return 1 fi @@ -2121,8 +2086,8 @@ rotatePoolKeys() { && return 1 else - println ACTION "${CCLI} node issue-op-cert --kes-verification-key-file ${pool_hotkey_vk_file} --cold-signing-key-file ${pool_coldkey_sk_file} --operational-certificate-issue-counter-file ${pool_opcert_counter_file} --kes-period ${current_kes_period} --out-file ${pool_opcert_file}" - ! ${CCLI} node issue-op-cert --kes-verification-key-file "${pool_hotkey_vk_file}" --cold-signing-key-file "${pool_coldkey_sk_file}" --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" --kes-period "${current_kes_period}" --out-file "${pool_opcert_file}" && return 1 + println ACTION "${CCLI} ${NETWORK_ERA} node issue-op-cert --kes-verification-key-file ${pool_hotkey_vk_file} --cold-signing-key-file ${pool_coldkey_sk_file} --operational-certificate-issue-counter-file ${pool_opcert_counter_file} --kes-period ${current_kes_period} --out-file ${pool_opcert_file}" + ! ${CCLI} ${NETWORK_ERA} node issue-op-cert --kes-verification-key-file "${pool_hotkey_vk_file}" --cold-signing-key-file "${pool_coldkey_sk_file}" --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" --kes-period "${current_kes_period}" --out-file "${pool_opcert_file}" && return 1 fi chmod 700 ${POOL_FOLDER}/${pool_name}/* @@ -2165,6 +2130,7 @@ sendMetadata() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -2262,6 +2228,7 @@ mintAsset() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -2368,6 +2335,7 @@ burnAsset() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} @@ -2449,8 +2417,8 @@ burnAsset() { # : populate an array variable called 'build_args' with all data # Parameters : build_args > an array with all the arguments to assemble the transaction buildTx() { - println ACTION "${CCLI} transaction build-raw ${ERA_IDENTIFIER} ${build_args[*]}" - ${CCLI} transaction build-raw ${ERA_IDENTIFIER} "${build_args[@]}" + println ACTION "${CCLI} ${NETWORK_ERA} transaction build-raw ${build_args[*]}" + ${CCLI} ${NETWORK_ERA} transaction build-raw "${build_args[@]}" } # Command : witnessTx [raw tx file] [signing keys ...] @@ -2528,7 +2496,7 @@ assembleTx() { fi done sign_command=( - ${CCLI} transaction assemble + ${CCLI} ${NETWORK_ERA} transaction assemble --tx-body-file "${tx_raw}" ${tx_witness_out[@]} --out-file "${tx_signed}" @@ -2548,7 +2516,7 @@ submitTx() { tx_signed="$1" submit_command=( - ${CCLI} transaction submit + ${CCLI} ${NETWORK_ERA} transaction submit --tx-file "${tx_signed}" ${NETWORK_IDENTIFIER} ) @@ -2585,13 +2553,13 @@ unlockHWDevice() { println ERROR "Make sure device is seen by OS using tools like lsusb etc and is working correctly" waitForInput && return 1 elif [[ ${device_app_vendor} = Ledger ]]; then - if ! versionCheck "3.0.0" "${device_app_version}"; then - println ERROR "${FG_RED}ERROR${NC}: Cardano app version installed on Ledger is ${FG_LGRAY}v${device_app_version}${NC}, minimum required app version is ${FG_GREEN}v3.0.0${NC} !!" + if ! versionCheck "5.0.1" "${device_app_version}"; then + println ERROR "${FG_RED}ERROR${NC}: Cardano app version installed on Ledger is ${FG_LGRAY}v${device_app_version}${NC}, minimum required app version is ${FG_GREEN}v5.0.1${NC} !!" return 1 fi elif [[ ${device_app_vendor} = Trezor ]]; then - if ! versionCheck "2.4.3" "${device_app_version}"; then - println ERROR "${FG_RED}ERROR${NC}: Trezor firmware installed on device is ${FG_LGRAY}v${device_app_version}${NC}, minimum required version is ${FG_GREEN}v2.4.3${NC} !!" + if ! versionCheck "2.6.4" "${device_app_version}"; then + println ERROR "${FG_RED}ERROR${NC}: Trezor firmware installed on device is ${FG_LGRAY}v${device_app_version}${NC}, minimum required version is ${FG_GREEN}v2.6.4${NC} !!" return 1 fi else @@ -2606,8 +2574,8 @@ HWCLIversionCheck() { println ACTION "cardano-hw-cli version" HWCLI_version="$(cardano-hw-cli version 2>/dev/null | head -n 1 | cut -d' ' -f6)" println LOG "cardano-hw-cli version: ${HWCLI_version}" - if ! versionCheck "1.10.0" "${HWCLI_version}"; then - println ERROR "${FG_RED}ERROR${NC}: Vacuumlabs cardano-hw-cli ${FG_LGRAY}v${HWCLI_version}${NC} installed on system, minimum required version is ${FG_GREEN}v1.10.0${NC} !!" + if ! versionCheck "1.14.0" "${HWCLI_version}"; then + println ERROR "${FG_RED}ERROR${NC}: Vacuumlabs cardano-hw-cli ${FG_LGRAY}v${HWCLI_version}${NC} installed on system, minimum required version is ${FG_GREEN}v1.14.0${NC} !!" println ERROR "Please run ${FG_LGRAY}guild-deploy.sh -s w${NC} to upgrade to the latest version." return 1 fi @@ -2749,6 +2717,7 @@ submitPoll() { if ! buildTx; then return 1; fi min_fee_args=( + ${NETWORK_ERA} transaction calculate-min-fee --tx-body-file "${TMP_DIR}"/tx0.tmp --tx-in-count ${utxo_cnt} diff --git a/scripts/cnode-helper-scripts/cntools.sh b/scripts/cnode-helper-scripts/cntools.sh index 250063c3a..785ee620c 100755 --- a/scripts/cnode-helper-scripts/cntools.sh +++ b/scripts/cnode-helper-scripts/cntools.sh @@ -385,12 +385,12 @@ function main { println " Choose another name or delete the existing one" waitForInput && continue fi - println ACTION "${CCLI} address key-gen --verification-key-file ${payment_vk_file} --signing-key-file ${payment_sk_file}" - if ! ${CCLI} address key-gen --verification-key-file "${payment_vk_file}" --signing-key-file "${payment_sk_file}"; then + println ACTION "${CCLI} ${NETWORK_ERA} address key-gen --verification-key-file ${payment_vk_file} --signing-key-file ${payment_sk_file}" + if ! ${CCLI} ${NETWORK_ERA} address key-gen --verification-key-file "${payment_vk_file}" --signing-key-file "${payment_sk_file}"; then println ERROR "\n${FG_RED}ERROR${NC}: failure during payment key creation!"; safeDel "${WALLET_FOLDER}/${wallet_name}"; waitForInput && continue fi - println ACTION "${CCLI} stake-address key-gen --verification-key-file ${stake_vk_file} --signing-key-file ${stake_sk_file}" - if ! ${CCLI} stake-address key-gen --verification-key-file "${stake_vk_file}" --signing-key-file "${stake_sk_file}"; then + println ACTION "${CCLI} ${NETWORK_ERA} stake-address key-gen --verification-key-file ${stake_vk_file} --signing-key-file ${stake_sk_file}" + if ! ${CCLI} ${NETWORK_ERA} stake-address key-gen --verification-key-file "${stake_vk_file}" --signing-key-file "${stake_sk_file}"; then println ERROR "\n${FG_RED}ERROR${NC}: failure during stake key creation!"; safeDel "${WALLET_FOLDER}/${wallet_name}"; waitForInput && continue fi chmod 600 "${WALLET_FOLDER}/${wallet_name}/"* @@ -502,20 +502,20 @@ function main { "cborHex": "5880${ses_key}" } EOF - println ACTION "${CCLI} key verification-key --signing-key-file ${payment_sk_file} --verification-key-file ${TMP_DIR}/payment.evkey" - if ! ${CCLI} key verification-key --signing-key-file "${payment_sk_file}" --verification-key-file "${TMP_DIR}/payment.evkey"; then + println ACTION "${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file ${payment_sk_file} --verification-key-file ${TMP_DIR}/payment.evkey" + if ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${payment_sk_file}" --verification-key-file "${TMP_DIR}/payment.evkey"; then println ERROR "\n${FG_RED}ERROR${NC}: failure during payment signing key extraction!"; safeDel "${WALLET_FOLDER}/${wallet_name}"; waitForInput && continue fi - println ACTION "${CCLI} key verification-key --signing-key-file ${stake_sk_file} --verification-key-file ${TMP_DIR}/stake.evkey" - if ! ${CCLI} key verification-key --signing-key-file "${stake_sk_file}" --verification-key-file "${TMP_DIR}/stake.evkey"; then + println ACTION "${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file ${stake_sk_file} --verification-key-file ${TMP_DIR}/stake.evkey" + if ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${stake_sk_file}" --verification-key-file "${TMP_DIR}/stake.evkey"; then println ERROR "\n${FG_RED}ERROR${NC}: failure during stake signing key extraction!"; safeDel "${WALLET_FOLDER}/${wallet_name}"; waitForInput && continue fi - println ACTION "${CCLI} key non-extended-key --extended-verification-key-file ${TMP_DIR}/payment.evkey --verification-key-file ${payment_vk_file}" - if ! ${CCLI} key non-extended-key --extended-verification-key-file "${TMP_DIR}/payment.evkey" --verification-key-file "${payment_vk_file}"; then + println ACTION "${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file ${TMP_DIR}/payment.evkey --verification-key-file ${payment_vk_file}" + if ! ${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file "${TMP_DIR}/payment.evkey" --verification-key-file "${payment_vk_file}"; then println ERROR "\n${FG_RED}ERROR${NC}: failure during payment verification key extraction!"; safeDel "${WALLET_FOLDER}/${wallet_name}"; waitForInput && continue fi - println ACTION "${CCLI} key non-extended-key --extended-verification-key-file ${TMP_DIR}/stake.evkey --verification-key-file ${stake_vk_file}" - if ! ${CCLI} key non-extended-key --extended-verification-key-file "${TMP_DIR}/stake.evkey" --verification-key-file "${stake_vk_file}"; then + println ACTION "${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file ${TMP_DIR}/stake.evkey --verification-key-file ${stake_vk_file}" + if ! ${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file "${TMP_DIR}/stake.evkey" --verification-key-file "${stake_vk_file}"; then println ERROR "\n${FG_RED}ERROR${NC}: failure during stake verification key extraction!"; safeDel "${WALLET_FOLDER}/${wallet_name}"; waitForInput && continue fi chmod 600 "${WALLET_FOLDER}/${wallet_name}/"* @@ -1290,66 +1290,64 @@ function main { println ERROR "${FG_RED}ERROR${NC}: no funds available for wallet ${FG_GREEN}${s_wallet}${NC}" waitForInput && continue fi + + # Destination + d_wallet="" + println DEBUG "# Select ${FG_YELLOW}destination${NC} type" + select_opt "[w] Wallet" "[a] Address" "[Esc] Cancel" + case $? in + 0) selectWallet "balance" + case $? in + 1) waitForInput; continue ;; + 2) continue ;; + esac + d_wallet="${wallet_name}" + getBaseAddress ${d_wallet} + getPayAddress ${d_wallet} + if [[ -n "${base_addr}" && "${base_addr}" != "${s_addr}" && -n "${pay_addr}" && "${pay_addr}" != "${s_addr}" ]]; then + # Both base and enterprise address available, let user choose what to use + select_opt "[b] Base (default)" "[e] Enterprise" "[Esc] Cancel" + case $? in + 0) d_addr="${base_addr}" ;; + 1) d_addr="${pay_addr}" ;; + 2) continue ;; + esac + elif [[ -n "${base_addr}" && "${base_addr}" != "${s_addr}" ]]; then + d_addr="${base_addr}" + elif [[ -n "${pay_addr}" && "${pay_addr}" != "${s_addr}" ]]; then + d_addr="${pay_addr}" + elif [[ "${base_addr}" = "${s_addr}" || "${pay_addr}" = "${s_addr}" ]]; then + println ERROR "\n${FG_RED}ERROR${NC}: sending to same address as source not supported" + waitForInput && continue + else + println ERROR "\n${FG_RED}ERROR${NC}: no address found for wallet ${FG_GREEN}${d_wallet}${NC} :(" + waitForInput && continue + fi + ;; + 1) getAnswerAnyCust d_addr "Address" ;; + 2) continue ;; + esac + # Destination could be empty, if so without getting a valid address + if [[ -z ${d_addr} ]]; then + println ERROR "${FG_RED}ERROR${NC}: destination address field empty" + waitForInput && continue + fi + getBalance ${s_addr} declare -gA assets_left=() + declare -gA assets_to_send=() for asset in "${!assets[@]}"; do assets_left[${asset}]=${assets[${asset}]} done - minUTxOValue=$(jq -r '.minUTxOValue //1000000' <<< "${PROT_PARAMS}") - # Amount - println DEBUG "\n# Amount to Send (in Ada)" - println DEBUG " Valid entry:" - println DEBUG " ${FG_LGRAY}>${NC} Integer (e.g. 15) or Decimal (e.g. 956.1235), commas allowed as thousand separator" - println DEBUG " ${FG_LGRAY}>${NC} The string '${FG_YELLOW}all${NC}' sends all available funds in source wallet" - println DEBUG " Multi-Asset Info:" - println DEBUG " ${FG_LGRAY}>${NC} If '${FG_YELLOW}all${NC}' is used and the wallet contain multiple assets," - println DEBUG " ${FG_LGRAY}>${NC} then all assets will be transferred(incl Ada) to the destination address" - println DEBUG " Minimum Amount: ${FG_LBLUE}$(formatLovelace ${minUTxOValue})${NC} Ada" - println DEBUG " ${FG_LGRAY}>${NC} To calculate the minimum Ada required if additional assets/tokens are to be sent,"\ - " make a dummy transaction with ${FG_LBLUE}0${NC} Ada selecting the tokens to send with the correct amount\n" - getAnswerAnyCust amountADA "Amount (Ada)" - amountADA="${amountADA//,}" - echo - if [[ ${amountADA} != "all" ]]; then - if ! AdaToLovelace "${amountADA}" >/dev/null; then - waitForInput && continue - fi - amount_lovelace=$(AdaToLovelace "${amountADA}") - [[ ${amount_lovelace} -gt ${assets[lovelace]} ]] && println ERROR "${FG_RED}ERROR${NC}: not enough funds on address, ${FG_LBLUE}$(formatLovelace ${assets[lovelace]})${NC} Ada available but trying to send ${FG_LBLUE}$(formatLovelace ${amount_lovelace})${NC} Ada" && waitForInput && continue - println DEBUG "Fee payed by sender? [else amount sent is reduced]" - select_opt "[y] Yes" "[n] No" "[Esc] Cancel" - case $? in - 0) include_fee="no" ;; - 1) include_fee="yes" ;; - 2) continue ;; - esac - else - amount_lovelace=${assets[lovelace]} - println DEBUG "Ada to send set to total supply: ${FG_LBLUE}$(formatLovelace ${amount_lovelace})${NC}" - include_fee="yes" - fi - echo - declare -gA assets_to_send=() - if [[ ${amount_lovelace} -eq ${assets[lovelace]} ]]; then - unset assets_left - for asset in "${!assets[@]}"; do - assets_to_send[${asset}]=${assets[${asset}]} # add all assets, e.g clone assets array to assets_to_send - done - else - assets_left[lovelace]=$(( assets_left[lovelace] - amount_lovelace )) - assets_to_send[lovelace]=${amount_lovelace} - fi - # Add additional assets to transaction? - if [[ ${#assets_left[@]} -gt 0 && ${#assets[@]} -gt 1 ]]; then + if [[ ${#assets_left[@]} -gt 1 ]]; then println DEBUG "Additional assets found on address, include in transaction?" - asset_cnt=1 select_opt "[n] No" "[y] Yes" "[Esc] Cancel" case $? in 0) : ;; 1) declare -A assets_on_addr=() - for asset in "${!assets[@]}"; do + for asset in "${!assets_left[@]}"; do [[ ${asset} = "lovelace" ]] && continue IFS='.' read -ra asset_arr <<< "${asset}" assets_on_addr["${asset} ($(hexToAscii ${asset_arr[1]}))"]=0 # only interested in the key @@ -1359,21 +1357,21 @@ function main { selection=$? [[ ${selected_value} = "[Esc] Cancel" ]] && continue 2 IFS=' ' read -ra selection_arr <<< "${selected_value}" - println DEBUG "Available to send: ${FG_LBLUE}$(formatAsset ${assets[${selection_arr[0]}]})${NC}" + println DEBUG "Available to send: ${FG_LBLUE}$(formatAsset ${assets_left[${selection_arr[0]}]})${NC}" getAnswerAnyCust asset_amount "Amount (commas allowed as thousand separator)" asset_amount="${asset_amount//,}" - [[ ${asset_amount} = "all" ]] && asset_amount=${assets[${selection_arr[0]}]} + [[ ${asset_amount} = "all" ]] && asset_amount=${assets_left[${selection_arr[0]}]} if ! isNumber ${asset_amount}; then println ERROR "${FG_RED}ERROR${NC}: invalid number, non digit characters found!" && continue; fi - if [[ ${asset_amount} -gt ${assets[${selection_arr[0]}]} ]]; then + if [[ ${asset_amount} -gt ${assets_left[${selection_arr[0]}]} ]]; then println ERROR "${FG_RED}ERROR${NC}: you cant send more assets than available on address!" && continue - elif [[ ${asset_amount} -eq ${assets[${selection_arr[0]}]} ]]; then + elif [[ ${asset_amount} -eq ${assets_left[${selection_arr[0]}]} ]]; then unset assets_left[${selection_arr[0]}] else assets_left[${selection_arr[0]}]=$(( assets_left[${selection_arr[0]}] - asset_amount )) fi assets_to_send[${selection_arr[0]}]=${asset_amount} unset assets_on_addr["${selected_value}"] - [[ $((++asset_cnt)) -eq ${#assets[@]} ]] && break + [[ ${#assets_on_addr[@]} -eq 0 ]] && break println DEBUG "Add more assets?" select_opt "[n] No" "[y] Yes" "[Esc] Cancel" case $? in @@ -1381,53 +1379,71 @@ function main { 1) : ;; 2) continue 2 ;; esac - done + done ;; 2) continue ;; esac echo fi - # Destination - d_wallet="" - println DEBUG "# Select ${FG_YELLOW}destination${NC} type" - select_opt "[w] Wallet" "[a] Address" "[Esc] Cancel" - case $? in - 0) selectWallet "balance" + # Amount + assets_tx_out_d="" + for idx in "${!assets_to_send[@]}"; do + [[ ${idx} = "lovelace" ]] && continue + [[ ${assets_to_send[${idx}]} -gt 0 ]] && assets_tx_out_d+="+${assets_to_send[${idx}]} ${idx}" + done + getMinUTxO "${d_addr}+1${assets_tx_out_d}" + println DEBUG "\n# Amount to Send (in Ada)" + println DEBUG " Valid entry:" + println DEBUG " ${FG_LGRAY}>${NC} Integer (e.g. 15) or Decimal (e.g. 956.1235), commas allowed as thousand separator" + println DEBUG " ${FG_LGRAY}>${NC} The string '${FG_YELLOW}all${NC}' sends all available funds in source wallet" + println DEBUG " Multi-Asset Info:" + println DEBUG " ${FG_LGRAY}>${NC} If '${FG_YELLOW}all${NC}' is used and the wallet contain multiple assets," + println DEBUG " ${FG_LGRAY}>${NC} you will be asked to transfer all assets (incl Ada) to the destination address" + println DEBUG " Minimum Amount: ${FG_LBLUE}$(formatLovelace ${min_utxo_out})${NC} Ada" + getAnswerAnyCust amountADA "Amount (Ada)" + amountADA="${amountADA//,}" + echo + if [[ ${amountADA} != "all" ]]; then + if ! amount_lovelace=$(AdaToLovelace "${amountADA}" >/dev/null); then waitForInput && continue; fi + [[ ${amount_lovelace} -gt ${assets[lovelace]} ]] && println ERROR "${FG_RED}ERROR${NC}: not enough funds on address, ${FG_LBLUE}$(formatLovelace ${assets[lovelace]})${NC} Ada available but trying to send ${FG_LBLUE}$(formatLovelace ${amount_lovelace})${NC} Ada" && waitForInput && continue + if [[ ${amount_lovelace} -lt ${assets[lovelace]} ]]; then + println DEBUG "Fee payed by sender? [else amount sent is reduced]" + select_opt "[y] Yes" "[n] No" "[Esc] Cancel" case $? in - 1) waitForInput; continue ;; + 0) include_fee="no" ;; + 1) include_fee="yes" ;; 2) continue ;; esac - d_wallet="${wallet_name}" - getBaseAddress ${d_wallet} - getPayAddress ${d_wallet} - if [[ -n "${base_addr}" && "${base_addr}" != "${s_addr}" && -n "${pay_addr}" && "${pay_addr}" != "${s_addr}" ]]; then - # Both base and enterprise address available, let user choose what to use - select_opt "[b] Base (default)" "[e] Enterprise" "[Esc] Cancel" - case $? in - 0) d_addr="${base_addr}" ;; - 1) d_addr="${pay_addr}" ;; - 2) continue ;; - esac - elif [[ -n "${base_addr}" && "${base_addr}" != "${s_addr}" ]]; then - d_addr="${base_addr}" - elif [[ -n "${pay_addr}" && "${pay_addr}" != "${s_addr}" ]]; then - d_addr="${pay_addr}" - elif [[ "${base_addr}" = "${s_addr}" || "${pay_addr}" = "${s_addr}" ]]; then - println ERROR "\n${FG_RED}ERROR${NC}: sending to same address as source not supported" - waitForInput && continue - else - println ERROR "\n${FG_RED}ERROR${NC}: no address found for wallet ${FG_GREEN}${d_wallet}${NC} :(" - waitForInput && continue - fi - ;; - 1) getAnswerAnyCust d_addr "Address" ;; - 2) continue ;; - esac - # Destination could be empty, if so without getting a valid address - if [[ -z ${d_addr} ]]; then - println ERROR "${FG_RED}ERROR${NC}: destination address field empty" - waitForInput && continue + else + include_fee="yes" + fi + else + amount_lovelace=${assets[lovelace]} + println DEBUG "Ada to send set to total supply: ${FG_LBLUE}$(formatLovelace ${amount_lovelace})${NC}" + include_fee="yes" + fi + + echo + + if [[ ${amount_lovelace} -eq ${assets[lovelace]} ]]; then + if [[ ${#assets_left[@]} -gt 1 ]]; then + println DEBUG "All Ada selected to be sent, automatically add all tokens?" + select_opt "[y] Yes" "[n] No" "[Esc] Cancel" + case $? in + 0) declare -gA assets_left=() + declare -gA assets_to_send=() + for asset in "${!assets[@]}"; do + assets_to_send[${asset}]=${assets[${asset}]} # add all assets, e.g clone assets array to assets_to_send + done + ;; + 1) println ERROR "${FG_RED}ERROR${NC}: Unable to send all Ada as there are additional assets left on address not selected to be sent" && waitForInput && continue ;; + 2) continue ;; + esac + fi + else + assets_left[lovelace]=$(( assets_left[lovelace] - amount_lovelace )) + assets_to_send[lovelace]=${amount_lovelace} fi # Optional metadata/message @@ -1580,8 +1596,8 @@ function main { esac stake_vk_file="${WALLET_FOLDER}/${wallet_name}/${WALLET_STAKE_VK_FILENAME}" pool_delegcert_file="${WALLET_FOLDER}/${wallet_name}/${WALLET_DELEGCERT_FILENAME}" - println ACTION "${CCLI} stake-address delegation-certificate --stake-verification-key-file ${stake_vk_file} --stake-pool-id ${pool_id} --out-file ${pool_delegcert_file}" - ${CCLI} stake-address delegation-certificate --stake-verification-key-file "${stake_vk_file}" --stake-pool-id "${pool_id}" --out-file "${pool_delegcert_file}" + println ACTION "${CCLI} ${NETWORK_ERA} stake-address delegation-certificate --stake-verification-key-file ${stake_vk_file} --stake-pool-id ${pool_id} --out-file ${pool_delegcert_file}" + ${CCLI} ${NETWORK_ERA} stake-address delegation-certificate --stake-verification-key-file "${stake_vk_file}" --stake-pool-id "${pool_id}" --out-file "${pool_delegcert_file}" if ! delegate; then if [[ ${op_mode} = "online" ]]; then echo && println ERROR "${FG_RED}ERROR${NC}: failure during delegation, removing newly created delegation certificate file" @@ -1722,17 +1738,17 @@ function main { println ERROR " Choose another name or delete the existing one" waitForInput && continue fi - println ACTION "${CCLI} node key-gen-KES --verification-key-file ${pool_hotkey_vk_file} --signing-key-file ${pool_hotkey_sk_file}" - ${CCLI} node key-gen-KES --verification-key-file "${pool_hotkey_vk_file}" --signing-key-file "${pool_hotkey_sk_file}" + println ACTION "${CCLI} ${NETWORK_ERA} node key-gen-KES --verification-key-file ${pool_hotkey_vk_file} --signing-key-file ${pool_hotkey_sk_file}" + ${CCLI} ${NETWORK_ERA} node key-gen-KES --verification-key-file "${pool_hotkey_vk_file}" --signing-key-file "${pool_hotkey_sk_file}" if [ -f "${POOL_FOLDER}-pregen/${pool_name}/${POOL_ID_FILENAME}" ]; then mv ${POOL_FOLDER}'-pregen/'${pool_name}/* ${POOL_FOLDER}/${pool_name}/ rm -r ${POOL_FOLDER}'-pregen/'${pool_name} else - println ACTION "${CCLI} node key-gen --cold-verification-key-file ${pool_coldkey_vk_file} --cold-signing-key-file ${pool_coldkey_sk_file} --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" - ${CCLI} node key-gen --cold-verification-key-file "${pool_coldkey_vk_file}" --cold-signing-key-file "${pool_coldkey_sk_file}" --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" + println ACTION "${CCLI} ${NETWORK_ERA} node key-gen --cold-verification-key-file ${pool_coldkey_vk_file} --cold-signing-key-file ${pool_coldkey_sk_file} --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" + ${CCLI} ${NETWORK_ERA} node key-gen --cold-verification-key-file "${pool_coldkey_vk_file}" --cold-signing-key-file "${pool_coldkey_sk_file}" --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" fi - println ACTION "${CCLI} node key-gen-VRF --verification-key-file ${pool_vrf_vk_file} --signing-key-file ${pool_vrf_sk_file}" - ${CCLI} node key-gen-VRF --verification-key-file "${pool_vrf_vk_file}" --signing-key-file "${pool_vrf_sk_file}" + println ACTION "${CCLI} ${NETWORK_ERA} node key-gen-VRF --verification-key-file ${pool_vrf_vk_file} --signing-key-file ${pool_vrf_sk_file}" + ${CCLI} ${NETWORK_ERA} node key-gen-VRF --verification-key-file "${pool_vrf_vk_file}" --signing-key-file "${pool_vrf_sk_file}" chmod 600 "${POOL_FOLDER}/${pool_name}/"* getPoolID ${pool_name} echo @@ -1768,11 +1784,11 @@ function main { waitForInput && continue fi - println ACTION "${CCLI} node key-gen-KES --verification-key-file ${pool_hotkey_vk_file} --signing-key-file ${pool_hotkey_sk_file}" - ${CCLI} node key-gen-KES --verification-key-file "${pool_hotkey_vk_file}" --signing-key-file "${pool_hotkey_sk_file}" + println ACTION "${CCLI} ${NETWORK_ERA} node key-gen-KES --verification-key-file ${pool_hotkey_vk_file} --signing-key-file ${pool_hotkey_sk_file}" + ${CCLI} ${NETWORK_ERA} node key-gen-KES --verification-key-file "${pool_hotkey_vk_file}" --signing-key-file "${pool_hotkey_sk_file}" - println ACTION "${CCLI} node key-gen-VRF --verification-key-file ${pool_vrf_vk_file} --signing-key-file ${pool_vrf_sk_file}" - ${CCLI} node key-gen-VRF --verification-key-file "${pool_vrf_vk_file}" --signing-key-file "${pool_vrf_sk_file}" + println ACTION "${CCLI} ${NETWORK_ERA} node key-gen-VRF --verification-key-file ${pool_vrf_vk_file} --signing-key-file ${pool_vrf_sk_file}" + ${CCLI} ${NETWORK_ERA} node key-gen-VRF --verification-key-file "${pool_vrf_vk_file}" --signing-key-file "${pool_vrf_sk_file}" println ACTION "cardano-hw-cli node key-gen --path 1853H/1815H/0H/0H --hw-signing-file ${pool_coldkey_sk_file} --cold-verification-key-file ${pool_coldkey_kk_file} --operational-certificate-issue-counter-file ${pool_opcert_counter_file}" if ! unlockHWDevice "export cold pub keys"; then safeDel "${POOL_FOLDER}/${pool_name}"; continue; fi @@ -2291,8 +2307,8 @@ function main { --out-file "${pool_opcert_file}" \ && return 1 else - println ACTION "${CCLI} node issue-op-cert --kes-verification-key-file ${pool_hotkey_vk_file} --cold-signing-key-file ${pool_coldkey_sk_file} --operational-certificate-issue-counter-file ${pool_opcert_counter_file} --kes-period ${current_kes_period} --out-file ${pool_opcert_file}" - ${CCLI} node issue-op-cert --kes-verification-key-file "${pool_hotkey_vk_file}" --cold-signing-key-file "${pool_coldkey_sk_file}" --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" --kes-period "${current_kes_period}" --out-file "${pool_opcert_file}" + println ACTION "${CCLI} ${NETWORK_ERA} node issue-op-cert --kes-verification-key-file ${pool_hotkey_vk_file} --cold-signing-key-file ${pool_coldkey_sk_file} --operational-certificate-issue-counter-file ${pool_opcert_counter_file} --kes-period ${current_kes_period} --out-file ${pool_opcert_file}" + ${CCLI} ${NETWORK_ERA} node issue-op-cert --kes-verification-key-file "${pool_hotkey_vk_file}" --cold-signing-key-file "${pool_coldkey_sk_file}" --operational-certificate-issue-counter-file "${pool_opcert_counter_file}" --kes-period "${current_kes_period}" --out-file "${pool_opcert_file}" fi fi @@ -2309,8 +2325,8 @@ function main { fi println LOG "creating registration certificate" - println ACTION "${CCLI} stake-pool registration-certificate --cold-verification-key-file ${pool_coldkey_vk_file} --vrf-verification-key-file ${pool_vrf_vk_file} --pool-pledge ${pledge_lovelace} --pool-cost ${cost_lovelace} --pool-margin ${margin_fraction} --pool-reward-account-verification-key-file ${reward_stake_vk_file} --pool-owner-stake-verification-key-file ${owner_stake_vk_file} ${multi_owner_output} --metadata-url ${meta_json_url} --metadata-hash \$\(${CCLI} stake-pool metadata-hash --pool-metadata-file ${pool_meta_file} \) ${relay_output} ${NETWORK_IDENTIFIER} --out-file ${pool_regcert_file}" - ${CCLI} stake-pool registration-certificate --cold-verification-key-file "${pool_coldkey_vk_file}" --vrf-verification-key-file "${pool_vrf_vk_file}" --pool-pledge ${pledge_lovelace} --pool-cost ${cost_lovelace} --pool-margin ${margin_fraction} --pool-reward-account-verification-key-file "${reward_stake_vk_file}" --pool-owner-stake-verification-key-file "${owner_stake_vk_file}" ${multi_owner_output} --metadata-url "${meta_json_url}" --metadata-hash "$(${CCLI} stake-pool metadata-hash --pool-metadata-file ${pool_meta_file} )" ${relay_output} ${NETWORK_IDENTIFIER} --out-file "${pool_regcert_file}" + println ACTION "${CCLI} ${NETWORK_ERA} stake-pool registration-certificate --cold-verification-key-file ${pool_coldkey_vk_file} --vrf-verification-key-file ${pool_vrf_vk_file} --pool-pledge ${pledge_lovelace} --pool-cost ${cost_lovelace} --pool-margin ${margin_fraction} --pool-reward-account-verification-key-file ${reward_stake_vk_file} --pool-owner-stake-verification-key-file ${owner_stake_vk_file} ${multi_owner_output} --metadata-url ${meta_json_url} --metadata-hash \$\(${CCLI} ${NETWORK_ERA} stake-pool metadata-hash --pool-metadata-file ${pool_meta_file} \) ${relay_output} ${NETWORK_IDENTIFIER} --out-file ${pool_regcert_file}" + ${CCLI} ${NETWORK_ERA} stake-pool registration-certificate --cold-verification-key-file "${pool_coldkey_vk_file}" --vrf-verification-key-file "${pool_vrf_vk_file}" --pool-pledge ${pledge_lovelace} --pool-cost ${cost_lovelace} --pool-margin ${margin_fraction} --pool-reward-account-verification-key-file "${reward_stake_vk_file}" --pool-owner-stake-verification-key-file "${owner_stake_vk_file}" ${multi_owner_output} --metadata-url "${meta_json_url}" --metadata-hash "$(${CCLI} ${NETWORK_ERA} stake-pool metadata-hash --pool-metadata-file ${pool_meta_file} )" ${relay_output} ${NETWORK_IDENTIFIER} --out-file "${pool_regcert_file}" delegate_owner_wallet='N' if [[ ${SUBCOMMAND} = "register" ]]; then @@ -2320,8 +2336,8 @@ function main { waitForInput "press any key to continue" else println LOG "creating delegation certificate for main owner wallet" - println ACTION "${CCLI} stake-address delegation-certificate --stake-verification-key-file ${owner_stake_vk_file} --cold-verification-key-file ${pool_coldkey_vk_file} --out-file ${owner_delegation_cert_file}" - ${CCLI} stake-address delegation-certificate --stake-verification-key-file "${owner_stake_vk_file}" --cold-verification-key-file "${pool_coldkey_vk_file}" --out-file "${owner_delegation_cert_file}" + println ACTION "${CCLI} ${NETWORK_ERA} stake-address delegation-certificate --stake-verification-key-file ${owner_stake_vk_file} --cold-verification-key-file ${pool_coldkey_vk_file} --out-file ${owner_delegation_cert_file}" + ${CCLI} ${NETWORK_ERA} stake-address delegation-certificate --stake-verification-key-file "${owner_stake_vk_file}" --cold-verification-key-file "${pool_coldkey_vk_file}" --out-file "${owner_delegation_cert_file}" delegate_owner_wallet='Y' if [[ "${owner_wallets[0]}" != "${reward_wallet}" ]]; then println DEBUG "\n${FG_BLUE}INFO${NC}: reward wallet not the same as owner, automatic reward wallet delegation disabled" @@ -2535,8 +2551,8 @@ function main { pool_deregcert_file="${POOL_FOLDER}/${pool_name}/${POOL_DEREGCERT_FILENAME}" pool_regcert_file="${POOL_FOLDER}/${pool_name}/${POOL_REGCERT_FILENAME}" println LOG "creating de-registration cert" - println ACTION "${CCLI} stake-pool deregistration-certificate --cold-verification-key-file ${pool_coldkey_vk_file} --epoch ${epoch_enter} --out-file ${pool_deregcert_file}" - ${CCLI} stake-pool deregistration-certificate --cold-verification-key-file ${pool_coldkey_vk_file} --epoch ${epoch_enter} --out-file ${pool_deregcert_file} + println ACTION "${CCLI} ${NETWORK_ERA} stake-pool deregistration-certificate --cold-verification-key-file ${pool_coldkey_vk_file} --epoch ${epoch_enter} --out-file ${pool_deregcert_file}" + ${CCLI} ${NETWORK_ERA} stake-pool deregistration-certificate --cold-verification-key-file ${pool_coldkey_vk_file} --epoch ${epoch_enter} --out-file ${pool_deregcert_file} echo if ! deRegisterPool; then waitForInput && continue @@ -2630,8 +2646,8 @@ function main { select_opt "[y] Yes" "[n] No, abort" [[ $? -eq 1 ]] && continue tput sc && println DEBUG "Quering pool parameters from node, can take a while...\n" - println ACTION "${CCLI} query pool-params --stake-pool-id ${pool_id_bech32} ${NETWORK_IDENTIFIER}" - if ! pool_params=$(${CCLI} query pool-params --stake-pool-id ${pool_id_bech32} ${NETWORK_IDENTIFIER} 2>&1); then + println ACTION "${CCLI} ${NETWORK_ERA} query pool-params --stake-pool-id ${pool_id_bech32} ${NETWORK_IDENTIFIER}" + if ! pool_params=$(${CCLI} ${NETWORK_ERA} query pool-params --stake-pool-id ${pool_id_bech32} ${NETWORK_IDENTIFIER} 2>&1); then tput rc && tput ed println ERROR "${FG_RED}ERROR${NC}: pool-params query failed: ${pool_params}" waitForInput && continue @@ -2678,8 +2694,8 @@ function main { println "$(printf " %-19s : ${FG_LGRAY}%s${NC}" "Description" "$(jq -r .description "${pool_meta_file}")")" [[ -f "${pool_config}" ]] && meta_url="$(jq -r .json_url "${pool_config}")" || meta_url="---" println "$(printf " %-19s : ${FG_LGRAY}%s${NC}" "URL" "${meta_url}")" - println "ACTION" "${CCLI} stake-pool metadata-hash --pool-metadata-file ${pool_meta_file}" - meta_hash="$( ${CCLI} stake-pool metadata-hash --pool-metadata-file "${pool_meta_file}" )" + println "ACTION" "${CCLI} ${NETWORK_ERA} stake-pool metadata-hash --pool-metadata-file ${pool_meta_file}" + meta_hash="$( ${CCLI} ${NETWORK_ERA} stake-pool metadata-hash --pool-metadata-file "${pool_meta_file}" )" println "$(printf " %-19s : ${FG_LGRAY}%s${NC}" "Hash" "${meta_hash}")" fi elif [[ ${pool_registered} = *YES* ]]; then @@ -2697,8 +2713,8 @@ function main { println "$(printf " %-19s : ${FG_LGRAY}%s${NC}" "Homepage" "$(jq -r .homepage "$TMP_DIR/url_poolmeta.json")")" println "$(printf " %-19s : ${FG_LGRAY}%s${NC}" "Description" "$(jq -r .description "$TMP_DIR/url_poolmeta.json")")" println "$(printf " %-19s : ${FG_LGRAY}%s${NC}" "URL" "${meta_json_url}")" - println ACTION "${CCLI} stake-pool metadata-hash --pool-metadata-file ${TMP_DIR}/url_poolmeta.json" - meta_hash_url="$( ${CCLI} stake-pool metadata-hash --pool-metadata-file "${TMP_DIR}/url_poolmeta.json" )" + println ACTION "${CCLI} ${NETWORK_ERA} stake-pool metadata-hash --pool-metadata-file ${TMP_DIR}/url_poolmeta.json" + meta_hash_url="$( ${CCLI} ${NETWORK_ERA} stake-pool metadata-hash --pool-metadata-file "${TMP_DIR}/url_poolmeta.json" )" println "$(printf " %-19s : ${FG_LGRAY}%s${NC}" "Hash URL" "${meta_hash_url}")" if [[ -z ${KOIOS_API} ]]; then meta_hash_pParams=$(jq -r '.metadata.hash //empty' <<< "${ledger_pParams}") @@ -2876,8 +2892,8 @@ function main { if [[ -z ${KOIOS_API} ]]; then # get stake distribution - println "ACTION" "LC_NUMERIC=C printf %.10f \$(${CCLI} query stake-distribution ${NETWORK_IDENTIFIER} | grep ${pool_id_bech32} | tr -s ' ' | cut -d ' ' -f 2))" - stake_pct=$(fractionToPCT "$(LC_NUMERIC=C printf "%.10f" "$(${CCLI} query stake-distribution ${NETWORK_IDENTIFIER} | grep "${pool_id_bech32}" | tr -s ' ' | cut -d ' ' -f 2)")") + println "ACTION" "LC_NUMERIC=C printf %.10f \$(${CCLI} ${NETWORK_ERA} query stake-distribution ${NETWORK_IDENTIFIER} | grep ${pool_id_bech32} | tr -s ' ' | cut -d ' ' -f 2))" + stake_pct=$(fractionToPCT "$(LC_NUMERIC=C printf "%.10f" "$(${CCLI} ${NETWORK_ERA} query stake-distribution ${NETWORK_IDENTIFIER} | grep "${pool_id_bech32}" | tr -s ' ' | cut -d ' ' -f 2)")") if validateDecimalNbr ${stake_pct}; then println "$(printf "%-21s : ${FG_LBLUE}%s${NC} %%" "Stake distribution" "${stake_pct}")" fi @@ -2896,8 +2912,8 @@ function main { println "$(printf "%-21s : %s" "KES counter" "${kes_counter_str}")" elif [[ ${CNTOOLS_MODE} = "CONNECTED" ]]; then pool_opcert_file="${POOL_FOLDER}/${pool_name}/${POOL_OPCERT_FILENAME}" - println ACTION "${CCLI} query kes-period-info --op-cert-file ${pool_opcert_file} ${NETWORK_IDENTIFIER}" - if ! kes_period_info=$(${CCLI} query kes-period-info --op-cert-file "${pool_opcert_file}" ${NETWORK_IDENTIFIER}); then + println ACTION "${CCLI} ${NETWORK_ERA} query kes-period-info --op-cert-file ${pool_opcert_file} ${NETWORK_IDENTIFIER}" + if ! kes_period_info=$(${CCLI} ${NETWORK_ERA} query kes-period-info --op-cert-file "${pool_opcert_file}" ${NETWORK_IDENTIFIER}); then kes_counter_str="${FG_RED}ERROR${NC}: failed to grab counter from node: [${FG_LGRAY}${kes_period_info}${NC}]" else if op_cert_counter=$(awk '/{/,0' <<< "${kes_period_info}" | jq -er '.qKesNodeStateOperationalCertificateNumber' 2>/dev/null); then @@ -3459,9 +3475,9 @@ function main { # look for signing key in wallet folder while IFS= read -r -d '' w_file; do if [[ ${w_file} = */"${WALLET_PAY_SK_FILENAME}" || ${w_file} = */"${WALLET_STAKE_SK_FILENAME}" ]]; then - ! ${CCLI} key verification-key --signing-key-file "${w_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue + ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${w_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue if [[ $(jq -er '.type' "${w_file}" 2>/dev/null) = *"Extended"* ]]; then - ! ${CCLI} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey" && continue + ! ${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey" && continue mv -f "${TMP_DIR}/tmp2.vkey" "${TMP_DIR}/tmp.vkey" fi grep -q "${otx_vkey_cborHex}" "${TMP_DIR}"/tmp.vkey && skey_path="${w_file}" && break @@ -3472,14 +3488,14 @@ function main { # look for cold signing key in pool folder if [[ -z ${skey_path} ]]; then while IFS= read -r -d '' p_file; do - ! ${CCLI} key verification-key --signing-key-file "${p_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue + ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${p_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue grep -q "${otx_vkey_cborHex}" "${TMP_DIR}"/tmp.vkey && skey_path="${p_file}" && break done < <(find "${POOL_FOLDER}" -mindepth 2 -maxdepth 2 -type f -name "${POOL_COLDKEY_SK_FILENAME}" -print0 2>/dev/null) fi # look for signing key in asset folder if [[ -z ${skey_path} ]]; then while IFS= read -r -d '' a_file; do - ! ${CCLI} key verification-key --signing-key-file "${a_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue + ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${a_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue grep -q "${otx_vkey_cborHex}" "${TMP_DIR}"/tmp.vkey && skey_path="${a_file}" && break done < <(find "${ASSET_FOLDER}" -mindepth 2 -maxdepth 2 -type f -name "${ASSET_POLICY_SK_FILENAME}" -print0 2>/dev/null) fi @@ -3515,11 +3531,11 @@ function main { waitForInput && continue 2 fi else - println ACTION "${CCLI} key verification-key --signing-key-file ${file} --verification-key-file ${TMP_DIR}/tmp.vkey" - if ! ${CCLI} key verification-key --signing-key-file "${file}" --verification-key-file "${TMP_DIR}"/tmp.vkey; then waitForInput && continue 2; fi + println ACTION "${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file ${file} --verification-key-file ${TMP_DIR}/tmp.vkey" + if ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${file}" --verification-key-file "${TMP_DIR}"/tmp.vkey; then waitForInput && continue 2; fi if [[ $(jq -r '.type' "${file}") = *"Extended"* ]]; then - println ACTION "${CCLI} key non-extended-key --extended-verification-key-file ${TMP_DIR}/tmp.vkey --verification-key-file ${TMP_DIR}/tmp2.vkey" - if ! ${CCLI} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey"; then waitForInput && continue 2; fi + println ACTION "${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file ${TMP_DIR}/tmp.vkey --verification-key-file ${TMP_DIR}/tmp2.vkey" + if ! ${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey"; then waitForInput && continue 2; fi mv -f "${TMP_DIR}/tmp2.vkey" "${TMP_DIR}/tmp.vkey" fi if [[ ${otx_vkey_cborHex} != $(jq -r .cborHex "${TMP_DIR}"/tmp.vkey) ]]; then @@ -3568,9 +3584,9 @@ function main { # look for signing key in wallet folder while IFS= read -r -d '' w_file; do if [[ ${w_file} = */"${WALLET_PAY_SK_FILENAME}" || ${w_file} = */"${WALLET_STAKE_SK_FILENAME}" ]]; then - ! ${CCLI} key verification-key --signing-key-file "${w_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue + ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${w_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue if [[ $(jq -er '.type' "${w_file}" 2>/dev/null) = *"Extended"* ]]; then - ! ${CCLI} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey" && continue + ! ${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey" && continue mv -f "${TMP_DIR}/tmp2.vkey" "${TMP_DIR}/tmp.vkey" fi grep -q "${otx_vkey_cborHex}" "${TMP_DIR}"/tmp.vkey && skey_path="${w_file}" && break @@ -3581,7 +3597,7 @@ function main { # look for cold signing key in pool folder if [[ -z ${skey_path} ]]; then while IFS= read -r -d '' p_file; do - ! ${CCLI} key verification-key --signing-key-file "${p_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue + ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${p_file}" --verification-key-file "${TMP_DIR}"/tmp.vkey && continue grep -q "${otx_vkey_cborHex}" "${TMP_DIR}"/tmp.vkey && skey_path="${p_file}" && break done < <(find "${POOL_FOLDER}" -mindepth 2 -maxdepth 2 -type f -name "${POOL_COLDKEY_SK_FILENAME}" -print0 2>/dev/null) fi @@ -3615,11 +3631,11 @@ function main { waitForInput && continue 2 fi else - println ACTION "${CCLI} key verification-key --signing-key-file ${file} --verification-key-file ${TMP_DIR}/tmp.vkey" - if ! ${CCLI} key verification-key --signing-key-file "${file}" --verification-key-file "${TMP_DIR}"/tmp.vkey; then waitForInput && continue 2; fi + println ACTION "${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file ${file} --verification-key-file ${TMP_DIR}/tmp.vkey" + if ! ${CCLI} ${NETWORK_ERA} key verification-key --signing-key-file "${file}" --verification-key-file "${TMP_DIR}"/tmp.vkey; then waitForInput && continue 2; fi if [[ $(jq -r '.type' "${file}") = *"Extended"* ]]; then - println ACTION "${CCLI} key non-extended-key --extended-verification-key-file ${TMP_DIR}/tmp.vkey --verification-key-file ${TMP_DIR}/tmp2.vkey" - if ! ${CCLI} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey"; then waitForInput && continue 2; fi + println ACTION "${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file ${TMP_DIR}/tmp.vkey --verification-key-file ${TMP_DIR}/tmp2.vkey" + if ! ${CCLI} ${NETWORK_ERA} key non-extended-key --extended-verification-key-file "${TMP_DIR}/tmp.vkey" --verification-key-file "${TMP_DIR}/tmp2.vkey"; then waitForInput && continue 2; fi mv -f "${TMP_DIR}/tmp2.vkey" "${TMP_DIR}/tmp.vkey" fi if [[ ${otx_vkey_cborHex} != $(jq -r .cborHex "${TMP_DIR}"/tmp.vkey) ]]; then @@ -4415,12 +4431,12 @@ function main { println " Choose another name or delete the existing one" waitForInput && continue fi - println ACTION "${CCLI} address key-gen --verification-key-file ${policy_vk_file} --signing-key-file ${policy_sk_file}" - if ! ${CCLI} address key-gen --verification-key-file "${policy_vk_file}" --signing-key-file "${policy_sk_file}"; then + println ACTION "${CCLI} ${NETWORK_ERA} address key-gen --verification-key-file ${policy_vk_file} --signing-key-file ${policy_sk_file}" + if ! ${CCLI} ${NETWORK_ERA} address key-gen --verification-key-file "${policy_vk_file}" --signing-key-file "${policy_sk_file}"; then println ERROR "${FG_RED}ERROR${NC}: failure during policy key creation!"; safeDel "${policy_folder}"; waitForInput && continue fi - println ACTION "${CCLI} address key-hash --payment-verification-key-file ${policy_vk_file}" - if ! policy_key_hash=$(${CCLI} address key-hash --payment-verification-key-file "${policy_vk_file}"); then + println ACTION "${CCLI} ${NETWORK_ERA} address key-hash --payment-verification-key-file ${policy_vk_file}" + if ! policy_key_hash=$(${CCLI} ${NETWORK_ERA} address key-hash --payment-verification-key-file "${policy_vk_file}"); then println ERROR "${FG_RED}ERROR${NC}: failure during policy verification key hashing!"; safeDel "${policy_folder}"; waitForInput && continue fi println DEBUG "How long do you want the policy to be valid? (0/blank=unlimited)" @@ -4437,8 +4453,8 @@ function main { ttl=$(( $(getSlotTipRef) + (ttl_enter/SLOT_LENGTH) )) echo "{ \"type\": \"all\", \"scripts\": [ { \"slot\": ${ttl}, \"type\": \"before\" }, { \"keyHash\": \"${policy_key_hash}\", \"type\": \"sig\" } ] }" > "${policy_script_file}" fi - println ACTION "${CCLI} transaction policyid --script-file ${policy_script_file}" - if ! policy_id=$(${CCLI} transaction policyid --script-file "${policy_script_file}"); then + println ACTION "${CCLI} ${NETWORK_ERA} transaction policyid --script-file ${policy_script_file}" + if ! policy_id=$(${CCLI} ${NETWORK_ERA} transaction policyid --script-file "${policy_script_file}"); then println ERROR "${FG_RED}ERROR${NC}: failure during policy ID generation!"; safeDel "${policy_folder}"; waitForInput && continue fi echo "${policy_id}" > "${policy_id_file}" diff --git a/scripts/cnode-helper-scripts/dbsync.sh b/scripts/cnode-helper-scripts/dbsync.sh index db18ee067..60e2167f2 100755 --- a/scripts/cnode-helper-scripts/dbsync.sh +++ b/scripts/cnode-helper-scripts/dbsync.sh @@ -66,11 +66,11 @@ check_config_sanity() { [[ "${DBSYNC_CONSUMED_TX_OUT}" != "N" ]] && versionCheck 13.1.1.3 ${DBSYNC_VERSION} && DBSYNC_ARGS=" --consumed-tx-out" BYGENHASH=$("${CCLI}" byron genesis print-genesis-hash --genesis-json "${BYRON_GENESIS_JSON}" 2>/dev/null) BYGENHASHCFG=$(jq '.ByronGenesisHash' <"${CONFIG}" 2>/dev/null) - SHGENHASH=$("${CCLI}" genesis hash --genesis "${GENESIS_JSON}" 2>/dev/null) + SHGENHASH=$("${CCLI}" ${NETWORK_ERA} genesis hash --genesis "${GENESIS_JSON}" 2>/dev/null) SHGENHASHCFG=$(jq '.ShelleyGenesisHash' <"${CONFIG}" 2>/dev/null) - ALGENHASH=$("${CCLI}" genesis hash --genesis "${ALONZO_GENESIS_JSON}" 2>/dev/null) + ALGENHASH=$("${CCLI}" ${NETWORK_ERA} genesis hash --genesis "${ALONZO_GENESIS_JSON}" 2>/dev/null) ALGENHASHCFG=$(jq '.AlonzoGenesisHash' <"${CONFIG}" 2>/dev/null) - CWGENHASH=$("${CCLI}" genesis hash --genesis "${CONWAY_GENESIS_JSON}" 2>/dev/null) + CWGENHASH=$("${CCLI}" ${NETWORK_ERA} genesis hash --genesis "${CONWAY_GENESIS_JSON}" 2>/dev/null) CWGENHASHCFG=$(jq '.ConwayGenesisHash' <"${CONFIG}" 2>/dev/null) # If hash are missing/do not match, add that to the end of config. We could have sorted it based on logic, but that would mess up sdiff comparison outputs if [[ "${BYGENHASH}" != "${BYGENHASHCFG}" ]] || [[ "${SHGENHASH}" != "${SHGENHASHCFG}" ]] || [[ "${ALGENHASH}" != "${ALGENHASHCFG}" ]] || [[ "${CWGENHASH}" != "${CWGENHASHCFG}" ]]; then diff --git a/scripts/cnode-helper-scripts/env b/scripts/cnode-helper-scripts/env index 022802ea6..d19380011 100644 --- a/scripts/cnode-helper-scripts/env +++ b/scripts/cnode-helper-scripts/env @@ -78,9 +78,12 @@ #ASSET_POLICY_SK_FILENAME="policy.skey" #ASSET_POLICY_SCRIPT_FILENAME="policy.script" # File extension '.script' mandatory #ASSET_POLICY_ID_FILENAME="policy.id" + #CIP0094_POLL_URL="https://raw.githubusercontent.com/cardano-foundation/CIP-0094-polls/main/networks/polls.json" # URL for polls to vote against -#MITHRIL_DOWNLOAD="N" # (Y|N) Download latest Mithril snapshot +#MITHRIL_DOWNLOAD="N" # (Y|N) Download latest Mithril snapshot + +#STRICT_VERSION_CHECK="Y" # (Y|N) Restrict operation to supported major.minor version leaving patch version open. If disabled, any version will be accepted (unsupported) ###################################### # Do NOT modify code below # @@ -102,10 +105,12 @@ is_dir() { # Description : Check higher of two versions # : $1=minimal_needed_version -# : $2=current_node_version -versionCheck() -{ - printf '%s\n%s' "${1//v/}" "${2//v/}" | sort -C -V +# : $2=current_version +versionCheck() { + [[ ${STRICT_VERSION_CHECK} = N ]] && return 0 + w_ver=${1//v/}; w_ver_dots=${w_ver//[^.]}; [[ ${#w_ver_dots} -gt 1 && ${w_ver} =~ ^([0-9]+.[0-9]) ]] && w_ver=${BASH_REMATCH[1]} + c_ver=${2//v/}; c_ver_dots=${c_ver//[^.]}; [[ ${#c_ver_dots} -gt 1 && ${c_ver} =~ ^([0-9]+.[0-9]) ]] && c_ver=${BASH_REMATCH[1]} + printf '%s\n%s' "${w_ver}" "${c_ver}" | sort -C -V } # Description : Exit with error message @@ -443,6 +448,7 @@ getPassword() { fi done } + readPassword() { read_password="" prompt="$1: " @@ -567,7 +573,7 @@ getNodeMetrics() { [[ ${node_metrics} =~ cardano_node_metrics_RTS_gcMajorNum_int[[:space:]]([^[:space:]]*) ]] && gc_major=${BASH_REMATCH[1]} || gc_major=0 [[ ${node_metrics} =~ cardano_node_metrics_forks_int[[:space:]]([^[:space:]]*) ]] && forks=${BASH_REMATCH[1]} || forks=0 [[ ${node_metrics} =~ cardano_node_metrics_blockfetchclient_blockdelay_s[[:space:]]([^[:space:]]*) ]] && block_delay=${BASH_REMATCH[1]} || block_delay=0 - [[ ${node_metrics} =~ cardano_node_metrics_served_block_count_int[[:space:]]([^[:space:]]*) ]] && blocks_served=${BASH_REMATCH[1]} || block_served=0 + [[ ${node_metrics} =~ cardano_node_metrics_served_block_count_int[[:space:]]([^[:space:]]*) ]] && blocks_served=${BASH_REMATCH[1]} || blocks_served=0 [[ ${node_metrics} =~ cardano_node_metrics_blockfetchclient_lateblocks[[:space:]]([^[:space:]]*) ]] && blocks_late=${BASH_REMATCH[1]} || blocks_late=0 [[ ${node_metrics} =~ cardano_node_metrics_blockfetchclient_blockdelay_cdfOne[[:space:]]([^[:space:]]*) ]] && printf -v blocks_w1s "%.6f" ${BASH_REMATCH[1]} || blocks_w1s=0 [[ ${node_metrics} =~ cardano_node_metrics_blockfetchclient_blockdelay_cdfThree[[:space:]]([^[:space:]]*) ]] && printf -v blocks_w3s "%.6f" ${BASH_REMATCH[1]} || blocks_w3s=0 @@ -726,10 +732,10 @@ getPoolID() { pool_id_bech32="" pool_coldkey_vk_file="${pool_dir}/${POOL_COLDKEY_VK_FILENAME}" if [[ -f ${pool_coldkey_vk_file} ]]; then - println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file} --output-format hex" - println ACTION "${CCLI} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file}" - if ! pool_id=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" --output-format hex 2>/dev/null) || \ - ! pool_id_bech32=$(${CCLI} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" 2>/dev/null); then + [[ $(type -t println) = function ]] && println ACTION "${CCLI} ${NETWORK_ERA} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file} --output-format hex" + [[ $(type -t println) = function ]] && println ACTION "${CCLI} ${NETWORK_ERA} stake-pool id --cold-verification-key-file ${pool_coldkey_vk_file}" + if ! pool_id=$(${CCLI} ${NETWORK_ERA} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" --output-format hex 2>/dev/null) || \ + ! pool_id_bech32=$(${CCLI} ${NETWORK_ERA} stake-pool id --cold-verification-key-file "${pool_coldkey_vk_file}" 2>/dev/null); then return 1 fi echo ${pool_id} > "${pool_id_file}" @@ -741,25 +747,16 @@ getPoolID() { # Description : Calculate expected interval between blocks slotInterval() { - if [[ -z ${DECENTRALISATION} || $(echo "${DECENTRALISATION} < 0.5" | bc) -eq 1 ]]; then d=0.5; else d=${DECENTRALISATION}; fi - echo "(${SLOT_LENGTH} / ${ACTIVE_SLOTS_COEFF} / ${d}) + 0.5" | bc -l | awk '{printf "%.0f\n", $1}' + echo "(${SLOT_LENGTH} / ${ACTIVE_SLOTS_COEFF}) + 0.5" | bc -l | awk '{printf "%.0f\n", $1}' } -# Description : Identify current era and set variables accordingly -# TODO: Track progress of https://github.com/intersectmbo/cardano-node/pull/4135 to see if era identifier can be removed in a future release. -getEraIdentifier() { - NETWORK_ERA=$(${CCLI} query tip ${NETWORK_IDENTIFIER} 2>/dev/null | jq -r '.era //empty') - case ${NETWORK_ERA} in - Byron) ERA_IDENTIFIER="--byron-era" ;; - Shelley) ERA_IDENTIFIER="--shelley-era" ;; - Allegra) ERA_IDENTIFIER="--allegra-era" ;; - Mary) ERA_IDENTIFIER="--mary-era" ;; - Alonzo) ERA_IDENTIFIER="--alonzo-era" ;; - Babbage) ERA_IDENTIFIER="--babbage-era" ;; - *) ERA_IDENTIFIER="--babbage-era" - [[ ${OFFLINE_MODE} = "N" ]] && return 1 - esac - return 0 +getProtocolParams() { + PROT_PARAMS="$(${CCLI} ${NETWORK_ERA} query protocol-parameters ${NETWORK_IDENTIFIER} 2>/dev/null)" + read -ra PROT_PARAMS_VERSION <<<"$(jq -r '[ .protocolVersion.major //0, .protocolVersion.minor //0]| @tsv' <<<"${PROT_PARAMS}" 2>/dev/null)" + PROT_MAJOR=${PROT_PARAMS_VERSION[0]} + PROT_MINOR=${PROT_PARAMS_VERSION[1]} + PROT_VERSION="${PROT_MAJOR}.${PROT_MINOR}" + [[ ${PROT_MAJOR} -eq 0 ]] && return 1 || return 0 } telegramSend() { @@ -840,6 +837,7 @@ set_default_vars() { [[ -z ${ASSET_POLICY_ID_FILENAME} ]] && ASSET_POLICY_ID_FILENAME="policy.id" [[ -z ${CIP0094_POLL_URL} ]] && CIP0094_POLL_URL="https://raw.githubusercontent.com/cardano-foundation/CIP-0094-polls/main/networks/polls.json" [[ -z ${MITHRIL_DOWNLOAD} ]] && MITHRIL_DOWNLOAD="N" + [[ -z ${STRICT_VERSION_CHECK} ]] && STRICT_VERSION_CHECK="Y" FG_BLACK='\e[30m' FG_RED='\e[31m' FG_GREEN='\e[32m' @@ -856,6 +854,27 @@ set_default_vars() { NC='\e[0m' } +read_genesis() { + read -ra SHGENESIS <<< "$(jq -r '[ .networkMagic, .systemStart, .epochLength, .slotLength, .activeSlotsCoeff, .slotsPerKESPeriod, .maxKESEvolutions ] |@tsv' < ${GENESIS_JSON})" + read -ra BYGENESIS <<< "$(jq -r '[ .startTime, .protocolConsts.k, .blockVersionData.slotDuration ] |@tsv' < ${BYRON_GENESIS_JSON})" + NWMAGIC=${SHGENESIS[0]} + SHELLEY_GENESIS_START_SEC=$(date --date="${SHGENESIS[1]}" +%s) + EPOCH_LENGTH=${SHGENESIS[2]} + SLOT_LENGTH=${SHGENESIS[3]} + ACTIVE_SLOTS_COEFF=${SHGENESIS[4]} + SLOTS_PER_KES_PERIOD=${SHGENESIS[5]} + MAX_KES_EVOLUTIONS=${SHGENESIS[6]} + BYRON_GENESIS_START_SEC=${BYGENESIS[0]} + BYRON_K=${BYGENESIS[1]} + BYRON_SLOT_LENGTH=${BYGENESIS[2]} + BYRON_EPOCH_LENGTH=$(( 10 * BYRON_K )) +} + +test_koios() { + # make sure KOIOS_API is reachable, else fall back to cli + [[ ${ENABLE_KOIOS} = 'Y' && -n ${KOIOS_API} && $(curl -sfk -o /dev/null -w "%{http_code}" -m 5 ${KOIOS_API}/tip | awk '{print $1}') = "200" ]] || unset KOIOS_API +} + [[ ${0} != '-bash' ]] && PARENT=$(dirname $0) || PARENT="$(pwd)" # If sourcing at terminal, $0 would be "-bash" , which is invalid. Thus, fallback to present working directory # Initialise/Set offline mode prior to calling functions OFFLINE_MODE='N' @@ -892,6 +911,13 @@ if [[ -z "${CNCLI}" ]]; then CNCLI=$(command -v cncli) || CNCLI="${HOME}/.local/bin/cncli" fi +node_version="$(${CNODEBIN} version | head -1 | cut -d' ' -f2)" +cli_version="$(${CCLI} version | head -1 | cut -d' ' -f2)" +if ! versionCheck "8.7.3" "${node_version}" || ! versionCheck "8.17.0.0" "${cli_version}"; then + echo -e "\nKoios scripts have now been upgraded to support cardano-node 8.7.x ('${node_version}' found) / cardano-cli 8.17.x.x ('${cli_version}' found).\nPlease update cardano-node binaries (ensure to read release notes and update various configs using guild-deploy (use appropriate options to download/install/overwrite parts you need) or use tagged branches for older node version (eg: ./