Skip to main content

Mining RPC Methods

Mining RPCs provide functionality for generating blocks, estimating network hashrate, and interacting with mining pool software.
Most mining RPCs are primarily used for testing on regtest/testnet or by mining pool operators. Solo mining on mainnet is generally not profitable.

Network Hashrate

getnetworkhashps

Returns the estimated network hashes per second based on recent blocks.
number
Estimated network hashes per second

getmininginfo

Returns mining-related information.
number
Current block height
number
Weight of the last block
number
Number of transactions in last block
number
Current difficulty
number
Estimated network hashes per second
number
Number of transactions in mempool
string
Network name (main, test, signet, regtest)
string
Any network warnings

Block Generation (Regtest/Testnet)

generatetoaddress

Mines blocks to a specified address. Only works on regtest.
array
Array of block hashes generated
This RPC only works on regtest network. For mainnet/testnet, use external mining software.

generatetodescriptor

Mines blocks to a specified descriptor. Only works on regtest.
array
Array of block hashes generated

generate

Deprecated. Replaced by the -generate CLI option.

Mining Pool Operations

getblocktemplate

Returns data needed to construct a block to mine.
number
Block version
string
Hash of previous block
array
Array of transaction objects with:
  • data: Serialized transaction (hex)
  • txid: Transaction ID
  • hash: Transaction witness hash
  • depends: Transaction dependencies (1-based indices)
  • fee: Transaction fee in satoshis
  • sigops: Legacy signature operations count
  • weight: Transaction weight
object
Data for coinbase transaction
number
Maximum value for coinbase (subsidy + fees)
string
Hash target (hex)
number
Minimum timestamp for block
number
Current timestamp
string
Compressed difficulty target
number
Height of next block
string
Witness commitment for coinbase (if SegWit enabled)
This RPC requires the node to be configured for mining (e.g., with -miner configuration) and have at least one peer connection.

submitblock

Submits a new block to the network.
string | null
  • null: Block was accepted
  • Error string: Block was rejected with reason
Possible rejection reasons:
  • duplicate: Block already exists
  • duplicate-invalid: Block previously marked invalid
  • inconclusive: Node not sure if block is valid
  • rejected: Block violated consensus rules
  • high-hash: Block doesn’t meet proof-of-work requirement

submitheader

Submits a block header (without transactions) to check validity.
Useful for testing block header validity without constructing full block.

Priority and Fee Estimation

prioritisetransaction

Modifies transaction priority for block inclusion.
boolean
Returns true if successful
This affects the transaction’s priority in this node’s mempool and block template generation. It does not affect other nodes.

Block Assembly

getblockhash

Returns the hash of a block at given height.
string
Block hash at specified height

Mining Configuration

For mining operations, configure your bitcoin.conf:

Mining Pool Integration

Typical mining pool workflow:
  1. Get block template
  2. Construct coinbase transaction with pool’s address and witness commitment
  3. Build merkle root from transactions
  4. Create block header with nonce field
  5. Mine block by incrementing nonce until valid proof-of-work found
  6. Submit block

Testing Block Generation

For testing on regtest:

Difficulty Information

Understanding difficulty values:
  • Difficulty: Multiple of minimum difficulty (1.0 = minimum)
  • Target: Maximum hash value for valid block (lower = harder)
  • Bits: Compact representation of target
  • Chainwork: Cumulative proof-of-work in chain (hex)
Difficulty adjusts every 2016 blocks (~2 weeks) to maintain 10-minute block time.