19#include <boost/test/unit_test.hpp>
37 coinbaseTx.vout[0].scriptPubKey = scriptPubKey;
59 std::vector<COutPoint> outpoints;
67 std::vector<CPubKey> keys;
69 for (
size_t i{0}; i <
num_keys; ++i) {
82 mtx.vin.resize(inputs.size());
84 for (
size_t i{0}; i < inputs.size(); ++i) {
85 mtx.vin[i].prevout = inputs[i];
87 for (
auto i{0}; i < 25; ++i) {
89 mtx.vout[i].nValue = 10000;
102 mtx.vin.resize(inputs.size());
103 for (
size_t i{0}; i < inputs.size(); ++i) {
104 mtx.vin[i].prevout = inputs[i];
282 std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef>
empty_parents;
391 for (
size_t i{0}; i < 2; ++i) {
416 for (
size_t i{0}; i < 2; ++i) {
462 for (
const auto& key : keys) {
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
#define Assert(val)
Identity function.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
std::optional< txiter > GetIter(const Txid &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
int64_t GetDescendantCount(txiter it) const
std::vector< CTxMemPoolEntry::CTxMemPoolEntryRef > GetParents(const CTxMemPoolEntry &entry) const
std::string GetRejectReason() const
transaction_identifier represents the two canonical transaction identifier types (txid,...
static transaction_identifier FromUint256(const uint256 &id)
static int32_t GetTransactionWeight(const CTransaction &tx)
@ TX_CONSENSUS
invalid by consensus rules
static const int WITNESS_SCALE_FACTOR
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_AUTO_TEST_SUITE_END()
bool CheckEphemeralSpends(const Package &package, CFeeRate dust_relay_rate, const CTxMemPool &tx_pool, TxValidationState &out_child_state, Wtxid &out_child_wtxid)
Called for each transaction(package) if any dust is in the package.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
static constexpr unsigned int DUST_RELAY_TX_FEE
Min feerate for defining dust.
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP
Default for -bytespersigop.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
uint256 GetRandHash() noexcept
Generate a random uint256.
static const int MAX_PUBKEYS_PER_MULTISIG
std::vector< unsigned char > ToByteVector(const T &in)
static constexpr CAmount CENT
A mutable version of CTransaction.
Validation result for a transaction evaluated by MemPoolAccept (single or package).
const ResultType m_result_type
Result type.
const TxValidationState m_state
Contains information about why the transaction failed.
@ INVALID
‍Fully validated, valid.
Identical to TestingSetup, but chain set to regtest.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
std::unique_ptr< CTxMemPool > mempool
std::unique_ptr< ChainstateManager > chainman
transaction_identifier< true > Wtxid
Wtxid commits to all transaction fields including the witness.
std::optional< std::pair< std::string, CTransactionRef > > SingleTRUCChecks(const CTxMemPool &pool, const CTransactionRef &ptx, const std::vector< CTxMemPoolEntry::CTxMemPoolEntryRef > &mempool_parents, const std::set< Txid > &direct_conflicts, int64_t vsize)
Must be called for every transaction, even if not TRUC.
std::optional< std::string > PackageTRUCChecks(const CTxMemPool &pool, const CTransactionRef &ptx, int64_t vsize, const Package &package, const std::vector< CTxMemPoolEntry::CTxMemPoolEntryRef > &mempool_parents)
Must be called for every transaction that is submitted within a package, even if not TRUC.
static constexpr int64_t TRUC_CHILD_MAX_VSIZE
Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction.
static constexpr decltype(CTransaction::version) TRUC_VERSION
static CTransactionRef make_ephemeral_tx(const std::vector< COutPoint > &inputs, int32_t version)
static CTransactionRef make_tx(const std::vector< COutPoint > &inputs, int32_t version)
static std::vector< COutPoint > random_outpoints(size_t num_outpoints)
static constexpr auto NUM_EPHEMERAL_TX_OUTPUTS
BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
Ensure that the mempool won't accept coinbase transactions.
static std::vector< CPubKey > random_keys(size_t num_keys)
static constexpr auto EPHEMERAL_DUST_INDEX
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.