text: // Copyright (c) 2018 The Bitcoin Core developers
  // Copyright (c) 2017 The Raven Core developers
  // Copyright (c) 2018 The Rito Core developers
  // Copyright (c) 2020 The Ukcoin Core developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #ifndef UKC_SPENTINDEX_H
  #define UKC_SPENTINDEX_H
  
  #include "uint256.h"
  #include "amount.h"
  
  struct CSpentIndexKey {
      uint256 txid;
      unsigned int outputIndex;
  
      ADD_SERIALIZE_METHODS;
  
      template <typename Stream, typename Operation>
      inline void SerializationOp(Stream& s, Operation ser_action) {
          READWRITE(txid);
          READWRITE(outputIndex);
      }
  
      CSpentIndexKey(uint256 t, unsigned int i) {
          txid = t;
          outputIndex = i;
      }
  
      CSpentIndexKey() {
          SetNull();
      }
  
      void SetNull() {
          txid.SetNull();
          outputIndex = 0;
      }
  
  };
  
  struct CSpentIndexValue {
      uint256 txid;
      unsigned int inputIndex;
      int blockHeight;
      CAmount satoshis;
      int addressType;
      uint160 addressHash;
  
      ADD_SERIALIZE_METHODS;
  
      template <typename Stream, typename Operation>
      inline void SerializationOp(Stream& s, Operation ser_action) {
          READWRITE(txid);
          READWRITE(inputIndex);
          READWRITE(blockHeight);
          READWRITE(satoshis);
          READWRITE(addressType);
          READWRITE(addressHash);
      }
  
      CSpentIndexValue(uint256 t, unsigned int i, int h, CAmount s, int type, uint160 a) {
          txid = t;
          inputIndex = i;
          blockHeight = h;
          satoshis = s;
          addressType = type;
          addressHash = a;
      }
  
      CSpentIndexValue() {
          SetNull();
      }
  
      void SetNull() {
          txid.SetNull();
          inputIndex = 0;
          blockHeight = 0;
          satoshis = 0;
          addressType = 0;
          addressHash.SetNull();
      }
  
      bool IsNull() const {
          return txid.IsNull();
      }
  };
  
  struct CSpentIndexKeyCompare
  {
      bool operator()(const CSpentIndexKey& a, const CSpentIndexKey& b) const {
          if (a.txid == b.txid) {
              return a.outputIndex < b.outputIndex;
          } else {
              return a.txid < b.txid;
          }
      }
  };
  
  #endif // UKC_SPENTINDEX_H
  