@@ -1424,7 +1424,7 @@ UniValue viewshieldedtransaction(const JSONRPCRequest& request)
14241424#define CTXIN_SPEND_DUST_SIZE 148
14251425#define CTXOUT_REGULAR_SIZE 34
14261426
1427- static UniValue CreateShieldedTransaction (const JSONRPCRequest& request)
1427+ static SaplingOperation CreateShieldedTransaction (const JSONRPCRequest& request)
14281428{
14291429 EnsureWalletIsUnlocked ();
14301430 LOCK2 (cs_main, pwalletMain->cs_wallet );
@@ -1610,23 +1610,22 @@ static UniValue CreateShieldedTransaction(const JSONRPCRequest& request)
16101610 throw JSONRPCError (RPC_INVALID_PARAMETER, " Minconf cannot be negative" );
16111611 }
16121612
1613- // Process the send operation
1614- std::string txHash;
1613+ // Build the send operation
16151614 OperationResult res = operation.setFee (nFee)
16161615 ->setMinDepth (nMinDepth)
16171616 ->setShieldedRecipients (shieldAddrRecipients)
16181617 ->setTransparentRecipients (taddrRecipients)
1619- ->buildAndSend (txHash );
1618+ ->build ( );
16201619 if (!res) throw JSONRPCError (RPC_WALLET_ERROR, res.getError ());
1621- return txHash ;
1620+ return operation ;
16221621}
16231622
16241623UniValue shielded_sendmany (const JSONRPCRequest& request)
16251624{
16261625 if (request.fHelp || request.params .size () < 2 || request.params .size () > 4 )
16271626 throw std::runtime_error (
16281627 " shielded_sendmany \" fromaddress\" [{\" address\" :... ,\" amount\" :...},...] ( minconf ) ( fee )\n "
1629- " \n Send multiple times . Amounts are decimal numbers with at most 8 digits of precision."
1628+ " \n Send to many recipients . Amounts are decimal numbers with at most 8 digits of precision."
16301629 " \n Change generated from a transparent addr flows to a new transparent addr address, while change generated from a shielded addr returns to itself."
16311630 " \n When sending coinbase UTXOs to a shielded addr, change is not allowed. The entire value of the UTXO(s) must be consumed."
16321631 + HelpRequiringPassphrase () + " \n "
@@ -1652,7 +1651,50 @@ UniValue shielded_sendmany(const JSONRPCRequest& request)
16521651 " \" DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" , [{\" address\" : \" ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\" amount\" : 5.0}]" )
16531652 );
16541653
1655- return CreateShieldedTransaction (request);
1654+ SaplingOperation operation = CreateShieldedTransaction (request);
1655+ std::string txHash;
1656+ auto res = operation.send (txHash);
1657+ if (!res)
1658+ throw JSONRPCError (RPC_WALLET_ERROR, res.getError ());
1659+ return txHash;
1660+ }
1661+
1662+ UniValue raw_shielded_sendmany (const JSONRPCRequest& request)
1663+ {
1664+ if (request.fHelp || request.params .size () < 2 || request.params .size () > 4 )
1665+ throw std::runtime_error (
1666+ " raw_shielded_sendmany \" fromaddress\" [{\" address\" :... ,\" amount\" :...},...] ( minconf ) ( fee )\n "
1667+ " \n Creates a transaction sending to many recipients (without committing it), and returns the hex string."
1668+ " \n Amounts are decimal numbers with at most 8 digits of precision."
1669+ " \n Change generated from a transparent addr flows to a new transparent addr address, while change generated from a shielded addr returns to itself."
1670+ " \n When sending coinbase UTXOs to a shielded addr, change is not allowed. The entire value of the UTXO(s) must be consumed."
1671+ + HelpRequiringPassphrase () + " \n "
1672+ " \n Arguments:\n "
1673+ " 1. \" fromaddress\" (string, required) The transparent addr or shielded addr to send the funds from.\n "
1674+ " It can also be the string \" from_transparent\" |\" from_shielded\" to send the funds\n "
1675+ " from any transparent|shielded address available.\n "
1676+ " 2. \" amounts\" (array, required) An array of json objects representing the amounts to send.\n "
1677+ " [{\n "
1678+ " \" address\" :address (string, required) The address is a transparent addr or shielded addr\n "
1679+ " \" amount\" :amount (numeric, required) The numeric amount in " + " PIV" + " is the value\n "
1680+ " \" memo\" :memo (string, optional) If the address is a shielded addr, raw data represented in hexadecimal string format\n "
1681+ " }, ... ]\n "
1682+ " 3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n "
1683+ " 4. fee (numeric, optional, default=" + strprintf (" %s" , FormatMoney (DEFAULT_SAPLING_FEE)) +
1684+ " ) The fee amount to attach to this transaction.\n "
1685+ " \n Result:\n "
1686+ " {tx_json} (json object) decoded transaction\n "
1687+ " \n Examples:\n "
1688+ + HelpExampleCli (" raw_shielded_sendmany" ,
1689+ " \" DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" '[{\" address\" : \" ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\" amount\" : 5.0}]'" )
1690+ + HelpExampleRpc (" raw_shielded_sendmany" ,
1691+ " \" DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" , [{\" address\" : \" ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\" amount\" : 5.0}]" )
1692+ );
1693+
1694+ CTransaction tx = CreateShieldedTransaction (request).getFinalTx ();
1695+ UniValue tx_json (UniValue::VOBJ);
1696+ TxToUniv (tx, UINT256_ZERO, tx_json);
1697+ return tx_json;
16561698}
16571699
16581700UniValue listaddressgroupings (const JSONRPCRequest& request)
@@ -4009,6 +4051,7 @@ static const CRPCCommand commands[] =
40094051 { " wallet" , " exportsaplingviewingkey" , &exportsaplingviewingkey, true },
40104052 { " wallet" , " getshieldedbalance" , &getshieldedbalance, false },
40114053 { " wallet" , " listshieldedunspent" , &listshieldedunspent, false },
4054+ { " wallet" , " raw_shielded_sendmany" , &raw_shielded_sendmany, false },
40124055 { " wallet" , " shielded_sendmany" , &shielded_sendmany, false },
40134056 { " wallet" , " listreceivedbyshieldedaddress" , &listreceivedbyshieldedaddress, false },
40144057 { " wallet" , " viewshieldedtransaction" , &viewshieldedtransaction, false },
0 commit comments