@@ -5434,11 +5434,11 @@ inline bool MatchPrefix(uint32_t nAddrBits, uint32_t addrPrefix, uint32_t output
5434
5434
bool CWallet::ProcessStealthQueue ()
5435
5435
{
5436
5436
CWalletDB* pwdb = GetWalletDB ();
5437
- if (!pwdb)
5438
- return false ;
5439
5437
5440
- if (IsLocked ())
5438
+ if (IsLocked ()) {
5439
+ delete pwdb;
5441
5440
return false ;
5441
+ }
5442
5442
5443
5443
for (const std::pair<CKeyID, CStealthKeyQueueData>& data : vStealthKeyQueue) {
5444
5444
CStealthKeyQueueData stealthData = data.second ;
@@ -5472,6 +5472,7 @@ bool CWallet::ProcessStealthQueue()
5472
5472
}
5473
5473
// TODO (Stealth): Add lock for vector.
5474
5474
vStealthKeyQueue.clear ();
5475
+ delete pwdb;
5475
5476
return true ;
5476
5477
}
5477
5478
@@ -5486,8 +5487,6 @@ bool RunProcessStealthQueue()
5486
5487
bool CWallet::ProcessStealthOutput (const CTxDestination& address, std::vector<uint8_t >& vchEphemPK, uint32_t prefix, bool fHavePrefix , CKey& sShared )
5487
5488
{
5488
5489
CWalletDB* pwdb = GetWalletDB ();
5489
- if (!pwdb)
5490
- return false ;
5491
5490
5492
5491
CKeyID idMatchShared = boost::get<CKeyID>(address);
5493
5492
ec_point pkExtracted;
@@ -5532,15 +5531,18 @@ bool CWallet::ProcessStealthOutput(const CTxDestination& address, std::vector<ui
5532
5531
CStealthKeyQueueData lockedSkQueueData (cpkEphem, cpkScan, cpkSpend, sShared );
5533
5532
if (!pwdb->WriteStealthKeyQueue (idMatchShared, lockedSkQueueData)) {
5534
5533
LogPrintf (" %s: Error WriteStealthKeyQueue failed for %s.\n " , __func__, CDynamicAddress (idExtracted).ToString ());
5534
+ delete pwdb;
5535
5535
return false ;
5536
5536
}
5537
5537
vStealthKeyQueue.push_back (std::make_pair (cpkSpend.GetID (), lockedSkQueueData));
5538
5538
nFoundStealth++;
5539
+ delete pwdb;
5539
5540
return true ;
5540
5541
}
5541
5542
5542
5543
if (!GetKey (sxAddr.GetSpendKeyID (), sSpend )) {
5543
5544
LogPrintf (" %s: Error getting spend private key (%s) for stealth transaction.\n " , __func__, CDynamicAddress (sxAddr.GetSpendKeyID ()).ToString ());
5545
+ delete pwdb;
5544
5546
return false ;
5545
5547
}
5546
5548
CKey sSpendR ;
@@ -5563,8 +5565,10 @@ bool CWallet::ProcessStealthOutput(const CTxDestination& address, std::vector<ui
5563
5565
continue ;
5564
5566
}
5565
5567
nFoundStealth++;
5568
+ delete pwdb;
5566
5569
return true ;
5567
5570
}
5571
+ delete pwdb;
5568
5572
return false ;
5569
5573
}
5570
5574
@@ -5717,14 +5721,14 @@ bool CWallet::AddStealthAddress(const CStealthAddress& sxAddr, const CKey& skSpe
5717
5721
{
5718
5722
LogPrintf (" %s: %s\n " , __func__, sxAddr.Encoded ());
5719
5723
CWalletDB* pwdb = GetWalletDB ();
5720
- if (!pwdb)
5721
- return false ;
5722
5724
5723
5725
LOCK (cs_wallet);
5724
5726
if (!pwdb->WriteStealthAddress (sxAddr)) {
5727
+ delete pwdb;
5725
5728
return error (" %s: WriteStealthAddress failed." , __func__);
5726
5729
}
5727
5730
mapstealthAddresses[sxAddr.GetSpendKeyID ()] = sxAddr;
5731
+ delete pwdb;
5728
5732
return true ;
5729
5733
}
5730
5734
@@ -5742,13 +5746,7 @@ bool CWallet::AddToStealthQueue(const std::pair<CKeyID, CStealthKeyQueueData>& p
5742
5746
5743
5747
CWalletDB* CWallet::GetWalletDB ()
5744
5748
{
5745
- CWalletDB* pwdb;
5746
- if (IsCrypted () && pwalletdbEncryption) {
5747
- pwdb = pwalletdbEncryption;
5748
- }
5749
- else {
5750
- pwdb = new CWalletDB (strWalletFile, " r+" );
5751
- }
5749
+ CWalletDB* pwdb = new CWalletDB (strWalletFile, " r+" );
5752
5750
assert (pwdb);
5753
5751
return pwdb;
5754
5752
}
0 commit comments