@@ -546,6 +546,9 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
546
546
UpdateTime (pblock, consensusParams, pindexPrev);
547
547
pblock->nNonce = 0 ;
548
548
549
+ // NOTE: If at some point we support pre-segwit miners post-segwit-activation, this needs to take segwit support into consideration
550
+ const bool fPreSegWit = (THRESHOLD_ACTIVE != VersionBitsState (pindexPrev, consensusParams, Consensus::DEPLOYMENT_SEGWIT, versionbitscache));
551
+
549
552
UniValue aCaps (UniValue::VARR); aCaps.push_back (" proposal" );
550
553
551
554
UniValue transactions (UniValue::VARR);
@@ -574,7 +577,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
574
577
575
578
int index_in_template = i - 1 ;
576
579
entry.push_back (Pair (" fee" , pblocktemplate->vTxFees [index_in_template]));
577
- entry.push_back (Pair (" sigops" , pblocktemplate->vTxSigOpsCost [index_in_template]));
580
+ int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost [index_in_template];
581
+ if (fPreSegWit ) {
582
+ assert (nTxSigOps % WITNESS_SCALE_FACTOR == 0 );
583
+ nTxSigOps /= WITNESS_SCALE_FACTOR;
584
+ }
585
+ entry.push_back (Pair (" sigops" , nTxSigOps));
578
586
entry.push_back (Pair (" weight" , GetTransactionWeight (tx)));
579
587
580
588
transactions.push_back (entry);
@@ -657,7 +665,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
657
665
result.push_back (Pair (" mintime" , (int64_t )pindexPrev->GetMedianTimePast ()+1 ));
658
666
result.push_back (Pair (" mutable" , aMutable));
659
667
result.push_back (Pair (" noncerange" , " 00000000ffffffff" ));
660
- result.push_back (Pair (" sigoplimit" , (int64_t )MAX_BLOCK_SIGOPS_COST));
668
+ int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
669
+ if (fPreSegWit ) {
670
+ assert (nSigOpLimit % WITNESS_SCALE_FACTOR == 0 );
671
+ nSigOpLimit /= WITNESS_SCALE_FACTOR;
672
+ }
673
+ result.push_back (Pair (" sigoplimit" , nSigOpLimit));
661
674
result.push_back (Pair (" sizelimit" , (int64_t )MAX_BLOCK_SERIALIZED_SIZE));
662
675
result.push_back (Pair (" weightlimit" , (int64_t )MAX_BLOCK_WEIGHT));
663
676
result.push_back (Pair (" curtime" , pblock->GetBlockTime ()));
0 commit comments