@@ -609,7 +609,7 @@ static UniValue getreceivedbyaddress(const JSONRPCRequest& request)
609609 return NullUniValue;
610610 }
611611
612- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
612+ if (request.fHelp || request.params .size () < 1 || request.params .size () > 3 )
613613 throw std::runtime_error (
614614 " getreceivedbyaddress \" address\" ( minconf )\n "
615615 " \n Returns the total amount received by the given address in transactions with at least minconf confirmations.\n "
@@ -692,7 +692,7 @@ static UniValue getreceivedbylabel(const JSONRPCRequest& request)
692692 return NullUniValue;
693693 }
694694
695- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
695+ if (request.fHelp || request.params .size () < 1 || request.params .size () > 3 )
696696 throw std::runtime_error (
697697 " getreceivedbylabel \" label\" ( minconf )\n "
698698 " \n Returns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.\n "
@@ -1285,7 +1285,7 @@ static UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bo
12851285
12861286 bool has_filtered_address = false ;
12871287 CTxDestination filtered_address = CNoDestination ();
1288- if (!by_label && params. size () > 3 && params[3 ].get_str () != " " ) {
1288+ if (!by_label && params[ 3 ]. isStr () && params[3 ].get_str () != " " ) {
12891289 if (!IsValidDestinationString (params[3 ].get_str ())) {
12901290 throw JSONRPCError (RPC_WALLET_ERROR, " address_filter parameter was invalid" );
12911291 }
@@ -1395,7 +1395,7 @@ static UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bo
13951395 if (fIsWatchonly )
13961396 obj.pushKV (" involvesWatchonly" , true );
13971397 obj.pushKV (" address" , EncodeDestination (address));
1398- obj.pushKV (" amount" , AmountMapToUniv (mapAmount, " " ));
1398+ obj.pushKV (" amount" , AmountMapToUniv (mapAmount, strasset ));
13991399 obj.pushKV (" confirmations" , (nConf == std::numeric_limits<int >::max () ? 0 : nConf));
14001400 obj.pushKV (" label" , label);
14011401 UniValue transactions (UniValue::VARR);
@@ -1894,13 +1894,14 @@ static UniValue gettransaction(const JSONRPCRequest& request)
18941894 return NullUniValue;
18951895 }
18961896
1897- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
1897+ if (request.fHelp || request.params .size () < 1 || request.params .size () > 3 )
18981898 throw std::runtime_error (
18991899 " gettransaction \" txid\" ( include_watchonly )\n "
19001900 " \n Get detailed information about in-wallet transaction <txid>\n "
19011901 " \n Arguments:\n "
19021902 " 1. \" txid\" (string, required) The transaction id\n "
19031903 " 2. \" include_watchonly\" (bool, optional, default=false) Whether to include watch-only addresses in balance calculation and details[]\n "
1904+ " 3. \" assetlabel\" (string, optional) Hex asset id or asset label for balance.\n "
19041905 " \n Result:\n "
19051906 " {\n "
19061907 " \" amount\" : x.xxx, (numeric) The transaction amount in " + CURRENCY_UNIT + " \n "
@@ -1952,6 +1953,11 @@ static UniValue gettransaction(const JSONRPCRequest& request)
19521953 if (request.params [1 ].get_bool ())
19531954 filter = filter | ISMINE_WATCH_ONLY;
19541955
1956+ std::string asset = " " ;
1957+ if (request.params [2 ].isStr () && !request.params [2 ].get_str ().empty ()) {
1958+ asset = request.params [2 ].get_str ();
1959+ }
1960+
19551961 UniValue entry (UniValue::VOBJ);
19561962 auto it = pwallet->mapWallet .find (hash);
19571963 if (it == pwallet->mapWallet .end ()) {
@@ -1973,7 +1979,7 @@ static UniValue gettransaction(const JSONRPCRequest& request)
19731979 nFee[::policyAsset] = wtx.IsFromMe (filter) ? total_out - nDebit[::policyAsset] : 0 ;
19741980 }
19751981
1976- entry.pushKV (" amount" , AmountMapToUniv (nNet - nFee, " " ));
1982+ entry.pushKV (" amount" , AmountMapToUniv (nNet - nFee, asset ));
19771983 if (wtx.IsFromMe (filter))
19781984 entry.pushKV (" fee" , AmountMapToUniv (nFee, " " ));
19791985
@@ -6251,12 +6257,12 @@ static const CRPCCommand commands[] =
62516257 { " wallet" , " encryptwallet" , &encryptwallet, {" passphrase" } },
62526258 { " wallet" , " getaddressesbylabel" , &getaddressesbylabel, {" label" } },
62536259 { " wallet" , " getaddressinfo" , &getaddressinfo, {" address" } },
6254- { " wallet" , " getbalance" , &getbalance, {" dummy" ," minconf" ," include_watchonly" } },
6260+ { " wallet" , " getbalance" , &getbalance, {" dummy" ," minconf" ," include_watchonly" , " assetlabel " } },
62556261 { " wallet" , " getnewaddress" , &getnewaddress, {" label" ," address_type" } },
62566262 { " wallet" , " getrawchangeaddress" , &getrawchangeaddress, {" address_type" } },
6257- { " wallet" , " getreceivedbyaddress" , &getreceivedbyaddress, {" address" ," minconf" } },
6258- { " wallet" , " getreceivedbylabel" , &getreceivedbylabel, {" label" ," minconf" } },
6259- { " wallet" , " gettransaction" , &gettransaction, {" txid" ," include_watchonly" } },
6263+ { " wallet" , " getreceivedbyaddress" , &getreceivedbyaddress, {" address" ," minconf" , " assetlabel " } },
6264+ { " wallet" , " getreceivedbylabel" , &getreceivedbylabel, {" label" ," minconf" , " assetlabel " } },
6265+ { " wallet" , " gettransaction" , &gettransaction, {" txid" ," include_watchonly" , " assetlabel " } },
62606266 { " wallet" , " getunconfirmedbalance" , &getunconfirmedbalance, {} },
62616267 { " wallet" , " getwalletinfo" , &getwalletinfo, {} },
62626268 { " wallet" , " importaddress" , &importaddress, {" address" ," label" ," rescan" ," p2sh" } },
@@ -6269,7 +6275,7 @@ static const CRPCCommand commands[] =
62696275 { " wallet" , " listaddressgroupings" , &listaddressgroupings, {} },
62706276 { " wallet" , " listlabels" , &listlabels, {" purpose" } },
62716277 { " wallet" , " listlockunspent" , &listlockunspent, {} },
6272- { " wallet" , " listreceivedbyaddress" , &listreceivedbyaddress, {" minconf" ," include_empty" ," include_watchonly" ," address_filter" } },
6278+ { " wallet" , " listreceivedbyaddress" , &listreceivedbyaddress, {" minconf" ," include_empty" ," include_watchonly" ," address_filter" , " assetlabel " } },
62736279 { " wallet" , " listreceivedbylabel" , &listreceivedbylabel, {" minconf" ," include_empty" ," include_watchonly" } },
62746280 { " wallet" , " listsinceblock" , &listsinceblock, {" blockhash" ," target_confirmations" ," include_watchonly" ," include_removed" } },
62756281 { " wallet" , " listtransactions" , &listtransactions, {" dummy" ," count" ," skip" ," include_watchonly" } },
0 commit comments