2424
2525#include < boost/lexical_cast.hpp>
2626
27- void TokenGroupCreationToJSON (const CTokenGroupID &tgID, const CTokenGroupCreation& tgCreation, UniValue& entry, const bool extended = false ) {
27+ void TokenGroupCreationToJSON (const CTokenGroupID &tgID, const CTokenGroupCreation& tgCreation, UniValue& entry, const bool fShowCreation = false , const bool fShowNFTData = false ) {
2828 CTxOut creationOutput;
2929 CTxDestination creationDestination;
3030 GetGroupedCreationOutput (*tgCreation.creationTransaction , creationOutput);
@@ -36,15 +36,15 @@ void TokenGroupCreationToJSON(const CTokenGroupID &tgID, const CTokenGroupCreati
3636 entry.push_back (Pair (" parent_groupID" , EncodeTokenGroup (tgCreation.tokenGroupInfo .associatedGroup )));
3737 entry.push_back (Pair (" subgroup_data" , std::string (subgroupData.begin (), subgroupData.end ())));
3838 }
39- entry.push_back (Pair (" ticker" , tgDescGetTicker (*tgCreation.pTokenGroupDescription )));
40- entry.push_back (Pair (" name" , tgDescGetName (*tgCreation.pTokenGroupDescription )));
41- entry.push_back (Pair (" decimal_pos" , tgDescGetDecimalPos (*tgCreation.pTokenGroupDescription )));
42- entry.push_back (Pair (" metadata_url" , tgDescGetDocumentURL (*tgCreation.pTokenGroupDescription )));
43- entry.push_back (Pair (" metadata_hash" , tgDescGetDocumentHash (*tgCreation.pTokenGroupDescription ).ToString ()));
39+
4440 std::string flags = tgID.encodeFlags ();
4541 if (flags != " none" )
4642 entry.push_back (Pair (" flags" , flags));
47- if (extended) {
43+
44+ UniValue specification = tgDescToJson (*tgCreation.pTokenGroupDescription , fShowNFTData );
45+ entry.push_back (Pair (" specification" , specification));
46+
47+ if (fShowCreation ) {
4848 UniValue extendedEntry (UniValue::VOBJ);
4949 extendedEntry.push_back (Pair (" txid" , tgCreation.creationTransaction ->GetHash ().GetHex ()));
5050 extendedEntry.push_back (Pair (" blockhash" , tgCreation.creationBlockHash .GetHex ()));
@@ -64,19 +64,20 @@ extern UniValue tokeninfo(const JSONRPCRequest& request)
6464
6565 if (request.fHelp || request.params .size () < 1 )
6666 throw std::runtime_error (
67- " tokeninfo [list, all, stats, groupid, ticker, name] ( \" specifier \" ) ( \" extended_info \" ) \n "
67+ " tokeninfo [list, all, stats, groupid, ticker, name] ( \" specifier \" ) ( \" creation_data \" ) ( \" nft_data \" ) \n "
6868 " \n Returns information on all tokens configured on the blockchain.\n "
6969 " \n Arguments:\n "
7070 " 'list' lists all token groupID's and corresponding token tickers\n "
71- " 'all' shows extended information on all tokens\n "
71+ " 'all' shows data for all tokens\n "
7272 " 'stats' shows statistical information on the management tokens in a specific block.\n "
7373 " Args: block hash (optional)\n "
7474 " 'groupid' shows information on the token configuration with the specified grouID\n "
7575 " 'ticker' shows information on the token configuration with the specified ticker\n "
7676 " 'name' shows information on the token configuration with the specified name'\n "
7777 " \n "
7878 " 'specifier' (string, optional) parameter to couple with the main action'\n "
79- " 'extended_info' (bool, optional) show extended information'\n "
79+ " 'creation_data' (bool, optional) show token creation data'\n "
80+ " 'nft_data' (bool, optional) show base64 encoded data of NFT tokens'\n "
8081 " \n " +
8182 HelpExampleCli (" tokeninfo" , " ticker \" WAGERR\" " ) +
8283 " \n "
@@ -105,17 +106,17 @@ extern UniValue tokeninfo(const JSONRPCRequest& request)
105106 if (request.params .size () > 2 ) {
106107 throw JSONRPCError (RPC_INVALID_PARAMS, " Too many parameters" );
107108 }
108- bool extended = false ;
109+ bool fShowCreation = false ;
109110 if (request.params .size () > curparam) {
110- std::string sExtended ;
111+ std::string strShowCreation ;
111112 std::string p = request.params [curparam].get_str ();
112- std::transform (p.begin (), p.end (), std::back_inserter (sExtended ), ::tolower);
113- extended = (sExtended == " true" );
113+ std::transform (p.begin (), p.end (), std::back_inserter (strShowCreation ), ::tolower);
114+ fShowCreation = (strShowCreation == " true" );
114115 }
115116
116117 for (auto tokenGroupMapping : tokenGroupManager.get ()->GetMapTokenGroups ()) {
117118 UniValue entry (UniValue::VOBJ);
118- TokenGroupCreationToJSON (tokenGroupMapping.first , tokenGroupMapping.second , entry, extended );
119+ TokenGroupCreationToJSON (tokenGroupMapping.first , tokenGroupMapping.second , entry, fShowCreation );
119120 ret.push_back (entry);
120121 }
121122 } else if (operation == " stats" ) {
@@ -147,7 +148,7 @@ extern UniValue tokeninfo(const JSONRPCRequest& request)
147148 ret.push_back (entry);
148149
149150 } else if (operation == " groupid" ) {
150- if (request.params .size () > 3 ) {
151+ if (request.params .size () > 4 ) {
151152 throw JSONRPCError (RPC_INVALID_PARAMS, " Too many parameters" );
152153 }
153154
@@ -158,20 +159,28 @@ extern UniValue tokeninfo(const JSONRPCRequest& request)
158159 throw JSONRPCError (RPC_INVALID_PARAMS, " Invalid parameter: No group specified" );
159160 }
160161 curparam++;
161- bool extended = false ;
162+ bool fShowCreation = false ;
163+ if (request.params .size () > curparam) {
164+ std::string strShowCreation;
165+ std::string p = request.params [curparam].get_str ();
166+ std::transform (p.begin (), p.end (), std::back_inserter (strShowCreation), ::tolower);
167+ fShowCreation = (strShowCreation == " true" );
168+ }
169+ curparam++;
170+ bool fShowNFTData = false ;
162171 if (request.params .size () > curparam) {
163- std::string sExtended ;
172+ std::string strShowNFTData ;
164173 std::string p = request.params [curparam].get_str ();
165- std::transform (p.begin (), p.end (), std::back_inserter (sExtended ), ::tolower);
166- extended = (sExtended == " true" );
174+ std::transform (p.begin (), p.end (), std::back_inserter (strShowNFTData ), ::tolower);
175+ fShowNFTData = (strShowNFTData == " true" );
167176 }
168177 UniValue entry (UniValue::VOBJ);
169178 CTokenGroupCreation tgCreation;
170179 tokenGroupManager.get ()->GetTokenGroupCreation (grpID, tgCreation);
171- TokenGroupCreationToJSON (grpID, tgCreation, entry, extended );
180+ TokenGroupCreationToJSON (grpID, tgCreation, entry, fShowCreation , fShowNFTData );
172181 ret.push_back (entry);
173182 } else if (operation == " ticker" ) {
174- if (request.params .size () > 3 ) {
183+ if (request.params .size () > 4 ) {
175184 throw JSONRPCError (RPC_INVALID_PARAMS, " Too many parameters" );
176185 }
177186
@@ -183,23 +192,31 @@ extern UniValue tokeninfo(const JSONRPCRequest& request)
183192 throw JSONRPCError (RPC_INVALID_PARAMS, " Invalid parameter: could not find token group" );
184193 }
185194 curparam++;
186- bool extended = false ;
195+ bool fShowCreation = false ;
187196 if (request.params .size () > curparam) {
188- std::string sExtended ;
197+ std::string strShowCreation ;
189198 std::string p = request.params [curparam].get_str ();
190- std::transform (p.begin (), p.end (), std::back_inserter (sExtended ), ::tolower);
191- extended = (sExtended == " true" );
199+ std::transform (p.begin (), p.end (), std::back_inserter (strShowCreation), ::tolower);
200+ fShowCreation = (strShowCreation == " true" );
201+ }
202+ curparam++;
203+ bool fShowNFTData = false ;
204+ if (request.params .size () > curparam) {
205+ std::string strShowNFTData;
206+ std::string p = request.params [curparam].get_str ();
207+ std::transform (p.begin (), p.end (), std::back_inserter (strShowNFTData), ::tolower);
208+ fShowNFTData = (strShowNFTData == " true" );
192209 }
193210
194211 CTokenGroupCreation tgCreation;
195212 tokenGroupManager.get ()->GetTokenGroupCreation (grpID, tgCreation);
196213
197214 LogPrint (BCLog::TOKEN, " %s - tokenGroupCreation has [%s] [%s]\n " , __func__, tgDescGetTicker (*tgCreation.pTokenGroupDescription ), EncodeTokenGroup (tgCreation.tokenGroupInfo .associatedGroup ));
198215 UniValue entry (UniValue::VOBJ);
199- TokenGroupCreationToJSON (grpID, tgCreation, entry, extended );
216+ TokenGroupCreationToJSON (grpID, tgCreation, entry, fShowCreation , fShowNFTData );
200217 ret.push_back (entry);
201218 } else if (operation == " name" ) {
202- if (request.params .size () > 3 ) {
219+ if (request.params .size () > 4 ) {
203220 throw JSONRPCError (RPC_INVALID_PARAMS, " Too many parameters" );
204221 }
205222
@@ -211,20 +228,28 @@ extern UniValue tokeninfo(const JSONRPCRequest& request)
211228 throw JSONRPCError (RPC_INVALID_PARAMS, " Invalid parameter: Could not find token group" );
212229 }
213230 curparam++;
214- bool extended = false ;
231+ bool fShowCreation = false ;
232+ if (request.params .size () > curparam) {
233+ std::string strShowCreation;
234+ std::string p = request.params [curparam].get_str ();
235+ std::transform (p.begin (), p.end (), std::back_inserter (strShowCreation), ::tolower);
236+ fShowCreation = (strShowCreation == " true" );
237+ }
238+ curparam++;
239+ bool fShowNFTData = false ;
215240 if (request.params .size () > curparam) {
216- std::string sExtended ;
241+ std::string strShowNFTData ;
217242 std::string p = request.params [curparam].get_str ();
218- std::transform (p.begin (), p.end (), std::back_inserter (sExtended ), ::tolower);
219- extended = (sExtended == " true" );
243+ std::transform (p.begin (), p.end (), std::back_inserter (strShowNFTData ), ::tolower);
244+ fShowNFTData = (strShowNFTData == " true" );
220245 }
221246
222247 CTokenGroupCreation tgCreation;
223248 tokenGroupManager.get ()->GetTokenGroupCreation (grpID, tgCreation);
224249
225250 LogPrint (BCLog::TOKEN, " %s - tokenGroupCreation has [%s] [%s]\n " , __func__, tgDescGetTicker (*tgCreation.pTokenGroupDescription ), EncodeTokenGroup (tgCreation.tokenGroupInfo .associatedGroup ));
226251 UniValue entry (UniValue::VOBJ);
227- TokenGroupCreationToJSON (grpID, tgCreation, entry, extended );
252+ TokenGroupCreationToJSON (grpID, tgCreation, entry, fShowCreation , fShowNFTData );
228253 ret.push_back (entry);
229254 } else {
230255 throw JSONRPCError (RPC_INVALID_PARAMS, " Invalid parameter: unknown operation" );
0 commit comments