rpc: remove cs_main lock from `createrawtransaction`

This is a pure utility function that doesn't use
main's data structures, so it does not require that lock.

zcash: cs_main still needed while calling chainActive()

zcash: cherry picked 6e765873605ee5e31652ce107848a157151791b4
zcash: https://github.com/bitcoin/bitcoin/pull/7156
This commit is contained in:
Wladimir J. van der Laan 2015-12-02 13:42:47 +01:00 committed by Larry Ruane
parent bc3da48a11
commit 2713f9680d
1 changed files with 5 additions and 2 deletions

View File

@ -573,7 +573,6 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"")
);
LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM)(UniValue::VNUM), true);
if (params[0].isNull() || params[1].isNull())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null");
@ -581,7 +580,11 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
UniValue inputs = params[0].get_array();
UniValue sendTo = params[1].get_obj();
int nextBlockHeight = chainActive.Height() + 1;
int nextBlockHeight;
{
LOCK(cs_main);
nextBlockHeight = chainActive.Height() + 1;
}
CMutableTransaction rawTx = CreateNewContextualCMutableTransaction(
Params().GetConsensus(), nextBlockHeight);