Skip to content

Commit 7e0042a

Browse files
authored
Merge pull request miketout#299 from VerusCoin/dev
Dev
2 parents 9e6dfb1 + 961ff90 commit 7e0042a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/rpc/pbaasrpc.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,16 @@ bool CConnectedChains::CreateLatestImports(const CCurrencyDefinition &currencyDe
852852
//printf("rtxd.ReserveInputMap(): %s, ccx.totalAmounts: %s\n", rtxd.ReserveInputMap().ToUniValue().write().c_str(), ccx.totalAmounts.ToUniValue().write().c_str());
853853
//printf("leftoverCurrency: %s\n", leftoverCurrency.ToUniValue().write().c_str());
854854

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+
855865
// breakout native from leftover currency
856866
availableCurrencyInput = leftoverCurrency;
857867
totalNativeInput = leftoverCurrency.valueMap[systemID];
@@ -870,16 +880,6 @@ bool CConnectedChains::CreateLatestImports(const CCurrencyDefinition &currencyDe
870880

871881
newImportTx.vout[0] = CTxOut(totalNativeInput, MakeMofNCCScript(CConditionObj<CCrossChainImport>(EVAL_CROSSCHAIN_IMPORT, dests, 1, &cci), &indexDests));
872882

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-
883883
// add a proof of the export transaction at the notarization height
884884
CBlock block;
885885
if (!ReadBlockFromDisk(block, chainActive[aixIt->second.first.blockHeight], Params().GetConsensus(), false))

0 commit comments

Comments
 (0)