You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

transaction_tests.cpp 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. // Copyright (c) 2011-2017 The Bitcoin Core developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #include <test/data/tx_invalid.json.h>
  5. #include <test/data/tx_valid.json.h>
  6. #include <test/test_bitcoin.h>
  7. #include <clientversion.h>
  8. #include <checkqueue.h>
  9. #include <consensus/tx_verify.h>
  10. #include <consensus/validation.h>
  11. #include <core_io.h>
  12. #include <key.h>
  13. #include <keystore.h>
  14. #include <validation.h>
  15. #include <policy/policy.h>
  16. #include <script/script.h>
  17. #include <script/sign.h>
  18. #include <script/script_error.h>
  19. #include <script/standard.h>
  20. #include <utilstrencodings.h>
  21. #include <map>
  22. #include <string>
  23. #include <boost/algorithm/string/classification.hpp>
  24. #include <boost/algorithm/string/split.hpp>
  25. #include <boost/test/unit_test.hpp>
  26. #include <univalue.h>
  27. typedef std::vector<unsigned char> valtype;
  28. // In script_tests.cpp
  29. extern UniValue read_json(const std::string& jsondata);
  30. static std::map<std::string, unsigned int> mapFlagNames = {
  31. {std::string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE},
  32. {std::string("P2SH"), (unsigned int)SCRIPT_VERIFY_P2SH},
  33. {std::string("STRICTENC"), (unsigned int)SCRIPT_VERIFY_STRICTENC},
  34. {std::string("DERSIG"), (unsigned int)SCRIPT_VERIFY_DERSIG},
  35. {std::string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S},
  36. {std::string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY},
  37. {std::string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA},
  38. {std::string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY},
  39. {std::string("DISCOURAGE_UPGRADABLE_NOPS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS},
  40. {std::string("CLEANSTACK"), (unsigned int)SCRIPT_VERIFY_CLEANSTACK},
  41. {std::string("MINIMALIF"), (unsigned int)SCRIPT_VERIFY_MINIMALIF},
  42. {std::string("NULLFAIL"), (unsigned int)SCRIPT_VERIFY_NULLFAIL},
  43. {std::string("CHECKLOCKTIMEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY},
  44. {std::string("CHECKSEQUENCEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKSEQUENCEVERIFY},
  45. {std::string("WITNESS"), (unsigned int)SCRIPT_VERIFY_WITNESS},
  46. {std::string("DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM},
  47. {std::string("WITNESS_PUBKEYTYPE"), (unsigned int)SCRIPT_VERIFY_WITNESS_PUBKEYTYPE},
  48. {std::string("CONST_SCRIPTCODE"), (unsigned int)SCRIPT_VERIFY_CONST_SCRIPTCODE},
  49. };
  50. unsigned int ParseScriptFlags(std::string strFlags)
  51. {
  52. if (strFlags.empty()) {
  53. return 0;
  54. }
  55. unsigned int flags = 0;
  56. std::vector<std::string> words;
  57. boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(","));
  58. for (std::string word : words)
  59. {
  60. if (!mapFlagNames.count(word))
  61. BOOST_ERROR("Bad test: unknown verification flag '" << word << "'");
  62. flags |= mapFlagNames[word];
  63. }
  64. return flags;
  65. }
  66. std::string FormatScriptFlags(unsigned int flags)
  67. {
  68. if (flags == 0) {
  69. return "";
  70. }
  71. std::string ret;
  72. std::map<std::string, unsigned int>::const_iterator it = mapFlagNames.begin();
  73. while (it != mapFlagNames.end()) {
  74. if (flags & it->second) {
  75. ret += it->first + ",";
  76. }
  77. it++;
  78. }
  79. return ret.substr(0, ret.size() - 1);
  80. }
  81. BOOST_FIXTURE_TEST_SUITE(transaction_tests, BasicTestingSetup)
  82. BOOST_AUTO_TEST_CASE(tx_valid)
  83. {
  84. // Read tests from test/data/tx_valid.json
  85. // Format is an array of arrays
  86. // Inner arrays are either [ "comment" ]
  87. // or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, verifyFlags
  88. // ... where all scripts are stringified scripts.
  89. //
  90. // verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
  91. UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
  92. ScriptError err;
  93. for (unsigned int idx = 0; idx < tests.size(); idx++) {
  94. UniValue test = tests[idx];
  95. std::string strTest = test.write();
  96. if (test[0].isArray())
  97. {
  98. if (test.size() != 3 || !test[1].isStr() || !test[2].isStr())
  99. {
  100. BOOST_ERROR("Bad test: " << strTest);
  101. continue;
  102. }
  103. std::map<COutPoint, CScript> mapprevOutScriptPubKeys;
  104. std::map<COutPoint, int64_t> mapprevOutValues;
  105. UniValue inputs = test[0].get_array();
  106. bool fValid = true;
  107. for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
  108. const UniValue& input = inputs[inpIdx];
  109. if (!input.isArray())
  110. {
  111. fValid = false;
  112. break;
  113. }
  114. UniValue vinput = input.get_array();
  115. if (vinput.size() < 3 || vinput.size() > 4)
  116. {
  117. fValid = false;
  118. break;
  119. }
  120. COutPoint outpoint(uint256S(vinput[0].get_str()), vinput[1].get_int());
  121. mapprevOutScriptPubKeys[outpoint] = ParseScript(vinput[2].get_str());
  122. if (vinput.size() >= 4)
  123. {
  124. mapprevOutValues[outpoint] = vinput[3].get_int64();
  125. }
  126. }
  127. if (!fValid)
  128. {
  129. BOOST_ERROR("Bad test: " << strTest);
  130. continue;
  131. }
  132. std::string transaction = test[1].get_str();
  133. CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION);
  134. CTransaction tx(deserialize, stream);
  135. CValidationState state;
  136. BOOST_CHECK_MESSAGE(CheckTransaction(tx, state), strTest);
  137. BOOST_CHECK(state.IsValid());
  138. PrecomputedTransactionData txdata(tx);
  139. for (unsigned int i = 0; i < tx.vin.size(); i++)
  140. {
  141. if (!mapprevOutScriptPubKeys.count(tx.vin[i].prevout))
  142. {
  143. BOOST_ERROR("Bad test: " << strTest);
  144. break;
  145. }
  146. CAmount amount = 0;
  147. if (mapprevOutValues.count(tx.vin[i].prevout)) {
  148. amount = mapprevOutValues[tx.vin[i].prevout];
  149. }
  150. unsigned int verify_flags = ParseScriptFlags(test[2].get_str());
  151. const CScriptWitness *witness = &tx.vin[i].scriptWitness;
  152. BOOST_CHECK_MESSAGE(VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout],
  153. witness, verify_flags, TransactionSignatureChecker(&tx, i, amount, txdata), &err),
  154. strTest);
  155. BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
  156. }
  157. }
  158. }
  159. }
  160. BOOST_AUTO_TEST_CASE(tx_invalid)
  161. {
  162. // Read tests from test/data/tx_invalid.json
  163. // Format is an array of arrays
  164. // Inner arrays are either [ "comment" ]
  165. // or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, verifyFlags
  166. // ... where all scripts are stringified scripts.
  167. //
  168. // verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
  169. UniValue tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid)));
  170. // Initialize to SCRIPT_ERR_OK. The tests expect err to be changed to a
  171. // value other than SCRIPT_ERR_OK.
  172. ScriptError err = SCRIPT_ERR_OK;
  173. for (unsigned int idx = 0; idx < tests.size(); idx++) {
  174. UniValue test = tests[idx];
  175. std::string strTest = test.write();
  176. if (test[0].isArray())
  177. {
  178. if (test.size() != 3 || !test[1].isStr() || !test[2].isStr())
  179. {
  180. BOOST_ERROR("Bad test: " << strTest);
  181. continue;
  182. }
  183. std::map<COutPoint, CScript> mapprevOutScriptPubKeys;
  184. std::map<COutPoint, int64_t> mapprevOutValues;
  185. UniValue inputs = test[0].get_array();
  186. bool fValid = true;
  187. for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
  188. const UniValue& input = inputs[inpIdx];
  189. if (!input.isArray())
  190. {
  191. fValid = false;
  192. break;
  193. }
  194. UniValue vinput = input.get_array();
  195. if (vinput.size() < 3 || vinput.size() > 4)
  196. {
  197. fValid = false;
  198. break;
  199. }
  200. COutPoint outpoint(uint256S(vinput[0].get_str()), vinput[1].get_int());
  201. mapprevOutScriptPubKeys[outpoint] = ParseScript(vinput[2].get_str());
  202. if (vinput.size() >= 4)
  203. {
  204. mapprevOutValues[outpoint] = vinput[3].get_int64();
  205. }
  206. }
  207. if (!fValid)
  208. {
  209. BOOST_ERROR("Bad test: " << strTest);
  210. continue;
  211. }
  212. std::string transaction = test[1].get_str();
  213. CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION );
  214. CTransaction tx(deserialize, stream);
  215. CValidationState state;
  216. fValid = CheckTransaction(tx, state) && state.IsValid();
  217. PrecomputedTransactionData txdata(tx);
  218. for (unsigned int i = 0; i < tx.vin.size() && fValid; i++)
  219. {
  220. if (!mapprevOutScriptPubKeys.count(tx.vin[i].prevout))
  221. {
  222. BOOST_ERROR("Bad test: " << strTest);
  223. break;
  224. }
  225. unsigned int verify_flags = ParseScriptFlags(test[2].get_str());
  226. CAmount amount = 0;
  227. if (mapprevOutValues.count(tx.vin[i].prevout)) {
  228. amount = mapprevOutValues[tx.vin[i].prevout];
  229. }
  230. const CScriptWitness *witness = &tx.vin[i].scriptWitness;
  231. fValid = VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout],
  232. witness, verify_flags, TransactionSignatureChecker(&tx, i, amount, txdata), &err);
  233. }
  234. BOOST_CHECK_MESSAGE(!fValid, strTest);
  235. BOOST_CHECK_MESSAGE(err != SCRIPT_ERR_OK, ScriptErrorString(err));
  236. }
  237. }
  238. }
  239. BOOST_AUTO_TEST_CASE(basic_transaction_tests)
  240. {
  241. // Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436)
  242. unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xda, 0x0d, 0xc6, 0xae, 0xce, 0xfe, 0x1e, 0x06, 0xef, 0xdf, 0x05, 0x77, 0x37, 0x57, 0xde, 0xb1, 0x68, 0x82, 0x09, 0x30, 0xe3, 0xb0, 0xd0, 0x3f, 0x46, 0xf5, 0xfc, 0xf1, 0x50, 0xbf, 0x99, 0x0c, 0x02, 0x21, 0x00, 0xd2, 0x5b, 0x5c, 0x87, 0x04, 0x00, 0x76, 0xe4, 0xf2, 0x53, 0xf8, 0x26, 0x2e, 0x76, 0x3e, 0x2d, 0xd5, 0x1e, 0x7f, 0xf0, 0xbe, 0x15, 0x77, 0x27, 0xc4, 0xbc, 0x42, 0x80, 0x7f, 0x17, 0xbd, 0x39, 0x01, 0x41, 0x04, 0xe6, 0xc2, 0x6e, 0xf6, 0x7d, 0xc6, 0x10, 0xd2, 0xcd, 0x19, 0x24, 0x84, 0x78, 0x9a, 0x6c, 0xf9, 0xae, 0xa9, 0x93, 0x0b, 0x94, 0x4b, 0x7e, 0x2d, 0xb5, 0x34, 0x2b, 0x9d, 0x9e, 0x5b, 0x9f, 0xf7, 0x9a, 0xff, 0x9a, 0x2e, 0xe1, 0x97, 0x8d, 0xd7, 0xfd, 0x01, 0xdf, 0xc5, 0x22, 0xee, 0x02, 0x28, 0x3d, 0x3b, 0x06, 0xa9, 0xd0, 0x3a, 0xcf, 0x80, 0x96, 0x96, 0x8d, 0x7d, 0xbb, 0x0f, 0x91, 0x78, 0xff, 0xff, 0xff, 0xff, 0x02, 0x8b, 0xa7, 0x94, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xba, 0xde, 0xec, 0xfd, 0xef, 0x05, 0x07, 0x24, 0x7f, 0xc8, 0xf7, 0x42, 0x41, 0xd7, 0x3b, 0xc0, 0x39, 0x97, 0x2d, 0x7b, 0x88, 0xac, 0x40, 0x94, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00};
  243. std::vector<unsigned char> vch(ch, ch + sizeof(ch) -1);
  244. CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
  245. CMutableTransaction tx;
  246. stream >> tx;
  247. CValidationState state;
  248. BOOST_CHECK_MESSAGE(CheckTransaction(tx, state) && state.IsValid(), "Simple deserialized transaction should be valid.");
  249. // Check that duplicate txins fail
  250. tx.vin.push_back(tx.vin[0]);
  251. BOOST_CHECK_MESSAGE(!CheckTransaction(tx, state) || !state.IsValid(), "Transaction with duplicate txins should be invalid.");
  252. }
  253. //
  254. // Helper: create two dummy transactions, each with
  255. // two outputs. The first has 11 and 50 CENT outputs
  256. // paid to a TX_PUBKEY, the second 21 and 22 CENT outputs
  257. // paid to a TX_PUBKEYHASH.
  258. //
  259. static std::vector<CMutableTransaction>
  260. SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
  261. {
  262. std::vector<CMutableTransaction> dummyTransactions;
  263. dummyTransactions.resize(2);
  264. // Add some keys to the keystore:
  265. CKey key[4];
  266. for (int i = 0; i < 4; i++)
  267. {
  268. key[i].MakeNewKey(i % 2);
  269. keystoreRet.AddKey(key[i]);
  270. }
  271. // Create some dummy input transactions
  272. dummyTransactions[0].vout.resize(2);
  273. dummyTransactions[0].vout[0].nValue = 11*CENT;
  274. dummyTransactions[0].vout[0].scriptPubKey << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG;
  275. dummyTransactions[0].vout[1].nValue = 50*CENT;
  276. dummyTransactions[0].vout[1].scriptPubKey << ToByteVector(key[1].GetPubKey()) << OP_CHECKSIG;
  277. AddCoins(coinsRet, dummyTransactions[0], 0);
  278. dummyTransactions[1].vout.resize(2);
  279. dummyTransactions[1].vout[0].nValue = 21*CENT;
  280. dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey().GetID());
  281. dummyTransactions[1].vout[1].nValue = 22*CENT;
  282. dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey().GetID());
  283. AddCoins(coinsRet, dummyTransactions[1], 0);
  284. return dummyTransactions;
  285. }
  286. BOOST_AUTO_TEST_CASE(test_Get)
  287. {
  288. CBasicKeyStore keystore;
  289. CCoinsView coinsDummy;
  290. CCoinsViewCache coins(&coinsDummy);
  291. std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
  292. CMutableTransaction t1;
  293. t1.vin.resize(3);
  294. t1.vin[0].prevout.hash = dummyTransactions[0].GetHash();
  295. t1.vin[0].prevout.n = 1;
  296. t1.vin[0].scriptSig << std::vector<unsigned char>(65, 0);
  297. t1.vin[1].prevout.hash = dummyTransactions[1].GetHash();
  298. t1.vin[1].prevout.n = 0;
  299. t1.vin[1].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
  300. t1.vin[2].prevout.hash = dummyTransactions[1].GetHash();
  301. t1.vin[2].prevout.n = 1;
  302. t1.vin[2].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
  303. t1.vout.resize(2);
  304. t1.vout[0].nValue = 90*CENT;
  305. t1.vout[0].scriptPubKey << OP_1;
  306. BOOST_CHECK(AreInputsStandard(t1, coins));
  307. BOOST_CHECK_EQUAL(coins.GetValueIn(t1), (50+21+22)*CENT);
  308. }
  309. void CreateCreditAndSpend(const CKeyStore& keystore, const CScript& outscript, CTransactionRef& output, CMutableTransaction& input, bool success = true)
  310. {
  311. CMutableTransaction outputm;
  312. outputm.nVersion = 1;
  313. outputm.vin.resize(1);
  314. outputm.vin[0].prevout.SetNull();
  315. outputm.vin[0].scriptSig = CScript();
  316. outputm.vout.resize(1);
  317. outputm.vout[0].nValue = 1;
  318. outputm.vout[0].scriptPubKey = outscript;
  319. CDataStream ssout(SER_NETWORK, PROTOCOL_VERSION);
  320. ssout << outputm;
  321. ssout >> output;
  322. assert(output->vin.size() == 1);
  323. assert(output->vin[0] == outputm.vin[0]);
  324. assert(output->vout.size() == 1);
  325. assert(output->vout[0] == outputm.vout[0]);
  326. CMutableTransaction inputm;
  327. inputm.nVersion = 1;
  328. inputm.vin.resize(1);
  329. inputm.vin[0].prevout.hash = output->GetHash();
  330. inputm.vin[0].prevout.n = 0;
  331. inputm.vout.resize(1);
  332. inputm.vout[0].nValue = 1;
  333. inputm.vout[0].scriptPubKey = CScript();
  334. bool ret = SignSignature(keystore, *output, inputm, 0, SIGHASH_ALL);
  335. assert(ret == success);
  336. CDataStream ssin(SER_NETWORK, PROTOCOL_VERSION);
  337. ssin << inputm;
  338. ssin >> input;
  339. assert(input.vin.size() == 1);
  340. assert(input.vin[0] == inputm.vin[0]);
  341. assert(input.vout.size() == 1);
  342. assert(input.vout[0] == inputm.vout[0]);
  343. assert(input.vin[0].scriptWitness.stack == inputm.vin[0].scriptWitness.stack);
  344. }
  345. void CheckWithFlag(const CTransactionRef& output, const CMutableTransaction& input, int flags, bool success)
  346. {
  347. ScriptError error;
  348. CTransaction inputi(input);
  349. bool ret = VerifyScript(inputi.vin[0].scriptSig, output->vout[0].scriptPubKey, &inputi.vin[0].scriptWitness, flags, TransactionSignatureChecker(&inputi, 0, output->vout[0].nValue), &error);
  350. assert(ret == success);
  351. }
  352. static CScript PushAll(const std::vector<valtype>& values)
  353. {
  354. CScript result;
  355. for (const valtype& v : values) {
  356. if (v.size() == 0) {
  357. result << OP_0;
  358. } else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) {
  359. result << CScript::EncodeOP_N(v[0]);
  360. } else {
  361. result << v;
  362. }
  363. }
  364. return result;
  365. }
  366. void ReplaceRedeemScript(CScript& script, const CScript& redeemScript)
  367. {
  368. std::vector<valtype> stack;
  369. EvalScript(stack, script, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
  370. assert(stack.size() > 0);
  371. stack.back() = std::vector<unsigned char>(redeemScript.begin(), redeemScript.end());
  372. script = PushAll(stack);
  373. }
  374. BOOST_AUTO_TEST_CASE(test_big_witness_transaction) {
  375. CMutableTransaction mtx;
  376. mtx.nVersion = 1;
  377. CKey key;
  378. key.MakeNewKey(true); // Need to use compressed keys in segwit or the signing will fail
  379. CBasicKeyStore keystore;
  380. keystore.AddKeyPubKey(key, key.GetPubKey());
  381. CKeyID hash = key.GetPubKey().GetID();
  382. CScript scriptPubKey = CScript() << OP_0 << std::vector<unsigned char>(hash.begin(), hash.end());
  383. std::vector<int> sigHashes;
  384. sigHashes.push_back(SIGHASH_NONE | SIGHASH_ANYONECANPAY);
  385. sigHashes.push_back(SIGHASH_SINGLE | SIGHASH_ANYONECANPAY);
  386. sigHashes.push_back(SIGHASH_ALL | SIGHASH_ANYONECANPAY);
  387. sigHashes.push_back(SIGHASH_NONE);
  388. sigHashes.push_back(SIGHASH_SINGLE);
  389. sigHashes.push_back(SIGHASH_ALL);
  390. // create a big transaction of 4500 inputs signed by the same key
  391. for(uint32_t ij = 0; ij < 4500; ij++) {
  392. uint32_t i = mtx.vin.size();
  393. uint256 prevId;
  394. prevId.SetHex("0000000000000000000000000000000000000000000000000000000000000100");
  395. COutPoint outpoint(prevId, i);
  396. mtx.vin.resize(mtx.vin.size() + 1);
  397. mtx.vin[i].prevout = outpoint;
  398. mtx.vin[i].scriptSig = CScript();
  399. mtx.vout.resize(mtx.vout.size() + 1);
  400. mtx.vout[i].nValue = 1000;
  401. mtx.vout[i].scriptPubKey = CScript() << OP_1;
  402. }
  403. // sign all inputs
  404. for(uint32_t i = 0; i < mtx.vin.size(); i++) {
  405. bool hashSigned = SignSignature(keystore, scriptPubKey, mtx, i, 1000, sigHashes.at(i % sigHashes.size()));
  406. assert(hashSigned);
  407. }
  408. CDataStream ssout(SER_NETWORK, PROTOCOL_VERSION);
  409. auto vstream = WithOrVersion(&ssout, 0);
  410. vstream << mtx;
  411. CTransaction tx(deserialize, vstream);
  412. // check all inputs concurrently, with the cache
  413. PrecomputedTransactionData txdata(tx);
  414. boost::thread_group threadGroup;
  415. CCheckQueue<CScriptCheck> scriptcheckqueue(128);
  416. CCheckQueueControl<CScriptCheck> control(&scriptcheckqueue);
  417. for (int i=0; i<20; i++)
  418. threadGroup.create_thread(boost::bind(&CCheckQueue<CScriptCheck>::Thread, boost::ref(scriptcheckqueue)));
  419. std::vector<Coin> coins;
  420. for(uint32_t i = 0; i < mtx.vin.size(); i++) {
  421. Coin coin;
  422. coin.nHeight = 1;
  423. coin.fCoinBase = false;
  424. coin.out.nValue = 1000;
  425. coin.out.scriptPubKey = scriptPubKey;
  426. coins.emplace_back(std::move(coin));
  427. }
  428. for(uint32_t i = 0; i < mtx.vin.size(); i++) {
  429. std::vector<CScriptCheck> vChecks;
  430. CScriptCheck check(coins[tx.vin[i].prevout.n].out, tx, i, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false, &txdata);
  431. vChecks.push_back(CScriptCheck());
  432. check.swap(vChecks.back());
  433. control.Add(vChecks);
  434. }
  435. bool controlCheck = control.Wait();
  436. assert(controlCheck);
  437. threadGroup.interrupt_all();
  438. threadGroup.join_all();
  439. }
  440. BOOST_AUTO_TEST_CASE(test_witness)
  441. {
  442. CBasicKeyStore keystore, keystore2;
  443. CKey key1, key2, key3, key1L, key2L;
  444. CPubKey pubkey1, pubkey2, pubkey3, pubkey1L, pubkey2L;
  445. key1.MakeNewKey(true);
  446. key2.MakeNewKey(true);
  447. key3.MakeNewKey(true);
  448. key1L.MakeNewKey(false);
  449. key2L.MakeNewKey(false);
  450. pubkey1 = key1.GetPubKey();
  451. pubkey2 = key2.GetPubKey();
  452. pubkey3 = key3.GetPubKey();
  453. pubkey1L = key1L.GetPubKey();
  454. pubkey2L = key2L.GetPubKey();
  455. keystore.AddKeyPubKey(key1, pubkey1);
  456. keystore.AddKeyPubKey(key2, pubkey2);
  457. keystore.AddKeyPubKey(key1L, pubkey1L);
  458. keystore.AddKeyPubKey(key2L, pubkey2L);
  459. CScript scriptPubkey1, scriptPubkey2, scriptPubkey1L, scriptPubkey2L, scriptMulti;
  460. scriptPubkey1 << ToByteVector(pubkey1) << OP_CHECKSIG;
  461. scriptPubkey2 << ToByteVector(pubkey2) << OP_CHECKSIG;
  462. scriptPubkey1L << ToByteVector(pubkey1L) << OP_CHECKSIG;
  463. scriptPubkey2L << ToByteVector(pubkey2L) << OP_CHECKSIG;
  464. std::vector<CPubKey> oneandthree;
  465. oneandthree.push_back(pubkey1);
  466. oneandthree.push_back(pubkey3);
  467. scriptMulti = GetScriptForMultisig(2, oneandthree);
  468. keystore.AddCScript(scriptPubkey1);
  469. keystore.AddCScript(scriptPubkey2);
  470. keystore.AddCScript(scriptPubkey1L);
  471. keystore.AddCScript(scriptPubkey2L);
  472. keystore.AddCScript(scriptMulti);
  473. keystore.AddCScript(GetScriptForWitness(scriptPubkey1));
  474. keystore.AddCScript(GetScriptForWitness(scriptPubkey2));
  475. keystore.AddCScript(GetScriptForWitness(scriptPubkey1L));
  476. keystore.AddCScript(GetScriptForWitness(scriptPubkey2L));
  477. keystore.AddCScript(GetScriptForWitness(scriptMulti));
  478. keystore2.AddCScript(scriptMulti);
  479. keystore2.AddCScript(GetScriptForWitness(scriptMulti));
  480. keystore2.AddKeyPubKey(key3, pubkey3);
  481. CTransactionRef output1, output2;
  482. CMutableTransaction input1, input2;
  483. SignatureData sigdata;
  484. // Normal pay-to-compressed-pubkey.
  485. CreateCreditAndSpend(keystore, scriptPubkey1, output1, input1);
  486. CreateCreditAndSpend(keystore, scriptPubkey2, output2, input2);
  487. CheckWithFlag(output1, input1, 0, true);
  488. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  489. CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true);
  490. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  491. CheckWithFlag(output1, input2, 0, false);
  492. CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, false);
  493. CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false);
  494. CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false);
  495. // P2SH pay-to-compressed-pubkey.
  496. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(scriptPubkey1)), output1, input1);
  497. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(scriptPubkey2)), output2, input2);
  498. ReplaceRedeemScript(input2.vin[0].scriptSig, scriptPubkey1);
  499. CheckWithFlag(output1, input1, 0, true);
  500. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  501. CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true);
  502. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  503. CheckWithFlag(output1, input2, 0, true);
  504. CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, false);
  505. CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false);
  506. CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false);
  507. // Witness pay-to-compressed-pubkey (v0).
  508. CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey1), output1, input1);
  509. CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey2), output2, input2);
  510. CheckWithFlag(output1, input1, 0, true);
  511. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  512. CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true);
  513. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  514. CheckWithFlag(output1, input2, 0, true);
  515. CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, true);
  516. CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false);
  517. CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false);
  518. // P2SH witness pay-to-compressed-pubkey (v0).
  519. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey1))), output1, input1);
  520. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey2))), output2, input2);
  521. ReplaceRedeemScript(input2.vin[0].scriptSig, GetScriptForWitness(scriptPubkey1));
  522. CheckWithFlag(output1, input1, 0, true);
  523. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  524. CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true);
  525. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  526. CheckWithFlag(output1, input2, 0, true);
  527. CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, true);
  528. CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false);
  529. CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false);
  530. // Normal pay-to-uncompressed-pubkey.
  531. CreateCreditAndSpend(keystore, scriptPubkey1L, output1, input1);
  532. CreateCreditAndSpend(keystore, scriptPubkey2L, output2, input2);
  533. CheckWithFlag(output1, input1, 0, true);
  534. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  535. CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true);
  536. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  537. CheckWithFlag(output1, input2, 0, false);
  538. CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, false);
  539. CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false);
  540. CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false);
  541. // P2SH pay-to-uncompressed-pubkey.
  542. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(scriptPubkey1L)), output1, input1);
  543. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(scriptPubkey2L)), output2, input2);
  544. ReplaceRedeemScript(input2.vin[0].scriptSig, scriptPubkey1L);
  545. CheckWithFlag(output1, input1, 0, true);
  546. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  547. CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true);
  548. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  549. CheckWithFlag(output1, input2, 0, true);
  550. CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, false);
  551. CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false);
  552. CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false);
  553. // Signing disabled for witness pay-to-uncompressed-pubkey (v1).
  554. CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey1L), output1, input1, false);
  555. CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey2L), output2, input2, false);
  556. // Signing disabled for P2SH witness pay-to-uncompressed-pubkey (v1).
  557. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey1L))), output1, input1, false);
  558. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey2L))), output2, input2, false);
  559. // Normal 2-of-2 multisig
  560. CreateCreditAndSpend(keystore, scriptMulti, output1, input1, false);
  561. CheckWithFlag(output1, input1, 0, false);
  562. CreateCreditAndSpend(keystore2, scriptMulti, output2, input2, false);
  563. CheckWithFlag(output2, input2, 0, false);
  564. BOOST_CHECK(*output1 == *output2);
  565. UpdateTransaction(input1, 0, CombineSignatures(output1->vout[0].scriptPubKey, MutableTransactionSignatureChecker(&input1, 0, output1->vout[0].nValue), DataFromTransaction(input1, 0), DataFromTransaction(input2, 0)));
  566. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  567. // P2SH 2-of-2 multisig
  568. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(scriptMulti)), output1, input1, false);
  569. CheckWithFlag(output1, input1, 0, true);
  570. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, false);
  571. CreateCreditAndSpend(keystore2, GetScriptForDestination(CScriptID(scriptMulti)), output2, input2, false);
  572. CheckWithFlag(output2, input2, 0, true);
  573. CheckWithFlag(output2, input2, SCRIPT_VERIFY_P2SH, false);
  574. BOOST_CHECK(*output1 == *output2);
  575. UpdateTransaction(input1, 0, CombineSignatures(output1->vout[0].scriptPubKey, MutableTransactionSignatureChecker(&input1, 0, output1->vout[0].nValue), DataFromTransaction(input1, 0), DataFromTransaction(input2, 0)));
  576. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  577. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  578. // Witness 2-of-2 multisig
  579. CreateCreditAndSpend(keystore, GetScriptForWitness(scriptMulti), output1, input1, false);
  580. CheckWithFlag(output1, input1, 0, true);
  581. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false);
  582. CreateCreditAndSpend(keystore2, GetScriptForWitness(scriptMulti), output2, input2, false);
  583. CheckWithFlag(output2, input2, 0, true);
  584. CheckWithFlag(output2, input2, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false);
  585. BOOST_CHECK(*output1 == *output2);
  586. UpdateTransaction(input1, 0, CombineSignatures(output1->vout[0].scriptPubKey, MutableTransactionSignatureChecker(&input1, 0, output1->vout[0].nValue), DataFromTransaction(input1, 0), DataFromTransaction(input2, 0)));
  587. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true);
  588. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  589. // P2SH witness 2-of-2 multisig
  590. CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptMulti))), output1, input1, false);
  591. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
  592. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false);
  593. CreateCreditAndSpend(keystore2, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptMulti))), output2, input2, false);
  594. CheckWithFlag(output2, input2, SCRIPT_VERIFY_P2SH, true);
  595. CheckWithFlag(output2, input2, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false);
  596. BOOST_CHECK(*output1 == *output2);
  597. UpdateTransaction(input1, 0, CombineSignatures(output1->vout[0].scriptPubKey, MutableTransactionSignatureChecker(&input1, 0, output1->vout[0].nValue), DataFromTransaction(input1, 0), DataFromTransaction(input2, 0)));
  598. CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true);
  599. CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
  600. }
  601. BOOST_AUTO_TEST_CASE(test_IsStandard)
  602. {
  603. LOCK(cs_main);
  604. CBasicKeyStore keystore;
  605. CCoinsView coinsDummy;
  606. CCoinsViewCache coins(&coinsDummy);
  607. std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
  608. CMutableTransaction t;
  609. t.vin.resize(1);
  610. t.vin[0].prevout.hash = dummyTransactions[0].GetHash();
  611. t.vin[0].prevout.n = 1;
  612. t.vin[0].scriptSig << std::vector<unsigned char>(65, 0);
  613. t.vout.resize(1);
  614. t.vout[0].nValue = 90*CENT;
  615. CKey key;
  616. key.MakeNewKey(true);
  617. t.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID());
  618. std::string reason;
  619. BOOST_CHECK(IsStandardTx(t, reason));
  620. // Check dust with default relay fee:
  621. CAmount nDustThreshold = 182 * dustRelayFee.GetFeePerK()/1000;
  622. BOOST_CHECK_EQUAL(nDustThreshold, 546);
  623. // dust:
  624. t.vout[0].nValue = nDustThreshold - 1;
  625. BOOST_CHECK(!IsStandardTx(t, reason));
  626. // not dust:
  627. t.vout[0].nValue = nDustThreshold;
  628. BOOST_CHECK(IsStandardTx(t, reason));
  629. // Check dust with odd relay fee to verify rounding:
  630. // nDustThreshold = 182 * 3702 / 1000
  631. dustRelayFee = CFeeRate(3702);
  632. // dust:
  633. t.vout[0].nValue = 673 - 1;
  634. BOOST_CHECK(!IsStandardTx(t, reason));
  635. // not dust:
  636. t.vout[0].nValue = 673;
  637. BOOST_CHECK(IsStandardTx(t, reason));
  638. dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
  639. t.vout[0].scriptPubKey = CScript() << OP_1;
  640. BOOST_CHECK(!IsStandardTx(t, reason));
  641. // MAX_OP_RETURN_RELAY-byte TX_NULL_DATA (standard)
  642. t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
  643. BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY, t.vout[0].scriptPubKey.size());
  644. BOOST_CHECK(IsStandardTx(t, reason));
  645. // MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard)
  646. t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
  647. BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size());
  648. BOOST_CHECK(!IsStandardTx(t, reason));
  649. // Data payload can be encoded in any way...
  650. t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("");
  651. BOOST_CHECK(IsStandardTx(t, reason));
  652. t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("00") << ParseHex("01");
  653. BOOST_CHECK(IsStandardTx(t, reason));
  654. // OP_RESERVED *is* considered to be a PUSHDATA type opcode by IsPushOnly()!
  655. t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RESERVED << -1 << 0 << ParseHex("01") << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16;
  656. BOOST_CHECK(IsStandardTx(t, reason));
  657. t.vout[0].scriptPubKey = CScript() << OP_RETURN << 0 << ParseHex("01") << 2 << ParseHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
  658. BOOST_CHECK(IsStandardTx(t, reason));
  659. // ...so long as it only contains PUSHDATA's
  660. t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RETURN;
  661. BOOST_CHECK(!IsStandardTx(t, reason));
  662. // TX_NULL_DATA w/o PUSHDATA
  663. t.vout.resize(1);
  664. t.vout[0].scriptPubKey = CScript() << OP_RETURN;
  665. BOOST_CHECK(IsStandardTx(t, reason));
  666. // Only one TX_NULL_DATA permitted in all cases
  667. t.vout.resize(2);
  668. t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
  669. t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
  670. BOOST_CHECK(!IsStandardTx(t, reason));
  671. t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
  672. t.vout[1].scriptPubKey = CScript() << OP_RETURN;
  673. BOOST_CHECK(!IsStandardTx(t, reason));
  674. t.vout[0].scriptPubKey = CScript() << OP_RETURN;
  675. t.vout[1].scriptPubKey = CScript() << OP_RETURN;
  676. BOOST_CHECK(!IsStandardTx(t, reason));
  677. }
  678. BOOST_AUTO_TEST_SUITE_END()