<blockquote>
  <p>1) "getmininginfo" gives the difficulty right now, and "getblocktemplate" gives the difficulty for the next block</p>
</blockquote>

<p>That is correct. <code>getmininginfo</code> gives the diffculty of the block at the current blockchain tip, and <code>getblocktemplate</code> gives the target for the block to be mined on top of the current tip, i.e. the next block.</p>

<blockquote>
  <p>under the assumption that this block will be solved within the next second.</p>
</blockquote>

<p>There is no such assumption. The difficulty doesn't change by the second, it only changes at the end of each difficulty adjustment interval. If you are fully synced, you will always know what the difficulty of the next block will be. The calculation is completely deterministic and any block that has your current tip as its previous block will have the exact same target.</p>

CC BY-SA 4.0
2019-07-06T10:39:13.623Z
so the target that the miners are working on right now is or is not the one given by "getblocktemplate" ?
SDiv
CC BY-SA 4.0
2019-07-06T16:25:48.787Z
Miners are always working on the next block. So they want to meet the target of the next block, which is given by `getblocktemplate`.
Ava Chow
CC BY-SA 4.0
2019-07-06T05:05:33.473Z
2019-07-06T05:05:33.473Z
Ava Chow
<p>I am interested in the difficulty <em>right now</em>. That is, the miners are working a block right now and they have a target. Both of the RPC commands "getmininginfo" (or "getdifficulty") and "getblocktemplate" can be used to get a number that represents a "difficulty".</p>

<p>"getmininginfo" (or "getdifficulty") gives a difficulty value directly. "getblocktemplate" gives the "target" and the "bits", both of which can be used to derive a difficulty value. I understand that miners work according to a "target." But, which target?</p>

<p>I list two possibilities below. Which (if either) is the correct case?</p>

<p>1) "getmininginfo" gives the difficulty right now, and "getblocktemplate" gives the difficulty for the next block under the assumption that this block will be solved within the next second.</p>

<p>2) "getblocktemplate" gives the difficulty right now (through the "bits" or "target"), and "getmininginfo" gives what the difficulty was for the most recently solved block.</p>

<p>If both of these are wrong, what exactly do the difficulties given by the two commands really represent?</p>

<json-rpc><bitcoin-cli>
getmininginfo vs getblocktemplate
SDiv
# getmininginfo vs getblocktemplate

(Asked by: username_0 on 2019-07-06)

I am interested in the difficulty *right now*. That is, the miners are working a block right now and they have a target. Both of the RPC commands "getmininginfo" (or "getdifficulty") and "getblocktemplate" can be used to get a number that represents a "difficulty".

"getmininginfo" (or "getdifficulty") gives a difficulty value directly. "getblocktemplate" gives the "target" and the "bits", both of which can be used to derive a difficulty value. I understand that miners work according to a "target." But, which target?

I list two possibilities below. Which (if either) is the correct case?

1) "getmininginfo" gives the difficulty right now, and "getblocktemplate" gives the difficulty for the next block under the assumption that this block will be solved within the next second.

2) "getblocktemplate" gives the difficulty right now (through the "bits" or "target"), and "getmininginfo" gives what the difficulty was for the most recently solved block.

If both of these are wrong, what exactly do the difficulties given by the two commands really represent?

**Tags:** json-rpc, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2019-07-06. Score: 4

> 1) "getmininginfo" gives the difficulty right now, and "getblocktemplate" gives the difficulty for the next block

That is correct. `getmininginfo` gives the diffculty of the block at the current blockchain tip, and `getblocktemplate` gives the target for the block to be mined on top of the current tip, i.e. the next block.

> under the assumption that this block will be solved within the next second.

There is no such assumption. The difficulty doesn't change by the second, it only changes at the end of each difficulty adjustment interval. If you are fully synced, you will always know what the difficulty of the next block will be. The calculation is completely deterministic and any block that has your current tip as its previous block will have the exact same target.

> **Comments:**
> **username_0**: so the target that the miners are working on right now is or is not the one given by "getblocktemplate" ?  
> **username_1**: Miners are always working on the next block. So they want to meet the target of the next block, which is given by `getblocktemplate`.  

---

