From 652077830eaf86f8b4ea6f6c0cf4a82948f571c6 Mon Sep 17 00:00:00 2001 From: Jowen Date: Tue, 12 Feb 2019 10:54:53 +0800 Subject: [PATCH 1/2] fix create_coinstake_tx with input of lockseq pattern --- src/lib/blockchain/validate_transaction.cpp | 7 +++++-- src/lib/consensus/miner.cpp | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/lib/blockchain/validate_transaction.cpp b/src/lib/blockchain/validate_transaction.cpp index 2fb0ef24a..bd2a21b28 100644 --- a/src/lib/blockchain/validate_transaction.cpp +++ b/src/lib/blockchain/validate_transaction.cpp @@ -1576,8 +1576,11 @@ code validate_transaction::check_transaction_basic() const const auto is_testnet = chain.chain_settings().use_testnet_rules; if (tx.version >= transaction_version::check_output_script) { - for (auto& i : tx.outputs) { - if (i.script.pattern() == chain::script_pattern::non_standard) { + for (size_t i = 0; i < tx.outputs.size(); ++i) { + if (i == 0 && tx.is_coinstake()) { + continue; + } + if (tx.outputs[i].script.pattern() == chain::script_pattern::non_standard) { return error::script_not_standard; } } diff --git a/src/lib/consensus/miner.cpp b/src/lib/consensus/miner.cpp index ce1edb13b..0cadf40e3 100644 --- a/src/lib/consensus/miner.cpp +++ b/src/lib/consensus/miner.cpp @@ -1040,6 +1040,14 @@ miner::block_ptr miner::create_new_block_pos( log::info(LOG_HEADER) << "create a PoS block at height " << block_height << ", header hash is " << encode_hash(pblock->header.hash()); + +#ifdef MVS_DEBUG + for (auto& tx : pblock->transactions) { + log::info(LOG_HEADER) << encode_hash(tx.hash()); + log::info(LOG_HEADER) << tx.to_string(1); + } +#endif + return pblock; } @@ -1160,7 +1168,7 @@ miner::transaction_ptr miner::create_coinstake_tx( { blockchain::block_chain_impl& block_chain = node_.chain_impl(); transaction_ptr coinstake = std::make_shared(); - coinstake->version = chain::transaction_version::first; + coinstake->version = bc::relative_locktime_min_version; bool enable_collect_split = setting_.collect_split_stake; uint64_t nCredit = 0; @@ -1179,9 +1187,10 @@ miner::transaction_ptr miner::create_coinstake_tx( coinstake->outputs.clear(); nCredit = stake.data.value; + auto input_sequence = stake.data.get_lock_sequence(max_input_sequence); // generate inputs - coinstake->inputs.emplace_back(stake.point, stake.data.script, max_input_sequence); + coinstake->inputs.emplace_back(stake.point, stake.data.script, input_sequence); // generate outputs coinstake->outputs.emplace_back(0, chain::script(), ATTACH_NULL_TYPE); @@ -1209,7 +1218,9 @@ miner::transaction_ptr miner::create_coinstake_tx( break; } - coinstake->inputs.emplace_back(stake.point, stake.data.script, max_input_sequence); + auto input_sequence = stake.data.get_lock_sequence(max_input_sequence); + + coinstake->inputs.emplace_back(stake.point, stake.data.script, input_sequence); nCredit += stake.data.value; } } From 597b4c1b2c934e9f47bc5fca7069170cc3f35dc4 Mon Sep 17 00:00:00 2001 From: Jowen Date: Sun, 3 Feb 2019 10:08:08 +0800 Subject: [PATCH 2/2] add NDEBUG preprocess for mvsd windows building --- builds/msvc-140/mvsd/mvsd.vcxproj | 2 +- builds/msvc-140/network/network.vcxproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builds/msvc-140/mvsd/mvsd.vcxproj b/builds/msvc-140/mvsd/mvsd.vcxproj index 42c5fa367..849553ae6 100644 --- a/builds/msvc-140/mvsd/mvsd.vcxproj +++ b/builds/msvc-140/mvsd/mvsd.vcxproj @@ -74,7 +74,7 @@ MaxSpeed true true - MINIUPNP_STATICLIB;_MBCS;BC_STATIC;BCB_STATIC;BCC_STATIC;BCK_STATIC;BCD_STATIC;BCX_STATIC;BCT_STATIC;BCN_STATIC;BCP_STATIC;BCS_STATIC;ZMQ_STATIC;_CRT_SUPPRESS_RESTRICT;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + NDEBUG;MINIUPNP_STATICLIB;_MBCS;BC_STATIC;BCB_STATIC;BCC_STATIC;BCK_STATIC;BCD_STATIC;BCX_STATIC;BCT_STATIC;BCN_STATIC;BCP_STATIC;BCS_STATIC;ZMQ_STATIC;_CRT_SUPPRESS_RESTRICT;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded true diff --git a/builds/msvc-140/network/network.vcxproj b/builds/msvc-140/network/network.vcxproj index c8a050cbd..d8d2a795a 100644 --- a/builds/msvc-140/network/network.vcxproj +++ b/builds/msvc-140/network/network.vcxproj @@ -133,7 +133,7 @@ MaxSpeed true true - USE_UPNP;MINIUPNP_STATICLIB;NDEBUG;_LIB;BC_STATIC;BCT_STATIC;BOOST_ASIO_ENABLE_CANCELIO;_SCL_SECURE_NO_WARNINGS + NDEBUG;USE_UPNP;MINIUPNP_STATICLIB;_LIB;BC_STATIC;BCT_STATIC;BOOST_ASIO_ENABLE_CANCELIO;_SCL_SECURE_NO_WARNINGS true MultiThreaded ..\..\..\..\miniupnp;..\..\..\include;..\..\..\..\boost_1_63_0