Skip to content

Commit 952555f

Browse files
committed
[Refactor] Introduce CreateShieldedTransaction auxiliary fun for RPC
1 parent 3bf6248 commit 952555f

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,33 +1424,8 @@ UniValue viewshieldedtransaction(const JSONRPCRequest& request)
14241424
#define CTXIN_SPEND_DUST_SIZE 148
14251425
#define CTXOUT_REGULAR_SIZE 34
14261426

1427-
UniValue shielded_sendmany(const JSONRPCRequest& request) {
1428-
if (request.fHelp || request.params.size() < 2 || request.params.size() > 4)
1429-
throw std::runtime_error(
1430-
"shielded_sendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf ) ( fee )\n"
1431-
"\nSend multiple times. Amounts are decimal numbers with at most 8 digits of precision."
1432-
"\nChange generated from a transparent addr flows to a new transparent addr address, while change generated from a shielded addr returns to itself."
1433-
"\nWhen sending coinbase UTXOs to a shielded addr, change is not allowed. The entire value of the UTXO(s) must be consumed."
1434-
+ HelpRequiringPassphrase() + "\n"
1435-
"\nArguments:\n"
1436-
"1. \"fromaddress\" (string, required) The transparent addr or shielded addr to send the funds from.\n"
1437-
"2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n"
1438-
" [{\n"
1439-
" \"address\":address (string, required) The address is a transparent addr or shielded addr\n"
1440-
" \"amount\":amount (numeric, required) The numeric amount in " + "PIV" + " is the value\n"
1441-
" \"memo\":memo (string, optional) If the address is a shielded addr, raw data represented in hexadecimal string format\n"
1442-
" }, ... ]\n"
1443-
"3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n"
1444-
"4. fee (numeric, optional, default=" + strprintf("%s", FormatMoney(COIN)) +
1445-
") The fee amount to attach to this transaction.\n"
1446-
"\nResult:\n"
1447-
"\"id\" (string) transaction hash in the network\n"
1448-
"\nExamples:\n"
1449-
+ HelpExampleCli("shielded_sendmany",
1450-
"\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" '[{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]'")
1451-
+ HelpExampleRpc("shielded_sendmany",
1452-
"\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\", [{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]")
1453-
);
1427+
static UniValue CreateShieldedTransaction(const JSONRPCRequest& request)
1428+
{
14541429
EnsureWalletIsUnlocked();
14551430

14561431
// Check that the from address is valid.
@@ -1641,6 +1616,38 @@ UniValue shielded_sendmany(const JSONRPCRequest& request) {
16411616
return txHash;
16421617
}
16431618

1619+
UniValue shielded_sendmany(const JSONRPCRequest& request)
1620+
{
1621+
if (request.fHelp || request.params.size() < 2 || request.params.size() > 4)
1622+
throw std::runtime_error(
1623+
"shielded_sendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf ) ( fee )\n"
1624+
"\nSend multiple times. Amounts are decimal numbers with at most 8 digits of precision."
1625+
"\nChange generated from a transparent addr flows to a new transparent addr address, while change generated from a shielded addr returns to itself."
1626+
"\nWhen sending coinbase UTXOs to a shielded addr, change is not allowed. The entire value of the UTXO(s) must be consumed."
1627+
+ HelpRequiringPassphrase() + "\n"
1628+
"\nArguments:\n"
1629+
"1. \"fromaddress\" (string, required) The transparent addr or shielded addr to send the funds from.\n"
1630+
"2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n"
1631+
" [{\n"
1632+
" \"address\":address (string, required) The address is a transparent addr or shielded addr\n"
1633+
" \"amount\":amount (numeric, required) The numeric amount in " + "PIV" + " is the value\n"
1634+
" \"memo\":memo (string, optional) If the address is a shielded addr, raw data represented in hexadecimal string format\n"
1635+
" }, ... ]\n"
1636+
"3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n"
1637+
"4. fee (numeric, optional, default=" + strprintf("%s", FormatMoney(COIN)) +
1638+
") The fee amount to attach to this transaction.\n"
1639+
"\nResult:\n"
1640+
"\"id\" (string) transaction hash in the network\n"
1641+
"\nExamples:\n"
1642+
+ HelpExampleCli("shielded_sendmany",
1643+
"\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" '[{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]'")
1644+
+ HelpExampleRpc("shielded_sendmany",
1645+
"\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\", [{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]")
1646+
);
1647+
1648+
return CreateShieldedTransaction(request);
1649+
}
1650+
16441651
UniValue listaddressgroupings(const JSONRPCRequest& request)
16451652
{
16461653
if (request.fHelp)

0 commit comments

Comments
 (0)