]> Git Repo - VerusCoin.git/commitdiff
Cross chain send fixes
authormiketout <[email protected]>
Tue, 27 Apr 2021 03:09:48 +0000 (20:09 -0700)
committermiketout <[email protected]>
Tue, 27 Apr 2021 03:09:48 +0000 (20:09 -0700)
src/pbaas/notarization.cpp
src/pbaas/pbaas.cpp
src/pbaas/pbaas.h
src/rpc/pbaasrpc.cpp

index 4dabf001b4bc826e4eccd75bbfa1d1535061f028..1aba94cd0081d703c478cb84f125b61b55f652ce 100644 (file)
@@ -469,7 +469,7 @@ bool CPBaaSNotarization::NextNotarizationInfo(const CCurrencyDefinition &sourceS
         // maximum pre-conversions
         else if (reserveTransfer.IsPreConversion())
         {
-            if (lastExportHeight >= destCurrency.startBlock)
+            if (lastExportHeight >= (destCurrency.startBlock - 1))
             {
                 //printf("%s: Invalid pre-conversion, mined after start block\n", __func__);
                 LogPrintf("%s: Invalid pre-conversion, mined after start block\n", __func__);
@@ -491,7 +491,8 @@ bool CPBaaSNotarization::NextNotarizationInfo(const CCurrencyDefinition &sourceS
         }
         else if (reserveTransfer.IsConversion())
         {
-            if (!newNotarization.currencyState.IsLaunchCompleteMarker())
+            if (!((destCurrency.systemID != sourceSystemID && newNotarization.IsLaunchCleared()) || 
+                  newNotarization.currencyState.IsLaunchCompleteMarker()))
             {
                 //printf("%s: Invalid conversion, mined before start block\n", __func__);
                 LogPrintf("%s: Invalid conversion, mined before start block\n", __func__);
@@ -636,19 +637,27 @@ bool CPBaaSNotarization::NextNotarizationInfo(const CCurrencyDefinition &sourceS
         newNotarization.currencyState.SetLaunchCompleteMarker();
         newNotarization.currencyState.SetLaunchClear(false);
 
+        CCurrencyDefinition destSystem;
+
         if (destCurrency.systemID != ASSETCHAINS_CHAINID)
         {
+            destSystem = ConnectedChains.GetCachedCurrency(destCurrency.systemID);
             newNotarization.SetSameChain(false);
         }
+        else
+        {
+            destSystem = ConnectedChains.ThisChain();
+        }
 
         // calculate new state from processing all transfers
         // we are not refunding, and it is possible that we also have
         // normal conversions in addition to pre-conversions. add any conversions that may 
         // be present into the new currency state
+        CCoinbaseCurrencyState intermediateState = newNotarization.currencyState;
         bool isValidExport = rtxd.AddReserveTransferImportOutputs(sourceSystem, 
-                                                                  ConnectedChains.ThisChain(),
+                                                                  destSystem,
                                                                   destCurrency, 
-                                                                  currencyState, 
+                                                                  intermediateState, 
                                                                   exportTransfers, 
                                                                   dummyImportOutputs, 
                                                                   importedCurrency,
@@ -668,7 +677,7 @@ bool CPBaaSNotarization::NextNotarizationInfo(const CCurrencyDefinition &sourceS
             tempCurState.viaConversionPrice = newNotarization.currencyState.viaConversionPrice;
             rtxd = CReserveTransactionDescriptor();
             isValidExport = rtxd.AddReserveTransferImportOutputs(sourceSystem, 
-                                                                 ConnectedChains.ThisChain(),
+                                                                 destSystem,
                                                                  destCurrency, 
                                                                  tempCurState, 
                                                                  exportTransfers, 
index 1bda4fd2a37cdaf99bc9c92c41b0eb91b10f1862..592b10f29a836a0ad0c8caf50f8c8a99aa9aecf3 100644 (file)
@@ -2959,7 +2959,7 @@ bool CConnectedChains::CreateNextExport(const CCurrencyDefinition &_curDef,
     bool crossSystem = destSystemID != ASSETCHAINS_CHAINID;
     bool isPreLaunch = _curDef.launchSystemID == ASSETCHAINS_CHAINID &&
                        _curDef.startBlock > sinceHeight &&
-                       !(_curDef.systemID == ASSETCHAINS_CHAINID && sinceHeight == (_curDef.startBlock - 1) && curHeight > _curDef.startBlock);
+                       !lastNotarization.IsLaunchCleared();
     bool isClearLaunchExport = isPreLaunch && curHeight >= _curDef.startBlock && !lastNotarization.IsLaunchCleared();
 
     if (!isClearLaunchExport && !_txInputs.size() && !addInputTx)
index 3d92b7969d7bbba7f497f5b7e3521f207671d59e..52d7470440c99bee046c14798daaf5be94fa77df 100644 (file)
@@ -846,7 +846,7 @@ public:
         BLOCK_NOTARIZATION_MODULO = 10,                 // incentive to earn one valid notarization during this many blocks
         MIN_BLOCKS_BEFORE_NOTARY_FINALIZED = 15,        // 15 blocks must go by before notary signatures or confirming evidence can be provided
         MAX_NODES = 2,                                  // only provide 2 nodes per notarization
-        MIN_NOTARIZATION_OUTPUT = 0,                    // inimum amount for notarization output
+        MIN_NOTARIZATION_OUTPUT = 0,                    // minimum amount for notarization output
     };
     //static const int FINAL_CONFIRMATIONS = 10;
     //static const int MIN_BLOCKS_BETWEEN_NOTARIZATIONS = 8;
index 053536d0fa0a5ef659304f85eb73f7c2942c531b..ae77129564b55d2ccbcc0b418b8a7aaac12e12ed 100644 (file)
@@ -3652,16 +3652,19 @@ UniValue sendcurrency(const UniValue& params, bool fHelp)
                 }
                 else if (convertToCurrencyID.IsNull())
                 {
-                    convertToCurrencyID = exportSystemDef.GatewayConverterID();
+                    convertToCurrencyID = exportToCurrencyDef.GetID();
                     if (convertToCurrencyID.IsNull())
                     {
                         throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid fee currency for system destination without fee converter.");
                     }
                     // get gateway converter and set as fee converter/exportto currency
-                    convertToCurrencyDef = ConnectedChains.GetCachedCurrency(convertToCurrencyID);
+                    convertToCurrencyDef = exportToCurrencyDef;
+                    bool toCurrencyIsFractional = convertToCurrencyDef.IsFractional();
                     if (!convertToCurrencyDef.IsValid() ||
-                        convertToCurrencyDef.GetCurrenciesMap().count(feeCurrencyID) || 
-                        convertToCurrencyDef.GetID() == feeCurrencyID)
+                        (!((convertToCurrencyDef.IsPBaaSChain() && (feeCurrencyID == destSystemDef.launchSystemID || 
+                            feeCurrencyID == destSystemID))) &&
+                         !(toCurrencyIsFractional && convertToCurrencyDef.GetCurrenciesMap().count(feeCurrencyID) || 
+                            convertToCurrencyDef.GetID() == feeCurrencyID)))
                     {
                         throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid fee currency for system destination.");
                     }
@@ -3770,7 +3773,7 @@ UniValue sendcurrency(const UniValue& params, bool fHelp)
                 {
                     flags |= CReserveTransfer::PRECONVERT;
                 }
-                if (!burnCurrency && !convertToCurrencyID.IsNull())
+                if (isConversion && !burnCurrency && !convertToCurrencyID.IsNull())
                 {
                     flags |= CReserveTransfer::CONVERT;
                 }
This page took 0.034871 seconds and 4 git commands to generate.