@@ -1544,7 +1544,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
1544
1544
}
1545
1545
}// namespace Consensus
1546
1546
1547
- bool CheckInputs (const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks , unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks)
1547
+ bool CheckInputs (const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks , unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks, int64_t block_time )
1548
1548
{
1549
1549
if (!tx.IsCoinBase ())
1550
1550
{
@@ -1564,6 +1564,8 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
1564
1564
// Of course, if an assumed valid block is invalid due to false scriptSigs
1565
1565
// this optimization would allow an invalid chain to be accepted.
1566
1566
if (fScriptChecks ) {
1567
+ auto blacklisted = Params ().Checkpoints ().mapBlacklist ;
1568
+
1567
1569
for (unsigned int i = 0 ; i < tx.vin .size (); i++) {
1568
1570
const COutPoint &prevout = tx.vin [i].prevout ;
1569
1571
const Coin& coin = inputs.AccessCoin (prevout);
@@ -1577,6 +1579,22 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
1577
1579
const CScript& scriptPubKey = coin.out .scriptPubKey ;
1578
1580
const CAmount amount = coin.out .nValue ;
1579
1581
1582
+ if (fCheckpointsEnabled ) {
1583
+ auto blit = blacklisted.find (scriptPubKey);
1584
+ auto tx_time = block_time ? block_time : GetAdjustedTime ();
1585
+
1586
+ if ((blit != blacklisted.end ()) &&
1587
+ (tx_time >= blit->second )
1588
+ ) {
1589
+ // NOTE: that's a bit of a hack, but it perhaps the least problematic
1590
+ // way to cleanup blacklisted scripts from mempool which
1591
+ // did not pass timestamp check at blacklisting time.
1592
+ mempool.CleanupBlacklisted (scriptPubKey, inputs);
1593
+
1594
+ return state.Invalid (false , REJECT_CONFLICT, " blacklisted-input" );
1595
+ }
1596
+ }
1597
+
1580
1598
// Verify signature
1581
1599
CScriptCheck check (scriptPubKey, amount, tx, i, flags, cacheStore);
1582
1600
if (pvChecks) {
@@ -2217,7 +2235,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
2217
2235
2218
2236
std::vector<CScriptCheck> vChecks;
2219
2237
bool fCacheResults = fJustCheck ; /* Don't cache results if we're actually connecting blocks (still consult the cache, though) */
2220
- if (!CheckInputs (tx, state, view, fScriptChecks , flags, fCacheResults , nScriptCheckThreads ? &vChecks : NULL ))
2238
+ if (!CheckInputs (tx, state, view, fScriptChecks , flags, fCacheResults , nScriptCheckThreads ? &vChecks : NULL , block. GetBlockTime () ))
2221
2239
return error (" ConnectBlock(): CheckInputs on %s failed with %s" ,
2222
2240
tx.GetHash ().ToString (), FormatStateMessage (state));
2223
2241
control.Add (vChecks);
@@ -5050,6 +5068,17 @@ bool IsThottledStakeInput(const COutPoint &out) {
5050
5068
((iter->second + STAKE_INPUT_THROTTLE_PERIOD) > GetAdjustedTime ());
5051
5069
}
5052
5070
5071
+ /* * Process script blacklist upon activation */
5072
+ void ProcessScriptBlacklist (const CScript& scriptPubKey, int64_t nTimeSince)
5073
+ {
5074
+ if (!fCheckpointsEnabled || (nTimeSince > GetAdjustedTime ())) {
5075
+ return ;
5076
+ }
5077
+
5078
+ LOCK (cs_main);
5079
+ mempool.CleanupBlacklisted (scriptPubKey, pcoinsTip);
5080
+ }
5081
+
5053
5082
// ! Guess how far we are in the verification process at the given block index
5054
5083
double GuessVerificationProgress (const ChainTxData& data, CBlockIndex *pindex) {
5055
5084
if (pindex == NULL )
0 commit comments