24#include <validation.h>
34#include <boost/test/unit_test.hpp>
64 opts.limits.cluster_size_vbytes = 1'200'000;
65 m_node.mempool = std::make_unique<CTxMemPool>(opts, error);
80constexpr static struct {
83}
BLOCKINFO[]{{0, 3552706918}, {500, 37506755}, {1000, 948987788}, {400, 524762339}, {800, 258510074}, {300, 102309278},
84 {1300, 54365202}, {600, 1107740426}, {1000, 203094491}, {900, 391178848}, {800, 381177271}, {600, 87188412},
85 {0, 66522866}, {800, 874942736}, {1000, 89200838}, {400, 312638088}, {400, 66263693}, {500, 924648304},
86 {400, 369913599}, {500, 47630099}, {500, 115045364}, {100, 277026602}, {1100, 809621409}, {700, 155345322},
87 {800, 943579953}, {400, 28200730}, {900, 77200495}, {0, 105935488}, {400, 698721821}, {500, 111098863},
88 {1300, 445389594}, {500, 621849894}, {1400, 56010046}, {1100, 370669776}, {1200, 380301940}, {1200, 110654905},
89 {400, 213771024}, {1500, 120014726}, {1200, 835019014}, {1500, 624817237}, {900, 1404297}, {400, 189414558},
90 {400, 293178348}, {1100, 15393789}, {600, 396764180}, {800, 1387046371}, {800, 199368303}, {700, 111496662},
91 {100, 129759616}, {200, 536577982}, {500, 125881300}, {500, 101053391}, {1200, 471590548}, {900, 86957729},
92 {1200, 179604104}, {600, 68658642}, {1000, 203295701}, {500, 139615361}, {900, 233693412}, {300, 153225163},
93 {0, 27616254}, {1200, 9856191}, {100, 220392722}, {200, 66257599}, {1100, 145489641}, {1300, 37859442},
94 {400, 5816075}, {1200, 215752117}, {1400, 32361482}, {1400, 6529223}, {500, 143332977}, {800, 878392},
95 {700, 159290408}, {400, 123197595}, {700, 43988693}, {300, 304224916}, {700, 214771621}, {1100, 274148273},
96 {400, 285632418}, {1100, 923451065}, {600, 12818092}, {1200, 736282054}, {1000, 246683167}, {600, 92950402},
97 {1400, 29223405}, {1000, 841327192}, {700, 174301283}, {1400, 214009854}, {1000, 6989517}, {1200, 278226956},
98 {700, 540219613}, {400, 93663104}, {1100, 152345635}, {1500, 464194499}, {1300, 333850111}, {600, 258311263},
99 {600, 90173162}, {1000, 33590797}, {1500, 332866027}, {100, 204704427}, {1000, 463153545}, {800, 303244785},
100 {600, 88096214}, {0, 137477892}, {1200, 195514506}, {300, 704114595}, {900, 292087369}, {1400, 758684870},
101 {1300, 163493028}, {1200, 53151293}};
105 auto index{std::make_unique<CBlockIndex>()};
107 index->pprev = active_chain_tip;
114void MinerTestingSetup::TestPackageSelection(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst)
126 std::unique_ptr<BlockTemplate> block_template = mining->createNewBlock(options,
false);
127 BOOST_REQUIRE(block_template);
128 CBlock block{block_template->getBlock()};
129 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 1U);
132 auto should_be_nullptr = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 1});
133 BOOST_REQUIRE(should_be_nullptr ==
nullptr);
136 block_template = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 0});
137 BOOST_REQUIRE(block_template);
147 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
148 tx.
vin[0].prevout.n = 0;
150 tx.
vout[0].nValue = 5000000000LL - 1000;
157 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
158 tx.
vout[0].nValue = 5000000000LL - 10000;
164 tx.
vin[0].prevout.hash = hashParentTx;
165 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000;
170 block_template = mining->createNewBlock(options,
false);
171 BOOST_REQUIRE(block_template);
172 block = block_template->getBlock();
173 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 4U);
179 const auto block_package_feerates =
BlockAssembler{m_node.chainman->ActiveChainstate(), &tx_mempool, options}.
CreateNewBlock()->m_package_feerates;
183 const auto combined_txs_fee = parent_tx.GetFee() + high_fee_tx.GetFee();
184 const auto combined_txs_size = parent_tx.GetTxSize() + high_fee_tx.GetTxSize();
185 FeeFrac package_feefrac{combined_txs_fee, combined_txs_size};
187 BOOST_CHECK(block_package_feerates[0] == package_feefrac);
190 FeeFrac medium_tx_feefrac{medium_fee_tx.GetFee(), medium_fee_tx.GetTxSize()};
191 BOOST_CHECK(block_package_feerates[1] == medium_tx_feefrac);
194 tx.
vin[0].prevout.hash = hashHighFeeTx;
195 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000;
204 tx.
vin[0].prevout.hash = hashFreeTx;
205 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
210 should_be_nullptr = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 1});
211 BOOST_REQUIRE(should_be_nullptr ==
nullptr);
213 block = block_template->getBlock();
215 for (
size_t i=0; i<block.
vtx.size(); ++i) {
224 tx.
vout[0].nValue -= 2;
229 block_template = block_template->waitNext({.fee_threshold = 1});
230 BOOST_REQUIRE(block_template);
231 block = block_template->getBlock();
232 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 6U);
239 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
241 tx.
vout[0].nValue = 5000000000LL - 100000000;
242 tx.
vout[1].nValue = 100000000;
251 tx.
vin[0].prevout.hash = hashFreeTx2;
254 tx.
vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
257 block_template = mining->createNewBlock(options,
false);
258 BOOST_REQUIRE(block_template);
259 block = block_template->getBlock();
262 for (
size_t i=0; i<block.
vtx.size(); ++i) {
269 tx.
vin[0].prevout.n = 1;
270 tx.
vout[0].nValue = 100000000 - 10000;
272 block_template = mining->createNewBlock(options,
false);
273 BOOST_REQUIRE(block_template);
274 block = block_template->getBlock();
275 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 9U);
281 std::vector<CTransactionRef>
ret;
288 tx.
vin[0].prevout.hash = first_tx->GetHash();
289 tx.
vin[0].prevout.n = 0;
291 for (
auto &out : tx.
vout) {
292 out.nValue = first_tx->vout[0].nValue / 50;
298 ret.push_back(parent_tx);
304 for (
unsigned int i = 0; i < 50; ++i) {
307 tx2.vin[0].prevout.hash = parent_tx->GetHash();
308 tx2.vin[0].prevout.n = i;
311 tx2.vout[0].nValue = parent_tx->vout[i].nValue -
CENT;
312 for (
auto &out : tx2.vout) {
321void MinerTestingSetup::TestBasicMining(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst,
int baseheight)
335 BOOST_REQUIRE(mining);
346 auto block_template{mining->createNewBlock(options,
false)};
347 BOOST_REQUIRE(block_template);
348 CBlock block{block_template->getBlock()};
352 int64_t legacy_sigops = 0;
353 for (
auto&
t : txs) {
361 assert(legacy_sigops == 20001);
362 BOOST_CHECK_EXCEPTION(mining->createNewBlock(options,
false), std::runtime_error,
HasReason(
"bad-blk-sigops"));
370 assert(tx_mempool.mapTx.empty());
373 auto block_template{mining->createNewBlock(options,
false)};
374 BOOST_REQUIRE(block_template);
375 CBlock block{block_template->getBlock()};
379 int64_t legacy_sigops = 0;
380 for (
auto&
t : txs) {
386 assert(legacy_sigops == 20001);
388 BOOST_REQUIRE(mining->createNewBlock(options,
false));
398 tx.
vout[0].nValue = BLOCKSUBSIDY;
400 std::vector<unsigned char> vchData(520);
401 for (
unsigned int i = 0; i < 18; ++i) {
407 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
408 tx.
vin[0].prevout.n = 0;
409 tx.
vout[0].nValue = BLOCKSUBSIDY;
410 for (
unsigned int i = 0; i < 63; ++i) {
411 tx.
vout[0].nValue -= LOWFEE;
416 tx.
vin[0].prevout.hash = hash;
418 BOOST_REQUIRE(mining->createNewBlock(options,
false));
428 BOOST_CHECK_EXCEPTION(mining->createNewBlock(options,
false), std::runtime_error,
HasReason(
"bad-txns-inputs-missingorspent"));
437 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
438 tx.
vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
441 tx.
vin[0].prevout.hash = hash;
444 tx.
vin[1].prevout.hash = txFirst[0]->GetHash();
445 tx.
vin[1].prevout.n = 0;
446 tx.
vout[0].nValue = tx.
vout[0].nValue + BLOCKSUBSIDY - HIGHERFEE;
449 BOOST_REQUIRE(mining->createNewBlock(options,
false));
458 tx.
vin[0].prevout.SetNull();
460 tx.
vout[0].nValue = 0;
465 BOOST_CHECK_EXCEPTION(mining->createNewBlock(options,
false), std::runtime_error,
HasReason(
"bad-cb-multiple"));
473 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
475 tx.
vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
482 BOOST_CHECK_EXCEPTION(mining->createNewBlock(options,
false), std::runtime_error,
HasReason(
"bad-txns-inputs-missingorspent"));
490 int nHeight = m_node.chainman->ActiveChain().Height();
492 while (m_node.chainman->ActiveChain().Tip()->nHeight < 209999) {
493 CBlockIndex* prev = m_node.chainman->ActiveChain().Tip();
496 m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(next->
GetBlockHash());
500 m_node.chainman->ActiveChain().SetTip(*next);
502 BOOST_REQUIRE(mining->createNewBlock(options,
false));
504 while (m_node.chainman->ActiveChain().Tip()->nHeight < 210000) {
505 CBlockIndex* prev = m_node.chainman->ActiveChain().Tip();
508 m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(next->
GetBlockHash());
512 m_node.chainman->ActiveChain().SetTip(*next);
514 BOOST_REQUIRE(mining->createNewBlock(options,
false));
517 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
518 tx.
vin[0].prevout.n = 0;
520 tx.
vout[0].nValue = BLOCKSUBSIDY - LOWFEE;
525 tx.
vin[0].prevout.hash = hash;
527 tx.
vout[0].nValue -= LOWFEE;
530 BOOST_CHECK_EXCEPTION(mining->createNewBlock(options,
false), std::runtime_error,
HasReason(
"block-script-verify-flag-failed"));
533 while (m_node.chainman->ActiveChain().Tip()->nHeight >
nHeight) {
534 CBlockIndex* del = m_node.chainman->ActiveChain().Tip();
535 m_node.chainman->ActiveChain().SetTip(*
Assert(del->
pprev));
536 m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(del->
pprev->
GetBlockHash());
546 SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1);
549 std::vector<int> prevheights;
554 prevheights.resize(1);
555 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
556 tx.
vin[0].prevout.n = 0;
558 tx.
vin[0].nSequence = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
559 prevheights[0] = baseheight + 1;
561 tx.
vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
570 CBlockIndex* active_chain_tip = m_node.chainman->ActiveChain().Tip();
575 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
577 prevheights[0] = baseheight + 2;
583 const int SEQUENCE_LOCK_TIME = 512;
585 m_node.chainman->ActiveChain().Tip()->GetAncestor(m_node.chainman->ActiveChain().Tip()->nHeight - i)->nTime += SEQUENCE_LOCK_TIME;
587 CBlockIndex* active_chain_tip = m_node.chainman->ActiveChain().Tip();
592 CBlockIndex* ancestor{
Assert(m_node.chainman->ActiveChain().Tip()->GetAncestor(m_node.chainman->ActiveChain().Tip()->nHeight - i))};
593 ancestor->
nTime -= SEQUENCE_LOCK_TIME;
597 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
599 prevheights[0] = baseheight + 3;
600 tx.
nLockTime = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
612 tx.
vin[0].prevout.hash = txFirst[3]->GetHash();
613 tx.
nLockTime = m_node.chainman->ActiveChain().Tip()->GetMedianTimePast();
614 prevheights.resize(1);
615 prevheights[0] = baseheight + 4;
623 tx.
vin[0].prevout.hash = hash;
624 prevheights[0] = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
626 tx.
vin[0].nSequence = 0;
629 tx.
vin[0].nSequence = 1;
636 auto block_template = mining->createNewBlock(options,
false);
637 BOOST_REQUIRE(block_template);
643 CBlock block{block_template->getBlock()};
647 CBlockIndex* ancestor{
Assert(m_node.chainman->ActiveChain().Tip()->GetAncestor(m_node.chainman->ActiveChain().Tip()->nHeight - i))};
648 ancestor->
nTime += SEQUENCE_LOCK_TIME;
650 m_node.chainman->ActiveChain().Tip()->nHeight++;
651 SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1);
653 block_template = mining->createNewBlock(options,
false);
654 BOOST_REQUIRE(block_template);
655 block = block_template->getBlock();
659void MinerTestingSetup::TestPrioritisedMining(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst)
662 BOOST_REQUIRE(mining);
676 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
677 tx.
vin[0].prevout.n = 0;
680 tx.
vout[0].nValue = 5000000000LL;
685 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
686 tx.
vin[0].prevout.n = 0;
687 tx.
vout[0].nValue = 5000000000LL - 1000;
693 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
694 tx.
vout[0].nValue = 5000000000LL - 10000;
700 tx.
vin[0].prevout.hash = hashParentTx;
701 tx.
vout[0].nValue = 5000000000LL - 1000 - 1000;
712 tx.
vin[0].prevout.hash = txFirst[3]->GetHash();
713 tx.
vout[0].nValue = 5000000000LL;
718 tx.
vin[0].prevout.hash = hashFreeParent;
719 tx.
vout[0].nValue = 5000000000LL;
724 tx.
vin[0].prevout.hash = hashFreeChild;
725 tx.
vout[0].nValue = 5000000000LL;
729 auto block_template = mining->createNewBlock(options,
false);
730 BOOST_REQUIRE(block_template);
731 CBlock block{block_template->getBlock()};
732 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 6U);
738 for (
size_t i=0; i<block.
vtx.size(); ++i) {
749 auto mining{MakeMining()};
750 BOOST_REQUIRE(mining);
753 CScript scriptPubKey =
CScript() <<
"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"_hex <<
OP_CHECKSIG;
759 std::unique_ptr<BlockTemplate> block_template = mining->createNewBlock(options,
false);
760 BOOST_REQUIRE(block_template);
762 CBlock block{block_template->getBlock()};
766 BOOST_REQUIRE(!mining->checkBlock(block, {.check_pow = false}, reason, debug));
767 BOOST_REQUIRE_EQUAL(reason,
"bad-txnmrklroot");
768 BOOST_REQUIRE_EQUAL(debug,
"hashMerkleRoot mismatch");
776 BOOST_REQUIRE(mining->checkBlock(block, {.check_pow = false}, reason, debug));
777 BOOST_REQUIRE_EQUAL(reason,
"");
778 BOOST_REQUIRE_EQUAL(debug,
"");
790 BOOST_REQUIRE(!mining->checkBlock(block, {.check_pow = true}, reason, debug));
791 BOOST_REQUIRE_EQUAL(reason,
"high-hash");
792 BOOST_REQUIRE_EQUAL(debug,
"proof of work failed");
798 static_assert(std::size(
BLOCKINFO) == 110,
"Should have 110 blocks to import");
800 std::vector<CTransactionRef> txFirst;
802 const int current_height{mining->getTip()->height};
809 if (current_height % 2 == 0) {
810 block_template = mining->createNewBlock(options,
false);
811 BOOST_REQUIRE(block_template);
814 CBlock block{block_template->getBlock()};
819 block.
nTime =
Assert(m_node.chainman)->ActiveChain().Tip()->GetMedianTimePast()+1;
821 txCoinbase.
vin[0].scriptSig =
CScript{} << (current_height + 1) << bi.extranonce;
822 txCoinbase.
vout.resize(1);
825 if (txFirst.size() == 0)
826 baseheight = current_height;
827 if (txFirst.size() < 4)
828 txFirst.push_back(block.
vtx[0]);
832 std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
836 if (current_height % 2 == 0) {
837 BOOST_REQUIRE(
Assert(m_node.chainman)->ProcessNewBlock(shared_pblock,
true,
true,
nullptr));
845 auto maybe_new_tip{
Assert(m_node.chainman)->ActiveChain().Tip()};
846 BOOST_REQUIRE_EQUAL(maybe_new_tip->GetBlockHash(), block.
GetHash());
848 if (current_height % 2 == 0) {
849 block_template = block_template->waitNext();
850 BOOST_REQUIRE(block_template);
859 TestBasicMining(scriptPubKey, txFirst, baseheight);
861 m_node.chainman->ActiveChain().Tip()->nHeight--;
864 TestPackageSelection(scriptPubKey, txFirst);
866 m_node.chainman->ActiveChain().Tip()->nHeight--;
869 TestPrioritisedMining(scriptPubKey, txFirst);
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
int64_t CAmount
Amount in satoshis (Can be negative).
static constexpr CAmount COIN
The amount of satoshis in one BTC.
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
#define Assert(val)
Identity function.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
void BuildSkip()
Build the skiplist pointer for this entry.
uint256 GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
static constexpr int nMedianTimeSpan
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
CCoinsView that brings transactions from a mempool into view.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
static const uint32_t MAX_SEQUENCE_NONFINAL
This is the maximum sequence number that enables both nLockTime and OP_CHECKLOCKTIMEVERIFY (BIP 65).
static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG
If CTxIn::nSequence encodes a relative lock-time and this flag is set, the relative lock-time has uni...
static const int SEQUENCE_LOCKTIME_GRANULARITY
In order to use the same number of bits to encode roughly the same wall-clock duration,...
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void PrioritiseTransaction(const Txid &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
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.
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(voi removeRecursive)(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
unsigned long size() const
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Block template interface.
Generate a new block, without valid proof-of-work.
std::unique_ptr< CBlockTemplate > CreateNewBlock()
Construct a new block template.
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks.
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_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
@ REPLACED
Removed for replacement.
std::vector< CTransactionRef > CreateBigSigOpsCluster(const CTransactionRef &first_tx)
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
static std::unique_ptr< CBlockIndex > CreateBlockIndex(int nHeight, CBlockIndex *active_chain_tip) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static constexpr struct @264074122144367246160252320203044150204025367053 BLOCKINFO[]
static CFeeRate blockMinFeeRate
std::unique_ptr< Mining > MakeMining(node::NodeContext &node, bool wait_loaded=true)
""_hex is a compile-time user-defined literal returning a std::array<std::byte>, equivalent to ParseH...
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by min...
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
static constexpr TransactionSerParams TX_WITH_WITNESS
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
uint64_t GetSerializeSize(const T &t)
static constexpr CAmount CENT
A mutable version of CTransaction.
std::vector< CTxOut > vout
Txid GetHash() const
Compute the hash of this CMutableTransaction.
Data structure storing a fee and size, ordered by increasing fee/size.
TestMemPoolEntryHelper & SigOpsCost(unsigned int _sigopsCost)
TestMemPoolEntryHelper & Time(NodeSeconds tp)
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & SpendsCoinbase(bool _flag)
TestMemPoolEntryHelper & Fee(CAmount _fee)
TestingSetup(ChainType chainType=ChainType::MAIN, TestOpts={})
std::unique_ptr< Mining > MakeMining()
CTxMemPool & MakeMempool()
void TestPackageSelection(const CScript &scriptPubKey, const std::vector< CTransactionRef > &txFirst) EXCLUSIVE_LOCKS_REQUIRED(void TestBasicMining(const CScript &scriptPubKey, const std::vector< CTransactionRef > &txFirst, int baseheight) EXCLUSIVE_LOCKS_REQUIRED(void TestPrioritisedMining(const CScript &scriptPubKey, const std::vector< CTransactionRef > &txFirst) EXCLUSIVE_LOCKS_REQUIRED(boo TestSequenceLocks)(const CTransaction &tx, CTxMemPool &tx_mempool) EXCLUSIVE_LOCKS_REQUIRED(
bool include_dummy_extranonce
Whether to include an OP_0 as a dummy extraNonce in the template's coinbase.
CScript coinbase_output_script
Script to put in the coinbase transaction.
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
transaction_identifier< false > Txid
Txid commits to all transaction fields except the witness.
void BulkTransaction(CMutableTransaction &tx, int32_t target_weight)
unsigned int GetLegacySigOpCount(const CTransaction &tx)
Auxiliary functions for transaction validation (ideally should not be exposed).
bool SequenceLocks(const CTransaction &tx, int flags, std::vector< int > &prevHeights, const CBlockIndex &block)
Check if transaction is final per BIP 68 sequence numbers and can be included in a block.
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
Check if transaction is final and can be included in a block with the specified height and time.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
std::chrono::duration< double, std::chrono::milliseconds::period > MillisecondsDouble
T Now()
Return the current time point cast to the given precision.
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx)
bool CheckSequenceLocksAtTip(CBlockIndex *tip, const LockPoints &lock_points)
Check if transaction will be BIP68 final in the next block to be created on top of tip.
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(std::optional< LockPoints CalculateLockPointsAtTip)(CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx)
Check if transaction will be final in the next block to be created.
static const int32_t VERSIONBITS_TOP_BITS
What bits to set in version for versionbits blocks.