@@ -852,6 +852,16 @@ bool CConnectedChains::CreateLatestImports(const CCurrencyDefinition ¤cyDe
852
852
// printf("rtxd.ReserveInputMap(): %s, ccx.totalAmounts: %s\n", rtxd.ReserveInputMap().ToUniValue().write().c_str(), ccx.totalAmounts.ToUniValue().write().c_str());
853
853
// printf("leftoverCurrency: %s\n", leftoverCurrency.ToUniValue().write().c_str());
854
854
855
+ // printf("totalNativeInput: %s, leftoverCurrency:%s\n", ValueFromAmount(totalNativeInput).write().c_str(), leftoverCurrency.ToUniValue().write().c_str());
856
+ if ((availableCurrencyInput - (rtxd.ReserveInputMap () + CCurrencyValueMap (std::vector<uint160>({systemID}), std::vector<CAmount>({rtxd.nativeIn })))).HasNegative ())
857
+ {
858
+ LogPrintf (" %s: ERROR - importing more currency than available for %s\n " , __func__, currencyDef.name .c_str ());
859
+ LogPrintf (" totalNativeInput: %s, leftoverCurrency:%s\n " , ValueFromAmount (totalNativeInput).write ().c_str (), leftoverCurrency.ToUniValue ().write ().c_str ());
860
+ printf (" %s: ERROR - importing more currency than available for %s\n " , __func__, currencyDef.name .c_str ());
861
+ printf (" totalNativeInput: %s, rtxd.ReserveInputMap(): %s, leftoverCurrency:%s\n " , ValueFromAmount (totalNativeInput).write ().c_str (), rtxd.ReserveInputMap ().ToUniValue ().write ().c_str (), leftoverCurrency.ToUniValue ().write ().c_str ());
862
+ return false ;
863
+ }
864
+
855
865
// breakout native from leftover currency
856
866
availableCurrencyInput = leftoverCurrency;
857
867
totalNativeInput = leftoverCurrency.valueMap [systemID];
@@ -870,16 +880,6 @@ bool CConnectedChains::CreateLatestImports(const CCurrencyDefinition ¤cyDe
870
880
871
881
newImportTx.vout [0 ] = CTxOut (totalNativeInput, MakeMofNCCScript (CConditionObj<CCrossChainImport>(EVAL_CROSSCHAIN_IMPORT, dests, 1 , &cci), &indexDests));
872
882
873
- // printf("totalNativeInput: %s, leftoverCurrency:%s\n", ValueFromAmount(totalNativeInput).write().c_str(), leftoverCurrency.ToUniValue().write().c_str());
874
- if (totalNativeInput < 0 || (leftoverCurrency - rtxd.ReserveInputMap ()).HasNegative ())
875
- {
876
- LogPrintf (" %s: ERROR - importing more currency than available for %s\n " , __func__, currencyDef.name .c_str ());
877
- LogPrintf (" totalNativeInput: %s, leftoverCurrency:%s\n " , ValueFromAmount (totalNativeInput).write ().c_str (), leftoverCurrency.ToUniValue ().write ().c_str ());
878
- printf (" %s: ERROR - importing more currency than available for %s\n " , __func__, currencyDef.name .c_str ());
879
- printf (" totalNativeInput: %s, leftoverCurrency:%s\n " , ValueFromAmount (totalNativeInput).write ().c_str (), leftoverCurrency.ToUniValue ().write ().c_str ());
880
- return false ;
881
- }
882
-
883
883
// add a proof of the export transaction at the notarization height
884
884
CBlock block;
885
885
if (!ReadBlockFromDisk (block, chainActive[aixIt->second .first .blockHeight ], Params ().GetConsensus (), false ))
0 commit comments