Browse Source

Import/Export fixes

pull/283/head
miketout 4 years ago
parent
commit
c8c677c9c3
  1. 2
      src/coins.cpp
  2. 2
      src/coins.h
  3. 4
      src/core_write.cpp
  4. 8
      src/main.cpp
  5. 2
      src/miner.cpp
  6. 2
      src/pbaas/notarization.cpp
  7. 4
      src/pbaas/notarization.h
  8. 16
      src/pbaas/pbaas.cpp
  9. 66
      src/pbaas/reserves.cpp
  10. 55
      src/pbaas/reserves.h
  11. 2
      src/primitives/transaction.h
  12. 2
      src/rpc/client.cpp
  13. 84
      src/rpc/pbaasrpc.cpp
  14. 2
      src/rpc/pbaasrpc.h
  15. 2
      src/script/script.h
  16. 4
      src/txmempool.cpp
  17. 2
      src/txmempool.h

2
src/coins.cpp

@ -767,7 +767,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
return true;
}
double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight, const CReserveTransactionDescriptor *desc, const CCurrencyStateNew *currencyState) const
double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight, const CReserveTransactionDescriptor *desc, const CCurrencyState *currencyState) const
{
if (tx.IsCoinBase())
return 0.0;

2
src/coins.h

@ -597,7 +597,7 @@ public:
bool HaveShieldedRequirements(const CTransaction& tx) const;
//! Return priority of tx at height nHeight
double GetPriority(const CTransaction &tx, int nHeight, const CReserveTransactionDescriptor *desc=NULL, const CCurrencyStateNew *currencyState=NULL) const;
double GetPriority(const CTransaction &tx, int nHeight, const CReserveTransactionDescriptor *desc=NULL, const CCurrencyState *currencyState=NULL) const;
const CTxOut &GetOutputFor(const CTxIn& input) const;
const CScript &GetSpendFor(const CTxIn& input) const;

4
src/core_write.cpp

@ -200,7 +200,7 @@ uint160 CCurrencyDefinition::GetConditionID(int32_t condition) const
return CCrossChainRPCData::GetConditionID(name, condition);
}
UniValue CCurrencyStateNew::ToUniValue() const
UniValue CCurrencyState::ToUniValue() const
{
UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("flags", (int32_t)flags));
@ -262,7 +262,7 @@ UniValue ValueVectorsToUniValue(const std::vector<std::string> &rowNames,
UniValue CCoinbaseCurrencyState::ToUniValue() const
{
UniValue ret(UniValue::VOBJ);
ret = ((CCurrencyStateNew *)this)->ToUniValue();
ret = ((CCurrencyState *)this)->ToUniValue();
std::vector<std::string> rowNames;
for (int i = 0; i < currencies.size(); i++)
{

8
src/main.cpp

@ -1906,13 +1906,13 @@ bool AcceptToMemoryPoolInt(CTxMemPool& pool, CValidationState &state, const CTra
double dPriority;
CReserveTransactionDescriptor txDesc;
CCurrencyStateNew currencyState;
CCurrencyState currencyState;
bool isVerusActive = IsVerusActive();
{
LOCK(mempool.cs);
// if we don't recognize it, process and check
CCurrencyStateNew currencyState = ConnectedChains.GetCurrencyState(nextBlockHeight > chainActive.Height() ? chainActive.Height() : nextBlockHeight);
CCurrencyState currencyState = ConnectedChains.GetCurrencyState(nextBlockHeight > chainActive.Height() ? chainActive.Height() : nextBlockHeight);
if (!mempool.IsKnownReserveTransaction(hash, txDesc))
{
// we need the current currency state
@ -3886,7 +3886,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
if (isBlock1 && thisChain.preconverted.size() && thisChain.conversions.size())
{
// if we can have a pre-conversion output on block 1, add pre-conversion
nativeBlockReward += CCurrencyStateNew::ReserveToNativeRaw(CCurrencyValueMap(thisChain.currencies, thisChain.preconverted),
nativeBlockReward += CCurrencyState::ReserveToNativeRaw(CCurrencyValueMap(thisChain.currencies, thisChain.preconverted),
thisChain.currencies,
thisChain.conversions) + currencyState.nativeFees;
}
@ -3896,7 +3896,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
{
return state.DoS(100, error(("ConnectBlock(): invalid currency state fee does not match block total of " + totalReserveTxFees.ToUniValue().write()).c_str()), REJECT_INVALID, "bad-blk-currency-fee");
}
nativeBlockReward += CCurrencyStateNew::ReserveToNativeRaw(CCurrencyValueMap(currencyState.currencies, currencyState.reserveIn),
nativeBlockReward += CCurrencyState::ReserveToNativeRaw(CCurrencyValueMap(currencyState.currencies, currencyState.reserveIn),
currencyState.currencies,
currencyState.conversionPrice) + currencyState.nativeFees;
}

2
src/miner.cpp

@ -539,7 +539,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& _
{
prealloc += onePair.second;
}
CCoinbaseCurrencyState currencyState = CCoinbaseCurrencyState(CCurrencyStateNew(thisChain.currencies,
CCoinbaseCurrencyState currencyState = CCoinbaseCurrencyState(CCurrencyState(thisChain.currencies,
thisChain.weights,
thisChain.contributions,
prealloc, 0, 0));

2
src/pbaas/notarization.cpp

@ -90,7 +90,7 @@ CPBaaSNotarization::CPBaaSNotarization(const UniValue &obj)
auto currencyObj = find_value(obj, "currencystate");
if (currencyObj.isObject())
{
currencyState = CCurrencyStateNew(currencyObj);
currencyState = CCurrencyState(currencyObj);
}
prevNotarization = uint256S(uni_get_str(find_value(obj, "prevnotarization")));

4
src/pbaas/notarization.h

@ -95,7 +95,7 @@ public:
uint256 notarizationPreHash; // combination of block hash, block MMR root, and compact power (or external proxy) for the notarization height
uint256 compactPower; // compact power (or external proxy) of the block height notarization to compare
CCurrencyStateNew currencyState; // currency state of this chain as of this notarization
CCurrencyState currencyState; // currency state of this chain as of this notarization
uint256 prevNotarization; // txid of the prior notarization on this chain that we agree with, even those not accepted yet
int32_t prevHeight;
@ -115,7 +115,7 @@ public:
const uint256 &MMRRoot,
const uint256 &preHash,
const uint256 &compactpower,
const CCurrencyStateNew &currencystate,
const CCurrencyState &currencystate,
const uint256 &prevnotarization,
int32_t prevheight,
const uint256 &crossnotarization,

16
src/pbaas/pbaas.cpp

@ -322,7 +322,13 @@ void DeleteOpRetObjects(std::vector<CBaseChainObject *> &ora)
}
default:
{
printf("ERROR: invalid object type, likely corrupt pointer %p\n", pobj);
printf("generate code that won't be optimized away %s\n", CCurrencyValueMap(std::vector<uint160>({ASSETCHAINS_CHAINID}), std::vector<CAmount>({200000000})).ToUniValue().write(1,2).c_str());
printf("This is here to generate enough code for a good break point system chain name: %s\n", ConnectedChains.ThisChain().name.c_str());
delete pobj;
}
}
}
ora.clear();
@ -934,7 +940,7 @@ bool CConnectedChains::CheckVerusPBaaSAvailable()
if (!chainInfo.isNull())
{
params.push_back(VERUS_CHAINNAME);
chainDef = find_value(RPCCallRoot("getcurrencydefinition", params), "result");
chainDef = find_value(RPCCallRoot("getcurrency", params), "result");
if (!chainDef.isNull() && CheckVerusPBaaSAvailable(chainInfo, chainDef))
{
@ -944,7 +950,7 @@ bool CConnectedChains::CheckVerusPBaaSAvailable()
bool success = false;
params.clear();
params.push_back(EncodeDestination(CIdentityID(thisChain.GetID())));
chainDef = find_value(RPCCallRoot("getcurrencydefinition", params), "result");
chainDef = find_value(RPCCallRoot("getcurrency", params), "result");
if (!chainDef.isNull())
{
CCurrencyDefinition currencyDef(chainDef);
@ -1516,7 +1522,7 @@ void CConnectedChains::ProcessLocalImports()
for (auto &exportThread : exportOutputs)
{
CCurrencyDefinition exportDef;
int32_t defHeight;
int32_t defHeight = 0;
if (!GetCurrencyDefinition(exportThread.first, exportDef, &defHeight))
{
printf("%s: definition for export currency ID %s not found\n\n", __func__, EncodeDestination(CIdentityID(exportThread.first)).c_str());
@ -1566,7 +1572,7 @@ void CConnectedChains::ProcessLocalImports()
for (auto &oneIT : importThreads)
{
std::vector<CTransaction> importTxes;
int32_t importOutNum;
int32_t importOutNum = 0;
CCrossChainImport oneImportInput(oneIT.second, &importOutNum);
if (oneImportInput.IsValid())
{
@ -1593,7 +1599,7 @@ void CConnectedChains::ProcessLocalImports()
if (importTxes.size())
{
CMutableTransaction firstImport = importTxes[0];
int32_t outNum;
int32_t outNum = 0;
CCrossChainImport cci(importTxes[0], &outNum);
if (cci.IsValid())
{

66
src/pbaas/reserves.cpp

@ -323,7 +323,7 @@ CCurrencyValueMap CCurrencyValueMap::SubtractToZero(const CCurrencyValueMap& ope
return *this;
}
std::vector<CAmount> CCurrencyValueMap::AsCurrencyVector(const CCurrencyStateNew &cState) const
std::vector<CAmount> CCurrencyValueMap::AsCurrencyVector(const CCurrencyState &cState) const
{
std::vector<CAmount> retVal(cState.currencies.size());
std::map<uint160, int> curMap = cState.GetReserveMap();
@ -479,7 +479,7 @@ CCrossChainImport::CCrossChainImport(const CTransaction &tx, int32_t *pOutNum)
}
}
CCurrencyStateNew::CCurrencyStateNew(const UniValue &obj)
CCurrencyState::CCurrencyState(const UniValue &obj)
{
flags = uni_get_int(find_value(obj, "flags"));
@ -594,7 +594,7 @@ std::vector<std::vector<CAmount>> ValueColumnsFromUniValue(const UniValue &uni,
}
CCoinbaseCurrencyState::CCoinbaseCurrencyState(const UniValue &obj) : CCurrencyStateNew(obj)
CCoinbaseCurrencyState::CCoinbaseCurrencyState(const UniValue &obj) : CCurrencyState(obj)
{
std::vector<std::vector<CAmount>> columnAmounts;
@ -634,7 +634,7 @@ CAmount CalculateFractionalOut(CAmount NormalizedReserveIn, CAmount Supply, CAmo
{
cpp_dec_float_50 supplyout = (supply * (pow((reservein / reserve) + one, ratio) - one));
if (!CCurrencyStateNew::to_int64(supplyout, fractionalOut))
if (!CCurrencyState::to_int64(supplyout, fractionalOut))
{
assert(false);
}
@ -656,7 +656,7 @@ CAmount CalculateReserveOut(CAmount FractionalIn, CAmount Supply, CAmount Normal
if (FractionalIn)
{
cpp_dec_float_50 reserveout = reserve * (one - pow(one - (fractionalin / supply), (one / ratio)));
if (!CCurrencyStateNew::to_int64(reserveout, reserveOut))
if (!CCurrencyState::to_int64(reserveout, reserveOut))
{
assert(false);
}
@ -668,7 +668,7 @@ CAmount CalculateReserveOut(CAmount FractionalIn, CAmount Supply, CAmount Normal
// takes both input amounts of any number of reserves and the fractional currencies targeting those reserves to merge the conversion into one
// merged calculation with the same price across currencies for all transactions in the block. It returns the newly calculated
// conversion prices of the fractional reserve in the reserve currency.
std::vector<CAmount> CCurrencyStateNew::ConvertAmounts(const std::vector<CAmount> &inputReserves, const std::vector<CAmount> &inputFractional, CCurrencyStateNew &newState) const
std::vector<CAmount> CCurrencyState::ConvertAmounts(const std::vector<CAmount> &inputReserves, const std::vector<CAmount> &inputFractional, CCurrencyState &newState) const
{
// we use indexes because transactions use indexes to refer to fractional currency, which means once
// a spot is used in a blockchain, it cannot be changed
@ -975,7 +975,7 @@ std::vector<CAmount> CCurrencyStateNew::ConvertAmounts(const std::vector<CAmount
return rates;
}
CAmount CCurrencyStateNew::ConvertAmounts(CAmount inputReserve, CAmount inputFraction, CCurrencyStateNew &newState, int32_t reserveIndex) const
CAmount CCurrencyState::ConvertAmounts(CAmount inputReserve, CAmount inputFraction, CCurrencyState &newState, int32_t reserveIndex) const
{
if (reserveIndex >= newState.currencies.size())
{
@ -1268,7 +1268,7 @@ void CReserveTransactionDescriptor::AddReserveExchange(const CReserveExchange &r
vRex.push_back(std::make_pair(outputIndex, rex));
}
CAmount CReserveTransactionDescriptor::AllFeesAsNative(const CCurrencyStateNew &currencyState) const
CAmount CReserveTransactionDescriptor::AllFeesAsNative(const CCurrencyState &currencyState) const
{
CAmount nativeFees = NativeFees();
CCurrencyValueMap reserveFees = ReserveFees();
@ -1283,7 +1283,7 @@ CAmount CReserveTransactionDescriptor::AllFeesAsNative(const CCurrencyStateNew &
return nativeFees;
}
CAmount CReserveTransactionDescriptor::AllFeesAsNative(const CCurrencyStateNew &currencyState, const std::vector<CAmount> &exchangeRates) const
CAmount CReserveTransactionDescriptor::AllFeesAsNative(const CCurrencyState &currencyState, const std::vector<CAmount> &exchangeRates) const
{
assert(exchangeRates.size() == currencyState.currencies.size());
CAmount nativeFees = NativeFees();
@ -1299,7 +1299,7 @@ CAmount CReserveTransactionDescriptor::AllFeesAsNative(const CCurrencyStateNew &
return nativeFees;
}
CCurrencyValueMap CReserveTransactionDescriptor::AllFeesAsReserve(const CCurrencyStateNew &currencyState, int defaultReserve) const
CCurrencyValueMap CReserveTransactionDescriptor::AllFeesAsReserve(const CCurrencyState &currencyState, int defaultReserve) const
{
CCurrencyValueMap reserveFees = ReserveFees();
@ -1315,7 +1315,7 @@ CCurrencyValueMap CReserveTransactionDescriptor::AllFeesAsReserve(const CCurrenc
return reserveFees;
}
CCurrencyValueMap CReserveTransactionDescriptor::AllFeesAsReserve(const CCurrencyStateNew &currencyState, const std::vector<CAmount> &exchangeRates, int defaultReserve) const
CCurrencyValueMap CReserveTransactionDescriptor::AllFeesAsReserve(const CCurrencyState &currencyState, const std::vector<CAmount> &exchangeRates, int defaultReserve) const
{
CCurrencyValueMap reserveFees = ReserveFees();
@ -1676,7 +1676,7 @@ bool CReserveTransactionDescriptor::AddReserveTransferImportOutputs(const uint16
if (exportObjects[i]->objectType == CHAINOBJ_RESERVETRANSFER)
{
CReserveTransfer &curTransfer = ((CChainObject<CReserveTransfer> *)exportObjects[i])->object;
CCurrencyDefinition &currencyDest = ConnectedChains.GetCachedCurrency(curTransfer.destCurrencyID);
CCurrencyDefinition currencyDest = ConnectedChains.GetCachedCurrency(curTransfer.destCurrencyID);
if (!currencyDest.IsValid())
{
printf("%s: invalid currency or currency not found %s\n", __func__, EncodeDestination(CIdentityID(curTransfer.destCurrencyID)).c_str());
@ -1773,7 +1773,7 @@ bool CReserveTransactionDescriptor::AddReserveTransferImportOutputs(const uint16
{
preConversionFee = CalculateConversionFee(curTransfer.nValue);
valueOut = curTransfer.nValue - preConversionFee;
newCurrencyConverted = CCurrencyStateNew::ReserveToNativeRaw(valueOut, currencyDest.conversions[curIdx]);
newCurrencyConverted = CCurrencyState::ReserveToNativeRaw(valueOut, currencyDest.conversions[curIdx]);
CAmount totalReserveFee = preConversionFee + curTransfer.CalculateTransferFee(curTransfer.destination);
@ -1796,7 +1796,7 @@ bool CReserveTransactionDescriptor::AddReserveTransferImportOutputs(const uint16
{
if (curTransfer.destCurrencyID == systemDestID)
{
newNativeFees = CCurrencyStateNew::ReserveToNativeRaw(totalReserveFee, currencyDest.conversions[curIdx]);
newNativeFees = CCurrencyState::ReserveToNativeRaw(totalReserveFee, currencyDest.conversions[curIdx]);
AddReserveConversionFees(systemDestID, newNativeFees);
feesConverted = newNativeFees;
nativeIn += newNativeFees;
@ -1829,7 +1829,7 @@ bool CReserveTransactionDescriptor::AddReserveTransferImportOutputs(const uint16
else
{
// input comes from non-fee outputs
newCurrencyConverted = CCurrencyStateNew::ReserveToNativeRaw(curTransfer.nValue, currencyDest.conversions[curIdx]);
newCurrencyConverted = CCurrencyState::ReserveToNativeRaw(curTransfer.nValue, currencyDest.conversions[curIdx]);
if (curTransfer.destCurrencyID == systemDestID)
{
nativeOut += newCurrencyConverted;
@ -1964,7 +1964,7 @@ bool CReserveTransactionDescriptor::AddReserveTransferImportOutputs(const uint16
return true;
}
CMutableTransaction &CReserveTransactionDescriptor::AddConversionInOuts(CMutableTransaction &conversionTx, std::vector<CInputDescriptor> &conversionInputs, const CCurrencyValueMap &_exchangeRates, const CCurrencyStateNew *pCurrencyState) const
CMutableTransaction &CReserveTransactionDescriptor::AddConversionInOuts(CMutableTransaction &conversionTx, std::vector<CInputDescriptor> &conversionInputs, const CCurrencyValueMap &_exchangeRates, const CCurrencyState *pCurrencyState) const
{
if (!IsReserveExchange() || IsFillOrKillFail())
{
@ -1972,8 +1972,8 @@ CMutableTransaction &CReserveTransactionDescriptor::AddConversionInOuts(CMutable
}
bool noExchangeRate = false;
CCurrencyStateNew dummy;
const CCurrencyStateNew &currencyState = pCurrencyState ? *pCurrencyState : dummy;
CCurrencyState dummy;
const CCurrencyState &currencyState = pCurrencyState ? *pCurrencyState : dummy;
// set exchange rates as well as we can, either from explicit rates or currency state if possible
CCurrencyValueMap __exchangeRates;
@ -2174,7 +2174,7 @@ CCurrencyValueMap CReserveTransactionDescriptor::ReserveConversionFeesMap() cons
return retVal;
}
std::vector<CAmount> CReserveTransactionDescriptor::ReserveInputVec(const CCurrencyStateNew &cState) const
std::vector<CAmount> CReserveTransactionDescriptor::ReserveInputVec(const CCurrencyState &cState) const
{
std::vector<CAmount> retVal(cState.currencies.size());
std::map<uint160, int> curMap = cState.GetReserveMap();
@ -2185,7 +2185,7 @@ std::vector<CAmount> CReserveTransactionDescriptor::ReserveInputVec(const CCurre
return retVal;
}
std::vector<CAmount> CReserveTransactionDescriptor::ReserveOutputVec(const CCurrencyStateNew &cState) const
std::vector<CAmount> CReserveTransactionDescriptor::ReserveOutputVec(const CCurrencyState &cState) const
{
std::vector<CAmount> retVal(cState.currencies.size());
std::map<uint160, int> curMap = cState.GetReserveMap();
@ -2196,7 +2196,7 @@ std::vector<CAmount> CReserveTransactionDescriptor::ReserveOutputVec(const CCurr
return retVal;
}
std::vector<CAmount> CReserveTransactionDescriptor::ReserveOutConvertedVec(const CCurrencyStateNew &cState) const
std::vector<CAmount> CReserveTransactionDescriptor::ReserveOutConvertedVec(const CCurrencyState &cState) const
{
std::vector<CAmount> retVal(cState.currencies.size());
std::map<uint160, int> curMap = cState.GetReserveMap();
@ -2207,7 +2207,7 @@ std::vector<CAmount> CReserveTransactionDescriptor::ReserveOutConvertedVec(const
return retVal;
}
std::vector<CAmount> CReserveTransactionDescriptor::NativeOutConvertedVec(const CCurrencyStateNew &cState) const
std::vector<CAmount> CReserveTransactionDescriptor::NativeOutConvertedVec(const CCurrencyState &cState) const
{
std::vector<CAmount> retVal(cState.currencies.size());
std::map<uint160, int> curMap = cState.GetReserveMap();
@ -2218,7 +2218,7 @@ std::vector<CAmount> CReserveTransactionDescriptor::NativeOutConvertedVec(const
return retVal;
}
std::vector<CAmount> CReserveTransactionDescriptor::ReserveConversionFeesVec(const CCurrencyStateNew &cState) const
std::vector<CAmount> CReserveTransactionDescriptor::ReserveConversionFeesVec(const CCurrencyState &cState) const
{
std::vector<CAmount> retVal(cState.currencies.size());
std::map<uint160, int> curMap = cState.GetReserveMap();
@ -2231,7 +2231,7 @@ std::vector<CAmount> CReserveTransactionDescriptor::ReserveConversionFeesVec(con
// this should be done no more than once to prepare a currency state to be updated to the next state
// emission occurs for a block before any conversion or exchange and that impact on the currency state is calculated
CCurrencyStateNew &CCurrencyStateNew::UpdateWithEmission(CAmount Emitted)
CCurrencyState &CCurrencyState::UpdateWithEmission(CAmount Emitted)
{
initialSupply = supply;
emitted = 0;
@ -2359,7 +2359,7 @@ CCoinbaseCurrencyState CCoinbaseCurrencyState::MatchOrders(const std::vector<CRe
CMutableTransaction mConversionTx = pConversionTx ? *pConversionTx : CMutableTransaction();
std::vector<CInputDescriptor> tmpConversionInputs(conversionInputs);
int64_t totalSerializedSize = pInOutTotalSerializeSize ? *pInOutTotalSerializeSize + CCurrencyStateNew::CONVERSION_TX_SIZE_MIN : CCurrencyStateNew::CONVERSION_TX_SIZE_MIN;
int64_t totalSerializedSize = pInOutTotalSerializeSize ? *pInOutTotalSerializeSize + CCurrencyState::CONVERSION_TX_SIZE_MIN : CCurrencyState::CONVERSION_TX_SIZE_MIN;
int64_t conversionSizeOverhead = 0;
if (!(flags & ISRESERVE))
@ -2427,7 +2427,7 @@ CCoinbaseCurrencyState CCoinbaseCurrencyState::MatchOrders(const std::vector<CRe
// there is no point in retracing if an element fails to be added
// 3. calculate a final order price
// 4. create and return a new, updated CCoinbaseCurrencyState
CCoinbaseCurrencyState newState(*(CCurrencyStateNew *)this);
CCoinbaseCurrencyState newState(*(CCurrencyState *)this);
conversionSizeOverhead = GetSerializeSize(mConversionTx, SER_NETWORK, PROTOCOL_VERSION);
@ -2563,7 +2563,7 @@ CCoinbaseCurrencyState CCoinbaseCurrencyState::MatchOrders(const std::vector<CRe
limitOrdersSizeLimit = maxSerializeSize - totalSerializedSize;
int64_t buyLimitSizeLimit = numLimitOrders ? totalSerializedSize + ((arith_uint256(limitBuys.size()) * arith_uint256(limitOrdersSizeLimit)) / arith_uint256(numLimitOrders)).GetLow64() : limitOrdersSizeLimit;
CCurrencyStateNew latestState = newState;
CCurrencyState latestState = newState;
// TODO - finish limit orders, which are significantly more complex after moving to
// multi-reserves. until then, skip limit orders.
@ -2787,7 +2787,7 @@ CCoinbaseCurrencyState CCoinbaseCurrencyState::MatchOrders(const std::vector<CRe
}
}
CAmount CCurrencyStateNew::CalculateConversionFee(CAmount inputAmount, bool convertToNative, int currencyIndex) const
CAmount CCurrencyState::CalculateConversionFee(CAmount inputAmount, bool convertToNative, int currencyIndex) const
{
arith_uint256 bigAmount(inputAmount);
arith_uint256 bigSatoshi(SATOSHIDEN);
@ -2845,7 +2845,7 @@ CAmount CReserveTransactionDescriptor::CalculateAdditionalConversionFee(CAmount
return fee;
}
CAmount CCurrencyStateNew::ReserveToNativeRaw(CAmount reserveAmount, CAmount exchangeRate)
CAmount CCurrencyState::ReserveToNativeRaw(CAmount reserveAmount, CAmount exchangeRate)
{
static arith_uint256 bigSatoshi(SATOSHIDEN);
arith_uint256 bigAmount(reserveAmount);
@ -2854,7 +2854,7 @@ CAmount CCurrencyStateNew::ReserveToNativeRaw(CAmount reserveAmount, CAmount exc
return bigAmount.GetLow64();
}
CAmount CCurrencyStateNew::ReserveToNativeRaw(const CCurrencyValueMap &reserveAmounts, const std::vector<CAmount> &exchangeRates) const
CAmount CCurrencyState::ReserveToNativeRaw(const CCurrencyValueMap &reserveAmounts, const std::vector<CAmount> &exchangeRates) const
{
CAmount nativeOut = 0;
for (int i = 0; i < currencies.size(); i++)
@ -2868,7 +2868,7 @@ CAmount CCurrencyStateNew::ReserveToNativeRaw(const CCurrencyValueMap &reserveAm
return nativeOut;
}
CAmount CCurrencyStateNew::ReserveToNativeRaw(const CCurrencyValueMap &reserveAmounts,
CAmount CCurrencyState::ReserveToNativeRaw(const CCurrencyValueMap &reserveAmounts,
const std::vector<uint160> &currencies,
const std::vector<CAmount> &exchangeRates)
{
@ -2884,14 +2884,14 @@ CAmount CCurrencyStateNew::ReserveToNativeRaw(const CCurrencyValueMap &reserveAm
return nativeOut;
}
CAmount CCurrencyStateNew::NativeToReserveRaw(CAmount nativeAmount, CAmount exchangeRate)
CAmount CCurrencyState::NativeToReserveRaw(CAmount nativeAmount, CAmount exchangeRate)
{
static arith_uint256 bigSatoshi(SATOSHIDEN);
arith_uint256 bigAmount(nativeAmount);
return ((bigAmount * arith_uint256(exchangeRate)) / bigSatoshi).GetLow64();
}
CCurrencyValueMap CCurrencyStateNew::NativeToReserveRaw(const std::vector<CAmount> &nativeAmount, const std::vector<CAmount> &exchangeRates) const
CCurrencyValueMap CCurrencyState::NativeToReserveRaw(const std::vector<CAmount> &nativeAmount, const std::vector<CAmount> &exchangeRates) const
{
static arith_uint256 bigSatoshi(SATOSHIDEN);
CCurrencyValueMap retVal;

55
src/pbaas/reserves.h

@ -34,7 +34,7 @@ class CTransaction;
class CMutableTransaction;
class CTxOut;
class CReserveTransactionDescriptor;
class CCurrencyStateNew;
class CCurrencyState;
// convenience class for collections of currencies that supports comparisons, including ==, >, >=, <, <=, as well as addition, and subtraction
class CCurrencyValueMap
@ -96,7 +96,7 @@ public:
// subtract, but do not subtract to negative values
CCurrencyValueMap SubtractToZero(const CCurrencyValueMap& operand);
std::vector<CAmount> AsCurrencyVector(const CCurrencyStateNew &cState) const;
std::vector<CAmount> AsCurrencyVector(const CCurrencyState &cState) const;
std::vector<CAmount> AsCurrencyVector(const std::vector<uint160> &currencies) const;
UniValue ToUniValue() const;
@ -390,8 +390,7 @@ public:
{
return nVersion > VERSION_INVALID &&
nVersion <= VERSION_LAST &&
!systemID.IsNull() &&
totalAmounts.valueMap.size() == totalFees.valueMap.size();
!systemID.IsNull();
}
static CCurrencyValueMap CalculateExportFee(const CCurrencyValueMap &fees, int numIn);
@ -402,7 +401,7 @@ public:
UniValue ToUniValue() const;
};
class CCurrencyStateNew
class CCurrencyState
{
public:
enum {
@ -427,9 +426,9 @@ public:
//std::vector<CAmount> Reserves; // reserve currencies amounts controlled by this fractional chain - only present for reserve currencies, currency IDs are in chain definition
CCurrencyStateNew() : flags(0), initialSupply(0), emitted(0), supply(0) {}
CCurrencyState() : flags(0), initialSupply(0), emitted(0), supply(0) {}
CCurrencyStateNew(const std::vector<uint160> &Currencies,
CCurrencyState(const std::vector<uint160> &Currencies,
const std::vector<int32_t> &Weights,
const std::vector<int64_t> &Reserves,
CAmount InitialSupply,
@ -439,12 +438,12 @@ public:
flags(Flags), supply(Supply), initialSupply(InitialSupply), emitted(Emitted), weights(Weights), reserves(Reserves)
{}
CCurrencyStateNew(const std::vector<unsigned char> &asVector)
CCurrencyState(const std::vector<unsigned char> &asVector)
{
FromVector(asVector, *this);
}
CCurrencyStateNew(const UniValue &uni);
CCurrencyState(const UniValue &uni);
ADD_SERIALIZE_METHODS;
@ -466,7 +465,7 @@ public:
// this should be done no more than once to prepare a currency state to be moved to the next state
// emission occurs for a block before any conversion or exchange and that impact on the currency state is calculated
CCurrencyStateNew &UpdateWithEmission(CAmount emitted);
CCurrencyState &UpdateWithEmission(CAmount emitted);
cpp_dec_float_50 GetReserveRatio(int32_t reserveIndex=0) const
{
@ -526,12 +525,12 @@ public:
}
// This considers one currency at a time
CAmount ConvertAmounts(CAmount inputReserve, CAmount inputFractional, CCurrencyStateNew &newState, int32_t reserveIndex=0) const;
CAmount ConvertAmounts(CAmount inputReserve, CAmount inputFractional, CCurrencyState &newState, int32_t reserveIndex=0) const;
// convert amounts for multi-reserve fractional reserve currencies
// one entry in the vector for each currency in and one fractional input for each
// currency expected as output
std::vector<CAmount> ConvertAmounts(const std::vector<CAmount> &inputReserve, const std::vector<CAmount> &inputFractional, CCurrencyStateNew &newState) const;
std::vector<CAmount> ConvertAmounts(const std::vector<CAmount> &inputReserve, const std::vector<CAmount> &inputFractional, CCurrencyState &newState) const;
CAmount CalculateConversionFee(CAmount inputAmount, bool convertToNative = false, int32_t reserveIndex=0) const;
CAmount ReserveFeeToNative(CAmount inputAmount, CAmount outputAmount, int32_t reserveIndex=0) const;
@ -581,12 +580,12 @@ public:
bool IsValid() const
{
return flags & CCurrencyStateNew::VALID;
return flags & CCurrencyState::VALID;
}
bool IsReserve() const
{
return flags & CCurrencyStateNew::ISRESERVE;
return flags & CCurrencyState::ISRESERVE;
}
std::map<uint160, int32_t> GetReserveMap() const
@ -600,7 +599,7 @@ public:
}
};
class CCoinbaseCurrencyState : public CCurrencyStateNew
class CCoinbaseCurrencyState : public CCurrencyState
{
public:
CAmount nativeFees;
@ -614,7 +613,7 @@ public:
CCoinbaseCurrencyState() : nativeFees(0), nativeConversionFees(0) {}
CCoinbaseCurrencyState(const CCurrencyStateNew &CurrencyState,
CCoinbaseCurrencyState(const CCurrencyState &CurrencyState,
CAmount NativeFees=0, CAmount NativeConversionFees=0,
const std::vector<CAmount> &ReserveIn=std::vector<CAmount>(),
const std::vector<CAmount> &NativeIn=std::vector<CAmount>(),
@ -622,7 +621,7 @@ public:
const std::vector<CAmount> &ConversionPrice=std::vector<CAmount>(),
const std::vector<CAmount> &Fees=std::vector<CAmount>(),
const std::vector<CAmount> &ConversionFees=std::vector<CAmount>()) :
CCurrencyStateNew(CurrencyState), nativeFees(NativeFees), nativeConversionFees(NativeConversionFees)
CCurrencyState(CurrencyState), nativeFees(NativeFees), nativeConversionFees(NativeConversionFees)
{
if (!reserveIn.size()) reserveIn = std::vector<CAmount>(currencies.size());
if (!nativeIn.size()) nativeIn = std::vector<CAmount>(currencies.size());
@ -645,7 +644,7 @@ public:
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(*(CCurrencyStateNew *)this);
READWRITE(*(CCurrencyState *)this);
READWRITE(nativeFees);
READWRITE(nativeConversionFees);
READWRITE(reserveIn);
@ -810,10 +809,10 @@ public:
return retFees;
}
CAmount AllFeesAsNative(const CCurrencyStateNew &currencyState) const;
CAmount AllFeesAsNative(const CCurrencyStateNew &currencyState, const std::vector<CAmount> &exchangeRates) const;
CCurrencyValueMap AllFeesAsReserve(const CCurrencyStateNew &currencyState, int defaultReserve=0) const;
CCurrencyValueMap AllFeesAsReserve(const CCurrencyStateNew &currencyState, const std::vector<CAmount> &exchangeRates, int defaultReserve=0) const;
CAmount AllFeesAsNative(const CCurrencyState &currencyState) const;
CAmount AllFeesAsNative(const CCurrencyState &currencyState, const std::vector<CAmount> &exchangeRates) const;
CCurrencyValueMap AllFeesAsReserve(const CCurrencyState &currencyState, int defaultReserve=0) const;
CCurrencyValueMap AllFeesAsReserve(const CCurrencyState &currencyState, const std::vector<CAmount> &exchangeRates, int defaultReserve=0) const;
// does not check for errors
void AddReserveInput(const uint160 &currency, CAmount value);
@ -829,11 +828,11 @@ public:
CCurrencyValueMap ReserveConversionFeesMap() const;
// returns vectors in same size and order as reserve currencies
std::vector<CAmount> ReserveInputVec(const CCurrencyStateNew &cState) const;
std::vector<CAmount> ReserveOutputVec(const CCurrencyStateNew &cState) const;
std::vector<CAmount> ReserveOutConvertedVec(const CCurrencyStateNew &cState) const;
std::vector<CAmount> NativeOutConvertedVec(const CCurrencyStateNew &cState) const;
std::vector<CAmount> ReserveConversionFeesVec(const CCurrencyStateNew &cState) const;
std::vector<CAmount> ReserveInputVec(const CCurrencyState &cState) const;
std::vector<CAmount> ReserveOutputVec(const CCurrencyState &cState) const;
std::vector<CAmount> ReserveOutConvertedVec(const CCurrencyState &cState) const;
std::vector<CAmount> NativeOutConvertedVec(const CCurrencyState &cState) const;
std::vector<CAmount> ReserveConversionFeesVec(const CCurrencyState &cState) const;
void AddReserveOutput(const CTokenOutput &ro)
{
@ -860,7 +859,7 @@ public:
CMutableTransaction &AddConversionInOuts(CMutableTransaction &conversionTx,
std::vector<CInputDescriptor> &conversionInputs,
const CCurrencyValueMap &exchangeRates=CCurrencyValueMap(),
const CCurrencyStateNew *pCurrencyState=nullptr) const;
const CCurrencyState *pCurrencyState=nullptr) const;
bool AddReserveTransferImportOutputs(const uint160 &currencySourceID,
const CCurrencyDefinition &systemDest,

2
src/primitives/transaction.h

@ -33,7 +33,7 @@
#include "zcash/Proof.hpp"
extern uint32_t ASSETCHAINS_MAGIC;
class CCurrencyStateNew;
class CCurrencyState;
// Overwinter transaction version

2
src/rpc/client.cpp

@ -489,7 +489,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "calc_MoM", 2},
// pbaas
{ "definecurrency", 0},
{ "getcurrencydefinitions", 0},
{ "listcurrencies", 0},
{ "sendcurrency", 1},
{ "registeridentity", 0},
{ "updateidentity", 0},

84
src/rpc/pbaasrpc.cpp

@ -325,7 +325,7 @@ bool SetThisChain(const UniValue &chainDefinition)
PBAAS_ENDBLOCK = ConnectedChains.ThisChain().endBlock;
mapArgs["-endblock"] = to_string(PBAAS_ENDBLOCK);
CCurrencyStateNew currencyState = ConnectedChains.GetCurrencyState(0);
CCurrencyState currencyState = ConnectedChains.GetCurrencyState(0);
ASSETCHAINS_SUPPLY = currencyState.supply;
mapArgs["-ac_supply"] = to_string(ASSETCHAINS_SUPPLY);
@ -387,7 +387,7 @@ bool CConnectedChains::LoadReserveCurrencies()
UniValue result;
try
{
result = find_value(RPCCallRoot("getcurrencydefinition", params), "result");
result = find_value(RPCCallRoot("getcurrency", params), "result");
} catch (exception e)
{
result = NullUniValue;
@ -619,8 +619,6 @@ bool CConnectedChains::CreateLatestImports(const CCurrencyDefinition &currencyDe
// which transaction are we in this block?
std::vector<std::pair<CAddressIndexKey, CAmount>> addressIndex;
CBlockIndex *pIndex;
// get all export transactions including and since this one up to the confirmed height
if (blkHeight <= lastConfirmed.notarizationHeight &&
GetAddressIndex(CCrossChainRPCData::GetConditionID(systemID, EVAL_CROSSCHAIN_EXPORT), 1, addressIndex, blkHeight, lastConfirmed.notarizationHeight))
@ -641,7 +639,8 @@ bool CConnectedChains::CreateLatestImports(const CCurrencyDefinition &currencyDe
BlockMap::iterator blkIt;
CCrossChainExport ccx;
COptCCParams p;
if ((utxo.first.txhash != lastExportHash) &&
if (!utxo.first.spending &&
(utxo.first.txhash != lastExportHash) &&
myGetTransaction(utxo.first.txhash, tx, blkHash1) &&
(ccx = CCrossChainExport(tx)).IsValid() &&
ccx.numInputs &&
@ -926,12 +925,12 @@ uint160 GetChainIDFromParam(const UniValue &param, CCurrencyDefinition *pCurrenc
return ValidateCurrencyName(uni_get_str(param), pCurrencyDef);
}
UniValue getcurrencydefinition(const UniValue& params, bool fHelp)
UniValue getcurrency(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
{
throw runtime_error(
"getcurrencydefinition \"chainname\"\n"
"getcurrency \"chainname\"\n"
"\nReturns a complete definition for any given chain if it is registered on the blockchain. If the chain requested\n"
"\nis NULL, chain definition of the current chain is returned.\n"
@ -971,8 +970,8 @@ UniValue getcurrencydefinition(const UniValue& params, bool fHelp)
" }\n"
"\nExamples:\n"
+ HelpExampleCli("getcurrencydefinition", "\"chainname\"")
+ HelpExampleRpc("getcurrencydefinition", "\"chainname\"")
+ HelpExampleCli("getcurrency", "\"chainname\"")
+ HelpExampleRpc("getcurrency", "\"chainname\"")
);
}
@ -1053,12 +1052,12 @@ UniValue getcurrencydefinition(const UniValue& params, bool fHelp)
}
}
UniValue getpendingchaintransfers(const UniValue& params, bool fHelp)
UniValue getpendingtransfers(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
{
throw runtime_error(
"getpendingchaintransfers \"chainname\"\n"
"getpendingtransfers \"chainname\"\n"
"\nReturns all pending transfers for a particular chain that have not yet been aggregated into an export\n"
"\nArguments\n"
@ -1069,8 +1068,8 @@ UniValue getpendingchaintransfers(const UniValue& params, bool fHelp)
" }\n"
"\nExamples:\n"
+ HelpExampleCli("getpendingchaintransfers", "\"chainname\"")
+ HelpExampleRpc("getpendingchaintransfers", "\"chainname\"")
+ HelpExampleCli("getpendingtransfers", "\"chainname\"")
+ HelpExampleRpc("getpendingtransfers", "\"chainname\"")
);
}
@ -1122,12 +1121,12 @@ UniValue getpendingchaintransfers(const UniValue& params, bool fHelp)
return NullUniValue;
}
UniValue getchainexports(const UniValue& params, bool fHelp)
UniValue getexports(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
{
throw runtime_error(
"getchainexports \"chainname\"\n"
"getexports \"chainname\"\n"
"\nReturns all pending export transfers that are not yet provable with confirmed notarizations.\n"
"\nArguments\n"
@ -1138,8 +1137,8 @@ UniValue getchainexports(const UniValue& params, bool fHelp)
" }\n"
"\nExamples:\n"
+ HelpExampleCli("getchainexports", "\"chainname\"")
+ HelpExampleRpc("getchainexports", "\"chainname\"")
+ HelpExampleCli("getexports", "\"chainname\"")
+ HelpExampleRpc("getexports", "\"chainname\"")
);
}
@ -1215,12 +1214,12 @@ UniValue getchainexports(const UniValue& params, bool fHelp)
return NullUniValue;
}
UniValue getchainimports(const UniValue& params, bool fHelp)
UniValue getimports(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
{
throw runtime_error(
"getchainimports \"chainname\"\n"
"getimports \"chainname\"\n"
"\nReturns all imports from a specific chain.\n"
"\nArguments\n"
@ -1231,8 +1230,8 @@ UniValue getchainimports(const UniValue& params, bool fHelp)
" }\n"
"\nExamples:\n"
+ HelpExampleCli("getchainimports", "\"chainname\"")
+ HelpExampleRpc("getchainimports", "\"chainname\"")
+ HelpExampleCli("getimports", "\"chainname\"")
+ HelpExampleRpc("getimports", "\"chainname\"")
);
}
@ -1322,12 +1321,12 @@ UniValue getchainimports(const UniValue& params, bool fHelp)
return NullUniValue;
}
UniValue getcurrencydefinitions(const UniValue& params, bool fHelp)
UniValue listcurrencies(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
{
throw runtime_error(
"getcurrencydefinitions (includeexpired)\n"
"listcurrencies (includeexpired)\n"
"\nReturns a complete definition for any given chain if it is registered on the blockchain. If the chain requested\n"
"\nis NULL, chain definition of the current chain is returned.\n"
@ -1362,8 +1361,8 @@ UniValue getcurrencydefinitions(const UniValue& params, bool fHelp)
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getcurrencydefinitions", "true")
+ HelpExampleRpc("getcurrencydefinitions", "true")
+ HelpExampleCli("listcurrencies", "true")
+ HelpExampleRpc("listcurrencies", "true")
);
}
@ -2620,7 +2619,7 @@ UniValue getcrossnotarization(const UniValue& params, bool fHelp)
}
CBlockIndex *nzIndex = chainActive[proofheight];
CCurrencyStateNew currencyState = ConnectedChains.GetCurrencyState(proofheight);
CCurrencyState currencyState = ConnectedChains.GetCurrencyState(proofheight);
// get the current block's MMR root and proof height
CPBaaSNotarization notarization = CPBaaSNotarization(CPBaaSNotarization::CURRENT_VERSION,
@ -2807,7 +2806,7 @@ CCurrencyValueMap CalculatePreconversions(const CCurrencyDefinition &chainDef, i
CCoinbaseCurrencyState GetInitialCurrencyState(CCurrencyDefinition &chainDef)
{
bool isReserve = chainDef.IsReserve();
CCurrencyStateNew cState;
CCurrencyState cState;
// calculate contributions and conversions
const std::vector<CAmount> reserveFees(chainDef.currencies.size());
@ -2815,23 +2814,23 @@ CCoinbaseCurrencyState GetInitialCurrencyState(CCurrencyDefinition &chainDef)
CAmount nativeFees = 0;
if (isReserve)
{
cState = CCurrencyStateNew(chainDef.currencies,
cState = CCurrencyState(chainDef.currencies,
chainDef.weights,
std::vector<int64_t>(chainDef.currencies.size()), 0, 0, 0, CCurrencyStateNew::VALID + CCurrencyStateNew::ISRESERVE);
CCurrencyStateNew tmpState;
std::vector<int64_t>(chainDef.currencies.size()), 0, 0, 0, CCurrencyState::VALID + CCurrencyState::ISRESERVE);
CCurrencyState tmpState;
chainDef.conversions = cState.ConvertAmounts(chainDef.preconverted, std::vector<int64_t>(chainDef.currencies.size()), tmpState);
cState = tmpState;
}
else
{
CAmount PreconvertedNative = cState.ReserveToNativeRaw(CCurrencyValueMap(chainDef.currencies, chainDef.preconverted), chainDef.conversions);
CCurrencyStateNew cState(std::vector<uint160>(0),
CCurrencyState cState(std::vector<uint160>(0),
std::vector<int32_t>(0),
std::vector<int64_t>(0),
0,
PreconvertedNative,
PreconvertedNative,
CCurrencyStateNew::VALID);
CCurrencyState::VALID);
}
cState.UpdateWithEmission(chainDef.GetTotalPreallocation());
@ -3474,6 +3473,10 @@ UniValue getlatestimportsout(const UniValue& params, bool fHelp)
return ret;
}
UniValue txUniv(UniValue::VOBJ);
TxToUniv(lastImportTx, uint256(), txUniv);
printf("lastImportTx%s\n", txUniv.write(1,2).c_str());
DeleteOpRetObjects(chainObjs);
std::vector<CTransaction> newImports;
@ -4413,7 +4416,7 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
mmvRoot,
nodePreHash,
mmr.GetNode(0).power,
static_cast<CCurrencyStateNew>(newCurrencyState),
static_cast<CCurrencyState>(newCurrencyState),
uint256(),
0,
uint256(),
@ -4555,7 +4558,10 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
// import thread is specific to the chain importing from
dests = std::vector<CTxDestination>({proofDest});
indexDests = std::vector<CTxDestination>({CKeyID(CCrossChainRPCData::GetConditionID(newChainID, EVAL_CROSSCHAIN_IMPORT))});
CCrossChainImport cci(newChainID, InitialPreallocation);
// if this is a token on this chain, the transfer that is output here is burned through the export
// and merges with the import thread. we multiply new input times 2, to cover both the import thread output
// and the reserve transfer outputs.
CCrossChainImport cci(newChainID, newChain.IsToken() ? InitialPreallocation * 2 : InitialPreallocation, InitialPreallocation);
vOutputs.push_back({MakeMofNCCScript(CConditionObj<CCrossChainImport>(EVAL_CROSSCHAIN_IMPORT, dests, 1, &cci), &indexDests), 0, false});
// export thread
@ -6019,8 +6025,8 @@ static const CRPCCommand commands[] =
{ "identity", "getidentity", &getidentity, true },
{ "identity", "listidentities", &listidentities, true },
{ "multichain", "definecurrency", &definecurrency, true },
{ "multichain", "getcurrencydefinitions", &getcurrencydefinitions, true },
{ "multichain", "getcurrencydefinition", &getcurrencydefinition, true },
{ "multichain", "listcurrencies", &listcurrencies, true },
{ "multichain", "getcurrency", &getcurrency, true },
{ "multichain", "getnotarizationdata", &getnotarizationdata, true },
{ "multichain", "getcrossnotarization", &getcrossnotarization, true },
{ "multichain", "submitacceptednotarization", &submitacceptednotarization, true },
@ -6028,9 +6034,9 @@ static const CRPCCommand commands[] =
{ "multichain", "getinitialcurrencystate", &getinitialcurrencystate, true },
{ "multichain", "getcurrencystate", &getcurrencystate, true },
{ "multichain", "sendcurrency", &sendcurrency, true },
{ "multichain", "getpendingchaintransfers", &getpendingchaintransfers, true },
{ "multichain", "getchainexports", &getchainexports, true },
{ "multichain", "getchainimports", &getchainimports, true },
{ "multichain", "getpendingtransfers", &getpendingtransfers, true },
{ "multichain", "getexports", &getexports, true },
{ "multichain", "getimports", &getimports, true },
{ "multichain", "reserveexchange", &reserveexchange, true },
{ "multichain", "getlatestimportsout", &getlatestimportsout, true },
{ "multichain", "getlastimportin", &getlastimportin, true },

2
src/rpc/pbaasrpc.h

@ -25,7 +25,7 @@ bool GetChainTransfers(std::multimap<uint160, std::pair<CInputDescriptor, CReser
bool GetUnspentChainTransfers(std::multimap<uint160, std::pair<CInputDescriptor, CReserveTransfer>> &inputDescriptors, uint160 chainFilter = uint160());
bool GetUnspentChainExports(uint160 chainID, std::multimap<uint160, std::pair<int, CInputDescriptor>> &exportOutputs);
UniValue getcurrencydefinition(const UniValue& params, bool fHelp);
UniValue getcurrency(const UniValue& params, bool fHelp);
UniValue getnotarizationdata(const UniValue& params, bool fHelp);
UniValue getcrossnotarization(const UniValue& params, bool fHelp);
UniValue definecurrency(const UniValue& params, bool fHelp);

2
src/script/script.h

@ -28,7 +28,7 @@
#define OPRETTYPE_OBJECTARR 5
#define OPRETTYPE_STAKEPARAMS2 6
class CCurrencyStateNew;
class CCurrencyState;
class CIdentity;
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE_V2 = 1024;

4
src/txmempool.cpp

@ -53,7 +53,7 @@ double
CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const
{
CAmount nValueIn = tx.GetValueOut()+nFee;
CCurrencyStateNew currencyState;
CCurrencyState currencyState;
unsigned int lastHeight = currentHeight < 1 ? 0 : currentHeight - 1;
if (hasReserve && (currencyState = ConnectedChains.GetCurrencyState(currentHeight - 1)).IsValid())
{
@ -879,7 +879,7 @@ void CTxMemPool::ClearPrioritisation(const uint256 hash)
mapReserveTransactions.erase(hash);
}
bool CTxMemPool::PrioritiseReserveTransaction(const CReserveTransactionDescriptor &txDesc, const CCurrencyStateNew &currencyState)
bool CTxMemPool::PrioritiseReserveTransaction(const CReserveTransactionDescriptor &txDesc, const CCurrencyState &currencyState)
{
LOCK(cs);
uint256 hash = txDesc.ptx->GetHash();

2
src/txmempool.h

@ -218,7 +218,7 @@ public:
/** Affect CreateNewBlock prioritisation of transactions */
void PrioritiseTransaction(const uint256 &hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta);
bool PrioritiseReserveTransaction(const CReserveTransactionDescriptor &txDesc, const CCurrencyStateNew &currencyState);
bool PrioritiseReserveTransaction(const CReserveTransactionDescriptor &txDesc, const CCurrencyState &currencyState);
bool IsKnownReserveTransaction(const uint256 &hash, CReserveTransactionDescriptor &txDesc); // know to be reserve transaction, get descriptor, update mempool
void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta);
void ClearPrioritisation(const uint256 hash);

Loading…
Cancel
Save