Correct script serialization

This commit is contained in:
miketout
2018-10-13 18:21:44 -07:00
parent e5ea351a13
commit 26bf01e90e
2 changed files with 11 additions and 4 deletions

View File

@@ -221,8 +221,10 @@ bool GetCCParams(Eval* eval, const CTransaction &tx, uint32_t nIn,
{
if (tx.vout[tx.vout.size() - 1].scriptPubKey.GetOpretData(params) && params.size() == 1)
{
CScript scr = CScript(params[0]);
// printf("Stake cheat parameter opret:\n%s\n", scr.ToString().c_str());
CScript scr = CScript(params[0].begin(), params[0].end());
printf("Script decoding inner:\n%s\nouter:\n%s\n", scr.ToString().c_str(), tx.vout[tx.vout.size() - 1].scriptPubKey.ToString().c_str());
if (!scr.GetPushedData(scr.begin(), params))
{
return false;

View File

@@ -293,12 +293,17 @@ bool MakeCheatEvidence(CMutableTransaction &mtx, const CTransaction &ccTx, uint3
if (ValidateMatchingStake(ccTx, voutNum, cheatTx, isCheater) && isCheater)
{
CTxOut vOut = CTxOut();
int64_t opretype_stakecheat = OPRETTYPE_STAKECHEAT;
CScript vData = CScript();
cheatTx.Serialize(s);
vch = std::vector<unsigned char>(s.begin(), s.end());
vData << ((int64_t)OPRETTYPE_STAKECHEAT) << vch;
vOut.scriptPubKey << OP_RETURN << std::vector<unsigned char>(vData.begin(), vData.end());
vData << opretype_stakecheat << vch;
vch = std::vector<unsigned char>(vData.begin(), vData.end());
vOut.scriptPubKey << OP_RETURN << vch;
printf("Script encoding inner:\n%s\nouter:\n%s\n", vData.ToString().c_str(), vOut.scriptPubKey.ToString().c_str());
vOut.nValue = 0;
mtx.vout.push_back(vOut);
}