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.Estimated network hashes per second
getmininginfo
Returns mining-related information.Current block height
Weight of the last block
Number of transactions in last block
Current difficulty
Estimated network hashes per second
Number of transactions in mempool
Network name (main, test, signet, regtest)
Any network warnings
Block Generation (Regtest/Testnet)
generatetoaddress
Mines blocks to a specified address. Only works on regtest.Array of block hashes generated
generatetodescriptor
Mines blocks to a specified descriptor. Only works on regtest.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.Block version
Hash of previous block
Array of transaction objects with:
data: Serialized transaction (hex)txid: Transaction IDhash: Transaction witness hashdepends: Transaction dependencies (1-based indices)fee: Transaction fee in satoshissigops: Legacy signature operations countweight: Transaction weight
Data for coinbase transaction
Maximum value for coinbase (subsidy + fees)
Hash target (hex)
Minimum timestamp for block
Current timestamp
Compressed difficulty target
Height of next block
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.null: Block was accepted- Error string: Block was rejected with reason
duplicate: Block already existsduplicate-invalid: Block previously marked invalidinconclusive: Node not sure if block is validrejected: Block violated consensus ruleshigh-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.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.Block hash at specified height
Mining Configuration
For mining operations, configure yourbitcoin.conf:
Mining Pool Integration
Typical mining pool workflow:-
Get block template
- Construct coinbase transaction with pool’s address and witness commitment
- Build merkle root from transactions
- Create block header with nonce field
- Mine block by incrementing nonce until valid proof-of-work found
-
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)