try to construct secod opret w/o serialization
This commit is contained in:
@@ -71,8 +71,8 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t
|
|||||||
|
|
||||||
opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \
|
opret << OP_RETURN << E_MARSHAL(ss << evalCodeInOpret << tokenFuncId << tokenid << ccType; \
|
||||||
if (ccType >= 1) ss << voutPubkeys[0]; \
|
if (ccType >= 1) ss << voutPubkeys[0]; \
|
||||||
if (ccType == 2) ss << voutPubkeys[1]; ); // \
|
if (ccType == 2) ss << voutPubkeys[1]; \
|
||||||
// if (vpayload.size() > 0) ss << vpayload;);
|
if (vpayload.size() > 0) ss << vpayload;);
|
||||||
|
|
||||||
|
|
||||||
// "error 64: scriptpubkey":
|
// "error 64: scriptpubkey":
|
||||||
@@ -84,10 +84,11 @@ CScript EncodeTokenOpRet(uint8_t tokenFuncId, uint8_t evalCodeInOpret, uint256 t
|
|||||||
// return opret + opretPayloadNoOpcode;
|
// return opret + opretPayloadNoOpcode;
|
||||||
|
|
||||||
// how to attach payload without re-serialization:
|
// how to attach payload without re-serialization:
|
||||||
opret.resize(opret.size() + vpayload.size());
|
// sig_aborted:
|
||||||
CScript::iterator it = opret.begin() + opret.size();
|
// opret.resize(opret.size() + vpayload.size());
|
||||||
for (int i = 0; i < vpayload.size(); i++, it++)
|
// CScript::iterator it = opret.begin() + opret.size();
|
||||||
*it = vpayload[i];
|
// for (int i = 0; i < vpayload.size(); i++, it++)
|
||||||
|
// *it = vpayload[i];
|
||||||
|
|
||||||
return opret;
|
return opret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,18 +408,23 @@ uint8_t _DecodeHeirEitherOpret(CScript scriptPubKey, uint256 &tokenid, CPubKey&
|
|||||||
{
|
{
|
||||||
uint8_t evalCodeTokens = 0;
|
uint8_t evalCodeTokens = 0;
|
||||||
std::vector<CPubKey> voutPubkeys;
|
std::vector<CPubKey> voutPubkeys;
|
||||||
std::vector<uint8_t> vopretExtra;
|
std::vector<uint8_t> vopretExtra, vopretStripped;
|
||||||
|
|
||||||
CScript heirScript = scriptPubKey;
|
CScript heirScript = scriptPubKey;
|
||||||
int32_t heirType = HEIR_COINS;
|
|
||||||
|
|
||||||
if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra) != 0) {
|
if (DecodeTokenOpRet(heirScript, evalCodeTokens, tokenid, voutPubkeys, vopretExtra) != 0) {
|
||||||
if (vopretExtra.size() > 1) {
|
if (vopretExtra.size() > 1) {
|
||||||
// restore the second opret:
|
// restore the second opret:
|
||||||
heirScript = CScript();
|
heirScript = CScript();
|
||||||
std::vector<uint8_t> vopretStripped = std::vector<uint8_t>(vopretExtra.begin()+1, vopretExtra.end()); //strip string size
|
|
||||||
heirScript << OP_RETURN << E_MARSHAL(ss << vopretStripped);
|
E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; }); // std::vector<uint8_t>(vopretExtra.begin()+1, vopretExtra.end()); //strip string size
|
||||||
heirType = HEIR_TOKENS;
|
|
||||||
|
heirScript << OP_RETURN;
|
||||||
|
uint32_t i = heirScript.size();
|
||||||
|
heirScript << E_MARSHAL(ss << vopretStripped);
|
||||||
|
for (uint32_t iStripped = 0; iStripped < vopretStripped.size(); iStripped++)
|
||||||
|
heirScript[i] = vopretStripped[iStripped];
|
||||||
|
heirScript.resize(heirScript.size()-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (uint8_t)0;
|
return (uint8_t)0;
|
||||||
|
|||||||
Reference in New Issue
Block a user