#include "asyncrpcoperation.h"
#include "asyncrpcqueue.h"
#include "wallet/asyncrpcoperation_sendmany.h"
+#include "wallet/asyncrpcoperation_shieldcoinbase.h"
#include "sodium.h"
"\nArguments:\n"
"1. \"account\" (string, optional) DEPRECATED. If provided, it MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"\nResult:\n"
- "\"zcashaddress\" (string) The new zcash address\n"
+ "\"zcashaddress\" (string) The new Zcash address\n"
"\nExamples:\n"
+ HelpExampleCli("getnewaddress", "")
+ HelpExampleRpc("getnewaddress", "")
"\nArguments:\n"
"1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"\nResult:\n"
- "\"zcashaddress\" (string) The account zcash address\n"
+ "\"zcashaddress\" (string) The account Zcash address\n"
"\nExamples:\n"
+ HelpExampleCli("getaccountaddress", "")
+ HelpExampleCli("getaccountaddress", "\"\"")
"setaccount \"zcashaddress\" \"account\"\n"
"\nDEPRECATED. Sets the account associated with the given address.\n"
"\nArguments:\n"
- "1. \"zcashaddress\" (string, required) The zcash address to be associated with an account.\n"
+ "1. \"zcashaddress\" (string, required) The Zcash address to be associated with an account.\n"
"2. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"\nExamples:\n"
+ HelpExampleCli("setaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"tabby\"")
"getaccount \"zcashaddress\"\n"
"\nDEPRECATED. Returns the account associated with the given address.\n"
"\nArguments:\n"
- "1. \"zcashaddress\" (string, required) The zcash address for account lookup.\n"
+ "1. \"zcashaddress\" (string, required) The Zcash address for account lookup.\n"
"\nResult:\n"
"\"accountname\" (string) the account address\n"
"\nExamples:\n"
"1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"\nResult:\n"
"[ (json array of string)\n"
- " \"zcashaddress\" (string) a zcash address associated with the given account\n"
+ " \"zcashaddress\" (string) a Zcash address associated with the given account\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpRequiringPassphrase() +
"\nArguments:\n"
"1. \"zcashaddress\" (string, required) The zcash address to send to.\n"
- "2. \"amount\" (numeric, required) The amount in btc to send. eg 0.1\n"
+ "2. \"amount\" (numeric, required) The amount in " + CURRENCY_UNIT + " to send. eg 0.1\n"
"3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n"
" This is not part of the transaction, just kept in your wallet.\n"
"4. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n"
" to which you're sending the transaction. This is not part of the \n"
" transaction, just kept in your wallet.\n"
"5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n"
- " The recipient will receive less zcash than you enter in the amount field.\n"
+ " The recipient will receive less Zcash than you enter in the amount field.\n"
"\nResult:\n"
"\"transactionid\" (string) The transaction id.\n"
"\nExamples:\n"
" [\n"
" [\n"
" \"zcashaddress\", (string) The zcash address\n"
- " amount, (numeric) The amount in btc\n"
+ " amount, (numeric) The amount in " + CURRENCY_UNIT + "\n"
" \"account\" (string, optional) The account (DEPRECATED)\n"
" ]\n"
" ,...\n"
"\nSign a message with the private key of an address"
+ HelpRequiringPassphrase() + "\n"
"\nArguments:\n"
- "1. \"zcashaddress\" (string, required) The zcash address to use for the private key.\n"
+ "1. \"zcashaddress\" (string, required) The Zcash address to use for the private key.\n"
"2. \"message\" (string, required) The message to create a signature of.\n"
"\nResult:\n"
"\"signature\" (string) The signature of the message encoded in base 64\n"
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getreceivedbyaddress \"zcashaddress\" ( minconf )\n"
- "\nReturns the total amount received by the given zcashaddress in transactions with at least minconf confirmations.\n"
+ "\nReturns the total amount received by the given Zcash address in transactions with at least minconf confirmations.\n"
"\nArguments:\n"
- "1. \"zcashaddress\" (string, required) The zcash address for transactions.\n"
+ "1. \"zcashaddress\" (string, required) The Zcash address for transactions.\n"
"2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n"
"\nResult:\n"
- "amount (numeric) The total amount in btc received at this address.\n"
+ "amount (numeric) The total amount in " + CURRENCY_UNIT + " received at this address.\n"
"\nExamples:\n"
"\nThe amount from transactions with at least 1 confirmation\n"
+ HelpExampleCli("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\"") +
"1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n"
"\nResult:\n"
- "amount (numeric) The total amount in btc received for this account.\n"
+ "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n"
"\nExamples:\n"
"\nAmount received by the default account with at least 1 confirmation\n"
+ HelpExampleCli("getreceivedbyaccount", "\"\"") +
"2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n"
"3. includeWatchonly (bool, optional, default=false) Also include balance in watchonly addresses (see 'importaddress')\n"
"\nResult:\n"
- "amount (numeric) The total amount in btc received for this account.\n"
+ "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n"
"\nExamples:\n"
"\nThe total amount in the wallet\n"
+ HelpExampleCli("getbalance", "") +
"\nArguments:\n"
"1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"2. \"toaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
- "3. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n"
- "4. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n"
+ "3. amount (numeric) Quantity of " + CURRENCY_UNIT + " to move between accounts.\n"
+ "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n"
+ "5. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n"
"\nResult:\n"
"true|false (boolean) true if successful.\n"
"\nExamples:\n"
- "\nMove 0.01 btc from the default account to the account named tabby\n"
+ "\nMove 0.01 " + CURRENCY_UNIT + " from the default account to the account named tabby\n"
+ HelpExampleCli("move", "\"\" \"tabby\" 0.01") +
- "\nMove 0.01 btc timotei to akiko with a comment and funds have 6 confirmations\n"
+ "\nMove 0.01 " + CURRENCY_UNIT + " timotei to akiko with a comment and funds have 6 confirmations\n"
+ HelpExampleCli("move", "\"timotei\" \"akiko\" 0.01 6 \"happy birthday!\"") +
"\nAs a json rpc call\n"
+ HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"")
if (fHelp || params.size() < 3 || params.size() > 6)
throw runtime_error(
"sendfrom \"fromaccount\" \"tozcashaddress\" amount ( minconf \"comment\" \"comment-to\" )\n"
- "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a zcash address.\n"
+ "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a Zcash address.\n"
"The amount is a real and is rounded to the nearest 0.00000001."
+ HelpRequiringPassphrase() + "\n"
"\nArguments:\n"
"1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"2. \"tozcashaddress\" (string, required) The zcash address to send funds to.\n"
- "3. amount (numeric, required) The amount in btc. (transaction fee is added on top).\n"
+ "3. amount (numeric, required) The amount in " + CURRENCY_UNIT + " (transaction fee is added on top).\n"
"4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n"
"5. \"comment\" (string, optional) A comment used to store what the transaction is for. \n"
" This is not part of the transaction, just kept in your wallet.\n"
"\nResult:\n"
"\"transactionid\" (string) The transaction id.\n"
"\nExamples:\n"
- "\nSend 0.01 btc from the default account to the address, must have at least 1 confirmation\n"
+ "\nSend 0.01 " + CURRENCY_UNIT + " from the default account to the address, must have at least 1 confirmation\n"
+ HelpExampleCli("sendfrom", "\"\" \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01") +
"\nSend 0.01 from the tabby account to the given address, funds must have at least 6 confirmations\n"
+ HelpExampleCli("sendfrom", "\"tabby\" \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01 6 \"donation\" \"seans outpost\"") +
"1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"2. \"amounts\" (string, required) A json object with addresses and amounts\n"
" {\n"
- " \"address\":amount (numeric) The zcash address is the key, the numeric amount in btc is the value\n"
+ " \"address\":amount (numeric) The zcash address is the key, the numeric amount in " + CURRENCY_UNIT + " is the value\n"
" ,...\n"
" }\n"
"3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.\n"
"4. \"comment\" (string, optional) A comment\n"
"5. subtractfeefromamount (string, optional) A json array with addresses.\n"
" The fee will be equally deducted from the amount of each selected address.\n"
- " Those recipients will receive less zcashs than you enter in their corresponding amount field.\n"
+ " Those recipients will receive less Zcash than you enter in their corresponding amount field.\n"
" If no addresses are specified here, the sender pays the fee.\n"
" [\n"
" \"address\" (string) Subtract fee from this address\n"
"\nArguments:\n"
"1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n"
- "2. \"keysobject\" (string, required) A json array of zcash addresses or hex-encoded public keys\n"
+ "2. \"keysobject\" (string, required) A json array of Zcash addresses or hex-encoded public keys\n"
" [\n"
- " \"address\" (string) zcash address or hex-encoded public key\n"
+ " \"address\" (string) Zcash address or hex-encoded public key\n"
" ...,\n"
" ]\n"
"3. \"account\" (string, optional) DEPRECATED. If provided, MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n"
"\nResult:\n"
- "\"zcashaddress\" (string) A zcash address associated with the keys.\n"
+ "\"zcashaddress\" (string) A Zcash address associated with the keys.\n"
"\nExamples:\n"
"\nAdd a multisig address from 2 addresses\n"
" \"involvesWatchonly\" : true, (bool) Only returned if imported addresses were involved in transaction\n"
" \"address\" : \"receivingaddress\", (string) The receiving address\n"
" \"account\" : \"accountname\", (string) DEPRECATED. The account of the receiving address. The default account is \"\".\n"
- " \"amount\" : x.xxx, (numeric) The total amount in btc received by the address\n"
+ " \"amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " received by the address\n"
" \"confirmations\" : n (numeric) The number of confirmations of the most recent transaction included\n"
" }\n"
" ,...\n"
" {\n"
" \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. \n"
" It will be \"\" for the default account.\n"
- " \"address\":\"zcashaddress\", (string) The zcash address of the transaction. Not present for \n"
+ " \"address\":\"zcashaddress\", (string) The Zcash address of the transaction. Not present for \n"
" move transactions (category = move).\n"
" \"category\":\"send|receive|move\", (string) The transaction category. 'move' is a local (off blockchain)\n"
" transaction between accounts, and not associated with an address,\n"
" transaction id or block. 'send' and 'receive' transactions are \n"
" associated with an address, transaction id and block details\n"
- " \"amount\": x.xxx, (numeric) The amount in btc. This is negative for the 'send' category, and for the\n"
+ " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the\n"
" 'move' category for moves outbound. It is positive for the 'receive' category,\n"
" and for the 'move' category for inbound funds.\n"
" \"vout\" : n, (numeric) the vout value\n"
- " \"fee\": x.xxx, (numeric) The amount of the fee in btc. This is negative and only available for the \n"
+ " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n"
" 'send' category of transactions.\n"
" \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and \n"
" 'receive' category of transactions.\n"
"{\n"
" \"transactions\": [\n"
" \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. Will be \"\" for the default account.\n"
- " \"address\":\"zcashaddress\", (string) The zcash address of the transaction. Not present for move transactions (category = move).\n"
+ " \"address\":\"zcashaddress\", (string) The Zcash address of the transaction. Not present for move transactions (category = move).\n"
" \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n"
- " \"amount\": x.xxx, (numeric) The amount in btc. This is negative for the 'send' category, and for the 'move' category for moves \n"
+ " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the 'move' category for moves \n"
" outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n"
" \"vout\" : n, (numeric) the vout value\n"
- " \"fee\": x.xxx, (numeric) The amount of the fee in btc. This is negative and only available for the 'send' category of transactions.\n"
+ " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions.\n"
" \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n"
" \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n"
" \"blockindex\": n, (numeric) The block index containing the transaction. Available for 'send' and 'receive' category of transactions.\n"
"2. \"includeWatchonly\" (bool, optional, default=false) Whether to include watchonly addresses in balance calculation and details[]\n"
"\nResult:\n"
"{\n"
- " \"amount\" : x.xxx, (numeric) The transaction amount in btc\n"
+ " \"amount\" : x.xxx, (numeric) The transaction amount in " + CURRENCY_UNIT + "\n"
" \"confirmations\" : n, (numeric) The number of confirmations\n"
" \"blockhash\" : \"hash\", (string) The block hash\n"
" \"blockindex\" : xx, (numeric) The block index\n"
" \"details\" : [\n"
" {\n"
" \"account\" : \"accountname\", (string) DEPRECATED. The account name involved in the transaction, can be \"\" for the default account.\n"
- " \"address\" : \"zcashaddress\", (string) The zcash address involved in the transaction\n"
+ " \"address\" : \"zcashaddress\", (string) The Zcash address involved in the transaction\n"
" \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n"
- " \"amount\" : x.xxx (numeric) The amount in btc\n"
+ " \"amount\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n"
" \"vout\" : n, (numeric) the vout value\n"
" }\n"
" ,...\n"
throw runtime_error(
"walletpassphrase \"passphrase\" timeout\n"
"\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
- "This is needed prior to performing transactions related to private keys such as sending zcash\n"
+ "This is needed prior to performing transactions related to private keys such as sending Zcash\n"
"\nArguments:\n"
"1. \"passphrase\" (string, required) The wallet passphrase\n"
"2. timeout (numeric, required) The time to keep the decryption key in seconds.\n"
"\nExamples:\n"
"\nEncrypt you wallet\n"
+ HelpExampleCli("encryptwallet", "\"my pass phrase\"") +
- "\nNow set the passphrase to use the wallet, such as for signing or sending zcash\n"
+ "\nNow set the passphrase to use the wallet, such as for signing or sending Zcash\n"
+ HelpExampleCli("walletpassphrase", "\"my pass phrase\"") +
"\nNow we can so something like sign\n"
+ HelpExampleCli("signmessage", "\"zcashaddress\" \"test message\"") +
"lockunspent unlock [{\"txid\":\"txid\",\"vout\":n},...]\n"
"\nUpdates list of temporarily unspendable outputs.\n"
"Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n"
- "A locked transaction output will not be chosen by automatic coin selection, when spending zcash.\n"
+ "A locked transaction output will not be chosen by automatic coin selection, when spending Zcash.\n"
"Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n"
"is always cleared (by virtue of process exit) when a node stops or fails.\n"
"Also see the listunspent call\n"
"settxfee amount\n"
"\nSet the transaction fee per kB.\n"
"\nArguments:\n"
- "1. amount (numeric, required) The transaction fee in BTC/kB rounded to the nearest 0.00000001\n"
+ "1. amount (numeric, required) The transaction fee in " + CURRENCY_UNIT + "/kB rounded to the nearest 0.00000001\n"
"\nResult\n"
"true|false (boolean) Returns true if successful\n"
"\nExamples:\n"
"\nResult:\n"
"{\n"
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
- " \"balance\": xxxxxxx, (numeric) the total confirmed zcash balance of the wallet\n"
- " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed zcash balance of the wallet\n"
- " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet\n"
+ " \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
+ " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
+ " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + CURRENCY_UNIT + "\n"
" \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
- " \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in ZEC/KB\n"
+ " \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getwalletinfo", "")
"\nArguments:\n"
"1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n"
"2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n"
- "3. \"addresses\" (string) A json array of zcash addresses to filter\n"
+ "3. \"addresses\" (string) A json array of Zcash addresses to filter\n"
" [\n"
- " \"address\" (string) zcash address\n"
+ " \"address\" (string) Zcash address\n"
" ,...\n"
" ]\n"
"\nResult\n"
" {\n"
" \"txid\" : \"txid\", (string) the transaction id \n"
" \"vout\" : n, (numeric) the vout value\n"
+ " \"generated\" : true|false (boolean) true if txout is a coinbase transaction output\n"
" \"address\" : \"address\", (string) the zcash address\n"
" \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
" \"scriptPubKey\" : \"key\", (string) the script key\n"
- " \"amount\" : x.xxx, (numeric) the transaction amount in btc\n"
+ " \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n"
" \"confirmations\" : n (numeric) The number of confirmations\n"
" }\n"
" ,...\n"
UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
entry.push_back(Pair("vout", out.i));
+ entry.push_back(Pair("generated", out.tx->IsCoinBase()));
CTxDestination address;
if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
std::vector<double> sample_times;
- if (benchmarktype == "createjoinsplit") {
- /* Load the proving now key so that it doesn't happen as part of the
- * first joinsplit. */
- pzcashParams->loadProvingKey();
- }
-
JSDescription samplejoinsplit;
if (benchmarktype == "verifyjoinsplit") {
throw JSONRPCError(RPC_TYPE_ERROR, "Benchmark must be run in regtest mode");
}
sample_times.push_back(benchmark_connectblock_slow());
+ } else if (benchmarktype == "sendtoaddress") {
+ if (Params().NetworkIDString() != "regtest") {
+ throw JSONRPCError(RPC_TYPE_ERROR, "Benchmark must be run in regtest mode");
+ }
+ auto amount = AmountFromValue(params[2]);
+ sample_times.push_back(benchmark_sendtoaddress(amount));
+ } else if (benchmarktype == "loadwallet") {
+ if (Params().NetworkIDString() != "regtest") {
+ throw JSONRPCError(RPC_TYPE_ERROR, "Benchmark must be run in regtest mode");
+ }
+ sample_times.push_back(benchmark_loadwallet());
+ } else if (benchmarktype == "listunspent") {
+ sample_times.push_back(benchmark_listunspent());
} else {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid benchmarktype");
}
}
}
- ZCNoteDecryption decryptor(k.viewing_key());
+ ZCNoteDecryption decryptor(k.receiving_key());
NotePlaintext npt = NotePlaintext::decrypt(
decryptor,
auto k = SpendingKey::random();
auto addr = k.address();
- auto viewing_key = k.viewing_key();
+ auto receiving_key = k.receiving_key();
- CDataStream viewing(SER_NETWORK, PROTOCOL_VERSION);
+ CDataStream receiving(SER_NETWORK, PROTOCOL_VERSION);
- viewing << viewing_key;
+ receiving << receiving_key;
CZCPaymentAddress pubaddr(addr);
CZCSpendingKey spendingkey(k);
- std::string viewing_hex = HexStr(viewing.begin(), viewing.end());
+ std::string receiving_hex = HexStr(receiving.begin(), receiving.end());
UniValue result(UniValue::VOBJ);
result.push_back(Pair("zcaddress", pubaddr.ToString()));
result.push_back(Pair("zcsecretkey", spendingkey.ToString()));
- result.push_back(Pair("zcviewingkey", viewing_hex));
+ result.push_back(Pair("zcviewingkey", receiving_hex));
return result;
}
"1. \"address\" (string) The selected address. It may be a transparent or private address.\n"
"2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n"
"\nResult:\n"
- "amount (numeric) The total amount in ZEC received for this address.\n"
+ "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this address.\n"
"\nExamples:\n"
"\nThe total amount received by address \"myaddress\"\n"
+ HelpExampleCli("z_getbalance", "\"myaddress\"") +
"2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n"
" [{\n"
" \"address\":address (string, required) The address is a taddr or zaddr\n"
- " \"amount\":amount (numeric, required) The numeric amount in ZEC is the value\n"
+ " \"amount\":amount (numeric, required) The numeric amount in " + CURRENCY_UNIT + " is the value\n"
" \"memo\":memo (string, optional) If the address is a zaddr, raw data represented in hexadecimal string format\n"
" }, ... ]\n"
"3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n"
}
+/**
+When estimating the number of coinbase utxos we can shield in a single transaction:
+1. Joinsplit description is 1802 bytes.
+2. Transaction overhead ~ 100 bytes
+3. Spending a typical P2PKH is >=148 bytes, as defined in CTXIN_SPEND_DUST_SIZE.
+4. Spending a multi-sig P2SH address can vary greatly:
+ https://github.com/bitcoin/bitcoin/blob/c3ad56f4e0b587d8d763af03d743fdfc2d180c9b/src/main.cpp#L517
+ In real-world coinbase utxos, we consider a 3-of-3 multisig, where the size is roughly:
+ (3*(33+1))+3 = 105 byte redeem script
+ 105 + 1 + 3*(73+1) = 328 bytes of scriptSig, rounded up to 400 based on testnet experiments.
+*/
+#define CTXIN_SPEND_P2SH_SIZE 400
+
+#define SHIELD_COINBASE_DEFAULT_LIMIT 50
+
+UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
+{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return NullUniValue;
+
+ if (fHelp || params.size() < 2 || params.size() > 4)
+ throw runtime_error(
+ "z_shieldcoinbase \"fromaddress\" \"tozaddress\" ( fee ) ( limit )\n"
+ "\nShield transparent coinbase funds by sending to a shielded zaddr. This is an asynchronous operation and utxos"
+ "\nselected for shielding will be locked. If there is an error, they are unlocked. The RPC call `listlockunspent`"
+ "\ncan be used to return a list of locked utxos. The number of coinbase utxos selected for shielding can be limited"
+ "\nby the caller. If the limit parameter is set to zero, the -mempooltxinputlimit option will determine the number"
+ "\nof uxtos. Any limit is constrained by the consensus rule defining a maximum transaction size of "
+ + strprintf("%d bytes.", MAX_TX_SIZE)
+ + HelpRequiringPassphrase() + "\n"
+ "\nArguments:\n"
+ "1. \"fromaddress\" (string, required) The address is a taddr or \"*\" for all taddrs belonging to the wallet.\n"
+ "2. \"toaddress\" (string, required) The address is a zaddr.\n"
+ "3. fee (numeric, optional, default="
+ + strprintf("%s", FormatMoney(SHIELD_COINBASE_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n"
+ "4. limit (numeric, optional, default="
+ + strprintf("%d", SHIELD_COINBASE_DEFAULT_LIMIT) + ") Limit on the maximum number of utxos to shield. Set to 0 to use node option -mempooltxinputlimit.\n"
+ "\nResult:\n"
+ "{\n"
+ " \"operationid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n"
+ " \"shieldedUTXOs\": xxx (numeric) Number of coinbase utxos being shielded.\n"
+ " \"shieldedValue\": xxx (numeric) Value of coinbase utxos being shielded.\n"
+ " \"remainingUTXOs\": xxx (numeric) Number of coinbase utxos still available for shielding.\n"
+ " \"remainingValue\": xxx (numeric) Value of coinbase utxos still available for shielding.\n"
+ "}\n"
+ );
+
+ LOCK2(cs_main, pwalletMain->cs_wallet);
+
+ // Validate the from address
+ auto fromaddress = params[0].get_str();
+ bool isFromWildcard = fromaddress == "*";
+ CBitcoinAddress taddr;
+ if (!isFromWildcard) {
+ taddr = CBitcoinAddress(fromaddress);
+ if (!taddr.IsValid()) {
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or \"*\".");
+ }
+ }
+
+ // Validate the destination address
+ auto destaddress = params[1].get_str();
+ try {
+ CZCPaymentAddress pa(destaddress);
+ libzcash::PaymentAddress zaddr = pa.Get();
+ } catch (const std::runtime_error&) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ") + destaddress );
+ }
+
+ // Convert fee from currency format to zatoshis
+ CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE;
+ if (params.size() > 2) {
+ if (params[2].get_real() == 0.0) {
+ nFee = 0;
+ } else {
+ nFee = AmountFromValue( params[2] );
+ }
+ }
+
+ int nLimit = SHIELD_COINBASE_DEFAULT_LIMIT;
+ if (params.size() > 3) {
+ nLimit = params[3].get_int();
+ if (nLimit < 0) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Limit on maximum number of utxos cannot be negative");
+ }
+ }
+
+ // Prepare to get coinbase utxos
+ std::vector<ShieldCoinbaseUTXO> inputs;
+ CAmount shieldedValue = 0;
+ CAmount remainingValue = 0;
+ size_t estimatedTxSize = 2000; // 1802 joinsplit description + tx overhead + wiggle room
+ size_t utxoCounter = 0;
+ bool maxedOutFlag = false;
+ size_t mempoolLimit = (nLimit != 0) ? nLimit : (size_t)GetArg("-mempooltxinputlimit", 0);
+
+ // Set of addresses to filter utxos by
+ set<CBitcoinAddress> setAddress = {};
+ if (!isFromWildcard) {
+ setAddress.insert(taddr);
+ }
+
+ // Get available utxos
+ vector<COutput> vecOutputs;
+ pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, true);
+
+ // Find unspent coinbase utxos and update estimated size
+ BOOST_FOREACH(const COutput& out, vecOutputs) {
+ if (!out.fSpendable) {
+ continue;
+ }
+
+ CTxDestination address;
+ if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
+ continue;
+ }
+ // If taddr is not wildcard "*", filter utxos
+ if (setAddress.size()>0 && !setAddress.count(address)) {
+ continue;
+ }
+
+ if (!out.tx->IsCoinBase()) {
+ continue;
+ }
+
+ utxoCounter++;
+ CAmount nValue = out.tx->vout[out.i].nValue;
+
+ if (!maxedOutFlag) {
+ CBitcoinAddress ba(address);
+ size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
+ if (estimatedTxSize + increase >= MAX_TX_SIZE ||
+ (mempoolLimit > 0 && utxoCounter > mempoolLimit))
+ {
+ maxedOutFlag = true;
+ } else {
+ estimatedTxSize += increase;
+ ShieldCoinbaseUTXO utxo = {out.tx->GetHash(), out.i, nValue};
+ inputs.push_back(utxo);
+ shieldedValue += nValue;
+ }
+ }
+
+ if (maxedOutFlag) {
+ remainingValue += nValue;
+ }
+ }
+
+ size_t numUtxos = inputs.size();
+
+ if (numUtxos == 0) {
+ throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any coinbase funds to shield.");
+ }
+
+ if (shieldedValue < nFee) {
+ throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS,
+ strprintf("Insufficient coinbase funds, have %s, which is less than miners fee %s",
+ FormatMoney(shieldedValue), FormatMoney(nFee)));
+ }
+
+ // Check that the user specified fee is sane (if too high, it can result in error -25 absurd fee)
+ CAmount netAmount = shieldedValue - nFee;
+ if (nFee > netAmount) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Fee %s is greater than the net amount to be shielded %s", FormatMoney(nFee), FormatMoney(netAmount)));
+ }
+
+ // Keep record of parameters in context object
+ UniValue contextInfo(UniValue::VOBJ);
+ contextInfo.push_back(Pair("fromaddress", params[0]));
+ contextInfo.push_back(Pair("toaddress", params[1]));
+ contextInfo.push_back(Pair("fee", ValueFromAmount(nFee)));
+
+ // Create operation and add to global queue
+ std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
+ std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_shieldcoinbase(inputs, destaddress, nFee, contextInfo) );
+ q->addOperation(operation);
+ AsyncRPCOperationId operationId = operation->getId();
+
+ // Return continuation information
+ UniValue o(UniValue::VOBJ);
+ o.push_back(Pair("remainingUTXOs", utxoCounter - numUtxos));
+ o.push_back(Pair("remainingValue", ValueFromAmount(remainingValue)));
+ o.push_back(Pair("shieldingUTXOs", numUtxos));
+ o.push_back(Pair("shieldingValue", ValueFromAmount(shieldedValue)));
+ o.push_back(Pair("opid", operationId));
+ return o;
+}
+
+
UniValue z_listoperationids(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))