// 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__);
}
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__);
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,
tempCurState.viaConversionPrice = newNotarization.currencyState.viaConversionPrice;
rtxd = CReserveTransactionDescriptor();
isValidExport = rtxd.AddReserveTransferImportOutputs(sourceSystem,
- ConnectedChains.ThisChain(),
+ destSystem,
destCurrency,
tempCurState,
exportTransfers,
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)
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;
}
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.");
}
{
flags |= CReserveTransfer::PRECONVERT;
}
- if (!burnCurrency && !convertToCurrencyID.IsNull())
+ if (isConversion && !burnCurrency && !convertToCurrencyID.IsNull())
{
flags |= CReserveTransfer::CONVERT;
}