Skip to content

Commit ad3d496

Browse files
committed
Add extra lock check for OSX build
Apparently my upstream checkpoint was in the middle of a series of commits by ianofsky separating wallet from the main code. This means that I have to add this main lock which will be replaced by the locked_chain interface in a subsequence catchup.
1 parent 872d39f commit ad3d496

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5493,6 +5493,7 @@ UniValue claimpegin(const JSONRPCRequest& request)
54935493

54945494
// To check if it's not double spending an existing pegin UTXO, we check mempool acceptance.
54955495
CValidationState acceptState;
5496+
LockAnnotation lock(::cs_main); //TODO(stevenroose) replace with locked_chain later
54965497
bool accepted = ::AcceptToMemoryPool(mempool, acceptState, MakeTransactionRef(mtx), nullptr /* pfMissingInputs */,
54975498
nullptr /* plTxnReplaced */, false /* bypass_limits */, maxTxFee, true /* test_accept */);
54985499
if (!accepted) {

src/wallet/wallet.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,7 @@ bool CWallet::SelectCoinsMinConf(const CAmountMap& mapTargetValue, const CoinEli
25102510

25112511
bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmountMap& mapTargetValue, std::set<CInputCoin>& setCoinsRet, CAmountMap& mapValueRet, const CCoinControl& coin_control, CoinSelectionParams& coin_selection_params, bool& bnb_used) const
25122512
{
2513+
AssertLockHeld(cs_wallet); // mapWallet
25132514
std::vector<COutput> vCoins(vAvailableCoins);
25142515

25152516
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
@@ -2684,6 +2685,11 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
26842685
coinControl.Select(txin.prevout);
26852686
}
26862687

2688+
// Acquire the locks to prevent races to the new locked unspents between the
2689+
// CreateTransaction call and LockCoin calls (when lockUnspents is true).
2690+
auto locked_chain = chain().lock();
2691+
LOCK(cs_wallet);
2692+
26872693
// Also account for the assets in the preset inputs.
26882694
std::vector<COutPoint> vPresetInputs;
26892695
coinControl.ListSelected(vPresetInputs);
@@ -2700,11 +2706,6 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
27002706
vChangeKey.push_back(std::unique_ptr<CReserveKey>(new CReserveKey(this)));
27012707
}
27022708

2703-
// Acquire the locks to prevent races to the new locked unspents between the
2704-
// CreateTransaction call and LockCoin calls (when lockUnspents is true).
2705-
auto locked_chain = chain().lock();
2706-
LOCK(cs_wallet);
2707-
27082709
CTransactionRef tx_new;
27092710
BlindDetails* blind_details = g_con_elementsmode ? new BlindDetails() : NULL;
27102711
if (!CreateTransaction(*locked_chain, vecSend, tx_new, vChangeKey, nFeeRet, nChangePosInOut, strFailReason, coinControl, false, blind_details)) {

0 commit comments

Comments
 (0)