Auto merge of #2525 - bitcartel:2519_no_zero_minconf_from_zaddr_zsendmany, r=daira
When sending from a zaddr, minconf cannot be zero. Closes #2519.
This commit is contained in:
commit
95d18784ec
|
@ -71,7 +71,7 @@ z_importwallet | filename | _Requires an unlocked wallet or an unencrypted walle
|
||||||
Command | Parameters | Description
|
Command | Parameters | Description
|
||||||
--- | --- | ---
|
--- | --- | ---
|
||||||
z_listreceivedbyaddress<br> | zaddr [minconf=1] | Return a list of amounts received by a zaddr belonging to the node’s wallet.<br><br>Optionally set the minimum number of confirmations which a received amount must have in order to be included in the result. Use 0 to count unconfirmed transactions.<br><br>Output:<br>[{<br>“txid”: “4a0f…”,<br>“amount”: 0.54,<br>“memo”:”F0FF…”,}, {...}, {...}<br>]
|
z_listreceivedbyaddress<br> | zaddr [minconf=1] | Return a list of amounts received by a zaddr belonging to the node’s wallet.<br><br>Optionally set the minimum number of confirmations which a received amount must have in order to be included in the result. Use 0 to count unconfirmed transactions.<br><br>Output:<br>[{<br>“txid”: “4a0f…”,<br>“amount”: 0.54,<br>“memo”:”F0FF…”,}, {...}, {...}<br>]
|
||||||
z_sendmany<br> | fromaddress amounts [minconf=1] [fee=0.0001] | _This is an Asynchronous RPC call_<br><br>Send funds from an address to multiple outputs. The address can be either a taddr or a zaddr.<br><br>Amounts is a list containing key/value pairs corresponding to the addresses and amount to pay. Each output address can be in taddr or zaddr format.<br><br>When sending to a zaddr, you also have the option of attaching a memo in hexadecimal format.<br><br>**NOTE:**When sending coinbase funds to a zaddr, the node's wallet does not allow any change. Put another way, spending a partial amount of a coinbase utxo is not allowed. This is not a consensus rule but a local wallet rule due to the current implementation of z_sendmany. In future, this rule may be removed.<br><br>Example of Outputs parameter:<br>[{“address”:”t123…”, “amount”:0.005},<br>,{“address”:”z010…”,”amount”:0.03, “memo”:”f508af…”}]<br><br>Optionally set the minimum number of confirmations which a private or transparent transaction must have in order to be used as an input.<br><br>Optionally set a transaction fee, which by default is 0.0001 ZEC.<br><br>Any transparent change will be sent to a new transparent address. Any private change will be sent back to the zaddr being used as the source of funds.<br><br>Returns an operationid. You use the operationid value with z_getoperationstatus and z_getoperationresult to obtain the result of sending funds, which if successful, will be a txid.
|
z_sendmany<br> | fromaddress amounts [minconf=1] [fee=0.0001] | _This is an Asynchronous RPC call_<br><br>Send funds from an address to multiple outputs. The address can be either a taddr or a zaddr.<br><br>Amounts is a list containing key/value pairs corresponding to the addresses and amount to pay. Each output address can be in taddr or zaddr format.<br><br>When sending to a zaddr, you also have the option of attaching a memo in hexadecimal format.<br><br>**NOTE:**When sending coinbase funds to a zaddr, the node's wallet does not allow any change. Put another way, spending a partial amount of a coinbase utxo is not allowed. This is not a consensus rule but a local wallet rule due to the current implementation of z_sendmany. In future, this rule may be removed.<br><br>Example of Outputs parameter:<br>[{“address”:”t123…”, “amount”:0.005},<br>,{“address”:”z010…”,”amount”:0.03, “memo”:”f508af…”}]<br><br>Optionally set the minimum number of confirmations which a private or transparent transaction must have in order to be used as an input. When sending from a zaddr, minconf must be greater than zero.<br><br>Optionally set a transaction fee, which by default is 0.0001 ZEC.<br><br>Any transparent change will be sent to a new transparent address. Any private change will be sent back to the zaddr being used as the source of funds.<br><br>Returns an operationid. You use the operationid value with z_getoperationstatus and z_getoperationresult to obtain the result of sending funds, which if successful, will be a txid.
|
||||||
|
|
||||||
### Operations
|
### Operations
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ Zcash error codes are defined in https://github.com/zcash/zcash/blob/master/src/
|
||||||
|
|
||||||
RPC_INVALID_PARAMETER (-8) | _Invalid, missing or duplicate parameter_
|
RPC_INVALID_PARAMETER (-8) | _Invalid, missing or duplicate parameter_
|
||||||
---------------------------| -------------------------------------------------
|
---------------------------| -------------------------------------------------
|
||||||
|
"Minconf cannot be zero when sending from zaddr" | Cannot accept minimum confirmation value of zero when sending from zaddr.
|
||||||
"Minconf cannot be negative" | Cannot accept negative minimum confirmation number.
|
"Minconf cannot be negative" | Cannot accept negative minimum confirmation number.
|
||||||
"Minimum number of confirmations cannot be less than 0" | Cannot accept negative minimum confirmation number.
|
"Minimum number of confirmations cannot be less than 0" | Cannot accept negative minimum confirmation number.
|
||||||
"From address parameter missing" | Missing an address to send funds from.
|
"From address parameter missing" | Missing an address to send funds from.
|
||||||
|
|
|
@ -976,6 +976,18 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
||||||
BOOST_CHECK( msg.find("Insufficient funds, no UTXOs found") != string::npos);
|
BOOST_CHECK( msg.find("Insufficient funds, no UTXOs found") != string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// minconf cannot be zero when sending from zaddr
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
std::vector<SendManyRecipient> recipients = {SendManyRecipient(taddr1, 100.0, "DEADBEEF")};
|
||||||
|
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(zaddr1, recipients, {}, 0));
|
||||||
|
BOOST_CHECK(false); // Fail test if an exception is not thrown
|
||||||
|
} catch (const UniValue& objError) {
|
||||||
|
BOOST_CHECK(find_error(objError, "Minconf cannot be zero when sending from zaddr"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// there are no unspent notes to spend
|
// there are no unspent notes to spend
|
||||||
{
|
{
|
||||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient(taddr1,100.0, "DEADBEEF") };
|
std::vector<SendManyRecipient> recipients = { SendManyRecipient(taddr1,100.0, "DEADBEEF") };
|
||||||
|
|
|
@ -93,6 +93,10 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isfromzaddr_ && minDepth==0) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Minconf cannot be zero when sending from zaddr");
|
||||||
|
}
|
||||||
|
|
||||||
// Log the context info i.e. the call parameters to z_sendmany
|
// Log the context info i.e. the call parameters to z_sendmany
|
||||||
if (LogAcceptCategory("zrpcunsafe")) {
|
if (LogAcceptCategory("zrpcunsafe")) {
|
||||||
LogPrint("zrpcunsafe", "%s: z_sendmany initialized (params=%s)\n", getId(), contextInfo.write());
|
LogPrint("zrpcunsafe", "%s: z_sendmany initialized (params=%s)\n", getId(), contextInfo.write());
|
||||||
|
|
Loading…
Reference in New Issue