Commit 763de7c6 authored by Ashot Khachatryan's avatar Ashot Khachatryan
Browse files

Fixed auxpow validation

parent 1aca86ed
Showing with 18 additions and 11 deletions
+18 -11
......@@ -573,7 +573,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, const std::string& strCommand,
mapSeenMasternodePing.insert(make_pair(mnp.GetHash(), mnp));
int nDoS = 0;
LOCK(cs_main);
//LOCK(cs_main);
if(mnp.CheckAndUpdate(nDoS)) return;
if(nDoS > 0) {
......
......@@ -64,8 +64,8 @@ std::string CTxOut::ToString() const
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, HexStr(scriptPubKey).substr(0, 30));
}
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), extraPayload(tx.extraPayload) {}
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nType(TRANSACTION_NORMAL), nLockTime(0) {}
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nType(tx.nType), nLockTime(tx.nLockTime), extraPayload(tx.extraPayload) {}
uint256 CMutableTransaction::GetHash() const
{
......@@ -87,11 +87,11 @@ uint256 CTransaction::ComputeWitnessHash() const
/* For backward compatibility, the hash is initialized to 0. TODO: remove the need for this default constructor entirely. */
CTransaction::CTransaction() : vin(), vout(), nVersion(CTransaction::CURRENT_VERSION), nType(TRANSACTION_NORMAL), nLockTime(0), hash{}, m_witness_hash{} {}
CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nType(TRANSACTION_NORMAL), nLockTime(tx.nLockTime), extraPayload(tx.extraPayload), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
CTransaction::CTransaction(CMutableTransaction&& tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nType(TRANSACTION_NORMAL), nLockTime(tx.nLockTime), extraPayload(tx.extraPayload), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nType(tx.nType), nLockTime(tx.nLockTime), extraPayload(tx.extraPayload), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {ComputeHash();}
CTransaction::CTransaction(CMutableTransaction&& tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nType(tx.nType), nLockTime(tx.nLockTime), extraPayload(tx.extraPayload), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {ComputeHash();}
CTransaction& CTransaction::operator=(const CTransaction &tx) {
*const_cast<int32_t *>(&nVersion) = tx.nVersion;
*const_cast<int16_t *>(&nVersion) = tx.nVersion;
*const_cast<int16_t*>(&nType) = tx.nType;
*const_cast<std::vector<CTxIn>*>(&vin) = tx.vin;
*const_cast<std::vector<CTxOut>*>(&vout) = tx.vout;
......
......@@ -225,7 +225,12 @@ template<typename Stream, typename TxType>
inline void UnserializeTransaction(TxType& tx, Stream& s) {
const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
s >> tx.nVersion;
int32_t n32bitVersion = tx.nVersion | (tx.nType << 16);
s >> n32bitVersion;
tx.nVersion = (int16_t)(n32bitVersion & 0xffff);
tx.nType = (int16_t)((n32bitVersion >> 16) & 0xffff);
unsigned char flags = 0;
tx.vin.clear();
tx.vout.clear();
......@@ -264,7 +269,9 @@ template<typename Stream, typename TxType>
inline void SerializeTransaction(const TxType& tx, Stream& s) {
const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
s << tx.nVersion;
int32_t n32bitVersion = tx.nVersion | (tx.nType << 16);
s << n32bitVersion;
unsigned char flags = 0;
// Consistency check
if (fAllowWitness) {
......@@ -315,7 +322,7 @@ public:
// structure, including the hash.
const std::vector<CTxIn> vin;
const std::vector<CTxOut> vout;
const int32_t nVersion;
const int16_t nVersion;
const int16_t nType;
const uint32_t nLockTime;
const std::vector<uint8_t> extraPayload; // only available for special transaction types
......@@ -345,7 +352,7 @@ public:
/** This deserializing constructor is provided instead of an Unserialize method.
* Unserialize is not possible, since it would require overwriting const fields. */
template <typename Stream>
CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}
CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {ComputeHash();}
bool IsNull() const {
return vin.empty() && vout.empty();
......@@ -400,7 +407,7 @@ struct CMutableTransaction
{
std::vector<CTxIn> vin;
std::vector<CTxOut> vout;
int32_t nVersion;
int16_t nVersion;
int16_t nType;
uint32_t nLockTime;
std::vector<uint8_t> extraPayload; // only available for special transaction types
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment