diff --git a/src/Makefile.am b/src/Makefile.am index 8e0e53422ac4b..3f48f10639102 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -179,6 +179,8 @@ BITCOIN_CORE_H = \ httpserver.h \ indirectmap.h \ init.h \ + invalid.h \ + invalid_scripts.h \ ionaddrenc.h \ key.h \ keepass.h \ @@ -606,6 +608,7 @@ libion_common_a_SOURCES = \ dstencode.cpp \ hdchain.cpp \ ionaddrenc.cpp \ + invalid.cpp \ key.cpp \ keystore.cpp \ netaddress.cpp \ diff --git a/src/chainparams.cpp b/src/chainparams.cpp index bfadff1bb7462..3914722beada9 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -526,7 +526,7 @@ class CTestNetParams : public CChainParams { consensus.POSPOWStartHeight = 117000; // The best chain should have at least this much work. - consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000001088a59861293dfc3"); // 126142 + consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000106cee2b2baf64cba"); // 119800 // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x0000000005ae4db9746d6cad8e0ccebdef1e05afec9c40809f31457fdaf7d843"); // 95930 @@ -593,15 +593,16 @@ class CTestNetParams : public CChainParams { {1, uint256S("0x16ac2683f6ccab2f095a6270d485087e5c441f39a18fd32e00c7bfa996cdf696")}, {5530, uint256S("0xa7332c2034d501bb11f686ae6c224dbcbdf5332c2522204a63224a8ca670c18b")}, {117000, uint256S("0x4c092ef6ad08622df9be8b5287ea29a1e9bfbe6756fd3056b9caebed61c697ca")}, - {126142, uint256S("0x0000002e138642509d8417111990895d1b625d58366002d2172aef97e9a97ba9")}, + {119254, uint256S("0x65442ee4e4b0116ca7f85fdce633c21cc9e0fafdc7710505adfa21e30c291f84")}, + {119800, uint256S("0x445c9f1f85fc15cdadc04f5f9d58de3edfcc8419a0ec8a691e5b235f38a97bc7")}, } }; chainTxData = ChainTxData{ - 1583851321, // * UNIX timestamp of last known number of transactions (Block 155400) - 251524, // * total number of transactions between genesis and that timestamp + 1585764678, // * UNIX timestamp of last known number of transactions (Block 119800) + 239608, // * total number of transactions between genesis and that timestamp // (the tx=... number in the SetBestChain debug.log lines) - 0.999999 // * estimated number of transactions per second after that timestamp + 0.029999 // * estimated number of transactions per second after that timestamp (2 per minute) }; } diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 904ca94b3e6db..c708e1e1c098a 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -6,6 +6,7 @@ #include "chainparams.h" #include "consensus.h" +#include "invalid.h" #include "primitives/transaction.h" #include "script/interpreter.h" #include "tokens/groups.h" @@ -251,6 +252,12 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c } } + if (nSpendHeight >= params.POSPOWStartHeight && invalid_out::ContainsScript(coin.out.scriptPubKey)) { + return state.Invalid(false, + REJECT_INVALID, "bad-txns-inputs-invalid-script", + strprintf("tried to spend invalid script")); + } + // Check for negative or overflow input values nValueIn += coin.out.nValue; if (!MoneyRange(coin.out.nValue) || !MoneyRange(nValueIn)) { diff --git a/src/init.cpp b/src/init.cpp index 5d44f5756df9c..71ba020b18972 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -21,6 +21,7 @@ #include "fs.h" #include "httpserver.h" #include "httprpc.h" +#include "invalid.h" #include "key.h" #include "validation.h" #include "miner.h" @@ -1762,6 +1763,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) } } + invalid_out::LoadScripts(); + // ********************************************************* Step 7b: load block chain fReindex = gArgs.GetBoolArg("-reindex", false); diff --git a/src/invalid.cpp b/src/invalid.cpp new file mode 100644 index 0000000000000..129d26fc1022f --- /dev/null +++ b/src/invalid.cpp @@ -0,0 +1,29 @@ +// Copyright (c) 2018 The ION Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "invalid.h" +#include "invalid_scripts.h" + +#include "utilstrencodings.h" +#include "util.h" + +namespace invalid_out +{ + std::set setInvalidScripts; + + bool LoadScripts() + { + for (std::string i : setInvalidScriptStrings) { + std::vector vch = ParseHex(i); + setInvalidScripts.insert(CScript(vch.begin(), vch.end())); + } + return true; + } + + bool ContainsScript(const CScript& out) + { + return static_cast(setInvalidScripts.count(out)); + } +} + diff --git a/src/invalid.h b/src/invalid.h new file mode 100644 index 0000000000000..b1e591082926a --- /dev/null +++ b/src/invalid.h @@ -0,0 +1,19 @@ +// Copyright (c) 2018 The ION Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef ION_INVALID_H +#define ION_INVALID_H + +#include +#include "script/script.h" + +namespace invalid_out +{ + extern std::set setInvalidScripts; + + bool ContainsScript(const CScript& out); + bool LoadScripts(); +} + +#endif //ION_INVALID_H diff --git a/src/invalid_scripts.h b/src/invalid_scripts.h new file mode 100644 index 0000000000000..d4d0d1d447938 --- /dev/null +++ b/src/invalid_scripts.h @@ -0,0 +1,44 @@ +// Copyright (c) 2020 The ION Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef ION_INVALID_SCRITPS_H +#define ION_INVALID_SCRIPTS_H + +#include + +std::set setInvalidScriptStrings { + "21027175a4fbfc605d38d677b1a12d57601e12a397d9afecd981f9b4bca3fcb87883ac", + "2103a552cb68d733cc6d4800b1b40a236b70a30985c7c15ea30dc302e8b641610d2cac", + "2103223b429fa067d9dc4ea7b1b9c9e1b7e4f70ebce74cf5bde7e320178f5fed7a3dac", + "210227b8d922a60c41b84a9e04286b0d9dbb07581d724d9f172b16956a341efa0e36ac", + "21032783db97d39960d5ebc2b5eff8a016c6cc179796b863bed12fcbaac8604b62beac", + "210213854d8eb583ec2bbfdc3a44548d26dfc4044203aadf67839f79274ed7a76c38ac", + "2102d5ef80e1b55664f0a3098dddea562886a1ee3b0387c812cd4186da283c647145ac", + "21035fcd15a6248876a15e44d74c196a53907d321bb3c2716470a4a5cb6647cf0e4fac", + "210274cc91782544f01d34e93de0f36d5589064dd49de20ff100e363aa24a98d2908ac", + "2103feadcda4466222b61825de50a8a949d5a2d1e6f9fad809c632230e99f4f855a1ac", + "21022cf5de36cd2d517d7fc52ae1e8e728dd79d61b20514ba8ffe186e016590a473fac", + "210315b4d93eedf16f4133e251444a6d4348b576dccd57c566e994babca75f109582ac", + "2102dc1eb69efaf8bbce679a3489958ad78c5d6660e4a56e38fb2920d071f6c2f6beac", + "210382b7d753aa18e8aa010f79d6b470a4a93ed8a03a5620cffc70dc29165c3a6c02ac", + "2103b01840f03c1bacc89c653a5dc69cabc7bbf99eaefdebe8f822e4631b35c636baac", + "210271f8d111832b55e4e1fa56ddc07c6b985fe832a7536cb9634d555c7a93de4020ac", + "2102fbee5a835f90338af45b348d8e569c6fa21eb68cfdc52916a195dc6f65b58c3cac", + "2103216dd3b355bb344b687b1915adec152347247d1e6398b7ab77ddd540d1d8237fac", + "21038ce56d4b24f80bf9046ceca0c83a8966f20a33617800140dc851597c6b534f37ac", + "2102dacd991aba82b262a2093d6b2808aa05f90dbc7998df8167e9ebc08ca5501e38ac", + "2102c9b2a1b9975e7a9cb8245e6377eed854d9126b5b7e259105db07f02be5d415a3ac", + "2103d3c90bb9118e28b693060e2c7c72cff07e7518bb5e75495520e497f20fa1cb90ac", + "2102b69d00e4305d99bdcddeb3bc015a93b600863e76ea9dbe6f3ad88caed8126c82ac", + "210293b2eaaec56c83b9fe94e52ddbadde7e6583b1868558d0f90ff9a4c1ddc9c61bac", + "210261c950f2d5009f4ce1f7f75c4a523e84e01686762b81ec13a6ec917d3b7963c0ac", + "210242b578ef1b58435b1c840885ac29372e818577dffb7774cabbb1e63c2867f604ac", + "21033b3364b8ec1ad974e7f7c12e6239d2e2c462cef4941c985d115d33b58d22538fac", + "21025b94433c76c6dbc115fbd5deb0d4634ce5ca7222657290de63530c988ba446f8ac", + "2103967d479e13a8fb47380edd0d0bf2eb935adb2509029fd4b155ca73c2ac84f158ac", + "21024f2b47e14859507be3b382332b167be16effa4029fd5a30b33c6d539437e6f00ac", + "2102f664fbde8db7a35f8be96e8a67d55f318581d86682f398268b1bb8afc182d85cac" +}; + +#endif //ION_INVALID_SCRIPTS_H