#include "script/script.h"
#include "main.h"
#include "hash.h"
+#include "key_io.h"
#include "streams.h"
// destination address or a properly signed stake transaction of the same utxo on a fork
vout = MakeCC1of2vout(EVAL_STAKEGUARD, value, dest, ccAddress);
- std::vector<CPubKey> vPubKeys = std::vector<CPubKey>();
- vPubKeys.push_back(dest);
- vPubKeys.push_back(ccAddress);
+ std::vector<CTxDestination> vKeys;
+ vKeys.push_back(dest);
+ vKeys.push_back(ccAddress);
std::vector<std::vector<unsigned char>> vData = std::vector<std::vector<unsigned char>>();
}
vData.push_back(height);
- COptCCParams ccp = COptCCParams(COptCCParams::VERSION, EVAL_STAKEGUARD, 1, 2, vPubKeys, vData);
+ COptCCParams ccp = COptCCParams(COptCCParams::VERSION_V1, EVAL_STAKEGUARD, 1, 2, vKeys, vData);
vout.scriptPubKey << ccp.AsVector() << OP_DROP;
return true;
bool MakeCheatEvidence(CMutableTransaction &mtx, const CTransaction &ccTx, uint32_t voutNum, const CTransaction &cheatTx)
{
std::vector<unsigned char> vch;
- CDataStream s = CDataStream(SER_DISK, CLIENT_VERSION);
+ CDataStream s = CDataStream(SER_DISK, PROTOCOL_VERSION);
bool isCheater = false;
if (ValidateMatchingStake(ccTx, voutNum, cheatTx, isCheater) && isCheater)
if (ccp.IsValid() && ccp.m == 1 && ccp.n == 2 && ccp.vKeys.size() == 2)
{
std::vector<uint32_t> vc = {0, 0};
- ccFulfillmentCheck fc = {ccp.vKeys, vc};
- signedByFirstKey = (IsCCFulfilled(cc, &fc) != 0);
-
- if ((!signedByFirstKey && ccp.evalCode == EVAL_STAKEGUARD && ccp.vKeys.size() == 2 && ccp.version == COptCCParams::VERSION) &&
- params.size() == 2 && params[0].size() > 0 && params[0][0] == OPRETTYPE_STAKECHEAT)
+ std::vector<CPubKey> keys;
+ for (auto pk : ccp.vKeys)
{
- CDataStream s = CDataStream(std::vector<unsigned char>(params[1].begin(), params[1].end()), SER_DISK, CLIENT_VERSION);
- bool checkOK = false;
- CTransaction cheatTx;
- try
- {
- cheatTx.Unserialize(s);
- checkOK = true;
- }
- catch (...)
+ uint160 keyID = GetDestinationID(pk);
+ std::vector<unsigned char> vkch = GetDestinationBytes(pk);
+ if (vkch.size() == 33)
{
+ keys.push_back(CPubKey(vkch));
}
- if (checkOK && !ValidateMatchingStake(txOut, tx.vin[0].prevout.n, cheatTx, validCheat))
+ }
+
+ if (keys.size() == 2)
+ {
+ ccFulfillmentCheck fc = {keys, vc};
+
+ signedByFirstKey = (IsCCFulfilled(cc, &fc) != 0);
+
+ if ((!signedByFirstKey && ccp.evalCode == EVAL_STAKEGUARD && ccp.vKeys.size() == 2 && ccp.version == COptCCParams::VERSION_V1) &&
+ params.size() == 2 && params[0].size() > 0 && params[0][0] == OPRETTYPE_STAKECHEAT)
{
- validCheat = false;
+ CDataStream s = CDataStream(std::vector<unsigned char>(params[1].begin(), params[1].end()), SER_DISK, PROTOCOL_VERSION);
+ bool checkOK = false;
+ CTransaction cheatTx;
+ try
+ {
+ cheatTx.Unserialize(s);
+ checkOK = true;
+ }
+ catch (...)
+ {
+ }
+ if (checkOK && !ValidateMatchingStake(txOut, tx.vin[0].prevout.n, cheatTx, validCheat))
+ {
+ validCheat = false;
+ }
}
}
}