#compdef zcash-cli
# ------------------------------------------------------------------------------
# Copyright (c) 2017 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the zsh-users nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
#  Completion script for zcash-cli v6.10.0 (https://z.cash).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
#  * Jordy van Wolferen (https://github.com/jvwdev)
#
# ------------------------------------------------------------------------------

_zcash_cli_commands() {
  local -a commands=(
    'addmultisigaddress:Add a nrequired-to-sign transparent multisignature address to the wallet'
    'addnode:Attempts to add or remove a node from the addnode list'
    'backupwallet:Safely copies current wallet file to destination filename'
    'clearbanned:Clear all banned IPs'
    'createmultisig:Creates a multi-signature address with n signature of m keys required'
    'decoderawtransaction:Return a JSON object representing the serialized, hex-encoded transaction'
    'decodescript:Decode a hex-encoded script'
    'disconnectnode:Immediately disconnects from the specified node'
    'dumpprivkey:Reveals the private key corresponding to "t-addr"'
    'encryptwallet:Encrypts the wallet with "passphrase"'
    'generate:Mine blocks immediately'
    'getaddednodeinfo:Returns information about the given added node, or all added nodes'
    'getaddressbalance:Returns the balance for addresses'
    'getaddressdeltas:Returns all changes for an address'
    'getaddressmempool:Returns all mempool deltas for an address'
    'getaddresstxids:Returns the txids for given transparent addresses within the given'
    'getaddressutxos:Returns all unspent outputs for an address'
    "getbalance:Returns the wallet's available transparent balance"
    'getbestblockhash:Returns the hash of the best (tip) block in the longest block chain'
    'getblock:return data for the block'
    'getblockchaininfo:Returns an object containing various state info regarding block chain processing'
    'getblockcount:Returns the height of the most recent block in the best valid block chain'
    'getblockdeltas:Returns information about the given block and its transactions'
    'getblockhash:Returns hash of block in best-block-chain at index provided'
    'getblockhashes:Returns array of hashes of blocks within the timestamp range provided'
    'getblockheader:return block header'
    'getblocksubsidy:Returns block subsidy reward'
    'getblocktemplate:get block template'
    'getchaintips:Return information about all known tips in the block tree'
    'getconnectioncount:Returns the number of connections to other nodes'
    'getdeprecationinfo:Returns an object containing current version and deprecation block height'
    'getdifficulty:Returns the proof-of-work difficulty as a multiple of the minimum difficulty'
    'getexperimentalfeatures:Returns enabled experimental features'
    'getgenerate:Return if the server is set to generate coins or not'
    'getinfo:Returns an object containing various state info'
    'getlocalsolps:Returns the average local solutions per second since this node was started'
    'getmemoryinfo:Returns an object containing information about memory usage'
    'getmempoolinfo:Returns details on the active state of the TX memory pool'
    'getmininginfo:Returns a json object containing mining-related information'
    'getnettotals:Returns information about network traffic'
    'getnetworkinfo:Returns an object containing various state info regarding P2P networking'
    'getnetworksolps:Returns the estimated network solutions per second based on the last n blocks'
    'getnewaddress:Returns a new transparent Zcash address'
    'getpeerinfo:Returns data about each connected network node as a json array of objects'
    'getrawchangeaddress:Returns a new transparent Zcash address for receiving change'
    'getrawmempool:Returns all transaction ids in memory pool as a json array of string transaction ids'
    'getrawtransaction:Return the raw transaction data'
    'getreceivedbyaddress:Returns the total amount received by the given transparent Zcash address'
    'getspentinfo:Returns the txid and index where an output is spent'
    'gettransaction:Returns detailed information about in-wallet transaction'
    'gettxout:Returns details about an unspent transaction output'
    'gettxoutproof:Returns a hex-encoded proof that "txid" was included in a block'
    'gettxoutsetinfo:Returns statistics about the unspent transaction output set'
    "getunconfirmedbalance:Returns the server's total unconfirmed transparent balance"
    'getwalletinfo:Returns wallet state information'
    'help:List all commands, or get help for a specified command'
    'importaddress:import address'
    'importprivkey:Adds a private key to your wallet'
    'importpubkey:Adds a public key'
    'importwallet:Imports taddr keys from a wallet dump file'
    'listaddresses:Lists the addresses managed by this wallet by source'
    'listaddressgroupings:Lists groups of transparent addresses'
    'listbanned:List all banned IPs/Subnets'
    'listlockunspent:Returns list of temporarily unspendable transparent outputs'
    'listreceivedbyaddress:List balances by transparent receiving address'
    'listsinceblock:Get all transactions in blocks'
    "listtransactions:Returns up to 'count' of the most recent transactions"
    'listunspent:Returns array of unspent transparent transaction outputs'
    'lockunspent:Updates list of temporarily unspendable outputs'
    'ping:Requests that a ping be sent to all other nodes, to measure ping time'
    'prioritisetransaction:Accepts the transaction into mined blocks at a higher/lower priority'
    'sendmany:Send to multiple transparent recipient'
    'sendrawtransaction:Submits raw transaction to local node and network'
    'sendtoaddress:Send an amount to a given transparent address'
    'setban:Attempts to add or remove an IP/Subnet from the banned list'
    'setgenerate:Set "generate" true or false to turn generation on or off'
    'setlogfilter:Sets the filter to be used for selecting events to log'
    'signmessage:Sign a message with the private key of a t-addr'
    'stop:Stop Zcash server'
    'submitblock:Attempts to submit new block to network'
    'validateaddress:Return information about the given Zcash address'
    'verifychain:Verifies blockchain database'
    'verifymessage:Verify a signed message'
    'verifytxoutproof:Verifies that a proof points to a transaction in a block'
    'walletconfirmbackup:Notify the wallet that the user has backed up the emergency recovery phrase'
    'z_converttex:Converts a transparent Zcash address to a TEX address'
    'z_exportkey:Reveals the zkey corresponding to "zaddr"'
    'z_exportviewingkey:Returns the full viewing key corresponding to "zaddr"'
    'z_exportwallet:Exports all wallet keys, for taddr and zaddr, in a human-readable format'
    'z_getaddressforaccount:get address for account'
    "z_getbalance:Returns the balance of a taddr or zaddr belonging to the node's wallet"
    "z_getbalanceforaccount:Returns the account's spendable balance for each value pool"
    'z_getbalanceforviewingkey:Returns the balance viewable by a full viewing key'
    'z_getmigrationstatus:Returns information about the status of the Sprout to Sapling migration'
    'z_getnewaccount:Prepares and returns a new account'
    'z_getnewaddress:Returns a new shielded address for receiving payments'
    'z_getnotescount:Returns the number of notes available in the wallet for each shielded value pool'
    'z_getoperationresult:Retrieve the result and status of an operation which has finished'
    'z_getoperationstatus:Get operation status and any associated result or error data'
    'z_getpaymentdisclosure:Generate a payment disclosure for a given joinsplit output'
    "z_getsubtreesbyindex:Returns roots of subtrees of the given pool's note commitment tree"
    "z_gettreestate:Return information about the given block's tree state"
    'z_importkey:Adds a zkey (as returned by z_exportkey) to your wallet'
    'z_importviewingkey:Adds a viewing key to your wallet'
    'z_importwallet:Imports taddr and zaddr keys from a wallet export file'
    'z_listaccounts:Returns the list of accounts created with z_getnewaccount'
    'z_listaddresses:Returns the list of shielded addresses belonging to the wallet'
    'z_listoperationids:Returns the list of operation ids currently known to the wallet'
    "z_listreceivedbyaddress:Return a list of amounts received by a zaddr belonging to the node's wallet"
    'z_listunifiedreceivers:Returns a record of the individual receivers contained within the provided UA'
    'z_listunspent:Returns an array of unspent shielded notes'
    'z_mergetoaddress:Merge multiple UTXOs and notes into a single UTXO or note'
    'z_sendmany:Send a transaction with multiple recipients'
    "z_setmigration:attempt to migrate all funds from this wallet's Sprout addresses"
    'z_shieldcoinbase:Shield transparent coinbase funds by sending to a shielded zaddr'
    'z_validateaddress:Return information about the given address'
    'z_validatepaymentdisclosure:Validates a payment disclosure'
    'z_viewtransaction:Get detailed shielded information about in-wallet transaction'
    'zcbenchmark:Runs a benchmark of the selected benchmark type samplecount times'
    'zcsamplejoinsplit:Perform a joinsplit and return the JSDescription'
  )

  _describe -t commands 'command' commands "$@"
}

_arguments \
  '(- *)-?[display usage information]' \
  '(- *)-version[display version and exit]' \
  '-conf=[specify configuration file]:file [zcash.conf]:_files' \
  '-datadir=[specify data directory]:directory:_files -/' \
  '-testnet[use the test network]' \
  '-regtest[enter regression test mode]' \
  '-rpcconnect=[send commands to node running on specified ip]:rpcconnect [127.0.0.1]:_hosts' \
  '-rpcport=[connect to JSON-RPC on specified port]: :_guard "[[\:digit\:]]#" "port [8232 or testnet\: 18232]"' \
  '-rpcwait[wait for RPC server to start]' \
  '-rpcuser=[username for JSON-RPC connections]:rpcuser' \
  '-rpcpassword=[password for JSON-RPC connections]:rpcpassword' \
  '-rpcclienttimeout=[specify timeout during HTTP requests, or 0 for no timeout]: :_guard "[[\:digit\:]]#" "timeout (seconds) [900]"' \
  '1: :_zcash_cli_commands' \
  '*:: :_files'

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et
