corrected for both token and no token vintx

This commit is contained in:
dimxy
2019-02-11 00:16:53 +05:00
parent f86c6a07e8
commit 4c3e9226b6

View File

@@ -711,12 +711,18 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
GetCCaddress1of2(cp,destaddr,roguepk,roguepk);
CCaddr1of2set(cp,roguepk,roguepk,cp->CCpriv,destaddr);
mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode, 1, mypk));
std::vector<uint8_t> vopretFinish, vopret2; uint8_t e, f; uint256 tokenid; std::vector<CPubKey> voutPubkeys, voutPubkeysEmpty;
DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2);
CScript opretRegister = rogue_registeropret(gametxid, playertxid);
rawtx = FinalizeCCTx(0,cp,mtx,CPubKey()/*=null pubkey*/,txfee,
EncodeTokenOpRet(tokenid, voutPubkeysEmpty, vopretFinish /*=non-fungible*/, opretRegister));
if (DecodeTokenOpRet(playertx.vout.back().scriptPubKey, e, tokenid, voutPubkeys, vopretFinish, vopret2) != 0) { // if token in the opret
rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee,
EncodeTokenOpRet(tokenid, voutPubkeysEmpty /*=never spent*/, vopretFinish /*=non-fungible*/, opretRegister));
}
else {
rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, opretRegister);
}
return(rogue_rawtxresult(result,rawtx,1));
} else return(cclib_error(result,"invalid gametxid"));
} else return(cclib_error(result,"no gametxid"));