MCPcopy Create free account
hub / github.com/ElementsProject/elements / getnewblockhex

Function getnewblockhex

src/rpc/mining.cpp:1292–1419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1290// ELEMENTS:
1291
1292static RPCHelpMan getnewblockhex()
1293{
1294 return RPCHelpMan{"getnewblockhex",
1295 "\nGets hex representation of a proposed, unmined new block\n",
1296 {
1297 {"min_tx_age", RPCArg::Type::NUM, RPCArg::Default{0}, "How many seconds a transaction must have been in the mempool to be included in the block proposal. This may help with faster block convergence among functionaries using compact blocks."},
1298 {"proposed_parameters", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "Parameters to be used in dynamic federations blocks as proposals. During a period of `-dynamic_epoch_length` blocks, 4/5 of total blocks must signal these parameters for the proposal to become activated in the next epoch.",
1299 {
1300 {"signblockscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded block signing script to propose"},
1301 {"max_block_witness", RPCArg::Type::NUM, RPCArg::Optional::NO, "Total size in witness bytes that are allowed in the dynamic federations block witness for blocksigning"},
1302 {"fedpegscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded fedpegscript for dynamic block proposal. This is interpreted as a v0 segwit witnessScript, and fills out the fedpeg_program as such."},
1303 {"extension_space", RPCArg::Type::ARR, RPCArg::Optional::NO, "Array of additional fields to embed in the dynamic blockheader. Has no consensus meaning aside from serialized size changes. This space is currently is only used for PAK enforcement.",
1304 {
1305 {"", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex encoded string for extension entries."},
1306 },
1307 },
1308 },
1309 "proposed_parameters"},
1310 {"commit_data", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "Array of data in hex to be committed to in additional coinbase outputs.",
1311 {
1312 {"", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex encoded string for commit data"},
1313 },
1314 },
1315 },
1316 RPCResult{
1317 RPCResult::Type::STR_HEX, "blockhex", "the block hex",
1318 },
1319 RPCExamples{
1320 HelpExampleCli("getnewblockhex", ""),
1321 },
1322 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1323{
1324 ChainstateManager& chainman = EnsureAnyChainman(request.context);
1325
1326 int required_wait = !request.params[0].isNull() ? request.params[0].get_int() : 0;
1327 if (required_wait < 0) {
1328 throw JSONRPCError(RPC_INVALID_PARAMETER, "min_tx_age must be non-negative.");
1329 }
1330
1331 // Construct proposed parameter entry, if any
1332 DynaFedParamEntry proposed;
1333 if (!request.params[1].isNull()) {
1334 if (!DeploymentActiveAfter(chainman.ActiveChain().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DYNA_FED)) {
1335 throw JSONRPCError(RPC_INVALID_PARAMETER, "Dynamic federations is not active on this network. Proposed parameters are not needed.");
1336 }
1337
1338 UniValue prop = request.params[1].get_obj();
1339
1340 std::string sbs_str = prop["signblockscript"].get_str();
1341 if (!IsHex(sbs_str)) {
1342 throw JSONRPCError(RPC_INVALID_PARAMETER, "signblockscript must be hex");
1343 }
1344 std::vector<unsigned char> signblock_bytes = ParseHex(sbs_str);
1345 proposed.m_signblockscript = CScript(signblock_bytes.begin(), signblock_bytes.end());
1346
1347 int max_sbs_wit = prop["max_block_witness"].get_int();
1348 if (max_sbs_wit < 0) {
1349 throw JSONRPCError(RPC_INVALID_PARAMETER, "max_block_witness must be non-negative");

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
JSONRPCErrorFunction · 0.85
DeploymentActiveAfterFunction · 0.85
IsHexFunction · 0.85
ParseHexFunction · 0.85
GetScriptForDestinationFunction · 0.85
WitnessV0ScriptHashClass · 0.85
BlockAssemblerClass · 0.85
IncrementExtraNonceFunction · 0.85
get_intMethod · 0.80
isStrMethod · 0.80
CreateNewBlockMethod · 0.80

Tested by

no test coverage detected