==1. Overview==

dcrd provides a [https://jsonrpc.org/specification JSON-RPC] API that is
fully compatible with the original bitcoind/bitcoin-qt.  There are a few key
differences between dcrd and bitcoind as far as how RPCs are serviced:

* Unlike bitcoind that has the wallet and chain intermingled in the same process which leads to several issues, dcrd intentionally splits the wallet and chain services into independent processes.  See the blog post [https://blog.conformal.com/btcd-not-your-moms-bitcoin-daemon/ here] for further details on why they were separated.  This means that if you are talking directly to dcrd, only chain-related RPCs are available.  However both chain-related and wallet-related RPCs are available via [https://github.com/decred/dcrwallet dcrwallet].

* dcrd is secure by default which means that the RPC connection is TLS-enabled by default

* dcrd provides access to the API through both [https://en.wikipedia.org/wiki/POST_%28HTTP%29 HTTP POST] requests and [https://en.wikipedia.org/wiki/WebSocket Websockets]

Websockets are the preferred transport for dcrd RPC and are used by applications
such as [https://github.com/decred/dcrwallet dcrwallet] for inter-process
communication with dcrd.  The websocket connection endpoint for dcrd is
<code>wss://your_ip_or_domain:9109/ws</code>.

All requests are limited to a maximum size of 8 MiB when accessed via HTTP POST
and 16 MiB when accessed via Websockets.

In addition to the [[#5-standard-methods|standard API]], an [[#6-websocket-methods-websocket-specific|extension API]]
has been developed that is exclusive to clients using Websockets. In its current
state, this API attempts to cover features found missing in the standard API
during the development of dcrwallet.

While the [[#5-standard-methods|standard API]] is stable, the
[[#6-websocket-methods-websocket-specific|Websocket extension API]] should be considered a work in
progress, incomplete, and susceptible to changes (both additions and removals).

==2. HTTP POST Versus Websockets==

The dcrd RPC server supports both [https://en.wikipedia.org/wiki/POST_%28HTTP%29 HTTP POST]
requests and the preferred [https://en.wikipedia.org/wiki/WebSocket Websockets].
All of the standard and extension methods described in
this documentation can be accessed through both. As the name
indicates, the [[#6-websocket-methods-websocket-specific|Websocket-specific extension]] methods can only be
accessed when connected via Websockets.

As mentioned in the [[#1-overview|overview]], the websocket connection endpoint for
dcrd is <code>wss://your_ip_or_domain:9109/ws</code>.

The most important differences between the two transports as it pertains to the
JSON-RPC API are:

{|
!&nbsp;
!HTTP POST Requests
!Websockets
|-
|Allows multiple requests across a single connection
|Yes
|Yes
|-
|Supports asynchronous notifications
|No
|Yes
|-
|Scales well with large numbers of requests
|No
|Yes
|}

==3. Authentication==

===3.1 Authentication Overview===

The following authentication details are needed before establishing a connection
to a dcrd RPC server:

* '''rpcuser''' is the full-access username configured for the dcrd RPC server
* '''rpcpass''' is the full-access password configured for the dcrd RPC server
* '''rpclimituser''' is the limited username configured for the dcrd RPC server
* '''rpclimitpass''' is the limited password configured for the dcrd RPC server
* '''rpccert''' is the PEM-encoded X.509 certificate (public key) that the dcrd server is configured with.  It is automatically generated by dcrd and placed in the dcrd home directory (which is typically <code>%LOCALAPPDATA%\Dcrd</code> on Windows and <code>~/.dcrd</code> on POSIX-like OSes)

'''NOTE:''' As mentioned above, dcrd is secure by default which means the RPC
server is not running unless configured with a '''rpcuser''' and '''rpcpass'''
and/or a '''rpclimituser''' and '''rpclimitpass''', and uses TLS authentication for
all connections.

Depending on which connection type you are using, you can choose one of
two, mutually exclusive, methods.
* [[#32-http-basic-access-authentication|Use HTTP Authorization Header]] - HTTP POST requests and Websockets
* [[#33-json-rpc-authenticate-command-websocket-specific|Use the JSON-RPC "authenticate" command]] - Websockets only

===3.2 HTTP Basic Access Authentication===

The dcrd RPC server uses HTTP [https://en.wikipedia.org/wiki/Basic_access_authentication basic access authentication] with the '''rpcuser'''
and '''rpcpass''' detailed above.  If the supplied credentials are invalid, you
will be disconnected immediately upon making the connection.

===3.3 JSON-RPC Authenticate Command (Websocket-specific)===

While the HTTP basic access authentication method is the preferred method, the
ability to set HTTP headers from websockets is not always available.  In that
case, you will need to use the [[#authenticate|authenticate]] JSON-RPC method.

The [[#authenticate|authenticate]] command must be the first command sent after
connecting to the websocket.  Sending any other commands before authenticating,
supplying invalid credentials, or attempting to authenticate again when already
authenticated will cause the websocket to be closed immediately.

==4. Command-line Utility==

dcrd is built to work with [https://github.com/decred/dcrctl <code>dcrctl</code>]
which can be used to issue these RPC commands via HTTP POST requests to dcrd
after configuring it with the information in the [[#3-authentication|Authentication]]
section above.  It can also be used to communicate with any server/daemon/service
which provides a JSON-RPC API compatible with the original dcrd client.

==5. Standard Methods==

===5.1 Method Overview===

The following is an overview of the RPC methods and their current status.  Click
the method name for further details such as parameter and return information.

{|
!Method
!Safe for limited user?
!Description
|-
|[[#addnode|addnode]]
|N
|Attempts to add or remove a persistent peer.
|-
|[[#createrawsstx|createrawsstx]]
|Y
|Returns a new unsigned ticket spending the provided inputs.
|-
|[[#createrawssrtx|createrawssrtx]]
|Y
|Returns a new unsigned revocation spending the provided inputs.
|-
|[[#createrawtransaction|createrawtransaction]]
|Y
|Returns a new transaction spending the provided inputs and sending to the provided addresses.
|-
|[[#debuglevel|debuglevel]]
|N
|Dynamically changes the debug logging level.
|-
|[[#decoderawtransaction|decoderawtransaction]]
|Y
|Returns a JSON object representing the provided serialized, hex-encoded transaction.
|-
|[[#decodescript|decodescript]]
|Y
|Returns a JSON object with information about the provided hex-encoded script.
|-
|[[#estimatefee|estimatefee]]
|Y
|Returns the estimated fee in dcr/kb.
|-
|[[#estimatesmartfee|estimatesmartfee]]
|Y
|Returns the estimated fee using the historical fee data in dcr/kb and the block number where the estimate was found.
|-
|[[#estimatestakediff|estimatestakediff]]
|Y
|Returns the estimated next minimum, maximum, expected, and user-specified stake difficulty.
|-
|[[#existsaddress|existsaddress]]
|Y
|Returns the existence of the provided address.
|-
|[[#existsaddresses|existsaddresses]]
|Y
|Returns the existence of the provided addresses.
|-
|[[#existsliveticket|existsliveticket]]
|Y
|Returns the existence of the provided ticket.
|-
|[[#existslivetickets|existslivetickets]]
|Y
|Returns the existence of the provided tickets in the live ticket map.
|-
|[[#existsmempooltxs|existsmempooltxs]]
|Y
|Returns the existence of the provided txs in the mempool.
|-
|[[#generate|generate]]
|N
|When in simnet or regtest mode, generate a set number of blocks.
|-
|[[#getaddednodeinfo|getaddednodeinfo]]
|N
|Returns information about manually added (persistent) peers.
|-
|[[#getbestblock|getbestblock]]
|Y
|Get block height and hash of best block in the main chain.
|-
|[[#getbestblockhash|getbestblockhash]]
|Y
|Returns the hash of the of the best (most recent) block in the longest block chain.
|-
|[[#getblock|getblock]]
|Y
|Returns information about a block given its hash.
|-
|[[#getblockchaininfo|getblockchaininfo]]
|Y
|Returns information about the current state of the block chain.
|-
|[[#getblockcount|getblockcount]]
|Y
|Returns the number of blocks in the longest block chain.
|-
|[[#getblockhash|getblockhash]]
|Y
|Returns hash of the block in best block chain at the given height.
|-
|[[#getblockheader|getblockheader]]
|N
|Returns the block header of the block.
|-
|[[#getblocksubsidy|getblocksubsidy]]
|Y
|Returns information regarding subsidy amounts.
|-
|[[#getcfilterv2|getcfilterv2]]
|Y
|Returns the version 2 block filter for the given block along with a proof that can be used to prove the filter is committed to by the block header.
|-
|[[#getchaintips|getchaintips]]
|Y
|Returns information about all known chain tips the in the block tree.
|-
|[[#getcoinsupply|getcoinsupply]]
|Y
|Returns current total coin supply in atoms.
|-
|[[#getconnectioncount|getconnectioncount]]
|N
|Returns the number of active connections to other peers.
|-
|[[#getcurrentnet|getcurrentnet]]
|Y
|Get Decred network dcrd is running on.
|-
|[[#getdifficulty|getdifficulty]]
|Y
|Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
|-
|[[#getgenerate|getgenerate]]
|N
|Return if the server is set to generate coins (mine) or not.
|-
|[[#gethashespersec|gethashespersec]]
|N
|Returns a recent hashes per second performance measurement while generating coins (mining).
|-
|[[#getheaders|getheaders]]
|Y
|Returns block headers starting with the first known block hash from the request.
|-
|[[#getinfo|getinfo]]
|Y
|Returns a JSON object containing various state info.
|-
|[[#getmempoolinfo|getmempoolinfo]]
|N
|Returns a JSON object containing mempool-related information.
|-
|[[#getmininginfo|getmininginfo]]
|N
|Returns a JSON object containing mining-related information.
|-
|[[#getnettotals|getnettotals]]
|Y
|Returns a JSON object containing network traffic statistics.
|-
|[[#getnetworkhashps|getnetworkhashps]]
|Y
|Returns the estimated network hashes per second for the block heights provided by the parameters.
|-
|[[#getnetworkinfo|getnetworkinfo]]
|Y
|Returns a JSON object containing network-related information.
|-
|[[#getpeerinfo|getpeerinfo]]
|N
|Returns information about each connected network peer as an array of json objects.
|-
|[[#getrawmempool|getrawmempool]]
|Y
|Returns an array of hashes for all of the transactions currently in the memory pool.
|-
|[[#getrawtransaction|getrawtransaction]]
|Y
|Returns information about a transaction given its hash.
|-
|[[#getstakedifficulty|getstakedifficulty]]
|Y
|Returns the proof-of-stake difficulty.
|-
|[[#getstakeversioninfo|getstakeversioninfo]]
|Y
|Returns stake version statistics for one or more stake version intervals.
|-
|[[#getstakeversions|getstakeversions]]
|Y
|Get stake versions per block.
|-
|[[#getticketpoolvalue|getticketpoolvalue]]
|N
|Returns the current value of all locked funds in the ticket pool.
|-
|[[#gettreasurybalance|gettreasurybalance]]
|Y
|Returns the mature balance of the treasury account.
|-
|[[#gettreasuryspendvotes|gettreasuryspendvotes]]
|N
|Returns the vote counts for mempool or mined treasury spend transactions.
|-
|[[#gettxout|gettxout]]
|Y
|Returns information about an unspent transaction output.
|-
|[[#gettxoutsetinfo|gettxoutsetinfo]]
|N
|Returns statistics on current unspent transaction output set.
|-
|[[#getvoteinfo|getvoteinfo]]
|Y
|Returns the vote info statistics.
|-
|[[#getwork|getwork]]
|N
|Returns formatted hash data to work on or checks and submits solved data. NOTE: Since dcrd does not have the wallet integrated to provide payment addresses, dcrd must be configured via the <code>--miningaddr</code> option to provide which payment addresses to pay created blocks to for this RPC to function.
|-
|[[#help|help]]
|Y
|Returns a list of all commands or help for a specified command.
|-
|[[#invalidateblock|invalidateblock]]
|N
|Permanently invalidates a block as if it had violated consensus rules.
|-
|[[#livetickets|livetickets]]
|Y
|Returns live ticket hashes from the ticket database.
|-
|[[#node|node]]
|N
|Attempts to add or remove a peer.
|-
|[[#ping|ping]]
|N
|Queues a ping to be sent to each connected peer.
|-
|[[#reconsiderblock|reconsiderblock]]
|N
|Reconsiders a block for validation and best chain selection by removing any invalid status from it and its ancestors.  Any descendants that are neither themselves marked as having failed validation, nor descendants of another such block, are also made eligibile for best chain selection.
|-
|[[#regentemplate|regentemplate]]
|Y
|Asks the daemon to regenerate the mining block template.
|-
|[[#sendrawtransaction|sendrawtransaction]]
|Y
|Submits the serialized, hex-encoded transaction to the local peer and relays it to the network.
|-
|[[#setgenerate|setgenerate]]
|N
|Set the server to generate coins (mine) or not. NOTE: Since dcrd does not have the wallet integrated to provide payment addresses, dcrd must be configured via the <code>--miningaddr</code> option to provide which payment addresses to pay created blocks to for this RPC to function.
|-
|[[#stop|stop]]
|N
|Shutdown dcrd.
|-
|[[#submitblock|submitblock]]
|Y
|Attempts to submit a new serialized, hex-encoded block to the network.
|-
|[[#ticketfeeinfo|ticketfeeinfo]]
|Y
|Get various information about ticket fees from the mempool, blocks, and difficulty windows (units: DCR/kB).
|-
|[[#ticketsforaddress|ticketsforaddress]]
|Y
|Request all the tickets for an address.
|-
|[[#ticketvwap|ticketvwap]]
|Y
|Calculate the volume weighted average price of tickets for a range of blocks (default: full PoS difficulty adjustment depth).
|-
|[[#txfeeinfo|txfeeinfo]]
|Y
|Get various information about regular transaction fees from the mempool, blocks, and difficulty windows.
|-
|[[#validateaddress|validateaddress]]
|Y
|Verifies the given address is valid.  NOTE: Since dcrd does not have a wallet integrated, dcrd will only return whether the address is valid or not.
|-
|[[#verifychain|verifychain]]
|N
|Verifies the block chain database.
|-
|[[#verifymessage|verifymessage]]
|Y
|Verifies a signed message.
|-
|[[#version|version]]
|Y
|Returns the JSON-RPC API version (semver).
|}

===5.2 Method Details===

====addnode====
{|
!Method
|addnode
|-
!Parameters
|
# <code>addr</code>: <code>(string, required)</code> IP address and port of the peer to operate on.
# <code>subcmd</code>: <code>(string, required)</code> - <code>add</code> to add a persistent peer, <code>remove</code> to remove a persistent peer, or <code>onetry</code> to try a single connection to a peer.
|-
!Description
|Attempts to add or remove a persistent peer.
|-
!Returns
|Nothing
|}

----

====createrawsstx====
{|
!Method
|createrawsstx
|-
!Parameters
|
# <code>inputs</code>: <code>(json array, required)</code> The inputs to the transaction of type.
#: <code>txid</code>: <code>(string)</code> Unspent tx output hash.
#: <code>vout</code>: <code><numeric></code> Index of the output being redeemed.
#: <code>amt</code>: <code><numeric></code> Amount of utxo in atoms.
#: <code>tree</code>: <code><numeric></code> Which tree utxo is located.
# <code>amount</code>: <code>(json object, required)</code> json object with the destination address as key and amount as value in atoms.
#: <code>{"address":"amount"}</code>
# <code>couts</code>: <code>(json array, required)</code> Array of sstx commit outs to use.
#: <code>addr</code>: <code>(string)</code> Address to send sstx commit.
#: <code>commitamt</code>: <code>(string)</code> Amount to commit in atoms.
#: <code>changeamt</code>: <code>(string)</code> Amount for change in atoms.
#: <code>changeaddr</code>: <code>(string)</code> Address for change.
|-
!Description
|Returns a new unsigned ticket spending the provided inputs.
|-
!Returns
|<code>(string)</code> Hex-encoded bytes of the serialized transaction.
|}

----

====createrawssrtx====
{|
!Method
|createrawssrtx
|-
!Parameters
|
# <code>inputs</code>: <code>(json array, required)</code> The input to the transaction.
#: <code>amount</code>: <code>(numeric)</code> Amount of the uxto in coins.
#: <code>txid</code>: <code>(string)</code> Unspent ticket output hash.
#: <code>vout</code>: <code>(numeric)</code> Index of the ticket output being redeemed.
#: <code>tree</code>: <code>(numeric)</code>  Which tree utxo is located.
# <code>fee</code>: <code>(numeric)</code> The fee to apply to the revocation in coins.
|-
!Description
|Returns a new unsigned revocation spending the provided inputs.
|-
!Returns
|<code>(string)</code> Hex-encoded bytes of the serialized transaction.
|}

----

====createrawtransaction====
{|
!Method
|createrawtransaction
|-
!Parameters
|
# <code>transaction inputs</code>: <code>(JSON array, required)</code> json array of json objects.
#: <code>amount</code>: <code>(numeric)</code> the previous output amount in coins.
#: <code>hash</code>: <code>(string, required)</code> the hash of the input.
#: <code>vout</code>: <code>(numeric, required)</code> the specific output of the input transaction to redeem transaction.
#: <code>[{"amount": n.nnn, "txid": "hash", "vout": n}, ...]</code>
# <code>addresses and amounts</code>: <code>(JSON object, required)</code> - json object with addresses as keys and output amounts as values in coins.
#: <code>address</code>: <code>(string, required)</code> the address to send the specified output amount to.
#: <code>{"address": n.nnn, ...}</code>
|-
!Description
|
: Returns a new transaction spending the provided inputs and sending to the provided addresses. The transaction inputs are not signed in the created transaction.
: The <code>signrawtransaction</code> RPC command provided by wallet must be used to sign the resulting transaction.
|-
!Returns
|<code>transaction</code>: (string) - hex-encoded bytes of the serialized transaction.
|-
!Example Parameters
|
# transaction inputs <code>[{"amount":0.49213337, "txid":"e6da89de7a6b8508ce8f371a3d0535b04b5e108cb1a6e9284602d3bfd357c018", "vout":1}]</code>
# addresses and amounts <code>{"13cgrTP7wgbZYWrY9BZ22BV6p82QXQT3nY": 0.49213337}</code>
|-
!Example Return
|
: Newlines added for display purposes. The actual return does not contain newlines.
: <code>010000000118c057d3bfd3024628e9a6b18c105e4bb035053d1a378fce08856b7ade89dae6010000</code>
: <code>0000ffffffff0199efee02000000001976a9141cb013db35ecccc156fdfd81d03a11c51998f99388</code>
: <code>ac00000000</code>
|}

----

====debuglevel====
{|
!Method
|debuglevel
|-
!Parameters
|
# <code>levelspec</code>: <code>(string, required)</code> the debug level specification.
|-
!Description
|
: Dynamically changes the debug logging level.
: The levelspec can either be a debug level or of the form <code><subsystem>=<level>,<subsystem2>=<level2>,...</code>
: The valid debug levels are <code>trace</code>, <code>debug</code>, <code>info</code>, <code>warn</code>, <code>error</code>, and <code>critical</code>.
: The valid subsystems are <code>AMGR</code>, <code>ADXR</code>, <code>BCDB</code>, <code>DCRD</code>, <code>CHAN</code>, <code>DISC</code>, <code>PEER</code>, <code>RPCS</code>, <code>SCRP</code>, <code>SRVR</code>, <code>SYNC</code>, and <code>TXMP</code>.
: Additionally, the special keyword <code>show</code> can be used to get a list of the available subsystems.
|-
!Returns
|<code>string</code>
|-
!Example Return
|<code>Done.</code>
|-
!Example <code>show</code> Return
|<code>Supported subsystems [AMGR ADXR BCDB DCRD CHAN DISC PEER RPCS SCRP SRVR SYNC TXMP]</code>
|}

----

====decoderawtransaction====
{|
!Method
|decoderawtransaction
|-
!Parameters
|# <code>data</code>: <code>(string, required)</code> serialized, hex-encoded transaction.
|-
!Description
|Returns a JSON object representing the provided serialized, hex-encoded transaction.
|-
!Returns
|
<code>(json object)</code>
: <code>txid</code>: <code>(string)</code> the transaction id.
: <code>hash</code>: <code>(string)</code> the hash of the transaction.
: <code>version</code>: <code>(numeric)</code> the block version.
: <code>locktime</code>: <code>(numeric)</code> the transaction lock time.
: <code>expiry</code>: <code>(numeric)</code> the transaction expiry.
: <code>vin</code>: <code>(array of json objects)</code> the transaction inputs as json objects.
: <code>vout</code>: <code>(array of json objects)</code> the transaction outputs as json objects.

<code>{"txid": "hash", "version": n, "locktime": n, "expiry": n, "vin": [...], "vout": [...]}</code>

; vin (for coinbase transactions)
: <code>(json object)</code>
:: <code>coinbase</code>: (string) the hex-encoded bytes of the signature script.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"coinbase": "data", "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for vote transactions)
: <code>(json object)</code>
:: <code>stakebase</code>: (string) the hex-encoded bytes of the signature script.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"stakebase": "data", "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for treasurybase transactions)
: <code>(json object)</code>
:: <code>treasurybase</code>: (boolean) Whether or not the input is a treasury base.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"treasurybase": bool, "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for treasury spend transactions)
: <code>(json object)</code>
:: <code>treasuryspend</code>: (string) the hex-encoded bytes of the signature script.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"treasuryspend": "data", "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for other transactions)
: <code>(json object)</code>
:: <code>txid</code>: <code>(string)</code> the hash of the origin transaction.
:: <code>vout</code>: <code>(numeric)</code> the index of the output being redeemed from the origin transaction.
:: <code>tree</code>: <code>(numeric)</code> the tree of the transaction.
:: <code>sequence</code>:  <code>(numeric)</code> the script sequence number.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>scriptSig</code>: <code>(json object)</code> the signature script used to redeem the origin transaction.
::: <code>asm</code>:<code>(string)</code> disassembly of the script.
::: <code>hex</code>: <code>(string)</code> hex-encoded bytes of the script.

: <code>{"txid": "hash", "vout": n, "tree": n, "sequence": n, "amountin": n.nnn, "blockheight": n, "blockindex": n, "scriptSig": {"asm": "asm", "hex": "data"}, ...}</code>

; vout
: <code>(json object)</code>
:: <code>value</code>: <code>(numeric)</code> the value in DCR.
:: <code>n</code>: <code>(numeric)</code> the index of this transaction output.
:: <code>version</code>: <code>(numeric)</code> the version of public key script.
:: <code>scriptPubKey</code>:<code>(json object)</code> the public key script used to pay coins.
::: <code>asm</code>: <code>(string)</code> disassembly of the script.
::: <code>hex</code>: <code>(string)</code> hex-encoded bytes of the script.
::: <code>reqSigs</code>: <code>(numeric)</code> the number of required signatures.
::: <code>type</code>: <code>(string)</code> the type of the script (e.g. 'pubkeyhash').
::: <code>addresses</code>: <code>(json array of string)</code> the Decred addresses associated with this output.
::: <code>commitamt</code>: <code>(numeric)</code> the ticket commitment value if the script is for a staking commitment (ticket txns only)
::: <code>version</code>: <code>(numeric)</code> the script version.

: <code>{"value": n, "n": n, "scriptPubKey": {"asm": "asm", "hex": "data","reqSigs": n, "type": "scripttype", "addresses": [...], "commitamt": n.nnn, "version": n}}</code>
|-
!Example Return
|
; For coinbase transactions
: <code>{"txid": "df2c767ea46a8b459d78dc3cad7e1ce47cc91f4d9d6cfa6e8af4f2cf8a1d2501", "version": 3, "locktime": 0, "expiry": 0, "vin": [{"coinbase": "00002f646372642f", "amountin": 0.98182641, "blockheight": 0, "blockindex": 0, "sequence": 4294967295}], "vout": [{"value": 0, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 2da3aaa402b110247f08c3ea2300a0567de77a5b OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9142da3aaa402b110247f08c3ea2300a0567de77a5b88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["DsVBSwwjs42fzxrJduHotLXhQX3AoUQEsVg", ...]}}]}</code>

; For vote transactions
: <code>{"txid": "b77b9367f7d7cf428a54c39d4bcbf66e2b5917a6d1c643f534853e32ae41b000", "version": 1, "locktime": 0, "expiry": 0, "vin": [{"stakebase": "0000", "amountin": 0.09818264, "blockheight": 0, "blockindex": 4294967295, "sequence": 4294967295}, {"txid":"078e60de39e764c1053e404bd498d319c16e903104a17aea283f4aa5cdb3e28b", "vout": 0, "tree": 1, "sequence": 4294967295, "amountin": 76.06810002, "blockheight": 560810, "blockindex": 23, "scriptSig": {"asm": "304402200ed0a2d476b29cde2221a31f5e07cdef...", "hex": "47304402200ed0a2d476b29cde2221a31f5e07cd..."}, ...}], "vout": [{"value": 0, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_RETURN fdb752026e489bec1334177405c0c4dd632cf1018c45f1db62a335081d000000de920800", "hex": "6a24fdb752026e489bec1334177405c0c4dd632cf1018c45f1db62a335081d000000de920800", "type": "nulldata"}}, {"value": 0, "n": 1, "version": 0, "scriptPubKey": {"asm": "OP_RETURN 010009000000", "hex": "6a06010009000000", "type": "nulldata"}}, {"value": 76.16628266, "n": 2, "version": 0, "scriptPubKey": {"asm": "OP_SSGEN OP_DUP OP_HASH160 6e479df154d676e44069d5d2d5dd4e9f0d461c8f OP_EQUALVERIFY OP_CHECKSIG", "hex": "bb76a9146e479df154d676e44069d5d2d5dd4e9f0d461c8f88ac", "type": "stakegen", "addresses": ["Dsb5EbhGhWwUJXbcuMr46cyvm2J5n4ekFYm"], "version": 0}}, ...]}</code>

; For treasurybase transactions
: <code>{"txid": "cc84c219827d98011398e842190f62a2d1e755ba6f9aea925264c04a8c6c18d8", "version": 3, "locktime": 0, "expiry": 0, "vin": [{"treasurybase": true, "amountin": 0.16363773, "blockheight": 0, "blockindex": 4294967295, "sequence": 4294967295}], "vout": [{"value": 0.16363773, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_TADD", "hex": "c1", "type": "treasuryadd"}}, {"value": 0, "n": 1, "version": 0, "scriptPubKey": {"asm": "OP_RETURN df92080067c8c34911561fe7", "hex": "6a0cdf92080067c8c34911561fe7", "type": "nulldata"}}]}</code>

; For treasury spend transactions
: <code>{"txid": "47de5efe98f073b6f33fbffb1743bacb850fbd8be5723195a744086061f5f0f2", "version": 3, "locktime": 0, "expiry": 560882, "vin": [{"treasuryspend": "4054a36eb67457facef5a075f8ebba5d7a9342dd13b45c6d3dd43b22bead35428603fd805ee...", "amountin": 1.0000255, "blockheight": 0, "blockindex": 4294967295, "sequence": 4294967295}], "vout": [{"value": 0, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_RETURN f6eaf505000000000c9ef1c885c62d089ff9988eb4ca4c2c620614eb75c620bc", "hex": "6a20f6eaf505000000000c9ef1c885c62d089ff9988eb4ca4c2c620614eb75c620bc", "type": "nulldata"}}, {"value": 1, "n": 1, "version": 0, "scriptPubKey": {"asm": "OP_TGEN OP_DUP OP_HASH160 bd15503ed7d24fc5b36ceba70ee8741a36fe3dca OP_EQUALVERIFY OP_CHECKSIG", "hex": "c376a914bd15503ed7d24fc5b36ceba70ee8741a36fe3dca88ac", "reqSigs": 1, "type": "treasurygen", "addresses": ["TsiFuihcGfaffRH41mTK1FRoR4zRuH26Dov", ...]}}, ...]}</code>

; For other transactions
: <code>{"txid": "f1d21c62f4444c5fb0d68d1f75109ad8fb44bbf3bf08b275eb08aec55bdb22f9", "version": 1, "locktime": 0, "expiry": 0, "vin": [{"txid": "b3a6dc584c36c59360f682cf67294566843b580909a2f543e53a45dc17f29ed4", "vout": 2, "tree": 1, "sequence": 4294967295, "amountin": 85.23317042, "blockheight": 561882, "blockindex": 2, "scriptSig": {"asm": "30440220088e38e24ce1cd863389a5790221d6c71879d4fc21e86b97ee345ce6e18a3b54022...", "hex": "4730440220088e38e24ce1cd863389a5790221d6c71879d4fc21e86b97ee345ce6e18a3b540..."}}, ...], "vout": [{"value": 0.00485517, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 fe420208bf2d1bbb40b9ee27a11ca0061d45e35c OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914fe420208bf2d1bbb40b9ee27a11ca0061d45e35c88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["Dsa5TDxF5X8oSQnekqYUHZpFbXWKJKR6Lj3"], "version": 0}}, ...]}</code>
|}

----

====decodescript====
{|
!Method
|decodescript
|-
!Parameters
|# <code>script</code>: <code>(string, required)</code> hex-encoded script.
|-
!Description
|Returns a JSON object with information about the provided hex-encoded script.
|-
!Returns
|
<code>(json object)</code>
: <code>asm</code>: <code>(string)</code> disassembly of the script (absent for nonstandard scripts).
: <code>reqSigs</code>: <code>(numeric)</code> the number of required signatures.
: <code>type</code>: <code>(string)</code> the type of the script (e.g. 'pubkeyhash').
: <code>addresses</code>: <code>(json array of string)</code> the Decred addresses associated with this script.
: <code>p2sh</code>: <code>(string)</code> the script hash for use in pay-to-script-hash transactions.
<code>{ "asm": "asm", "reqSigs": n, "type": "scripttype", "addresses": [...], "p2sh": "scripthash"}</code>
|-
!Example Return
|<code>{"asm": "OP_DUP OP_HASH160 b0a4d8a91981106e4ed85165a66748b19f7b7ad4 OP_EQUALVERIFY OP_CHECKSIG", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["1H71QVBpzuLTNUh5pewaH3UTLTo2vWgcRJ"], "p2sh": "359b84ff799f48231990ff0298206f54117b08b6"}</code>
|}

----

====estimatefee====
{|
!Method
|estimatefee
|-
!Parameters
|
# <code>numblocks</code>: <code>(numeric, required)</code> unused.
|-
!Description
|Returns the estimated fee in dcr/kb.
|-
!Returns
|<code>numeric</code>
|-
!Example Return
|<code>0.0001</code>
|}

----

====estimatesmartfee====
{|
!Method
|estimatesmartfee
|-
!Parameters
|
# <code>confirmations</code>: <code>(numeric, required)</code> Estimate the fee rate a transaction requires so that it is mined in up to this number of blocks.
# <code>mode</code>: <code>(string)</code> The only supported mode for the moment is 'conservative'.
|-
!Description
|Returns the estimated fee using the historical fee data in dcr/kb and the block number where the estimate was found.
|-
!Returns
|<code>{json object}</code>
: <code>fee</code>: <code>(numeric)</code> The estimated fee.
: <code>errors</code>: <code>(json array)</code> Unused.
: <code>blocks</code>: <code>(numeric)</code> The block number where the estimate was found.
|-
!Example Return
|
: <code>0.0001</code>
|}

----

====estimatestakediff====
{|
!Method
|estimatestakediff
|-
!Parameters
|
# <code>tickets</code>: <code>(numeric)</code> Use this number of new tickets in blocks to estimate the next difficulty.
|-
!Description
|Returns the estimated next minimum, maximum, expected, and user-specified stake difficulty.
|-
!Returns
|
<code>(json object)</code>
: <code>min</code>: <code>(numeric)</code> Minimum estimate for stake difficulty.
: <code>max</code>: <code>(numeric)</code> Maximum estimate for stake difficulty.
: <code>expected</code>: <code>(numeric)</code> Expected estimate for stake difficulty.
: <code>user</code>: <code>(numeric)</code> Estimate for stake difficulty with the passed user amount of tickets.
|-
!Example Return
|<code>{"min": 128.13311397, "max": 137.30522474, "expected": 130.85145872, "user": 128.16965817}</code>
|}

----

====existsaddress====
{|
!Method
|existsaddress
|-
!Parameters
|
# <code>address</code>: <code>(string, required)</code> The address to check.
|-
!Description
|Returns the existence of the provided address.
|-
!Returns
|<code>boolean</code>
|-
!Example Return
|<code>true</code>
|}

----

====existsaddresses====
{|
!Method
|existsaddresses
|-
!Parameters
|
# <code>addresses</code>: <code>(json array, required)</code> The addresses to check.
|-
!Description
|Returns the existence of the provided address.
|-
!Returns
|<code>bitset</code> Bitset of bools showing if addresses exist or not.
|-
!Example Return
|<code>07</code>
|}

----

====existsliveticket====
{|
!Method
|existsliveticket
|-
!Parameters
|
# <code>txhash</code>: <code>(string, required)</code> The ticket hash to check.
|-
!Description
|Returns the existence of the provided ticket.
|-
!Returns
|<code>boolean</code>
|-
!Example Return
|<code>true</code>
|}

----

====existslivetickets====
{|
!Method
|existslivetickets
|-
!Parameters
|
# <code>txhashes</code>: <code>(json array, required)</code> The array of tx hashes to check.
|-
!Description
|Returns the existence of the provided tickets in the live ticket map.
|-
!Returns
|<code>bitset</code> Bitset of bools showing if tx hashes exist or not as live tickets.
|-
!Example Return
|<code>00</code>
|}

----

====existsmempooltxs====
{|
!Method
|existsmempooltxs
|-
!Parameters
|
# <code>txhashes</code>: <code>(json array, required)</code> The array of tx hashes to check.
|-
!Description
|Returns the existence of the provided txs in the mempool.
|-
!Returns
|<code>bitset</code> Bitset of bools showing if tx hashes exist or not in the mempool.
|-
!Example Return
|<code>00</code>
|}

----

====generate====
{|
!Method
|generate
|-
!Parameters
|
# <code>numblocks</code>: <code>(int, required)</code> The number of blocks to generate.
|-
!Description
|When in simnet or regtest mode, generates <code>numblocks</code> blocks. If blocks arrive from elsewhere, they are built upon but don't count toward the number of blocks to generate. Only generated blocks are returned. This RPC call will exit with an error if the server is already CPU mining, and will prevent the server from CPU mining for another command while it runs.
|-
!Returns
|<code>(json array of strings)</code>
: <code>blockhash</code>: hash of the generated block.
<code>["blockhash", ...]</code>
|-
|}

----

====getaddednodeinfo====
{|
!Method
|getaddednodeinfo
|-
!Parameters
|
# <code>dns</code>: <code>(boolean, required)</code> specifies whether the returned data is a JSON object including DNS and connection information, or just a list of added peers.
# <code>node</code>: <code>(string, optional)</code> only return information about this specific peer instead of all added peers.
|-
!Description
|Returns information about manually added (persistent) peers.
|-
!Returns (dns=false)
|<code>["ip:port", ...]</code>
|-
!Returns (dns=true)
|<code>(json array of objects)</code>
: <code>addednode</code>: <code>(string)</code> the ip address or domain of the added peer.
: <code>connected</code>: <code>(boolean)</code> whether or not the peer is currently connected.
: <code>addresses</code>: <code>(json array or objects)</code> DNS lookup and connection information about the peer.
: <code>address</code>: <code>(string)</code> the ip address for this DNS entry.
: <code>connected</code>: <code>(string)</code> the connection 'direction' (if connected).
<code>[{"addednode": "ip_or_domain","connected": true or false,"addresses": [{address: "ip"}, ...], "connected": "inbound/outbound/false"}, ...]</code>
|-
!Example Return (dns=false)
|<code>["192.168.0.10:9108", "mydomain.org:9108"]</code>
|-
!Example Return (dns=true)
|<code>[{"addednode": "mydomain.org:9108", "connected": true, "addresses": [{"address": "1.2.3.4", "connected": "outbound"}, {"address": "5.6.7.8", "connected": "false"}]}]</code>
|}

----

====getbestblock====
{|
!Method
|getbestblock
|-
!Parameters
|None
|-
!Description
|Get block height and hash of best block in the main chain.
|-
!Returns
|
<code>(json object)</code>
: <code>hash</code>: <code>(string)</code> the hex-encoded bytes of the best block hash.
: <code>height</code>: <code>(numeric)</code> the block height
of the best block.

<code>{"hash": "data", "height": n}</code>
|}

----

====getbestblockhash====
{|
!Method
|getbestblockhash
|-
!Parameters
|None
|-
!Description
|Returns the hash of the of the best (most recent) block in the longest block chain.
|-
!Returns
|<code>string</code>
|-
!Example Return
|<code>0000000000000001f356adc6b29ab42b59f913a396e170f80190dba615bd1e60</code>
|}

----

====getblock====
{|
!Method
|getblock
|-
!Parameters
|
# <code>block hash</code>: <code>(string, required)</code> the hash of the block.
# <code>verbose</code>: <code>(boolean, optional, default=true)</code> specifies the block is returned as a JSON object instead of hex-encoded string.
# <code>verbosetx</code>: <code>(boolean, optional, default=false)</code> specifies that each transaction is returned as a JSON object and only applies if the <code>verbose</code> flag is true.
|-
!Description
|Returns information about a block given its hash.
|-
!Returns (verbose=false)
|<code>"data" (string) hex-encoded bytes of the serialized block</code>
|-
!Returns (verbose=true, verbosetx=false)
|
<code>(json object)</code>
: <code>hash</code>: <code>(string)</code> the hash of the block (same as provided).
: <code>powhash</code>: <code>(string)</code> the Proof-of-Work hash of the block (same as hash prior to DCP0011 activation).
: <code>confirmations</code>: <code>(numeric)</code> the number of confirmations.
: <code>size</code>: <code>(numeric)</code> the size of the block.
: <code>height</code>: <code>(numeric)</code> the height of the block in the block chain.
: <code>version</code>: <code>(numeric)</code> the block version.
: <code>merkleroot</code>: <code>(string)</code> root hash of the merkle tree.
: <code>stakeroot</code>: <code>(string)</code> root hash of the stake tree.
: <code>tx</code>: <code>(json array of string)</code> the transaction hashes.
: <code>stx</code>: <code>(json array of string)</code> the stake transaction hashes.
: <code>time</code>: <code>(numeric)</code> the block time in seconds since 1 Jan 1970 GMT.
: <code>mediantime</code>: <code>(numeric)</code> the median block time over the last 11 blocks.
: <code>nonce</code>: <code>(numeric)</code> the block nonce.
: <code>votebits</code>: <code>(numeric)</code> the block voting results.
: <code>finalstate</code>: <code>(string)</code> the final lottery state.
: <code>voters</code>: <code>(numeric)</code> the number of votes.
: <code>freshstake</code>: <code>(numeric)</code> the number of ticket purchases.
: <code>revocations</code>: <code>(numeric)</code> the number of ticket revocations.
: <code>poolsize</code>: <code>(numeric)</code> the total number of valid spendble tickets as of the block.
: <code>bits</code>: <code>(numeric)</code> the bits which represent the block difficulty.
: <code>sbits</code>: <code>(numeric)</code> the bits which represent the stake difficulty.
: <code>difficulty</code>: <code>(numeric)</code> the proof-of-work difficulty as a multiple of the minimum difficulty.
: <code>chainwork</code>: <code>(string)</code> the total number of hashes expected to produce the chain up to the block in hex.
: <code>extradata</code>: <code>(string)</code> extra data for the block including the extra nonce used by proof-of-work miners.
: <code>stakeversion</code>: <code>(string)</code> block stake version.
: <code>previousblockhash</code>: <code>(string)</code> the hash of the previous block.
: <code>nextblockhash</code>: <code>(string)</code> the hash of the next block (only if there is one).

<code>{"hash": "blockhash", "powhash": "hash", "confirmations": n, "size": n, "height": n, "version": n, "merkleroot": "hash", "stakeroot": "hash", "tx": ["transactionhash", ...], "stx": ["transactionhash", ...], "time": n, "nonce": n, "votebits": n, "finalstate": "state", "voters": n, "freshstake": n, "revocations": n, "poolsize": n, "bits": n, "sbits": n.nn, "difficulty": n.nn, "chainwork": "workhex", "extradata": "data", "stakeversion": n, previousblockhash": "hash", "nextblockhash": "hash"}</code>
|-
!Example Return (verbose=false)
|
: Newlines added for display purposes. The actual return does not contain newlines.
: <code>"01000000b926d1870d6f88760a8b10db0d4439e5cd74f3827fd4b6827443000000000000</code>
: <code>35cade3c4cd99e7547d1dffe8474855dd363dff69b395428810466c985d067c800000000</code>
: <code>000000000000000000000000000000000000000000000000000000000100000000000000</code>
: <code>0000000000000000ffff011b00c2eb0b00000000020000007e01000080d8b856bac0f231</code>
: <code>c84e3a6b6ad536d301000000000000000000000000000000000000000000000000000000</code>
: <code>010100000001000000000000000000000000000000000000000000000000000000000000</code>
: <code>0000ffffffff00ffffffff03fa1a981200000000000017a914f5916158e3e2c4551c1796</code>
: <code>708db8367207ed13bb8700000000000000000000266a2402000000000000000000000000</code>
: <code>000000000000000000000000000000ffa310d9a6a9588edea1906f0000000000001976a9</code>
: <code>148ffe7a49ecf0f4858e7a52155302177398d2296988ac000000000000000001d8bc2882</code>
: <code>0000000000000000ffffffff0800002f646372642f00"</code>
|-
!Example Return (verbose=true, verbosetx=false)
|<code>"hash": "000000000000c41019872ff7db8fd2e9bfa05f42d3f8fee8e895e8c1e5b8dcba", "powhash": "000000000000c41019872ff7db8fd2e9bfa05f42d3f8fee8e895e8c1e5b8dcba", "confirmations": 283285,"size": 382, "height": 2, "version": 1, "merkleroot": "c867d085c96604812854399bf6df63d35d857484fedfd147759ed94c3cdeca35", "stakeroot": "000000000000000000000000000000000000000000000000000000000000000", tx": ["ba8d2fcb5c705a1e5cbeda0db9dd30a521e360efd3aef75e862b2b69e0a673af", ...], "time": 1454954624, "nonce": 837992634, "votebits": 1, "finalstate": "000000000000", "voters": 0, "freshstake": 0, "revocations": 0, "poolsize": 0, "bits": "1d00ffff", "sbits": 2, "difficulty": 32767.74999809, "chainwork": "00000000000000000000000000000000000000000000000000018000c0006000", "extradata": "c84e3a6b6ad536d3010000000000000000000000000000000000000000000000", "stakeversion": 0, "previousblockhash": "000000000000437482b6d47f82f374cde539440ddb108b0a76886f0d87d126b9", "nextblockhash": "00000000000108ac3e3f51a0f4424dd757a3b0485da0ec96592f637f27bd1cf5"}</code>
|}

----

====getblockchaininfo====
{|
!Method
|getblockchaininfo
|-
!Parameters
|None
|-
!Description
|Returns information about the current state of the block chain.
|-
!Returns
|<code>(json object)</code>
: <code>chain</code>: <code>(string)</code> The current network name.
: <code>blocks</code>: <code>(numeric)</code> The number of blocks in the current best chain.
: <code>headers</code>: <code>(numeric)</code> The number of validated block headers that comprise the target best chain.
: <code>syncheight</code>: <code>(numeric)</code> The latest known block height being synced to.
: <code>bestblockhash</code>: <code>(string)</code> The block hash of the current best chain tip.
: <code>difficulty</code>: <code>(numeric)</code> (DEPRECATED) The current network difficulty.
: <code>difficultyratio</code>: <code>(numeric)</code> The current proof-of-work difficulty as a multiple of the minimum difficulty.
: <code>verificationprogress</code>: <code>(numeric)</code> The chain verification progress estimate.
: <code>chainwork</code>: <code>(string)</code> Hex encoded total work done for the chain.
: <code>initialblockdownload</code>: <code>(boolean)</code> Best guess of whether this node is in the initial block download mode used to catch up the chain when it is far behind.
: <code>maxblocksize</code>: <code>(numeric)</code> The maximum allowed block size.
: <code>deployments</code>: <code>(json array of objects)</code> Network consensus deployments.
: <code>status</code>: <code>(string)</code> The deployment agenda's current status.
: <code>since</code>: <code>(numeric)</code> The blockheight of the first block to which the status applies.
: <code>starttime</code>: <code>(numeric)</code> The start time of the voting period for the agenda.
: <code>expiretime</code>: <code>(numeric)</code> The expiry time of the voting period for the agenda.

<code>{ "chain": "name", "blocks": n, "headers": n, "syncheight": n, "bestblockhash": "hash", "difficulty": n, "difficultyratio": n, "verificationprogress": n, "chainwork": "n", "initialblockdownload": bool, "maxblocksize": n, "deployments": {"agenda": { "status": "status", "since": n, "starttime": n, "expiretime": n}, ...}}</code>
|-
!Example Return
|<code>{"chain": "simnet", "blocks": 463, "headers": 463, "syncheight": 0, "bestblockhash": "000043c89f6e227c9d90a5460aff98b662e503b9a394818942bdd60709cbb8aa", "difficulty": 520127421, "difficultyratio": 1180923195.260000, "verificationprogress": 0, "chainwork": "0x23c0e40", "initialblockdownload": false, "maxblocksize": 1000000, "deployments": {"lnfeatures": {"status": "started", "since": 463, "starttime": 0, "expiretime": 9223372036854775807}, "maxblocksize": {"status": "started", "since": 463, "starttime": 0, "expiretime": 9223372036854775807}, "sdiffalgorithm": {"status": "started", "since": 463, "starttime": 0, "expiretime": 9223372036854775807}}}</code>
|}

----

====getblockcount====
{|
!Method
|getblockcount
|-
!Parameters
|None
|-
!Description
|Returns the number of blocks in the longest block chain.
|-
!Returns
|numeric
|-
!Example Return
|<code>276820</code>
|}

----

====getblockhash====
{|
!Method
|getblockhash
|-
!Parameters
|
# block height (numeric, required)
|-
!Description
|Returns hash of the block in best block chain at the given height.
|-
!Returns
|string
|-
!Example Return
|<code>000000000000000096579458d1c0f1531fcfc58d57b4fce51eb177d8d10e784d</code>
|}

----

====getblockheader====
{|
!Method
|getblockheader
|-
!Parameters
|
# <code>block hash</code>: <code>(string, required)</code> the hash of the block.
# <code>verbose</code>: <code>(boolean, optional, default=true)</code> specifies the block header is returned as a JSON object instead of a hex-encoded string.
|-
!Description
|Returns hex-encoded bytes of the serialized block header.
|-
!Returns (verbose=false)
|<code>"data" (string) hex-encoded bytes of the serialized block</code>
|-
!Returns (verbose=true)
|<code>(json object)</code>
: <code>hash</code>: <code>(string)</code> the hash of the block (same as provided).
: <code>powhash</code>: <code>(string)</code> the Proof-of-Work hash of the block (same as hash prior to DCP0011 activation).
: <code>confirmations</code>: <code>(numeric)</code> the number of confirmations.
: <code>version</code>: <code>(numeric)</code> the block version.
: <code>merkleroot</code>: <code>(string)</code> root hash of the merkle tree.
: <code>stakeroot</code>: <code>(string)</code> root hash of the stake tree.
: <code>votebits</code>: <code>(numeric)</code> the block voting results.
: <code>finalstate</code>: <code>(string)</code> the final lottery state.
: <code>voters</code>: <code>(numeric)</code> the number of votes.
: <code>freshstake</code>: <code>(numeric)</code> the number of ticket purchases.
: <code>revocations</code>: <code>(numeric)</code> the number of ticket revocations.
: <code>poolsize</code>: <code>(numeric)</code> the total number of valid spendble tickets as of the block.
: <code>bits</code>: <code>(numeric)</code> the bits which represent the block difficulty.
: <code>sbits</code>: <code>(numeric)</code> the bits which represent the stake difficulty.
: <code>height</code>: <code>(numeric)</code> the height of the block in the block chain.
: <code>size</code>: <code>(numeric)</code> the size of the block.
: <code>time</code>: <code>(numeric)</code> the block time in seconds since 1 Jan 1970 GMT.
: <code>mediantime</code>: <code>(numeric)</code> the median block time over the last 11 blocks.
: <code>nonce</code>: <code>(numeric)</code> the block nonce.
: <code>extradata</code>: <code>(string)</code> extra data for the block including the extra nonce used by proof-of-work miners.
: <code>stakeversion</code>: <code>(string)</code> block stake version.
: <code>difficulty</code>: <code>(numeric)</code> the proof-of-work difficulty as a multiple of the minimum difficulty.
: <code>chainwork</code>: <code>(string)</code> the total number of hashes expected to produce the chain up to the block in hex.
: <code>previousblockhash</code>: <code>(string)</code> the hash of the previous block.
: <code>nextblockhash</code>: <code>(string)</code> the hash of the next block (only if there is one).

<code>{"hash": "blockhash", "powhash": "hash", "confirmations": n, "version": n, "merkleroot": "hash", "stakeroot": "hash", "votebits": n, "finalstate": "state", "voters": n, "freshstake": n, "revocations": n, "poolsize": n, "bits": n, "sbits": n.nn, "height": n, "size": n, "time": n, "nonce": n, "extradata": "data", "stakeversion": n, "difficulty": n.nn, "chainwork": "workhex", "previousblockhash": "hash", "nextblockhash": "hash"}</code>
|-
!Example Return (verbose=false)
|
: Newlines added for display purposes.  The actual return does not contain newlines.
: <code>"0100000094f455952f88b4ff019c6673f3f01541b76e700e0c8a2ab9da00000000000000</code>
: <code>266b9d4672f099e2b36c7adcede6564ee7326ac02b757b065e4a7c69efa44925825ccc8e</code>
: <code>9602af73d03e54ea1ac717f712c869440a1762375f64b9fe3ae2409f01008b736885bab7</code>
: <code>0500000047a60000b494111a6688f80402000000a0860100600c000000a081585ab58b03</code>
: <code>360000000024680140d1ec18000000000000000000000000000000000000000000000000"</code>
|-
!Example Return (verbose=true)
|<code>{"hash": "00000000000004289d9a7b0f7a332fb60a1c221faae89a107ce3ab93eead2f93", "powhash": "00000000000004289d9a7b0f7a332fb60a1c221faae89a107ce3ab93eead2f93", "confirmations": 183291, "version": 1, "merkleroot": "2549a4ef697c4a5e067b752bc06a32e74e56e6eddc7a6cb3e299f072469d6b26", "stakeroot":"9f40e23afeb9645f3762170a4469c812f717c71aea543ed073af02968ecc5c82", "votebits": 1, "finalstate": "8b736885bab7", "voters": 5, "freshstake": 0, "revocations": 0, "poolsize": 42567, "bits": "1a1194b4", "sbits": 86.73331302, "height": 100000, "size": 3168, "time": 1484890112, "nonce": 59487578, "stakeversion": 0, "difficulty": 954273.50809769, "chainwork": "00000000000000000000000000000000000000000000001060ad4432c4d6eff1", "previousblockhash": "00000000000000dab92a8a0c0e706eb74115f0f373669c01ffb4882f9555f494",  "nextblockhash": "0000000000000578b08f22fd2bdf5f7fe5b0af1bb4928de5053a3f906b3c8f6b"}</code>
|}

----

====getblocksubsidy====
{|
!Method
|getblocksubsidy
|-
!Parameters
|
# <code>height</code>: <code>(numeric, required)</code> The block height.
# <code>voters</code>: <code>(numeric, required)</code> The number of voters.
|-
!Description
|Returns information regarding subsidy amounts.
|-
!Returns
|<code>(json object)</code>
: <code>developer</code>: <code>(nuneric)</code> The developer subsidy.
: <code>pos</code>: <code>(numeric)</code> The Proof-of-Stake subsidy.
: <code>pow</code>: <code>(numeric)</code> The Proof-of-Work subsidy.
: <code>total</code>: <code>(numeric)</code> The total subsidy.
|-
!Example Return
|<code>{"developer": 171717305, "pos": 515151915, "pow": 1030303833, "total": 1717173053}</code>
|}

----

====getcfilterv2====
{|
!Method
|getcfilterv2
|-
!Parameters
|
# <code>hash</code>: <code>(string, required)</code> The block hash of the filter to retrieve.
|-
!Description
|Returns the version 2 block filter for the given block along with a proof that can be used to prove the filter is committed to by the block header.
|-
!Returns
|<code>(json object)</code>
: <code>blockhash</code>: <code>(string)</code> The block hash associated with the filter.
: <code>data</code>: <code>(string)</code> Hex-encoded bytes of the serialized filter.
: <code>proofindex</code>: <code>(numeric)</code> The index of the leaf that represents the filter hash in the header commitment.
: <code>proofhashes</code>: <code>(array of string)</code> The hashes needed to prove the filter is committed to by the header commitment.
|-
!Example Return
|<code>{"blockhash": "000000000000c41019872ff7db8fd2e9bfa05f42d3f8fee8e895e8c1e5b8dcba", "data": "035ba13b533cb5a848", "proofindex": 0, "proofhashes": null}</code>
|}

----

====getchaintips====
{|
!Method
|getchaintips
|-
!Parameters
|None
|-
!Description
|
: Returns about all known chain tips the in the block tree.
: The statuses in the result have the following meanings:
* <code>active</code>: The current best chain tip.
* <code>invalid</code>: The block or one of its ancestors is invalid.
* <code>headers-only</code>: The block or one of its ancestors does not have the full block data available which also means the block can't be validated or connected.
* <code>valid-fork</code>: The block is fully validated which implies it was probably part of the main chain at one point and was reorganized.
* <code>valid-headers</code>: The full block data is available and the header is valid, but the block was never validated which implies it was probably never part of the main chain.
|-
!Returns
|
<code>(json array of objects)</code>
: <code>height</code>: <code>(numeric)</code> The height of the chain tip.
: <code>hash</code>: <code>(string)</code> The block hash of the chain tip.
: <code>branchlen</code>: <code>(numeric)</code> The length of the branch that connects the tip to the main chain (0 for the main chain tip).
: <code>status</code>: <code>(string)</code>  status of the chain (active, invalid, headers-only, valid-fork, valid-headers).

<code>[{"height": n, "hash": "hash", "branchlen": n, "status": "status"}, ...]</code>
|-
!Example Return
|<code>[{"height": 217033, "hash": "00000000000000161bd5b120ef945faad60fc6e4c32b5caf1d4cabeae9a75346", "branchlen": 0, "status": "active"}, {"height": 213522, "hash": "0000000000000015e27658ce02ba8fa05d8d7ad9c587a5a472e3307773a9b36e", "branchlen": 1, "status": "valid-fork"}]"</code>
|}

----

====getcoinsupply====
{|
!Method
|getcoinsupply
|-
!Parameters
|None
|-
!Description
|Returns current total coin supply in atoms.
|-
!Returns
|<code>numeric</code> Current coin supply in atoms.
|-
!Example Return
|<code>1029794286558577</code>
|}

----

====getconnectioncount====
{|
!Method
|getconnectioncount
|-
!Parameters
|None
|-
!Description
|Returns the number of active connections to other peers.
|-
!Returns
|numeric
|-
!Example Return
|<code>8</code>
|}

----

====getcurrentnet====
{|
!Method
|getcurrentnet
|-
!Parameters
|None
|-
!Description
|Get Decred network dcrd is running on.
|-
!Returns
|<code>numeric</code>
|-
!Example Return
|
: <code>(mainnet)</code> <code>3652501241</code>
: <code>(testnet3)</code> <code>2979310197</code>
:
|}

----

====getdifficulty====
{|
!Method
|getdifficulty
|-
!Parameters
|None
|-
!Description
|Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
|-
!Returns
|numeric
|-
!Example Return
|<code>1180923195.260000</code>
|}

----

====getgenerate====
{|
!Method
|getgenerate
|-
!Parameters
|None
|-
!Description
|Return if the server is set to generate coins (mine) or not.
|-
!Returns
|<code>false</code> (boolean)
|}

----

====gethashespersec====
{|
!Method
|gethashespersec
|-
!Parameters
|None
|-
!Description
|Returns a recent hashes per second performance measurement while generating coins (mining).
|-
!Returns
|<code>0</code> (numeric)
|}

----

====getheaders====
{|
!Method
|getheaders
|-
!Parameters
|
# <code>blocklocators</code>: <code>(json array, required)</code> Array of block locator hashes.
# <code>hashstop</code>: <code>(string, required)</code> Block hash to stop including block headers for, set to zero to get as many blocks as possible.
|-
!Description
|Returns block headers starting with the first known block hash from the request.
|-
!Returns
|<code>(json object)</code>
: <code>headers</code>: <code>(json array)</code> Serialized block headers of all located blocks, limited to some arbitrary maximum number of hashes (currently 2000, which matches the wire protocol headers message, but this is not guaranteed).
|-
!Example Return
|<code>{"headers": ["060000001abfc354ad9f714fad8f8ec8ae0aecac8a660d...",...]}</code>
|}

----

====getinfo====
{|
!Method
|getinfo
|-
!Parameters
|None
|-
!Description
|Returns a JSON object containing various state info.
|-
!Notes
|NOTE: Since dcrd does NOT contain wallet functionality, wallet-related fields are not returned.  See getinfo in dcrwallet for a version which includes that information.
|-
!Returns
|
<code>(json object)</code>
: <code>version</code>: <code>(numeric)</code> the version of the server.
: <code>protocolversion</code>: <code>(numeric)</code> the latest supported protocol version.
: <code>blocks</code>: <code>(numeric)</code> the number of blocks processed.
: <code>timeoffset</code>: <code>(numeric)</code> the time offset.
: <code>connections</code>: <code>(numeric)</code> the number of connected peers.
: <code>proxy</code>: <code>(string)</code> the proxy used by the server
: <code>difficulty</code>: <code>(numeric)</code> the current target difficulty.
: <code>testnet</code>: <code>(boolean)</code> whether or not server is using testnet.
: <code>relayfee</code>: <code>(numeric)</code> the minimum relay fee for non-free transactions in DCR/KB.
: <code>txindex</code>: <code>(boolean)</code> whether or not server has transaction index enabled.
<code>{"version": n,"protocolversion": n, "blocks": n, "timeoffset": n, "connections": n, "proxy": "host:port", "difficulty": n.nn, "testnet": true or false, "relayfee": n.nn, "txindex": true or false}</code>
|-
!Example Return
|<code>{"version": 70000, "protocolversion": 70001, "blocks": 298963, "timeoffset": 0, "connections": 17, "proxy": "", "difficulty": 8000872135.97, "testnet": false,"relayfee": 0.00001}</code>
|}

----

====getmempoolinfo====
{|
!Method
|getmempoolinfo
|-
!Parameters
|None
|-
!Description
|Returns a JSON object containing mempool-related information.
|-
!Returns
|<code>(json object)</code>
: <code>bytes</code>: <code>(numeric)</code> size in bytes of the mempool
: <code>size</code>: <code>(numeric)</code> number of transactions in the mempool
<code>{"bytes": n, "size": n}</code>
|-
!Example Return
|<code>{"bytes": 310768, "size": 157}</code>
|}

----

====getmininginfo====
{|
!Method
|getmininginfo
|-
!Parameters
|None
|-
!Description
|Returns a JSON object containing mining-related information.
|-
!Returns
|<code>(json object)</code>
: <code>blocks</code>: <code>(numeric)</code> latest best block.
: <code>currentblocksize</code>: <code>(numeric)</code> size of the latest best block.
: <code>currentblocktx</code>: <code>(numeric)</code> number of transactions in the latest best block.
: <code>difficulty</code>: <code>(numeric)</code> current target difficulty.
: <code>stakedifficulty</code>: <code>(numeric)</code> Stake difficulty required for the next block.
: <code>errors</code>: <code>(string)</code> any current errors.
: <code>generate</code>: <code>(boolean)</code> whether or not server is set to generate coins.
: <code>genproclimit</code>:  <code>(numeric)</code> number of processors to use for coin generation (-1 when disabled).
: <code>hashespersec</code>: <code>(numeric)</code> recent hashes per second performance measurement while generating coins.
: <code>networkhashps</code>: <code>(numeric)</code> estimated network hashes per second for the most recent blocks.
: <code>pooledtx</code>:  <code>(numeric)</code> number of transactions in the memory pool.
: <code>testnet</code>: <code>(boolean)</code> whether or not server is using testnet.

<code>{"blocks": n, "currentblocksize": n, "currentblocktx": n, "difficulty": n.nn,  "stakedifficulty": n, "errors": "errors", "generate": true or false,  "genproclimit": n, "hashespersec": n, "networkhashps": n, "pooledtx": n,  "testnet": true or false }</code>
|-
!Example Return
|<code>{"blocks": 236526, "currentblocksize": 185, "currentblocktx": 1, "difficulty": 256, "errors": "", "generate": false, "genproclimit": -1, "hashespersec": 0, "networkhashps": 33081554756, "pooledtx": 8, "testnet": true }</code>
|}

----

====getnettotals====
{|
!Method
|getnettotals
|-
!Parameters
|None
|-
!Description
|Returns a JSON object containing network traffic statistics.
|-
!Returns
|<code>(json object)</code>
: <code>totalbytesrecv</code>: <code>(numeric)</code> total bytes received.
: <code>totalbytessent</code>: <code>(numeric)</code> total bytes sent.
: <code>timemillis</code>: <code>(numeric)</code> number of milliseconds since 1 Jan 1970 GMT.

<code>{"totalbytesrecv": n, "totalbytessent": n, "timemillis": n }</code>
|-
!Example Return
|<code>{"totalbytesrecv": 1150990, "totalbytessent": 206739, "timemillis": 1391626433845 }</code>
|}

----

====getnetworkhashps====
{|
!Method
|getnetworkhashps
|-
!Parameters
|
# <code>blocks</code>: <code>(numeric, optional, default=120)</code> The number of blocks, or -1 for blocks since last difficulty change.
# <code>height</code>: <code>(numeric, optional, default=-1)</code> Perform estimate ending with this height or -1 for current best chain block height.
|-
!Description
|Returns the estimated network hashes per second for the block heights provided by the parameters.
|-
!Returns
|numeric
|-
!Example Return
|<code>6573971939</code>
|}

----

====getnetworkinfo====
{|
!Method
|getnetworkinfo
|-
!Parameters
|None
|-
!Description
|Returns a JSON object containing network-related information.
|-
!Returns
|<code>(json object)</code>
: <code>address</code>: <code>(string)</code> The local address being listened on.
: <code>port</code>: <code>(numeric)</code> The port being listened on for the associated local address.
: <code>score</code>: <code>(numeric)</code> Reserved.
: <code>name</code>: <code>(string)</code> The name of the network interface.
: <code>limited</code>: <code>(boolean)</code> True if only connections to the network are allowed.
: <code>proxy</code>: <code>(string)</code> The proxy set for the network.
: <code>proxyrandomizecredentials</code>: <code>(boolean)</code> True if randomized credentials are set for the proxy.
: <code>reachable</code>: <code>(boolean)</code> True if connections can be made to or from the network.
: <code>version</code>: <code>(numeric)</code> The version of the node as a numeric.
: <code>subversion</code>: <code>(string)</code> The subversion of the node, as advertised to peers.
: <code>protocolversion</code>: <code>(numeric)</code> The protocol version of the node.
: <code>timeoffset</code>: <code>(numeric)</code> The node clock offset in seconds.
: <code>connections</code>: <code>(numeric)</code> The total number of open connections for the node.
: <code>networks</code>: <code>(json array)</code> An array of objects describing IPV4, IPV6 and Onion network interface states.
: <code>relayfee</code>: <code>(numeric)</code> The minimum required transaction fee for the node.
: <code>localaddresses</code>: <code>(json array)</code> An array of objects describing local addresses being listened on by the node.
: <code>localservices</code>: <code>(string)</code> The services supported by the node, as advertised in its version message.

<code>{"version": n, "subversion": "major.minor.patch", "protocolversion": n, "timeoffset": n, "connections": n, "networks": [{"name": "network", "limited": true or false, "reachable": true or false, "proxy": "host:port","proxyrandomizecredentials": true or false }, ...], "relayfee": n.nn., "localaddresses": [{ "address": "ip", "port": n, "score": n }, ...], "localservices": "services"}</code>
|-
!Example Return
|<code>{"version": 1050000, "subversion": "1.5.0", "protocolversion": 6, "timeoffset": 0, "connections": 4, "networks": [{"name": "IPV4", "limited": true, "reachable": true, "proxy": "127.0.0.1:9050", "proxyrandomizecredentials": false}, {"name": "IPV6", "limited": false, "reachable": false, "proxy": "", "proxyrandomizecredentials": false}, {"name": "Onion", "limited": false, "reachable": false, "proxy": "", "proxyrandomizecredentials": false}], "relayfee": 0.0001, "localaddresses": [{"address": "fd87:d87e:eb43:d208:593b:4305:c8e5:2e77", "port": 9108, "score": 0}], "localservices": "0000000000000005"}</code>
|}

----

====getpeerinfo====
{|
!Method
|getpeerinfo
|-
!Parameters
|None
|-
!Description
|Returns data about each connected network peer as an array of json objects.
|-
!Returns
|<code>(json array)</code>
: <code>id</code>: <code>(numeric)</code> a unique node ID.
: <code>addr</code>: <code>(string)</code> the ip address and port of the peer.
: <code>addrlocal</code>: <code>(string)</code> local address.
: <code>services</code>: <code>(string)</code> the services supported by the peer.
: <code>relaytxes</code>: <code>(boolean)</code> peer has requested transactions be relayed to it.
: <code>lastsend</code>: <code>(numeric)</code> time the last message was sent in seconds since 1 Jan 1970 GMT.
: <code>lastrecv</code>: <code>(numeric)</code> time the last message was received in seconds since 1 Jan 1970 GMT.
: <code>bytessent</code>: <code>(numeric)</code> total bytes sent.
: <code>bytesrecv</code>: <code>(numeric)</code> total bytes received.
: <code>conntime</code>: <code>(numeric)</code> time the connection was made in seconds since 1 Jan 1970 GMT.
: <code>pingtime</code>: <code>(numeric)</code> number of microseconds the last ping took.
: <code>pingwait</code>: <code>(numeric)</code> number of microseconds a queued ping has been waiting for a response.
: <code>version</code>: <code>(numeric)</code> the protocol version of the peer.
: <code>subver</code>: <code>(string)</code> the user agent of the peer.
: <code>inbound</code>: <code>(boolean)</code> whether or not the peer is an inbound connection.
: <code>startingheight</code>: <code>(numeric)</code> the latest block height the peer knew about when the connection was established.
: <code>currentheight</code>: <code>(numeric)</code> the latest block height the peer is known to have relayed since connected.
: <code>banscore</code>: <code>(numeric)</code> the ban score.
: <code>syncnode</code>: <code>(boolean)</code> whether or not the peer is the sync peer.

<code>[{"id": n, "addr": "host:port", "addrlocal": "host:port", "services": "00000001", "relaytxes": true_or_false, "lastsend": n, "lastrecv": n, "bytessent": n, "bytesrecv": n, "conntime": n, "pingtime": n.nnn, "pingwait": n.nnn,  "version": n, "subver": "useragent", "inbound": true_or_false, "startingheight": n, "currentheight": n, "banscore": n, "syncnode": true_or_false }, ...]</code>
|-
!Example Return
|<code>[{"id": 1, "addr": "178.172.xxx.xxx:9108", "addrlocal": "192.168.x.x:54349", "services": "00000001", "relaytxes": true, "lastsend": 1388185470, "lastrecv": 1388183523, "bytessent": 287592965, "bytesrecv": 780340, "conntime": 1388182973, "pingtime": 405551, "pingwait": 183023, "version": 70001, "subver": "/dcrd:0.4.0/", "inbound": false, "startingheight": 276921, "currentheight": 276955, "banscore": 0, "syncnode": true }, ...]</code>
|}

----

====getrawmempool====
{|
!Method
|getrawmempool
|-
!Parameters
|
# <code>verbose</code> <code>(boolean, optional, default=false)</code> Returns JSON object when true or an array of transaction hashes when false.
# <code>txtype</code> <code>(string, optional)</code> Type of transaction to return.
|-
!Description
|
:Returns information about all of the transactions currently in the memory pool.
:The <code>verbose</code> flag specifies that each transaction is returned as a JSON object.
:The valid transaction types are <code>regular</code>, <code>tickets</code>, <code>votes</code>, <code>revocations</code>, <code>tspend</code>, <code>tadd</code>, and <code>all</code>.
|-
!Returns (verbose=false)
|
<code>(json array of string)</code>
: <code>transactionhash</code>: <code>(string)</code> hash of the transaction.
<code>["transactionhash", ...]</code>
|-
!Returns (verbose=true)
|
<code>(json object)</code>
: <code>size</code>: <code>(numeric)</code> transaction size in bytes.
: <code>fee</code> : <code>(numeric)</code> transaction fee in DCR.
: <code>time</code>:  <code>(numeric)</code> local time transaction entered pool in seconds since 1 Jan 1970 GMT.
: <code>height</code>: <code>(numeric)</code> block height when transaction entered the pool.
: <code>startingpriority</code>: <code>(numeric)</code> (DEPRECATED) this field is always 0 and will be removed in a future version of the software.
: <code>currentpriority</code>: <code>(numeric)</code> (DEPRECATED) this field is always 0 and will be removed in a future version of the software.
: <code>depends</code>:  <code>(json array)</code> unconfirmed transactions used as inputs for this transaction.
: <code>transactionhash</code>: <code>(string)</code> hash of the parent transaction.

<code>{"transactionhash": {"size": n,"fee" : n, "time": n,"height": n, "startingpriority": n, "currentpriority": n, "depends": ["transactionhash", ...]}, ...}</code>
|-
!Example Return (verbose=false)
|<code>["3480058a397b6ffcc60f7e3345a61370fded1ca6bef4b58156ed17987f20d4e7","cbfe7c056a358c3a1dbced5a22b06d74b8650055d5195c1c2469e6b63a41514a"]</code>
|-
!Example Return (verbose=true)
|<code>{"1697a19cede08694278f19584e8dcc87945f40c6b59a942dd8906f133ad3f9cc": {"size": 226, "fee" : 0.0001, "time": 1387992789, "height": 276836, "startingpriority": 0, "currentpriority": 0, "depends": ["aa96f672fcc5a1ec6a08a94aa46d6b789799c87bd6542967da25a96b2dee0afb", ...]}</code>
|}

----

====getrawtransaction====
{|
!Method
|getrawtransaction
|-
!Parameters
|
# <code>transaction hash</code>: <code>(string, required)</code> the hash of the transaction.
# <code>verbose</code>: <code>(int, optional, default=0)</code> specifies the transaction is returned as a JSON object instead of hex-encoded string.
|-
!Description
|Returns information about a transaction given its hash.
|-
!Returns (verbose=0)
|<code>"data" (string) hex-encoded bytes of the serialized transaction</code>
|-
!Returns (verbose=1)
|<code>(json object)</code>
: <code>hex</code>: <code>(string)</code> hex-encoded transaction / hex-encoded bytes of the script.
: <code>txid</code>: <code>(string)</code> the hash of the transaction.
: <code>version</code>: <code>(numeric)</code> the transaction version.
: <code>locktime</code>: <code>(numeric)</code> the transaction lock time.
: <code>expiry</code>: <code>(numeric)</code> the transaction expiry.
: <code>vin</code>: <code>(array of json objects)</code> the transaction inputs as json objects.
: <code>vout</code>: <code>(array of json objects)</code> the transaction outputs as json objects.

<code>{"hex": "data", "txid": "hash", "version": n, "locktime": n, "expiry": n, "vin": [...], "vout": [...]}</code>

; vin (for coinbase transactions)
: <code>(json object)</code>
:: <code>coinbase</code>: (string) the hex-encoded bytes of the signature script.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"coinbase": "data", "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for vote transactions)
: <code>(json object)</code>
:: <code>stakebase</code>: (string) the hex-encoded bytes of the signature script.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"stakebase": "data", "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for treasurybase transactions)
: <code>(json object)</code>
:: <code>treasurybase</code>: (boolean) Whether or not the input is a treasury base.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"treasurybase": bool, "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for treasury spend transactions)
: <code>(json object)</code>
:: <code>treasuryspend</code>: (string) the hex-encoded bytes of the signature script.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>sequence</code>: (numeric) the script sequence number.

: <code>{"treasuryspend": "data", "amountin": n.nnn, "blockheight": n, "blockindex": n, "sequence": n, ...}</code>

; vin (for other transactions)
: <code>(json object)</code>
:: <code>txid</code>: <code>(string)</code> the hash of the origin transaction.
:: <code>vout</code>: <code>(numeric)</code> the index of the output being redeemed from the origin transaction.
:: <code>tree</code>: <code>(numeric)</code> the tree of the transaction.
:: <code>sequence</code>:  <code>(numeric)</code> the script sequence number.
:: <code>amountin</code>: (numeric) the input amount.
:: <code>blockheight</code>: (numeric) the block height of the origin transaction.
:: <code>blockindex</code>: (numeric) the block index of the origin transaction.
:: <code>scriptSig</code>: <code>(json object)</code> the signature script used to redeem the origin transaction.
::: <code>asm</code>:<code>(string)</code> disassembly of the script.
::: <code>hex</code>: <code>(string)</code> hex-encoded bytes of the script.

: <code>{"txid": "hash", "vout": n, "tree": n, "sequence": n, "amountin": n.nnn, "blockheight": n, "blockindex": n, "scriptSig": {"asm": "asm", "hex": "data"}, ...}</code>

; vout
: <code>(json object)</code>
:: <code>value</code>: <code>(numeric)</code> the value in DCR.
:: <code>n</code>: <code>(numeric)</code> the index of this transaction output.
:: <code>version</code>: <code>(numeric)</code> the version of public key script.
:: <code>scriptPubKey</code>:<code>(json object)</code> the public key script used to pay coins.
::: <code>asm</code>: <code>(string)</code> disassembly of the script.
::: <code>hex</code>: <code>(string)</code> hex-encoded bytes of the script.
::: <code>reqSigs</code>: <code>(numeric)</code> the number of required signatures.
::: <code>type</code>: <code>(string)</code> the type of the script (e.g. 'pubkeyhash').
::: <code>addresses</code>: <code>(json array of string)</code> the Decred addresses associated with this output.
::: <code>commitamt</code>: <code>(numeric)</code> the ticket commitment value if the script is for a staking commitment (ticket txns only)
::: <code>version</code>: <code>(numeric)</code> the script version.

: <code>{"value": n, "n": n, "scriptPubKey": {"asm": "asm", "hex": "data","reqSigs": n, "type": "scripttype", "addresses": [...], "commitamt": n.nnn, "version": n}}</code>
|-
!Example Return (verbose=0)
|
: Newlines added for display purposes.  The actual return does not contain newlines.
: <code>03000000010000000000000000000000000000000000000000000000000000000000000000ffffff</code>
: <code>ff00ffffffff02000000000000000000000e6a0cdf920800f34792efcaad585df125da0500000000</code>
: <code>00001976a9142da3aaa402b110247f08c3ea2300a0567de77a5b88ac000000000000000001f125da</code>
: <code>050000000000000000ffffffff0800002f646372642f</code>
|-
!Example Return (verbose=1)
|
; For coinbase transactions
: <code>{"hex": "03000000010000000000000000000000000000000000000000000000000000000000000000f...", "txid": "df2c767ea46a8b459d78dc3cad7e1ce47cc91f4d9d6cfa6e8af4f2cf8a1d2501", "version": 3, "locktime": 0, "expiry": 0, "vin": [{"coinbase": "00002f646372642f", "amountin": 0.98182641, "blockheight": 0, "blockindex": 0, "sequence": 4294967295}], "vout": [{"value": 0, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 2da3aaa402b110247f08c3ea2300a0567de77a5b OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9142da3aaa402b110247f08c3ea2300a0567de77a5b88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["DsVBSwwjs42fzxrJduHotLXhQX3AoUQEsVg", ...]}}]}</code>

; For vote transactions
: <code>{"hex": "01000000020000000000000000000000000000000000000000000000000000000000000000f...", "txid": "b77b9367f7d7cf428a54c39d4bcbf66e2b5917a6d1c643f534853e32ae41b000", "version": 1, "locktime": 0, "expiry": 0, "vin": [{"stakebase": "0000", "amountin": 0.09818264, "blockheight": 0, "blockindex": 4294967295, "sequence": 4294967295}, {"txid":"078e60de39e764c1053e404bd498d319c16e903104a17aea283f4aa5cdb3e28b", "vout": 0, "tree": 1, "sequence": 4294967295, "amountin": 76.06810002, "blockheight": 560810, "blockindex": 23, "scriptSig": {"asm": "304402200ed0a2d476b29cde2221a31f5e07cdef...", "hex": "47304402200ed0a2d476b29cde2221a31f5e07cd..."}, ...}], "vout": [{"value": 0, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_RETURN fdb752026e489bec1334177405c0c4dd632cf1018c45f1db62a335081d000000de920800", "hex": "6a24fdb752026e489bec1334177405c0c4dd632cf1018c45f1db62a335081d000000de920800", "type": "nulldata"}}, {"value": 0, "n": 1, "version": 0, "scriptPubKey": {"asm": "OP_RETURN 010009000000", "hex": "6a06010009000000", "type": "nulldata"}}, {"value": 76.16628266, "n": 2, "version": 0, "scriptPubKey": {"asm": "OP_SSGEN OP_DUP OP_HASH160 6e479df154d676e44069d5d2d5dd4e9f0d461c8f OP_EQUALVERIFY OP_CHECKSIG", "hex": "bb76a9146e479df154d676e44069d5d2d5dd4e9f0d461c8f88ac", "type": "stakegen", "addresses": ["Dsb5EbhGhWwUJXbcuMr46cyvm2J5n4ekFYm"], "version": 0}}, ...], "blockhash": "0000002fd3e1c731012bb29571bd414d9bde0af348ab362971c0e2f037cd31d0", "blockheight": 561887, "blockindex": 1, "confirmations": 56, "time": 1606032208, "blocktime": 1606032208}</code>

; For treasurybase transactions
: <code>{"hex": "03000000010000000000000000000000000000000000000000000000000000000000000000f...", "txid": "cc84c219827d98011398e842190f62a2d1e755ba6f9aea925264c04a8c6c18d8", "version": 3, "locktime": 0, "expiry": 0, "vin": [{"treasurybase": true, "amountin": 0.16363773, "blockheight": 0, "blockindex": 4294967295, "sequence": 4294967295}], "vout": [{"value": 0.16363773, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_TADD", "hex": "c1", "type": "treasuryadd"}}, {"value": 0, "n": 1, "version": 0, "scriptPubKey": {"asm": "OP_RETURN df92080067c8c34911561fe7", "hex": "6a0cdf92080067c8c34911561fe7", "type": "nulldata"}}], "blockhash": "0000002fd3e1c731012bb29571bd414d9bde0af348ab362971c0e2f037cd31d0", "blockheight": 561887, "confirmations": 58, "time": 1606032208, "blocktime": 1606032208}</code>

; For treasury spend transactions
: <code>{"hex": "03000000010000000000000000000000000000000000000000000000000000000000000000f...", "txid": "47de5efe98f073b6f33fbffb1743bacb850fbd8be5723195a744086061f5f0f2", "version": 3, "locktime": 0, "expiry": 560882, "vin": [{"treasuryspend": "4054a36eb67457facef5a075f8ebba5d7a9342dd13b45c6d3dd43b22bead35428603fd805ee...", "amountin": 1.0000255, "blockheight": 0, "blockindex": 4294967295, "sequence": 4294967295}], "vout": [{"value": 0, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_RETURN f6eaf505000000000c9ef1c885c62d089ff9988eb4ca4c2c620614eb75c620bc", "hex": "6a20f6eaf505000000000c9ef1c885c62d089ff9988eb4ca4c2c620614eb75c620bc", "type": "nulldata"}}, {"value": 1, "n": 1, "version": 0, "scriptPubKey": {"asm": "OP_TGEN OP_DUP OP_HASH160 bd15503ed7d24fc5b36ceba70ee8741a36fe3dca OP_EQUALVERIFY OP_CHECKSIG", "hex": "c376a914bd15503ed7d24fc5b36ceba70ee8741a36fe3dca88ac", "reqSigs": 1, "type": "treasurygen", "addresses": ["TsiFuihcGfaffRH41mTK1FRoR4zRuH26Dov", ...]}}, ...], "blockhash": "0000002fb43a19427c2c56764134bd1f4de64a5d5973ff4d38131dfa05431293", "blockheight"": 560880, "blockindex": 6, "confirmations": 2153, "time": 1605909343, "blocktime": 1605909343}</code>

; For other transactions
: <code>{"hex": "0100000001d49ef217dc453ae543f5a20909583b8466452967cf82f66093c5364c58dca6b30...", "txid": "f1d21c62f4444c5fb0d68d1f75109ad8fb44bbf3bf08b275eb08aec55bdb22f9", "version": 1, "locktime": 0, "expiry": 0, "vin": [{"txid": "b3a6dc584c36c59360f682cf67294566843b580909a2f543e53a45dc17f29ed4", "vout": 2, "tree": 1, "sequence": 4294967295, "amountin": 85.23317042, "blockheight": 561882, "blockindex": 2, "scriptSig": {"asm": "30440220088e38e24ce1cd863389a5790221d6c71879d4fc21e86b97ee345ce6e18a3b54022...", "hex": "4730440220088e38e24ce1cd863389a5790221d6c71879d4fc21e86b97ee345ce6e18a3b540..."}}, ...], "vout": [{"value": 0.00485517, "n": 0, "version": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 fe420208bf2d1bbb40b9ee27a11ca0061d45e35c OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914fe420208bf2d1bbb40b9ee27a11ca0061d45e35c88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["Dsa5TDxF5X8oSQnekqYUHZpFbXWKJKR6Lj3"], "version": 0}}, ...], "blockhash": "000000453c04c1dc6925704c396573cbf627c3c35134d4cae38495d959412ae3", "blockheight": 561917, "blockindex": 1, "confirmations": 29, "time": 1606035418, "blocktime": 1606035418}</code>
|}

----

====getstakedifficulty====
{|
!Method
|getstakedifficulty
|-
!Parameters
|None
|-
!Description
|Returns the proof-of-stake difficulty.
|-version
!Returns
|<code>(json object)</code>
: <code>current</code>: <code>(numeric)</code> The current top block's stake difficulty.
: <code>next</code>: <code>(numeric)</code> The calculated stake difficulty of the next block.
|-
!Example Return
|<code>{"current": 131.13416327,"next": 131.13416327}</code>
|}

----

====getstakeversioninfo====
{|
!Method
|getstakeversioninfo
|-
!Parameters
|
# <code>count</code>: <code>(numeric)</code> Number of intervals to return.
|-
!Description
|Returns stake version statistics for one or more stake version intervals.
|-
!Returns
|<code>(json object)</code>
: <code>currentheight</code>: <code>(numeric)</code> Top of the chain height.
: <code>hash</code>: <code>(string)</code> Top of the chain hash.
: <code>intervals</code>: <code>(json array)</code> Array of total stake and vote counts.
:: <code>startingheight</code>: <code>(numeric)</code> Start of the interval.
:: <code>endheight</code>: <code>(numeric)</code> End of the interval.
:: <code>posversions</code>: <code>(numeric)</code> Tally of all stake versions.
:: <code>voteversions</code>: <code>(numeric)</code> Tally of all vote versions.
:: <code>count</code>: <code>(numeric)</code> Number of votes.
:: <code>version</code>: <code>(numeric)</code> Version of the vote.
|-
!Example Return
|<code>{"currentheight": 374702,"hash": "000000000000000002dc20112532524e9224949c2e5ac94b418532552e3e9a26","intervals": [{"startheight": 373024,"endheight": 374702,"posversions": [{"version": 6,"count": 1679}],"voteversions": [{"version": 5,"count": 390},{"version": 6,"count": 7912}]}]}</code>
|}

----

====getstakeversions====
{|
!Method
|getstakeversions
|-
!Parameters
|
# <code>hash</code>: <code>(string, required)</code> The start block hash.
# <code>count</code>: <code>(numeric, required)</code> The number of blocks that will be returned.
|-
!Description
| Returns the stake versions statistics.
|-
!Returns
|
<code>stakeversions</code>: <code>(array of object)</code> Array of stake versions per block.
: <code>hash</code>: <code>(string)</code> hash of the block.
: <code>height</code>: <code>(numeric)</code> Height of the block.
: <code>blockversion</code>: <code>(numeric)</code> the block version.
: <code>stakeversion</code>: <code>(numeric)</code> the stake version of the block.
: <code>votes</code>: <code>(array of object)</code> the version and bits of each vote in the block.
: <code>version</code>: <code>(numeric)</code> the version of the vote.
: <code>bits</code>: <code>(numeric)</code> the bits assigned by the vote.
<code>{"stakeversions": [{ "hash": "value", "height": n, "blockversion": n, "stakeversion": n,"votes": [{ "version": n, "bits": n },...]},...]}</code>
|}

----

====getticketpoolvalue====
{|
!Method
|getticketpoolvalue
|-
!Parameters
|None
|-
!Description
| Returns the current value of all locked funds in the ticket pool.
|-
!Returns
|<code>numeric</code>
|-
!Example Return
|<code>5214124.18608402</code>
|}

----

====gettreasurybalance====
{|
!Method
|gettreasurybalance
|-
!Parameters
|
# <code>hash</code>: <code>(string, optional)</code> Return the treasury balance at the specified block. If unspecified, return the balance for the current tip block.
# <code>verbose</code>: <code>(bool, optional)</code> Whether to fill the <code>updates</code> field of the response. Defaults to false.
|-
!Description
| Returns the matured balance of the network's treasury account. It optionally also returns the individual balance-changing amounts (treasury base, add and spend transactions) for the block.
|-
!Returns
|
<code>(json object)</code>
: <code>hash</code>: <code>(string)</code> Block hash for which the balance was fetched.
: <code>height</code>: <code>(numeric)</code> Block height for which the balance was fetched.
: <code>balance</code>: <code>(numeric)</code> Balance (in atoms) of mature funds of the treasury account.
: <code>updates</code>: <code>(json array of numeric)</code>: Individual amounts that affect the treasury balance in the given block. Amounts corresponding to treasury spend transactions will be negative. Only filled if <code>verbose</code> is specified.
|-
!Example Return
|<code>{"hash": "00000000000000001605faff0827dafcea7d0986cf0aad06e87eccf9e02ff441","height": 428944,"balance": 1923209183818,"updates":[157007970,19200000000,-1892811207]}</code>
|}

----

====gettreasuryspendvotes====
{|
!Method
|gettreasuryspendvotes
|-
!Parameters
|
# <code>blockhash</code>: <code>(string, optional)</code> Count treasury spend votes up to this block. If unspecified, the current chain tip is used.
# <code>tspends</code>: <code>(json array of strings, optional)</code> A list of treasury spend transaction hashes for which to tally votes. All specified hashes must correspond to either mined or mempool residing tspends. If unspecified, defaults to tallying votes for all tspends currently in the mempool.
|-
!Description
| Returns a tally of on-chain votes for treasury spend transactions.
|-
!Returns
|
<code>(json object)</code>
: <code>hash</code>: <code>(string)</code> The block hash of the block up to which the votes were tallied.
: <code>height</code>: <code>(numeric)</code> The block height of the block up to which the votes were tallied.
: <code>votes</code>: <code>(json array of objects)</code> Per-tspend vote counts.
:  <code>hash</code>: <code>(string)</code> Hash of the treasury spend transaction.
:  <code>expiry</code>: <code>(numeric)</code> Expiry value for the tspend tx.
:  <code>votestart</code>: <code>(numeric)</code> Block height at which voting for the tspend starts.
:  <code>voteend</code>: <code>(numeric)</code> Block height at which voting for the tspend ends.
:  <code>yesvotes</code>: <code>(numeric)</code> Number of <code>yes</code> votes the tspend received (up to the height returned in the main response object).
:  <code>novotes</code>: <code>(numeric)</code> Number of <code>no</code> votes the tspend received (up to the height returned in the main response object).
|-
!Example Return
|<code>{"hash": "00000000000000001605faff0827dafcea7d0986cf0aad06e87eccf9e02ff441","height":428944,"votes": [{"hash": "f9d40601f4156dbdf7b310da9f5751488d9e531cf26151782642cd47efa4b732","expiry": 432290,"votestart": 428832,"voteend": 432288,"yesvotes":392,"novotes":91}]}</code>
|}

----

====gettxout====
{|
!Method
|gettxout
|-
!Parameters
|
# <code>txid</code>: <code>(string, required)</code> The hash of the transaction.
# <code>vout</code>: <code>(numeric, required)</code> The index of the output.
# <code>tree</code>: <code>(numeric, required)</code> The tree of the transaction.
# <code>includemempool</code>: <code>(string,default=true)</code> Include the mempool when true.
|-
!Description
|
: Returns information about an unspent transaction output.
: Returns <code>null</code> if the output is spent or never existed.
|-
!Returns
|<code>(json object)</code>
: <code>bestblock</code>: <code>(string)</code> The block hash that contains the transaction output.
: <code>confirmations</code>: <code>(numeric)</code> The number of confirmations.
: <code>value</code>: <code>(numeric)</code> The transaction amount in DCR.
: <code>scriptpubkey</code>: <code>(json object)</code> The public key script used to pay coins as a JSON object.
:: <code>asm</code>: <code>(string)</code> Disassembly of the script.
:: <code>hex</code>: <code>(string)</code> Hex-encoded bytes of the script. Omitted if empty.
:: <code>reqSigs</code>: <code>(numeric)</code> The number of required signatures. Omitted if empty.
:: <code>type</code>: <code>(string)</code> The type of the script (e.g. 'pubkeyhash').
:: <code>addresses</code>: <code>(json array of strings)</code> The Decred addresses associated with this script. Omitted if empty.
:: <code>commitamt</code>: <code>(numeric)</code> The ticket commitment value if the script is for a staking commitment. Omitted if empty.
:: <code>version</code>: <code>(string)</code> The script version.
: <code>coinbase</code>: <code>(numeric)</code> Whether or not the transaction is a coinbase.
|-
!Example Return
|<code>{"bestblock": "00000000000000001914563fe4f93addae64cd2808a81835ae03b0947034843b","confirmations": 19,"value": 4.63835862,"scriptPubKey": {"asm": "OP_DUP OP_HASH160 f127302adf84741d28fa705a995dc827030077e5 OP_EQUALVERIFY OP_CHECKSIG","hex": "76a914f127302adf84741d28fa705a995dc827030077e588ac","reqSigs": 1,"type": "pubkeyhash","addresses": ["Dsnx1HW62otMif9zFyLzDnQdKuaV9cRNoyr"],"version": 0},"coinbase": false}</code>
|}

----

====gettxoutsetinfo====
{|
!Method
|gettxoutsetinfo
|-
!Parameters
|None
|-
!Description
| Returns statistics on current unspent transaction output set.
|-
!Returns
|<code>(json object)</code>
: <code>height</code>: <code>(numeric)</code> The current block height.
: <code>bestblock</code>: <code>(numeric)</code> The hex encoded hash of the best block.
: <code>transactions</code>: <code>(numeric)</code> The number of unique transactions referenced by outputs.
: <code>txouts</code>: <code>(numeric)</code> The number of transaction outputs.
: <code>serializedhash</code>: <code>(string)</code> The merklized hash of the utxo set.
: <code>disksize</code>: <code>(numeric)</code> The size of the utxo set on disk, in bytes.
: <code>totalamount</code>: <code>(numeric)</code> The total value of the utxo set.
|-
!Example Return
|<code>{"height": 5,"bestblock": "00000f3ee4055640ac68e678351e96394e30807987aa769afcbe69200cd442d5","transactions": 5,"txouts": 16,"serializedhash": "34d660dd929fd7a7cefd43e8f0a24c1d32dc39a172c912594160817695159e9f","disksize": 293,"totalamount": 30140000000000}</code>
|}

----

====getvoteinfo====
{|
!Method
|getvoteinfo
|-
!Parameters
|
# <code>version</code>: <code>(numeric)</code> The stake version.
|-
!Description
| Returns the vote info statistics.
|-
!Returns
|<code>(json array)</code>
: <code>currentheight</code>: <code>(numeric)</code> Top of the chain height.
: <code>startheight</code>: <code>(numeric)</code> The start height of the voting window.
: <code>endheight</code>: <code>(numeric)</code> The end height of the voting window.
: <code>hash</code>: <code>(string)</code> The hash of the current height block.
: <code>voteversion</code>: <code>(numeric)</code> The selected vote version.
: <code>quorum</code>: <code>(numeric)</code> The minimum amount of votes required.
: <code>totalvotes</code>: <code>(numeric)</code> Total votes.
: <code>agendas</code>: <code>(json array)</code> All agendas for this stake version.
:: <code>id</code>: <code>(string)</code> Unique identifier of the agenda.
:: <code>description</code>: <code>(string)</code> Description of this agenda.
:: <code>mask</code>: <code>(numeric)</code> Agenda mask.
:: <code>starttime</code>: <code>(numeric)</code> Time agenda becomes valid.
:: <code>expiretime</code>: <code>(numeric)</code> Time agenda becomes invalid.
:: <code>status</code>: <code>(string)</code> Agenda status.
:: <code>quorumprogress</code>: <code>(numeric)</code> Progress of quorum reached.
:: <code>choices</code>: <code>(json array)</code> All choices in the agenda.
::: <code>id</code>: <code>(string)</code> Unique identifier of the choice.
::: <code>description</code>: <code>(string)</code> Unique identifier of the choice.
::: <code>bits</code>: <code>(numeric)</code> Bits that identify the choice.
::: <code>isabstain</code>: <code>(boolean)</code> This choice is to abstain from change.
::: <code>isno</code>: <code>(boolean)</code> Hard no choice (1 and only 1 per agenda).
::: <code>count</code>: <code>(numeric)</code> How many votes received.
::: <code>progress</code>: <code>(numeric)</code> Progress of the overall count.
|-
!Example Return
|<code>{"currentheight": 374709,"startheight": 366976,"endheight": 375039,"hash": "00000000000000001ff9abe7300929d1a0ce8cca0d3a57e201336af82be3330e","voteversion": 5,"quorum": 4032,"totalvotes": 1835,"agendas": [{"id": "lnfeatures","description": "Enable features defined in DCP0002 and DCP0003 necessary to support Lightning Network (LN)","mask": 6,"starttime": 1505260800,"expiretime": 1536796800,"status": "active","quorumprogress": 0,"choices": [{"id": "abstain","description": "abstain voting for change","bits": 0,"isabstain": true,"isno": false,"count": 0,"progress": 0},{"id": "no","description": "keep the existing consensus rules","bits": 2,"isabstain": false,"isno": true,"count": 0,"progress": 0},{"id": "yes","description": "change to the new consensus rules","bits": 4,"isabstain": false,"isno": false,"count": 0,"progress": 0}]}]}</code>
|}

----

====getwork====
{|
!Method
|getwork
|-
!Parameters
|
# <code>data</code>: <code>(string, optional)</code> The hex
|-
!Description
|Returns information about a transaction given its hash.
|-
!Notes
|Since dcrd does not have the wallet integrated to provide payment addresses, dcrd must be configured via the <code>--miningaddr</code> option to provide which payment addresses to pay created blocks to for this RPC to function.
|-
!Returns (data not specified)
|
<code>(json object)</code>
: <code>data</code>: <code>(string)</code> hex-encoded block data
: <code>target</code>: <code>(string)</code> the hex-encoded little-endian hash target

<code>{"data": "hex", "target": "hex"}</code>
|-
!Returns (data specified)
|<code>true</code> or <code>false</code> (boolean)
|-
!Example Return (data not specified)
|<code>{"data": "00000002c39b5d2b7a1e8f7356a1efce26b24bd15d7d906e85341ef9cec99b6a000000006474f...", "target": "0000000000000000000000000000000000000000000000008c96010000000000"}</code>
|-
!Example Return (data specified)
|<code>true</code>
|}

----

====help====
{|
!Method
|help
|-
!Parameters
|
# <code>command</code>: <code>(string, optional)</code> the command to get help for
|-
!Description
|
: Returns a list of all commands or help for a specified command.
: When no <code>command</code> parameter is specified, a list of available commands is returned
: When <code>command</code> is a valid method, the help text for that method is returned.
|-
!Returns
|<code>string</code>
|-
!Example Return
|
: getblockcount
: Returns a numeric for the number of blocks in the longest block chain.
|}

----

====invalidateblock====
{|
!Method
|invalidateblock
|-
!Parameters
|
# <code>block hash</code>: <code>(string, required)</code> the hash of the block to invalidate
|-
!Description
|
: Permanently invalidates a block as if it had violated consensus rules.
: Use [[#reconsiderblock|reconsiderblock]] to remove the invalid status.
|-
!Returns
|Nothing
|}

----

====livetickets====
{|
!Method
|livetickets
|-
!Parameters
|None
|-
!Description
| Returns live ticket hashes from the ticket database.
|-
!Returns
|<code>(json object)</code>
: <code>tickets</code>: <code>(json array)</code> List of live tickets.
|-
!Example Return
|<code>{"tickets": ["12ce6a03ce0d449cd88f2c0b6796d746be2f2902aedcc2829b9279ce27020ef4","325742e8037cfa2f76e32ed337978cc845001c9a0aeccb387186a6119ea510f4",...]}</code>
|}

----

====node====
{|
!Method
|node
|-
!Parameters
|
# <code>subcmd</code>: <code>(string, required)</code> <code>disconnect</code> to remove all matching non-persistent peers, <code>remove</code> to remove a persistent peer, or <code>connect</code> to connect to a peer.
# <code>target</code>: <code>(string, required)</code> Either the IP address and port of the peer to operate on, or a valid peer ID.
# <code>connectsubcmd</code>: <code>(string)</code> <code>perm</code> to make the connected peer a permanent one, <code>temp</code> to try a single connect to a peer.
|-
!Description
|Attempts to add or remove a peer.
|-
!Returns
|Nothing
|}

----

====ping====
{|
!Method
|ping
|-
!Parameters
|None
|-
!Description
|
: Queues a ping to be sent to each connected peer.
: Ping times are provided by [[#getpeerinfo|getpeerinfo]] via the <code>pingtime</code> and <code>pingwait</code> fields.
|-
!Returns
|Nothing
|-
|}

----

====reconsiderblock====
{|
!Method
|reconsiderblock
|-
!Parameters
|
# <code>block hash</code>: <code>(string, required)</code> the hash of the block to reconsider
|-
!Description
|
: Reconsiders a block for validation and best chain selection by removing any invalid status from it and its ancestors.
: Any descendants that are neither themselves marked as having failed validation, nor descendants of another such block, are also made eligibile for best chain selection.
|-
!Returns
|Nothing
|}

----

====regentemplate====
{|
!Method
|regentemplate
|-
!Parameters
|None
|-
!Description
|Asks the daemon to regenerate the block mining template. Note that template generation is an asynchronous process and some situations (such as the node performing a reorg or waiting for remaining votes after a new block was connected to the main chain) might delay template regeneration.
|-
!Returns
|Nothing
|-
|}

----

====sendrawtransaction====
{|
!Method
|sendrawtransaction
|-
!Parameters
|
# <code>signedhex</code>: <code>(string, required)</code> serialized, hex-encoded signed transaction.
# <code>allowhighfees</code>: <code>(boolean, optional, default=false)</code> whether or not to allow insanely high fees.
|-
!Description
|Submits the serialized, hex-encoded transaction to the local peer and relays it to the network.
|-
!Returns
|<code>"hash" (string) the hash of the transaction</code>
|-
!Example Return
|<code>"1697a19cede08694278f19584e8dcc87945f40c6b59a942dd8906f133ad3f9cc"</code>
|}

----

====setgenerate====
{|
!Method
|setgenerate
|-
!Parameters
|
# <code>generate</code>: <code>(boolean, required)</code> set to <code>true</code> to enable generation, <code>false</code> to disable it.
# <code>genproclimit</code>: <code>(numeric, optional)</code> the number of processors (cores) to limit generation to or <code>-1</code> for default.
|-
!Description
|Set the server to generate coins (mine) or not.
|-
!Notes
|NOTE: Since dcrd does not have the wallet integrated to provide payment addresses, dcrd must be configured via the <code>--miningaddr</code> option to provide which payment addresses to pay created blocks to for this RPC to function.
|-
!Returns
|Nothing
|-
|}

----

====stop====
{|
!Method
|stop
|-
!Parameters
|None
|-
!Description
|Shutdown dcrd.
|-
!Returns
|<code>"dcrd stopping."</code> <code>(string)</code>
|-
|}

----

====submitblock====
{|
!Method
|submitblock
|-
!Parameters
|
# <code>data</code>: <code>(string, required)</code> serialized, hex-encoded block.
# <code>params</code>: <code>(json object, optional, default=nil)</code> this parameter is currently ignored.
|-
!Description
|Attempts to submit a new serialized, hex-encoded block to the network.
|-
!Returns
|
: <code>Success</code>: Nothing.
: <code>Failure</code>: <code>(string)</code> <code>"rejected: reason"</code>
|-
|}

----

====ticketfeeinfo====
{|
!Method
|ticketfeeinfo
|-
!Parameters
|
# <code>blocks</code>: <code>(numeric)</code> The number of blocks, starting from the chain tip and descending, to return fee information about.
# <code>windows</code>: <code>(numeric)</code> The number of difficulty windows to return ticket fee information about.
|-
!Description
| Returns various information about ticket fees from the mempool, blocks, and difficulty windows (units: DCR/kB).
|-
!Returns
|<code>(json object)</code>
: <code>feeinfomempool</code>: <code>(json object)</code> Ticket fee information for all tickets in the mempool (units: DCR/kB).
:: <code>number</code>: <code>(numeric)</code> Number of transactions in the mempool.
:: <code>min</code>: <code>(numeric)</code> Minimum transaction fee in the mempool.
:: <code>max</code>: <code>(numeric)</code> Minimum transaction fee in the mempool.
:: <code>mean</code>: <code>(numeric)</code> Mean of transaction fees in the mempool.
:: <code>median</code>: <code>(numeric)</code> Median of transaction fees in the mempool.
:: <code>stddev</code>: <code>(numeric)</code> Standard deviation of transaction fees in the mempool.
: <code>feeinfoblocks</code>: <code>(json array)</code> Ticket fee information for a given list of blocks descending from the chain tip (units: DCR/kB).
:: <code>height</code>: <code>(numeric)</code> Height of the block.
:: <code>number</code>: <code>(numeric)</code> Number of transactions in the block.
:: <code>min</code>: <code>(numeric)</code> Minimum transaction fee in the block.
:: <code>max</code>: <code>(numeric)</code> Minimum transaction fee in the block.
:: <code>mean</code>: <code>(numeric)</code> Mean of transaction fees in the block.
:: <code>median</code>: <code>(numeric)</code> Median of transaction fees in the block.
:: <code>stddev</code>: <code>(numeric)</code> Standard deviation of transaction fees in the block.
: <code>feeinfowindows</code>: <code>(json array)</code> Ticket fee information for a window period where the stake difficulty was the same (units: DCR/kB).
:: <code>startheight</code>: <code>(numeric)</code> First block in the window (inclusive).
:: <code>endheight</code>: <code>(numeric)</code> Last block in the window (exclusive).
:: <code>number</code>: <code>(numeric)</code> Number of transactions in the window.
:: <code>min</code>: <code>(numeric)</code> Minimum transaction fee in the window.
:: <code>max</code>: <code>(numeric)</code> Minimum transaction fee in the window.
:: <code>mean</code>: <code>(numeric)</code> Mean of transaction fees in the window.
:: <code>median</code>: <code>(numeric)</code> Median of transaction fees in the window.
:: <code>stddev</code>: <code>(numeric)</code> Standard deviation of transaction fees in the window.
|-
!Example Return
|<code>{"feeinfomempool": {"number": 8,"min": 0.00010033,"max": 0.00100675,"mean": 0.00021377,"median": 0.00010052,"stddev": 0.00032041},"feeinfoblocks": [{"height": 374776,"number": 4,"min": 0.00010033,"max": 0.00100336,"mean": 0.00032619,"median": 0.00010055,"stddev": 0.00045144}],"feeinfowindows": [{"startheight": 374688,"endheight": 374777,"number": 474,"min": 0.00010033,"max": 0.00103381,"mean": 0.00011589,"median": 0.00010055,"stddev": 0.0001172}]}</code>
|}

----

====ticketsforaddress====
{|
!Method
|ticketsforaddress
|-
!Parameters
|
# <code>address</code>: <code>(string, required)</code> Address to look for.
|-
!Description
|Request all the tickets for an address.
|-
!Returns
|<code>(json object)</code>
: <code>tickets</code>: <code>(json array)</code> Tickets owned by the specified address.
|-
!Example Return
|<code>{"tickets":["f93c7fc34f72d546eabac791ea6b11d0fcaf7ec42e14045d8a837e4445a5b7ff","312a741b3c4a6bf8ead9071ddd16e539bcb0b2b13d6443dae617af35eec5cdff",...]}</code>
|}

----

====ticketvwap====
{|
!Method
|ticketvwap
|-
!Parameters
|
# <code>start</code>: <code>(numeric)</code> The start height to begin calculating the VWAP from.
# <code>end</code>: <code>(numeric)</code> The end height to begin calculating the VWAP from.
|-
!Description
|Calculate the volume weighted average price of tickets for a range of blocks (default: full PoS difficulty adjustment depth).
|-
!Returns
|<code>numeric</code> The volume weighted average price.
|-
!Example Return
|<code>129.59443029</code>
|}

----

====txfeeinfo====
{|
!Method
|txfeeinfo
|-
!Parameters
|
# <code>blocks</code>: <code>(numeric)</code> The number of blocks to calculate transaction fees for, starting from the end of the tip moving backwards.
# <code>rangestart</code>: <code>(numeric)</code> The start height of the block range to calculate transaction fees for.
# <code>rangeend</code>: <code>(numeric)</code> The end height of the block range to calculate transaction fees for.
|-
!Description
|Get various information about regular transaction fees from the mempool, blocks, and difficulty windows.
|-
!Returns
|<code>(json object)</code>
: <code>feeinfomempool</code>: <code>(json object)</code> Transaction fee information for all regular transactions in the mempool.
: <code>feeinfoblocks</code>: <code>(json array)</code> Transaction fee information for a given list of blocks descending from the chain tip.
: <code>feeinforange</code>: <code>(json object)</code> Transaction fee information for a window period where the stake difficulty was the same.
|-
!Example Return
|<code>{"feeinfomempool": {"number": 7,"min": 0.00010047,"max": 0.00010387,"mean": 0.00010166,"median": 0.00010096,"stddev": 0.00000146},"feeinfoblocks": [{"height": 374851,"number": 0,"min": 0,"max": 0,"mean": 0,"median": 0,"stddev": 0},{"height": 374850,"number": 7,"min": 0.00010038,"max": 0.00364651,"mean": 0.00060713,"median": 0.00010072,"stddev": 0.00134024}],"feeinforange": {"number": 670,"min": 0.00010018,"max": 0.03968253,"mean": 0.00033239,"median": 0.00010072,"stddev": 0.00235464}}</code>
|}

----

====validateaddress====
{|
!Method
|validateaddress
|-
!Parameters
|
# <code>address</code>: <code>(string, required)</code> Decred address.
|-
!Description
|Verify an address is valid.
|-
!Returns
|<code>(json object)</code>
: <code>isvalid</code>: <code>(bool)</code> whether or not the address is valid.
: <code>address</code>: <code>(string)</code> the Decred address validated.

<code>{"isvalid": true or false,"address": "decredaddress"}</code>
|}

----

====verifychain====
{|
!Method
|verifychain
|-
!Parameters
|
# <code>checklevel</code>: <code>(numeric, optional, default=3)</code> how in-depth the verification is (0=least amount of checks, higher levels are clamped to the highest supported level).
# <code>numblocks</code>: <code>(numeric, optional, default=288)</code> the number of blocks starting from the end of the chain to verify.
|-
!Description
|
:Verifies the block chain database. The actual checks performed by the <code>checklevel</code> parameter is implementation specific.
:For dcrd this is:
:: <code>checklevel=0</code> - Look up each block and ensure it can be loaded from the database.
:: <code>checklevel=1</code> - Perform basic context-free sanity checks on each block.
|-
!Notes
|dcrd currently only supports <code>checklevel</code> 0 and 1, but the default is still 3 for compatibility.  Per the information in the Parameters section above, higher levels are automatically clamped to the highest supported level, so this means the default is effectively 1 for dcrd.
|-
!Returns
|<code>(boolean)</code> <code>true</code> or <code>false</code>
|-
!Example Return
|<code>true</code>
|}

----

====verifymessage====
{|
!Method
|verifymessage
|-
!Parameters
|
# <code>address</code>: <code>(string, required)</code> The Decred address to use for the signature.
# <code>signature</code>: <code>(string, required)</code> The base-64 encoded signature provided by the signer.
# <code>message</code>: <code>(string, required)</code> The signed message.
|-
!Description
|Verify an address is valid.
|-
!Returns
|<code>(boolean)</code> Whether or not the signature verified.
|-
!Example Return
|<code>true</code>
|}

----

====version====
{|
!Method
|version
|-
!Parameters
|None
|-
!Description
|Returns the JSON-RPC API version (semver)
|-
!Returns
|<code>(json object)</code> Object containing the semantic versions of programs and API versions.
|-
!Example Return
|<code>{"dcrd": {"versionstring": "1.5.0-pre+dev","major": 1,"minor": 5,"patch": 0,"prerelease": "pre","buildmetadata": "dev.go1-12-9"},"dcrdjsonrpcapi": {"versionstring": "6.1.0","major": 6,"minor": 1,"patch": 0,"prerelease": "","buildmetadata": ""}}</code>
|}

----

==6. Websocket Methods (Websocket-specific)==

===6.1 Method Overview===

The following is an overview of the RPC method requests available exclusively to Websocket clients.  All of these RPC methods are available to the limited
user.  Click the method name for further details such as parameter and return information.

{|
!Method
!Description
!Notifications
|-
|[[#authenticate|authenticate]]
|Authenticate the connection against the username and passphrase configured for the RPC server. NOTE: This is only required if an HTTP Authorization header is not being used.
|None
|-
|[[#notifyblocks|notifyblocks]]
|Send notifications when a block is connected or disconnected from the best chain.
|[[#blockconnected|blockconnected]] and [[#blockdisconnected|blockdisconnected]]
|-
|[[#stopnotifyblocks|stopnotifyblocks]]
|Cancel registered notifications for whenever a block is connected or disconnected from the main (best) chain.
|None
|-
|[[#notifywork|notifywork]]
|Send notifications when a new block template is generated.
|[[#work|work]]
|-
|[[#stopnotifywork|stopnotifywork]]
|Cancel registered notifications for whenever a new block template is generated.
|None
|-
|[[#notifytspend|notifytspend]]
|Send notifications when a new tspend arrives in the mempool.
|[[#tspend|tspend]]
|-
|[[#stoptspend|stoptspend]]
|Cancel registered notifications for whenever when a new tspend arrives in the mempool.
|None
|-
|[[#loadtxfilter|loadtxfilter]]
|Load, add to, or reload a websocket client's transaction filter for mempool transactions, new blocks and [[#rescan|rescan]].
|[[#blockconnected|blockconnected]], [[#relevanttxaccepted|relevanttxaccepted]]
|-
|[[#rebroadcastwinners|rebroadcastwinners]]
|Asks the daemon to rebroadcast the winners of the voting lottery.
|[[#winningtickets|winningtickets]]
|-
|[[#rescan|rescan]]
|Rescan blocks for transactions matching the loaded transaction filter.
|None
|-
|[[#notifynewtransactions|notifynewtransactions]]
|Send notifications for all new transactions as they are accepted into the mempool.
|[[#txaccepted|txaccepted]] or [[#txacceptedverbose|txacceptedverbose]]
|-
|[[#stopnotifynewtransactions|stopnotifynewtransactions]]
|Stop sending either a txaccepted or a txacceptedverbose notification when a new transaction is accepted into the mempool.
|None
|-
|[[#notifywinningtickets|notifywinningtickets]]
|Send notifications for all tickets that are chosen to vote.
|[[#winningtickets|winningtickets]]
|-
|[[#notifynewtickets|notifynewtickets]]
|Send notifications for all new tickets that have matured.
|[[#newtickets|newtickets]]
|-
|[[#session|session]]
|Return details regarding a websocket client's current connection.
|None
|}

===6.2 Method Details===

====authenticate====
{|
!Method
|authenticate
|-
!Parameters
|
# <code>username</code>: <code>(string, required)</code>
# <code>passphrase</code>: <code>(string, required)</code>
|-
!Description
|Authenticate the connection against the username and password configured for the RPC server. Invoking any other method before authenticating with this command will close the connection.
NOTE: This is only required if an HTTP Authorization header is not being used.
|-
!Returns
|
<code>Success</code>: <code>Nothing</code>
<code>Failure</code>: <code>Nothing</code> <code>(websocket disconnected)</code>
|}

----

====notifyblocks====
{|
!Method
|notifyblocks
|-
!Notifications
|[[#blockconnected|blockconnected]] and [[#blockdisconnected|blockdisconnected]]
|-
!Parameters
|None
|-
!Description
|Request notifications for whenever a block is connected or disconnected from the main (best) chain.
|-
!Returns
|Nothing
|}

----

====stopnotifyblocks====
{|
!Method
|stopnotifyblocks
|-
!Notifications
|None
|-
!Parameters
|None
|-
!Description
|Cancel sending notifications for whenever a block is connected or disconnected from the main (best) chain.
|-
!Returns
|Nothing
|}

----

====notifywork====
{|
!Method
|notifywork
|-
!Notifications
|[[#work|work]]
|-
!Parameters
|None
|-
!Description
|Send notifications when a new block template is generated.
|-
!Returns
|Nothing
|}

----

====stopnotifywork====
{|
!Method
|stopnotifywork
|-
!Notifications
|None
|-
!Parameters
|None
|-
!Description
|Cancel sending notifications for whenever a new block template is generated.
|-
!Returns
|Nothing
|}

----

====notifytspend====
{|
!Method
|notifytspend
|-
!Notifications
|[[#tspend|tspend]]
|-
!Parameters
|None
|-
!Description
|Send notifications when a new tspend arrives in the mempool.
|-
!Returns
|Nothing
|}

----

====stopnotifytspend====
{|
!Method
|stopnotifytspend
|-
!Notifications
|None
|-
!Parameters
|None
|-
!Description
|Cancel sending notifications for whenever a new tspend arrives in the mempool.
|-
!Returns
|Nothing
|}

----

====loadtxfilter====
{|
!Method
|loadtxfilter
|-
!Notifications
|[[#blockconnected|blockconnected]], [[#relevanttxaccepted|relevanttxaccepted]]
|-
!Parameters
|
# <code>Reload</code>: <code>(boolean, required)</code> load a new filter instead of adding data to an existing one.
# <code>Addresses</code>: <code>(json array, required)</code> array of addresses to add to the transaction filter
# <code>Outpoints</code>: <code>(json array, required)</code> array of outpoints to add to the transaction filter.
|-
!Description
|Load, add to, or reload a websocket client's transaction filter for mempool transactions, new blocks and [[#rescan|rescan]].
|-
!Returns
|Nothing
|}

----

====rebroadcastwinners====
{|
!Method
|rebroadcastwinners
|-
!Parameters
|None
|-
!Description
|Asks the daemon to rebroadcast the winners of the voting lottery via a [[#winningtickets|winningtickets]] notification.
|-
!Returns
|Nothing
|-
|}

----

====rescan====
{|
!Method
|rescan
|-
!Notifications
|None
|-
!Parameters
|
# <code>Blockhashes</code>: <code>(JSON array, required)</code> array of block hashes to rescan.  Each subsequent block after the first one must be a child of the previous.
|-
!Description
|Rescan blocks for transactions matching the loaded transaction filter.
|-
!Returns
|
<code>(json object)</code>
: <code>discovereddata</code>: <code>(json array of objects)</code> The data matching the loaded transaction filter as JSON objects.
: <code>hash</code>: <code>(string)</code> The hash of the block containing matching transactions.
: <code>transactions</code>: <code>(json array)</code> Array of hex-encoded bytes of the serialized matching transactions.
: <code>serializedtx</code>: <code>(string)</code> hex-encoded bytes of the serialized transaction.

<code>{"discovereddata": [{"hash": "hash", "transactions": ["serializedtx", ...]}, ...]}</code>
|-
!Example Return
|<code>{"discovereddata": [{"hash": "0000002099417930b2ae09feda10e38b58c0f6bb44b4d60fa33f0e000000000000000000d53...", "transactions": ["493046022100cb42f8df44eca83dd0a727988dcde9384953e830b1f8004d57485e2ede1b9c8...", ...]}, ...]}</code>
|}

----

====notifynewtransactions====
{|
!Method
|notifynewtransactions
|-
!Notifications
|[[#txaccepted|txaccepted]] or [[#txacceptedverbose|txacceptedverbose]]
|-
!Parameters
|
# <code>verbose</code>: <code>(boolean, optional, default=false)</code> specifies which type of notification to receive.  If verbose is true, then the caller receives [[#txacceptedverbose|txacceptedverbose]], otherwise the caller receives [[#txaccepted|txaccepted]]
|-
!Description
|Send either a [[#txaccepted|txaccepted]] or a [[#txacceptedverbose|txacceptedverbose]] notification when a new transaction is accepted into the mempool.
|-
!Returns
|Nothing
|}

----

====stopnotifynewtransactions====
{|
!Method
|stopnotifynewtransactions
|-
!Notifications
|None
|-
!Parameters
|None
|-
!Description
|Stop sending either a [[#txaccepted|txaccepted]] or a [[#txacceptedverbose|txacceptedverbose]] notification when a new transaction is accepted into the mempool.
|-
!Returns
|Nothing
|}

----

====notifywinningtickets====
{|
!Method
|notifywinningtickets
|-
!Notifications
|[[#winningtickets|winningtickets]]
|-
!Parameters
|None
|-
!Description
|Send a winningtickets notification when tickets are chosen to vote.
|-
!Returns
|Nothing
|}

----

====notifynewtickets====
{|
!Method
|notifynewtickets
|-
!Notifications
|[[#newtickets|newtickets]]
|-
!Parameters
|None
|-
!Description
|Send a newtickets notification when new tickets have matured.
|-
!Returns
|Nothing
|}

----

====session====
{|
!Method
|session
|-
!Notifications
|None
|-
!Parameters
|None
|-
!Description
|Return a JSON object with details regarding a websocket client's current connection to the RPC server.  This currently only includes the session ID, a random unsigned 64-bit integer that is created for each newly connected client.  Session IDs may be used to verify that the current connection was not lost and subsequently reestablished.
|-
!Returns
|
<code>(json object)</code>
: <code>sessionid</code>: <code>(numeric)</code> the session ID.

<code>{"sessionid": n}</code>
|-
!Example Return
|<code>{"sessionid": 67089679842}</code>
|}

==7. Notifications (Websocket-specific)==

dcrd uses standard JSON-RPC notifications to notify clients of changes, rather than requiring clients to poll dcrd for updates.  JSON-RPC notifications are a subset of requests, but do not contain an ID.  The notification type is categorized by the <code>method</code> field and additional details are sent as a JSON array in the <code>params</code> field.

===7.1 Notification Overview===

The following is an overview of the JSON-RPC notifications used for Websocket connections.  Click the method name for further details of the context(s) in which they are sent and their parameters.

{|
!Method
!Description
!Request
|-
|[[#blockconnected|blockconnected]]
|Block connected to the main chain.
|[[#notifyblocks|notifyblocks]]
|-
|[[#blockdisconnected|blockdisconnected]]
|Block disconnected from the main chain.
|[[#notifyblocks|notifyblocks]]
|-
|[[#work|work]]
|New generated block template.
|[[#notifywork|notifywork]]
|-
|[[#tspend|tspend]]
|New generated tspend.
|[[#notifytspend|notifytspend]]
|-
|[[#txaccepted|txaccepted]]
|Received a new transaction after requesting simple notifications of all new transactions accepted into the mempool.
|[[#notifynewtransactions|notifynewtransactions]]
|-
|[[#txacceptedverbose|txacceptedverbose]]
|Received a new transaction after requesting verbose notifications of all new transactions accepted into the mempool.
|[[#notifynewtransactions|notifynewtransactions]]
|-
|[[#relevanttxaccepted|relevanttxaccepted]]
|Accepted a new transaction that matches the loaded transaction filter into the mempool.
|[[#loadtxfilter|loadtxfilter]]
|-
|[[#winningtickets|winningtickets]]
|Tickets were chosen to vote.
|[[#notifywinningtickets|notifywinningtickets]]
|-
|[[#newtickets|newtickets]]
|New tickets matured.
|[[#notifynewtickets|notifynewtickets]]
|}

===7.2 Notification Details===

====blockconnected====
{|
!Method
|blockconnected
|-
!Request
|[[#notifyblocks|notifyblocks]]
|-
!Parameters
|
# <code>Header</code>: <code>(string)</code> hex-encoded bytes of the attached serialized block header.
# <code>SubscribedTxs</code>: <code>(json array of string)</code> array of hex-encoded bytes of the serialized transactions that match the loaded transaction filter.
|-
!Description
|Notifies when a block has been added to the main chain.  Notification is sent to all connected clients.
|-
!Example
|Example blockconnected notification for mainnet block 280330:

: <code>{"jsonrpc": "1.0", "method": "blockconnected", "params": ["05000000be1e39c54738d534a55e6ee8d2fc62433857368041def11b000000000000000085d...",["01000000010a09cf6e9b4b7b77069cc829e68b5bc5b2b26d7d6698623a5f1e8439ea7f265f0..."]], "id": null}</code>
|}

----

====blockdisconnected====
{|
!Method
|blockdisconnected
|-
!Request
|[[#notifyblocks|notifyblocks]]
|-
!Parameters
|
# <code>Header</code>: <code>(string)</code> hex-encoded bytes of the disconnected serialized block header.
|-
!Description
|Notifies when a block has been removed from the main chain.  Notification is sent to all connected clients.
|-
!Example
|Example blockdisconnected notification for mainnet block 280330:

: <code>{"jsonrpc": "1.0","method": "blockdisconnected", "params": ["05000000be1e39c54738d534a55e6ee8d2fc62433857368041def11b000000000000000085d..."], "id": null}</code>
|}

----

====work====
{|
!Method
|work
|-
!Request
|[[#notifywork|notifywork]]
|-
!Parameters
|
# <code>Data</code>: <code>(string)</code> hex-encoded block data.
# <code>Target</code>: <code>(string)</code> the hex-encoded little-endian hash target.
# <code>Reason</code>: <code>(string)</code> the reason the new block template was generated.
|-
!Description
|Notifies a client when a new block template has been generated.
: The possible reasons are:
: <code>newparent</code> - The template builds on a new block as compared to the previous one.
: <code>newvotes</code> - A new vote for the block the template builds on has been received.
: <code>newtxns</code> - New non-vote transactions are available and have potentially been included.
|-
!Example
|Example work notification on testnet:

: <code>{"jsonrpc":"1.0","method":"work","params":["06000000c9ee7cd5b14b72e41195891a9617f80049eaac06a0dfe063479523060000000088087dbb59923da4faf632a29777805a7632efbd680b86f3c6cbbe3fddf905d45045d61784ad0810749cc045d03a7b9d5e8f6b2ed3ed767c9827f1dad4925771010082ebc7097cf5050007003b1400003b84061cff2d333700000000322400003f10000070b67b5b3bc400803b057900c5575400000000000000000000000000000000000000000000000000060000008000000100000000000005a0","000000000000000000000000000000000000000000000000003b840600000000","newparent"],"id":null}</code>
|}

----

====tspend====
{|
!Method
|tspend
|-
!Request
|[[#notifytspend|notifytspend]]
|-
!Parameters
|
# <code>TSpend</code>: <code>(string)</code> hex-encoded tspend transaction.
|-
!Description
|Notifies a client when a new tspend has arrived in the mempool.
|-
!Example
|Example tspend notification on simnet:

: <code>{"jsonrpc":"1.0","method":"tspend","params":["03000000010000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff0300000000000000000000226a203ff1461b188e100f6fed467eb9b12e2d10ed86446df6c3a99c1df4af159d39f70065cd1d0000000000001ac376a91449a6061cda6d9243cecf3186af60caefc613904988ac0027b9290000000000001ac376a9145722802cd0905b4589d2094fcb6b76f746dcf18988ac000000002200000001c29786470000000000000000ffffffff644039401cb6daacd3310cd282abcc04f92649a3f27d3fd9be2038c94d531addb2ced539a25dbb186fc4c572054d36d457b1416008ac11033175e31d68a5d97877d42102a36b785d584555696b69d1b2bbeff4010332b301e3edd316d79438554cacb3e7c2"],"id":null}</code>
|}

----

====txaccepted====
{|
!Method
|txaccepted
|-
!Request
|[[#notifynewtransactions|notifynewtransactions]]
|-
!Parameters
|
# <code>TxId</code>: <code>(string)</code> hex-encoded bytes of the transaction hash.
# <code>Amount</code>: <code>(numeric)</code> sum of the value of all the transaction outpoints.
|-
!Description
|Notifies when a new transaction has been accepted and the client has requested standard transaction details.
|-
!Example
|Example txaccepted notification for mainnet transaction id <code>16c54c9d02fe570b9d41b518c0daefae81cc05c69bbe842058e84c6ed5826261</code>:

: <code>{"jsonrpc": "1.0", "method": "txaccepted", "params": ["16c54c9d02fe570b9d41b518c0daefae81cc05c69bbe842058e84c6ed5826261", 55838384], "id": null}</code>
|}

----

====txacceptedverbose====
{|
!Method
|txacceptedverbose
|-
!Request
|[[#notifynewtransactions|notifynewtransactions]]
|-
!Parameters
|
# <code>RawTx</code>: <code>(json object)</code> the transaction as a json object (see getrawtransaction json object details).
|-
!Description
|Notifies when a new transaction has been accepted and the client has requested verbose transaction details.
|-
!Example
|
; For coinbase transactions
: <code>{"jsonrpc": "1.0", "method": "txacceptedverbose", "params": [{"hex": "01000000010000000000000000000000000000000000000000000000000000000000000000f...", "txid": "90743aad855880e517270550d2a881627d84db5265142fd1e7fb7add38b08be9", "version": 1, "locktime": 0, "vin": [{"coinbase": "03708203062f503253482f04066d605108f800080100000ea2122f6f7a636f696e4065757374726174756d2f", "sequence": 0}, ...], "vout": [{"value": 25.1394, "n": 0,"scriptPubKey": {"asm": "OP_DUP OP_HASH160 ea132286328cfc819457b9dec386c4b5c84faa5c OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914ea132286328cfc819457b9dec386c4b5c84faa5c88ac", "reqSigs": 1,"type": "pubkeyhash", "addresses": ["1NLg3QJMsMQGM5KEUaEu5ADDmKQSLHwmyh", ...]}]}], "id": null}</code>

; For non-coinbase transactions
: <code>{"jsonrpc": "1.0", "method": "txacceptedverbose", "params": [{"hex": "01000000010000000000000000000000000000000000000000000000000000000000000000f...", "txid": "90743aad855880e517270550d2a881627d84db5265142fd1e7fb7add38b08be9", "version": 1, "locktime": 0, "vin": [{"txid": "60ac4b057247b3d0b9a8173de56b5e1be8c1d1da970511c626ef53706c66be04","vout": 0, "scriptSig": {"asm": "3046022100cb42f8df44eca83dd0a727988dcde9384953e830b1f8004d57485e2ede1b9c8f0...", "hex": "493046022100cb42f8df44eca83dd0a727988dcde9384953e830b1f8004d57485e2ede1b9c8..."}, "sequence": 4294967295}, ...], "vout": [{"value": 25.1394, "n": 0,"scriptPubKey": {"asm": "OP_DUP OP_HASH160 ea132286328cfc819457b9dec386c4b5c84faa5c OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914ea132286328cfc819457b9dec386c4b5c84faa5c88ac", "reqSigs": 1,"type": "pubkeyhash", "addresses": ["1NLg3QJMsMQGM5KEUaEu5ADDmKQSLHwmyh", ...], "version": 0}]}], "id": null}</code>
|}

----

====relevanttxaccepted====
{|
!Method
|relevanttxaccepted
|-
!Request
|[[#loadtxfilter|loadtxfilter]]
|-
!Parameters
|
# <code>Transaction</code>: <code>(string)</code> hex-encoded bytes of the serialized transaction.
|-
!Description
|Notifies when a new transaction that matches the loaded transaction filter has been accepted to the mempool.
|-
!Example
|Example relevanttxaccepted notification for mainnet transaction id <code>6364bb003155a5cc4dc89fb73dd50cb0fd58cafa65ee12ecc69b5f724313fead</code>:

: <code>{"jsonrpc": "1.0", "method": "relevanttxaccepted", "params": ["01000000010a09cf6e9b4b7b77069cc829e68b5bc5b2b26d7d6698623a5f1e8439ea7f265f0..."], "id": null}</code>
|}

----

====winningtickets====
{|
!Method
|winningtickets
|-
!Request
|[[#notifywinningtickets|notifywinningtickets]]
|-
!Parameters
|
# <code>BlockHash</code>: <code>(string)</code> the hash of the block.
# <code>BlockHeight</code>: <code>(numeric)</code> the height of the block.
# <code>Tickets</code>: <code>(object)</code> the tickets chosen to vote.
|-
!Description
|Notifies a client when tickets are chosen to vote.
|-
!Example
|Example notifywinningtickets notification for block 479903 on testnet:
: <code>{"jsonrpc": "1.0", "method": "winningtickets", "params": ["00000044a6c0e2fb8f4feae2ac1133443859407abcf27d5d3a29d7d16eda8bc4", 479903, {"0": "37bb1218876ed8d11497130e253e98f7fd75546744aa9d209e40b97dd5ac735f", "1": "05ad6ce380d97f254c9c60669e9a33d044fccb5589789128abf7ca8c113159d3", "2": "0c43fa8b907acff3d35d81655b3c0a6ae41904ddd939f81b48e5df8d89c6283c", "3": "f2e544178e9e2a4473114b7bf0c383808eadf81f454fc11b835cd5083b0fae7e", "4": "c982fd8c7350df4781c0826c059e7675e6fb568cecee33d19f3a1b03aa41b1ce"}], "id": null}</code>
|}
----

====newtickets====
{|
!Method
|newtickets
|-
!Request
|[[#notifynewtickets|notifynewtickets]]
|-
!Parameters
|
# <code>Hash</code>: <code>(string)</code> the hash of the block.
# <code>Height</code>: <code>(numeric)</code> the height of the block.
# <code>StakeDiff</code>: <code>(numeric)</code> the stake difficulty of the block.
# <code>Tickets</code>: <code>(array of strings)</code> the new tickets that have matured.
|-
!Description
|Notifies a client when new tickets have matured.
|-
!Example
|Example newtickets notification for block 479903 on testnet:
: <code>{"jsonrpc": "1.0", "method": "newtickets", "params": ["00000044a6c0e2fb8f4feae2ac1133443859407abcf27d5d3a29d7d16eda8bc4", 479903, 9003800525, ["5297d32d5178c464c279711e771250f4f80a15830dfb89ae6bf414ee22613c88", "237c15fe027797d72c1ffd5aa3b3f9069b50352855bda5a9e7d0fa13d2299e32", "cd11ab320a543c946a021b37d5339a7f0ea72a6baf46fda455edf302165e812b", "eb82dba288e7af4a02a44818376f7228929c89a4fd51cf07ebdd825acc1c039d"]], "id": null}</code>
|}

==8. Example Code==

This section provides example code for interacting with the JSON-RPC API in
various languages.

* [[#81-example-go-code|Example Go Code]]
* [[#82-example-nodejs-code|Example node.js Code]]

===8.1 Example Go Code===

This section provides examples of using the RPC interface using Go and the
[https://github.com/decred/dcrd/tree/master/rpcclient rpcclient] package.

* [[#811-using-getblockcount-to-retrieve-the-current-block-height|Using getblockcount to Retrieve the Current Block Height]]
* [[#812-using-getblock-to-retrieve-the-genesis-block|Using getblock to Retrieve the Genesis Block]]
* [[#813-using-notifyblocks-to-receive-blockconnected-and-blockdisconnected-notifications-websocket-specific|Using notifyblocks to Receive blockconnected and blockdisconnected Notifications (Websocket-specific)]]

====8.1.1 Using getblockcount to Retrieve the Current Block Height====

The following is an example Go application which uses the
[https://github.com/decred/dcrd/tree/master/rpcclient rpcclient] package to connect with
a dcrd instance via Websockets, issues [[#getblockcount|getblockcount]] to
retrieve the current block height, and displays it.

<pre>
package main

import (
	"context"
	"log"
	"os"
	"path/filepath"

	"github.com/decred/dcrd/dcrutil/v4"
	"github.com/decred/dcrd/rpcclient/v8"
)

func main() {
	// Load the certificate for the TLS connection which is automatically
	// generated by dcrd when it starts the RPC server and doesn't already
	// have one.
	dcrdHomeDir := dcrutil.AppDataDir("dcrd", false)
	certs, err := os.ReadFile(filepath.Join(dcrdHomeDir, "rpc.cert"))
	if err != nil {
		log.Fatal(err)
	}

	// Create a new RPC client using websockets.  Since this example is
	// not long-lived, the connection will be closed as soon as the program
	// exits.
	connCfg := &rpcclient.ConnConfig{
		Host:         "localhost:9109",
		Endpoint:     "ws",
		User:         "yourrpcuser",
		Pass:         "yourrpcpass",
		Certificates: certs,
	}
	client, err := rpcclient.New(connCfg, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer client.Shutdown()

	// Query the RPC server for the current block count and display it.
	ctx := context.Background()
	blockCount, err := client.GetBlockCount(ctx)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Block count: %d", blockCount)
}
</pre>

Which results in:

<pre>
Block count: 203528
</pre>

====8.1.2 Using getblock to Retrieve the Genesis Block====

The following is an example Go application which uses the
[https://github.com/decred/dcrd/tree/master/rpcclient rpcclient] package to connect with
a dcrd instance via Websockets, issues [[#getblock|getblock]] to retrieve
information about the Genesis block, and display a few details about it.

<pre>
package main

import (
	"context"
	"log"
	"os"
	"path/filepath"
	"time"

	"github.com/decred/dcrd/chaincfg/chainhash"
	"github.com/decred/dcrd/dcrutil/v4"
	"github.com/decred/dcrd/rpcclient/v8"
)

func main() {
	// Load the certificate for the TLS connection which is automatically
	// generated by dcrd when it starts the RPC server and doesn't already
	// have one.
	dcrdHomeDir := dcrutil.AppDataDir("dcrd", false)
	certs, err := os.ReadFile(filepath.Join(dcrdHomeDir, "rpc.cert"))
	if err != nil {
		log.Fatal(err)
	}

	// Create a new RPC client using websockets.  Since this example is
	// not long-lived, the connection will be closed as soon as the program
	// exits.
	connCfg := &rpcclient.ConnConfig{
		Host:         "localhost:9109",
		Endpoint:     "ws",
		User:         "yourrpcuser",
		Pass:         "yourrpcpass",
		Certificates: certs,
	}
	client, err := rpcclient.New(connCfg, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer client.Shutdown()

	// Query the RPC server for the genesis block using the "getblock"
	// command with the verbose flag set to true and the verboseTx flag
	// set to false.
	ctx := context.Background()
	genesisHashStr := "298e5cc3d985bfe7f81dc135f360abe089edd4396b86d2de66b0cef42b21d980"
	blockHash, err := chainhash.NewHashFromStr(genesisHashStr)
	if err != nil {
		log.Fatal(err)
	}
	block, err := client.GetBlockVerbose(ctx, blockHash, false)
	if err != nil {
		log.Fatal(err)
	}

	// Display some details about the returned block.
	log.Printf("Hash: %v\n", block.Hash)
	log.Printf("Previous Block: %v\n", block.PreviousHash)
	log.Printf("Next Block: %v\n", block.NextHash)
	log.Printf("Merkle root: %v\n", block.MerkleRoot)
	log.Printf("Timestamp: %v\n", time.Unix(block.Time, 0).UTC())
	log.Printf("Confirmations: %v\n", block.Confirmations)
	log.Printf("Difficulty: %f\n", block.Difficulty)
	log.Printf("Size (in bytes): %v\n", block.Size)
	log.Printf("Num transactions: %v\n", len(block.Tx))
}
</pre>

Which results in:

<pre>
Hash: 298e5cc3d985bfe7f81dc135f360abe089edd4396b86d2de66b0cef42b21d980
Previous Block: 0000000000000000000000000000000000000000000000000000000000000000
Next Block: 000000000000437482b6d47f82f374cde539440ddb108b0a76886f0d87d126b9
Merkle root: 66aa7491b9adce110585ccab7e3fb5fe280de174530cca10eba2c6c3df01c10d
Timestamp: 2016-02-08 18:00:00 +0000 UTC
Confirmations: 203529
Difficulty: 32767.749998
Size (in bytes): 0
Num transactions: 1
</pre>

====8.1.3 Using notifyblocks to Receive blockconnected and blockdisconnected Notifications (Websocket-specific)====

The following is an example Go application which uses the
[https://github.com/decred/dcrd/tree/master/rpcclient rpcclient] package to connect with
a dcrd instance via Websockets and registers for
[[#blockconnected|blockconnected]] and [[#blockdisconnected|blockdisconnected]]
notifications with [[#notifyblocks|notifyblocks]].  It also sets up handlers for
the notifications.

<pre>
package main

import (
	"context"
	"log"
	"os"
	"path/filepath"
	"time"

	"github.com/decred/dcrd/dcrutil/v4"
	"github.com/decred/dcrd/rpcclient/v8"
)

func main() {
	// Setup handlers for blockconnected and blockdisconnected
	// notifications.
	ntfnHandlers := rpcclient.NotificationHandlers{
		OnBlockConnected: func(blockHeader []byte, transactions [][]byte) {
			log.Printf("Block connected: %x (%d txs)", blockHeader, len(transactions))

		},
		OnBlockDisconnected: func(blockHeader []byte) {
			log.Printf("Block disconnected: %x", blockHeader)
		},
	}

	// Load the certificate for the TLS connection which is automatically
	// generated by dcrd when it starts the RPC server and doesn't already
	// have one.
	dcrdHomeDir := dcrutil.AppDataDir("dcrd", false)
	certs, err := os.ReadFile(filepath.Join(dcrdHomeDir, "rpc.cert"))
	if err != nil {
		log.Fatal(err)
	}

	// Create a new RPC client using websockets.
	connCfg := &rpcclient.ConnConfig{
		Host:         "localhost:9109",
		Endpoint:     "ws",
		User:         "yourrpcuser",
		Pass:         "yourrpcpass",
		Certificates: certs,
	}
	client, err := rpcclient.New(connCfg, &ntfnHandlers)
	if err != nil {
		log.Fatal(err)
	}

	// Register for blockconnected and blockdisconneted notifications.
	ctx := context.Background()
	if err := client.NotifyBlocks(ctx); err != nil {
		client.Shutdown()
		log.Fatal(err)
	}

	// For this example, gracefully shutdown the client after 10 seconds.
	// Ordinarily when to shutdown the client is highly application
	// specific.
	log.Println("Client shutdown in 10 seconds...")
	time.AfterFunc(time.Second*10, func() {
		log.Println("Client shutting down...")
		client.Shutdown()
		log.Println("Client shutdown complete.")
	})

	// Wait until the client either shuts down gracefully (or the user
	// terminates the process with Ctrl+C).
	client.WaitForShutdown()
}
</pre>

Example output:

<pre>
Client shutdown in 10 seconds...
Block connected: 050000008478546af6812f4b3cb2148b5967b2dab78c3438d31821760f000000000000002c5f513f6ed478b90a7fc3525bbd64d16ab9b577c6b01861a1e9438f42e22ad95369522fdb6d393edf7eff3f0b33e93b60361fef1ec678843faae2caec0b782701003406e68c8961050013004aa00000e21668193dcd2d0302000000a21d03002bed00003b125d5a005fd38e00000000f1ea07e25fff20eb000000000000000000000000000000000000000005000000 (0 txs)
Client shutting down...
Client shutdown complete.
</pre>

===8.2. Example node.js Code===

====8.2.1 Using notifyblocks to be Notified of Block Connects and Disconnects====

The following is example node.js code which uses [https://github.com/einaros/ws ws]
(can be installed with <code>npm install ws</code>) to connect with a dcrd instance,
issues [[#notifyblocks|notifyblocks]] to register for
[[#blockconnected|blockconnected]] and [[#blockdisconnected|blockdisconnected]]
notifications, and displays all incoming messages.

This code has only been confirmed to work as of node.js 8.11.1 LTS.  It might
not work with earlier versions.

<pre>
var fs = require('fs');
var WebSocket = require('ws');

// Load the certificate for the TLS connection which is automatically
// generated by dcrd when it starts the RPC server and doesn't already
// have one.
var cert = fs.readFileSync('/path/to/dcrd/appdata/rpc.cert');
var user = "yourusername";
var password = "yourpassword";


// Initiate the websocket connection.  The dcrd generated certificate acts as
// its own certificate authority, so it needs to be specified in the 'ca' array
// for the certificate to properly validate.
var ws = new WebSocket('wss://127.0.0.1:9109/ws', {
  headers: {
    'Authorization': 'Basic '+Buffer.from(user+':'+password).toString('base64')
  },
  cert: cert,
  ecdhCurve: 'secp521r1', // Required for node.js v8.11.1 LTS, not for v10.1.0.
  ca: [cert]
});
ws.on('open', function() {
    console.log('CONNECTED');
    // Send a JSON-RPC command to be notified when blocks are connected and
    // disconnected from the chain.
    ws.send('{"jsonrpc":"1.0","id":"0","method":"notifyblocks","params":[]}');
});
ws.on('message', function(data, flags) {
    console.log(data);
});
ws.on('error', function(derp) {
  console.log('ERROR:' + derp);
})
ws.on('close', function(data) {
  console.log('DISCONNECTED');
})
</pre>
