mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
[wallet] Make CWallet::FundTransaction atomic
This commit is contained in:
parent
95d4450a41
commit
03a5dc9c3c
@ -2605,6 +2605,10 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
|
|||||||
coinControl.Select(txin.prevout);
|
coinControl.Select(txin.prevout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Acquire the locks to prevent races to the new locked unspents between the
|
||||||
|
// CreateTransaction call and LockCoin calls (when lockUnspents is true).
|
||||||
|
LOCK2(cs_main, cs_wallet);
|
||||||
|
|
||||||
CReserveKey reservekey(this);
|
CReserveKey reservekey(this);
|
||||||
CWalletTx wtx;
|
CWalletTx wtx;
|
||||||
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, coinControl, false)) {
|
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, coinControl, false)) {
|
||||||
@ -2630,7 +2634,6 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
|
|||||||
tx.vin.push_back(txin);
|
tx.vin.push_back(txin);
|
||||||
|
|
||||||
if (lockUnspents) {
|
if (lockUnspents) {
|
||||||
LOCK2(cs_main, cs_wallet);
|
|
||||||
LockCoin(txin.prevout);
|
LockCoin(txin.prevout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user