Last active
November 8, 2019 03:43
-
-
Save ssainball/96dd2340e43664d48b5d917869be27dd to your computer and use it in GitHub Desktop.
test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Env : ubuntu 16.04] | |
sudo su root | |
cd ~ | |
jcli key generate --type=Ed25519Extended > receiver_secret.key | |
cat receiver_secret.key | jcli key to-public > receiver_public.key | |
jcli address account --testing $(cat receiver_public.key) | tee receiver_account.txt | |
ACCOUNT_SK=$(cat receiver_secret.key) | |
ACCOUNT_PK=$(cat receiver_public.key) | |
ACCOUNT_ADDR=$(cat receiver_account.txt) | |
// Generating VRF Key Pairs Used to Elect Leaders | |
POOL_VRF_SK=$(jcli key generate --type=Curve25519_2HashDH) | |
POOL_VRF_PK=$(echo ${POOL_VRF_SK} | jcli key to-public) | |
echo ${POOL_VRF_PK} | |
// Generate KES key pair used for block signing | |
POOL_KES_SK=$(jcli key generate --type=SumEd25519_12) | |
POOL_KES_PK=$(echo ${POOL_KES_SK} | jcli key to-public) | |
echo ${POOL_KES_PK} | |
// Generate a stake_pool.cert Certificate | |
jcli certificate new stake-pool-registration \ | |
--kes-key ${POOL_KES_PK} \ | |
--vrf-key ${POOL_VRF_PK} \ | |
--owner ${ACCOUNT_PK} \ | |
--start-validity 0 \ | |
--management-threshold 1 \ | |
--serial 1010101010 > stake_pool.cert | |
cat stake_pool.cert | |
// Sign the certificate using the account private key | |
STAKE_KEY=${ACCOUNT_SK} | |
echo ${STAKE_KEY} > stake_key.sk | |
cat stake_pool.cert | jcli certificate sign stake_key.sk > stake_pool.signcert | |
cat stake_pool.signcert | |
// Extract stake_pool.id from certificate | |
cat stake_pool.cert | jcli certificate get-stake-pool-id | tee stake_pool.id | |
CERTIFICATE_PATH=$HOME/stake_pool.signcert | |
REST_PORT=3101 | |
REST_URL="http://127.0.0.1:${REST_PORT}/api" | |
// Constant fee | |
FEE_CONSTANT=$(jcli rest v0 settings get -h "${REST_URL}" | grep 'constant:' | sed -e 's/^[[:space:]]*//' | sed -e 's/constant: //') | |
// Coefficient fee | |
FEE_COEFFICIENT=$(jcli rest v0 settings get -h "${REST_URL}" | grep 'coefficient:' | sed -e 's/^[[:space:]]*//' | sed -e 's/coefficient: //') | |
// Certificate fee | |
FEE_CERTIFICATE=$(jcli rest v0 settings get -h "${REST_URL}" | grep 'certificate:' | sed -e 's/^[[:space:]]*//' | sed -e 's/certificate: //') | |
BLOCK0_HASH=$(jcli rest v0 settings get -h "${REST_URL}" | grep 'block0Hash:' | sed -e 's/^[[:space:]]*//' | sed -e 's/block0Hash: //') | |
ACCOUNT_COUNTER=$(jcli rest v0 account get "${ACCOUNT_ADDR}" -h "${REST_URL}" | grep '^counter:' | sed -e 's/counter: //') | |
ACCOUNT_AMOUNT=$((${FEE_CONSTANT} + ${FEE_COEFFICIENT} + ${FEE_CERTIFICATE})) | |
STAGING_FILE="staging.$$.transaction" | |
jcli transaction new --staging ${STAGING_FILE} | |
jcli transaction add-account "${ACCOUNT_ADDR}" "${ACCOUNT_AMOUNT}" --staging "${STAGING_FILE}" | |
jcli transaction add-certificate --staging ${STAGING_FILE} $(cat ${CERTIFICATE_PATH}) | |
jcli transaction finalize --staging ${STAGING_FILE} | |
TRANSACTION_ID=$(jcli transaction id --staging ${STAGING_FILE}) | |
==== Display output ==== | |
1341939289a358fd095eca09b02071ac22539bc72500995f61a682f09a0dee11 | |
==================== | |
WITNESS_SECRET_FILE="witness.secret.$$" | |
WITNESS_OUTPUT_FILE="witness.out.$$" | |
// Signature using account private key | |
printf "${ACCOUNT_SK}" > ${WITNESS_SECRET_FILE} | |
jcli transaction make-witness ${TRANSACTION_ID} \ | |
--genesis-block-hash ${BLOCK0_HASH} \ | |
--type "account" --account-spending-counter "${ACCOUNT_COUNTER}" \ | |
${WITNESS_OUTPUT_FILE} ${WITNESS_SECRET_FILE} | |
// Sign the staging file | |
jcli transaction add-witness ${WITNESS_OUTPUT_FILE} --staging "${STAGING_FILE}" | |
jcli transaction info --fee-constant ${FEE_CONSTANT} --fee-coefficient ${FEE_COEFFICIENT} --fee-certificate ${FEE_CERTIFICATE} --staging "${STAGING_FILE}" | |
==== Display output ==== | |
Transaction `1341939289a358fd095eca09b02071ac22539bc72500995f61a682f09a0dee11' (finalizing) | |
Input: 11050 | |
Output: 0 | |
Fees: 11050 | |
Balance: 0 | |
e9ea405277603593ec8ea54b05f473864d9d068affb97bfddf958e3c125cffe0 11050 | |
======================== | |
// Seal the staging file, transfer the staging file to the node | |
jcli transaction seal --staging "${STAGING_FILE}" | |
jcli transaction to-message --staging "${STAGING_FILE}" | jcli rest v0 message post -h "${REST_URL}" | |
==== Display output ==== | |
-- 902f0d0fc76cde515bf0773b2be921bc8d593ced4b00bca2ae55e13626ee7ebc | |
======================== | |
rm ${STAGING_FILE} ${WITNESS_SECRET_FILE} ${WITNESS_OUTPUT_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment