From b85008e78603209ec01222362ede57ee253591a8 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 26 Sep 2017 10:13:03 -0700 Subject: [PATCH] Update which lock to synchronize on when calling GetBestAnchor(). --- src/wallet/asyncrpcoperation_sendmany.cpp | 2 +- src/wallet/asyncrpcoperation_shieldcoinbase.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 89b43c7b3..b4e831d57 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -878,7 +878,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info std::vector> witnesses; uint256 anchor; { - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK(cs_main); anchor = pcoinsTip->GetBestAnchor(); // As there are no inputs, ask the wallet for the best anchor } return perform_joinsplit(info, witnesses, anchor); diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 8c8de21e6..20d659cc2 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -279,7 +279,12 @@ void AsyncRPCOperation_shieldcoinbase::sign_send_raw_transaction(UniValue obj) UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInfo & info) { - uint256 anchor = pcoinsTip->GetBestAnchor(); + uint256 anchor; + { + LOCK(cs_main); + anchor = pcoinsTip->GetBestAnchor(); + } + if (anchor.IsNull()) { throw std::runtime_error("anchor is null"); }