Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

providertx.h
Go to the documentation of this file.
1 // Copyright (c) 2018-2020 The Dash 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 DASH_PROVIDERTX_H
6 #define DASH_PROVIDERTX_H
7 
8 #include <bls/bls.h>
9 #include <consensus/validation.h>
10 #include <primitives/transaction.h>
11 
12 #include <base58.h>
13 #include <netaddress.h>
14 #include <pubkey.h>
15 #include <univalue.h>
16 
17 class CBlockIndex;
18 
19 class CProRegTx
20 {
21 public:
22  static const uint16_t CURRENT_VERSION = 1;
23 
24 public:
25  uint16_t nVersion{CURRENT_VERSION}; // message version
26  uint16_t nType{0}; // only 0 supported for now
27  uint16_t nMode{0}; // only 0 supported for now
28  COutPoint collateralOutpoint{uint256(), (uint32_t)-1}; // if hash is null, we refer to a ProRegTx output
33  uint16_t nOperatorReward{0};
35  uint256 inputsHash; // replay protection
36  std::vector<unsigned char> vchSig;
37 
38 public:
40 
41  template <typename Stream, typename Operation>
42  inline void SerializationOp(Stream& s, Operation ser_action)
43  {
48  READWRITE(addr);
55  if (!(s.GetType() & SER_GETHASH)) {
57  }
58  }
59 
60  // When signing with the collateral key, we don't sign the hash but a generated message instead
61  // This is needed for HW wallet support which can only sign text messages as of now
62  std::string MakeSignString() const;
63 
64  std::string ToString() const;
65 
66  void ToJson(UniValue& obj) const
67  {
68  obj.clear();
69  obj.setObject();
70  obj.push_back(Pair("version", nVersion));
71  obj.push_back(Pair("collateralHash", collateralOutpoint.hash.ToString()));
72  obj.push_back(Pair("collateralIndex", (int)collateralOutpoint.n));
73  obj.push_back(Pair("service", addr.ToString(false)));
74  obj.push_back(Pair("ownerAddress", EncodeDestination(keyIDOwner)));
75  obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting)));
76 
77  CTxDestination dest;
78  if (ExtractDestination(scriptPayout, dest)) {
79  obj.push_back(Pair("payoutAddress", EncodeDestination(dest)));
80  }
81  obj.push_back(Pair("pubKeyOperator", pubKeyOperator.ToString()));
82  obj.push_back(Pair("operatorReward", (double)nOperatorReward / 100));
83 
84  obj.push_back(Pair("inputsHash", inputsHash.ToString()));
85  }
86 };
87 
89 {
90 public:
91  static const uint16_t CURRENT_VERSION = 1;
92 
93 public:
94  uint16_t nVersion{CURRENT_VERSION}; // message version
98  uint256 inputsHash; // replay protection
100 
101 public:
103 
104  template <typename Stream, typename Operation>
105  inline void SerializationOp(Stream& s, Operation ser_action)
106  {
109  READWRITE(addr);
112  if (!(s.GetType() & SER_GETHASH)) {
113  READWRITE(sig);
114  }
115  }
116 
117 public:
118  std::string ToString() const;
119 
120  void ToJson(UniValue& obj) const
121  {
122  obj.clear();
123  obj.setObject();
124  obj.push_back(Pair("version", nVersion));
125  obj.push_back(Pair("proTxHash", proTxHash.ToString()));
126  obj.push_back(Pair("service", addr.ToString(false)));
127  CTxDestination dest;
129  obj.push_back(Pair("operatorPayoutAddress", EncodeDestination(dest)));
130  }
131  obj.push_back(Pair("inputsHash", inputsHash.ToString()));
132  }
133 };
134 
136 {
137 public:
138  static const uint16_t CURRENT_VERSION = 1;
139 
140 public:
141  uint16_t nVersion{CURRENT_VERSION}; // message version
143  uint16_t nMode{0}; // only 0 supported for now
147  uint256 inputsHash; // replay protection
148  std::vector<unsigned char> vchSig;
149 
150 public:
152 
153  template <typename Stream, typename Operation>
154  inline void SerializationOp(Stream& s, Operation ser_action)
155  {
158  READWRITE(nMode);
163  if (!(s.GetType() & SER_GETHASH)) {
164  READWRITE(vchSig);
165  }
166  }
167 
168 public:
169  std::string ToString() const;
170 
171  void ToJson(UniValue& obj) const
172  {
173  obj.clear();
174  obj.setObject();
175  obj.push_back(Pair("version", nVersion));
176  obj.push_back(Pair("proTxHash", proTxHash.ToString()));
177  obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting)));
178  CTxDestination dest;
179  if (ExtractDestination(scriptPayout, dest)) {
180  obj.push_back(Pair("payoutAddress", EncodeDestination(dest)));
181  }
182  obj.push_back(Pair("pubKeyOperator", pubKeyOperator.ToString()));
183  obj.push_back(Pair("inputsHash", inputsHash.ToString()));
184  }
185 };
186 
188 {
189 public:
190  static const uint16_t CURRENT_VERSION = 1;
191 
192  // these are just informational and do not have any effect on the revocation
193  enum {
199  };
200 
201 public:
202  uint16_t nVersion{CURRENT_VERSION}; // message version
205  uint256 inputsHash; // replay protection
207 
208 public:
210 
211  template <typename Stream, typename Operation>
212  inline void SerializationOp(Stream& s, Operation ser_action)
213  {
218  if (!(s.GetType() & SER_GETHASH)) {
219  READWRITE(sig);
220  }
221  }
222 
223 public:
224  std::string ToString() const;
225 
226  void ToJson(UniValue& obj) const
227  {
228  obj.clear();
229  obj.setObject();
230  obj.push_back(Pair("version", nVersion));
231  obj.push_back(Pair("proTxHash", proTxHash.ToString()));
232  obj.push_back(Pair("reason", (int)nReason));
233  obj.push_back(Pair("inputsHash", inputsHash.ToString()));
234  }
235 };
236 
237 
238 bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);
239 bool CheckProUpServTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);
240 bool CheckProUpRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);
241 bool CheckProUpRevTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);
242 
243 #endif //DASH_PROVIDERTX_H
uint16_t nMode
Definition: providertx.h:143
uint256 proTxHash
Definition: providertx.h:142
uint256 inputsHash
Definition: providertx.h:147
uint256 proTxHash
Definition: providertx.h:95
bool CheckProRegTx(const CTransaction &tx, const CBlockIndex *pindexPrev, CValidationState &state)
Definition: providertx.cpp:86
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:80
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:158
void ToJson(UniValue &obj) const
Definition: providertx.h:171
CKeyID keyIDVoting
Definition: providertx.h:145
std::string ToString(bool fUseGetnameinfo=true) const
Definition: netaddress.cpp:581
static const uint16_t CURRENT_VERSION
Definition: providertx.h:138
std::vector< unsigned char > vchSig
Definition: providertx.h:36
#define READWRITE(obj)
Definition: serialize.h:165
COutPoint collateralOutpoint
Definition: providertx.h:28
std::string ToString() const
Definition: providertx.cpp:447
CScript scriptOperatorPayout
Definition: providertx.h:97
CKeyID keyIDVoting
Definition: providertx.h:32
uint256 inputsHash
Definition: providertx.h:98
ADD_SERIALIZE_METHODS
Definition: providertx.h:39
std::string ToString() const
Definition: providertx.cpp:435
uint256 inputsHash
Definition: providertx.h:205
CBLSPublicKey pubKeyOperator
Definition: providertx.h:144
static const uint16_t CURRENT_VERSION
Definition: providertx.h:91
std::string ToString() const
Definition: providertx.cpp:459
bool CheckProUpRevTx(const CTransaction &tx, const CBlockIndex *pindexPrev, CValidationState &state)
Definition: providertx.cpp:358
void SerializationOp(Stream &s, Operation ser_action)
Definition: providertx.h:212
CBLSSignature sig
Definition: providertx.h:206
void ToJson(UniValue &obj) const
Definition: providertx.h:226
CBLSSignature sig
Definition: providertx.h:99
bool push_back(const UniValue &val)
Definition: univalue.cpp:110
void ToJson(UniValue &obj) const
Definition: providertx.h:66
std::string ToString() const
Definition: bls.h:210
uint256 inputsHash
Definition: providertx.h:35
void SerializationOp(Stream &s, Operation ser_action)
Definition: providertx.h:105
CService addr
Definition: providertx.h:96
static const uint16_t CURRENT_VERSION
Definition: providertx.h:22
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:143
std::string MakeSignString() const
Definition: providertx.cpp:398
void SerializationOp(Stream &s, Operation ser_action)
Definition: providertx.h:42
uint32_t n
Definition: transaction.h:30
CKeyID keyIDOwner
Definition: providertx.h:30
uint16_t nVersion
Definition: providertx.h:25
void SerializationOp(Stream &s, Operation ser_action)
Definition: providertx.h:154
uint16_t nType
Definition: providertx.h:26
std::string ToString() const
Definition: uint256.cpp:62
CScript scriptPayout
Definition: providertx.h:34
static std::pair< std::string, UniValue > Pair(const char *cKey, const char *cVal)
Definition: univalue.h:185
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
CScript scriptPayout
Definition: providertx.h:146
uint16_t nMode
Definition: providertx.h:27
uint16_t nOperatorReward
Definition: providertx.h:33
bool CheckProUpRegTx(const CTransaction &tx, const CBlockIndex *pindexPrev, CValidationState &state)
Definition: providertx.cpp:274
Capture information about block/transaction validation.
Definition: validation.h:22
256-bit opaque blob.
Definition: uint256.h:123
std::string ToString() const
Definition: providertx.cpp:423
static const uint16_t CURRENT_VERSION
Definition: providertx.h:190
std::string EncodeDestination(const CTxDestination &dest)
Definition: base58.cpp:329
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:389
std::vector< unsigned char > vchSig
Definition: providertx.h:148
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:20
bool setObject()
Definition: univalue.cpp:103
uint16_t nVersion
Definition: providertx.h:94
uint16_t nReason
Definition: providertx.h:204
bool CheckProUpServTx(const CTransaction &tx, const CBlockIndex *pindexPrev, CValidationState &state)
Definition: providertx.cpp:218
void clear()
Definition: univalue.cpp:17
void ToJson(UniValue &obj) const
Definition: providertx.h:120
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
uint16_t nVersion
Definition: providertx.h:202
uint16_t nVersion
Definition: providertx.h:141
CBLSPublicKey pubKeyOperator
Definition: providertx.h:31
uint256 proTxHash
Definition: providertx.h:203
CService addr
Definition: providertx.h:29
uint256 hash
Definition: transaction.h:29
Released under the MIT license