Skip to content

Commit

Permalink
Fixed decoderawtransaction output on unsent stream creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mike31 committed Oct 28, 2018
1 parent 2b6084f commit 5923fad
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/rpc/rpcrawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,27 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
if(new_entity_type == MC_ENT_TYPE_STREAM)
{
uint256 txid=tx.GetHash();
entry.push_back(Pair("create", StreamEntry((unsigned char*)&txid,0x05)));

mc_EntityDetails entity;
mc_EntityDetails *lpEntity=NULL;
entity.Zero();
if(mc_gState->m_Assets->FindEntityByTxID(&entity,(unsigned char*)&txid) == 0)
{
mc_EntityLedgerRow entity_row;
entity_row.Zero();
memcpy(entity_row.m_Key,&txid,MC_ENT_KEY_SIZE);
entity_row.m_EntityType=MC_ENT_TYPE_STREAM;
entity_row.m_Block=mc_gState->m_Assets->m_Block;
entity_row.m_Offset=-1;
entity_row.m_ScriptSize=details_script_size;
if(details_script_size)
{
memcpy(entity_row.m_Script,details_script,details_script_size);
}
entity.Set(&entity_row);
lpEntity=&entity;
}
entry.push_back(Pair("create", StreamEntry((unsigned char*)&txid,0x05,lpEntity)));
}

if(mc_gState->m_Compatibility & MC_VCM_1_0)
Expand Down
14 changes: 12 additions & 2 deletions src/rpc/rpcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ Object FilterEntry(const unsigned char *txid,uint32_t output_level,uint32_t filt
return entry;
}

Object StreamEntry(const unsigned char *txid,uint32_t output_level)
Object StreamEntry(const unsigned char *txid,uint32_t output_level,mc_EntityDetails *raw_entity)
{
// output_level constants
// 0x0001 type
Expand All @@ -806,9 +806,14 @@ Object StreamEntry(const unsigned char *txid,uint32_t output_level)
return entry;
}


uint256 hash=*(uint256*)txid;
if(mc_gState->m_Assets->FindEntityByTxID(&entity,txid))
if( (raw_entity != NULL ) || (mc_gState->m_Assets->FindEntityByTxID(&entity,txid) != 0) )
{
if(raw_entity)
{
memcpy(&entity,raw_entity,sizeof(mc_EntityDetails));
}
ptr=(unsigned char *)entity.GetName();

if(output_level & 0x001)
Expand Down Expand Up @@ -1020,6 +1025,11 @@ Object StreamEntry(const unsigned char *txid,uint32_t output_level)
return entry;
}

Object StreamEntry(const unsigned char *txid,uint32_t output_level)
{
return StreamEntry(txid,output_level,NULL);
}

map<string, Value> ParamsToUpgrade(mc_EntityDetails *entity,int version)
{
map<string, Value> result;
Expand Down
1 change: 1 addition & 0 deletions src/rpc/rpcutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Value PermissionForFieldEntry(mc_EntityDetails *lpEntity);
Array PerOutputDataEntries(const CTxOut& txout,mc_Script *lpScript,uint256 txid,int vout);
Array PermissionEntries(const CTxOut& txout,mc_Script *lpScript,bool fLong);
Object StreamEntry(const unsigned char *txid,uint32_t output_level);
Object StreamEntry(const unsigned char *txid,uint32_t output_level,mc_EntityDetails *raw_entity);
Object UpgradeEntry(const unsigned char *txid);
const unsigned char *GetChunkDataInRange(int64_t *out_size,unsigned char* hashes,int chunk_count,int64_t start,int64_t count);
uint32_t GetFormattedData(mc_Script *lpScript,const unsigned char **elem,int64_t *out_size,unsigned char* hashes,int chunk_count,int64_t total_size);
Expand Down

0 comments on commit 5923fad

Please sign in to comment.