diff --git a/README.md b/README.md index 97d7808..42ad77a 100644 --- a/README.md +++ b/README.md @@ -257,33 +257,77 @@ Commands: Get the Stats(burned amount and percent, boosted amount and percent, rewarded amount and percent in epoch ) of QEarn SC [QVAULT COMMANDS] - -qvaultsubmitauthaddress - Submit the new authaddress using multisig address. - -qvaultchangeauthaddress - Change the authaddress using multisig address. is the one of (1, 2, 3). - -qvaultsubmitfees - Submit the new permilles for QcapHolders, Reinvesting, Development using multisig address. the sum of 3 permilles should be 970 because the permille of shareHolder is 30. - -qvaultchangefees - Change the permilles for QcapHolders, Reinvesting, Development using multisig address. the sum of 3 permilles should be 970 because the permille of shareHolder is 30. Get the locked amount that the user locked in the epoch . - -qvaultsubmitreinvestingaddress - Submit the new reinvesting address using multisig address. - -qvaultchangereinvestingaddress - Change the address using multisig address. should be already submitted by -qvaultsubmitreinvestingaddress command. - -qvaultsubmitadminaddress - Submit the admin address using multisig address. - -qvaultchangeadminaddress - Change the admin address using multisig address. should be already submitted by -qvaultsubmitadminaddress command. + -qvaultstake + Stake the Qcap with amount + -qvaultunstake + Unstake the Qcap with amount + -qvaultsubmitgeneralproposal + Submit the general proposal can be a website or github url. the max number of letters is 255. + -qvaultsubmitquorumchangeproposal + Submit the quorum change proposal with new permille for quorum. it should be permille(0 ~ 1000) for sure. not percent + -qvaultsubmitipoproposal + Submit the ipo proposal with + -qvaultsubmitqearnproposal + Submit the qearn proposal with + - the amount per epoch, - the number of epoches for locking + -qvaultsubmitfundproposal + Submit the fund proposal with + - the amount of Qubic for one Qcap, - the amount of Qcap for sale + -qvaultsubmitmarketplaceproposal + Submit the marketplace proposal with + - the amount of qubic received from the SC, - the name of asset that want to sell to the SC + - the amount of qcap received from the SC, - the contract index that want to sell the share to the SC, - the amount of share that want to sell to the SC + -qvaultsubmitpercentallocationproposal + Submit the allocation proposal with + - reinvesting permille, - team permille, - Qcap burn permille, - distribute permille for Qcap holders + -qvaultvoteinproposal + Vote in the proposal with + - if you want to vote in the ipo proposal, you need to input the exact price for ipo, it should be more than 1B + - the type of proposal, - the index of proposal, - yes = 1, no = 0 + -qvaultbuyqcap + Buy the qcap. - the amount of Qcap that want to buy, - the price of Qcap for one Qcap + -qvaulttransfersharemanagementrights + Transfer the share management right to the -qvaultgetdata - Get the state data of smart contract. anyone can check the changes after using the any command. - -qvaultsubmitbannedaddress - Submit the banned address using multisig address. - -qvaultsavebannedaddress - Save the banned address using multisig address. should be already submitted by -qvaultsubmitbannedaddress command. - -qvaultsubmitunbannedaddress - Submit the unbanned address using multisig address. - -qvaultsaveunbannedaddress - Unban the using the multisig address. should be already submitted by -qvaultsaveunbannedaddress command. - + Getting the state variables from the SC + -qvaultgetstakedamountandvotingpower + Getting the staked amount and voting power of from the SC + -qvaultgetgeneralproposal + Getting the general proposal info of proposal + -qvaultgetquorumchangeproposal + Getting the quorum change proposal info of proposal + -qvaultgetipoproposal + Getting the ipo proposal info of proposal + -qvaultgetqearnproposal + Getting the qearn proposal info of proposal + -qvaultgetfundproposal + Getting the fund proposal info of proposal + -qvaultgetmarketplaceproposal + Getting the marketplace proposal info of proposal + -qvaultgetallocationproposal + Getting the allocation proposal info of proposal + -qvaultgetidentitieshavingvotingpower + Getting the identities having the voting power + - the point to read, - the number of fetching + -qvaultgetproposalcreationpower + Checking if the has the proposal creation power + -qvaultgetqcapburntamountinlastepoches + Getting the burnt qcap amount in the last epoches + -qvaultgetamounttobesoldperyear + Getting the amount to be sold per year + -qvaultgettotalrevenueinqcap + Getting the total revenue in Qcap + -qvaultgetrevenueinqcapperepoch + Getting the revenue for Qcap in epoch + -qvaultgetrevenuepershare + Getting the revenue in share + -qvaultgetamountofshareqvaulthold + Getting the amount of share the SC hold + -qvaultgetnumberofholderandaverageamount + Getting the number of Qcap holder and average amount + -qvaultgetamountforqearninupcomingepoch + Getting the amount that should be locked in Qearn SC in the + [MSVAULT COMMANDS] -msvaultregistervault Register a vault. Vault's number of votes for proposal approval , vault name (max 32 chars), and a list of owners (separated by commas). Fee applies. diff --git a/argparser.h b/argparser.h index cea5a28..74f85ef 100644 --- a/argparser.h +++ b/argparser.h @@ -4,9 +4,11 @@ #include #include #include +#include #include "global.h" #include "logger.h" +#include "global.h" #include "structs.h" #define CHECK_OVER_PARAMETERS \ @@ -277,33 +279,77 @@ void print_help() printf("\t\tGet the Stats(burned amount and percent, boosted amount and percent, rewarded amount and percent in epoch ) of QEarn SC\n"); printf("\n[QVAULT COMMANDS]\n"); - printf("\t-qvaultsubmitauthaddress \n"); - printf("\t\tSubmit the new authaddress using multisig address.\n"); - printf("\t-qvaultchangeauthaddress \n"); - printf("\t\tChange the authaddress using multisig address. is the one of (1, 2, 3).\n"); - printf("\t-qvaultsubmitfees \n"); - printf("\t\tSubmit the new permilles for QcapHolders, Reinvesting, Development using multisig address. the sum of 3 permilles should be 970 because the permille of shareHolder is 30.\n"); - printf("\t-qvaultchangefees \n"); - printf("\t\tChange the permilles for QcapHolders, Reinvesting, Development using multisig address. the sum of 3 permilles should be 970 because the permille of shareHolder is 30. Get the locked amount that the user locked in the epoch .\n"); - printf("\t-qvaultsubmitreinvestingaddress \n"); - printf("\t\tSubmit the new reinvesting address using multisig address.\n"); - printf("\t-qvaultchangereinvestingaddress \n"); - printf("\t\tChange the address using multisig address. should be already submitted by -qvaultsubmitreinvestingaddress command.\n"); - printf("\t-qvaultsubmitadminaddress \n"); - printf("\t\tSubmit the admin address using multisig address.\n"); - printf("\t-qvaultchangeadminaddress \n"); - printf("\t\tChange the admin address using multisig address. should be already submitted by -qvaultsubmitadminaddress command.\n"); - printf("\t-qvaultgetdata\n"); - printf("\t\tGet the state data of smart contract. anyone can check the changes after using the any command.\n"); - printf("\t-qvaultsubmitbannedaddress \n"); - printf("\t\tSubmit the banned address using multisig address.\n"); - printf("\t-qvaultsavebannedaddress \n"); - printf("\t\tSave the banned address using multisig address. should be already submitted by -qvaultsubmitbannedaddress command.\n"); - printf("\t-qvaultsubmitunbannedaddress \n"); - printf("\t\tSubmit the unbanned address using multisig address.\n"); - printf("\t-qvaultsaveunbannedaddress \n"); - printf("\t\tUnban the using the multisig address. should be already submitted by -qvaultsaveunbannedaddress command.\n"); - + printf("\t-qvaultstake \n"); + printf("\t\tStake the Qcap with amount\n"); + printf("\t-qvaultunstake \n"); + printf("\t\tUnstake the Qcap with amount\n"); + printf("\t-qvaultsubmitgeneralproposal \n"); + printf("\t\tSubmit the general proposal. can be a website or github url. the max number of letters is 255\n"); + printf("\t-qvaultsubmitquorumchangeproposal \n"); + printf("\t\tSubmit the quorum change proposal with new permille for quorum. it should be permille(0 ~ 1000) for sure. not percent\n"); + printf("\t-qvaultsubmitipoproposal \n"); + printf("\t\tSubmit the ipo proposal with \n"); + printf("\t-qvaultsubmitqearnproposal \n"); + printf("\t\tSubmit the qearn proposal with \n"); + printf("\t\t - the amount per epoch, - the number of epoches for locking\n"); + printf("\t-qvaultsubmitfundproposal \n"); + printf("\t\tSubmit the fund proposal with \n"); + printf("\t\t - the amount of Qubic for one Qcap, - the amount of Qcap for sale\n"); + printf("\t-qvaultsubmitmarketplaceproposal \n"); + printf("\t\tSubmit the marketplace proposal with \n"); + printf("\t\t - the amount of qubic received from the SC, - the share name (max 8 uppercase letters or digits)\n"); + printf("\t\t - the amount of qcap received from the SC, - the contract index that want to sell the share to the SC, - the amount of share that want to sell to the SC\n"); + printf("\t-qvaultsubmitpercentallocationproposal \n"); + printf("\t\tSubmit the allocation proposal with \n"); + printf("\t\t - reinvesting permille, - Qcap burn permille, - distribute permille for Qcap holders. All percentages must sum to 970 (per mille)\n"); + printf("\t-qvaultvoteinproposal \n"); + printf("\t\tVote in the proposal with \n"); + printf("\t\t - if you want to vote in the ipo proposal, you need to input the exact price for ipo, it should be more than 1B\n"); + printf("\t\t - the type of proposal, - the index of proposal, - yes = 1, no = 0\n"); + printf("\t-qvaultbuyqcap \n"); + printf("\t\tBuy the qcap. - the amount of Qcap that want to buy, - the price of Qcap for one Qcap\n"); + printf("\t-qvaulttransfersharemanagementrights \n"); + printf("\t\tTransfer the share management right to the \n"); + printf("\t-qvaultgetdata\n"); + printf("\t\tGetting the state variables from the SC\n"); + printf("\t-qvaultgetstakedamountandvotingpower \n"); + printf("\t\tGetting the staked amount and voting power of from the SC\n"); + printf("\t-qvaultgetgeneralproposal \n"); + printf("\t\tGetting the general proposal info of proposal\n"); + printf("\t-qvaultgetquorumchangeproposal \n"); + printf("\t\tGetting the quorum change proposal info of proposal\n"); + printf("\t-qvaultgetipoproposal \n"); + printf("\t\tGetting the ipo proposal info of proposal\n"); + printf("\t-qvaultgetqearnproposal \n"); + printf("\t\tGetting the qearn proposal info of proposal\n"); + printf("\t-qvaultgetfundproposal \n"); + printf("\t\tGetting the fund proposal info of proposal\n"); + printf("\t-qvaultgetmarketplaceproposal \n"); + printf("\t\tGetting the marketplace proposal info of proposal\n"); + printf("\t-qvaultgetallocationproposal \n"); + printf("\t\tGetting the allocation proposal info of proposal\n"); + printf("\t-qvaultgetidentitieshavingvotingpower \n"); + printf("\t\tGetting the identities having the voting power\n"); + printf("\t\t - the point to read, - the number of fetching\n"); + printf("\t-qvaultgetproposalcreationpower \n"); + printf("\t\tChecking if the has the proposal creation power\n"); + printf("\t-qvaultgetqcapburntamountinlastepoches \n"); + printf("\t\tGetting the burnt qcap amount in the last epoches\n"); + printf("\t-qvaultgetamounttobesoldperyear \n"); + printf("\t\tGetting the amount to be sold per year\n"); + printf("\t-qvaultgettotalrevenueinqcap\n"); + printf("\t\tGetting the total revenue in Qcap\n"); + printf("\t-qvaultgetrevenueinqcapperepoch \n"); + printf("\t\tGetting the revenue for Qcap in epoch\n"); + printf("\t-qvaultgetrevenuepershare \n"); + printf("\t\tGetting the revenue in share \n"); + printf("\t-qvaultgetamountofshareqvaulthold \n"); + printf("\t\tGetting the amount of share the SC hold\n"); + printf("\t-qvaultgetnumberofholderandaverageamount\n"); + printf("\t\tGetting the number of Qcap holder and average amount\n"); + printf("\t-qvaultgetamountforqearninupcomingepoch \n"); + printf("\t\tGetting the amount that should be locked in Qearn SC in the \n"); + printf("\n[MSVAULT COMMANDS]\n"); printf("\t-msvaultregistervault \n"); printf("\t\tRegister a vault. Vault's number of votes for proposal approval , vault name (max 32 chars), and a list of owners (separated by commas). Fee applies.\n"); @@ -1852,126 +1898,312 @@ void parseArgument(int argc, char** argv) CHECK_OVER_PARAMETERS break; } - if (strcmp(argv[i], "-qvaultsubmitauthaddress") == 0) + + + /************************** + ***** QVAULT COMMANDS ***** + **************************/ + + if (strcmp(argv[i], "-qvaultstake") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(1) + g_cmd = QVAULT_COMMAND_STAKE; + g_qvault_stake_amount = uint32_t(charToNumber(argv[i + 1])); + i += 2; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultunstake") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_SUBMIT_AUTH_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_UNSTAKE; + g_qvault_stake_amount = uint32_t(charToNumber(argv[i + 1])); i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultchangeauthaddress") == 0) + if (strcmp(argv[i], "-qvaultsubmitgeneralproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_CHANGE_AUTH_ADDRESS; - g_qvault_numberOfChangedAddress = uint32_t(charToNumber(argv[i + 1])); + g_cmd = QVAULT_COMMAND_SUBMIT_GP; + g_qvaulturl = argv[i + 1]; i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultsubmitfees") == 0) + if (strcmp(argv[i], "-qvaultsubmitquorumchangeproposal") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(2) + g_cmd = QVAULT_COMMAND_SUBMIT_QCP; + g_qvaulturl = argv[i + 1]; + g_qvault_permille = uint32_t(charToNumber(argv[i + 2])); + i += 3; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultsubmitipoproposal") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(2) + g_cmd = QVAULT_COMMAND_SUBMIT_IPOP; + g_qvaulturl = argv[i + 1]; + g_qvault_ipo_contract_index = uint32_t(charToNumber(argv[i + 2])); + i += 3; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultsubmitqearnproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(3) - g_cmd = QVAULT_SUBMIT_FEES; - g_qvault_newQCAPHolderFee = uint32_t(charToNumber(argv[i + 1])); - g_qvault_newReinvestingFee = uint32_t(charToNumber(argv[i + 2])); - g_qvault_newDevFee = uint32_t(charToNumber(argv[i + 3])); + g_cmd = QVAULT_COMMAND_SUBMIT_QEARNP; + g_qvaulturl = argv[i + 1]; + g_qvault_amount_of_qubic = uint64_t(charToNumber(argv[i + 2])); + g_qvault_number_of_epoch = uint32_t(charToNumber(argv[i + 3])); i += 4; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultchangefees") == 0) + if (strcmp(argv[i], "-qvaultsubmitfundproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(3) - g_cmd = QVAULT_CHANGE_FEES; - g_qvault_newQCAPHolderFee = uint32_t(charToNumber(argv[i + 1])); - g_qvault_newReinvestingFee = uint32_t(charToNumber(argv[i + 2])); - g_qvault_newDevFee = uint32_t(charToNumber(argv[i + 3])); + g_cmd = QVAULT_COMMAND_SUBMIT_FUNDP; + g_qvaulturl = argv[i + 1]; + g_qvault_price_of_qcap = uint64_t(charToNumber(argv[i + 2])); + g_qvault_amount_of_qcap = uint32_t(charToNumber(argv[i + 3])); i += 4; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultsubmitreinvestingaddress") == 0) + if (strcmp(argv[i], "-qvaultsubmitmarketplaceproposal") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(6) + g_cmd = QVAULT_COMMAND_SUBMIT_MKTP; + g_qvaulturl = argv[i + 1]; + g_qvault_amount_of_qubic = uint64_t(charToNumber(argv[i + 2])); + g_qvault_share_name = argv[i + 3]; + g_qvault_amount_of_qcap = uint32_t(charToNumber(argv[i + 4])); + g_qvault_index_of_share = uint32_t(charToNumber(argv[i + 5])); + g_qvault_amount_of_share = uint32_t(charToNumber(argv[i + 6])); + i += 7; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultsubmitpercentallocationproposal") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(4) + g_cmd = QVAULT_COMMAND_SUBMIT_ALLOP; + g_qvaulturl = argv[i + 1]; + g_qvault_reinvested = uint32_t(charToNumber(argv[i + 2])); + g_qvault_burn = uint32_t(charToNumber(argv[i + 3])); + g_qvault_distribute = uint32_t(charToNumber(argv[i + 4])); + i += 5; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultvoteinproposal") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(4) + g_cmd = QVAULT_COMMAND_VOTE_IN_PROPOSAL; + g_qvault_price_of_ipo = uint64_t(charToNumber(argv[i + 1])); + g_qvault_proposal_type = uint32_t(charToNumber(argv[i + 2])); + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 3])); + g_qvault_yes = bool(charToNumber(argv[i + 4])); + i += 5; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultbuyqcap") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(2) + g_cmd = QVAULT_COMMAND_BUY_QCAP; + g_qvault_price_of_qcap = uint64_t(charToNumber(argv[i + 1])); + g_qvault_amount_of_qcap = uint32_t(charToNumber(argv[i + 2])); + i += 3; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaulttransfersharemanagementrights") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(4) + g_cmd = QVAULT_COMMAND_TRANSFER_SHARE_MANAGEMENT_RIGHTS; + g_qvault_assetname = argv[i + 1]; + g_qvaultIdentity = argv[i + 2]; + g_qvault_newmanagement_contract_index = uint32_t(charToNumber(argv[i + 3])); + g_qvault_number_of_share = int64_t(charToNumber(argv[i + 4])); + i += 5; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetdata") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(0) + g_cmd = QVAULT_COMMAND_GETDATA; + i += 1; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetstakedamountandvotingpower") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_SUBMIT_REINVESTING_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_STAKED_AMOUNT_AND_VOTING_POWER; + g_qvaultIdentity = argv[i + 1]; i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultchangereinvestingaddress") == 0) + if (strcmp(argv[i], "-qvaultgetgeneralproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_CHANGE_REINVESTING_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_GP; + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 1])); i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultsubmitadminaddress") == 0) + if (strcmp(argv[i], "-qvaultgetquorumchangeproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_SUBMIT_ADMIN_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_QCP; + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 1])); i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultchangeadminaddress") == 0) + if (strcmp(argv[i], "-qvaultgetipoproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_CHANGE_ADMIN_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_IPOP; + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 1])); i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultgetdata") == 0) + if (strcmp(argv[i], "-qvaultgetqearnproposal") == 0) { - g_cmd = QVAULT_GET_DATA; - i += 1; + CHECK_NUMBER_OF_PARAMETERS(1) + g_cmd = QVAULT_COMMAND_GET_QEARNP; + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 1])); + i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultsubmitbannedaddress") == 0) + if (strcmp(argv[i], "-qvaultgetfundproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_SUBMIT_BANNED_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_FUNDP; + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 1])); i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultsavebannedaddress") == 0) + if (strcmp(argv[i], "-qvaultgetmarketplaceproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_SAVE_BANNED_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_MKTP; + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 1])); i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultsubmitunbannedaddress") == 0) + if (strcmp(argv[i], "-qvaultgetallocationproposal") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_SUBMIT_UNBANNED_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_ALLOP; + g_qvault_proposal_id = uint32_t(charToNumber(argv[i + 1])); i += 2; CHECK_OVER_PARAMETERS; break; } - if (strcmp(argv[i], "-qvaultsaveunbannedaddress") == 0) + if (strcmp(argv[i], "-qvaultgetidentitieshavingvotingpower") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(2) + g_cmd = QVAULT_COMMAND_GET_IDENTITIES_HV_VT_PW; + g_qvault_offset = uint32_t(charToNumber(argv[i + 1])); + g_qvault_count = uint32_t(charToNumber(argv[i + 2])); + i += 3; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetproposalcreationpower") == 0) { CHECK_NUMBER_OF_PARAMETERS(1) - g_cmd = QVAULT_SAVE_UNBANNED_ADDRESS; - g_qvault_identity = argv[i + 1]; + g_cmd = QVAULT_COMMAND_GET_PP_CREATION_POWER; + g_qvaultIdentity = argv[i + 1]; i += 2; CHECK_OVER_PARAMETERS; break; } - + if (strcmp(argv[i], "-qvaultgetqcapburntamountinlastepoches") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(1) + g_cmd = QVAULT_COMMAND_GET_QCAP_BURNT_AMOUNT_IN_LAST_EPOCHES; + g_qvault_number_of_epoch = uint32_t(charToNumber(argv[i + 1])); + i += 2; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetamounttobesoldperyear") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(1) + g_cmd = QVAULT_COMMAND_GET_AMOUNT_TO_BE_SOLD_PER_YEAR; + g_qvault_year = uint32_t(charToNumber(argv[i + 1])); + i += 2; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgettotalrevenueinqcap") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(0) + g_cmd = QVAULT_COMMAND_GET_TOTAL_REVENUE_IN_QCAP; + i += 1; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetrevenueinqcapperepoch") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(1) + g_cmd = QVAULT_COMMAND_GET_REVENUE_IN_QCAP_PER_EPOCH; + g_qvault_epoch = uint32_t(charToNumber(argv[i + 1])); + i += 2; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetrevenuepershare") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(1) + g_cmd = QVAULT_COMMAND_GET_REVENUE_PER_SHARE; + g_qvault_contract_index = uint32_t(charToNumber(argv[i + 1])); + i += 2; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetamountofshareqvaulthold") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(2) + g_cmd = QVAULT_COMMAND_GET_AMOUNT_OF_SHARE_QVAULT_HOLD; + g_qvault_assetname = argv[i + 1]; + g_qvaultIdentity = argv[i + 2]; + i += 3; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetnumberofholderandaverageamount") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(0) + g_cmd = QVAULT_COMMAND_GET_NUMBER_OF_HOLDER_AND_AVG_AM; + i += 1; + CHECK_OVER_PARAMETERS; + break; + } + if (strcmp(argv[i], "-qvaultgetamountforqearninupcomingepoch") == 0) + { + CHECK_NUMBER_OF_PARAMETERS(1) + g_cmd = QVAULT_COMMAND_GET_AMOUNT_FOR_QEARN_IN_UPCOMING_EPOCH; + g_qvault_epoch = uint32_t(charToNumber(argv[i + 1])); + i += 2; + CHECK_OVER_PARAMETERS; + break; + } + /************************** **** MSVAULT COMMANDS **** **************************/ diff --git a/connection.cpp b/connection.cpp index 6a2467d..6de19f3 100644 --- a/connection.cpp +++ b/connection.cpp @@ -324,6 +324,25 @@ template qxGetAssetOrder_output QubicConnection::receivePacketWithHeaderAs(); // QVAULT template QVaultGetData_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetStakedAmountAndVotingPower_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetGP_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetQCP_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetIPOP_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetQEarnP_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetFundP_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetMKTP_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetAlloP_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetIdentitiesHvVtPw_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultppCreationPower_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetQcapBurntAmountInLastEpoches_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetAmountToBeSoldPerYear_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetTotalRevenueInQcap_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetRevenueInQcapPerEpoch_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetRevenuePerShare_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetAmountOfShareQvaultHold_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetNumberOfHolderAndAvgAm_output QubicConnection::receivePacketWithHeaderAs(); +template QvaultGetAmountForQearnInUpcomingEpoch_output QubicConnection::receivePacketWithHeaderAs(); + // QEARN template QEarnGetLockInfoPerEpoch_output QubicConnection::receivePacketWithHeaderAs(); template QEarnGetUserLockedInfo_output QubicConnection::receivePacketWithHeaderAs(); diff --git a/global.h b/global.h index 91fb07c..30acaad 100644 --- a/global.h +++ b/global.h @@ -111,11 +111,34 @@ uint32_t g_qearn_getInfoEpoch = 0; uint32_t g_qearn_getStatsEpoch = 0; // qvault -char* g_qvault_identity = nullptr; -uint32_t g_qvault_numberOfChangedAddress = 0; -uint32_t g_qvault_newQCAPHolderFee = 0; -uint32_t g_qvault_newReinvestingFee = 0; -uint32_t g_qvault_newDevFee = 0; +char* g_qvaulturl = nullptr; +char* g_qvaultIdentity = nullptr; +uint32_t g_qvault_stake_amount = 0; +uint32_t g_qvault_permille = 0; +uint32_t g_qvault_ipo_contract_index = 0; +uint64_t g_qvault_amount_of_qubic = 0; +uint32_t g_qvault_number_of_epoch = 0; +uint64_t g_qvault_price_of_qcap = 0; +uint32_t g_qvault_amount_of_qcap = 0; +char* g_qvault_share_name = nullptr; +uint32_t g_qvault_index_of_share = 0; +uint32_t g_qvault_amount_of_share = 0; +uint32_t g_qvault_reinvested = 0; +uint32_t g_qvault_burn = 0; +uint32_t g_qvault_distribute = 0; +uint32_t g_qvault_share_index = 0; +uint64_t g_qvault_price_of_ipo = 0; +uint32_t g_qvault_proposal_type = 0; +uint32_t g_qvault_proposal_id = 0; +bool g_qvault_yes = 0; +char* g_qvault_assetname = nullptr; +int64_t g_qvault_number_of_share = 0; +uint32_t g_qvault_newmanagement_contract_index = 0; +uint32_t g_qvault_count = 0; +uint32_t g_qvault_offset = 0; +uint32_t g_qvault_year = 0; +uint32_t g_qvault_epoch = 0; +uint32_t g_qvault_contract_index = 0; // msvault uint64_t g_msvault_id = 0; diff --git a/main.cpp b/main.cpp index e3403e9..d4c41ff 100644 --- a/main.cpp +++ b/main.cpp @@ -560,58 +560,143 @@ int run(int argc, char* argv[]) sanityCheckNode(g_nodeIp, g_nodePort); qearnGetBurnedAndBoostedStatsPerEpoch(g_nodeIp, g_nodePort, g_qearn_getStatsEpoch); break; - case QVAULT_SUBMIT_AUTH_ADDRESS: + case QVAULT_COMMAND_STAKE: sanityCheckNode(g_nodeIp, g_nodePort); - submitAuthAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + sanityCheckSeed(g_seed); + stake(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_stake_amount); break; - case QVAULT_CHANGE_AUTH_ADDRESS: + case QVAULT_COMMAND_UNSTAKE: sanityCheckNode(g_nodeIp, g_nodePort); - changeAuthAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_numberOfChangedAddress); + sanityCheckSeed(g_seed); + unStake(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_stake_amount); break; - case QVAULT_SUBMIT_FEES: + case QVAULT_COMMAND_SUBMIT_GP: sanityCheckNode(g_nodeIp, g_nodePort); - submitFees(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_newQCAPHolderFee, g_qvault_newReinvestingFee, g_qvault_newDevFee); + sanityCheckSeed(g_seed); + submitGP(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvaulturl); break; - case QVAULT_CHANGE_FEES: + case QVAULT_COMMAND_SUBMIT_QCP: sanityCheckNode(g_nodeIp, g_nodePort); - changeFees(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_newQCAPHolderFee, g_qvault_newReinvestingFee, g_qvault_newDevFee); + sanityCheckSeed(g_seed); + submitQCP(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_permille, g_qvaulturl); break; - case QVAULT_SUBMIT_REINVESTING_ADDRESS: + case QVAULT_COMMAND_SUBMIT_IPOP: sanityCheckNode(g_nodeIp, g_nodePort); - submitReinvestingAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + sanityCheckSeed(g_seed); + submitIPOP(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_ipo_contract_index, g_qvaulturl); break; - case QVAULT_CHANGE_REINVESTING_ADDRESS: + case QVAULT_COMMAND_SUBMIT_QEARNP: sanityCheckNode(g_nodeIp, g_nodePort); - changeReinvestingAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + sanityCheckSeed(g_seed); + submitQEarnP(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_amount_of_qubic, g_qvault_number_of_epoch, g_qvaulturl); break; - case QVAULT_SUBMIT_ADMIN_ADDRESS: + case QVAULT_COMMAND_SUBMIT_FUNDP: sanityCheckNode(g_nodeIp, g_nodePort); - submitAdminAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + sanityCheckSeed(g_seed); + submitFundP(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_price_of_qcap, g_qvault_amount_of_qcap, g_qvaulturl); break; - case QVAULT_CHANGE_ADMIN_ADDRESS: + case QVAULT_COMMAND_SUBMIT_MKTP: sanityCheckNode(g_nodeIp, g_nodePort); - changeAdminAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + sanityCheckSeed(g_seed); + submitMKTP(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_amount_of_qubic, g_qvault_share_name, g_qvault_amount_of_qcap, g_qvault_index_of_share, g_qvault_amount_of_share, g_qvaulturl); + break; + case QVAULT_COMMAND_SUBMIT_ALLOP: + sanityCheckNode(g_nodeIp, g_nodePort); + sanityCheckSeed(g_seed); + submitAlloP(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_reinvested, g_qvault_burn, g_qvault_distribute, g_qvaulturl); break; - case QVAULT_GET_DATA: + case QVAULT_COMMAND_VOTE_IN_PROPOSAL: + sanityCheckNode(g_nodeIp, g_nodePort); + sanityCheckSeed(g_seed); + voteInProposal(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_price_of_ipo, g_qvault_proposal_type, g_qvault_proposal_id, g_qvault_yes); + break; + case QVAULT_COMMAND_BUY_QCAP: + sanityCheckNode(g_nodeIp, g_nodePort); + sanityCheckSeed(g_seed); + buyQcap(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_amount_of_qcap, g_qvault_price_of_qcap); + break; + case QVAULT_COMMAND_TRANSFER_SHARE_MANAGEMENT_RIGHTS: + sanityCheckNode(g_nodeIp, g_nodePort); + sanityCheckSeed(g_seed); + TransferShareManagementRights(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvaultIdentity, g_qvault_assetname, g_qvault_number_of_share, g_qvault_newmanagement_contract_index); + break; + case QVAULT_COMMAND_GETDATA: sanityCheckNode(g_nodeIp, g_nodePort); getData(g_nodeIp, g_nodePort); break; - case QVAULT_SUBMIT_BANNED_ADDRESS: + case QVAULT_COMMAND_GET_STAKED_AMOUNT_AND_VOTING_POWER: + sanityCheckNode(g_nodeIp, g_nodePort); + getStakedAmountAndVotingPower(g_nodeIp, g_nodePort, g_qvaultIdentity); + break; + case QVAULT_COMMAND_GET_GP: sanityCheckNode(g_nodeIp, g_nodePort); - submitBannedAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + getGP(g_nodeIp, g_nodePort, g_qvault_proposal_id); break; - case QVAULT_SAVE_BANNED_ADDRESS: + case QVAULT_COMMAND_GET_QCP: sanityCheckNode(g_nodeIp, g_nodePort); - saveBannedAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + getQCP(g_nodeIp, g_nodePort, g_qvault_proposal_id); break; - case QVAULT_SUBMIT_UNBANNED_ADDRESS: + case QVAULT_COMMAND_GET_IPOP: sanityCheckNode(g_nodeIp, g_nodePort); - submitUnbannedannedAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + getIPOP(g_nodeIp, g_nodePort, g_qvault_proposal_id); break; - case QVAULT_SAVE_UNBANNED_ADDRESS: + case QVAULT_COMMAND_GET_QEARNP: sanityCheckNode(g_nodeIp, g_nodePort); - saveUnbannedAddress(g_nodeIp, g_nodePort, g_seed, g_offsetScheduledTick, g_qvault_identity); + getQEarnP(g_nodeIp, g_nodePort, g_qvault_proposal_id); break; + case QVAULT_COMMAND_GET_FUNDP: + sanityCheckNode(g_nodeIp, g_nodePort); + getFundP(g_nodeIp, g_nodePort, g_qvault_proposal_id); + break; + case QVAULT_COMMAND_GET_MKTP: + sanityCheckNode(g_nodeIp, g_nodePort); + getMKTP(g_nodeIp, g_nodePort, g_qvault_proposal_id); + break; + case QVAULT_COMMAND_GET_ALLOP: + sanityCheckNode(g_nodeIp, g_nodePort); + getAlloP(g_nodeIp, g_nodePort, g_qvault_proposal_id); + break; + case QVAULT_COMMAND_GET_IDENTITIES_HV_VT_PW: + sanityCheckNode(g_nodeIp, g_nodePort); + getIdentitiesHvVtPw(g_nodeIp, g_nodePort, g_qvault_offset, g_qvault_count); + break; + case QVAULT_COMMAND_GET_PP_CREATION_POWER: + sanityCheckNode(g_nodeIp, g_nodePort); + ppCreationPower(g_nodeIp, g_nodePort, g_qvaultIdentity); + break; + case QVAULT_COMMAND_GET_QCAP_BURNT_AMOUNT_IN_LAST_EPOCHES: + sanityCheckNode(g_nodeIp, g_nodePort); + getQcapBurntAmountInLastEpoches(g_nodeIp, g_nodePort, g_qvault_number_of_epoch); + break; + case QVAULT_COMMAND_GET_AMOUNT_TO_BE_SOLD_PER_YEAR: + sanityCheckNode(g_nodeIp, g_nodePort); + getAmountToBeSoldPerYear(g_nodeIp, g_nodePort, g_qvault_year); + break; + case QVAULT_COMMAND_GET_TOTAL_REVENUE_IN_QCAP: + sanityCheckNode(g_nodeIp, g_nodePort); + getTotalRevenueInQcap(g_nodeIp, g_nodePort); + break; + case QVAULT_COMMAND_GET_REVENUE_IN_QCAP_PER_EPOCH: + sanityCheckNode(g_nodeIp, g_nodePort); + getRevenueInQcapPerEpoch(g_nodeIp, g_nodePort, g_qvault_epoch); + break; + case QVAULT_COMMAND_GET_REVENUE_PER_SHARE: + sanityCheckNode(g_nodeIp, g_nodePort); + getRevenuePerShare(g_nodeIp, g_nodePort, g_qvault_contract_index); + break; + case QVAULT_COMMAND_GET_AMOUNT_OF_SHARE_QVAULT_HOLD: + sanityCheckNode(g_nodeIp, g_nodePort); + getAmountOfShareQvaultHold(g_nodeIp, g_nodePort, g_qvault_assetname, g_qvaultIdentity); + break; + case QVAULT_COMMAND_GET_NUMBER_OF_HOLDER_AND_AVG_AM: + sanityCheckNode(g_nodeIp, g_nodePort); + getNumberOfHolderAndAvgAm(g_nodeIp, g_nodePort); + break; + case QVAULT_COMMAND_GET_AMOUNT_FOR_QEARN_IN_UPCOMING_EPOCH: + sanityCheckNode(g_nodeIp, g_nodePort); + getAmountForQearnInUpcomingEpoch(g_nodeIp, g_nodePort, g_qvault_epoch); + break; + // MSVAULT case MSVAULT_REGISTER_VAULT_CMD: { diff --git a/qvault.cpp b/qvault.cpp index 4bb552d..aa64806 100644 --- a/qvault.cpp +++ b/qvault.cpp @@ -1,966 +1,1121 @@ +#include #include #include -#include +#include -#include "structs.h" #include "wallet_utils.h" #include "key_utils.h" -#include "asset_utils.h" -#include "connection.h" #include "logger.h" -#include "node_utils.h" -#include "k12_and_key_utils.h" #include "qvault.h" +#include "asset_utils.h" #define QVAULT_CONTRACT_INDEX 10 +#define QVAULT_PROPOSAL_CREATION_FEE 10000000 +#define QVAULT_SHARE_MANAGEMENT_TRANSFER_FEE 100 + +constexpr uint32_t QVAULT_MAX_URLS_COUNT = 256; + +// Proposal result constants +constexpr uint8_t QVAULT_PROPOSAL_PASSED = 0; +constexpr uint8_t QVAULT_PROPOSAL_REJECTED = 1; +constexpr uint8_t QVAULT_PROPOSAL_INSUFFICIENT_QUORUM = 2; +constexpr uint8_t QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER = 3; +constexpr uint8_t QVAULT_PROPOSAL_INSUFFICIENT_QCAP = 4; +constexpr uint8_t QVAULT_PROPOSAL_NOT_STARTED = 5; // QVAULT FUNCTIONS #define QVAULT_GETDATA 1 +#define QVAULT_GET_STAKED_AMOUNT_AND_VOTING_POWER 2 +#define QVAULT_GET_GP 3 +#define QVAULT_GET_QCP 4 +#define QVAULT_GET_IPOP 5 +#define QVAULT_GET_QEARNP 6 +#define QVAULT_GET_FUNDP 7 +#define QVAULT_GET_MKTP 8 +#define QVAULT_GET_ALLOP 9 +#define QVAULT_GET_IDENTITIES_HV_VT_PW 11 +#define QVAULT_GET_PP_CREATION_POWER 12 +#define QVAULT_GET_QCAP_BURNT_AMOUNT_IN_LAST_EPOCHES 13 +#define QVAULT_GET_AMOUNT_TO_BE_SOLD_PER_YEAR 14 +#define QVAULT_GET_TOTAL_REVENUE_IN_QCAP 15 +#define QVAULT_GET_REVENUE_IN_QCAP_PER_EPOCH 16 +#define QVAULT_GET_REVENUE_PER_SHARE 17 +#define QVAULT_GET_AMOUNT_OF_SHARE_QVAULT_HOLD 18 +#define QVAULT_GET_NUMBER_OF_HOLDER_AND_AVG_AM 19 +#define QVAULT_GET_AMOUNT_FOR_QEARN_IN_UPCOMING_EPOCH 20 // QVAULT PROCEDURES -#define QVAULT_SUBMITAUTHADDRESS 1 -#define QVAULT_CHANGEAUTHADDRESS 2 -#define QVAULT_SUBMITFEES 3 -#define QVAULT_CHANGEFEES 4 -#define QVAULT_SUBMITREINVESTINGADDRESS 5 -#define QVAULT_CHANGEREINVESTINGADDRESS 6 -#define QVAULT_SUBMITADMINADDRESS 7 -#define QVAULT_CHANGEADMINADDRESS 8 -#define QVAULT_SUBMITBANNEDADDRESS 9 -#define QVAULT_SAVEBANNEDADDRESS 10 -#define QVAULT_SUBMITUNBANNEDADDRESS 11 -#define QVAULT_SAVEUNBANNEDADDRESS 12 - -struct submitAuthAddress_input -{ - uint8_t newAddress[32]; +#define QVAULT_STAKE 1 +#define QVAULT_UNSTAKE 2 +#define QVAULT_SUBMIT_GP 3 +#define QVAULT_SUBMIT_QCP 4 +#define QVAULT_SUBMIT_IPOP 5 +#define QVAULT_SUBMIT_QEARNP 6 +#define QVAULT_SUBMIT_FUNDP 7 +#define QVAULT_SUBMIT_MKTP 8 +#define QVAULT_SUBMIT_ALLOP 9 +#define QVAULT_VOTE_IN_PROPOSAL 11 +#define QVAULT_BUY_QCAP 12 +#define QVAULT_TRANSFER_SHARE_MANAGEMENT_RIGHTS 13 + +struct stake_input +{ + uint32_t amount; }; -struct submitAuthAddress_output + +struct stake_output { + int32_t returnCode; }; -struct changeAuthAddress_input +struct unStake_input { - uint32_t numberOfChangedAddress; + uint32_t amount; }; -struct changeAuthAddress_output + +struct unStake_output { + int32_t returnCode; }; -struct submitFees_input +struct submitGP_input { - uint32_t newQCAPHolder_permille; - uint32_t newreinvesting_permille; - uint32_t newdev_permille; + uint8_t url[256]; }; -struct submitFees_output + +struct submitGP_output { + int32_t returnCode; }; -struct changeFees_input +struct submitQCP_input { - uint32_t newQCAPHolder_permille; - uint32_t newreinvesting_permille; - uint32_t newdev_permille; + uint32_t newQuorumPercent; + uint8_t url[256]; }; -struct changeFees_output + +struct submitQCP_output { + int32_t returnCode; }; -struct submitReinvestingAddress_input +struct submitIPOP_input { - uint8_t newAddress[32]; + uint32_t ipoContractIndex; + uint8_t url[256]; }; -struct submitReinvestingAddress_output + +struct submitIPOP_output { + int32_t returnCode; }; -struct changeReinvestingAddress_input +struct submitQEarnP_input { - uint8_t newAddress[32]; + uint64_t amountPerEpoch; + uint32_t numberOfEpoch; + uint8_t url[256]; }; -struct changeReinvestingAddress_output + +struct submitQEarnP_output { + int32_t returnCode; }; -struct submitAdminAddress_input +struct submitFundP_input { - uint8_t newAddress[32]; + uint64_t priceOfOneQcap; + uint32_t amountOfQcap; + uint8_t url[256]; }; -struct submitAdminAddress_output + +struct submitFundP_output { + int32_t returnCode; }; -struct changeAdminAddress_input +struct submitMKTP_input { - uint8_t newAddress[32]; + uint64_t amountOfQubic; + uint64_t shareName; + uint32_t amountOfQcap; + uint32_t indexOfShare; + uint32_t amountOfShare; + uint8_t url[256]; }; -struct changeAdminAddress_output + +struct submitMKTP_output { + int32_t returnCode; }; -struct submitBannedAddress_input +struct submitAlloP_input { - uint8_t bannedAddress[32]; + uint32_t reinvested; + uint32_t burn; + uint32_t distribute; + uint8_t url[256]; }; -struct submitBannedAddress_output + +struct submitAlloP_output { + int32_t returnCode; }; -struct saveBannedAddress_input +struct voteInProposal_input { - uint8_t bannedAddress[32]; + uint64_t priceOfIPO; + uint32_t proposalType; + uint32_t proposalId; + bool yes; }; -struct saveBannedAddress_output + +struct voteInProposal_output { + int32_t returnCode; }; -struct submitUnbannedAddress_input +struct buyQcap_input { - uint8_t unbannedAddress[32]; + uint32_t amount; }; -struct submitUnbannedAddress_output + +struct buyQcap_output { + int32_t returnCode; }; -struct unblockBannedAddress_input +struct TransferShareManagementRights_input { - uint8_t unbannedAddress[32]; + qpiAsset asset; + int64_t numberOfShares; + uint32_t newManagingContractIndex; }; -struct unblockBannedAddress_output +struct TransferShareManagementRights_output { + int64_t transferredNumberOfShares; + int32_t returnCode; }; -void submitAuthAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - submitAuthAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.newAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SUBMITAUTHADDRESS; - packet.transaction.inputSize = sizeof(submitAuthAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitAuthAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitAuthAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("submitAuthAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void changeAuthAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t numberOfChangedAddress) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - changeAuthAddress_input input; - unsigned char signature[64]; - } packet; - - packet.input.numberOfChangedAddress = numberOfChangedAddress; - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_CHANGEAUTHADDRESS; - packet.transaction.inputSize = sizeof(changeAuthAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeAuthAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeAuthAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("changeAuthAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void submitFees(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t newQCAPHolder_permille, uint32_t newreinvesting_permille, uint32_t newdev_permille) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - submitFees_input input; - unsigned char signature[64]; - } packet; - - packet.input.newdev_permille = newdev_permille; - packet.input.newQCAPHolder_permille = newQCAPHolder_permille; - packet.input.newreinvesting_permille = newreinvesting_permille; - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SUBMITFEES; - packet.transaction.inputSize = sizeof(submitFees_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitFees_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitFees_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("submitFees tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void changeFees(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t newQCAPHolder_permille, uint32_t newreinvesting_permille, uint32_t newdev_permille) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - changeFees_input input; - unsigned char signature[64]; - } packet; - - packet.input.newdev_permille = newdev_permille; - packet.input.newQCAPHolder_permille = newQCAPHolder_permille; - packet.input.newreinvesting_permille = newreinvesting_permille; - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_CHANGEFEES; - packet.transaction.inputSize = sizeof(changeFees_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeFees_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeFees_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("changeFees tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void submitReinvestingAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - submitReinvestingAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.newAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SUBMITREINVESTINGADDRESS; - packet.transaction.inputSize = sizeof(submitReinvestingAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitReinvestingAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitReinvestingAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("submitReinvestingAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void changeReinvestingAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - changeReinvestingAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.newAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_CHANGEREINVESTINGADDRESS; - packet.transaction.inputSize = sizeof(changeReinvestingAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeReinvestingAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeReinvestingAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("changeReinvestingAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void submitAdminAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - submitAdminAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.newAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SUBMITADMINADDRESS; - packet.transaction.inputSize = sizeof(submitAdminAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitAdminAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitAdminAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("submitAdminAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void changeAdminAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - changeAdminAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.newAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_CHANGEADMINADDRESS; - packet.transaction.inputSize = sizeof(changeAdminAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeAdminAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(changeAdminAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("changeAdminAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); +namespace +{ + +bool copyUrlField(uint8_t* dest, const char* url) +{ + if (!dest || !url) + return false; + size_t len = strlen(url); + if (len > 255) + return false; + memset(dest, 0, 256); + memcpy(dest, url, len); + return true; } -void getData(const char* nodeIp, int nodePort) +bool encodeAssetName(const char* source, uint64_t& encoded) +{ + if (!source) + return false; + size_t len = strlen(source); + if (len > 8) + return false; + char buffer[8] = {0}; + memcpy(buffer, source, len); + memcpy(&encoded, buffer, sizeof(buffer)); + return true; +} + +bool runQvaultFunction(const char* nodeIp, int nodePort, + unsigned short funcNumber, + void* inputPtr, size_t inputSize, + void* outputPtr, size_t outputSize) { - auto qc = make_qc(nodeIp, nodePort); - - struct { - RequestResponseHeader header; - RequestContractFunction rcf; - QVaultGetData_input input; - } packet; - packet.header.setSize(sizeof(packet)); - packet.header.randomizeDejavu(); - packet.header.setType(RequestContractFunction::type()); - packet.rcf.inputSize = sizeof(QVaultGetData_input); - packet.rcf.inputType = QVAULT_GETDATA; - packet.rcf.contractIndex = QVAULT_CONTRACT_INDEX; - packet.input.t = 10; - - qc->sendData((uint8_t *) &packet, packet.header.size()); - - QVaultGetData_output result; - try - { - result = qc->receivePacketWithHeaderAs(); - } - catch (std::logic_error) + if (!runContractFunction(nodeIp, nodePort, QVAULT_CONTRACT_INDEX, + funcNumber, inputPtr, inputSize, + outputPtr, outputSize)) { LOG("Failed to receive data\n"); + return false; + } + return true; +} + +constexpr const char* EMPTY_IDENTITY = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFXIB"; + +} // namespace + +void stake(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t amount) +{ + stake_input input{}; + input.amount = amount; + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_STAKE, + 0, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void unStake(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t amount) +{ + unStake_input input{}; + input.amount = amount; + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_UNSTAKE, + 0, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void submitGP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* url) +{ + submitGP_input input{}; + if (!copyUrlField(input.url, url)) + { + printf("The url should be less than 255.\nThe command is failed"); + return; + } + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_SUBMIT_GP, + QVAULT_PROPOSAL_CREATION_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void submitQCP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t newQuorumPercent, const char* url) +{ + submitQCP_input input{}; + input.newQuorumPercent = newQuorumPercent; + if (!copyUrlField(input.url, url)) + { + printf("The url should be less than 255.\nThe command is failed"); + return; + } + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_SUBMIT_QCP, + QVAULT_PROPOSAL_CREATION_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void submitIPOP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t ipoContractIndex, const char* url) +{ + submitIPOP_input input{}; + input.ipoContractIndex = ipoContractIndex; + if (!copyUrlField(input.url, url)) + { + printf("The url should be less than 255.\nThe command is failed"); + return; + } + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_SUBMIT_IPOP, + QVAULT_PROPOSAL_CREATION_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void submitQEarnP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t amountPerEpoch, uint32_t numberOfEpoch, const char* url) +{ + submitQEarnP_input input{}; + input.amountPerEpoch = amountPerEpoch; + input.numberOfEpoch = numberOfEpoch; + if (!copyUrlField(input.url, url)) + { + printf("The url should be less than 255.\nThe command is failed"); + return; + } + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_SUBMIT_QEARNP, + QVAULT_PROPOSAL_CREATION_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void submitFundP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t priceOfOneQcap, uint32_t amountOfQcap, const char* url) +{ + submitFundP_input input{}; + input.amountOfQcap = amountOfQcap; + input.priceOfOneQcap = priceOfOneQcap; + if (!copyUrlField(input.url, url)) + { + printf("The url should be less than 255.\nThe command is failed"); + return; + } + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_SUBMIT_FUNDP, + QVAULT_PROPOSAL_CREATION_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void submitMKTP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t amountOfQubic, const char* shareName, uint32_t amountOfQcap, uint32_t indexOfShare, uint32_t amountOfShare, const char* url) +{ + submitMKTP_input input{}; + if (!encodeAssetName(shareName, input.shareName)) + { + printf("The share name should be at most 8 characters.\n"); + return; + } + if (!copyUrlField(input.url, url)) + { + printf("The url should be less than 255.\nThe command is failed"); + return; + } + input.amountOfQcap = amountOfQcap; + input.amountOfQubic = amountOfQubic; + input.amountOfShare = amountOfShare; + input.indexOfShare = indexOfShare; + + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_SUBMIT_MKTP, + QVAULT_PROPOSAL_CREATION_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void submitAlloP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t reinvested, uint32_t burn, uint32_t distribute, const char* url) +{ + submitAlloP_input input{}; + input.reinvested = reinvested; + input.burn = burn; + input.distribute = distribute; + if (!copyUrlField(input.url, url)) + { + printf("The url should be less than 255.\nThe command is failed"); + return; + } + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_SUBMIT_ALLOP, + QVAULT_PROPOSAL_CREATION_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void voteInProposal(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t priceOfIPO, uint32_t proposalType, uint32_t proposalId, bool yes) +{ + voteInProposal_input input{}; + input.priceOfIPO = priceOfIPO; + input.proposalType = proposalType; + input.proposalId = proposalId; + input.yes = yes; + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_VOTE_IN_PROPOSAL, + 0, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void buyQcap(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t amount, uint64_t priceOfOneQcap) +{ + buyQcap_input input{}; + input.amount = amount; + const uint64_t txAmount = priceOfOneQcap * amount; + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_BUY_QCAP, + txAmount, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void TransferShareManagementRights(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* issuer, const char* assetName, int64_t numberOfShares, uint32_t newManagingContractIndex) +{ + uint64_t encodedAssetName = 0; + if (!encodeAssetName(assetName, encodedAssetName)) + { + printf("The asset name should be at most 8 characters.\n"); + return; + } + uint8_t pubKey[32] = {0}; + getPublicKeyFromIdentity(issuer, pubKey); + + TransferShareManagementRights_input input{}; + memcpy(input.asset.issuer, pubKey, sizeof(input.asset.issuer)); + input.asset.assetName = encodedAssetName; + input.numberOfShares = numberOfShares; + input.newManagingContractIndex = newManagingContractIndex; + + makeContractTransaction(nodeIp, + nodePort, + seed, + QVAULT_CONTRACT_INDEX, + QVAULT_TRANSFER_SHARE_MANAGEMENT_RIGHTS, + QVAULT_SHARE_MANAGEMENT_TRANSFER_FEE, + sizeof(input), + reinterpret_cast(&input), + scheduledTickOffset); +} + +void getData(const char* nodeIp, int nodePort) +{ + QVaultGetData_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, QVAULT_GETDATA, nullptr, 0, &result, sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + printf("returnCode: %d\ntotalVotingPower: %" PRIu64 "\nproposalCreateFund: %" PRIu64 "\nreinvestingFund: %" PRIu64 "\ntotalEpochRevenue: %" PRIu64 "\nfundForBurn: %" PRIu64 "\ntotalStakedQcapAmount: %" PRIu64 "\nqcapMarketCap: %" PRIu64 "\nraisedFundByQcap: %" PRIu64 "\nlastRoundPriceOfQcap: %" PRIu64 "\nrevenueByQearn:%" PRIu64 "\nqcapSoldAmount: %u\nshareholderDividend: %u\nQCAPHolderPermille: %u\nreinvestingPermille: %u\nburnPermille: %u\nqcapBurnPermille: %u\nnumberOfStaker: %u\nnumberOfVotingPower: %u\nnumberOfGP: %u\nnumberOfQCP: %u\nnumberOfIPOP: %u\nnumberOfQEarnP: %u\nnumberOfFundP: %u\nnumberOfMKTP: %u\nnumberOfAlloP: %u\ntransferRightsFee: %u\nminQuorumRq: %u\nmaxQuorumRq: %u\ntotalQcapBurntAmount: %u\ncirculatingSupply: %u\nquorumPercent: %u\n", result.returnCode, result.totalVotingPower, result.proposalCreateFund, result.reinvestingFund, result.totalEpochRevenue, result.fundForBurn, result.totalStakedQcapAmount, result.qcapMarketCap, result.raisedFundByQcap, result.lastRoundPriceOfQcap, result.revenueByQearn, result.qcapSoldAmount, result.shareholderDividend, result.QCAPHolderPermille, result.reinvestingPermille, result.burnPermille, result.qcapBurnPermille, result.numberOfStaker, result.numberOfVotingPower, result.numberOfGP, result.numberOfQCP, result.numberOfIPOP, result.numberOfQEarnP, result.numberOfFundP, result.numberOfMKTP, result.numberOfAlloP, result.transferRightsFee, result.minQuorumRq, result.maxQuorumRq, result.totalQcapBurntAmount, result.circulatingSupply, result.quorumPercent); +} + +void getStakedAmountAndVotingPower(const char* nodeIp, int nodePort, const char* address) +{ + QvaultGetStakedAmountAndVotingPower_input input{}; + getPublicKeyFromIdentity(address, input.address); + + QvaultGetStakedAmountAndVotingPower_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_STAKED_AMOUNT_AND_VOTING_POWER, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + printf("returnCode: %d\nstakedAmount: %u\nvotingPower: %u\n", result.returnCode, result.stakedAmount, result.votingPower); +} + +void getGP(const char* nodeIp, int nodePort, uint32_t proposalId) +{ + QvaultGetGP_input input{}; + input.proposalId = proposalId; + QvaultGetGP_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_GP, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + char proposer[128] = {0}; + getIdentityFromPublicKey(result.proposal.proposer, proposer, false); + + if (strcmp(proposer, EMPTY_IDENTITY) == 0) + { + printf("ERROR: Didn't receive valid proposal with index %u\n", proposalId); + return ; + } + + printf("returnCode: %d\n%s\nproposer: %s\ncurrentTotalVotingPower: %u\nnumberOfYes: %u\nnumberOfNo: %u\nproposedEpoch: %u\ncurrentQuorumPercent: %u\n", result.returnCode, result.proposal.url, proposer, result.proposal.currentTotalVotingPower, result.proposal.numberOfYes, result.proposal.numberOfNo, result.proposal.proposedEpoch, result.proposal.currentQuorumPercent); + if (result.proposal.result == QVAULT_PROPOSAL_PASSED) + { + printf("The proposal has been approved!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_REJECTED) + { + printf("The proposal has been rejected!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QUORUM) + { + printf("The proposal has been rejected due to insufficient Quorum!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER) + { + printf("The proposal has been rejected due to insufficient voting power!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QCAP) + { + printf("The proposal has been rejected due to insufficient QCAP!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_NOT_STARTED) + { + printf("The proposal has not started yet!\n"); + } +} + +void getQCP(const char* nodeIp, int nodePort, uint32_t proposalId) +{ + QvaultGetQCP_input input{}; + input.proposalId = proposalId; + QvaultGetQCP_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_QCP, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + char proposer[128] = {0}; + getIdentityFromPublicKey(result.proposal.proposer, proposer, false); + + if (strcmp(proposer, EMPTY_IDENTITY) == 0) + { + printf("ERROR: Didn't receive valid proposal with index %u\n", proposalId); + return ; + } + + printf("returnCode: %d\n%s\nproposer: %s\ncurrentTotalVotingPower: %u\nnumberOfYes: %u\nnumberOfNo: %u\nproposedEpoch: %u\ncurrentQuorumPercent: %u\nnewQuorumPercent: %u\n", result.returnCode, result.proposal.url, proposer, result.proposal.currentTotalVotingPower, result.proposal.numberOfYes, result.proposal.numberOfNo, result.proposal.proposedEpoch, result.proposal.currentQuorumPercent, result.proposal.newQuorumPercent); + + if (result.proposal.result == QVAULT_PROPOSAL_PASSED) + { + printf("The proposal has been approved!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_REJECTED) + { + printf("The proposal has been rejected!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QUORUM) + { + printf("The proposal has been rejected due to insufficient Quorum!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER) + { + printf("The proposal has been rejected due to insufficient voting power!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QCAP) + { + printf("The proposal has been rejected due to insufficient QCAP!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_NOT_STARTED) + { + printf("The proposal has not started yet!\n"); + } +} + +void getIPOP(const char* nodeIp, int nodePort, uint32_t proposalId) +{ + QvaultGetIPOP_input input{}; + input.proposalId = proposalId; + QvaultGetIPOP_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_IPOP, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + char proposer[128] = {0}; + getIdentityFromPublicKey(result.proposal.proposer, proposer, false); + + if (strcmp(proposer, EMPTY_IDENTITY) == 0) + { + printf("ERROR: Didn't receive valid proposal with index %u\n", proposalId); + return ; + } + + printf("returnCode: %d\n%s\nproposer: %s\ncurrentTotalVotingPower: %u\nnumberOfYes: %u\nnumberOfNo: %u\nproposedEpoch: %u\ncurrentQuorumPercent: %u\ntotalWeight: %" PRIu64 "\nassignedFund: %" PRIu64 "\nipoContractIndex: %u\n", result.returnCode, result.proposal.url, proposer, result.proposal.currentTotalVotingPower, result.proposal.numberOfYes, result.proposal.numberOfNo, result.proposal.proposedEpoch, result.proposal.currentQuorumPercent, result.proposal.totalWeight, result.proposal.assignedFund, result.proposal.ipoContractIndex); + if (result.proposal.result == QVAULT_PROPOSAL_PASSED) + { + printf("The proposal has been approved!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_REJECTED) + { + printf("The proposal has been rejected!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QUORUM) + { + printf("The proposal has been rejected due to insufficient Quorum!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER) + { + printf("The proposal has been rejected due to insufficient voting power!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QCAP) + { + printf("The proposal has been rejected due to insufficient QCAP!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_NOT_STARTED) + { + printf("The proposal has not started yet!\n"); + } +} + +void getQEarnP(const char* nodeIp, int nodePort, uint32_t proposalId) +{ + QvaultGetQEarnP_input input{}; + input.proposalId = proposalId; + QvaultGetQEarnP_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_QEARNP, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + char proposer[128] = {0}; + getIdentityFromPublicKey(result.proposal.proposer, proposer, false); + + if (strcmp(proposer, EMPTY_IDENTITY) == 0) + { + printf("ERROR: Didn't receive valid proposal with index %u\n", proposalId); + return ; + } + + printf("returnCode: %d\n%s\nproposer: %s\ncurrentTotalVotingPower: %u\nnumberOfYes: %u\nnumberOfNo: %u\nproposedEpoch: %u\ncurrentQuorumPercent: %u\namountOfInvestPerEpoch: %" PRIu64 "\nassignedFundPerEpoch: %" PRIu64 "\nnumberOfEpoch: %u\n", result.returnCode, result.proposal.url, proposer, result.proposal.currentTotalVotingPower, result.proposal.numberOfYes, result.proposal.numberOfNo, result.proposal.proposedEpoch, result.proposal.currentQuorumPercent, result.proposal.amountOfInvestPerEpoch, result.proposal.assignedFundPerEpoch, result.proposal.numberOfEpoch); + if (result.proposal.result == QVAULT_PROPOSAL_PASSED) + { + printf("The proposal has been approved!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_REJECTED) + { + printf("The proposal has been rejected!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QUORUM) + { + printf("The proposal has been rejected due to insufficient Quorum!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER) + { + printf("The proposal has been rejected due to insufficient voting power!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QCAP) + { + printf("The proposal has been rejected due to insufficient QCAP!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_NOT_STARTED) + { + printf("The proposal has not started yet!\n"); + } +} + +void getFundP(const char* nodeIp, int nodePort, uint32_t proposalId) +{ + QvaultGetFundP_input input{}; + input.proposalId = proposalId; + QvaultGetFundP_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_FUNDP, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + char proposer[128] = {0}; + getIdentityFromPublicKey(result.proposal.proposer, proposer, false); + + if (strcmp(proposer, EMPTY_IDENTITY) == 0) + { + printf("ERROR: Didn't receive valid proposal with index %u\n", proposalId); + return ; + } + + printf("returnCode: %d\n%s\nproposer: %s\ncurrentTotalVotingPower: %u\nnumberOfYes: %u\nnumberOfNo: %u\nproposedEpoch: %u\ncurrentQuorumPercent: %u\npricePerOneQcap: %" PRIu64 "\namountOfQcap: %u\nrestSaleAmount: %u\n", result.returnCode, result.proposal.url, proposer, result.proposal.currentTotalVotingPower, result.proposal.numberOfYes, result.proposal.numberOfNo, result.proposal.proposedEpoch, result.proposal.currentQuorumPercent, result.proposal.pricePerOneQcap, result.proposal.amountOfQcap, result.proposal.restSaleAmount); + if (result.proposal.result == QVAULT_PROPOSAL_PASSED) + { + printf("The proposal has been approved!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_REJECTED) + { + printf("The proposal has been rejected!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QUORUM) + { + printf("The proposal has been rejected due to insufficient Quorum!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER) + { + printf("The proposal has been rejected due to insufficient voting power!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QCAP) + { + printf("The proposal has been rejected due to insufficient QCAP!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_NOT_STARTED) + { + printf("The proposal has not started yet!\n"); + } +} + +void getMKTP(const char* nodeIp, int nodePort, uint32_t proposalId) +{ + QvaultGetMKTP_input input{}; + input.proposalId = proposalId; + QvaultGetMKTP_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_MKTP, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + char assetNameStr[8] = { 0 }; + assetNameToString(result.proposal.shareName, assetNameStr); + + char proposer[128] = {0}; + getIdentityFromPublicKey(result.proposal.proposer, proposer, false); + + if (strcmp(proposer, EMPTY_IDENTITY) == 0) + { + printf("ERROR: Didn't receive valid proposal with index %u\n", proposalId); + return ; + } + + printf("returnCode: %d\n%s\nproposer: %s\ncurrentTotalVotingPower: %u\nnumberOfYes: %u\nnumberOfNo: %u\nproposedEpoch: %u\ncurrentQuorumPercent: %u\namountOfQubic: %" PRIu64 "\nshareName: %s\namountOfQcap: %u\nshareIndex: %u\namountOfShare: %u\n", result.returnCode, result.proposal.url, proposer, result.proposal.currentTotalVotingPower, result.proposal.numberOfYes, result.proposal.numberOfNo, result.proposal.proposedEpoch, result.proposal.currentQuorumPercent, result.proposal.amountOfQubic, assetNameStr, result.proposal.amountOfQcap, result.proposal.shareIndex, result.proposal.amountOfShare); + if (result.proposal.result == QVAULT_PROPOSAL_PASSED) + { + printf("The proposal has been approved!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_REJECTED) + { + printf("The proposal has been rejected!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QUORUM) + { + printf("The proposal has been rejected due to insufficient Quorum!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER) + { + printf("The proposal has been rejected due to insufficient voting power!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QCAP) + { + printf("The proposal has been rejected due to insufficient QCAP!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_NOT_STARTED) + { + printf("The proposal has not started yet!\n"); + } +} + +void getAlloP(const char* nodeIp, int nodePort, uint32_t proposalId) +{ + QvaultGetAlloP_input input{}; + input.proposalId = proposalId; + QvaultGetAlloP_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_ALLOP, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + char proposer[128] = {0}; + getIdentityFromPublicKey(result.proposal.proposer, proposer, false); + + if (strcmp(proposer, EMPTY_IDENTITY) == 0) + { + printf("ERROR: Didn't receive valid proposal with index %u\n", proposalId); + return ; + } + + printf("returnCode: %d\n%s\nproposer: %s\ncurrentTotalVotingPower: %u\nnumberOfYes: %u\nnumberOfNo: %u\nproposedEpoch: %u\ncurrentQuorumPercent: %u\nreinvested: %u\ndistributed: %u\nburnQcap: %u\n", result.returnCode, result.proposal.url, proposer, result.proposal.currentTotalVotingPower, result.proposal.numberOfYes, result.proposal.numberOfNo, result.proposal.proposedEpoch, result.proposal.currentQuorumPercent, result.proposal.reinvested, result.proposal.distributed, result.proposal.burnQcap); + if (result.proposal.result == QVAULT_PROPOSAL_PASSED) + { + printf("The proposal has been approved!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_REJECTED) + { + printf("The proposal has been rejected!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QUORUM) + { + printf("The proposal has been rejected due to insufficient Quorum!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_VOTING_POWER) + { + printf("The proposal has been rejected due to insufficient voting power!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_INSUFFICIENT_QCAP) + { + printf("The proposal has been rejected due to insufficient QCAP!\n"); + } + else if (result.proposal.result == QVAULT_PROPOSAL_NOT_STARTED) + { + printf("The proposal has not started yet!\n"); + } +} + +void getIdentitiesHvVtPw(const char* nodeIp, int nodePort, uint32_t offset, uint32_t count) +{ + QvaultGetIdentitiesHvVtPw_input input{}; + input.offset = offset; + input.count = count; + QvaultGetIdentitiesHvVtPw_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_IDENTITIES_HV_VT_PW, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + uint32_t maxEntries = std::min(count, QVAULT_MAX_URLS_COUNT); + for (uint32_t i = 0; i < maxEntries; i++) + { + char stakerAddress[128] = {0}; + getIdentityFromPublicKey(result.idList[i], stakerAddress, false); + if (strcmp(stakerAddress, EMPTY_IDENTITY) == 0) + { + break; + } + printf("stakerAddress: %s amount: %u\n", stakerAddress, result.amountList[i]); + } +} + +void ppCreationPower(const char* nodeIp, int nodePort, const char* address) +{ + QvaultppCreationPower_input input{}; + getPublicKeyFromIdentity(address, input.address); + QvaultppCreationPower_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_PP_CREATION_POWER, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + printf("returnCode: %d\n%s\n", result.returnCode, (result.status != 0) ? "You have a power to create the proposal": "You can not create the proposal"); +} + +void getQcapBurntAmountInLastEpoches(const char* nodeIp, int nodePort, uint32_t numberOfLastEpoches) +{ + QvaultGetQcapBurntAmountInLastEpoches_input input{}; + input.numberOfLastEpoches = numberOfLastEpoches; + QvaultGetQcapBurntAmountInLastEpoches_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_QCAP_BURNT_AMOUNT_IN_LAST_EPOCHES, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + printf("returnCode: %d\nburntAmount: %u\n", result.returnCode, result.burntAmount); +} + +void getAmountToBeSoldPerYear(const char* nodeIp, int nodePort, uint32_t year) +{ + QvaultGetAmountToBeSoldPerYear_input input{}; + input.year = year; + QvaultGetAmountToBeSoldPerYear_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_AMOUNT_TO_BE_SOLD_PER_YEAR, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + printf("%u\n", result.amount); +} + +void getTotalRevenueInQcap(const char* nodeIp, int nodePort) +{ + QvaultGetTotalRevenueInQcap_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_TOTAL_REVENUE_IN_QCAP, + nullptr, + 0, + &result, + sizeof(result))) + return; + + printf("%" PRIu64 "\n", result.revenue); +} + +void getRevenueInQcapPerEpoch(const char* nodeIp, int nodePort, uint32_t epoch) +{ + QvaultGetRevenueInQcapPerEpoch_input input{}; + input.epoch = epoch; + QvaultGetRevenueInQcapPerEpoch_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_REVENUE_IN_QCAP_PER_EPOCH, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + printf("epochTotalRevenue: %" PRIu64 "\nepochOneQcapRevenue: %" PRIu64 "\nepochOneQvaultRevenue: %" PRIu64 "\nepochReinvestAmount: %" PRIu64 "\n", result.epochTotalRevenue, result.epochOneQcapRevenue, result.epochOneQvaultRevenue, result.epochReinvestAmount); +} + +void getRevenuePerShare(const char* nodeIp, int nodePort, uint32_t contractIndex) +{ + QvaultGetRevenuePerShare_input input{}; + input.contractIndex = contractIndex; + QvaultGetRevenuePerShare_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_REVENUE_PER_SHARE, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + printf("revenue: %" PRIu64 "\n", result.revenue); +} + +void getAmountOfShareQvaultHold(const char* nodeIp, int nodePort, const char* assetName, const char* issuer) +{ + uint64_t encodedAssetName = 0; + if (!encodeAssetName(assetName, encodedAssetName)) + { + printf("The asset name should be at most 8 characters.\n"); + return; + } + QvaultGetAmountOfShareQvaultHold_input input{}; + getPublicKeyFromIdentity(issuer, input.assetInfo.issuer); + input.assetInfo.assetName = encodedAssetName; + + QvaultGetAmountOfShareQvaultHold_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_AMOUNT_OF_SHARE_QVAULT_HOLD, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + printf("The amount of %s that SC held: %u\n", assetName, result.amount); +} + +void getNumberOfHolderAndAvgAm(const char* nodeIp, int nodePort) +{ + QvaultGetNumberOfHolderAndAvgAm_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_NUMBER_OF_HOLDER_AND_AVG_AM, + nullptr, + 0, + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); + return; + } + + printf("returnCode: %d\nnumberOfQcapHolder: %u\navgAmount: %u\n", result.returnCode, result.numberOfQcapHolder, result.avgAmount); +} + +void getAmountForQearnInUpcomingEpoch(const char* nodeIp, int nodePort, uint32_t epoch) +{ + QvaultGetAmountForQearnInUpcomingEpoch_input input{}; + input.epoch = epoch; + QvaultGetAmountForQearnInUpcomingEpoch_output result{}; + if (!runQvaultFunction(nodeIp, nodePort, + QVAULT_GET_AMOUNT_FOR_QEARN_IN_UPCOMING_EPOCH, + &input, + sizeof(input), + &result, + sizeof(result))) + return; + + if (result.returnCode != 0) + { + printf("Error: returnCode = %d\n", result.returnCode); return; } - char auth1[128] = {0}; - char auth2[128] = {0}; - char auth3[128] = {0}; - char reinvesting_address[128] = {0}; - char admin_address[128] = {0}; - char newAuth1[128] = {0}; - char newAuth2[128] = {0}; - char newAuth3[128] = {0}; - char newReinvestingAddress1[128] = {0}; - char newReinvestingAddress2[128] = {0}; - char newReinvestingAddress3[128] = {0}; - char newAdminAddress1[128] = {0}; - char newAdminAddress2[128] = {0}; - char newAdminAddress3[128] = {0}; - char newBannedAddress1[128] = {0}; - char newBannedAddress2[128] = {0}; - char newBannedAddress3[128] = {0}; - char newUnbannedAddress1[128] = {0}; - char newUnbannedAddress2[128] = {0}; - char newUnbannedAddress3[128] = {0}; - getIdentityFromPublicKey(result.AUTH_ADDRESS1, auth1, false); - getIdentityFromPublicKey(result.AUTH_ADDRESS2, auth2, false); - getIdentityFromPublicKey(result.AUTH_ADDRESS3, auth3, false); - getIdentityFromPublicKey(result.Reinvesting_address, reinvesting_address, false); - getIdentityFromPublicKey(result.admin_address, admin_address, false); - getIdentityFromPublicKey(result.newAuthAddress1, newAuth1, false); - getIdentityFromPublicKey(result.newAuthAddress2, newAuth2, false); - getIdentityFromPublicKey(result.newAuthAddress3, newAuth3, false); - getIdentityFromPublicKey(result.newReinvesting_address1, newReinvestingAddress1, false); - getIdentityFromPublicKey(result.newReinvesting_address2, newReinvestingAddress2, false); - getIdentityFromPublicKey(result.newReinvesting_address3, newReinvestingAddress3, false); - getIdentityFromPublicKey(result.newAdmin_address1, newAdminAddress1, false); - getIdentityFromPublicKey(result.newAdmin_address2, newAdminAddress2, false); - getIdentityFromPublicKey(result.newAdmin_address3, newAdminAddress3, false); - getIdentityFromPublicKey(result.bannedAddress1, newBannedAddress1, false); - getIdentityFromPublicKey(result.bannedAddress2, newBannedAddress2, false); - getIdentityFromPublicKey(result.bannedAddress3, newBannedAddress3, false); - getIdentityFromPublicKey(result.unbannedAddress1, newUnbannedAddress1, false); - getIdentityFromPublicKey(result.unbannedAddress2, newUnbannedAddress2, false); - getIdentityFromPublicKey(result.unbannedAddress3, newUnbannedAddress3, false); - - printf("AUTH_ADDRESS1: %s", auth1); - printf("\nAUTH_ADDRESS2: %s", auth2); - printf("\nAUTH_ADDRESS3: %s", auth3); - printf("\nReinvesting_address: %s", reinvesting_address); - printf("\nadmin_address: %s", admin_address); - printf("\nnewAuthAddress1: %s", newAuth1); - printf("\nnewAuthAddress2: %s", newAuth2); - printf("\nnewAuthAddress3: %s", newAuth3); - printf("\nnewReinvesting_address1: %s", newReinvestingAddress1); - printf("\nnewReinvesting_address2: %s", newReinvestingAddress2); - printf("\nnewReinvesting_address3: %s", newReinvestingAddress3); - printf("\nnewAdmin_address1: %s", newAdminAddress1); - printf("\nnewAdmin_address2: %s", newAdminAddress2); - printf("\nnewAdmin_address3: %s", newAdminAddress3); - printf("\nPermille for development:%u Permille for Reinvesting:%u Permille for Computors:%u Permille for Holders:%u\n", result.dev_permille, result.reinvesting_permille, result.computor_permille, result.QCAPHolder_permille); - - printf("\nbanned_address1: %s", newBannedAddress1); - printf("\nbanned_address2: %s", newBannedAddress2); - printf("\nbanned_address3: %s", newBannedAddress3); - printf("\nunbanned_address1: %s", newUnbannedAddress1); - printf("\nunbanned_address2: %s", newUnbannedAddress2); - printf("\nunbanned_address3: %s", newUnbannedAddress3); -} - -void submitBannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - submitBannedAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.bannedAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SUBMITBANNEDADDRESS; - packet.transaction.inputSize = sizeof(submitBannedAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitBannedAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitBannedAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("submitBannedAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void saveBannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - saveBannedAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.bannedAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SAVEBANNEDADDRESS; - packet.transaction.inputSize = sizeof(saveBannedAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(saveBannedAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(saveBannedAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("saveBannedAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void submitUnbannedannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - submitUnbannedAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.unbannedAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SUBMITUNBANNEDADDRESS; - packet.transaction.inputSize = sizeof(submitUnbannedAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitUnbannedAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(submitUnbannedAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("submitUnbannedannedAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); -} - -void saveUnbannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity) -{ - auto qc = make_qc(nodeIp, nodePort); - - uint8_t publicKey[32] = {0}; - getPublicKeyFromIdentity(identity, publicKey); - - uint8_t privateKey[32] = {0}; - uint8_t sourcePublicKey[32] = {0}; - uint8_t destPublicKey[32] = {0}; - uint8_t subseed[32] = {0}; - uint8_t digest[32] = {0}; - uint8_t signature[64] = {0}; - char publicIdentity[128] = {0}; - char txHash[128] = {0}; - getSubseedFromSeed((uint8_t*)seed, subseed); - getPrivateKeyFromSubSeed(subseed, privateKey); - getPublicKeyFromPrivateKey(privateKey, sourcePublicKey); - const bool isLowerCase = false; - getIdentityFromPublicKey(sourcePublicKey, publicIdentity, isLowerCase); - ((uint64_t*)destPublicKey)[0] = QVAULT_CONTRACT_INDEX; - ((uint64_t*)destPublicKey)[1] = 0; - ((uint64_t*)destPublicKey)[2] = 0; - ((uint64_t*)destPublicKey)[3] = 0; - - struct { - RequestResponseHeader header; - Transaction transaction; - unblockBannedAddress_input input; - unsigned char signature[64]; - } packet; - - memcpy(packet.input.unbannedAddress, publicKey, 32); - - packet.transaction.amount = 0; - memcpy(packet.transaction.sourcePublicKey, sourcePublicKey, 32); - memcpy(packet.transaction.destinationPublicKey, destPublicKey, 32); - uint32_t currentTick = getTickNumberFromNode(qc); - packet.transaction.tick = currentTick + scheduledTickOffset; - packet.transaction.inputType = QVAULT_SAVEUNBANNEDADDRESS; - packet.transaction.inputSize = sizeof(unblockBannedAddress_input); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(unblockBannedAddress_input), - digest, - 32); - sign(subseed, sourcePublicKey, digest, signature); - memcpy(packet.signature, signature, 64); - packet.header.setSize(sizeof(packet)); - packet.header.zeroDejavu(); - packet.header.setType(BROADCAST_TRANSACTION); - qc->sendData((uint8_t *) &packet, packet.header.size()); - KangarooTwelve((unsigned char*)&packet.transaction, - sizeof(packet.transaction) + sizeof(unblockBannedAddress_input) + SIGNATURE_SIZE, - digest, - 32); // recompute digest for txhash - getTxHashFromDigest(digest, txHash); - LOG("saveUnbannedAddress tx has been sent!\n"); - printReceipt(packet.transaction, txHash, nullptr); - LOG("run ./qubic-cli [...] -checktxontick %u %s\n", currentTick + scheduledTickOffset, txHash); - LOG("to check your tx confirmation status\n"); + printf("returnCode: %d\namount: %" PRIu64 "\n", result.returnCode, result.amount); } \ No newline at end of file diff --git a/qvault.h b/qvault.h index 0c3852a..aec116c 100644 --- a/qvault.h +++ b/qvault.h @@ -4,54 +4,486 @@ // SC structs +struct GPInfo // General proposal +{ + uint8_t proposer[32]; + uint32_t currentTotalVotingPower; + uint32_t numberOfYes; + uint32_t numberOfNo; + uint32_t proposedEpoch; + uint32_t currentQuorumPercent; + uint8_t url[256]; + uint8_t result; // 0 is the passed proposal, 1 is the rejected proposal. 2 is the insufficient quorum. +}; + +struct QCPInfo // Quorum change proposal +{ + uint8_t proposer[32]; + uint32_t currentTotalVotingPower; + uint32_t numberOfYes; + uint32_t numberOfNo; + uint32_t proposedEpoch; + uint32_t currentQuorumPercent; + uint32_t newQuorumPercent; + uint8_t url[256]; + uint8_t result; // 0 is the passed proposal, 1 is the rejected proposal. 2 is the insufficient quorum. +}; + +struct IPOPInfo // IPO participation +{ + uint8_t proposer[32]; + uint64_t totalWeight; + uint64_t assignedFund; + uint32_t currentTotalVotingPower; + uint32_t numberOfYes; + uint32_t numberOfNo; + uint32_t proposedEpoch; + uint32_t ipoContractIndex; + uint32_t currentQuorumPercent; + uint8_t url[256]; + uint8_t result; // 0 is the passed proposal, 1 is the rejected proposal. 2 is the insufficient quorum. 3 is the insufficient invest funds. +}; + +struct QEarnPInfo // Qearn participation proposal +{ + uint8_t proposer[32]; + uint64_t amountOfInvestPerEpoch; + uint64_t assignedFundPerEpoch; + uint32_t currentTotalVotingPower; + uint32_t numberOfYes; + uint32_t numberOfNo; + uint32_t proposedEpoch; + uint32_t currentQuorumPercent; + uint8_t url[256]; + uint8_t numberOfEpoch; + uint8_t result; // 0 is the passed proposal, 1 is the rejected proposal. 2 is the insufficient quorum. 3 is the insufficient funds. +}; + +struct FundPInfo // Fundraising proposal +{ + uint8_t proposer[32]; + uint64_t pricePerOneQcap; + uint32_t currentTotalVotingPower; + uint32_t numberOfYes; + uint32_t numberOfNo; + uint32_t amountOfQcap; + uint32_t restSaleAmount; + uint32_t proposedEpoch; + uint32_t currentQuorumPercent; + uint8_t url[256]; + uint8_t result; // 0 is the passed proposal, 1 is the rejected proposal. 2 is the insufficient quorum. +}; + +struct MKTPInfo // Marketplace proposal +{ + uint8_t proposer[32]; + uint64_t amountOfQubic; + uint64_t shareName; + uint32_t currentTotalVotingPower; + uint32_t numberOfYes; + uint32_t numberOfNo; + uint32_t amountOfQcap; + uint32_t currentQuorumPercent; + uint32_t proposedEpoch; + uint32_t shareIndex; + uint32_t amountOfShare; + uint8_t url[256]; + uint8_t result; // 0 is the passed proposal, 1 is the rejected proposal. 2 is the insufficient quorum. 3 is the insufficient funds. 4 is the insufficient Qcap. +}; + +struct AlloPInfo +{ + uint8_t proposer[32]; + uint32_t currentTotalVotingPower; + uint32_t numberOfYes; + uint32_t numberOfNo; + uint32_t proposedEpoch; + uint32_t currentQuorumPercent; + uint32_t reinvested; + uint32_t distributed; + uint32_t burnQcap; + uint8_t url[256]; + uint8_t result; // 0 is the passed proposal, 1 is the rejected proposal. 2 is the insufficient quorum. +}; + struct QVaultGetData_input { - uint32_t t; }; struct QVaultGetData_output { - uint64_t numberOfBannedAddress; - uint32_t computor_permille; - uint32_t QCAPHolder_permille; - uint32_t reinvesting_permille; - uint32_t dev_permille; - uint8_t AUTH_ADDRESS1[32]; - uint8_t AUTH_ADDRESS2[32]; - uint8_t AUTH_ADDRESS3[32]; - uint8_t Reinvesting_address[32]; - uint8_t admin_address[32]; - uint8_t newAuthAddress1[32]; - uint8_t newAuthAddress2[32]; - uint8_t newAuthAddress3[32]; - uint8_t newReinvesting_address1[32]; - uint8_t newReinvesting_address2[32]; - uint8_t newReinvesting_address3[32]; - uint8_t newAdmin_address1[32]; - uint8_t newAdmin_address2[32]; - uint8_t newAdmin_address3[32]; - uint8_t bannedAddress1[32]; - uint8_t bannedAddress2[32]; - uint8_t bannedAddress3[32]; - uint8_t unbannedAddress1[32]; - uint8_t unbannedAddress2[32]; - uint8_t unbannedAddress3[32]; - - static constexpr unsigned char type() - { - return RespondContractFunction::type(); - } -}; - -void submitAuthAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); -void changeAuthAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t numberOfChangedAddress); -void submitFees(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t newQCAPHolder_fee, uint32_t newreinvesting_fee, uint32_t newdev_fee); -void changeFees(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t newQCAPHolder_fee, uint32_t newreinvesting_fee, uint32_t newdev_fee); -void submitReinvestingAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); -void changeReinvestingAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); -void submitAdminAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); -void changeAdminAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); + int32_t returnCode; + uint64_t totalVotingPower; + uint64_t proposalCreateFund; + uint64_t reinvestingFund; + uint64_t totalEpochRevenue; + uint64_t fundForBurn; + uint64_t totalStakedQcapAmount; + uint64_t qcapMarketCap; + uint64_t raisedFundByQcap; + uint64_t lastRoundPriceOfQcap; + uint64_t revenueByQearn; + uint32_t qcapSoldAmount; + uint32_t shareholderDividend; + uint32_t QCAPHolderPermille; + uint32_t reinvestingPermille; + uint32_t burnPermille; + uint32_t qcapBurnPermille; + uint32_t numberOfStaker; + uint32_t numberOfVotingPower; + uint32_t numberOfGP; + uint32_t numberOfQCP; + uint32_t numberOfIPOP; + uint32_t numberOfQEarnP; + uint32_t numberOfFundP; + uint32_t numberOfMKTP; + uint32_t numberOfAlloP; + uint32_t transferRightsFee; + uint32_t minQuorumRq; + uint32_t maxQuorumRq; + uint32_t totalQcapBurntAmount; + uint32_t circulatingSupply; + uint32_t quorumPercent; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetStakedAmountAndVotingPower_input +{ + uint8_t address[32]; +}; + +struct QvaultGetStakedAmountAndVotingPower_output +{ + int32_t returnCode; + uint32_t stakedAmount; + uint32_t votingPower; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetGP_input +{ + uint32_t proposalId; +}; + +struct QvaultGetGP_output +{ + int32_t returnCode; + int32_t _padding; + GPInfo proposal; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetQCP_input +{ + uint32_t proposalId; +}; + +struct QvaultGetQCP_output +{ + int32_t returnCode; + int32_t _padding1; + QCPInfo proposal; + int32_t _padding2; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetIPOP_input +{ + uint32_t proposalId; +}; + +struct QvaultGetIPOP_output +{ + int32_t returnCode; + IPOPInfo proposal; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetQEarnP_input +{ + uint32_t proposalId; +}; + +struct QvaultGetQEarnP_output +{ + int32_t returnCode; + QEarnPInfo proposal; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetFundP_input +{ + uint32_t proposalId; +}; + +struct QvaultGetFundP_output +{ + int32_t returnCode; + FundPInfo proposal; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetMKTP_input +{ + uint32_t proposalId; +}; + +struct QvaultGetMKTP_output +{ + int32_t returnCode; + MKTPInfo proposal; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetAlloP_input +{ + uint32_t proposalId; +}; + +struct QvaultGetAlloP_output +{ + int32_t returnCode; + int32_t _padding1; + AlloPInfo proposal; + int32_t _padding2; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetIdentitiesHvVtPw_input +{ + uint32_t offset; + uint32_t count; +}; + +struct stakingInfo +{ + uint8_t stakerAddress[32]; + uint32_t amount; +}; + +struct QvaultGetIdentitiesHvVtPw_output +{ + int32_t returnCode; + uint8_t idList[256][32]; + uint32_t amountList[256]; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultppCreationPower_input +{ + uint8_t address[32]; +}; + +struct QvaultppCreationPower_output +{ + int32_t returnCode; + uint8_t status; // 0 means that there is no the proposal creation power, 1 means that there is. + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetQcapBurntAmountInLastEpoches_input +{ + uint32_t numberOfLastEpoches; +}; + +struct QvaultGetQcapBurntAmountInLastEpoches_output +{ + int32_t returnCode; + uint32_t burntAmount; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetAmountToBeSoldPerYear_input +{ + uint32_t year; +}; + +struct QvaultGetAmountToBeSoldPerYear_output +{ + uint32_t amount; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetTotalRevenueInQcap_input +{ +}; + +struct QvaultGetTotalRevenueInQcap_output +{ + uint64_t revenue; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetRevenueInQcapPerEpoch_input +{ + uint32_t epoch; +}; + +struct QvaultGetRevenueInQcapPerEpoch_output +{ + uint64_t epochTotalRevenue; + uint64_t epochOneQcapRevenue; + uint64_t epochOneQvaultRevenue; + uint64_t epochReinvestAmount; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetRevenuePerShare_input +{ + uint32_t contractIndex; +}; + +struct QvaultGetRevenuePerShare_output +{ + uint64_t revenue; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct qpiAsset +{ + uint8_t issuer[32]; + uint64_t assetName; +}; + +struct QvaultGetAmountOfShareQvaultHold_input +{ + qpiAsset assetInfo; +}; + +struct QvaultGetAmountOfShareQvaultHold_output +{ + uint32_t amount; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetNumberOfHolderAndAvgAm_input +{ +}; + +struct QvaultGetNumberOfHolderAndAvgAm_output +{ + int32_t returnCode; + uint32_t numberOfQcapHolder; + uint32_t avgAmount; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +struct QvaultGetAmountForQearnInUpcomingEpoch_input +{ + uint32_t epoch; +}; + +struct QvaultGetAmountForQearnInUpcomingEpoch_output +{ + int32_t returnCode; + uint64_t amount; + + static constexpr unsigned char type() + { + return RespondContractFunction::type(); + } +}; + +void stake(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t amount); +void unStake(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t amount); +void submitGP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* url); +void submitQCP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t newQuorumPercent, const char* url); +void submitIPOP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t ipoContractIndex, const char* url); +void submitQEarnP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t amountPerEpoch, uint32_t numberOfEpoch, const char* url); +void submitFundP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t priceOfOneQcap, uint32_t amountOfQcap, const char* url); +void submitMKTP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t amountOfQubic, const char* shareName, uint32_t amountOfQcap, uint32_t indexOfShare, uint32_t amountOfShare, const char* url); +void submitAlloP(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t reinvested, uint32_t burn, uint32_t distribute, const char* url); +void voteInProposal(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint64_t priceOfIPO, uint32_t proposalType, uint32_t proposalId, bool yes); +void buyQcap(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, uint32_t amount, uint64_t priceOfOneQcap); +void TransferShareManagementRights(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* issuer, const char* assetName, int64_t numberOfShares, uint32_t newManagingContractIndex); + void getData(const char* nodeIp, int nodePort); -void submitBannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); -void saveBannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); -void submitUnbannedannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); -void saveUnbannedAddress(const char* nodeIp, int nodePort, const char* seed, uint32_t scheduledTickOffset, const char* identity); +void getStakedAmountAndVotingPower(const char* nodeIp, int nodePort, const char* address); +void getGP(const char* nodeIp, int nodePort, uint32_t proposalId); +void getQCP(const char* nodeIp, int nodePort, uint32_t proposalId); +void getIPOP(const char* nodeIp, int nodePort, uint32_t proposalId); +void getQEarnP(const char* nodeIp, int nodePort, uint32_t proposalId); +void getFundP(const char* nodeIp, int nodePort, uint32_t proposalId); +void getMKTP(const char* nodeIp, int nodePort, uint32_t proposalId); +void getAlloP(const char* nodeIp, int nodePort, uint32_t proposalId); +void getIdentitiesHvVtPw(const char* nodeIp, int nodePort, uint32_t offset, uint32_t count); +void ppCreationPower(const char* nodeIp, int nodePort, const char* address); +void getQcapBurntAmountInLastEpoches(const char* nodeIp, int nodePort, uint32_t numberOfLastEpoches); +void getAmountToBeSoldPerYear(const char* nodeIp, int nodePort, uint32_t year); +void getTotalRevenueInQcap(const char* nodeIp, int nodePort); +void getRevenueInQcapPerEpoch(const char* nodeIp, int nodePort, uint32_t epoch); +void getRevenuePerShare(const char* nodeIp, int nodePort, uint32_t contractIndex); +void getAmountOfShareQvaultHold(const char* nodeIp, int nodePort, const char* assetName, const char* issuer); +void getNumberOfHolderAndAvgAm(const char* nodeIp, int nodePort); +void getAmountForQearnInUpcomingEpoch(const char* nodeIp, int nodePort, uint32_t epoch); diff --git a/structs.h b/structs.h index 9445d49..70f0a7d 100644 --- a/structs.h +++ b/structs.h @@ -81,19 +81,37 @@ enum COMMAND QEARN_GET_STATE_OF_ROUND, QEARN_GET_USER_LOCK_STATUS, QEARN_GET_UNLOCKING_STATUS, - QVAULT_SUBMIT_AUTH_ADDRESS, - QVAULT_CHANGE_AUTH_ADDRESS, - QVAULT_SUBMIT_FEES, - QVAULT_CHANGE_FEES, - QVAULT_SUBMIT_REINVESTING_ADDRESS, - QVAULT_CHANGE_REINVESTING_ADDRESS, - QVAULT_GET_DATA, - QVAULT_SUBMIT_ADMIN_ADDRESS, - QVAULT_CHANGE_ADMIN_ADDRESS, - QVAULT_SUBMIT_BANNED_ADDRESS, - QVAULT_SAVE_BANNED_ADDRESS, - QVAULT_SUBMIT_UNBANNED_ADDRESS, - QVAULT_SAVE_UNBANNED_ADDRESS, + QVAULT_COMMAND_GETDATA, + QVAULT_COMMAND_GET_STAKED_AMOUNT_AND_VOTING_POWER, + QVAULT_COMMAND_GET_GP, + QVAULT_COMMAND_GET_QCP, + QVAULT_COMMAND_GET_IPOP, + QVAULT_COMMAND_GET_QEARNP, + QVAULT_COMMAND_GET_FUNDP, + QVAULT_COMMAND_GET_MKTP, + QVAULT_COMMAND_GET_ALLOP, + QVAULT_COMMAND_GET_IDENTITIES_HV_VT_PW, + QVAULT_COMMAND_GET_PP_CREATION_POWER, + QVAULT_COMMAND_GET_QCAP_BURNT_AMOUNT_IN_LAST_EPOCHES, + QVAULT_COMMAND_GET_AMOUNT_TO_BE_SOLD_PER_YEAR, + QVAULT_COMMAND_GET_TOTAL_REVENUE_IN_QCAP, + QVAULT_COMMAND_GET_REVENUE_IN_QCAP_PER_EPOCH, + QVAULT_COMMAND_GET_REVENUE_PER_SHARE, + QVAULT_COMMAND_GET_AMOUNT_OF_SHARE_QVAULT_HOLD, + QVAULT_COMMAND_GET_NUMBER_OF_HOLDER_AND_AVG_AM, + QVAULT_COMMAND_GET_AMOUNT_FOR_QEARN_IN_UPCOMING_EPOCH, + QVAULT_COMMAND_STAKE, + QVAULT_COMMAND_UNSTAKE, + QVAULT_COMMAND_SUBMIT_GP, + QVAULT_COMMAND_SUBMIT_QCP, + QVAULT_COMMAND_SUBMIT_IPOP, + QVAULT_COMMAND_SUBMIT_QEARNP, + QVAULT_COMMAND_SUBMIT_FUNDP, + QVAULT_COMMAND_SUBMIT_MKTP, + QVAULT_COMMAND_SUBMIT_ALLOP, + QVAULT_COMMAND_VOTE_IN_PROPOSAL, + QVAULT_COMMAND_BUY_QCAP, + QVAULT_COMMAND_TRANSFER_SHARE_MANAGEMENT_RIGHTS, QEARN_GET_STATS_PER_EPOCH, QEARN_GET_BURNED_AND_BOOSTED_STATS, QEARN_GET_BURNED_AND_BOOSTED_STATS_PER_EPOCH,