Skip to content

Commit

Permalink
add submitblock
Browse files Browse the repository at this point in the history
  • Loading branch information
fflo committed Dec 18, 2015
1 parent e7377ac commit 319cf82
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/bitcoinrpc.cpp
Expand Up @@ -3322,6 +3322,31 @@ Value sendrawtransaction(const Array& params, bool fHelp)

extern CCriticalSection cs_mapTransactions;

Value submitblock(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"submitblock <hex data> [optional-params-obj]\n"
"[optional-params-obj] parameter is currently ignored.\n"
"Attempts to submit new block to network.\n"
"See https://en.bitcoin.it/wiki/BIP_0022 for full specification.");

vector<unsigned char> blockData(ParseHex(params[0].get_str()));
CDataStream ssBlock(blockData, SER_NETWORK, VERSION);
CBlock block;
try {
ssBlock >> block;
}
catch (std::exception &e) {
throw JSONRPCError(-22, "Block decode failed");
}
bool fAccepted = ProcessBlock(NULL, &block);
if (!fAccepted)
throw JSONRPCError(-23, "Block rejected");

return true;
}

Value getrawmempool(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
Expand Down Expand Up @@ -3468,6 +3493,7 @@ pair<string, rpcfn_type> pCallTable[] =
make_pair("listaccounts", &listaccounts),
make_pair("settxfee", &settxfee),
make_pair("getmemorypool", &getmemorypool),
make_pair("submitblock", &submitblock),
make_pair("setmininput", &setmininput),
make_pair("dumpprivkey", &dumpprivkey),
make_pair("importprivkey", &importprivkey),
Expand Down Expand Up @@ -3516,6 +3542,7 @@ string pAllowInSafeMode[] =
"getworkaux",
"getauxblock",
"getmemorypool",
"submitblock",
"dumpprivkey",
"getrawmempool",
};
Expand Down

0 comments on commit 319cf82

Please sign in to comment.