diff --git a/src/Makefile.am b/src/Makefile.am index 2eb247c7c1c2f..7f67136d1f217 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,6 +46,7 @@ BITCOIN_CORE_H = \ mastercore_rpc.h \ mastercore_sp.h \ mastercore_errors.h \ + mastercore_script.h \ mastercore_version.h \ crypter.h \ db.h \ @@ -140,6 +141,7 @@ libbitcoin_common_a_SOURCES = \ mastercore_tx.cpp \ mastercore_rpc.cpp \ mastercore_dex.cpp \ + mastercore_script.cpp \ mastercore_sp.cpp \ hash.cpp \ key.cpp \ diff --git a/src/mastercore.cpp b/src/mastercore.cpp index 3e1122dd1c715..4f1a862806dd8 100644 --- a/src/mastercore.cpp +++ b/src/mastercore.cpp @@ -77,6 +77,7 @@ using namespace mastercore; #include "mastercore_tx.h" #include "mastercore_sp.h" #include "mastercore_errors.h" +#include "mastercore_script.h" #include "mastercore_version.h" // part of 'breakout' feature @@ -1146,7 +1147,7 @@ uint64_t txFee = 0; if (msc_debug_parser_data) file_log("saving address_data #%d: %s:%s\n", i, strAddress.c_str(), wtx.vout[i].scriptPubKey.ToString().c_str()); // saving for Class A processing or reference - wtx.vout[i].scriptPubKey.mscore_parse(script_data); + GetScriptPushes(wtx.vout[i].scriptPubKey, script_data); address_data.push_back(strAddress); value_data.push_back(wtx.vout[i].nValue); } @@ -1305,7 +1306,9 @@ uint64_t txFee = 0; } if (msc_debug_script) file_log("\n"); - wtx.vout[i].scriptPubKey.mscore_parse(multisig_script_data, false); + // ignore first public key, as it should belong to the sender + // and it be used to avoid the creation of unspendable dust + GetScriptPushes(wtx.vout[i].scriptPubKey, multisig_script_data, true); } } } // end of the outputs' for loop @@ -3954,38 +3957,6 @@ int validity = 0; return true; } -std::string CScript::mscore_parse(std::vector&msc_parsed, bool bNoBypass) const -{ - int count = 0; - std::string str; - opcodetype opcode; - std::vector vch; - const_iterator pc = begin(); - while (pc < end()) - { - if (!str.empty()) - { - str += "\n"; - } - if (!GetOp(pc, opcode, vch)) - { - str += "[error]"; - return str; - } - if (0 <= opcode && opcode <= OP_PUSHDATA4) - { - str += ValueString(vch); - if (count || bNoBypass) msc_parsed.push_back(ValueString(vch)); - count++; - } - else - { - str += GetOpName(opcode); - } - } - return str; -} - int mastercore_handler_block_begin(int nBlockPrev, CBlockIndex const * pBlockIndex) { if (reorgRecoveryMode > 0) { reorgRecoveryMode = 0; // clear reorgRecovery here as this is likely re-entrant diff --git a/src/mastercore_script.cpp b/src/mastercore_script.cpp new file mode 100644 index 0000000000000..2aaef54c1cd06 --- /dev/null +++ b/src/mastercore_script.cpp @@ -0,0 +1,23 @@ +#include "mastercore_script.h" + +#include "script.h" +#include "util.h" + +#include +#include + +bool GetScriptPushes(const CScript& scriptIn, std::vector& vstrRet, bool fSkipFirst) +{ + int count = 0; + CScript::const_iterator pc = scriptIn.begin(); + while (pc < scriptIn.end()) + { + opcodetype opcode; + std::vector data; + if (!scriptIn.GetOp(pc, opcode, data)) + return false; + if (0 <= opcode && opcode <= OP_PUSHDATA4) + if (count++ || !fSkipFirst) vstrRet.push_back(HexStr(data)); + } + return true; +} diff --git a/src/mastercore_script.h b/src/mastercore_script.h new file mode 100644 index 0000000000000..3a41506ed7c22 --- /dev/null +++ b/src/mastercore_script.h @@ -0,0 +1,11 @@ +#ifndef MASTERCOIN_SCRIPT_H +#define MASTERCOIN_SCRIPT_H + +#include +#include + +class CScript; + +bool GetScriptPushes(const CScript& scriptIn, std::vector& vstrRet, bool fSkipFirst = false); + +#endif // MASTERCOIN_SCRIPT_H diff --git a/src/script.h b/src/script.h index 9721ef04d4330..1742ce81f810e 100644 --- a/src/script.h +++ b/src/script.h @@ -709,8 +709,6 @@ class CScript : public std::vector { return CScriptID(Hash160(*this)); } - - std::string mscore_parse(std::vector&msc_parsed, bool bNoBypass = true) const; }; /** Compact serializer for scripts.