]> Git Repo - VerusCoin.git/commitdiff
Separate currency and chain launch fees and increase chain launch fees for first...
authormiketout <[email protected]>
Tue, 27 Apr 2021 19:48:06 +0000 (12:48 -0700)
committermiketout <[email protected]>
Tue, 27 Apr 2021 19:48:06 +0000 (12:48 -0700)
src/core_write.cpp
src/pbaas/crosschainrpc.cpp
src/pbaas/crosschainrpc.h
src/pbaas/reserves.cpp
src/rpc/pbaasrpc.cpp
src/wallet/rpcwallet.cpp

index d71f4e5dcf77cf6d29cf802e52ef65e63b8673d6..54ed68992ae6cce68b7dc1e36f98f39e6a08e006 100644 (file)
@@ -775,12 +775,7 @@ UniValue CCurrencyDefinition::ToUniValue() const
     if (IsFractional())
     {
         obj.push_back(Pair("initialsupply", ValueFromAmount(initialFractionalSupply)));
-        CAmount carveOut = 0;
-        for (auto oneCarveOut : preLaunchCarveOuts)
-        {
-            carveOut += preLaunchCarveOuts.begin()->second;
-        }
-        obj.push_back(Pair("prelaunchcarveout", ValueFromAmount(carveOut)));
+        obj.push_back(Pair("prelaunchcarveout", ValueFromAmount(preLaunchCarveOut)));
     }
 
     if (preAllocation.size())
index f895971abe121bd57ee480add374dd906a93098e..028edcbfaf13e2e72d4423e04be78527bacd1cea 100644 (file)
@@ -422,6 +422,7 @@ CCurrencyDefinition::CCurrencyDefinition(const UniValue &obj) :
     idReferralLevels(DEFAULT_ID_REFERRAL_LEVELS),
     idImportFees(IDENTITY_IMPORT_FEE),
     currencyRegistrationFee(CURRENCY_REGISTRATION_FEE),
+    pbaasSystemLaunchFee(PBAAS_SYSTEM_LAUNCH_FEE),
     currencyImportFee(CURRENCY_IMPORT_FEE),
     transactionImportFee(TRANSACTION_TRANSFER_FEE >> 1),
     transactionExportFee(TRANSACTION_TRANSFER_FEE >> 1)
@@ -551,50 +552,7 @@ CCurrencyDefinition::CCurrencyDefinition(const UniValue &obj) :
                     nVersion = PBAAS_VERSION_INVALID;
                 }
 
-                UniValue preLaunchCarveoutsUni = find_value(obj, "prelaunchcarveouts");
-                int32_t preLaunchCarveOutTotal = 0;
-                if (nVersion != PBAAS_VERSION_INVALID && preLaunchCarveoutsUni.isArray())
-                {
-                    for (int i = 0; i < preLaunchCarveoutsUni.size(); i++)
-                    {
-                        std::vector<std::string> preLaunchCarveOutKey = preLaunchCarveoutsUni[i].getKeys();
-                        std::vector<UniValue> preLaunchCarveOutValue = preLaunchCarveoutsUni[i].getValues();
-                        if (preLaunchCarveOutKey.size() != 1 || preLaunchCarveOutValue.size() != 1)
-                        {
-                            LogPrintf("%s: each prelaunchcarveouts entry must contain one destination identity and one amount\n", __func__);
-                            printf("%s: each prelaunchcarveouts entry must contain one destination identity and one amount\n", __func__);
-                            nVersion = PBAAS_VERSION_INVALID;
-                            break;
-                        }
-
-                        CTxDestination carveOutDest = DecodeDestination(preLaunchCarveOutKey[0]);
-
-                        if (carveOutDest.which() != COptCCParams::ADDRTYPE_ID && !(carveOutDest.which() == COptCCParams::ADDRTYPE_INVALID && preLaunchCarveoutsUni.size() == 1))
-                        {
-                            LogPrintf("%s: prelaunchcarveouts destination must be an identity\n", __func__);
-                            nVersion = PBAAS_VERSION_INVALID;
-                            break;
-                        }
-
-                        CAmount carveOutAmount = AmountFromValueNoErr(preLaunchCarveOutValue[0]);
-                        if (carveOutAmount <= 0)
-                        {
-                            LogPrintf("%s: prelaunchcarveouts values must be greater than zero\n", __func__);
-                            nVersion = PBAAS_VERSION_INVALID;
-                            break;
-                        }
-                        preLaunchCarveOutTotal += carveOutAmount;
-                        if (preLaunchDiscount < 0 || 
-                            preLaunchDiscount >= SATOSHIDEN ||
-                            CCurrencyDefinition::CalculateRatioOfValue((totalReserveWeight - preLaunchCarveOutTotal), SATOSHIDEN - preLaunchDiscount) >= SATOSHIDEN)
-                        {
-                            LogPrintf("%s: prelaunchcarveouts values and discounts must total less than 1\n", __func__);
-                            nVersion = PBAAS_VERSION_INVALID;
-                            break;
-                        }
-                        preLaunchCarveOuts.push_back(make_pair(CIdentityID(GetDestinationID(carveOutDest)), preLaunchCarveOutTotal));
-                    }
-                }
+                int32_t preLaunchCarveOutTotal = AmountFromValue(find_value(obj, "prelaunchcarveout"));
 
                 // if weights are defined, use them as relative ratios of each member currency
                 if (weightArr.isArray() && weightArr.size())
@@ -854,6 +812,7 @@ CCurrencyDefinition::CCurrencyDefinition(const UniValue &obj) :
         if (vEras.size())
         {
             currencyRegistrationFee = uni_get_int64(find_value(obj, "currencyregistrationfee"), currencyRegistrationFee);
+            pbaasSystemLaunchFee = uni_get_int64(find_value(obj, "pbaassystemregistrationfee"), pbaasSystemLaunchFee);
             currencyImportFee = uni_get_int64(find_value(obj, "currencyimportfee"), currencyImportFee);
             transactionImportFee = uni_get_int64(find_value(obj, "transactionimportfee"), transactionImportFee);
             transactionExportFee = uni_get_int64(find_value(obj, "transactionexportfee"), transactionExportFee);
@@ -908,16 +867,6 @@ int64_t CCurrencyDefinition::GetTotalPreallocation() const
 // this will only return an accurate result after total preconversion has been updated and before any emission
 int32_t CCurrencyDefinition::GetTotalCarveOut() const
 {
-    int32_t totalCarveOut = 0;
-    for (auto &oneCarveOut : preLaunchCarveOuts)
-    {
-        totalCarveOut += oneCarveOut.second;
-        if (oneCarveOut.second < 0 || oneCarveOut.second > SATOSHIDEN || totalCarveOut > SATOSHIDEN)
-        {
-            LogPrintf("%s: invalid carve out amount specified %d\n", __func__, oneCarveOut.second);
-            return 0;
-        }
-    }
-    return totalCarveOut;
+    return preLaunchCarveOut;
 }
 
index bba9768176fbe0873e08ceff6963552da1694f15..232f63a96358752e9581331724bc9a6b8450d9f7 100644 (file)
@@ -448,6 +448,7 @@ public:
     {
         TRANSACTION_TRANSFER_FEE = 2000000, // 0.02 destination currency per cross chain transfer total, chain's accept notary currency or have converter
         CURRENCY_REGISTRATION_FEE = 10000000000, // default 100 to register a currency
+        PBAAS_SYSTEM_LAUNCH_FEE = 1000000000000, // default 10000 to register and launch a PBaaS chain
         CURRENCY_IMPORT_FEE = 2000000000,   // default 100 to import a currency
         IDENTITY_REGISTRATION_FEE = 10000000000, // 100 to register an identity
         IDENTITY_IMPORT_FEE = 2000000000,   // 20 in native currency to import an identity
@@ -536,7 +537,7 @@ public:
     std::vector<int64_t> preconverted;      // actual converted amount if known
 
     int32_t preLaunchDiscount;              // if non-zero, a ratio of the initial supply instead of a fixed number is used to calculate total preallocation
-    std::vector<std::pair<uint160, int32_t>> preLaunchCarveOuts; // pre-launch carve-out recipients, from reserve contributions, taken from reserve percentage
+    int32_t preLaunchCarveOut;              // pre-launch carve-out amount as a ratio of satoshis, from reserve contributions, taken from reserve percentage
 
     // this section for gateways
     CTransferDestination nativeCurrencyID;  // ID of the currency in its native system (for gateways)
@@ -554,6 +555,7 @@ public:
 
     // costs to register and import currencies
     int64_t currencyRegistrationFee;        // cost in native currency to register a currency on this system
+    int64_t pbaasSystemLaunchFee;           // cost in native currency to register and launch a connected PBaaS chain on this system
     int64_t currencyImportFee;              // cost in native currency to import currency into this system (PBaaS or Gateway)
 
     int64_t transactionImportFee;           // how much to import a basic transaction
@@ -585,6 +587,7 @@ public:
                             idReferralLevels(DEFAULT_ID_REFERRAL_LEVELS),
                             idImportFees(IDENTITY_IMPORT_FEE),
                             currencyRegistrationFee(CURRENCY_REGISTRATION_FEE),
+                            pbaasSystemLaunchFee(PBAAS_SYSTEM_LAUNCH_FEE),
                             currencyImportFee(CURRENCY_IMPORT_FEE),
                             transactionImportFee(TRANSACTION_TRANSFER_FEE >> 1),
                             transactionExportFee(TRANSACTION_TRANSFER_FEE >> 1)
@@ -605,13 +608,14 @@ public:
                         int32_t StartBlock, int32_t EndBlock, int64_t InitialFractionalSupply, std::vector<std::pair<uint160, int64_t>> PreAllocation, 
                         int64_t ConverterIssuance, std::vector<uint160> Currencies, std::vector<int32_t> Weights, std::vector<int64_t> Conversions, 
                         std::vector<int64_t> MinPreconvert, std::vector<int64_t> MaxPreconvert, std::vector<int64_t> Contributions, 
-                        std::vector<int64_t> Preconverted, int32_t PreLaunchDiscount, std::vector<std::pair<uint160, int32_t>> PreLaunchCarveOuts,
+                        std::vector<int64_t> Preconverted, int32_t PreLaunchDiscount, int32_t PreLaunchCarveOut,
                         const CTransferDestination &NativeID, const uint160 &GatewayID,
                         const std::vector<uint160> &Notaries, int32_t MinNotariesConfirm,
                         const std::vector<int64_t> &chainRewards, const std::vector<int64_t> &chainRewardsDecay,
                         const std::vector<int32_t> &chainHalving, const std::vector<int32_t> &chainEraEnd,
                         const std::string &LaunchGatewayName,
                         int64_t TransactionTransferFee=TRANSACTION_TRANSFER_FEE, int64_t CurrencyRegistrationFee=CURRENCY_REGISTRATION_FEE,
+                        int64_t PBaaSSystemRegistrationFee=PBAAS_SYSTEM_LAUNCH_FEE,
                         int64_t CurrencyImportFee=CURRENCY_IMPORT_FEE, int64_t IDRegistrationAmount=IDENTITY_REGISTRATION_FEE, 
                         int32_t IDReferralLevels=DEFAULT_ID_REFERRAL_LEVELS, int64_t IDImportFee=IDENTITY_IMPORT_FEE,
                         uint32_t Version=VERSION_CURRENT) :
@@ -636,7 +640,7 @@ public:
                         contributions(Contributions),
                         preconverted(Preconverted),
                         preLaunchDiscount(PreLaunchDiscount),
-                        preLaunchCarveOuts(PreLaunchCarveOuts),
+                        preLaunchCarveOut(PreLaunchCarveOut),
                         nativeCurrencyID(NativeID),
                         gatewayID(GatewayID),
                         notaries(Notaries),
@@ -645,6 +649,7 @@ public:
                         idReferralLevels(IDReferralLevels),
                         idImportFees(IDImportFee),
                         currencyRegistrationFee(CurrencyRegistrationFee),
+                        pbaasSystemLaunchFee(PBaaSSystemRegistrationFee),
                         currencyImportFee(CurrencyImportFee),
                         transactionImportFee(TransactionTransferFee >> 1),
                         transactionExportFee(TransactionTransferFee >> 1),
@@ -689,7 +694,7 @@ public:
         READWRITE(contributions);
         READWRITE(preconverted);
         READWRITE(VARINT(preLaunchDiscount));
-        READWRITE(preLaunchCarveOuts);
+        READWRITE(preLaunchCarveOut);
         READWRITE(notaries);
         READWRITE(VARINT(minNotariesConfirm));
         READWRITE(VARINT(idRegistrationFees));
@@ -703,6 +708,7 @@ public:
                 READWRITE(gatewayID);
             }
             READWRITE(VARINT(currencyRegistrationFee));
+            READWRITE(VARINT(pbaasSystemLaunchFee));
             READWRITE(VARINT(currencyImportFee));
             READWRITE(VARINT(transactionImportFee));
             READWRITE(VARINT(transactionExportFee));
@@ -719,6 +725,7 @@ public:
             s << initZero;
             s << initZero;
             READWRITE(VARINT(currencyRegistrationFee));
+            READWRITE(VARINT(pbaasSystemLaunchFee));
             READWRITE(VARINT(currencyImportFee));
             READWRITE(VARINT(transactionImportFee));
             READWRITE(VARINT(transactionExportFee));
@@ -763,6 +770,11 @@ public:
         return currencyRegistrationFee;
     }
 
+    int64_t GetPBaaSLaunchFee() const
+    {
+        return pbaasSystemLaunchFee;
+    }
+
     uint160 GetID() const
     {
         uint160 Parent = parent;
index 6108c27836dfc767e2e2497d595ac40cb43d53da..5b3034488434e018268f8186b7ad5284612fd7ee 100644 (file)
@@ -2168,7 +2168,9 @@ bool CReserveTransactionDescriptor::AddReserveTransferImportOutputs(const CCurre
                 {
                     // we need to pay 1/2 of the launch cost for the launch system in launch fees
                     // remainder was paid when the currency is defined
-                    currencyRegistrationFee = systemSource.GetCurrencyRegistrationFee();
+                    currencyRegistrationFee = importCurrencyDef.IsPBaaSChain() || importCurrencyDef.IsGateway() ? 
+                                                systemSource.GetPBaaSLaunchFee() : 
+                                                systemSource.GetCurrencyRegistrationFee();
                     transferFees.valueMap[importCurrencyDef.launchSystemID] += currencyRegistrationFee;
                     AddReserveInput(importCurrencyDef.launchSystemID, currencyRegistrationFee);
                     if (importCurrencyDef.launchSystemID != systemDestID)
index 5fbd582fd52703a90793fb0ef4d147693720ab8c..01625f8cd86fad2b7cecbe20567bb20c455bb2ba 100644 (file)
@@ -4694,7 +4694,7 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
             "         \"initialcontributions\" : \"[\"xx.xx\",..]\", (list, optional) initial contribution in each currency\n"
             "         \"prelaunchdiscount\" : \"xx.xx\" (value, optional) for fractional reserve currencies less than 100%, discount on final price at launch"
             "         \"initialsupply\" : \"xx.xx\"    (value, required for fractional) supply after conversion of contributions, before preallocation\n"
-            "         \"prelaunchcarveouts\" : \"[{\"identity\":xx.xx}..]\", (list, optional) identities and % of pre-converted amounts from each reserve currency\n"
+            "         \"prelaunchcarveout\" : \"0.xx\", (value, optional) identities and % of pre-converted amounts from each reserve currency\n"
             "         \"preallocations\" : \"[{\"identity\":xx.xx}..]\", (list, optional)  list of identities and amounts from pre-allocation\n"
             "         \"gatewayconvertername\" : \"name\", (string, optional) if this is a PBaaS chain, this names a co-launched gateway converter currency\n"
 
@@ -5021,8 +5021,10 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
     cp = CCinit(&CC, EVAL_CROSSCHAIN_EXPORT);
     dests = std::vector<CTxDestination>({CPubKey(ParseHex(CC.CChexstr))});
 
-    CCurrencyValueMap launchFee(std::vector<uint160>({thisChainID}),
-                                std::vector<int64_t>({ConnectedChains.ThisChain().GetCurrencyRegistrationFee()}));
+    CAmount mainLaunchFee = newChain.IsPBaaSChain() || newChain.IsGateway() ? ConnectedChains.ThisChain().GetPBaaSLaunchFee() :
+                                                                                ConnectedChains.ThisChain().GetCurrencyRegistrationFee();
+    CCurrencyValueMap launchFee(std::vector<uint160>({thisChainID}), std::vector<int64_t>({mainLaunchFee}));
+
     CCrossChainExport ccx = CCrossChainExport(thisChainID, 0, height, newChain.systemID, newChainID, 0, launchFee, launchFee, uint256());
     ccx.SetChainDefinition();
     if (newCurrencyState.GetID() == ASSETCHAINS_CHAINID)
@@ -5192,8 +5194,10 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
         pk = CPubKey(ParseHex(CC.CChexstr));
         dests = std::vector<CTxDestination>({pk});
         CReserveDeposit launchDeposit = CReserveDeposit(newChainID, CCurrencyValueMap());
+        CAmount mainLaunchFee = newChain.IsPBaaSChain() || newChain.IsGateway() ? ConnectedChains.ThisChain().GetPBaaSLaunchFee() :
+                                                                                  ConnectedChains.ThisChain().GetCurrencyRegistrationFee();
         vOutputs.push_back({MakeMofNCCScript(CConditionObj<CReserveDeposit>(EVAL_RESERVE_DEPOSIT, dests, 1, &launchDeposit)), 
-                                            ConnectedChains.ThisChain().GetCurrencyRegistrationFee()
+                                            mainLaunchFee
                                             false});
     }
 
index 6a2c9f23552398341530ddd138408f3f0e379f8e..d4a762fa4b097c8f93e98ebca931879fcc73c9a2 100644 (file)
@@ -3278,21 +3278,6 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp)
 
     uint32_t height = chainActive.LastTip() ? chainActive.LastTip()->GetHeight() : 0;
 
-    if ((ConnectedChains.ThisChain().IsFractional() || ConnectedChains.ThisChain().startBlock < height) && 
-        ConnectedChains.ThisChain().currencies.size())
-    {
-        UniValue pricesInReserve(UniValue::VARR);
-        CCoinbaseCurrencyState thisCurState(ConnectedChains.GetCurrencyState(height));
-        std::vector<CAmount> prices(thisCurState.PricesInReserve());
-        for (int i = 0; i < thisCurState.currencies.size(); i++)
-        {
-            UniValue oneCurObj(UniValue::VOBJ);
-            oneCurObj.push_back(make_pair(ConnectedChains.GetCachedCurrency(thisCurState.currencies[i]).name, ValueFromAmount(prices[i])));
-            pricesInReserve.push_back(oneCurObj);
-        }
-        obj.push_back(Pair("prices", pricesInReserve));
-    }
-
     obj.push_back(Pair("txcount",       (int)pwalletMain->mapWallet.size()));
     obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
     obj.push_back(Pair("keypoolsize",   (int)pwalletMain->GetKeyPoolSize()));
This page took 0.03795 seconds and 4 git commands to generate.