@@ -614,13 +614,11 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
614614 }
615615
616616 // 2. Handle Spark Address, check if Spark address
617- bool isSparkAddress = false ;
618617 try {
619618 const spark::Params* sparkParams = spark::Params::get_default ();
620619 spark::Address sparkAddress (sparkParams);
621620 unsigned char coinNetwork = sparkAddress.decode (strAddress);
622621 unsigned char network = spark::GetNetworkType ();
623- isSparkAddress = true ;
624622
625623 if (coinNetwork != network) {
626624 throw JSONRPCError (RPC_INVALID_PARAMETER, std::string (" Invalid address, wrong network type: " ) + strAddress);
@@ -716,7 +714,6 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
716714 std::string (" Failed to send to Spark address: " ) + e.what ());
717715 }
718716 } catch (const std::exception &e) {
719- isSparkAddress = false ;
720717 }
721718
722719 // 3. Handle Transparent Address
@@ -833,11 +830,9 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
833830 }
834831
835832 // 3. Handle Spark Address, check if Spark address
836- bool isSparkAddress = false ;
837833 try {
838834 spark::Address sparkAddress (sparkParams);
839835 unsigned char coinNetwork = sparkAddress.decode (resolvedAddress);
840- isSparkAddress = true ;
841836 if (coinNetwork != network) {
842837 throw JSONRPCError (RPC_INVALID_PARAMETER, std::string (" Invalid address, wrong network type: " ) + strAddress);
843838 }
@@ -852,7 +847,6 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
852847 totalSparkAmount += nAmount;
853848 continue ;
854849 } catch (const std::exception &) {
855- isSparkAddress = false ;
856850 }
857851
858852 // 4. Handle Transparent Address, check if transparent address
@@ -1777,9 +1771,6 @@ UniValue sendmany(const JSONRPCRequest& request)
17771771
17781772 std::string strAccount = AccountFromValue (request.params [0 ]);
17791773 UniValue sendTo = request.params [1 ].get_obj ();
1780- int nMinDepth = 1 ;
1781- if (request.params .size () > 2 )
1782- nMinDepth = request.params [2 ].get_int ();
17831774
17841775 CWalletTx wtx;
17851776 wtx.strFromAccount = strAccount;
@@ -4331,7 +4322,19 @@ UniValue spendspark(const JSONRPCRequest& request)
43314322 std::vector<CRecipient> recipients;
43324323 std::vector<std::pair<spark::OutputCoinData, bool >> privateRecipients;
43334324
4334- UniValue sendTo = request.params [0 ].get_obj ();
4325+ UniValue sendTo;
4326+ if (request.params [0 ].isStr ()) {
4327+ // Parse JSON string parameter
4328+ if (!sendTo.read (request.params [0 ].get_str ())) {
4329+ throw JSONRPCError (RPC_PARSE_ERROR, " Invalid JSON string" );
4330+ }
4331+ if (!sendTo.isObject ()) {
4332+ throw JSONRPCError (RPC_INVALID_PARAMETER, " JSON parameter must be an object" );
4333+ }
4334+ } else {
4335+ // Direct object parameter
4336+ sendTo = request.params [0 ].get_obj ();
4337+ }
43354338 std::vector<std::string> keys = sendTo.getKeys ();
43364339 const spark::Params* params = spark::Params::get_default ();
43374340 std::set<CBitcoinAddress> setAddress;
@@ -4462,9 +4465,9 @@ UniValue sendspark(const JSONRPCRequest& request)
44624465 return NullUniValue;
44634466 }
44644467
4465- if (request.fHelp || request.params .size () != 1 )
4468+ if (request.fHelp || request.params .size () < 1 || request. params . size () > 2 )
44664469 throw std::runtime_error (
4467- " sendspark {\" address\" :{amount,subtractfee...}, \" address\" :{amount,memo,subtractfee...}}\n "
4470+ " sendspark {\" address\" :{amount,subtractfee...}, \" address\" :{amount,memo,subtractfee...}} ( \" comment \" ) \n "
44684471 + HelpRequiringPassphrase (pwallet) + " \n "
44694472 " \n Arguments:\n "
44704473 " {\n "
@@ -4483,8 +4486,14 @@ UniValue sendspark(const JSONRPCRequest& request)
44834486 + HelpExampleRpc (" sendspark" , " \" {\" TR1FW48J6ozpRu25U8giSDdTrdXXUYau7U\" :{\" amount\" :0.01, \" subtractFee\" : false},\" TuzUyNtTznSNnT2rPXG6Mk7hHG8Svuuoci\" :{\" amount\" :0.01, \" subtractFee\" : true}, \" sr1hk87wuh660mss6vnxjf0syt4p6r6ptew97de3dvz698tl7p5p3w7h4m4hcw74mxnqhtz70r7gyydcx6pmkfmnew9q4z0c0muga3sd83h786znjx74ccsjwm284aswppqf2jd0sssendlj\" :{\" amount\" :0.01, \" memo\" :\"\" , \" subtractFee\" : false},\" sr1x7gcqdy670l2v4p9h2m4n5zgzde9y6ht86egffa0qrq40c6z329yfgvu8vyf99tgvnq4hwshvfxxhfzuyvz8dr3lt32j70x8l34japg73ca4w6z9x7c7ryd2gnafg9eg3gpr90gtunraw\" :{\" amount\" :0.01, \" memo\" :\" test_memo\" , \" subtractFee\" : false}}\" " )
44844487 );
44854488
4486- // Forward the call to spendspark implementation
4487- return spendspark (request);
4489+ // Create a new request and call spendspark
4490+ JSONRPCRequest newRequest;
4491+ newRequest.authUser = request.authUser ;
4492+ newRequest.strMethod = " spendspark" ;
4493+ newRequest.params = request.params ;
4494+ newRequest.fHelp = request.fHelp ;
4495+ newRequest.URI = request.URI ;
4496+ return spendspark (newRequest);
44884497}
44894498
44904499
0 commit comments