Skip to main content

RPC Commands


Blockchain

getbestblockhash

Description

Returns the hash of the best (tip) block in the longest blockchain.

Parameters

None

Return Value

FieldTypeDescription
(return value)stringBlock hash (hex-encoded)

Example

$ bitcoin-cli getbestblockhash
48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60

getblock

Description

Get information about a specified block.

Parameters

ParameterTypeRequiredDefaultDescription
blockhashstringYes-Block hash
verbositynumeric/booleanNo10/false=hex data, 1/true=json with txid list, 2=json without tx list, 3=json with full tx details
auxpowbooleanNofalseIf true and verbosity=0, include auxpow data

Return Value (verbosity=1/2/3)

FieldTypeDescription
hashstringBlock hash
confirmationsnumericNumber of confirmations, -1 if not on main chain
sizenumericBlock size
heightnumericBlock height
versionnumericBlock version
versionHexstringBlock version (hex)
merklerootstringMerkle root
nTxnumericNumber of transactions
txarrayTransaction list (returned when verbosity=1 or 3)
timenumericBlock time (Unix timestamp)
mediantimenumericBlock median time
noncenumericNonce
bitsstringDifficulty target
difficultynumericDifficulty value
chainworkstringCumulative work (hex)
previousblockhashstringPrevious block hash
nextblockhashstringNext block hash

Example

$ bitcoin-cli getblock "48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60"
{
"hash": "48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60",
"confirmations": 1,
"size": 183,
"height": 10,
"version": 1,
"versionHex": "00000001",
"merkleroot": "e1bdf6a3ad092a07813428f27750d0baf4c14bcb581de76e6d97da5bffd03892",
"nTx": 1,
"tx": [
"e1bdf6a3ad092a07813428f27750d0baf4c14bcb581de76e6d97da5bffd03892"
],
"time": 1765964622,
"mediantime": 1765964621,
"nonce": 3,
"bits": "207fffff",
"difficulty": 4.656542373906925e-10,
"chainwork": "0000000000000000000000000000000000000000000000000000000000000016",
"previousblockhash": "04d99cdbf71516ae149ade1fccc4cb6905cb81d8673b756081e2f4ce9422350d"
}

getblockchaininfo

Description

Returns various state information about blockchain processing.

Parameters

None

Return Value

FieldTypeDescription
chainstringCurrent network name (main, test, regtest)
blocksnumericNumber of currently processed blocks
headersnumericNumber of currently validated headers
bestblockhashstringHash of the current best block
difficultynumericCurrent mining difficulty
mediantimenumericMedian time of the current best block
verificationprogressnumericVerification progress estimate [0..1]
chainworkstringTotal work in the active chain (hex)
prunedbooleanWhether block pruning is enabled
pruneheightnumericLowest complete block height stored (pruning mode only)
softforksarraySoft fork status

Example

$ bitcoin-cli getblockchaininfo
{
"chain": "regtest",
"blocks": 10,
"headers": 10,
"bestblockhash": "48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60",
"difficulty": 4.656542373906925e-10,
"mediantime": 1765964621,
"verificationprogress": 1,
"chainwork": "0000000000000000000000000000000000000000000000000000000000000016",
"pruned": false
}

getblockcount

Description

Returns the number of blocks in the longest blockchain.

Parameters

None

Return Value

FieldTypeDescription
(return value)numericCurrent block count

Example

$ bitcoin-cli getblockcount
10

getblockhash

Description

Returns the block hash at a specified height.

Parameters

ParameterTypeRequiredDefaultDescription
heightnumericYes-Block height

Return Value

FieldTypeDescription
(return value)stringBlock hash

Example

$ bitcoin-cli getblockhash 5
5bf2cebc8eddc499b700210ec0c891e9fbec6390eec45870fbc977fba85c225d

getblockheader

Description

Get header information for a specified block.

Parameters

ParameterTypeRequiredDefaultDescription
hashstringYes-Block hash
verbosebooleanNotruetrue returns json object, false returns hex data
auxpowbooleanNofalsetrue includes auxpow data in hex data

Return Value (verbose=true)

FieldTypeDescription
hashstringBlock hash
confirmationsnumericNumber of confirmations
heightnumericBlock height
versionnumericBlock version
versionHexstringBlock version (hex)
merklerootstringMerkle root
timenumericBlock time
mediantimenumericMedian time
noncenumericNonce
bitsstringDifficulty target
difficultynumericDifficulty value
chainworkstringCumulative work
nTxnumericNumber of transactions
previousblockhashstringPrevious block hash
nextblockhashstringNext block hash

Example

$ bitcoin-cli getblockheader "48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60"
{
"hash": "48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60",
"version": 1,
"versionHex": "00000001",
"merkleroot": "e1bdf6a3ad092a07813428f27750d0baf4c14bcb581de76e6d97da5bffd03892",
"time": 1765964622,
"nonce": 3,
"bits": "207fffff",
"difficulty": 4.656542373906925e-10,
"previousblockhash": "04d99cdbf71516ae149ade1fccc4cb6905cb81d8673b756081e2f4ce9422350d",
"confirmations": 1,
"height": 10,
"mediantime": 1765964621,
"chainwork": "0000000000000000000000000000000000000000000000000000000000000016",
"nTx": 1
}

getchaintips

Description

Returns information about all known branches in the block tree, including the main chain and orphan branches.

Parameters

None

Return Value

FieldTypeDescription
heightnumericHeight of the chain tip
hashstringTip block hash
branchlennumericLength of branch connecting to main chain (0 for main chain)
statusstringChain status: active, valid-fork, valid-headers, headers-only, invalid

Example

$ bitcoin-cli getchaintips
[
{
"height": 10,
"hash": "48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60",
"branchlen": 0,
"status": "active"
}
]

getchaintxstats

Description

Computes statistics about the total number and rate of transactions in the chain.

Parameters

ParameterTypeRequiredDefaultDescription
nblocksnumericNoOne month of blocksWindow size (number of blocks)
blockhashstringNoBest blockBlock hash at which the window ends

Return Value

FieldTypeDescription
timenumericTimestamp of the last block in the window
txcountnumericTotal number of transactions up to that point
window_block_countnumericNumber of blocks in the window
window_tx_countnumericNumber of transactions in the window
window_intervalnumericTime span of the window (seconds)
txratenumericAverage transaction rate in the window (per second)

Example

$ bitcoin-cli getchaintxstats 5
{
"time": 1765964622,
"txcount": 11,
"window_block_count": 5,
"window_tx_count": 5,
"window_interval": 1,
"txrate": 5
}

getdifficulty

Description

Returns the current proof-of-work difficulty.

Parameters

None

Return Value

FieldTypeDescription
(return value)numericDifficulty value (multiple of minimum difficulty)

Example

$ bitcoin-cli getdifficulty
4.656542373906925e-10

getmempoolancestors

Description

Returns all ancestor transactions of a specified transaction in the mempool.

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID
verbosebooleanNofalsetrue returns detailed json, false returns txid array

Return Value (verbose=false)

Array of transaction IDs

Return Value (verbose=true)

Detailed information object for each ancestor transaction

Example

$ bitcoin-cli getmempoolancestors "txid"

getmempooldescendants

Description

Returns all descendant transactions of a specified transaction in the mempool.

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID
verbosebooleanNofalsetrue returns detailed json, false returns txid array

Return Value (verbose=false)

Array of transaction IDs

Return Value (verbose=true)

Detailed information object for each descendant transaction

Example

$ bitcoin-cli getmempooldescendants "txid"

getmempoolentry

Description

Returns data about a specified transaction in the mempool.

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID

Return Value

FieldTypeDescription
sizenumericTransaction size
feenumericTransaction fee
modifiedfeenumericModified fee
timenumericTime entered mempool
heightnumericBlock height when entered mempool
descendantcountnumericNumber of descendant transactions
descendantsizenumericTotal size of descendant transactions
descendantfeesnumericTotal fees of descendant transactions
ancestorcountnumericNumber of ancestor transactions
ancestorsizenumericTotal size of ancestor transactions
ancestorfeesnumericTotal fees of ancestor transactions
dependsarrayDependent unconfirmed transactions

Example

$ bitcoin-cli getmempoolentry "txid"

getmempoolinfo

Description

Returns status information about the transaction mempool.

Parameters

None

Return Value

FieldTypeDescription
loadedbooleanWhether the mempool is loaded
sizenumericCurrent number of transactions
bytesnumericTotal size of transactions
usagenumericMempool memory usage
maxmempoolnumericMaximum mempool memory limit
mempoolminfeenumericMinimum fee rate to enter mempool

Example

$ bitcoin-cli getmempoolinfo
{
"loaded": true,
"size": 0,
"bytes": 0,
"usage": 0,
"maxmempool": 1000000000,
"mempoolminfee": 0.00000001
}

getrawmempool

Description

Returns IDs of all transactions in the mempool.

Parameters

ParameterTypeRequiredDefaultDescription
verbosebooleanNofalsetrue returns detailed json, false returns txid array

Return Value (verbose=false)

Array of transaction IDs

Return Value (verbose=true)

Detailed information object for each transaction (same as getmempoolentry)

Example

$ bitcoin-cli getrawmempool
[]

gettxout

Description

Returns details about a specified unspent transaction output (UTXO).

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID
nnumericYes-Output index
include_mempoolbooleanNotrueWhether to include transactions in the mempool

Return Value

FieldTypeDescription
bestblockstringBest block hash
confirmationsnumericNumber of confirmations
valuenumericAmount
scriptPubKeyobjectLocking script information
coinbasebooleanWhether it's a coinbase transaction

Example

$ bitcoin-cli gettxout "txid" 0

gettxoutproof

Description

Returns a hex-encoded proof that the specified transaction exists in a block.

Parameters

ParameterTypeRequiredDefaultDescription
txidsarrayYes-Array of transaction IDs
blockhashstringNo-Specified block hash

Return Value

FieldTypeDescription
(return value)stringHex-encoded proof data

Example

$ bitcoin-cli gettxoutproof '["txid"]'

gettxoutsetinfo

Description

Returns statistics about the unspent transaction output set.

Parameters

None

Return Value

FieldTypeDescription
heightnumericCurrent block height
bestblockstringBest block hash
transactionsnumericNumber of transactions
txoutsnumericNumber of outputs
bogosizenumericUTXO set size metric
hash_serializedstringSerialized hash
disk_sizenumericEstimated disk size
total_amountnumericTotal amount

Example

$ bitcoin-cli gettxoutsetinfo
{
"height": 10,
"bestblock": "48b8df92729431ee0e5b261f836f4c1c1aa28c6f579e50862e6fb64dc7431b60",
"transactions": 1,
"txouts": 1,
"bogosize": 85,
"hash_serialized": "680741b50ecf2646e4d9892bb9e64923ea4d17f8a9d83738bd649a6c52eb2dd8",
"disk_size": 0,
"total_amount": 20999950.00000000
}

preciousblock

Description

Treats the specified block as if it were received earlier, which may affect chain selection.

Parameters

ParameterTypeRequiredDefaultDescription
blockhashstringYes-Block hash

Return Value

None

Example

$ bitcoin-cli preciousblock "blockhash"

pruneblockchain

Description

Prunes the blockchain to a specified height.

Parameters

ParameterTypeRequiredDefaultDescription
heightnumericYes-Target height

Return Value

FieldTypeDescription
(return value)numericActual height pruned to

Example

$ bitcoin-cli pruneblockchain 1000

verifychain

Description

Verifies the blockchain database.

Parameters

ParameterTypeRequiredDefaultDescription
checklevelnumericNo3Verification level (0-4)
nblocksnumericNo6Number of blocks to check

Return Value

FieldTypeDescription
(return value)booleanWhether verification passed

Example

$ bitcoin-cli verifychain
true

verifytxoutproof

Description

Verifies the proof generated by gettxoutproof.

Parameters

ParameterTypeRequiredDefaultDescription
proofstringYes-Hex-encoded proof

Return Value

FieldTypeDescription
(return value)arrayArray of transaction IDs associated with the proof

Example

$ bitcoin-cli verifytxoutproof "proof"

Control

getinfo

Description

Returns basic information about the node (deprecated, use getblockchaininfo, getnetworkinfo, getwalletinfo instead).

Parameters

None

Example

$ bitcoin-cli getinfo

getmemoryinfo

Description

Returns memory usage information.

Parameters

None

Return Value

FieldTypeDescription
lockedobjectLocked memory information

Example

$ bitcoin-cli getmemoryinfo

help

Description

Lists all commands or gets help information for a specified command.

Parameters

ParameterTypeRequiredDefaultDescription
commandstringNo-Command name to view help for

Example

$ bitcoin-cli help
$ bitcoin-cli help getblockchaininfo

stop

Description

Stops the node.

Parameters

None

Example

$ bitcoin-cli stop

uptime

Description

Returns the node uptime (in seconds).

Parameters

None

Return Value

FieldTypeDescription
(return value)numericUptime (seconds)

Example

$ bitcoin-cli uptime
123456

Generating

generate

Description

Immediately mines a specified number of blocks to a wallet address.

Parameters

ParameterTypeRequiredDefaultDescription
nblocksnumericYes-Number of blocks to generate
maxtriesnumericNo1000000Maximum number of attempts

Return Value

FieldTypeDescription
(return value)arrayArray of generated block hashes

Example

$ bitcoin-cli generate 11

generatetoaddress

Description

Immediately mines a specified number of blocks to a specified address.

Parameters

ParameterTypeRequiredDefaultDescription
nblocksnumericYes-Number of blocks to generate
addressstringYes-Address to receive newly generated coins
maxtriesnumericNo1000000Maximum number of attempts

Return Value

FieldTypeDescription
(return value)arrayArray of generated block hashes

Example

$ bitcoin-cli generatetoaddress 11 "myaddress"

Mining

getblocktemplate

Description

Gets data needed to construct a block. See BIP 22, 23, 9, and 145 for full specification.

Parameters

ParameterTypeRequiredDefaultDescription
template_requestobjectNo-Template request object containing mode, capabilities, rules, etc.

Return Value

FieldTypeDescription
versionnumericPreferred block version
rulesarraySpecific block rules to execute
previousblockhashstringHash of the current highest block
transactionsarrayNon-coinbase transactions to include in the next block
coinbaseauxobjectData to include in coinbase scriptSig
coinbasevaluenumericMaximum allowed input value for coinbase transaction (including block reward and fees)
targetstringHash target
mintimenumericMinimum timestamp for next block
mutablearrayList of ways the block template can be modified
noncerangestringValid nonce range
sigoplimitnumericBlock sigops limit
sizelimitnumericBlock size limit
curtimenumericCurrent timestamp
bitsstringCompressed target for next block
heightnumericHeight of next block

Example

$ bitcoin-cli getblocktemplate

getmininginfo

Description

Returns mining-related information.

Parameters

None

Return Value

FieldTypeDescription
blocksnumericCurrent block height
currentblocksizenumericSize of the last block
currentblocktxnumericNumber of transactions in the last block
difficultynumericCurrent difficulty
errorsstringCurrent error messages
networkhashpsnumericNetwork hashes per second
pooledtxnumericMempool size
chainstringCurrent network name

Example

$ bitcoin-cli getmininginfo

getnetworkhashps

Description

Estimates network hashes per second based on the last n blocks.

Parameters

ParameterTypeRequiredDefaultDescription
nblocksnumericNo120Number of blocks, -1 means since last difficulty adjustment
heightnumericNo-1Estimate network speed at specified height

Return Value

FieldTypeDescription
(return value)numericEstimated hashes per second

Example

$ bitcoin-cli getnetworkhashps

submitblock

Description

Attempts to submit a new block to the network.

Parameters

ParameterTypeRequiredDefaultDescription
hexdatastringYes-Hex-encoded block data
parametersobjectNo-Optional parameter object containing workid field

Return Value

None (returns null on success)

Example

$ bitcoin-cli submitblock "mydata"

createauxblock

Description

Creates a new block and returns information needed for merge mining.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringYes-Payout address for the coinbase transaction

Return Value

FieldTypeDescription
hashstringHash of the created block
chainidnumericChain ID for this block
previousblockhashstringHash of the previous block
coinbasevaluenumericValue of the block coinbase
bitsstringCompressed target for the block
heightnumericBlock height
_targetstringReversed byte order target (deprecated)

Example

$ bitcoin-cli createauxblock "myaddress"
{
"hash": "267a45996ffc0a7b7eab7aaca88dd1ee8e2ef291f09b4f5561774423c26cd5fc",
"chainid": 8229,
"previousblockhash": "4d9e21cedb6784a8304f448fb285f36bd9cd8c7ae14f5880d9fdbc5257f10d9d",
"coinbasevalue": 0,
"bits": "207fffff",
"height": 113,
"_target": "7fffff0000000000000000000000000000000000000000000000000000000000"
}

submitauxblock

Description

Submits a solved auxpow for a block that was previously created by 'createauxblock'.

Parameters

ParameterTypeRequiredDefaultDescription
hashstringYes-Hash of the block to submit
auxpowstringYes-Serialized auxpow data

Return Value

FieldTypeDescription
(return value)booleanWhether the submitted block is correct

Example

$ bitcoin-cli submitauxblock "blockhash" "serialised auxpow"
true

Network

addnode

Description

Attempts to add or remove a node from the addnode list, or tries to connect once.

Parameters

ParameterTypeRequiredDefaultDescription
nodestringYes-Node address
commandstringYes-'add', 'remove', or 'onetry'

Return Value

None

Example

$ bitcoin-cli addnode "192.168.0.6:8333" "onetry"

clearbanned

Description

Clears all banned IPs.

Parameters

None

Return Value

None

Example

$ bitcoin-cli clearbanned

disconnectnode

Description

Immediately disconnects from the specified node.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringNo-Node IP address/port
nodeidnumericNo-Node ID (see getpeerinfo)

Return Value

None

Example

$ bitcoin-cli disconnectnode "192.168.0.6:8333"
$ bitcoin-cli disconnectnode "" 1

getaddednodeinfo

Description

Returns information about added nodes.

Parameters

ParameterTypeRequiredDefaultDescription
nodestringNo-Specific node, otherwise returns all nodes

Return Value

FieldTypeDescription
addednodestringNode IP address or name
connectedbooleanWhether connected
addressesarrayList of connection addresses (only when connected=true)

Example

$ bitcoin-cli getaddednodeinfo

getconnectioncount

Description

Returns the number of connections to other nodes.

Parameters

None

Return Value

FieldTypeDescription
(return value)numericNumber of connections

Example

$ bitcoin-cli getconnectioncount

getexcessiveblock

Description

Returns the size limit for excessive blocks.

Parameters

None

Return Value

FieldTypeDescription
excessiveBlockSizenumericBlock size (bytes)

Example

$ bitcoin-cli getexcessiveblock

getnettotals

Description

Returns network traffic information.

Parameters

None

Return Value

FieldTypeDescription
totalbytesrecvnumericTotal bytes received
totalbytessentnumericTotal bytes sent
timemillisnumericCurrent Unix time (milliseconds)
uploadtargetobjectUpload target information

Example

$ bitcoin-cli getnettotals

getnetworkinfo

Description

Returns various state information about P2P networking.

Parameters

None

Return Value

FieldTypeDescription
versionnumericServer version
subversionstringServer subversion string
protocolversionnumericProtocol version
localservicesstringServices offered to the network
localrelaybooleanWhether to request peers to relay transactions
timeoffsetnumericTime offset
connectionsnumericNumber of connections
networkactivebooleanWhether P2P networking is enabled
networksarrayInformation for each network
relayfeenumericMinimum relay fee for non-free transactions
localaddressesarrayList of local addresses
warningsstringNetwork warnings

Example

$ bitcoin-cli getnetworkinfo

getpeerinfo

Description

Returns data about each connected network node.

Parameters

None

Return Value

FieldTypeDescription
idnumericPeer index
addrstringPeer IP address and port
servicesstringServices offered
lastsendnumericLast send time
lastrecvnumericLast receive time
bytessentnumericTotal bytes sent
bytesrecvnumericTotal bytes received
conntimenumericConnection time
timeoffsetnumericTime offset
pingtimenumericPing time
versionnumericPeer version
subverstringVersion string
inboundbooleanWhether inbound connection
startingheightnumericPeer starting height
banscorenumericBan score
synced_headersnumericLast common block header
synced_blocksnumericLast common block

Example

$ bitcoin-cli getpeerinfo

listbanned

Description

Lists all banned IPs/subnets.

Parameters

None

Return Value

Array of banned IPs

Example

$ bitcoin-cli listbanned

ping

Description

Requests that a ping be sent to all other nodes, to measure ping time.

Parameters

None

Return Value

None

Example

$ bitcoin-cli ping

setban

Description

Attempts to add or remove an IP/subnet from the ban list.

Parameters

ParameterTypeRequiredDefaultDescription
subnetstringYes-IP/subnet
commandstringYes-'add' or 'remove'
bantimenumericNo24 hoursBan time (seconds)
absolutebooleanNofalseWhether to use absolute timestamp

Return Value

None

Example

$ bitcoin-cli setban "192.168.0.6" "add" 86400
$ bitcoin-cli setban "192.168.0.0/24" "add"

setexcessiveblock

Description

Sets the size limit for excessive blocks. Excessive blocks are not used in the active chain or relayed.

Parameters

ParameterTypeRequiredDefaultDescription
blockSizenumericYes-Excessive block size (bytes)

Return Value

None

Example

$ bitcoin-cli setexcessiveblock 32000000

setnetworkactive

Description

Enables/disables all P2P network activity.

Parameters

ParameterTypeRequiredDefaultDescription
statebooleanYes-true enables networking, false disables

Return Value

None

Example

$ bitcoin-cli setnetworkactive true

Rawtransactions

createrawtransaction

Description

Creates a transaction spending the given inputs and creating new outputs. Returns the hex-encoded raw transaction. The transaction's inputs are not signed, and it is not stored in the wallet or transmitted to the network.

Parameters

ParameterTypeRequiredDefaultDescription
inputsarrayYes-Array of inputs, each element containing txid, vout, sequence
outputsobjectYes-Output object, keys are addresses or "data", values are amounts or hex data
locktimenumericNo0Raw locktime, non-0 value also activates locktime on inputs

Return Value

FieldTypeDescription
(return value)stringHex string of the transaction

Example

$ bitcoin-cli createrawtransaction '[{"txid":"myid","vout":0}]' '{"address":0.01}'
$ bitcoin-cli createrawtransaction '[{"txid":"myid","vout":0}]' '{"data":"00010203"}'

decoderawtransaction

Description

Returns a JSON object representing a serialized, hex-encoded transaction.

Parameters

ParameterTypeRequiredDefaultDescription
hexstringstringYes-Transaction hex string

Return Value

FieldTypeDescription
txidstringTransaction ID
hashstringTransaction hash
sizenumericTransaction size
versionnumericVersion
locktimenumericLocktime
vinarrayInput array
voutarrayOutput array

Example

$ bitcoin-cli decoderawtransaction "hexstring"

decodescript

Description

Decodes a hex-encoded script.

Parameters

ParameterTypeRequiredDefaultDescription
hexstringstringYes-Hex-encoded script

Return Value

FieldTypeDescription
asmstringScript public key
hexstringHex-encoded public key
typestringOutput type
reqSigsnumericRequired signatures
addressesarrayArray of addresses

Example

$ bitcoin-cli decodescript "hexstring"

fundrawtransaction

Description

Adds inputs to a transaction until its input value is sufficient to cover its output value.

Parameters

ParameterTypeRequiredDefaultDescription
hexstringstringYes-Hex string of the raw transaction
optionsobjectNo-Options object containing changeAddress, changePosition, includeWatching, lockUnspents, feeRate, etc.

Return Value

FieldTypeDescription
hexstringResulting raw transaction (hex-encoded)
feenumericFee paid by the transaction (cBTC)
changeposnumericPosition of the added change output, -1 if no change

Example

$ bitcoin-cli createrawtransaction "[]" '{"myaddress":0.01}'
$ bitcoin-cli fundrawtransaction "rawtransactionhex"

getrawtransaction

Description

Returns raw transaction data. By default only works for mempool transactions, also works for blockchain transactions when -txindex option is enabled.

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID
verbosebooleanNofalsefalse returns string, true returns json object

Return Value (verbose=false)

FieldTypeDescription
(return value)stringSerialized, hex-encoded data

Return Value (verbose=true)

FieldTypeDescription
hexstringSerialized, hex-encoded data
txidstringTransaction ID
hashstringTransaction hash
sizenumericSerialized transaction size
versionnumericVersion
locktimenumericLocktime
vinarrayInput array
voutarrayOutput array
blockhashstringBlock hash
confirmationsnumericNumber of confirmations
timenumericTransaction time
blocktimenumericBlock time

Example

$ bitcoin-cli getrawtransaction "mytxid"
$ bitcoin-cli getrawtransaction "mytxid" true

sendrawtransaction

Description

Submits raw transaction (serialized, hex-encoded) to local node and network.

Parameters

ParameterTypeRequiredDefaultDescription
hexstringstringYes-Hex string of the raw transaction
allowhighfeesbooleanNofalseAllow high fees

Return Value

FieldTypeDescription
(return value)stringTransaction hash in hex

Example

$ bitcoin-cli sendrawtransaction "signedhex"

signrawtransaction

Description

Signs inputs for raw transaction.

Parameters

ParameterTypeRequiredDefaultDescription
hexstringstringYes-Transaction hex string
prevtxsarrayNo-Previous transaction outputs array (see below)
privkeysarrayNo-Private keys for signing array
sighashtypestringNoALLSignature hash type

prevtxs element:

FieldTypeRequiredDescription
txidstringYesThe transaction id
voutnumericYesThe output number
scriptPubKeystringYesHex-encoded script key
amountnumericYesThe amount spent
datastringNoHex-encoded data field of the output

Return Value

FieldTypeDescription
hexstringHex-encoded raw transaction with signatures
completebooleanWhether the transaction has a complete set of signatures
errorsarrayScript verification errors (if any)

Example

$ bitcoin-cli signrawtransaction "myhex"

Util

createmultisig

Description

Creates a multisig script requiring n of m key signatures.

Parameters

ParameterTypeRequiredDefaultDescription
nrequirednumericYes-Number of required signatures
keysarrayYes-Array of keys (addresses or hex-encoded public keys)

Return Value

FieldTypeDescription
scriptstringHex-encoded multisig script

Example

$ bitcoin-cli createmultisig 2 '["key1","key2"]'

getblockminfee

Description

Returns the minimum fee per kilobyte required for a transaction to be accepted into a block.

The return value is the maximum of:

  • Dynamic mempool minimum fee (increases when mempool is full)
  • Block minimum transaction fee (-blockmintxfee configuration)
  • Relay minimum fee (-minrelaytxfee configuration)

Parameters

None

Return Value

FieldTypeDescription
(return value)numericMinimum fee per kilobyte (cBTC)

Example

$ bitcoin-cli getblockminfee

signmessagewithprivkey

Description

Signs a message with a private key.

Parameters

ParameterTypeRequiredDefaultDescription
privkeystringYes-Private key for signing
messagestringYes-Message to sign

Return Value

FieldTypeDescription
(return value)stringBase64-encoded signature

Example

$ bitcoin-cli signmessagewithprivkey "privkey" "my message"

validateaddress

Description

Returns information about a given bitcoin address.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringYes-Bitcoin address to validate

Return Value

FieldTypeDescription
isvalidbooleanWhether the address is valid
addressstringValidated bitcoin address
scriptPubKeystringHex-encoded scriptPubKey
isminebooleanWhether the address belongs to you
iswatchonlybooleanWhether it's a watch-only address
isscriptbooleanWhether the key is a script
pubkeystringHex value of raw public key
iscompressedbooleanWhether the address is compressed

Example

$ bitcoin-cli validateaddress "1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc"

verifymessage

Description

Verifies a signed message.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringYes-Bitcoin address used to sign
signaturestringYes-Base64-encoded signature
messagestringYes-Signed message

Return Value

FieldTypeDescription
(return value)booleanWhether signature verified

Example

$ bitcoin-cli verifymessage "address" "signature" "my message"

Wallet

abandontransaction

Description

Marks an in-wallet transaction as abandoned. This will mark the transaction and all its in-wallet descendants as abandoned, allowing their inputs to be respent. Only works for transactions not included in a block and not currently in the mempool.

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID

Return Value

None

Example

$ bitcoin-cli abandontransaction "txid"

backupwallet

Description

Safely copies the current wallet file to the destination.

Parameters

ParameterTypeRequiredDefaultDescription
destinationstringYes-Destination directory or file path

Return Value

None

Example

$ bitcoin-cli backupwallet "backup.dat"

dumpprivkey

Description

Reveals the private key corresponding to an address.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringYes-Bitcoin address

Return Value

FieldTypeDescription
(return value)stringPrivate key

Example

$ bitcoin-cli dumpprivkey "myaddress"

dumpwallet

Description

Dumps all wallet keys in a human-readable format to a server-side file.

Parameters

ParameterTypeRequiredDefaultDescription
filenamestringYes-Filename with path

Return Value

FieldTypeDescription
filenamestringFilename with full absolute path

Example

$ bitcoin-cli dumpwallet "test"

encryptwallet

Description

Encrypts the wallet with a passphrase. This is for first-time encryption. After encryption, any calls that involve private keys (such as sending or signing) require setting the passphrase first. Note that this command will shut down the server.

Parameters

ParameterTypeRequiredDefaultDescription
passphrasestringYes-Passphrase to encrypt the wallet

Return Value

None

Example

$ bitcoin-cli encryptwallet "my pass phrase"

getbalance

Description

Returns the server's total available balance.

Parameters

ParameterTypeRequiredDefaultDescription
minconfnumericNo1Minimum confirmations
include_watchonlybooleanNofalseWhether to include watch-only addresses

Return Value

FieldTypeDescription
(return value)numericTotal amount (cBTC)

Example

$ bitcoin-cli getbalance
$ bitcoin-cli getbalance 6

getnewaddress

Description

Returns a new bitcoin address for receiving payments. If label is specified, it is added to the address book, and payments received with this address will be associated with that label.

Parameters

ParameterTypeRequiredDefaultDescription
labelstringNo""Label name to associate with the address

Return Value

FieldTypeDescription
(return value)stringNew bitcoin address

Example

$ bitcoin-cli getnewaddress
$ bitcoin-cli getnewaddress "mylabel"

getrawchangeaddress

Description

Returns a new bitcoin address for receiving change. For use with raw transactions, not normal use.

Parameters

None

Return Value

FieldTypeDescription
(return value)stringAddress

Example

$ bitcoin-cli getrawchangeaddress

getreceivedbyaddress

Description

Returns the total amount received by the given address in transactions with at least minconf confirmations.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringYes-Bitcoin address
minconfnumericNo1Minimum confirmations

Return Value

FieldTypeDescription
(return value)numericTotal amount received (cBTC)

Example

$ bitcoin-cli getreceivedbyaddress "address"
$ bitcoin-cli getreceivedbyaddress "address" 6

gettransaction

Description

Gets detailed information about an in-wallet transaction.

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID
include_watchonlybooleanNofalseWhether to include watch-only addresses

Return Value

FieldTypeDescription
amountnumericTransaction amount (cBTC)
feenumericFee amount (send category only)
confirmationsnumericNumber of confirmations
blockhashstringBlock hash
blockindexnumericTransaction index in block
blocktimenumericBlock time
txidstringTransaction ID
timenumericTransaction time
timereceivednumericTime received
detailsarrayTransaction details array
hexstringRaw transaction data

Example

$ bitcoin-cli gettransaction "txid"

getunconfirmedbalance

Description

Returns the server's total unconfirmed balance.

Parameters

None

Return Value

FieldTypeDescription
(return value)numericUnconfirmed balance

Example

$ bitcoin-cli getunconfirmedbalance

getwalletinfo

Description

Returns various wallet state information.

Parameters

None

Return Value

FieldTypeDescription
walletnamestringWallet name
walletversionnumericWallet version
balancenumericConfirmed total balance (cBTC)
unconfirmed_balancenumericUnconfirmed total balance (cBTC)
immature_balancenumericImmature total balance (cBTC)
txcountnumericTotal number of transactions in the wallet
keypoololdestnumericTimestamp of the oldest pre-generated key in the keypool
keypoolsizenumericNumber of pre-generated new keys
unlocked_untilnumericTimestamp until which the wallet is unlocked
paytxfeenumericTransaction fee configuration (cBTC/kB)
hdmasterkeyidstringHash160 of the HD master public key

Example

$ bitcoin-cli getwalletinfo

importaddress

Description

Adds a script (hex) or address that can be watched as if it were in your wallet but cannot be used to spend.

Parameters

ParameterTypeRequiredDefaultDescription
scriptstringYes-Hex-encoded script or address
labelstringNo""Optional label
rescanbooleanNotrueRescan wallet transactions

Return Value

None

Example

$ bitcoin-cli importaddress "myscript"
$ bitcoin-cli importaddress "myscript" "testing" false

importmulti

Description

Imports addresses/scripts (with private or public keys), rescan all addresses at once.

Parameters

ParameterTypeRequiredDefaultDescription
requestsarrayYes-Array of data to import
optionsobjectNo-Options object containing rescan field

Return Value

Array of execution results for each request

Example

$ bitcoin-cli importmulti '[{"scriptPubKey":{"address":"<address>"},"timestamp":1455191478}]'

importprivkey

Description

Adds a private key to the wallet.

Parameters

ParameterTypeRequiredDefaultDescription
bitcoinprivkeystringYes-Private key
labelstringNo""Optional label
rescanbooleanNotrueRescan wallet transactions

Return Value

None

Example

$ bitcoin-cli importprivkey "mykey"
$ bitcoin-cli importprivkey "mykey" "testing" false

importprunedfunds

Description

Imports funds without rescanning. The corresponding address or script must already be included in the wallet. Designed for pruned wallets.

Parameters

ParameterTypeRequiredDefaultDescription
rawtransactionstringYes-Raw transaction (hex) funding an address already in the wallet
txoutproofstringYes-Hex output from gettxoutproof

Return Value

None

Example

$ bitcoin-cli importprunedfunds "rawtransaction" "txoutproof"

importpubkey

Description

Adds a public key (hex) that can be watched as if it were in your wallet but cannot be used to spend.

Parameters

ParameterTypeRequiredDefaultDescription
pubkeystringYes-Hex-encoded public key
labelstringNo""Optional label
rescanbooleanNotrueRescan wallet transactions

Return Value

None

Example

$ bitcoin-cli importpubkey "mypubkey"

importwallet

Description

Imports keys from a wallet dump file.

Parameters

ParameterTypeRequiredDefaultDescription
filenamestringYes-Wallet file

Return Value

None

Example

$ bitcoin-cli importwallet "test"

keypoolrefill

Description

Fills the keypool.

Parameters

ParameterTypeRequiredDefaultDescription
newsizenumericNo100New keypool size

Return Value

None

Example

$ bitcoin-cli keypoolrefill

listaddressgroupings

Description

Lists groups of addresses that have had their common ownership publicly exposed by being used as inputs together in past transactions or as change.

Parameters

None

Return Value

Array of address groups, each address entry containing: | Field | Type | Description | |-------|------|-------------| | address | string | Bitcoin address | | amount | numeric | Balance (cBTC) | | label | string | (Optional) Label for the address |

Example

$ bitcoin-cli listaddressgroupings

listlockunspent

Description

Returns a list of temporarily unspendable outputs.

Parameters

None

Return Value

FieldTypeDescription
txidstringLocked transaction ID
voutnumericvout value

Example

$ bitcoin-cli listlockunspent

listreceivedbyaddress

Description

Lists balances by receiving address.

Parameters

ParameterTypeRequiredDefaultDescription
minconfnumericNo1Minimum confirmations
include_emptybooleanNofalseWhether to include addresses that haven't received payments
include_watchonlybooleanNofalseWhether to include watch-only addresses

Return Value

FieldTypeDescription
involvesWatchonlybooleanOnly returned if an imported address is involved
addressstringReceiving address
amountnumericTotal amount received by this address (cBTC)
confirmationsnumericNumber of confirmations of the most recent transaction
labelstringLabel for the receiving address, default is ""
txidsarrayArray of received transaction IDs

Example

$ bitcoin-cli listreceivedbyaddress
$ bitcoin-cli listreceivedbyaddress 6 true

listsinceblock

Description

Gets all transactions since a specified block, or all transactions if omitted.

Parameters

ParameterTypeRequiredDefaultDescription
blockhashstringNo-Starting block hash
target_confirmationsnumericNo1Required confirmations
include_watchonlybooleanNofalseWhether to include watch-only addresses

Return Value

FieldTypeDescription
transactionsarrayArray of transactions
lastblockstringHash of the last block

Example

$ bitcoin-cli listsinceblock
$ bitcoin-cli listsinceblock "blockhash" 6

listtransactions

Description

Returns the wallet's most recent transactions.

Parameters

ParameterTypeRequiredDefaultDescription
countnumericNo10Number of transactions to return
skipnumericNo0Number of transactions to skip
include_watchonlybooleanNofalseWhether to include watch-only addresses

Return Value

Array of transactions

Example

$ bitcoin-cli listtransactions
$ bitcoin-cli listtransactions 20 100

listunspent

Description

Returns an array of unspent transaction outputs with between minconf and maxconf (inclusive) confirmations.

Parameters

ParameterTypeRequiredDefaultDescription
minconfnumericNo1Minimum confirmations
maxconfnumericNo9999999Maximum confirmations
addressesarrayNo-Address filter array
include_unsafebooleanNotrueWhether to include unsafe outputs

Return Value

FieldTypeDescription
txidstringTransaction ID
voutnumericvout value
addressstringBitcoin address
scriptPubKeystringScript key
datastringAdditional data field for output
amountnumericTransaction output amount (cBTC)
confirmationsnumericNumber of confirmations
spendablebooleanWhether we have the private key to spend
solvablebooleanWhether we know how to spend
safebooleanWhether it's safe to spend

Example

$ bitcoin-cli listunspent
[
{
"txid": "b64510583b748ccd17c8fb4f585f1f8547b90bbe2d29e43cbd57d10e8f9902ae",
"vout": 0,
"address": "mh4MVpMRiH5jrTGnutcxM5RCky8zfoNDfE",
"scriptPubKey": "76a91410e863ab536d4fc8c39395ed4351fcf1a12d027c88ac",
"data": "",
"amount": 20999950.00000000,
"confirmations": 101,
"spendable": true,
"solvable": true,
"safe": true
}
]

listwallets

Description

Returns a list of currently loaded wallets.

Parameters

None

Return Value

Array of wallet names

Example

$ bitcoin-cli listwallets

lockunspent

Description

Updates the list of temporarily unspendable outputs. Locks or unlocks specified transaction outputs.

Parameters

ParameterTypeRequiredDefaultDescription
unlockbooleanYes-true unlocks, false locks
transactionsarrayNo-Array of transaction outputs containing txid and vout

Return Value

FieldTypeDescription
(return value)booleanWhether the command succeeded

Example

$ bitcoin-cli lockunspent false '[{"txid":"txid","vout":1}]'
$ bitcoin-cli lockunspent true '[{"txid":"txid","vout":1}]'

removeprunedfunds

Description

Deletes the specified transaction from the wallet. Used for pruned wallets as a companion to importprunedfunds.

Parameters

ParameterTypeRequiredDefaultDescription
txidstringYes-Transaction ID (hex)

Return Value

None

Example

$ bitcoin-cli removeprunedfunds "txid"

sendmany

Description

Sends multiple amounts to multiple addresses.

Parameters

ParameterTypeRequiredDefaultDescription
amountsobjectYes-Address and amount object
minconfnumericNo1Minimum confirmations
commentstringNo-Comment
subtractfeefromarrayNo-Array of addresses to subtract fee from

Return Value

FieldTypeDescription
(return value)stringTransaction ID

Example

$ bitcoin-cli sendmany '{"address1":0.01,"address2":0.02}'

sendtoaddress

Description

Sends an amount to a given address.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringYes-Bitcoin address
amountnumericYes-Amount (cBTC)
commentstringNo-Comment
comment_tostringNo-Comment for recipient
subtractfeefromamountbooleanNofalseWhether to subtract fee from amount

Return Value

FieldTypeDescription
(return value)stringTransaction ID

Example

$ bitcoin-cli sendtoaddress "address" 0.1
$ bitcoin-cli sendtoaddress "address" 0.1 "donation" "seans outpost"

settxfee

Description

Sets the transaction fee per kB. Overrides the paytxfee parameter.

Parameters

ParameterTypeRequiredDefaultDescription
amountnumericYes-Transaction fee (cBTC/kB)

Return Value

FieldTypeDescription
(return value)booleanWhether successful

Example

$ bitcoin-cli settxfee 0.00001

signmessage

Description

Signs a message with the private key of an address.

Parameters

ParameterTypeRequiredDefaultDescription
addressstringYes-Bitcoin address for the private key
messagestringYes-Message to sign

Return Value

FieldTypeDescription
(return value)stringBase64-encoded signature

Example

$ bitcoin-cli signmessage "address" "my message"

Command Statistics

CategoryCount
Blockchain21
Control5
Generating2
Mining6
Network14
Rawtransactions7
Util5
Wallet32
Total92