r1
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
// Copyright (c) 2017-2018 The PIVX developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef Agrarian_STAKEINPUT_H
|
||||
#define Agrarian_STAKEINPUT_H
|
||||
|
||||
#include "chain.h"
|
||||
#include "streams.h"
|
||||
#include "uint256.h"
|
||||
|
||||
class CKeyStore;
|
||||
class CWallet;
|
||||
class CWalletTx;
|
||||
|
||||
class CStakeInput
|
||||
{
|
||||
protected:
|
||||
CBlockIndex* pindexFrom;
|
||||
|
||||
public:
|
||||
virtual ~CStakeInput(){};
|
||||
virtual CBlockIndex* GetIndexFrom() = 0;
|
||||
virtual bool CreateTxIn(CWallet* pwallet, CTxIn& txIn, uint256 hashTxOut = 0) = 0;
|
||||
virtual bool GetTxFrom(CTransaction& tx) = 0;
|
||||
virtual CAmount GetValue() = 0;
|
||||
virtual bool CreateTxOuts(CWallet* pwallet, vector<CTxOut>& vout, CAmount nTotal) = 0;
|
||||
virtual bool GetModifier(uint64_t& nStakeModifier) = 0;
|
||||
virtual bool IsZAGR() = 0;
|
||||
virtual CDataStream GetUniqueness() = 0;
|
||||
virtual uint256 GetSerialHash() const = 0;
|
||||
};
|
||||
|
||||
|
||||
// zAGRStake can take two forms
|
||||
// 1) the stake candidate, which is a zcmint that is attempted to be staked
|
||||
// 2) a staked zagr, which is a zcspend that has successfully staked
|
||||
class CZPivStake : public CStakeInput
|
||||
{
|
||||
private:
|
||||
uint32_t nChecksum;
|
||||
bool fMint;
|
||||
libzerocoin::CoinDenomination denom;
|
||||
uint256 hashSerial;
|
||||
|
||||
public:
|
||||
explicit CZPivStake(libzerocoin::CoinDenomination denom, const uint256& hashSerial)
|
||||
{
|
||||
this->denom = denom;
|
||||
this->hashSerial = hashSerial;
|
||||
this->pindexFrom = nullptr;
|
||||
fMint = true;
|
||||
}
|
||||
|
||||
explicit CZPivStake(const libzerocoin::CoinSpend& spend);
|
||||
|
||||
CBlockIndex* GetIndexFrom() override;
|
||||
bool GetTxFrom(CTransaction& tx) override;
|
||||
CAmount GetValue() override;
|
||||
bool GetModifier(uint64_t& nStakeModifier) override;
|
||||
CDataStream GetUniqueness() override;
|
||||
bool CreateTxIn(CWallet* pwallet, CTxIn& txIn, uint256 hashTxOut = 0) override;
|
||||
bool CreateTxOuts(CWallet* pwallet, vector<CTxOut>& vout, CAmount nTotal) override;
|
||||
bool MarkSpent(CWallet* pwallet, const uint256& txid);
|
||||
bool IsZAGR() override { return true; }
|
||||
uint256 GetSerialHash() const override { return hashSerial; }
|
||||
int GetChecksumHeightFromMint();
|
||||
int GetChecksumHeightFromSpend();
|
||||
uint32_t GetChecksum();
|
||||
};
|
||||
|
||||
class CPivStake : public CStakeInput
|
||||
{
|
||||
private:
|
||||
CTransaction txFrom;
|
||||
unsigned int nPosition;
|
||||
public:
|
||||
CPivStake()
|
||||
{
|
||||
this->pindexFrom = nullptr;
|
||||
}
|
||||
|
||||
bool SetInput(CTransaction txPrev, unsigned int n);
|
||||
|
||||
CBlockIndex* GetIndexFrom() override;
|
||||
bool GetTxFrom(CTransaction& tx) override;
|
||||
CAmount GetValue() override;
|
||||
bool GetModifier(uint64_t& nStakeModifier) override;
|
||||
CDataStream GetUniqueness() override;
|
||||
bool CreateTxIn(CWallet* pwallet, CTxIn& txIn, uint256 hashTxOut = 0) override;
|
||||
bool CreateTxOuts(CWallet* pwallet, vector<CTxOut>& vout, CAmount nTotal) override;
|
||||
bool IsZAGR() override { return false; }
|
||||
uint256 GetSerialHash() const override { return uint256(0); }
|
||||
};
|
||||
|
||||
|
||||
#endif //Agrarian_STAKEINPUT_H
|
||||
Reference in New Issue
Block a user