From 2713f9680d7a34257ae425b0d21d41947ab56fac Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 2 Dec 2015 13:42:47 +0100 Subject: [PATCH] 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 --- src/rpc/rawtransaction.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 2999febbe..37f150580 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -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);