This commit is contained in:
jl777
2018-07-21 07:54:43 -11:00
parent 977f6c1400
commit c7503fcf73

View File

@@ -206,9 +206,18 @@ CScript EncodeCreateOpRet(uint8_t funcid,std::vector<uint8_t> origpubkey,std::st
return(opret); return(opret);
} }
uint256 revuint256(uint256 txid)
{
uint256 revtxid; int32_t i;
for (i=31; i>=0; i--)
((uint8_t *)&revtxid)[31-i] = ((uint8_t *)&assetid)[i];
return(revtxid);
}
CScript EncodeOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,uint64_t price,std::vector<uint8_t> origpubkey) CScript EncodeOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,uint64_t price,std::vector<uint8_t> origpubkey)
{ {
CScript opret; uint8_t evalcode = EVAL_ASSETS; CScript opret; uint8_t evalcode = EVAL_ASSETS;
assetid = revuint256(assetid);
switch ( funcid ) switch ( funcid )
{ {
case 't': case 'x': case 'o': case 't': case 'x': case 'o':
@@ -218,6 +227,7 @@ CScript EncodeOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,uint64_t pri
opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << price << origpubkey); opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << price << origpubkey);
break; break;
case 'E': case 'e': case 'E': case 'e':
assetid2 = revuint256(assetid2);
opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << assetid2 << price << origpubkey); opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << assetid << assetid2 << price << origpubkey);
break; break;
default: default:
@@ -357,7 +367,10 @@ uint8_t DecodeOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &asseti
break; break;
case 's': case 'b': case 'S': case 'B': case 's': case 'b': case 'S': case 'B':
if ( E_UNMARSHAL(vopret, ss >> assetid; ss >> price; ss >> origpubkey) != 0 ) if ( E_UNMARSHAL(vopret, ss >> assetid; ss >> price; ss >> origpubkey) != 0 )
{
fprintf(stderr,"got price %llu\n",(long long)price);
return(funcid); return(funcid);
}
break; break;
case 'E': case 'e': case 'E': case 'e':
if ( E_UNMARSHAL(vopret, ss >> assetid; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 ) if ( E_UNMARSHAL(vopret, ss >> assetid; ss >> assetid2; ss >> price; ss >> origpubkey) != 0 )