14
14
#include " consensus/params.h"
15
15
#include " consensus/validation.h"
16
16
#include " core_io.h"
17
+ #include " fluid/fluid.h"
18
+ #include " fluid/fluiddb.h"
19
+ #include " fluid/fluidmint.h"
17
20
#include " init.h"
18
21
#include " miner/miner.h"
19
22
#include " net.h"
@@ -838,11 +841,12 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
838
841
// Note that this can probably also be removed entirely after the first BIP9 non-force deployment (ie, probably segwit) gets activated
839
842
aMutable.push_back (" version/force" );
840
843
}
841
-
844
+ int64_t nHeight = (int64_t )(pindexPrev->nHeight + 1 );
845
+ CAmount nCoinbaseValue = pblock->vtx [0 ]->GetValueOut ();
842
846
result.push_back (Pair (" previousblockhash" , pblock->hashPrevBlock .GetHex ()));
843
847
result.push_back (Pair (" transactions" , transactions));
844
848
result.push_back (Pair (" coinbaseaux" , aux));
845
- result.push_back (Pair (" coinbasevalue" , (int64_t )pblock-> vtx [ 0 ]-> GetValueOut () ));
849
+ result.push_back (Pair (" coinbasevalue" , (int64_t )nCoinbaseValue ));
846
850
result.push_back (Pair (" longpollid" , chainActive.Tip ()->GetBlockHash ().GetHex () + i64tostr (nTransactionsUpdatedLast)));
847
851
result.push_back (Pair (" target" , hashTarget.GetHex ()));
848
852
result.push_back (Pair (" mintime" , (int64_t )pindexPrev->GetMedianTimePast () + 1 ));
@@ -852,7 +856,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
852
856
result.push_back (Pair (" sizelimit" , (int64_t )MAX_BLOCK_SIZE));
853
857
result.push_back (Pair (" curtime" , pblock->GetBlockTime ()));
854
858
result.push_back (Pair (" bits" , strprintf (" %08x" , pblock->nBits )));
855
- result.push_back (Pair (" height" , ( int64_t )(pindexPrev-> nHeight + 1 ) ));
859
+ result.push_back (Pair (" height" , nHeight));
856
860
857
861
UniValue dynodeObj (UniValue::VOBJ);
858
862
if (pblocktemplate->txoutDynode != CTxOut ()) {
@@ -880,9 +884,36 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
880
884
superblockObjArray.push_back (entry);
881
885
}
882
886
}
887
+ CFluidMint fluidMint;
888
+ bool areWeMinting = GetMintingInstructions (nHeight, fluidMint);
889
+ CScript scriptMint;
890
+ if (areWeMinting) {
891
+ // Add minting output to superblock payments
892
+ CAmount fluidIssuance = nCoinbaseValue - GetFluidDynodeReward (nHeight) - GetFluidMiningReward (nHeight);
893
+ if (fluidIssuance > 0 ) {
894
+ UniValue entry (UniValue::VOBJ);
895
+ CDynamicAddress mintAddress = fluidMint.GetDestinationAddress ();
896
+ if (!mintAddress.IsScript ()) {
897
+ scriptMint = GetScriptForDestination (mintAddress.Get ());
898
+ } else {
899
+ CScriptID fluidScriptID = boost::get<CScriptID>(mintAddress.Get ());
900
+ scriptMint = CScript () << OP_HASH160 << ToByteVector (fluidScriptID) << OP_EQUAL;
901
+ }
902
+ entry.push_back (Pair (" payee" , mintAddress.ToString ().c_str ()));
903
+ entry.push_back (Pair (" script" , HexStr (scriptMint.begin (), scriptMint.end ())));
904
+ entry.push_back (Pair (" amount" , (int64_t )fluidIssuance));
905
+ superblockObjArray.push_back (entry);
906
+ }
907
+ }
883
908
result.push_back (Pair (" superblock" , superblockObjArray));
884
- result.push_back (Pair (" superblocks_started" , pindexPrev->nHeight + 1 > Params ().GetConsensus ().nSuperblockStartBlock ));
885
- result.push_back (Pair (" superblocks_enabled" , sporkManager.IsSporkActive (SPORK_9_SUPERBLOCKS_ENABLED)));
909
+ if (areWeMinting) {
910
+ result.push_back (Pair (" superblocks_started" , true ));
911
+ result.push_back (Pair (" superblocks_enabled" , true ));
912
+ }
913
+ else {
914
+ result.push_back (Pair (" superblocks_started" , pindexPrev->nHeight + 1 > Params ().GetConsensus ().nSuperblockStartBlock ));
915
+ result.push_back (Pair (" superblocks_enabled" , sporkManager.IsSporkActive (SPORK_9_SUPERBLOCKS_ENABLED)));
916
+ }
886
917
887
918
return result;
888
919
}
0 commit comments