@@ -976,7 +976,7 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
976976
977977UniValue getnewblockhex (const JSONRPCRequest& request)
978978{
979- if (request.fHelp || request.params .size () > 2 )
979+ if (request.fHelp || request.params .size () > 3 )
980980 throw std::runtime_error (
981981 RPCHelpMan{" getnewblockhex" ,
982982 " \n Gets hex representation of a proposed, unmined new block\n " ,
@@ -994,6 +994,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
994994 },
995995 },
996996 " proposed_parameters" },
997+ {" commit_data" , RPCArg::Type::STR_HEX , RPCArg::Optional::NO , " Data in hex to be committed to in an additional coinbase output." },
997998 },
998999 RPCResult{
9991000 " blockhex (hex) The block hex\n "
@@ -1048,9 +1049,17 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
10481049 proposed.m_serialize_type = 2 ;
10491050 }
10501051
1052+ // Any commitment required for non-consensus reasons.
1053+ // This will be placed in the first coinbase output.
1054+ CScript data_commitment;
1055+ if (!request.params [2 ].isNull ()) {
1056+ std::vector<unsigned char > data_bytes = ParseHex (request.params [2 ].get_str ());
1057+ data_commitment = CScript () << OP_RETURN << data_bytes;
1058+ }
1059+
10511060 CScript feeDestinationScript = Params ().GetConsensus ().mandatory_coinbase_destination ;
10521061 if (feeDestinationScript == CScript ()) feeDestinationScript = CScript () << OP_TRUE ;
1053- std::unique_ptr<CBlockTemplate> pblocktemplate (BlockAssembler (Params ()).CreateNewBlock (feeDestinationScript, std::chrono::seconds (required_wait), &proposed));
1062+ std::unique_ptr<CBlockTemplate> pblocktemplate (BlockAssembler (Params ()).CreateNewBlock (feeDestinationScript, std::chrono::seconds (required_wait), &proposed, data_commitment. empty () ? nullptr : &data_commitment ));
10541063 if (!pblocktemplate.get ()) {
10551064 throw JSONRPCError (RPC_INTERNAL_ERROR , " Wallet keypool empty" );
10561065 }
@@ -1451,7 +1460,7 @@ static const CRPCCommand commands[] =
14511460 { " mining" , " getblocktemplate" , &getblocktemplate, {" template_request" } },
14521461 { " generating" , " combineblocksigs" , &combineblocksigs, {" blockhex" ," signatures" } },
14531462 { " mining" , " submitheader" , &submitheader, {" hexdata" } },
1454- { " generating" , " getnewblockhex" , &getnewblockhex, {" min_tx_age" , " proposed_parameters" } },
1463+ { " generating" , " getnewblockhex" , &getnewblockhex, {" min_tx_age" , " proposed_parameters" , " commit_data " } },
14551464 { " generating" , " getcompactsketch" , &getcompactsketch, {" block_hex" } },
14561465 { " generating" , " consumecompactsketch" , &consumecompactsketch, {" sketch" } },
14571466 { " generating" , " consumegetblocktxn" , &consumegetblocktxn, {" full_block" , " block_tx_req" } },
0 commit comments