]> Git Repo - VerusCoin.git/blobdiff - src/script/script.h
Bubble up launch nodes on currency definitions and spent currency check
[VerusCoin.git] / src / script / script.h
index e95880ad1b79cf67e4666d261068ec3be489e477..d7fd32a86af00620ab8b81ccd76fed73fd735262 100644 (file)
@@ -409,6 +409,17 @@ public:
     CQuantumID(const uint160& in) : uint160(in) {}
 };
 
+/** A reference to an index only address type, not used in the API or externally, but
+ * reserved as an index for specific types of transaction outputs that can then be queried
+ * and assumed to be valid and checked if found.
+ * CQuantum public keys are indexed by a CIndexID that represents a hash of the quantum public key. */
+class CIndexID : public uint160
+{
+public:
+    CIndexID() : uint160() {}
+    CIndexID(const uint160& in) : uint160(in) {}
+};
+
 /** 
  * A txout script template with a specific destination. It is either:
  *  * CNoDestination: no destination set
@@ -416,9 +427,9 @@ public:
  *  * CScriptID: TX_SCRIPTHASH destination
  *  A CTxDestination is the internal data type encoded in a bitcoin address
  */
-typedef boost::variant<CNoDestination, CPubKey, CKeyID, CScriptID, CIdentityID, CQuantumID> CTxDestination;
+typedef boost::variant<CNoDestination, CPubKey, CKeyID, CScriptID, CIdentityID, CIndexID, CQuantumID> CTxDestination;
 
-CTxDestination TransferDestinationToDestination(const CTransferDestination &trasnferDest);
+CTxDestination TransferDestinationToDestination(const CTransferDestination &transferDest);
 CTransferDestination DestinationToTransferDestination(const CTxDestination &dest);
 CTransferDestination IdentityToTransferDestination(const CIdentity &identity);
 CIdentity TransferDestinationToIdentity(const CTransferDestination &dest);
@@ -427,35 +438,48 @@ std::vector<CTransferDestination> DestinationsToTransferDestinations(const std::
 
 class COptCCParams
 {
-    public:
-        static const uint8_t VERSION_V1 = 1;
-        static const uint8_t VERSION_V2 = 2;
-        static const uint8_t VERSION_V3 = 3;
+protected:
+    static std::set<uint160> feeCurrencies;
 
-        static const uint8_t ADDRTYPE_INVALID = 0;
-        static const uint8_t ADDRTYPE_PK = 1;
-        static const uint8_t ADDRTYPE_PKH = 2;
-        static const uint8_t ADDRTYPE_SH = 3;
-        static const uint8_t ADDRTYPE_ID = 4;
-        static const uint8_t ADDRTYPE_QUANTUM = 5;
-        static const uint8_t ADDRTYPE_LAST = 5;
+public:
+    static const uint8_t VERSION_V1 = 1;
+    static const uint8_t VERSION_V2 = 2;
+    static const uint8_t VERSION_V3 = 3;
+
+    static const uint8_t ADDRTYPE_INVALID = 0;
+    static const uint8_t ADDRTYPE_PK = 1;
+    static const uint8_t ADDRTYPE_PKH = 2;
+    static const uint8_t ADDRTYPE_SH = 3;
+    static const uint8_t ADDRTYPE_ID = 4;
+    static const uint8_t ADDRTYPE_INDEX = 5;
+    static const uint8_t ADDRTYPE_QUANTUM = 6;
+    static const uint8_t ADDRTYPE_LAST = 6;
+
+    uint8_t version;
+    uint8_t evalCode;
+    uint8_t m, n; // for m of n sigs required, n pub keys for sigs will follow
+    std::vector<CTxDestination> vKeys;
+    std::vector<std::vector<unsigned char>> vData; // extra parameters
 
-        uint8_t version;
-        uint8_t evalCode;
-        uint8_t m, n; // for m of n sigs required, n pub keys for sigs will follow
-        std::vector<CTxDestination> vKeys;
-        std::vector<std::vector<unsigned char>> vData; // extra parameters
+    COptCCParams() : version(0), evalCode(0), m(0), n(0) {}
 
-        COptCCParams() : version(0), evalCode(0), m(0), n(0) {}
+    COptCCParams(uint8_t ver, uint8_t code, uint8_t _m, uint8_t _n, const std::vector<CTxDestination> &vkeys, const std::vector<std::vector<unsigned char>> &vdata) : 
+        version(ver), evalCode(code), m(_m), n(_n), vKeys(vkeys), vData(vdata) {}
 
-        COptCCParams(uint8_t ver, uint8_t code, uint8_t _m, uint8_t _n, const std::vector<CTxDestination> &vkeys, const std::vector<std::vector<unsigned char>> &vdata) : 
-            version(ver), evalCode(code), m(_m), n(_n), vKeys(vkeys), vData(vdata) {}
+    COptCCParams(const std::vector<unsigned char> &vch);
 
-        COptCCParams(std::vector<unsigned char> &vch);
+    bool IsValid() const { return version == VERSION_V1 || version == VERSION_V2 || version == VERSION_V3; }
 
-        bool IsValid() const { return version == VERSION_V1 || version == VERSION_V2 || version == VERSION_V3; }
+    std::vector<unsigned char> AsVector() const;
 
-        std::vector<unsigned char> AsVector() const;
+    std::set<CIndexID> GetIndexKeys() const;
+    std::map<uint160, uint32_t> GetIndexHeightOffsets(uint32_t height) const;
+    std::vector<CTxDestination> GetDestinations() const;
+    static void AddFeeCurrency(const uint160 &feeCurrency);
+    static bool IsFeeCurrency(const uint160 &currencyID)
+    {
+        return feeCurrencies.count(currencyID);
+    }
 };
 
 // This is for STAKEGUARD2, which is versioned and enables staking the reserve of a reserve currency
@@ -759,8 +783,10 @@ public:
     bool IsPayToCryptoCondition() const;
     CScript &ReplaceCCParams(const COptCCParams &params);
 
+    bool IsSpendableOutputType(const COptCCParams &p) const;
+    bool IsSpendableOutputType() const;
     CCurrencyValueMap ReserveOutValue() const;
-    CCurrencyValueMap ReserveOutValue(COptCCParams &p) const;
+    CCurrencyValueMap ReserveOutValue(COptCCParams &p, bool spendingOnly=false) const;
     bool SetReserveOutValue(const CCurrencyValueMap &newValue);
 
     bool IsCoinImport() const;
@@ -776,7 +802,8 @@ public:
         P2CC = 1,   // CCs are actually not an address type, but as a type of transaction, they are identified historicall as P2PKH. they now can also pay to IDs.
         P2SH = 2,
         P2ID = 3,
-        P2QRK = 4,
+        P2IDX = 4,
+        P2QRK = 5,
     };
 
     ScriptType GetType() const;
This page took 0.026095 seconds and 4 git commands to generate.