This commit is contained in:
jl777
2018-07-27 01:25:50 -11:00
parent 5842e917f3
commit 1cdfa0b54b
3 changed files with 38 additions and 2 deletions

View File

@@ -57,12 +57,35 @@ int64_t GetAssetBalance(CPubKey pk,uint256 tokenid)
return(AddAssetInputs(cp,mtx,pk,tokenid,0,0));
}
UniValue AssetInfo(uint256 refassetid)
UniValue AssetInfo(uint256 assetid)
{
UniValue result(UniValue::VARR); uint256 hashBlock; CTransaction vintx; std::vector<uint8_t> origpubkey; std::string name,description; char str[67],numstr[65];
if ( GetTransaction(assetid,vintx,hashBlock,false) == 0 )
{
fprintf(stderr,"cant find assetid\n");
result.push_back(Pair("error","cant find assetid"));
return(0);
}
if ( vintx.vout.size() > 0 && DecodeAssetCreateOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,origpubkey,name,description) == 0 )
{
fprintf(stderr,"assetid isnt assetcreation txid\n");
result.push_back(Pair("error","assetid isnt assetcreation txid"));
}
result.push_back(Pair("result","success"));
result.push_back(Pair("tokenid",uint256_str(str,assetid)));
result.push_back(Pair("owner",pubkey33_str(str,origpubkey.data())));
result.push_back(Pair("name",name));
sprintf(numstr,"%.8f",(double)vintx.vout[0].nValue/COIN);
result.push_back(Pair("supply",numstr));
result.push_back(Pair("description",description));
result.push_back(Pair("result","success"));
return(result);
}
UniValue AssetList()
{
UniValue result(UniValue::VARR);
return(result);
}
UniValue AssetOrders(uint256 refassetid)

View File

@@ -60,6 +60,7 @@ int32_t unstringbits(char *buf,uint64_t bits);
uint64_t stringbits(char *str);
uint256 revuint256(uint256 txid);
char *uint256_str(char *dest,uint256 txid);
char *pubkey33_str(char *dest,uint8_t *pubkey33);
uint256 Parseuint256(char *hexstr);
CPubKey pubkey2pk(std::vector<uint8_t> pubkey);
bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk);

View File

@@ -92,7 +92,19 @@ char *uint256_str(char *dest,uint256 txid)
int32_t i,j=0;
for (i=31; i>=0; i--)
sprintf(&dest[j++ * 2],"%02x",((uint8_t *)&txid)[i]);
return(dest);
dest[64] = 0;
return(dest);
}
char *pubkey33_str(char *dest,uint8_t *pubkey33)
{
int32_t i;
if ( pubkey33 != 0 )
{
for (i=0; i<33; i++)
sprintf(&dest[i * 2],"%02x",pubkey33[i]);
} else dest[0] = 0;
return(dest);
}
uint256 Parseuint256(char *hexstr)