forked from heliumchain/squorum
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstakeinput.h
90 lines (76 loc) · 2.71 KB
/
stakeinput.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// 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 PIVX_STAKEINPUT_H
#define PIVX_STAKEINPUT_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 IsZPIV() = 0;
virtual CDataStream GetUniqueness() = 0;
};
// zPIVStake can take two forms
// 1) the stake candidate, which is a zcmint that is attempted to be staked
// 2) a staked zpiv, 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 IsZPIV() override { return true; }
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 IsZPIV() override { return false; }
};
#endif //PIVX_STAKEINPUT_H