LCOV - code coverage report
Current view: top level - src/zpiv - zpivmodule.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 13 0.0 %
Date: 2025-02-23 09:33:43 Functions: 0 4 0.0 %

          Line data    Source code
       1             : // Copyright (c) 2019-2021 The PIVX Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : //
       5             : #ifndef PIVX_ZPIV_ZPIVMODULE_H
       6             : #define PIVX_ZPIV_ZPIVMODULE_H
       7             : 
       8             : #include "libzerocoin/bignum.h"
       9             : #include "libzerocoin/Denominations.h"
      10             : #include "libzerocoin/CoinSpend.h"
      11             : #include "libzerocoin/Coin.h"
      12             : #include "libzerocoin/CoinRandomnessSchnorrSignature.h"
      13             : #include "libzerocoin/SpendType.h"
      14             : #include "primitives/transaction.h"
      15             : #include "script/script.h"
      16             : #include "serialize.h"
      17             : #include "uint256.h"
      18             : #include <streams.h>
      19             : #include <utilstrencodings.h>
      20             : #include "chainparams.h"
      21             : 
      22             : static int const PUBSPEND_SCHNORR = 4;
      23             : 
      24             : class PublicCoinSpend : public libzerocoin::CoinSpend {
      25             : public:
      26             : 
      27           0 :     explicit PublicCoinSpend(libzerocoin::ZerocoinParams* params): pubCoin(params) {};
      28             :     template <typename Stream> PublicCoinSpend(libzerocoin::ZerocoinParams* params, Stream& strm);
      29             : 
      30           0 :     ~PublicCoinSpend(){};
      31             : 
      32             :     const uint256 signatureHash() const override;
      33             :     bool HasValidSignature() const;
      34             :     bool Verify() const;
      35           0 :     int getCoinVersion() const { return this->coinVersion; }
      36             : 
      37             :     // Members
      38             :     int coinVersion;
      39             :     CBigNum randomness;
      40             :     libzerocoin::CoinRandomnessSchnorrSignature schnorrSig;
      41             :     // prev out values
      42             :     uint256 txHash;
      43             :     unsigned int outputIndex = -1;
      44             :     libzerocoin::PublicCoin pubCoin;
      45             : 
      46           0 :     SERIALIZE_METHODS(PublicCoinSpend, obj) {
      47           0 :         READWRITE(obj.version);
      48           0 :         if (obj.version < PUBSPEND_SCHNORR) {
      49           0 :             READWRITE(obj.coinSerialNumber, obj.randomness, obj.pubkey, obj.vchSig);
      50             :         } else {
      51           0 :             READWRITE(obj.coinVersion);
      52           0 :             if (obj.coinVersion < libzerocoin::PUBKEY_VERSION) {
      53           0 :                 READWRITE(obj.coinSerialNumber);
      54             :             } else {
      55           0 :                 READWRITE(obj.pubkey, obj.vchSig);
      56             :             }
      57           0 :             READWRITE(obj.schnorrSig);
      58             :         }
      59           0 :     }
      60             : };
      61             : 
      62             : 
      63             : class CValidationState;
      64             : 
      65             : namespace ZPIVModule {
      66             :     CDataStream ScriptSigToSerializedSpend(const CScript& scriptSig);
      67             :     PublicCoinSpend parseCoinSpend(const CTxIn &in);
      68             :     bool parseCoinSpend(const CTxIn &in, const CTransaction& tx, const CTxOut &prevOut, PublicCoinSpend& publicCoinSpend);
      69             :     libzerocoin::CoinSpend TxInToZerocoinSpend(const CTxIn& txin);
      70             :     bool validateInput(const CTxIn &in, const CTxOut &prevOut, const CTransaction& tx, PublicCoinSpend& ret);
      71             : 
      72             :     // Public zc spend parse
      73             :     /**
      74             :      *
      75             :      * @param in --> public zc spend input
      76             :      * @param tx --> input parent
      77             :      * @param publicCoinSpend ---> return the publicCoinSpend parsed
      78             :      * @return true if everything went ok
      79             :      */
      80             :     bool ParseZerocoinPublicSpend(const CTxIn &in, const CTransaction& tx, CValidationState& state, PublicCoinSpend& publicCoinSpend);
      81             : 
      82             :     // Clear the coinspend cache
      83             :     void CleanCoinSpendsCache();
      84             : };
      85             : 
      86             : 
      87             : #endif // PIVX_ZPIV_ZPIVMODULE_H

Generated by: LCOV version 1.14