47 BlockAssembler::Options options;
49 options.include_dummy_extranonce =
true;
62 std::set<COutPoint>& m_mempool_outpoints;
64 explicit OutpointsUpdater(std::set<COutPoint>& r)
65 : m_mempool_outpoints{r} {}
80 for (
const auto& input : tx->vin) {
82 m_mempool_outpoints.insert(input.prevout);
85 for (
uint32_t index{0}; index < tx->vout.size(); ++index) {
86 m_mempool_outpoints.erase(
COutPoint{tx->GetHash(), index});
92 std::set<CTransactionRef>& m_added;
94 explicit TransactionsDelta(std::set<CTransactionRef>&
a)
113 chainstate.m_chain.Tip()->GetMedianTimePast() + 1,
114 std::numeric_limits<
decltype(
chainstate.m_chain.Tip()->nTime)>::max());
137 auto mempool{std::make_unique<CTxMemPool>(std::move(
mempool_opts), error)};
159 auto mempool{std::make_unique<CTxMemPool>(std::move(
mempool_opts), error)};
176 const auto& children =
tx_pool.GetChildren(entry);
177 if (!children.empty()) {
178 Assert(children.size() == 1);
180 const auto&
only_child = children.begin()->get().GetTx();
204 std::unordered_map<COutPoint, CAmount, SaltedOutpointHasher>
outpoints_value;
222 std::vector<CTransactionRef>
txs;
233 txs.emplace_back([&] {
251 for (
int i = 0; i <
num_in; ++i) {
254 auto pop = outpoints.begin();
256 auto outpoint = *
pop;
260 outpoints.erase(outpoint);
262 outpoints.erase(
pop);
277 for (
int i = 0; i <
num_out; ++i) {
290 for (
const auto& in : tx->vin) {
294 for (
size_t i = 0; i < tx->vout.size(); ++i) {
299 for (
size_t i = 0; i < tx->vout.size(); ++i) {
308 txs.back()->GetHash() :
316 tx_pool.PrioritiseTransaction(txid, delta);
337 node.validation_signals->SyncWithValidationInterfaceQueue();
359 std::unordered_map<COutPoint, CAmount, SaltedOutpointHasher>
outpoints_value;
377 std::vector<CTransactionRef>
txs;
384 txs.emplace_back([&] {
397 Assert(!outpoints.empty());
400 for (
size_t i = 0; i <
num_in; ++i) {
403 auto pop = outpoints.begin();
405 const auto outpoint = *
pop;
406 outpoints.erase(
pop);
432 tx_mut.vin.emplace_back();
445 for (
int i = 0; i <
num_out; ++i) {
451 for (
const auto& in : tx->vin) {
456 for (
size_t i = 0; i < tx->vout.size(); ++i) {
461 for (
size_t i = 0; i < tx->vout.size(); ++i) {
476 txs.back()->GetHash() :
479 tx_pool.PrioritiseTransaction(txid, delta);
483 std::set<CTransactionRef>
added;
484 auto txr = std::make_shared<TransactionsDelta>(
added);
485 node.validation_signals->RegisterSharedValidationInterface(
txr);
507 node.validation_signals->SyncWithValidationInterfaceQueue();
508 node.validation_signals->UnregisterSharedValidationInterface(
txr);
532 if (
tx_pool.m_opts.require_standard) {
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
const TestingSetup * g_setup
#define Assert(val)
Identity function.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
static const uint32_t CURRENT_VERSION
An input of a transaction.
CScriptWitness scriptWitness
Only serialized through CTransaction.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
An output of a transaction.
Implement this to subscribe to events generated in validation and mempool.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
T ConsumeIntegralInRange(T min, T max)
Generate a new block, without valid proof-of-work.
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
unsigned int nBytesPerSigOp
std::vector< uint32_t > GetDust(const CTransaction &tx, CFeeRate dust_relay_rate)
Get the vout index numbers of all dust outputs.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
A mutable version of CTransaction.
std::vector< std::vector< unsigned char > > stack
Testing setup that configures a complete environment.
const CTransactionRef m_tx
int64_t ancestor_count
The maximum allowed number of transactions in a package including the entry and its ancestors.
Options struct containing options for constructing a CTxMemPool.
NodeContext struct containing references to chain state and connection state.
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
std::unique_ptr< ChainstateManager > chainman
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
uint32_t ConsumeSequence(FuzzedDataProvider &fuzzed_data_provider) noexcept
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
COutPoint MineBlock(const NodeContext &node, const node::BlockAssembler::Options &assembler_options)
Returns the generated coin.
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.
static const std::vector< std::vector< uint8_t > > P2WSH_EMPTY_TRUE_STACK
static const std::vector< std::vector< uint8_t > > P2WSH_EMPTY_TWO_STACK
static const CScript P2WSH_EMPTY
void CheckMempoolTRUCInvariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check TRUC invariants:
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
std::optional< std::string > CheckPackageMempoolAcceptResult(const Package &txns, const PackageMempoolAcceptResult &result, bool expect_valid, const CTxMemPool *mempool)
Check expected properties for every PackageMempoolAcceptResult, regardless of value.
void CheckMempoolEphemeralInvariants(const CTxMemPool &tx_pool)
Check that we never get into a state where an ephemeral dust transaction would be mined without the s...
#define EXCLUSIVE_LOCKS_REQUIRED(...)
static constexpr decltype(CTransaction::version) TRUC_VERSION
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
PackageMempoolAcceptResult ProcessNewPackage(Chainstate &active_chainstate, CTxMemPool &pool, const Package &package, bool test_accept, const std::optional< CFeeRate > &client_maxfeerate)
Validate (and maybe submit) a package to the mempool.
MempoolAcceptResult AcceptToMemoryPool(Chainstate &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept)
Try to add a transaction to the mempool.
FuzzedDataProvider & fuzzed_data_provider