Skip to content

Commit 7031cf8

Browse files
committed
scripted-diff: Invoke ::CheckFinalTx with chain tip
-BEGIN VERIFY SCRIPT- find_regex='\bCheckFinalTx\(' \ && git grep -l -E "$find_regex" -- src \ | grep -v '^src/validation\.\(cpp\|h\)$' \ | xargs sed -i -E 's@'"$find_regex"'@\0::ChainActive().Tip(), @g' -END VERIFY SCRIPT-
1 parent d015eaa commit 7031cf8

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/node/interfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class ChainImpl : public Chain
441441
bool checkFinalTx(const CTransaction& tx) override
442442
{
443443
LOCK(cs_main);
444-
return CheckFinalTx(tx);
444+
return CheckFinalTx(::ChainActive().Tip(), tx);
445445
}
446446
Optional<int> findLocatorFork(const CBlockLocator& locator) override
447447
{

src/test/miner_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
437437
tx.nLockTime = 0;
438438
hash = tx.GetHash();
439439
m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
440-
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
440+
BOOST_CHECK(CheckFinalTx(::ChainActive().Tip(), CTransaction(tx), flags)); // Locktime passes
441441
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
442442
BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 2))); // Sequence locks pass on 2nd block
443443

@@ -447,7 +447,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
447447
prevheights[0] = baseheight + 2;
448448
hash = tx.GetHash();
449449
m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
450-
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
450+
BOOST_CHECK(CheckFinalTx(::ChainActive().Tip(), CTransaction(tx), flags)); // Locktime passes
451451
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
452452

453453
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
@@ -463,7 +463,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
463463
tx.nLockTime = ::ChainActive().Tip()->nHeight + 1;
464464
hash = tx.GetHash();
465465
m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
466-
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
466+
BOOST_CHECK(!CheckFinalTx(::ChainActive().Tip(), CTransaction(tx), flags)); // Locktime fails
467467
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
468468
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast())); // Locktime passes on 2nd block
469469

@@ -474,7 +474,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
474474
prevheights[0] = baseheight + 4;
475475
hash = tx.GetHash();
476476
m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
477-
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
477+
BOOST_CHECK(!CheckFinalTx(::ChainActive().Tip(), CTransaction(tx), flags)); // Locktime fails
478478
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
479479
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast() + 1)); // Locktime passes 1 second later
480480

@@ -483,7 +483,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
483483
prevheights[0] = ::ChainActive().Tip()->nHeight + 1;
484484
tx.nLockTime = 0;
485485
tx.vin[0].nSequence = 0;
486-
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
486+
BOOST_CHECK(CheckFinalTx(::ChainActive().Tip(), CTransaction(tx), flags)); // Locktime passes
487487
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
488488
tx.vin[0].nSequence = 1;
489489
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail

src/txmempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
512512
const CTransaction& tx = it->GetTx();
513513
LockPoints lp = it->GetLockPoints();
514514
bool validLP = TestLockPointValidity(&lp);
515-
if (!CheckFinalTx(tx, flags) || !CheckSequenceLocks(*this, tx, flags, &lp, validLP)) {
515+
if (!CheckFinalTx(::ChainActive().Tip(), tx, flags) || !CheckSequenceLocks(*this, tx, flags, &lp, validLP)) {
516516
// Note if CheckSequenceLocks fails the LockPoints may still be invalid
517517
// So it's critical that we remove the tx and not depend on the LockPoints.
518518
txToRemove.insert(it);

0 commit comments

Comments
 (0)