Skip to content

Commit

Permalink
Merge pull request #13 from dorin100/master
Browse files Browse the repository at this point in the history
added per_certificate_fees
  • Loading branch information
dkijania authored Dec 14, 2019
2 parents e6f57d4 + 3b98196 commit 2c0b690
Show file tree
Hide file tree
Showing 5 changed files with 448 additions and 33 deletions.
27 changes: 10 additions & 17 deletions scripts/createStakePool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,32 @@ CLI="./jcli"
COLORS=1
ADDRTYPE="--testing"

if [ $# -ne 5 ]; then
echo "usage: $0 <REST-LISTEN-PORT> <TAX_VALUE> <TAX_RATIO> <TAX_LIMIT> <ACCOUNT_SK>"
if [ $# -ne 4 ]; then
echo "usage: $0 <REST-LISTEN-PORT> <TAX_VALUE> <TAX_RATIO> <ACCOUNT_SK>"
echo " <REST-LISTEN-PORT> The REST Listen Port set in node-config.yaml file (EX: 3101)"
echo " <TAX_VALUE> The fixed cut the stake pool will take from the total reward"
echo " <TAX_RATIO> The percentage of the remaining value that will be taken from the total"
echo " <TAX_LIMIT> A value that can be set to limit the pool's Tax."
echo " <TAX_RATIO> The percentage of the remaining value that will be taken from the total (EX: '1/10')"
echo " <SOURCE-SK> The Secret key of the Source address"
exit 1
fi

REST_PORT="$1"
TAX_VALUE="$2"
TAX_RATIO="$3"
TAX_LIMIT="$4"
ACCOUNT_SK="$5"
ACCOUNT_SK="$4"

REST_URL="http://127.0.0.1:${REST_PORT}/api"
BLOCK0_HASH=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'block0Hash:' | sed -e 's/^[[:space:]]*//' | sed -e 's/block0Hash: //')
FEE_CONSTANT=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'constant:' | sed -e 's/^[[:space:]]*//' | sed -e 's/constant: //')
FEE_COEFFICIENT=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'coefficient:' | sed -e 's/^[[:space:]]*//' | sed -e 's/coefficient: //')
FEE_CERTIFICATE=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'certificate:' | sed -e 's/^[[:space:]]*//' | sed -e 's/certificate: //')

ACCOUNT_PK=$(echo ${ACCOUNT_SK} | $CLI key to-public)
ACCOUNT_ADDR=$($CLI address account ${ADDRTYPE} ${ACCOUNT_PK})

echo "================ Blockchain details ================="
echo "REST_PORT: ${REST_PORT}"
echo "ACCOUNT_SK: ${ACCOUNT_SK}"
echo "BLOCK0_HASH: ${BLOCK0_HASH}"
echo "FEE_CONSTANT: ${FEE_CONSTANT}"
echo "FEE_COEFFICIENT: ${FEE_COEFFICIENT}"
echo "FEE_CERTIFICATE: ${FEE_CERTIFICATE}"
echo "BLOCK0_HASH: ${BLOCK0_HASH}"
echo "REST_PORT: ${REST_PORT}"
echo "TAX_VALUE: ${TAX_VALUE}"
echo "TAX_RATIO: ${TAX_RATIO}"
echo "ACCOUNT_SK: ${ACCOUNT_SK}"
echo "=================================================="

echo " ##1. Create VRF keys"
Expand All @@ -73,7 +67,7 @@ STAKE_POOL_CERTIFICATE_FILE="stake_pool.cert"
SIGNED_STAKE_POOL_CERTIFICATE_FILE="stake_pool_certificate.signed"
echo ${ACCOUNT_SK} > ${ACCOUNT_SK_FILE}

$CLI certificate new stake-pool-registration --tax-fixed ${TAX_VALUE} --tax-ratio ${TAX_RATIO} --tax-limit ${TAX_LIMIT} --kes-key ${POOL_KES_PK} --vrf-key ${POOL_VRF_PK} --owner ${ACCOUNT_PK} --start-validity 0 --management-threshold 1 >${STAKE_POOL_CERTIFICATE_FILE}
$CLI certificate new stake-pool-registration --tax-fixed ${TAX_VALUE} --tax-ratio ${TAX_RATIO} --kes-key ${POOL_KES_PK} --vrf-key ${POOL_VRF_PK} --owner ${ACCOUNT_PK} --start-validity 0 --management-threshold 1 >${STAKE_POOL_CERTIFICATE_FILE}

echo " Sign the Stake Pool certificate"
$CLI certificate sign \
Expand All @@ -96,7 +90,6 @@ echo "Stake Pool ID: ${NODE_ID}"
echo "Stake Pool owner: ${ACCOUNT_ADDR}"
echo "TAX_VALUE: ${TAX_VALUE}"
echo "TAX_RATIO: ${TAX_RATIO}"
echo "TAX_LIMIT: ${TAX_LIMIT}"
echo "=================================================="

rm ${STAKE_POOL_CERTIFICATE_FILE} ${ACCOUNT_SK_FILE} ${SIGNED_STAKE_POOL_CERTIFICATE_FILE}
Expand Down
13 changes: 9 additions & 4 deletions scripts/delegate-account.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ BLOCK0_HASH=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'block0Hash:' |
FEE_CONSTANT=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'constant:' | sed -e 's/^[[:space:]]*//' | sed -e 's/constant: //')
FEE_COEFFICIENT=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'coefficient:' | sed -e 's/^[[:space:]]*//' | sed -e 's/coefficient: //')
FEE_CERTIFICATE=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'certificate:' | sed -e 's/^[[:space:]]*//' | sed -e 's/certificate: //')
MAX_TXS_PER_BLOCK=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'maxTxsPerBlock:' | sed -e 's/^[[:space:]]*//' | sed -e 's/maxTxsPerBlock: //')
FEE_CERTIFICATE_POOL_REGISTRATION=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'certificate_pool_registration:' | sed -e 's/^[[:space:]]*//' | sed -e 's/certificate_pool_registration: //')
FEE_CERTIFICATE_STAKE_DELEGATION=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'certificate_stake_delegation:' | sed -e 's/^[[:space:]]*//' | sed -e 's/certificate_stake_delegation: //')
SLOT_DURATION=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'slotDuration:' | sed -e 's/^[[:space:]]*//' | sed -e 's/slotDuration: //')
SLOTS_PER_EPOCH=$($CLI rest v0 settings get -h "${REST_URL}" | grep 'slotsPerEpoch:' | sed -e 's/^[[:space:]]*//' | sed -e 's/slotsPerEpoch: //')

Expand All @@ -80,6 +81,8 @@ echo "BLOCK0_HASH: ${BLOCK0_HASH}"
echo "FEE_CONSTANT: ${FEE_CONSTANT}"
echo "FEE_COEFFICIENT: ${FEE_COEFFICIENT}"
echo "FEE_CERTIFICATE: ${FEE_CERTIFICATE}"
echo "FEE_CERTIFICATE_POOL_REGISTRATION: ${FEE_CERTIFICATE_POOL_REGISTRATION}"
echo "FEE_CERTIFICATE_STAKE_DELEGATION : ${FEE_CERTIFICATE_STAKE_DELEGATION}"
echo "=================================================="

STAGING_FILE="staging.$$.transaction"
Expand Down Expand Up @@ -112,7 +115,7 @@ $CLI certificate sign \
--output ${SIGNED_CERTIFICATE_FILE}

ACCOUNT_COUNTER=$( $CLI rest v0 account get "${ACCOUNT_ADDR}" -h "${REST_URL}" | grep '^counter:' | sed -e 's/counter: //' )
ACCOUNT_AMOUNT=$((${FEE_CONSTANT} + ${FEE_COEFFICIENT} + ${FEE_CERTIFICATE}))
ACCOUNT_AMOUNT=$((${FEE_CONSTANT} + ${FEE_COEFFICIENT} + ${FEE_CERTIFICATE_STAKE_DELEGATION}))

echo " ##2. Create the offline delegation transaction for the Account address"
$CLI transaction new --staging ${STAGING_FILE}
Expand All @@ -128,14 +131,14 @@ echo " ##5. Finalize the transaction"
$CLI transaction finalize --staging ${STAGING_FILE}

# get the transaction data-for-witness
TRANSACTION_ID=$($CLI transaction data-for-witness --staging ${STAGING_FILE})
TRANSACTION_DATA_FOR_WITNESS=$($CLI transaction data-for-witness --staging ${STAGING_FILE})

echo " ##6. Create the withness"
WITNESS_SECRET_FILE="witness.secret.$$"
WITNESS_OUTPUT_FILE="witness.out.$$"
printf "${ACCOUNT_SK}" > ${WITNESS_SECRET_FILE}

$CLI transaction make-witness ${TRANSACTION_ID} \
$CLI transaction make-witness ${TRANSACTION_DATA_FOR_WITNESS} \
--genesis-block-hash ${BLOCK0_HASH} \
--type "account" --account-spending-counter "${ACCOUNT_COUNTER}" \
${WITNESS_OUTPUT_FILE} ${WITNESS_SECRET_FILE}
Expand All @@ -157,7 +160,9 @@ $CLI transaction to-message --staging "${STAGING_FILE}" | $CLI rest v0 message p

waitNewBlockCreated

echo "=================================================="
echo " Account delegation signed certificate: $(cat ${SIGNED_CERTIFICATE_FILE})"
echo "=================================================="

echo " ##10. Check the account's delegation status"
$CLI rest v0 account get ${ACCOUNT_ADDR} -h ${REST_URL}
Expand Down
Loading

0 comments on commit 2c0b690

Please sign in to comment.