mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Avoid reference leakage in CKeyHolderStorage::AddKey (#1840)
This commit is contained in:
parent
21a10057df
commit
476888683c
@ -1096,7 +1096,7 @@ bool CPrivateSendClient::PrepareDenominate(int nMinRounds, int nMaxRounds, std::
|
|||||||
vecTxDSIn.erase(it);
|
vecTxDSIn.erase(it);
|
||||||
vCoins.erase(it2);
|
vCoins.erase(it2);
|
||||||
|
|
||||||
CScript scriptDenom = keyHolderStorage.AddKey(pwalletMain).GetScriptForDestination();
|
CScript scriptDenom = keyHolderStorage.AddKey(pwalletMain);
|
||||||
|
|
||||||
// add new output
|
// add new output
|
||||||
CTxOut txout(nValueDenom, scriptDenom);
|
CTxOut txout(nValueDenom, scriptDenom);
|
||||||
@ -1272,7 +1272,7 @@ bool CPrivateSendClient::CreateDenominated(const CompactTallyItem& tallyItem, bo
|
|||||||
// ****** Add an output for mixing collaterals ************ /
|
// ****** Add an output for mixing collaterals ************ /
|
||||||
|
|
||||||
if(fCreateMixingCollaterals) {
|
if(fCreateMixingCollaterals) {
|
||||||
CScript scriptCollateral = keyHolderStorageDenom.AddKey(pwalletMain).GetScriptForDestination();
|
CScript scriptCollateral = keyHolderStorageDenom.AddKey(pwalletMain);
|
||||||
vecSend.push_back((CRecipient){ scriptCollateral, CPrivateSend::GetMaxCollateralAmount(), false });
|
vecSend.push_back((CRecipient){ scriptCollateral, CPrivateSend::GetMaxCollateralAmount(), false });
|
||||||
nValueLeft -= CPrivateSend::GetMaxCollateralAmount();
|
nValueLeft -= CPrivateSend::GetMaxCollateralAmount();
|
||||||
}
|
}
|
||||||
@ -1307,7 +1307,7 @@ bool CPrivateSendClient::CreateDenominated(const CompactTallyItem& tallyItem, bo
|
|||||||
|
|
||||||
// add each output up to 11 times until it can't be added again
|
// add each output up to 11 times until it can't be added again
|
||||||
while(nValueLeft - nDenomValue >= 0 && nOutputs <= 10) {
|
while(nValueLeft - nDenomValue >= 0 && nOutputs <= 10) {
|
||||||
CScript scriptDenom = keyHolderStorageDenom.AddKey(pwalletMain).GetScriptForDestination();
|
CScript scriptDenom = keyHolderStorageDenom.AddKey(pwalletMain);
|
||||||
|
|
||||||
vecSend.push_back((CRecipient){ scriptDenom, nDenomValue, false });
|
vecSend.push_back((CRecipient){ scriptDenom, nDenomValue, false });
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ CScript CKeyHolder::GetScriptForDestination() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const CKeyHolder& CKeyHolderStorage::AddKey(CWallet* pwallet)
|
CScript CKeyHolderStorage::AddKey(CWallet* pwallet)
|
||||||
{
|
{
|
||||||
LOCK(cs_storage);
|
LOCK(cs_storage);
|
||||||
storage.emplace_back(std::unique_ptr<CKeyHolder>(new CKeyHolder(pwallet)));
|
storage.emplace_back(std::unique_ptr<CKeyHolder>(new CKeyHolder(pwallet)));
|
||||||
LogPrintf("CKeyHolderStorage::%s -- storage size %lld\n", __func__, storage.size());
|
LogPrintf("CKeyHolderStorage::%s -- storage size %lld\n", __func__, storage.size());
|
||||||
return *storage.back();
|
return storage.back()->GetScriptForDestination();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeyHolderStorage::KeepAll(){
|
void CKeyHolderStorage::KeepAll(){
|
||||||
|
@ -30,7 +30,7 @@ private:
|
|||||||
mutable CCriticalSection cs_storage;
|
mutable CCriticalSection cs_storage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const CKeyHolder& AddKey(CWallet* pwalletIn);
|
CScript AddKey(CWallet* pwalletIn);
|
||||||
void KeepAll();
|
void KeepAll();
|
||||||
void ReturnAll();
|
void ReturnAll();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user