opret processing returned to the variant without OP_RETURN opcode (cause this caused validation err)
This commit is contained in:
@@ -53,29 +53,32 @@ CScript EncodeTokenCreateOpRet(uint8_t funcid,std::vector<uint8_t> origpubkey,st
|
||||
// this is for other contracts which use tokens and build customized extra payloads to token's opret:
|
||||
CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 tokenid, std::vector<CPubKey> voutPubkeys, CScript payload)
|
||||
{
|
||||
CScript opret1, opret2;
|
||||
CScript opret;
|
||||
|
||||
if (evalCodeInOpret != EVAL_TOKENS) {
|
||||
std::cerr << "EncodeTokenOpRet() evalCode should be EVAL_TOKENS!" << std::endl;
|
||||
return opret; // return empty
|
||||
}
|
||||
|
||||
tokenid = revuint256(tokenid);
|
||||
|
||||
uint8_t ccType = 0;
|
||||
if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2)
|
||||
ccType = voutPubkeys.size();
|
||||
|
||||
//uint8_t evalcode = EVAL_TOKENS;
|
||||
tokenid = revuint256(tokenid);
|
||||
//uint8_t tokenFuncId = (isTransferrable) ? (uint8_t)'t' : (uint8_t)'l';
|
||||
|
||||
std::vector<uint8_t> vpayload;
|
||||
GetOpReturnData(payload, vpayload);
|
||||
|
||||
//opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << payload);
|
||||
opret1 << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \
|
||||
if (ccType >= 1) ss << voutPubkeys[0]; \
|
||||
if (ccType == 2) ss << voutPubkeys[1];);
|
||||
opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \
|
||||
if (ccType >= 1) ss << voutPubkeys[0]; \
|
||||
if (ccType == 2) ss << voutPubkeys[1]; \
|
||||
if (vpayload.size() > 0) ss << vpayload;);
|
||||
|
||||
//add second opret:
|
||||
opret2 << OP_RETURN << E_MARSHAL(ss << vpayload);
|
||||
|
||||
// if (payload.size() > 0)
|
||||
// opret += payload;
|
||||
return opret1 + opret2;
|
||||
// opret += payload; --> "error 64: scriptpubkey"
|
||||
|
||||
return opret;
|
||||
}
|
||||
|
||||
|
||||
@@ -370,7 +373,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
|
||||
|
||||
// moved opret checking to this new reusable func (dimxy):
|
||||
std::vector<CPubKey> voutPubkeys;
|
||||
std::vector<uint8_t> vopretExtra, vcontractOpret;
|
||||
std::vector<uint8_t> vopretExtra;
|
||||
//std::vector<uint8_t> vcontractOpret;
|
||||
const uint8_t funcId = ValidateTokenOpret(tx, v, reftokenid, voutPubkeys, vopretExtra);
|
||||
std::cerr << indentStr << "IsTokensvout() ValidateTokenOpret returned=" << (char)(funcId?funcId:' ') << " for txid=" << tx.GetHash().GetHex() << " for tokenid=" << reftokenid.GetHex() << std::endl;
|
||||
if (funcId != 0) {
|
||||
@@ -378,18 +382,18 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
|
||||
|
||||
if (checkPubkeys && funcId != 'c') { // verify that the vout is token's (for 'c' there is no pubkeys!):
|
||||
|
||||
CScript contractScript = CScript(vopretExtra);
|
||||
GetOpReturnData(contractScript, vcontractOpret);
|
||||
//CScript contractScript = CScript(vopretExtra);
|
||||
//GetOpReturnData(contractScript, vcontractOpret);
|
||||
|
||||
std::cerr << "IsTokensvout() vcontractOpret=" << HexStr(vopretExtra) << std::endl;
|
||||
std::cerr << "IsTokensvout() vcontractOpret2=" << HexStr(vcontractOpret) << std::endl;;
|
||||
std::cerr << "IsTokensvout() vopretExtra=" << HexStr(vopretExtra) << std::endl;
|
||||
//std::cerr << "IsTokensvout() vcontractOpret=" << HexStr(vcontractOpret) << std::endl;;
|
||||
|
||||
if (vcontractOpret.size() == 0) {
|
||||
std::cerr << "IsTokensvout() empty contract opret" << std::endl;
|
||||
if (vopretExtra.size() < 2 /*|| vopretExtra.size() != vopretExtra.begin()[0]*/) {
|
||||
std::cerr << "IsTokensvout() empty or incorrect contract opret" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t evalCodeInOpret = vcontractOpret.begin()[0];
|
||||
uint8_t evalCodeInOpret = vopretExtra.begin()[1];
|
||||
|
||||
if (voutPubkeys.size() >= 1 && voutPubkeys.size() <= 2) {
|
||||
CTxOut testVout;
|
||||
|
||||
Reference in New Issue
Block a user