mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
Move cs_wallet lock in CreateTransactionInternal to top of function
It isn't necessary to not lock parts of this function. Just lock the whole thing and get rid of an indent.
This commit is contained in:
parent
55a156fca0
commit
b2995963b5
2 changed files with 197 additions and 196 deletions
|
@ -578,6 +578,8 @@ bool CWallet::CreateTransactionInternal(
|
||||||
FeeCalculation& fee_calc_out,
|
FeeCalculation& fee_calc_out,
|
||||||
bool sign)
|
bool sign)
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(cs_wallet);
|
||||||
|
|
||||||
CAmount nValue = 0;
|
CAmount nValue = 0;
|
||||||
const OutputType change_type = TransactionChangeType(coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
|
const OutputType change_type = TransactionChangeType(coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
|
||||||
ReserveDestination reservedest(this, change_type);
|
ReserveDestination reservedest(this, change_type);
|
||||||
|
@ -606,9 +608,7 @@ bool CWallet::CreateTransactionInternal(
|
||||||
int nBytes;
|
int nBytes;
|
||||||
{
|
{
|
||||||
std::set<CInputCoin> setCoins;
|
std::set<CInputCoin> setCoins;
|
||||||
LOCK(cs_wallet);
|
|
||||||
txNew.nLockTime = GetLocktimeForNewTransaction(chain(), GetLastBlockHash(), GetLastBlockHeight());
|
txNew.nLockTime = GetLocktimeForNewTransaction(chain(), GetLastBlockHash(), GetLastBlockHeight());
|
||||||
{
|
|
||||||
std::vector<COutput> vAvailableCoins;
|
std::vector<COutput> vAvailableCoins;
|
||||||
AvailableCoins(vAvailableCoins, &coin_control, 1, MAX_MONEY, MAX_MONEY, 0);
|
AvailableCoins(vAvailableCoins, &coin_control, 1, MAX_MONEY, MAX_MONEY, 0);
|
||||||
CoinSelectionParams coin_selection_params; // Parameters for coin selection, init with dummy
|
CoinSelectionParams coin_selection_params; // Parameters for coin selection, init with dummy
|
||||||
|
@ -824,7 +824,6 @@ bool CWallet::CreateTransactionInternal(
|
||||||
if (scriptChange.empty() && nChangePosInOut != -1) {
|
if (scriptChange.empty() && nChangePosInOut != -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Shuffle selected coins and fill in final vin
|
// Shuffle selected coins and fill in final vin
|
||||||
txNew.vin.clear();
|
txNew.vin.clear();
|
||||||
|
@ -900,6 +899,8 @@ bool CWallet::CreateTransaction(
|
||||||
FeeCalculation& fee_calc_out,
|
FeeCalculation& fee_calc_out,
|
||||||
bool sign)
|
bool sign)
|
||||||
{
|
{
|
||||||
|
LOCK(cs_wallet);
|
||||||
|
|
||||||
int nChangePosIn = nChangePosInOut;
|
int nChangePosIn = nChangePosInOut;
|
||||||
Assert(!tx); // tx is an out-param. TODO change the return type from bool to tx (or nullptr)
|
Assert(!tx); // tx is an out-param. TODO change the return type from bool to tx (or nullptr)
|
||||||
bool res = CreateTransactionInternal(vecSend, tx, nFeeRet, nChangePosInOut, error, coin_control, fee_calc_out, sign);
|
bool res = CreateTransactionInternal(vecSend, tx, nFeeRet, nChangePosInOut, error, coin_control, fee_calc_out, sign);
|
||||||
|
|
|
@ -326,7 +326,7 @@ private:
|
||||||
// ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal structure
|
// ScriptPubKeyMan::GetID. In many cases it will be the hash of an internal structure
|
||||||
std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
|
std::map<uint256, std::unique_ptr<ScriptPubKeyMan>> m_spk_managers;
|
||||||
|
|
||||||
bool CreateTransactionInternal(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, const CCoinControl& coin_control, FeeCalculation& fee_calc_out, bool sign);
|
bool CreateTransactionInternal(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, const CCoinControl& coin_control, FeeCalculation& fee_calc_out, bool sign) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Catch wallet up to current chain, scanning new blocks, updating the best
|
* Catch wallet up to current chain, scanning new blocks, updating the best
|
||||||
|
|
Loading…
Add table
Reference in a new issue