]> Git Repo - VerusCoin.git/commitdiff
Fix PBaaS launch up to completion
authormiketout <[email protected]>
Sun, 7 Mar 2021 02:20:22 +0000 (18:20 -0800)
committermiketout <[email protected]>
Sun, 7 Mar 2021 02:20:22 +0000 (18:20 -0800)
src/core_write.cpp
src/pbaas/pbaas.cpp
src/pbaas/pbaas.h
src/pbaas/reserves.cpp
src/pbaas/reserves.h
src/rpc/pbaasrpc.cpp
src/script/script.cpp

index bd0cae9fde7bde435e88e3d988d61c80a8e93ffb..95caad3537b7de41f5cff5c16b9399724481f1b8 100644 (file)
@@ -697,9 +697,8 @@ UniValue CCurrencyDefinition::ToUniValue() const
         obj.push_back(Pair("preallocation", preAllocationArr));
     }
 
-    if ((IsPBaaSChain() && !gatewayConverterName.empty()) || IsPBaaSConverter())
+    if ((IsPBaaSChain() || IsGateway()))
     {
-        obj.push_back(Pair("gatewayconvertername", gatewayConverterName));
         obj.push_back(Pair("gatewayid", gatewayID.GetHex()));
         obj.push_back(Pair("gatewayconverterissuance", ValueFromAmount(gatewayConverterIssuance)));
     }
index 84aec21c1e3d9cc2e07f4014e11e30bc527d14d8..7c8aa841f023d6cdbb1bbcccbdeda5b7cd6d77ab 100644 (file)
@@ -1359,52 +1359,62 @@ CCurrencyDefinition CConnectedChains::UpdateCachedCurrency(const uint160 &curren
 }
 
 
-// returns all unspent chain exports for a specific chain/system, indexed by the actuall currency destination
-bool CConnectedChains::GetUnspentSystemExports(const uint160 systemID, multimap<uint160, pair<int, CInputDescriptor>> &exportOutputs)
+// returns all unspent chain exports for a specific chain/currency
+bool CConnectedChains::GetUnspentSystemExports(const CCoinsViewCache &view, 
+                                               const uint160 systemID, 
+                                               std::vector<pair<int, CInputDescriptor>> &exportOutputs)
 {
     std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>> unspentOutputs;
+    std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta>> exportUTXOs;
+
+    std::vector<pair<int, CInputDescriptor>> exportOuts;
 
     LOCK2(cs_main, mempool.cs);
 
-    if (!GetAddressUnspent(CCrossChainRPCData::GetConditionID(systemID, CCrossChainExport::SystemExportKey()), CScript::P2IDX, unspentOutputs))
-    {
-        return false;
-    }
-    else
-    {
-        CCoinsViewCache view(pcoinsTip);
+    uint160 exportIndexKey = CCrossChainRPCData::GetConditionID(systemID, CCrossChainExport::SystemExportKey());
 
-        for (auto it = unspentOutputs.begin(); it != unspentOutputs.end(); it++)
+    if (mempool.getAddressIndex(std::vector<std::pair<uint160, int32_t>>({{exportIndexKey, CScript::P2IDX}}), exportUTXOs) &&
+        exportUTXOs.size())
+    {
+        // we need to remove those that are spent
+        std::map<COutPoint, CInputDescriptor> memPoolOuts;
+        for (auto &oneExport : exportUTXOs)
         {
-            CCoins coins;
-
-            if (view.GetCoins(it->first.txhash, coins))
+            if (oneExport.first.spending)
             {
-                int i = it->first.index;
-                if (coins.IsAvailable(i))
-                {
-                    // if this is an export output, optionally to this chain, add it to the input vector
-                    COptCCParams p;
-                    CCrossChainExport cx;
-                    if (coins.vout[i].scriptPubKey.IsPayToCryptoCondition(p) && p.IsValid() && p.evalCode == EVAL_CROSSCHAIN_EXPORT &&
-                        p.vData.size() && (cx = CCrossChainExport(p.vData[0])).IsValid())
-                    {
-                        exportOutputs.insert(make_pair(cx.destCurrencyID,
-                                                    make_pair(coins.nHeight, CInputDescriptor(coins.vout[i].scriptPubKey, coins.vout[i].nValue, CTxIn(COutPoint(it->first.txhash, i))))));
-                    }
-                }
+                memPoolOuts.erase(COutPoint(oneExport.first.txhash, oneExport.first.index));
             }
             else
             {
-                printf("%s: cannot retrieve transaction %s\n", __func__, it->first.txhash.GetHex().c_str());
-                return false;
+                const CTransaction oneTx = mempool.mapTx.find(oneExport.first.txhash)->GetTx();
+                memPoolOuts.insert(std::make_pair(COutPoint(oneExport.first.txhash, oneExport.first.index),
+                                                CInputDescriptor(oneTx.vout[oneExport.first.index].scriptPubKey, oneExport.second.amount, 
+                                                            CTxIn(oneExport.first.txhash, oneExport.first.index))));
             }
         }
-        return true;
+
+        for (auto &oneUTXO : memPoolOuts)
+        {
+            exportOuts.push_back(std::make_pair(0, oneUTXO.second));
+        }
     }
+    if (!exportOuts.size() &&
+        !GetAddressUnspent(exportIndexKey, CScript::P2IDX, unspentOutputs))
+    {
+        return false;
+    }
+    else
+    {
+        for (auto it = unspentOutputs.begin(); it != unspentOutputs.end(); it++)
+        {
+            exportOuts.push_back(std::make_pair(it->second.blockHeight, CInputDescriptor(it->second.script, it->second.satoshis, 
+                                                            CTxIn(it->first.txhash, it->first.index))));
+        }
+    }
+    exportOutputs.insert(exportOutputs.end(), exportOuts.begin(), exportOuts.end());
+    return exportOuts.size() != 0;
 }
 
-
 // returns all unspent chain exports for a specific chain/currency
 bool CConnectedChains::GetUnspentCurrencyExports(const CCoinsViewCache &view, 
                                                  const uint160 currencyID, 
@@ -1461,7 +1471,6 @@ bool CConnectedChains::GetUnspentCurrencyExports(const CCoinsViewCache &view,
     return exportOuts.size() != 0;
 }
 
-
 bool CConnectedChains::GetPendingCurrencyExports(const uint160 currencyID,
                                                  uint32_t fromHeight,
                                                  std::vector<pair<int, CInputDescriptor>> &exportOutputs)
@@ -1658,9 +1667,10 @@ bool CConnectedChains::GetReserveDeposits(const uint160 &currencyID, const CCoin
     return true;
 }
 
-// given a set of exports and the reserve deposits for this from another chain, create a set of import transactions
+// given a set of provable exports to this chain from either this chain or another chain or system, 
+// create a set of import transactions
 bool CConnectedChains::CreateLatestImports(const CCurrencyDefinition &sourceSystemDef,                      // transactions imported from system
-                                           const CUTXORef &confirmedSourceNotarization,                     // last notarization of exporting system
+                                           const CUTXORef &confirmedSourceNotarization,                     // relevant notarization of exporting system
                                            const std::vector<std::pair<std::pair<CInputDescriptor,CPartialTransactionProof>,std::vector<CReserveTransfer>>> &exports,
                                            std::map<uint160, std::vector<std::pair<int, CTransaction>>> &newImports)
 {
@@ -2677,7 +2687,7 @@ bool CConnectedChains::CreateNextExport(const CCurrencyDefinition &_curDef,
     bool isPreLaunch = _curDef.launchSystemID == ASSETCHAINS_CHAINID &&
                        _curDef.startBlock > sinceHeight &&
                        !(_curDef.systemID == ASSETCHAINS_CHAINID && sinceHeight == _curDef.startBlock - 1 && curHeight > _curDef.startBlock);
-    bool isClearLaunchExport = isPreLaunch && curHeight == _curDef.startBlock && !lastNotarization.IsLaunchCleared();
+    bool isClearLaunchExport = isPreLaunch && curHeight >= _curDef.startBlock && !lastNotarization.IsLaunchCleared();
 
     if (!isClearLaunchExport && !_txInputs.size() && !addInputTx)
     {
@@ -2953,7 +2963,7 @@ bool CConnectedChains::CreateNextExport(const CCurrencyDefinition &_curDef,
 
     // if we should add a system export, do so
     CCrossChainExport sysCCX;
-    if (crossSystem)
+    if (crossSystem && ccx.destSystemID != ccx.destCurrencyID)
     {
         assert(priorExports.size() == 2);
         COptCCParams p;
@@ -2981,6 +2991,7 @@ bool CConnectedChains::CreateNextExport(const CCurrencyDefinition &_curDef,
                                    DestinationToTransferDestination(feeOutput),
                                    std::vector<CReserveTransfer>(),
                                    sysCCX.flags);
+        sysCCX.SetSystemThreadExport();
     }
 
     CAmount nativeReserveDeposit = 0;
@@ -3013,7 +3024,8 @@ bool CConnectedChains::CreateNextExport(const CCurrencyDefinition &_curDef,
     std::vector<CTxDestination> dests = std::vector<CTxDestination>({CPubKey(ParseHex(CC.CChexstr)).GetID()});
     exportOutputs.push_back(CTxOut(0, MakeMofNCCScript(CConditionObj<CCrossChainExport>(EVAL_CROSSCHAIN_EXPORT, dests, 1, &ccx))));
 
-    if (crossSystem)
+    // only add an extra system export if we aren't actually exporting to the system itself directly
+    if (crossSystem && ccx.destSystemID != ccx.destCurrencyID)
     {
         exportOutputs.push_back(CTxOut(0, MakeMofNCCScript(CConditionObj<CCrossChainExport>(EVAL_CROSSCHAIN_EXPORT, dests, 1, &sysCCX))));
     }
@@ -3183,7 +3195,7 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                     p.evalCode == EVAL_CURRENCY_DEFINITION &&
                     p.vData.size() &&
                     (oneDef = CCurrencyDefinition(p.vData[0])).IsValid() &&
-                    oneDef.systemID == ASSETCHAINS_CHAINID)
+                    oneDef.launchSystemID == ASSETCHAINS_CHAINID)
                 {
                     launchCurrencies.insert(std::make_pair(oneDef.GetID(), std::make_pair(oneDef, CUTXORef())));
                 }
@@ -3273,6 +3285,7 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                     LogPrintf("%s: cannot find destination currency %s\n", __func__, EncodeDestination(CIdentityID(lastChain)).c_str());
                     break;
                 }
+                uint160 destID = lastChain;
 
                 if (destDef.systemID == thisChainID)
                 {
@@ -3286,6 +3299,10 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                         systemDef = destDef;
                     }
                 }
+                else if (destDef.systemID == destID)
+                {
+                    systemDef = destDef;
+                }
                 else
                 {
                     systemDef = GetCachedCurrency(destDef.systemID);
@@ -3306,14 +3323,13 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                 std::vector<std::pair<int, CInputDescriptor>> exportOutputs;
                 std::vector<std::pair<int, CInputDescriptor>> sysExportOutputs;
                 std::vector<CInputDescriptor> allExportOutputs;
-                CCurrencyDefinition lastChainDef = GetCachedCurrency(lastChain);
 
                 // export outputs must come from the latest, including mempool, to ensure
                 // enforcement of sequential exports. get unspent currency export, and if not on the current
                 // system, the external system export as well
 
                 if ((ConnectedChains.GetUnspentCurrencyExports(view, lastChain, exportOutputs) && exportOutputs.size()) &&
-                    (isSameChain || ConnectedChains.GetUnspentCurrencyExports(view, lastChainDef.systemID, sysExportOutputs) && sysExportOutputs.size()))
+                    (isSameChain || ConnectedChains.GetUnspentSystemExports(view, destDef.systemID, sysExportOutputs) && sysExportOutputs.size()))
                 {
                     assert(exportOutputs.size() == 1);
                     std::pair<int, CInputDescriptor> lastExport = exportOutputs[0];
@@ -3339,11 +3355,23 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                            p.vData.size() &&
                            (sysCCX = CCrossChainExport(p.vData[0])).IsValid())))
                     {
-                        printf("%s: invalid export(s) for %s in index\n", __func__, EncodeDestination(CIdentityID(lastChainDef.GetID())).c_str());
-                        LogPrintf("%s: invalid export(s) for %s in index\n", __func__, EncodeDestination(CIdentityID(lastChainDef.GetID())).c_str());
+                        printf("%s: invalid export(s) for %s in index\n", __func__, EncodeDestination(CIdentityID(destID)).c_str());
+                        LogPrintf("%s: invalid export(s) for %s in index\n", __func__, EncodeDestination(CIdentityID(destID)).c_str());
                         break;
                     }
 
+                    // now, in the case that these are both the same export, and/or if this is a sys export thread export
+                    // merge into one export
+                    bool mergedSysExport = false;
+                    if (!isSameChain &&
+                        ccx.destCurrencyID == ccx.destSystemID)
+                    {
+                        ccx.SetSystemThreadExport(false);
+                        mergedSysExport = true;
+                        // remove the system output
+                        allExportOutputs.pop_back();
+                    }
+
                     // now, we have the previous export to this currency/system, which we should spend to
                     // enable this new export. if we find no export, we're done
                     int32_t numInputsUsed;
@@ -3354,8 +3382,8 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                     // get notarization for the actual currency we are exporting
                     if (!GetNotarizationData(lastChain, cnd) || cnd.lastConfirmed == -1)
                     {
-                        printf("%s: missing or invalid notarization for %s\n", __func__, EncodeDestination(CIdentityID(lastChainDef.GetID())).c_str());
-                        LogPrintf("%s: missing or invalid notarization for %s\n", __func__, EncodeDestination(CIdentityID(lastChainDef.GetID())).c_str());
+                        printf("%s: missing or invalid notarization for %s\n", __func__, EncodeDestination(CIdentityID(destID)).c_str());
+                        LogPrintf("%s: missing or invalid notarization for %s\n", __func__, EncodeDestination(CIdentityID(destID)).c_str());
                         break;
                     }
 
@@ -3371,7 +3399,7 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
 
                         // even if we have no txInputs, currencies that need to will launch
                         newNotarizationOutNum = -1;
-                        if (!CConnectedChains::CreateNextExport(lastChainDef,
+                        if (!CConnectedChains::CreateNextExport(destDef,
                                                                 txInputs,
                                                                 allExportOutputs,
                                                                 feeOutput,
@@ -3386,8 +3414,8 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                                                                 newNotarization,
                                                                 newNotarizationOutNum))
                         {
-                            printf("%s: unable to create export for %s\n", __func__, EncodeDestination(CIdentityID(lastChainDef.GetID())).c_str());
-                            LogPrintf("%s: unable to create export for  %s\n", __func__, EncodeDestination(CIdentityID(lastChainDef.GetID())).c_str());
+                            printf("%s: unable to create export for %s\n", __func__, EncodeDestination(CIdentityID(destID)).c_str());
+                            LogPrintf("%s: unable to create export for  %s\n", __func__, EncodeDestination(CIdentityID(destID)).c_str());
                             break;
                         }
 
@@ -3413,9 +3441,8 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                         tb.AddTransparentInput(lastExport.second.txIn.prevout, lastExport.second.scriptPubKey, lastExport.second.nValue);
 
                         // if going to another system, add the system export thread as well
-                        if (!isSameChain)
+                        if (!isSameChain && !mergedSysExport)
                         {
-
                             /* scriptUniOut = UniValue(UniValue::VOBJ);
                             ScriptPubKeyToUniv(lastSysExport.second.scriptPubKey, scriptUniOut, false);
                             printf("adding input %d with %ld nValue and script:\n%s\n", (int)tb.mtx.vin.size(), lastSysExport.second.nValue, scriptUniOut.write(1,2).c_str());
@@ -3443,7 +3470,12 @@ void CConnectedChains::AggregateChainTransfers(const CTxDestination &feeOutput,
                         for (auto &oneOut : exportTxOuts)
                         {
                             COptCCParams xp;
-                            if (oneOut.scriptPubKey.IsPayToCryptoCondition(xp) && xp.IsValid() && xp.evalCode == EVAL_CROSSCHAIN_EXPORT)
+                            CCrossChainExport checkCCX;
+                            if (oneOut.scriptPubKey.IsPayToCryptoCondition(xp) &&
+                                xp.IsValid() && 
+                                xp.evalCode == EVAL_CROSSCHAIN_EXPORT &&
+                                (checkCCX = CCrossChainExport(xp.vData[0])).IsValid() &&
+                                !checkCCX.IsSystemThreadExport())
                             {
                                 thisExport.second.scriptPubKey = oneOut.scriptPubKey;
                                 thisExport.second.nValue = oneOut.nValue;
index c9f9b28c14aee1a04905c7c1a5006d86bb127908..460b7bb156d35a89e9be033eec22f72436764fa8 100644 (file)
@@ -945,8 +945,9 @@ public:
                        CTransaction &lastImport, 
                        int32_t &outputNum);
 
-    bool GetUnspentSystemExports(const uint160 systemID, 
-                                 multimap<uint160, pair<int, CInputDescriptor>> &exportOutputs);
+    bool GetUnspentSystemExports(const CCoinsViewCache &view,
+                                 const uint160 systemID, 
+                                 std::vector<pair<int, CInputDescriptor>> &exportOutputs);
 
     bool GetUnspentCurrencyExports(const CCoinsViewCache &view,
                                    const uint160 currencyID, 
index eec54d11fd4553bf364d2371850c8ff55cc24acc..adad581c8a0e630fd8073b167fa5db382dd8034d 100644 (file)
@@ -188,6 +188,7 @@ CCrossChainImport::CCrossChainImport(const CTransaction &tx, int32_t *pOutNum)
 
 bool CCrossChainExport::GetExportInfo(const CTransaction &exportTx, 
                                       int numExportOut,
+                                      int &primaryExportOutNumOut,
                                       int32_t &nextOutput,
                                       CPBaaSNotarization &exportNotarization,
                                       std::vector<CReserveTransfer> &reserveTransfers,
@@ -199,17 +200,27 @@ bool CCrossChainExport::GetExportInfo(const CTransaction &exportTx,
     // if this is called directly to get info, though it is a supplemental output, it is currently an error
     if (IsSupplemental())
     {
-        return state.Error(strprintf("%s: cannot get export data directly from a supplemental data output. must be in context.",__func__));
+        return state.Error(strprintf("%s: cannot get export data directly from a supplemental data output. must be in context",__func__));
     }
 
     auto hw = CMMRNode<>::GetHashWriter();
-    int numOutput = numExportOut;
 
-    // if this export is from another system, we assume the reserve transfers come as part of this export or as supplemental outputs
+    // this can be called passing either a system export or a normal currency export, and it will always
+    // retrieve information from the same normal currency export in either case and return the primary output num
+    int numOutput = IsSystemThreadExport() ? numExportOut - 1 : numExportOut;
+    if (numOutput < 0)
+    {
+        return state.Error(strprintf("%s: invalid output index for export out or invalid export transaction",__func__));
+    }
+    primaryExportOutNumOut = numOutput;
+
+    // if this export is from our system
     if (sourceSystemID == ASSETCHAINS_CHAINID)
     {
-        // if we're going off-chain, we have a system export output after our currency export. skip it.
-        if (destSystemID != sourceSystemID)
+        // if we're exporting off-chain and not directly to the system currency,
+        // the system currency is added as a system export output, which ensures export serialization from this system
+        // to the other. the system export output will be after our currency export. if so skip it.
+        if (destSystemID != sourceSystemID && destCurrencyID != destSystemID)
         {
             numOutput++;
         }
@@ -240,6 +251,9 @@ bool CCrossChainExport::GetExportInfo(const CTransaction &exportTx,
     }
     else
     {
+        // this is coming from another chain or system.
+        // the proof of this export must already have been checked, so we are
+        // only interested in the reserve transfers for this and any supplements
         CCrossChainExport rtExport = *this;
         while (rtExport.IsValid())
         {
@@ -319,12 +333,13 @@ bool CCrossChainExport::GetExportInfo(const CTransaction &exportTx,
 
 bool CCrossChainExport::GetExportInfo(const CTransaction &exportTx, 
                                     int numExportOut, 
+                                    int &primaryExportOutNumOut,
                                     int32_t &nextOutput,
                                     CPBaaSNotarization &exportNotarization, 
                                     std::vector<CReserveTransfer> &reserveTransfers) const
 {
     CValidationState state;
-    return GetExportInfo(exportTx, numExportOut, nextOutput, exportNotarization, reserveTransfers, state);
+    return GetExportInfo(exportTx, numExportOut, primaryExportOutNumOut, nextOutput, exportNotarization, reserveTransfers, state);
 }
 
 
@@ -386,7 +401,8 @@ bool CCrossChainImport::GetImportInfo(const CTransaction &importTx,
         {
             int32_t nextOutput;
             CPBaaSNotarization xNotarization;
-            if (!ccx.GetExportInfo(exportTx, exportTxOutNum, nextOutput, xNotarization, reserveTransfers, state))
+            int primaryOutNumOut;
+            if (!ccx.GetExportInfo(exportTx, exportTxOutNum, primaryOutNumOut, nextOutput, xNotarization, reserveTransfers, state))
             {
                 return false;
             }
@@ -441,7 +457,8 @@ bool CCrossChainImport::GetImportInfo(const CTransaction &importTx,
         }
         int32_t nextOutput;
         CPBaaSNotarization xNotarization;
-        if (!ccx.GetExportInfo(importTx, evidenceOutStart, nextOutput, xNotarization, reserveTransfers))
+        int primaryOutNumOut;
+        if (!ccx.GetExportInfo(importTx, evidenceOutStart, primaryOutNumOut, nextOutput, xNotarization, reserveTransfers))
         {
             return state.Error(strprintf("%s: invalid export evidence for import 1",__func__));
         }
index 2309d2e0e4f9148f09bad255280013335627c2ce..77098defed0b627ab8fab34f5070cc9f446a2ddf 100644 (file)
@@ -838,7 +838,8 @@ public:
         FLAG_EVIDENCEONLY = 0x10,               // when set, this is not indexed as an active export
         FLAG_GATEWAYEXPORT = 0x20,              // when set, will be exported to a gateway currency, which may get routed from this chain as systemID
         FLAG_DEFINITIONEXPORT = 0x40,           // set on only the first export
-        FLAG_POSTLAUNCH = 0x80                  // set post launch
+        FLAG_POSTLAUNCH = 0x80,                 // set post launch
+        FLAG_SYSTEMTHREAD = 0x100               // export that is there to ensure continuous export thread only
     };
 
     uint16_t nVersion;                          // current version
@@ -994,6 +995,23 @@ public:
         }
     }
 
+    bool IsSystemThreadExport() const
+    {
+        return flags & FLAG_SYSTEMTHREAD;
+    }
+
+    void SetSystemThreadExport(bool setTrue=true)
+    {
+        if (setTrue)
+        {
+            flags |= FLAG_SYSTEMTHREAD;
+        }
+        else
+        {
+            flags &= ~FLAG_SYSTEMTHREAD;
+        }
+    }
+
     bool IsChainDefinition() const
     {
         return flags & FLAG_DEFINITIONEXPORT;
@@ -1030,6 +1048,7 @@ public:
 
     bool GetExportInfo(const CTransaction &exportTx, 
                        int numExportOut,
+                       int &primaryExportOutNumOut,
                        int32_t &nextOutput,
                        CPBaaSNotarization &exportNotarization, 
                        std::vector<CReserveTransfer> &reserveTransfers,
@@ -1037,6 +1056,7 @@ public:
 
     bool GetExportInfo(const CTransaction &exportTx, 
                        int numExportOut, 
+                       int &primaryExportOutNumOut,
                        int32_t &nextOutput,
                        CPBaaSNotarization &exportNotarization, 
                        std::vector<CReserveTransfer> &reserveTransfers) const;
index 9c1160fa4826a4b7d6aae7e199a4114b759dd055..f30c7d74ccafcd27d6e864626174316c1b24f53b 100644 (file)
@@ -338,7 +338,6 @@ bool SetThisChain(const UniValue &chainDefinition)
         ASSETCHAINS_TIMEUNLOCKFROM = 0;
         ASSETCHAINS_TIMEUNLOCKTO = 0;
 
-        LOCK(cs_main);
         //printf("%s: %s\n", __func__, EncodeDestination(CIdentityID(notaryChainDef.GetID())).c_str());
         ConnectedChains.notarySystems[notaryChainDef.GetID()] = 
             CNotarySystemInfo(0, CRPCChainData(notaryChainDef, PBAAS_HOST, PBAAS_PORT, PBAAS_USERPASS), CCurrencyDefinition());
@@ -4056,7 +4055,7 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
 
         CPBaaSNotarization gatewayPbn = CPBaaSNotarization(gatewayCurrencyID, 
                                                            gatewayCurrencyState,
-                                                           0,
+                                                           height,
                                                            CUTXORef(),
                                                            0);
 
index c790f3d6262e5a0453f6f1bd4b6d7166ce9e819c..033d1201b790a70b893daa3148e5496bf0fd6105 100644 (file)
@@ -1150,6 +1150,10 @@ std::set<CIndexID> COptCCParams::GetIndexKeys() const
             if (vData.size() && (ccx = CCrossChainExport(vData[0])).IsValid())
             {
                 destinations.insert(CIndexID(CCrossChainRPCData::GetConditionID(ccx.destCurrencyID, ccx.CurrencyExportKey())));
+                if (ccx.destCurrencyID == ccx.destSystemID && ccx.destCurrencyID != ASSETCHAINS_CHAINID)
+                {
+                    destinations.insert(CIndexID(CCrossChainRPCData::GetConditionID(ccx.destSystemID, ccx.SystemExportKey())));
+                }
             }
             break;
         }
@@ -1201,9 +1205,11 @@ std::map<uint160, uint32_t> COptCCParams::GetIndexHeightOffsets(uint32_t height)
     CCurrencyDefinition curDef;
     if (evalCode == EVAL_CURRENCY_DEFINITION &&
         vData.size() &&
-        (curDef = CCurrencyDefinition(vData[0])).IsValid())
+        (curDef = CCurrencyDefinition(vData[0])).IsValid() &&
+        curDef.launchSystemID == ASSETCHAINS_CHAINID &&
+        height <= curDef.startBlock)
     {
-        offsets.insert(make_pair(CCrossChainRPCData::GetConditionID(curDef.systemID, CCurrencyDefinition::CurrencyLaunchKey()),
+        offsets.insert(make_pair(CCrossChainRPCData::GetConditionID(ASSETCHAINS_CHAINID, CCurrencyDefinition::CurrencyLaunchKey()),
                                  (uint32_t)curDef.startBlock));
     }
     return offsets;
This page took 0.06086 seconds and 4 git commands to generate.