Commands

The Qtum 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 Qtum 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 qtumd server wallet or given to the qtum-qt desktop GUI (Graphical User Interface) wallet using the Debug window Console command line (see Figure 1).

Figure 1. The qtum-qt Console

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 qtumd, console commands are given using the Command Line Interface application qtum-cli on the system command line prompt (see Figure 2).

Figure 2. System command line prompt

You can always get a list of the current console commands using the help command (see Figure 3.)

Figure 3. The help command

Console Commands :hammer_and_wrench:

Console commands are given to a running Qtum Core wallet and provide additional information and control. Console commands and are required to operate the qtumd 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 Qtum 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.

Advanced interfaces to the Qtum 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.

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 qtum-qt wallet with Help ñ Command line options:

Figure 4. Startup commands

and on the command line itself with "qtumd -?":

Figure 5. Startup commands from the command line

Console Commands A - Z

For these console commands documented below, responses are given for default parameters (Qtum version 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 qtum-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".

qtum-cli abortrescan
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 Qtum 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. Qtumd returns nothing:

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 qtumd 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. qtum-qt will returns "null", qtumd returns nothing. On Windows:

clearbanned

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:

createmultisig nrequired ["key",...]

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 big transaction fee.

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.

Wallet dump created by Qtum v0.16.1.0-0806c12c4-dirty
* Created on 2018-10-31T01:56:32Z
* Best block at time of backup was 241161 (b11d5169d66d39cbcd848e2ea3f9adfcee1c22af945f100aec9e762d88609e2e),
mined on 2018-10-31T01:55:28Z
extended private masterkey: <snip>

Wallet dump created by Qtum v0.16.2.0-47a30461d-dirty
* Created on 2018-12-16T02:22:59Z
* Best block at time of backup was 148510
(ca8a9457a69882b395bf56671e3661e148d3aca4a7b6c77398804229e7fb58f4),
mined on 2018-05-06T02:45:52Z
extended private masterkey: <snip>

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.

encryptwallet "you should always use a long and strong passphrase"

(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 qtum-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 qtum-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.

estimatefee 10
estimatefee is deprecated and will be fully removed in v0.17.

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.

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 QTUM each, plus an initial block, and listaddressgroupings shows the result:

getaccountaddress "account"

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.

getblockchaininfo

Returns information about the blockchain. Here "blocks" equals "headers", so this wallet is synced to the latest blocks. "moneysupply" gives the total QTUM created (genesis blocks + all block rewards). "size_on_disk" gives the local storage size for blocks.

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.

getinfo

Hidden command. DEPERCATED. Command line interfaces (but not the qtum-qt GUI wallet) may invoke this command using -getinfo. The wallet below has a computer clock in sync with Qtum network time (timeoffset = 0), has 8 peer connections, and is unlocked for a long time ("unlocked until" is Unix epoch time in seconds).

getnetworkhashps ( nblocks height )

DEPRECATED. Returns a network hash value related to block mining difficulty, which is not relevant to Qtum Proof of Stake, for which the network hashes per second is the total number of nodes divided by 16 seconds.

getnewaddress ( "account" "address_type" )

Get a new receiving address, with types "legacy", "p2sh-segwit" or "bech32". Qtum Mainnet legacy addresses start with a "Q", and SegWit addresses will start with an "M" for p2sh-segwit and "qc1" for bech32. Qtum Testnet legacy addresses start with a "q", and SegWit addresses will start with an "m" for p2sh-segwit and "tq1" for bech32. Here we get a new Mainnet SegWit bech32 address:

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 QTUM 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).

getreceivedbyaccount "MyAccount1"
14.21655439

getreceivedbyaddress "address" ( minconf )

Returns the total amount received by an address, including transactions that are spent or unspent.

getreceivedbyaddress QfWtnPq9M4a7Fmeeh6dyu0s4KR59F9xn
10.05630000

getstakinginfo

Returns staking-related information.

"enabled": true means the wallet was launched with staking allowed (command line option -staking=false was not used)

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.

getunconfirmedbalance

Get the unconfirmed balance for the wallet, which is the amount in transactions received by the wallet that havenít yet been published in blocks. Here the wallet has received 7.0 QTUM that haven't been confirmed in a block:

getunconfirmedbalance
7.00000000

getwalletinfo

Returns information about the wallet:

"walletname" - the name of the wallet.dat file currently loaded

"walletversion" - not the software client version, use getnetworkinfo to check this

"balance" - balance in QTUM

"stake" - any balance currently committed to a stake

"unconfirmed_balance" - any balance that hasnít been published in the next blocks

"immature_balance" - any coinbase (Proof of Work) balance that does not have 500 confirmations, seen only for regtest.

"txcount" - the total number of transactions in the wallet

"keypoololdest" - the Unix epoch timestamp in seconds for the oldest key in the key pool

"keypoolsize" - how many new keys are pre-generated

"keypoolsize_hd_internal" - how many new keys are pre-generated for internal use (used for change addresses)

"unlocked_until" - the Unix epoch time in seconds that the wallet is unlocked, or 0 if the wallet is locked, this field is omitted for unencrypted wallets.

"paytxfee" - the transaction fee in QTUM per 1,000 bytes

"hdmasterkeyid" - a Hash 160 of the hierarchical deterministic (HD) master public key, this field is omitted if HD is not enabled

help ( "command" )

Gives help and examples for a specific command or lists all the commands (without a parameter). The examples are formatted so you can copy and paste them for giving the command (replacing the parameters as appropriate).

importaddress "address" ( "label" rescan p2sh )

Adds a 34-character Qtum address or 66 hex character public key address that can be watched as if it were in your wallet but cannot be used to spend. The wallet will rescan after entering this command and should be backed up after adding addresses. Qtum-qt returns "null" and displays the "Watch-only" balance, qtumd returns nothing.

importaddress QaL29jcCZ39pWcA334dA4BN3peVhnc42D
null

importmulti "requests" ( "options" )

Import multiple addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning the blockchain for all the new addresses in a single pass. Optional time stamps can control how far back the scanning begins for each address. Requires a new wallet backup after addition of the addresses.

Here we import two watch only addresses and scan the blockchain from 00:00:00 hours GMT on June 1, 2018 (timestamp 1527811200). After entering the command, the wallet will take several minutes to rescan the blockchain for the new addresses:

importprivkey "qtumprivkey" ( "label" ) ( rescan )

Adds a WIF private key to your wallet, for example as returned by dumpprivkey or from another Qtum wallet. The wallet must be unlocked and requires a new wallet backup afterwards. The wallet will rescan for a few minutes to add any balance from the new address, and return "null" if successful.

importprunedfunds

Imports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.

Example TO COME.

importpubkey "pubkey" ( "label" rescan )

Adds a public key that can be watched as if it were in your wallet but cannot be used to spend. The public key is 66 characters hex, and can be obtained using the validateaddress command. After entering this command, the wallet will rescan for a few minutes, qtum-qt returns "null" and qtumd returns nothing. The wallet should be backed up after importing a public key.

importwallet "filename"

Imports keys from a wallet dump file (see dumpwallet). Requires a new wallet backup after this command. Use the full path to the dump file. Qtum-qt will show a status of "Importing" for a while, then "Scanning" as it rescans the blockchain. This command may take five minutes or more to return, and the wallet may appear to freeze during this time.

invalidateblock "blockhash"

Hidden command. Permanently marks a block as invalid, as if it violated a consensus rule. Used for software testing or in some rare manual blockchain forking scenarios. Use reconsiderblock to reverse this command. Returns "null" if successful.

keypoolrefill ( newsize )

Refills the key pool with new private keys, with a default size of 100. The normal size of the keypool is 1,000 and the wallet opportunistically fills the keypool as addresses are used, so this command should use a 1,100 size, etc., to be meaningful. The wallet must be unlocked. qtum-qt returns "null", qtumd returns nothing.

List all the transactions for your wallet since the given blockhash, or a list all the transactions since block 1 if blockhash is not given. The transactions below show a send and a receive transaction.

listwallets

Gives the currently loaded wallet.dat file, usually "wallet.dat" unless you can load a different file with "Restore Wallet".

listwallets
[
"wallet1132019.dat"
]

lockunspent unlock ([{"txid":"txid","vout":n},...])

Updates list of temporarily unspendable outputs. Temporarily lock (unlock=false as shown below) or unlock (unlock=true) the specified transaction outputs. If no transactions are specified when unlocking then all current locked transactions are unlocked.

A locked transaction output will not be chosen by automatic coin selection when spending QTUM.

Locks are stored in memory only. Wallets launch with zero locked outputs and the locked output list is always cleared (by virtue of process exit) when a wallet stops or fails. Also see the listunspent call.

logging ( )

Gets and sets the logging configuration for the debug.log file. When called without an argument, returns the list of categories with status that are currently being debug logged or not. When called with arguments, adds or removes categories from debug logging. The arguments are evaluated in order "include" then "exclude". If an item is both included and excluded, it will thus end up being excluded.

move "fromaccount" "toaccount" amount ( minconf "comment" )

DEPRECATED. Move a specified amount from one account in your wallet to another. Returns "true" if the command can be parsed, whether or not the accounts exist or the movement took place.

move "Test Addr" "LTCp2shsegwit" 1.1
true

ping

Requests that a ping be sent to other peers, to measure ping time. Results are provided in getpeerinfo, "pingtime" and "pingwait" fields are decimal seconds (does not provide a direct result like using "ping" from a system command prompt). The ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.

ping
null

preciousblock "blockhash"

Prioritizes a block with an earlier time for blocks at the same height. Used in hard fork situations. See also invalidateblock. qtum-qt returns "null" if successful, qtumd returns nothing if successful.

prioritisetransaction

Accepts the transaction into mined blocks at a higher (or lower) priority. A higher fee is not actually paid, the algorithm for selecting transactions into a block (which is trying to maximize fees) considers the transaction as having paid a higher fee. Qtum-qt and qtumd return "true":

pruneblockchain

Prune the blockchain up to a given block. Pruning removes spent transactions to reduce the storage size for the blockchain. Returns the last block pruned. The wallet must be launched in prune mode with disk working space reserved, at least 550 MB, here with 2 GB of working space:

qtum-qt.exe -prune=2000

Then you can give the command

pruneblockchain 125000
125000

Donít prune the blockchain if your wallet accepts incoming connections (over 8 peers) because your wallet needs to be able to send all the blocks to bootstrap new peers coming online.

reconsiderblock "blockhash"

Hidden command. Removes invalidity status of a block and its descendants, used for code testing or in manual blockchain reorganization. This command can reverse the effects of invalidateblock. Returns "null" if successful:

rescanblockchain ("start_height") ("stop_height")

Rescan the local blockchain for wallet transactions. An optional start height and stop height can be used, or by default scan the entire blockchain. This command will scan the blockchain for transactions of your wallet, and can be used if the wallet balance doesnít appear to be correct after a wallet restore or adding private keys. Returns the start and top height scanned.

resendwallettransactions

Hidden command. Immediately re-broadcast unconfirmed wallet transactions to all peers. The wallet periodically re-broadcasts automatically, so this can be used for testing. Here two transactions were resent after being stuck in the local mempool after restarting the wallet.

DEPRECATED (use sendtoaddress). Send an amount to a Qtum address, requires the wallet to be unlocked. The "account" is for notation, it does not control the source of UTXOs. If successful, returns the transaction ID.

Send to multiple addresses, requires the wallet to unlocked. Amounts are floating point in QTUM. Donít put blank spaces betweeen the parameters. If successful, returns a single transaction ID containing all the outputs. Here we send to two different addresses:

Send to multiple addresses, requires the wallet to be unlocked. Amounts are floating point in QTUM. Can send to duplicate addresses which sendmany canít do. If successful, returns a single transaction ID containing all the outputs. Here we send two transactions to the same address:

setaccount "address" "account"

DEPRECATED. Assigns and account name to the given address. Qtum-qt will return "null" if successful.

setaccount "QJv3YhWxG6EC2cpqZM5E3fjGzXYgakezm" "My New Account"
null

setban "subnet" "add|remove" (bantime) (absolute)

Attempts to add or remove an IP address from the banned list. Use "add" to add a ban, and give the duration of the ban in seconds. Returns "null" if successful. Here we add a ban for one day and confirm the result with listbanned:

setmocktime timestamp

Hidden command. Set the local time to given timestamp, only works for regtest. Give an epoch time in seconds, or 0 to go back to system time. The command line interface has no return.

docker exec myapp qcli setmocktime 1547319783

setnetworkactive true|false

Use to enable/disable peer network connections. Returns the network connection status. To disable the network connections:

setnetworkactive false
false

settxfee amount

Set the transaction fee per kilobyte of the transaction message. Overwrites the paytxfee parameter seen in getwalletinfo. The default minimum fee per 1,000 bytes is 0.004 QTUM. Returns true if successful.

settxfee 0.01
true

getwalletinfo would show "paytxfee": 0.01000000,

signmessage "address" "message"

Sign a message using the private key of an address, the wallet must be unlocked. Returns a base 64 signature hash.

verifytxoutproof "proof"

Verifies that a proof points to a transaction in a block, returning the transaction if found or giving an empty tring or error not found in the best chain. The "proof" is the hex string from gettxoutproof.

waitforblock (timeout)

Hidden command. Used to monitor when blockchain reloading has reached a given block. For command line interfaces like qtumd (not for the qtum-qt GUI wallet), the command returns after the given block is loaded. This example waits for Mainnet block 150,000:

waitforblockheight (timeout)

Hidden command. Waits for (at least) block height and returns the height and blockhash of the current tip (highest block). Returns the current block on timeout or exit. Timeout is given in milliseconds, 0 or default is no timeout. This command only works from the command line (not with the qtum-qt GUI wallet) and is used for development.

waitforlogs (fromBlock) (toBlock) (filter) (minconf)

requires -logevents to be enabled

Waits for a new logs and returns matching log entries. When the call returns, it also specifies the next block number to start waiting for new logs. By calling waitforlogs repeatedly using the returned nextBlock number, a client can receive a stream of up-to-date log entries.

This call is different from the similarly named searchlogs. This call returns individual matching log entries, searchlogs returns a transaction receipt if one of the log entries of that transaction matches the filter conditions.

minconf (uint, optional, default=6) Minimal number of confirmations before a log is returned

Example TO COME.

waitfornewblock (timeout)

Hidden command. Waits for a new block and returns the blockhash and height. Returns the current block on timeout or exit. This command works on command line only (not with the qtum-qt GUI wallet) and is used for development. The timeout parameter is given in milliseconds and 0 indicates no timeout.

walletlock

qtum-cli returns no response, but you can check with getwalletinfo for "unlocked_until": 0 and check the padlock icon on qtum-qt.

walletpassphrase "passphrase" timeout ( true )

Unlock an encrypted wallet for transactions which require use of a private key, such as sending coins, staking, or exporting private keys. Timeout gives the time in seconds to unlock and the optional Boolean "true" allows unlocking for staking only.

This command would unlock the wallet for 10 minutes:

walletpassphrase "you should always use a long and strong passphrase" 600

This command would unlock the wallet for staking only for a long time:

walletpassphrase "you should always use a long and strong passphrase" 99999999 true

The qtum-qt wallet will show lock status with the padlock icon and the Console returns "null". qtum-cli returns no status but you can check the unlock status with getwalletinfo for "unlocked_until":