Changeset View
Changeset View
Standalone View
Standalone View
src/test/scriptflags.cpp
// Copyright (c) 2017 The Bitcoin developers | // Copyright (c) 2017 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "test/scriptflags.h" | #include "test/scriptflags.h" | ||||
#include "script/interpreter.h" | #include "script/interpreter.h" | ||||
#include <boost/algorithm/string/classification.hpp> | #include <boost/algorithm/string/classification.hpp> | ||||
#include <boost/algorithm/string/split.hpp> | #include <boost/algorithm/string/split.hpp> | ||||
#include <boost/assign/list_of.hpp> | |||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
#include <map> | #include <map> | ||||
#include <vector> | #include <vector> | ||||
static std::map<std::string, unsigned int> mapFlagNames = | static std::map<std::string, unsigned int> mapFlagNames = { | ||||
boost::assign::map_list_of(std::string("NONE"), | {"NONE", SCRIPT_VERIFY_NONE}, | ||||
(unsigned int)SCRIPT_VERIFY_NONE)( | {"P2SH", SCRIPT_VERIFY_P2SH}, | ||||
std::string("P2SH"), (unsigned int)SCRIPT_VERIFY_P2SH)( | {"STRICTENC", SCRIPT_VERIFY_STRICTENC}, | ||||
std::string("STRICTENC"), (unsigned int)SCRIPT_VERIFY_STRICTENC)( | {"DERSIG", SCRIPT_VERIFY_DERSIG}, | ||||
std::string("DERSIG"), (unsigned int)SCRIPT_VERIFY_DERSIG)( | {"LOW_S", SCRIPT_VERIFY_LOW_S}, | ||||
std::string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S)( | {"SIGPUSHONLY", SCRIPT_VERIFY_SIGPUSHONLY}, | ||||
std::string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY)( | {"MINIMALDATA", SCRIPT_VERIFY_MINIMALDATA}, | ||||
std::string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA)( | {"NULLDUMMY", SCRIPT_VERIFY_NULLDUMMY}, | ||||
std::string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY)( | {"DISCOURAGE_UPGRADABLE_NOPS", SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS}, | ||||
std::string("DISCOURAGE_UPGRADABLE_NOPS"), | {"CLEANSTACK", SCRIPT_VERIFY_CLEANSTACK}, | ||||
(unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)( | {"MINIMALIF", SCRIPT_VERIFY_MINIMALIF}, | ||||
std::string("CLEANSTACK"), (unsigned int)SCRIPT_VERIFY_CLEANSTACK)( | {"NULLFAIL", SCRIPT_VERIFY_NULLFAIL}, | ||||
std::string("MINIMALIF"), (unsigned int)SCRIPT_VERIFY_MINIMALIF)( | {"CHECKLOCKTIMEVERIFY", SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY}, | ||||
std::string("NULLFAIL"), (unsigned int)SCRIPT_VERIFY_NULLFAIL)( | {"CHECKSEQUENCEVERIFY", SCRIPT_VERIFY_CHECKSEQUENCEVERIFY}, | ||||
std::string("CHECKLOCKTIMEVERIFY"), | {"DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM", | ||||
(unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)( | SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM}, | ||||
std::string("CHECKSEQUENCEVERIFY"), | {"COMPRESSED_PUBKEYTYPE", SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE}, | ||||
(unsigned int)SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)( | {"SIGHASH_FORKID", SCRIPT_ENABLE_SIGHASH_FORKID}, | ||||
std::string("DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"), | }; | ||||
(unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)( | |||||
std::string("COMPRESSED_PUBKEYTYPE"), | |||||
(unsigned int)SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE)( | |||||
std::string("SIGHASH_FORKID"), | |||||
(unsigned int)SCRIPT_ENABLE_SIGHASH_FORKID); | |||||
unsigned int ParseScriptFlags(std::string strFlags) { | unsigned int ParseScriptFlags(std::string strFlags) { | ||||
if (strFlags.empty()) { | if (strFlags.empty()) { | ||||
return 0; | return 0; | ||||
} | } | ||||
unsigned int flags = 0; | unsigned int flags = 0; | ||||
std::vector<std::string> words; | std::vector<std::string> words; | ||||
boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(",")); | boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(",")); | ||||
Show All 25 Lines |