rpc: fix mintime for testnet4

Previously in getblocktemplate only curtime took the timewarp rule into account.

Mining pool software could use either, though in general it should use curtime.
This commit is contained in:
Sjors Provoost 2025-01-03 14:58:50 +01:00
parent 8454215a9f
commit 0b4e4d6f34
No known key found for this signature in database
GPG key ID: 57FF9BDBCC301009
2 changed files with 4 additions and 1 deletions

View file

@ -49,6 +49,7 @@
using interfaces::BlockTemplate;
using interfaces::Mining;
using node::BlockAssembler;
using node::GetMinimumTime;
using node::NodeContext;
using node::RegenerateCommitments;
using node::UpdateTime;
@ -954,7 +955,7 @@ static RPCHelpMan getblocktemplate()
result.pushKV("coinbasevalue", (int64_t)block.vtx[0]->vout[0].nValue);
result.pushKV("longpollid", tip.GetHex() + ToString(nTransactionsUpdatedLast));
result.pushKV("target", hashTarget.GetHex());
result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1);
result.pushKV("mintime", GetMinimumTime(pindexPrev, consensusParams));
result.pushKV("mutable", std::move(aMutable));
result.pushKV("noncerange", "00000000ffffffff");
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;

View file

@ -149,6 +149,8 @@ class MiningTest(BitcoinTestFramework):
# The template will have an adjusted timestamp, which we then modify
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
assert_greater_than_or_equal(tmpl['curtime'], t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP)
# mintime and curtime should match
assert_equal(tmpl['mintime'], tmpl['curtime'])
block = CBlock()
block.nVersion = tmpl["version"]