Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.cpp
// Copyright (c) 2020 The Bitcoin developers | // Copyright (c) 2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <avalanche/proof.h> | #include <avalanche/proof.h> | ||||
#include <avalanche/validation.h> | #include <avalanche/validation.h> | ||||
#include <blockindex.h> | |||||
#include <coins.h> | #include <coins.h> | ||||
#include <hash.h> | #include <hash.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | for (const SignedStake &ss : stakes) { | ||||
return state.Invalid(ProofValidationResult::INVALID_SIGNATURE, | return state.Invalid(ProofValidationResult::INVALID_SIGNATURE, | ||||
"invalid-signature"); | "invalid-signature"); | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool Proof::verify(ProofValidationState &state, const CCoinsView &view) const { | bool Proof::verify(ProofValidationState &state, const CCoinsView &view, | ||||
const CBlockIndex *pindex) const { | |||||
if (!verify(state)) { | if (!verify(state)) { | ||||
// state is set by verify. | // state is set by verify. | ||||
return false; | return false; | ||||
} | } | ||||
for (const SignedStake &ss : stakes) { | for (const SignedStake &ss : stakes) { | ||||
const Stake &s = ss.getStake(); | const Stake &s = ss.getStake(); | ||||
const COutPoint &utxo = s.getUTXO(); | const COutPoint &utxo = s.getUTXO(); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | for (const SignedStake &ss : stakes) { | ||||
const CPubKey &pubkey = s.getPubkey(); | const CPubKey &pubkey = s.getPubkey(); | ||||
if (*pkhash != PKHash(pubkey)) { | if (*pkhash != PKHash(pubkey)) { | ||||
// Wrong pubkey. | // Wrong pubkey. | ||||
return state.Invalid(ProofValidationResult::DESTINATION_MISMATCH, | return state.Invalid(ProofValidationResult::DESTINATION_MISMATCH, | ||||
"destination-mismatch"); | "destination-mismatch"); | ||||
} | } | ||||
} | } | ||||
if (pindex->GetMedianTimePast() >= expirationTime) { | |||||
Fabien: This needs a null check | |||||
// Expiration time in the past. | |||||
return state.Invalid(ProofValidationResult::EXPIRED, | |||||
"past-expiration-time"); | |||||
FabienUnsubmitted Not Done Inline Actionssupposedly it was past the expiration time for 5 blocks already, the name is not the best Fabien: supposedly it was past the expiration time for 5 blocks already, the name is not the best | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
} // namespace avalanche | } // namespace avalanche |
This needs a null check