Auto merge of #4992 - LarryRuane:upstream-locking-0.11, r=str4d

Bitcoin 0.12 locking PRs

These are locking changes from upstream (bitcoin core) release 0.12.

- bitcoin/bitcoin#7013
- bitcoin/bitcoin#7156
- bitcoin/bitcoin#7229
This commit is contained in:
Homu 2021-02-19 19:21:53 +00:00
commit b08c673ddd
2 changed files with 11 additions and 4 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);
@ -779,7 +782,6 @@ UniValue decodescript(const UniValue& params, bool fHelp)
+ HelpExampleRpc("decodescript", "\"hexstring\"")
);
LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR));
UniValue r(UniValue::VOBJ);

View File

@ -1248,8 +1248,13 @@ bool CWalletDB::Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKe
CDataStream ssKey(row.first, SER_DISK, CLIENT_VERSION);
CDataStream ssValue(row.second, SER_DISK, CLIENT_VERSION);
string strType, strErr;
bool fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue,
bool fReadOK;
{
// Required in LoadKeyMetadata():
LOCK(dummyWallet.cs_wallet);
fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue,
wss, strType, strErr);
}
if (!IsKeyType(strType))
continue;
if (!fReadOK)