1a445343f6
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
81 lines
3.2 KiB
C++
81 lines
3.2 KiB
C++
// Copyright (c) 2017-2017 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_CONSENSUS_TX_VERIFY_H
|
|
#define BITCOIN_CONSENSUS_TX_VERIFY_H
|
|
|
|
#include <amount.h>
|
|
|
|
#include <stdint.h>
|
|
#include <vector>
|
|
|
|
class CBlockIndex;
|
|
class CCoinsViewCache;
|
|
class CTransaction;
|
|
class CValidationState;
|
|
|
|
/** Transaction validation functions */
|
|
|
|
/** Context-independent validity checks */
|
|
bool CheckTransaction(const CTransaction& tx, CValidationState& state, bool fCheckDuplicateInputs=true);
|
|
|
|
namespace Consensus {
|
|
/**
|
|
* Check whether all inputs of this transaction are valid (no double spends and amounts)
|
|
* This does not modify the UTXO set. This does not check scripts and sigs.
|
|
* @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, int nSpendHeight, CAmount& txfee);
|
|
} // namespace Consensus
|
|
|
|
/** Auxiliary functions for transaction validation (ideally should not be exposed) */
|
|
|
|
/**
|
|
* Count ECDSA signature operations the old-fashioned (pre-0.6) way
|
|
* @return number of sigops this transaction's outputs will produce when spent
|
|
* @see CTransaction::FetchInputs
|
|
*/
|
|
unsigned int GetLegacySigOpCount(const CTransaction& tx);
|
|
|
|
/**
|
|
* Count ECDSA signature operations in pay-to-script-hash inputs.
|
|
*
|
|
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
|
|
* @return maximum number of sigops required to validate this transaction's inputs
|
|
* @see CTransaction::FetchInputs
|
|
*/
|
|
unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& mapInputs);
|
|
|
|
/**
|
|
* Compute total signature operation cost of a transaction.
|
|
* @param[in] tx Transaction for which we are computing the cost
|
|
* @param[in] inputs Map of previous transactions that have outputs we're spending
|
|
* @param[out] flags Script verification flags
|
|
* @return Total signature operation cost of tx
|
|
*/
|
|
int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& inputs, int flags);
|
|
|
|
/**
|
|
* Check if transaction is final and can be included in a block with the
|
|
* specified height and time. Consensus critical.
|
|
*/
|
|
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime);
|
|
|
|
/**
|
|
* Calculates the block height and previous block's median time past at
|
|
* which the transaction will be considered final in the context of BIP 68.
|
|
* Also removes from the vector of input heights any entries which did not
|
|
* correspond to sequence locked inputs as they do not affect the calculation.
|
|
*/
|
|
std::pair<int, int64_t> CalculateSequenceLocks(const CTransaction &tx, int flags, std::vector<int>* prevHeights, const CBlockIndex& block);
|
|
|
|
bool EvaluateSequenceLocks(const CBlockIndex& block, std::pair<int, int64_t> lockPair);
|
|
/**
|
|
* Check if transaction is final per BIP 68 sequence numbers and can be included in a block.
|
|
* Consensus critical. Takes as input a list of heights at which tx's inputs (in order) confirmed.
|
|
*/
|
|
bool SequenceLocks(const CTransaction &tx, int flags, std::vector<int>* prevHeights, const CBlockIndex& block);
|
|
|
|
#endif // BITCOIN_CONSENSUS_TX_VERIFY_H
|