Skip to content

Commit

Permalink
Merge branch 'master' into feature/listaccounthistory_by_txtype
Browse files Browse the repository at this point in the history
  • Loading branch information
monstrobishi authored Dec 9, 2020
2 parents eb01e0c + 329dff1 commit 3794952
Show file tree
Hide file tree
Showing 20 changed files with 782 additions and 410 deletions.
7 changes: 4 additions & 3 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#include <consensus/tx_verify.h>

#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <chainparams.h>
#include <masternodes/masternodes.h>
#include <masternodes/mn_checks.h>
#include <primitives/transaction.h>
#include <script/interpreter.h>
#include <consensus/validation.h>

// TODO remove the following dependencies
#include <chain.h>
Expand Down Expand Up @@ -161,7 +162,7 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
return nSigOps;
}

bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, const CCustomCSView * mnview, int nSpendHeight, CAmount& txfee)
bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, const CCustomCSView * mnview, int nSpendHeight, CAmount& txfee, const CChainParams& chainparams)
{
// are the actual inputs available?
if (!inputs.HaveInputs(tx)) {
Expand Down Expand Up @@ -220,7 +221,7 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c
const auto txType = GuessCustomTxType(tx, dummy);

if (NotAllowedToFail(txType)) {
auto res = ApplyCustomTx(const_cast<CCustomCSView&>(*mnview), inputs, tx, Params(), nSpendHeight, 0, true); // note for 'isCheck == true' here; 'zero' for txn is dummy value
auto res = ApplyCustomTx(const_cast<CCustomCSView&>(*mnview), inputs, tx, chainparams.GetConsensus(), nSpendHeight, 0, true); // note for 'isCheck == true' here; 'zero' for txn is dummy value
if (!res.ok && (res.code & CustomTxErrCodes::Fatal)) {
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-txns-customtx", res.msg);
}
Expand Down
3 changes: 2 additions & 1 deletion src/consensus/tx_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <vector>

class CBlockIndex;
class CChainParams;
class CCoinsViewCache;
class CCustomCSView;
class CTransaction;
Expand All @@ -25,7 +26,7 @@ namespace Consensus {
* @param[out] txfee Set to the transaction fee if successful.
* Preconditions: tx.IsCoinBase() is false.
*/
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, const CCustomCSView * mnview, int nSpendHeight, CAmount& txfee);
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, const CCustomCSView * mnview, int nSpendHeight, CAmount& txfee, const CChainParams& chainparams);
} // namespace Consensus

/** Auxiliary functions for transaction validation (ideally should not be exposed) */
Expand Down
6 changes: 2 additions & 4 deletions src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ bool HasAuth(CTransaction const & tx, CCoinsViewCache const & coins, CScript con
{
for (auto input : tx.vin) {
const Coin& coin = coins.AccessCoin(input.prevout);
assert(!coin.IsSpent());
if (coin.out.scriptPubKey == auth)
if (!coin.IsSpent() && coin.out.scriptPubKey == auth)
return true;
}
return false;
Expand All @@ -108,8 +107,7 @@ bool HasFoundationAuth(CTransaction const & tx, CCoinsViewCache const & coins, C
{
for (auto input : tx.vin) {
const Coin& coin = coins.AccessCoin(input.prevout);
assert(!coin.IsSpent());
if (consensusParams.foundationMembers.find(coin.out.scriptPubKey) != consensusParams.foundationMembers.end())
if (!coin.IsSpent() && consensusParams.foundationMembers.find(coin.out.scriptPubKey) != consensusParams.foundationMembers.end())
return true;
}
return false;
Expand Down
Loading

0 comments on commit 3794952

Please sign in to comment.