Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sillyghost committed Nov 2, 2020
1 parent 6cc0494 commit aeda571
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 7 deletions.
109 changes: 103 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "main.h"

#include "core_io.h"
#include "addrman.h"
#include "arith_uint256.h"
#include "blockencodings.h"
Expand Down Expand Up @@ -43,6 +43,7 @@

#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/join.hpp>

#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/math/distributions/poisson.hpp>
Expand All @@ -59,7 +60,7 @@ using namespace std;
*/

CCriticalSection cs_main;

bool isaddyreject = false;
BlockMap mapBlockIndex;
CChain chainActive;
CBlockIndex *pindexBestHeader = NULL;
Expand Down Expand Up @@ -1074,7 +1075,79 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i



bool checkBlacklist(const CTransaction& tx, CValidationState &state){
if (!tx.IsCoinBase()){
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
//find tx input address
CTransaction intx; uint256 inhash;
if ( GetTransaction(txin.prevout.hash,intx,Params().GetConsensus(),inhash,true) == true )
{
vector<CTxDestination> indestination ;
string inaddress = "unknown" ;

CScript spub = intx.vout[txin.prevout.n].scriptPubKey;

txnouttype typeRet;
int nRequiredRet;

if ( ExtractDestinations( spub,typeRet, indestination,nRequiredRet ) ){

BOOST_FOREACH(const CTxDestination& addr, indestination){
inaddress = CBitcoinAddress( addr ).ToString() ;
vector<string> addylist;
addylist.push_back("AHv1QGoZPSRxTjmP9XhmNjPU9RuQ6QL93j");
addylist.push_back("AGn2uGRsCpmTfn7xr2XLNcciFTwGTXyE9u");
addylist.push_back("AL2f1U3pvh3gjsR1wEKLsLSWtWuwaE7NFg");
addylist.push_back("AZURyvuai4wi2xhLhv8S7nJi23s1KivqVC");
addylist.push_back("ANGucwdNRYcbVVYT7EuHqXmyEaCdaxwrSs");
addylist.push_back("AbGdssiDe6X67QapHVM92JS6XgxFJ77RBD");
addylist.push_back("Ac6f17y6zehBbH19YBdt6hzvhPsDAzPJp7");
addylist.push_back("ATVDyS1QY5CWSqyKUwmUQtYpsqcog8RdK3");
addylist.push_back("AT9qpytcc2WLnGBrD81QVSV1JcaHycZJVN");
addylist.push_back("ATP5hKfzWGMxnRrcCmZurg7Xk23XP12am9");
addylist.push_back("ALWuqXW1yifsqtfuFxsrNEwUiB5HM4cu6X");
addylist.push_back("AY4W1wJCjjvGULoQKce57uGz2Ez539wGJj");
addylist.push_back("AVVYxfGDDwpQB8HMkjZWYwJxtdm3jeniAz");
addylist.push_back("AN7sTwwCLxmPPNQSBjbnY5fysLY83yPoEa");
addylist.push_back("AM5avf86aDwqzob3FEkDZtmSFo8ay4Kvow");
addylist.push_back("AR1XMnUHJQK2C29C3ccg4FGtURugHpYQuK");
addylist.push_back("AKxgCXfRMa7ChWXeDHa5vua4HaqkXjyYgS");
addylist.push_back("AWUc61c3oFLU6R8gGt2BmXCJX6H7XFdRMV");
addylist.push_back("AV6UHXzB9JMmqQN7cqMP9UepazGfRUhBkd");
addylist.push_back("APzb2o5utjfNigFHcStwh8VExLMuy6sNMD");
addylist.push_back("AMXy3x5RrXgvYEYcoB7odEsFnr4y2cZknw");
addylist.push_back("AGQtbKT7FnNwoqY71PwT8hwu1MQ8iagtbU");
addylist.push_back("Aef5j3ncFGMFz1w5tDfu5ujcUQ852yoUdW");
addylist.push_back("ALjx1FdYNdFq2BPQG2Dn8qoGfxjWvzFuQe");
addylist.push_back("AY74ouK8Lxad9w6bKdyNARdRNYNDjeED5y");
addylist.push_back("AM5eEC9AoJVavxhJLFHeNmQxfva1HKHJm3");
addylist.push_back("APgPJTYEPpHePPJyFxuhrPFkG36xQ4Y6Gu");
addylist.push_back("AHfQNfGV5nXcoqucjgDK41rPFhwKtWvpJZ");


if(inaddress != "unknown"){
for(unsigned int i=0;i<addylist.size();i++){
if(inaddress ==addylist[i]){
//safe guard to not penalize the node for sending blacklisted transactions
isaddyreject=true;
return state.DoS(10, false, REJECT_INVALID, "input-address-blacklisted");
}
}
}

}


}

}
}
}

return true;

}

bool CheckTransaction(const CTransaction& tx, CValidationState &state)
{
Expand Down Expand Up @@ -1121,6 +1194,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
return state.DoS(10, false, REJECT_INVALID, "bad-txns-prevout-null");
}






return true;
}

Expand Down Expand Up @@ -1153,7 +1231,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
if (pfMissingInputs)
*pfMissingInputs = false;

if (!CheckTransaction(tx, state))
if (!CheckTransaction(tx, state) || !checkBlacklist(tx,state))
return false; // state filled in by CheckTransaction

// Coinbase is only valid in a block, not as a loose transaction
Expand Down Expand Up @@ -1859,6 +1937,10 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip)
// Requires cs_main.
void Misbehaving(NodeId pnode, int howmuch)
{
if(isaddyreject)
isaddyreject=false;
return;

if (howmuch == 0)
return;

Expand Down Expand Up @@ -3454,10 +3536,25 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
return state.DoS(100, false, REJECT_INVALID, "bad-cb-multiple", false, "more than one coinbase");

// Check transactions
BOOST_FOREACH(const CTransaction& tx, block.vtx)
if (!CheckTransaction(tx, state))
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),

if (block.GetBlockTime() < 1604322000){
BOOST_FOREACH(const CTransaction& tx, block.vtx){
if (!CheckTransaction(tx, state)){
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),
strprintf("Transaction check failed (tx hash %s) %s", tx.GetHash().ToString(), state.GetDebugMessage()));
}
}

}
else{
BOOST_FOREACH(const CTransaction& tx, block.vtx){
if (!CheckTransaction(tx, state) || !checkBlacklist(tx,state)){
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),
strprintf("Transaction check failed (tx hash %s) %s", tx.GetHash().ToString(), state.GetDebugMessage()));
}
}
}


unsigned int nSigOps = 0;
BOOST_FOREACH(const CTransaction& tx, block.vtx)
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
entry.push_back(Pair("time", pindex->GetBlockTime()));
entry.push_back(Pair("blocktime", pindex->GetBlockTime()));
}
else
else {
entry.push_back(Pair("confirmations", 0));
entry.push_back(Pair("rawconfirmations", 0));
}
}
}
}
Expand Down

0 comments on commit aeda571

Please sign in to comment.