]> Git Repo - VerusCoin.git/commitdiff
Set ID root to Verus, make chain IDs case insensitive to prepare for PBaaS/ID compati...
authormiketout <[email protected]>
Thu, 14 Nov 2019 02:22:29 +0000 (18:22 -0800)
committermiketout <[email protected]>
Thu, 14 Nov 2019 02:22:29 +0000 (18:22 -0800)
src/init.cpp
src/key_io.cpp
src/pbaas/crosschainrpc.h
src/pbaas/identity.cpp
src/pbaas/pbaas.cpp
src/rpc/pbaasrpc.cpp

index 674a7e3616bc290c50a0ceb6e13be961aa8984c3..6667395e93c9f448e7916274343331aae7932545 100644 (file)
@@ -1221,7 +1221,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
         else
         {
             CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV2, 1);
-            CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV3, 200);
+            CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV3, 110);
             //CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV4, 1);
         }
     }
index 8578f8d3fb2c28ce9a6840720afe3c0cc6ecc2ea..fe6e1c8abddb746c46bf2776e7ef13904da33525 100644 (file)
@@ -18,6 +18,8 @@
 #include <string.h>
 #include <algorithm>
 
+extern uint160 VERUS_CHAINID;
+
 namespace
 {
 class DestinationEncoder : public boost::static_visitor<std::string>
@@ -144,7 +146,7 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
     }
     else if (std::count(str.begin(), str.end(), '@') == 1)
     {
-        return CIdentityID(CIdentity::GetID(str, uint160()));
+        return CIdentityID(CIdentity::GetID(str, VERUS_CHAINID));
     }
     
     return CNoDestination();
index 4729d9b25dc2692d78a5ded83e1d68a19449278a..b691b69adc6832918e5a3a4e2476e928ff82b7a9 100644 (file)
@@ -20,6 +20,7 @@
 #include "streams.h"
 #include "pubkey.h"
 #include "base58.h"
+#include "boost/algorithm/string.hpp"
 
 static const int DEFAULT_RPC_TIMEOUT=900;
 static const uint32_t PBAAS_VERSION = 1;
@@ -50,7 +51,7 @@ public:
 
     inline static uint160 GetChainID(std::string name)
     {
-        const char *chainName = name.c_str();
+        const char *chainName = boost::algorithm::to_lower_copy(name).c_str();
         uint256 chainHash = Hash(chainName, chainName + strlen(chainName));
         return Hash160(chainHash.begin(), chainHash.end());
     }
index 90ff0abbcdf04f809e9318d40ffe1ebfa60fe81d..b6c5235c7a3fb8c6a8d6b4e956963140bdcde1ee 100644 (file)
@@ -466,6 +466,12 @@ bool PrecheckIdentityReservation(const CTransaction &tx, int32_t outNum, CValida
         return state.Error("Invalid identity redefinition");
     }
 
+    // CHECK #3 - must be rooted in this chain
+    if (newIdentity.parent != ConnectedChains.ThisChain().GetChainID())
+    {
+        return state.Error("Identity parent of new identity must be current chain");
+    }
+
     // CHECK #3a - if dupID is valid, we need to be spending it to recover. redefinition is invalid
     CTxIn idTxIn;
     uint32_t priorHeightOut;
@@ -611,19 +617,38 @@ bool PrecheckIdentityPrimary(const CTransaction &tx, int32_t outNum, CValidation
 {
     AssertLockHeld(cs_main);
 
+    bool validReservation = false;
+    bool validIdentity = false;
+
+    CNameReservation nameRes;
+    CIdentity identity;
+
     for (auto &output : tx.vout)
     {
         COptCCParams p;
-        if (output.scriptPubKey.IsPayToCryptoCondition(p) && p.IsValid() && p.version >= COptCCParams::VERSION_V3 && p.evalCode == EVAL_IDENTITY_RESERVATION)
+        if (output.scriptPubKey.IsPayToCryptoCondition(p) && p.IsValid() && p.version >= COptCCParams::VERSION_V3 && p.evalCode == EVAL_IDENTITY_RESERVATION && p.vData.size() > 1 && (nameRes = CNameReservation(p.vData[0])).IsValid())
         {
-            return true;
+            // twice through makes it invalid
+            if (validReservation)
+            {
+                return state.Error("Invalid multiple identity reservations on one transaction");
+            }
+            validReservation = true;
+        }
+        else if (p.IsValid() && p.version >= COptCCParams::VERSION_V3 && p.evalCode == EVAL_IDENTITY_PRIMARY && p.vData.size() > 1 && (identity = CIdentity(p.vData[0])).IsValid())
+        {
+            // twice through makes it invalid
+            if (validIdentity)
+            {
+                return state.Error("Invalid multiple identity definitions on one transaction");
+            }
+            validIdentity = true;
         }
     }
 
     // if we made it to here without an early, positive exit, we must determine that we are spending a matching identity, and if so, all is fine so far
     CTransaction inTx;
     uint256 blkHash;
-    CIdentity identity;
     COptCCParams p;
     LOCK(mempool.cs);
     for (auto &input : tx.vin)
index 9e81ff6b32f9e32831107c349ef595a4e7c1d2fe..c4b7fea34ee203209cfa52b0cce5e1a3e3756ccb 100644 (file)
@@ -493,9 +493,7 @@ CCrossChainExport::CCrossChainExport(const CTransaction &tx)
 
 uint160 CPBaaSChainDefinition::GetChainID(std::string name)
 {
-    const char *chainName = name.c_str();
-    uint256 chainHash = Hash(chainName, chainName + strlen(chainName));
-    return Hash160(chainHash.begin(), chainHash.end());
+    return CCrossChainRPCData::GetChainID(name);
 }
 
 uint160 CPBaaSChainDefinition::GetConditionID(int32_t condition) const
index d78d12211acb5e360515dd5d9e2e7ac8064d1aab..4a432ce00da15940d4dc98d17198cd1b87e2e44f 100644 (file)
@@ -4177,7 +4177,7 @@ UniValue registernamecommitment(const UniValue& params, bool fHelp)
 
     CheckIdentityAPIsValid();
 
-    uint160 parent = IsVerusActive() ? uint160() : ConnectedChains.ThisChain().GetChainID();
+    uint160 parent;
     std::string name = CleanName(uni_get_str(params[0]), parent);
 
     // if either we have an invalid name or an implied parent, that is not valid
@@ -4186,6 +4186,8 @@ UniValue registernamecommitment(const UniValue& params, bool fHelp)
         throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid name for commitment");
     }
 
+    parent = ConnectedChains.ThisChain().GetChainID();
+
     CTxDestination dest = DecodeDestination(uni_get_str(params[1]));
     if (dest.which() == COptCCParams::ADDRTYPE_INVALID)
     {
@@ -4277,8 +4279,8 @@ UniValue registeridentity(const UniValue& params, bool fHelp)
 
     CheckIdentityAPIsValid();
 
-    // all names have a parent of the current chain, except if defined on the Verus chain, which has a parent of null
-    uint160 parent = IsVerusActive() ? uint160() : ConnectedChains.ThisChain().GetChainID();
+    // all names have a parent of the current chain
+    uint160 parent = ConnectedChains.ThisChain().GetChainID();
 
     uint256 txid = uint256S(uni_get_str(find_value(params[0], "txid")));
     CNameReservation reservation(find_value(params[0], "namereservation"));
This page took 0.04047 seconds and 4 git commands to generate.