Hydra Core Wallet Commands
The Hydra Core wallet has a rich set of commands which give comprehensive control of the wallet and blockchain transactions. There are two sets of commands that may be used with Hydra Core wallets:
Console commands are given to a wallet that is already running.
Startup commands are used when starting up a wallet.
This manual focuses on the console commands which are given to a wallet that is running and can be sent using RPC (Remote Procedure Calls) or on the command line to the hydrad server wallet or given to the Hydra-qt desktop GUI (Graphical User Interface) wallet using the Debug window Console command line (see Figure 1).
Note the warning message in red in Figure 1 and be careful using the private key commands (dumpprivkey
and dumpwallet
) with Mainnet wallets.
For the server wallet hydrad, console commands are given using the Command Line Interface application hydra-cli on the system command line prompt (see Figure 2).
You can always get a list of the current console commands using the help command (see Figure 3.)
Console Commands :hammer_and_wrench:
Console commands are given to a running Hydra Core wallet and provide additional information and control. Console commands and are required to operate the hydrad server wallet, which is a "headless" wallet with no graphical user interface.
There are 136 console commands with some good references for the 112 inherited from bitcoin. There are 13 "hidden" commands that are used by developers and won't show up in the "help" list.
Commands can have required or optional parameters and more numerous parameters are entered in JSON (JavaScript Object Notation) format with escaped double quotes ( \" ) as shown below.
Common parameters for these commands are Hydra addresses, block hashes, contract addresses, etc. Some of the commands will have an optional parameter "minconf" (minimum confirmations) which allows you to get a response for a transaction or block that has at least that number of confirmations.
The chain query bitcoin API reference http://chainquery.com/bitcoin-api explains the parameters and gives examples with responses for the commands inherited from bitcoin. The bitcoin chain query API reverence gives 67 commands, of which 2 are not in Hydra (estimatepriority
, getgenerate
) and two (gettransaction
, walletpassphrase
) have an additional parameter for Hydra. See also https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs.
Advanced interfaces to the Hydra Core wallet (full node) can use these "console commands" as RPCs (Remote Procedure Calls) over a dedicated port connection to the node. To build an exchange hot wallet or server node for a mobile DAPP (Distributed Application) you can use RPCs, which follow these same console commands. The client node offers a JSON-RPC interface over HTTP sockets to perform various operational functions and to manage the local node.
A quick comment on "accounts". Accounts was an ill-fated way from bitcoin to track balances for what are really UTXO transaction-based values, and "accounts" are deprecated and will be phased out by version 0.18.
Here are some command groupings that are useful for various tasks:
Peer connections:
getconnectioncount
,getpeerinfo
,addnodes
,getnetworkinfo
Staking:
getstakinginfo
,getwalletinfo
,getnetworkinfo
Sending:
listaddressgroupings
,sendtoaddress
,sendmany
,sendmanywithdupes
Raw transactions:
crearterawtransaction
,signrawtransaction
,combinerawtransactoins
,sendrawtransaction
Smart contract transactions:
createcontract
,callcontract
,sendtocontract
,getaccountinfo
,getstorage
,searchlogs
,waitforlogs
Startup Commands
Startup commands give additional control and recovery options when launching the wallet. For example, you can use startup commands for various kinds of blockchain recovery techniques, additional debug logging or additional controls. If you are going to use these startup commands, make sure you have a good backup of the wallet.dat file.
See the startup commands on the Hydra-qt wallet with Help - Command line options:
and on the command line itself with "Hydra -?":
Console Commands A - Z
For these console commands documented below, responses are given for default parameters (Hydraversion 0.16 - winter 2018/2019). Commands marked DEPRECATED should not be used because they will be removed and replaced in future versions of the wallet, for example, commands using "account" will be removed in version 0.18.
Using the command "help \" will give complete information about the command and relevant parameters, formatted in a way you can copy and paste (replacing the addresses, transactions IDs, etc., as required). The format below shows the command with parameters followed by the response, in some cases, parameters or responses are truncated with the term "\". Where noted, some commands only work with the regtest (Regression Test) network. Many commands will return "null" for Hydra-qt and return nothing for command line systems.
abandontransaction "txid"
Works on transactions not in the blockchain or mempool, used in testing.
abortrescan
Stops a wallet rescan triggered by a command such as importprivkey
. This command can be issued by opening a 2nd command line window (where the first window is scanning), in which case the command will stop the scan and return "true".
addmultisigaddress nrequired ["key",...] ( "account" "address_type" )
Add a multisignature address to the wallet so you can receive and send from that address. Run the command on each machine that will be signing and backup the wallet.dat file. The address can be a Hydra address or hex-encoded public key. Use importaddress
to add the multisig address on each signing wallet.
This functionality is only intended for use with non-watchonly addresses. See importaddress
for watchonly p2sh address support. Use of account is DEPRECATED). See also validateaddress
.
addnode "node" "add|remove|onetry"
Attempts to add a node with a known IP address. This command is useful for new wallets that are having trouble making peer connections. Here are some good IP addresses to add, you can put these commands in one after another, then the wallet will try for a few minutes to make a peer connection with each. Hydrad returns nothing:
Hydra-qt returns "null" after each (see Figure 6).
addwitnessaddress "address" ( p2sh )
Hidden command. DEPRECATED. This command was a way to generate a SegWit address from an existing legacy address, usually a P2SH-P2WPKH addresses - Pay-to-Witness-Public-Key-Hash (P2WPKH) script embedded in a Pay-to-Script-Hash (P2SH) address. This command is mostly disabled in version 0.16 and will be removed in version 0.17. Instead, use the getnewaddress
command with address type "p2sh-segwit" or "bech32".
Launch v 0.16 Hydrad with -deprecatedrpc=addwitnessaddress
to run the command:
backupwallet "destination"
The destination can be a filename or path with a filename. The wallet must be fully decrypted (not just for staking only) for this command to work. Hydra-qt will returns "null", Hydrad returns nothing. On Windows:
bumpfee "txid" ( options )
Bumps the fee of a transaction, replacing it with a new transaction by adjusting the change. The new fee can be calculated automatically or by using various options.
callcontract "address" "data" ( address )
Arguments:
"address" (string, required) The account address
"data" (string, required) The data hex string
address (string, optional) The sender address hex string
gasLimit (string, optional) The gas limit for executing the contract
TO COME
clearbanned
Clear all banned nodes IPs. Hydra-qt returns "null", hydrad gives no response.
combinerawtransaction ["hexstring",...]
Combine multiple partially signed raw transactions into one transaction. The combined transaction may be another partially signed transaction or a fully signed transaction. Here two raw transactions are combined:
createcontract "bytecode" (gaslimit gasprice "senderaddress" broadcast)
Publish a smart contract for the given bytecode, using default gas price of 0.00000040 and gas amount of 2,500,000. Returns the transaction ID and the contract address hash.
createmultisig nrequired ["key",...]
DEPRECATED. Use addmultisigaddress
.
createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,"data":"hex",...} ( locktime ) ( replaceable )
Create a hex-encoded raw transaction sending some inputs to outputs. The transaction must then be signed and sent to the network, see signrawtransaction
and sendrawtransaction
. Returns a hex-encoded raw transaction. If you are sending coins make sure to create a change address so the change can be returned; any difference between the input values and output values will be taken as the transaction fee.
If you don't work out the math you could pay a VERY HIGH transaction fee!
decoderawtransaction "hexstring" ( iswitness )
Gives the decoded data from a raw hex-encoded transaction. Here we decode the results from createrawtransaction
above.
decodescript "hexstring"
Decode a hex-encoded script, for example, decode the script for a mulitsig address:
disconnectnode "[address]" [nodeid]
Disconnects a peer (node) using either the IP address or node number. Hydra-qt will return "null", Hydra will return nothing.
dumpprivkey "address"
Displays the private key for a given address in WIF (Wallet Import Format). The wallet must be unlocked (and not for "staking only") for this command to work.
dumpwallet "filename"
Writes all the wallet private keys to a file in clear text (unencrypted) format. The wallet must be fully decrypted (not just for staking only) for this command to work. Returns the filename. Dumpwallet will save all the private keys and their addresses; it will not save watchonly addresses (which do not have private keys in the wallet). This file contains all the private keys in the wallet (1,000 or more), be very careful and do not store the dump file online.
On PC:
File:
On Mac:
File:
encryptwallet [passphrase]
Encrypts the wallet with "passphrase" for first-time encryption. After encryption, any calls that interact with private keys such as sending or signing will require passphrase entry to enable these functions. See also walletpassphrase
, walletlock
and walletpassphrasechange
. After this command runs, the wallet will shut down.
(wallet exits)
echo "message"
Hidden command. Simply echo back the input arguments. This command is for testing.
The difference between echo
and echojson
is that echojson
has argument conversion enabled in the client-side table in Hydra-cli and the GUI. There is no server-side difference. Here we echo the parameters used to setup a multisig address.
echojson "message"
Hidden command. Simply echo back the input arguments. This command is for testing.
The difference between echo
and echojson
is that echojson
has argument conversion enabled in the client-side table in Hydra-cli and the GUI. There is no server-side difference. Here we echo the parameters used to setup a multisig address.
estimatefee nblocks
DEPRECATED. Please use estimatesmartfee
for better estimates. Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within nblocks blocks.
estimaterawfee conf_target (threshold)
Hidden command. WARNING: This command is unstable and may disappear or change, and the results are tightly coupled to the calling parameters.
Gives fee estimates for short, medium, and long term confirmations, and gives mempool statistics for transactions with those fees. Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks.
estimatesmartfee conf_target ("estimate_mode")
Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks.
fromhexaddress "hexaddress"
Converts a raw hex address to a base 58 pubkeyhash address. Returns the base58 pubkeyhash address.
See gethexaddress
to convert a base58 pubkeyhash to a hex address.
fundrawtransaction "hexstring" ( options iswitness )
Select and add inputs to a transaction until it has enough in value to meet its out value. Collects one or more unspent transactions as inputs, and computes and specifies the change amount. Note that inputs which were signed may need to be resigned after completion since in/outputs have been added. The inputs added will not be signed, use signrawtransaction
for that.
generate nblocks ( maxtries )
Mine up to nblocks blocks immediately to an address in the wallet. Used with the regression test "regtest" private test blockchain. Can use generate 1
to publish waiting transactions in the next block, or generate 600
to initialize a new regtest blockchain.
generatetoaddress nblocks address (maxtries)
Mine up to nblocks immediately to a specified address. Used with the regression test "regtest" private test blockchain. Here we generate 10 genesis blocks on regtest with 20,000 Test Hydra each, plus an initial block, and listaddressgroupings
shows the result:
getaccount "address"
DEPRECATED. Returns the account name for a given address.
getaccountaddress "account"
DEPRECATED. Returns the current Hydra address for an account. Use the null account "" for the default address.
getaccountinfo "contract address hash"
Returns information about a contract including storage (the QRC20 balance for every address) and the code. The command may take several minutes to return, depending on the size of the storage (number of token holders). Here is the INK contract.
getaddednodeinfo ( "node" )
Returns information about nodes that have been manually added using the addnode
command.
getaddressesbyaccount "account"
DEPRECATED. Returns the list of addresses for the given account.
getbalance ( "account" minconf include_watchonly )
Get the balance in Hydra for a wallet.
getbestblockhash
Returns the block hash of the most recent block.
getblock "blockhash" ( verbosity )
Returns information about a block.
getblockchaininfo
Returns information about the blockchain. Here "blocks" equals "headers", so this wallet is synced to the latest blocks. "moneysupply" gives the total Hydra created (genesis blocks + all block rewards). "size_on_disk" gives the local storage size for blocks.
getblockcount
Returns the number of blocks in the main (longest with most difficulty) blockchain.
getblockhash height
Returns the hash of the main blockchain for the given block height (not an orphan block).
Returns hex or decoded data for the header of the given block hash.
getblocktemplate ( TemplateRequest )
Returns data needed to construct a block, and has a number of TemplateRequst parameters. The default (no TemplateReqest) gives:
getchaintips
Return information about all known tips in the block tree, including the main chain as well as orphaned branches. Will display chain tips since the wallet launched because only the main chain will be synced from other peers when this wallet launched. The status "active" is the mainchain, "valid-fork" are orphan blocks, and "valid headers" are not on the blockchain.
getchaintxstats ( nblocks blockhash )
Compute statistics about the total number and rate of transactions in the chain, where the default "window" is the last one month.
"time" gives the Unix timestamp for the last block in the window
"txcount" gives the total transactions from the launch of the blockchain
"window_block_count" gives the number of blocks in the window (675 TX/day * 30 days)
"window_interval" gives the window length in seconds
"txrate" gives the average transactions per second (TPS) in the window
getconnectioncount
Get the peer connection count for the wallet, typically 8 for outgoing only peer connections, or up to 125 for outgoing + incoming connections.
getdifficulty
Proof-of-stake difficulty gives the Proof of Stake consensus target from the most recent block (proof-of-work is not used after the genesis blocks).
gethexaddress "address"
Converts a base58 pubkeyhash address to a hex address for use in smart contracts, returns the hex address.
See fromhexaddress
to convert a hex address to base58 pubkeyhash.
getinfo
Hidden command. DEPERCATED. Command line interfaces (but not the hydra-qt GUI wallet) may invoke this command using -getinfo
. The wallet below has 8 peer connections, and is unlocked for a long time ("unlocked until" is Unix epoch time in seconds). Use getpeerinfo
to check computer clock compared to "timeoffset" for other peers in the network.
getmemoryinfo ("mode")
Gives information about memory usage.
getmempoolancestors txid (verbose)
If the given transaction is in the mempool, returns all its in-mempool ancestors.
getmempooldescendants txid (verbose)
If the given transaction is in the mempool, returns all its in-mempool descendants.
getmempoolentry txid
Get mempool data for a given transaction in the mempool.
getmempoolinfo
Returns details on the active state of the memory pool. Here a single transaction is waiting in the memory pool:
getmininginfo
Gives mining information including network weight ("netstakeweight" of 12.27 million shown below) and wallet weight ("stakeweight" of 107.6).
getnettotals
Gives the network traffic statistics since the wallet launched.
getnetworkhashps ( nblocks height )
DEPRECATED. Returns a network hash value related to block mining difficulty, which is not relevant to Hydra Proof of Stake, for which the network hashes per second is the total number of nodes divided by 16 seconds.
getnetworkinfo
Gives the parameters for IPv4, IPv6 and Tor (Onion) network connections. Use getpeerinfo
to check computer clock "timeoffset" to other peers in the network, not this value from getnetworkinfo
.
getnewaddress ( "account" "address_type" )
Get a new receiving address, with types "legacy", "p2sh-segwit" or "bech32". Hydra Mainnet legacy addresses start with an "H", and SegWit addresses will start with an "M" for p2sh-segwit and "qc1" for bech32. Hydra Testnet legacy addresses start with a "h", and SegWit addresses will start with an "m" for p2sh-segwit and "th1" for bech32. Here we get a new Mainnet SegWit bech32 address:
getpeerinfo
Gives information about the wallet peer connections. "timeoffset" values of mostly zero means the computer clock is set correctly for network time.
getrawchangeaddress ( "address_type" )
Returns a new address for receiving change with raw transactions, used for composing raw transactions. The address type may be "legacy", "p2sh-segwit" or "bech32".
getrawmempool ( verbose )
Get all the transactions waiting in the mempool.
getrawtransaction "txid" ( verbose "blockhash" )
Get the data from a transaction, either as raw hex data or formatted (use "true"). Here formatted data is shown.
The transaction above has one "vin" UTXO input which provides the previous transaction to be spent and two outputs "vout". The first output "vout" sends 300.685401 to a receiving address, the second sends 11769.78668720 Hydra to a change address. The difference in value between the inputs and outputs is the transaction fee.
getreceivedbyaccount "account" ( minconf )
DEPRECATED. Returns the total amount received for an account name, which could be spent or unspent transactions, for transactions with at least minconf confirmations (default is 1 confirmation).
getreceivedbyaddress "address" ( minconf )
Returns the total amount received by an address, including transactions that are spent or unspent.
getstakinginfo
Returns staking-related information.
"enabled": true means the wallet was launched with staking allowed (command line option
-staking=false
was not used)"staking": true means the wallet is staking (decrypted, mature coins, blockchain synced)
"errors" gives various errors (rare)
"currentblocktx" gives the number of transactions in a block mined by the wallet
"pooledtx" gives the number of transactions waiting in the mempool
"difficulty" gives the PoS target difficulty for the current block
"search-interval" gives either the time in seconds since the wallet began staking or the time since the wallet's most recent block reward, here one day and one minute
"weight" gives the wallet weight in Satoshis, move the decimal point eight digits to the left to give these weights in units, here wallet weight is 148 Hydra and the network weight is 12.23 million
"netstakeweight" gives the estimated network weight
"expected time" gives an estimate of the average expected time to a block reward in seconds, here 4.59 months
getstorage "contract address hash"
Get the storage used by a smart contract, may take 5 to 10 minutes to return. Here is the result for the Bodhi token contract. getaccountinfo
also returns smart contract storage, plus address, balance, and code.
getsubsidy [nTarget]
Returns subsidy (block reward) for the specified block height. Here we see the first block which will have a block reward of 2.0 Hydra.
gettransaction "txid" ( include_watchonly ) (waitconf)
Get detailed information about a transaction for an address in this wallet (send or receive). Here is a send transaction:
gettransactionreceipt "hash"
Returns details for a contract call transaction given the transaction ID (hash), requires -logevents
to be enabled for the wallet. Here is a contract call token transfer for Ocash: