@@ -419,7 +419,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
419
419
return false ;
420
420
if (!crypter.Encrypt (_vMasterKey, pMasterKey.second .vchCryptedKey ))
421
421
return false ;
422
- WalletBatch (*database ).WriteMasterKey (pMasterKey.first , pMasterKey.second );
422
+ WalletBatch (GetDatabase () ).WriteMasterKey (pMasterKey.first , pMasterKey.second );
423
423
if (fWasLocked )
424
424
Lock ();
425
425
return true ;
@@ -432,7 +432,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
432
432
433
433
void CWallet::chainStateFlushed (const CBlockLocator& loc)
434
434
{
435
- WalletBatch batch (*database );
435
+ WalletBatch batch (GetDatabase () );
436
436
batch.WriteBestBlock (loc);
437
437
}
438
438
@@ -444,7 +444,7 @@ void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in)
444
444
nWalletVersion = nVersion;
445
445
446
446
{
447
- WalletBatch* batch = batch_in ? batch_in : new WalletBatch (*database );
447
+ WalletBatch* batch = batch_in ? batch_in : new WalletBatch (GetDatabase () );
448
448
if (nWalletVersion > 40000 )
449
449
batch->WriteMinVersion (nWalletVersion);
450
450
if (!batch_in)
@@ -484,12 +484,12 @@ bool CWallet::HasWalletSpend(const uint256& txid) const
484
484
485
485
void CWallet::Flush ()
486
486
{
487
- database-> Flush ();
487
+ GetDatabase (). Flush ();
488
488
}
489
489
490
490
void CWallet::Close ()
491
491
{
492
- database-> Close ();
492
+ GetDatabase (). Close ();
493
493
}
494
494
495
495
void CWallet::SyncMetaData (std::pair<TxSpends::iterator, TxSpends::iterator> range)
@@ -615,7 +615,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
615
615
{
616
616
LOCK (cs_wallet);
617
617
mapMasterKeys[++nMasterKeyMaxID] = kMasterKey ;
618
- WalletBatch* encrypted_batch = new WalletBatch (*database );
618
+ WalletBatch* encrypted_batch = new WalletBatch (GetDatabase () );
619
619
if (!encrypted_batch->TxnBegin ()) {
620
620
delete encrypted_batch;
621
621
encrypted_batch = nullptr ;
@@ -667,12 +667,12 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
667
667
668
668
// Need to completely rewrite the wallet file; if we don't, bdb might keep
669
669
// bits of the unencrypted private key in slack space in the database file.
670
- database-> Rewrite ();
670
+ GetDatabase (). Rewrite ();
671
671
672
672
// BDB seems to have a bad habit of writing old data into
673
673
// slack space in .dat files; that is bad if the old data is
674
674
// unencrypted private keys. So:
675
- database-> ReloadDbEnv ();
675
+ GetDatabase (). ReloadDbEnv ();
676
676
677
677
}
678
678
NotifyStatusChanged (this );
@@ -683,7 +683,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
683
683
DBErrors CWallet::ReorderTransactions ()
684
684
{
685
685
LOCK (cs_wallet);
686
- WalletBatch batch (*database );
686
+ WalletBatch batch (GetDatabase () );
687
687
688
688
// Old wallets didn't have any defined order for transactions
689
689
// Probably a bad idea to change the output of this
@@ -744,7 +744,7 @@ int64_t CWallet::IncOrderPosNext(WalletBatch* batch)
744
744
if (batch) {
745
745
batch->WriteOrderPosNext (nOrderPosNext);
746
746
} else {
747
- WalletBatch (*database ).WriteOrderPosNext (nOrderPosNext);
747
+ WalletBatch (GetDatabase () ).WriteOrderPosNext (nOrderPosNext);
748
748
}
749
749
return nRet;
750
750
}
@@ -774,7 +774,7 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
774
774
775
775
wtx.mapValue [" replaced_by_txid" ] = newHash.ToString ();
776
776
777
- WalletBatch batch (*database );
777
+ WalletBatch batch (GetDatabase () );
778
778
779
779
bool success = true ;
780
780
if (!batch.WriteTx (wtx)) {
@@ -846,7 +846,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const CWalletTx::Confirmatio
846
846
{
847
847
LOCK (cs_wallet);
848
848
849
- WalletBatch batch (*database , fFlushOnClose );
849
+ WalletBatch batch (GetDatabase () , fFlushOnClose );
850
850
851
851
uint256 hash = tx->GetHash ();
852
852
@@ -1045,7 +1045,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1045
1045
{
1046
1046
LOCK (cs_wallet);
1047
1047
1048
- WalletBatch batch (*database );
1048
+ WalletBatch batch (GetDatabase () );
1049
1049
1050
1050
std::set<uint256> todo;
1051
1051
std::set<uint256> done;
@@ -1108,7 +1108,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
1108
1108
return ;
1109
1109
1110
1110
// Do not flush the wallet here for performance reasons
1111
- WalletBatch batch (*database , false );
1111
+ WalletBatch batch (GetDatabase () , false );
1112
1112
1113
1113
std::set<uint256> todo;
1114
1114
std::set<uint256> done;
@@ -1446,13 +1446,13 @@ void CWallet::SetWalletFlag(uint64_t flags)
1446
1446
{
1447
1447
LOCK (cs_wallet);
1448
1448
m_wallet_flags |= flags;
1449
- if (!WalletBatch (*database ).WriteWalletFlags (m_wallet_flags))
1449
+ if (!WalletBatch (GetDatabase () ).WriteWalletFlags (m_wallet_flags))
1450
1450
throw std::runtime_error (std::string (__func__) + " : writing wallet flags failed" );
1451
1451
}
1452
1452
1453
1453
void CWallet::UnsetWalletFlag (uint64_t flag)
1454
1454
{
1455
- WalletBatch batch (*database );
1455
+ WalletBatch batch (GetDatabase () );
1456
1456
UnsetWalletFlagWithDB (batch, flag);
1457
1457
}
1458
1458
@@ -1491,7 +1491,7 @@ bool CWallet::AddWalletFlags(uint64_t flags)
1491
1491
LOCK (cs_wallet);
1492
1492
// We should never be writing unknown non-tolerable wallet flags
1493
1493
assert (((flags & KNOWN_WALLET_FLAGS) >> 32 ) == (flags >> 32 ));
1494
- if (!WalletBatch (*database ).WriteWalletFlags (flags)) {
1494
+ if (!WalletBatch (GetDatabase () ).WriteWalletFlags (flags)) {
1495
1495
throw std::runtime_error (std::string (__func__) + " : writing wallet flags failed" );
1496
1496
}
1497
1497
@@ -1582,7 +1582,7 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
1582
1582
return false ;
1583
1583
}
1584
1584
if (apply_label) {
1585
- WalletBatch batch (*database );
1585
+ WalletBatch batch (GetDatabase () );
1586
1586
for (const CScript& script : script_pub_keys) {
1587
1587
CTxDestination dest;
1588
1588
ExtractDestination (script, dest);
@@ -3177,10 +3177,10 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
3177
3177
LOCK (cs_wallet);
3178
3178
3179
3179
fFirstRunRet = false ;
3180
- DBErrors nLoadWalletRet = WalletBatch (*database ).LoadWallet (this );
3180
+ DBErrors nLoadWalletRet = WalletBatch (GetDatabase () ).LoadWallet (this );
3181
3181
if (nLoadWalletRet == DBErrors::NEED_REWRITE)
3182
3182
{
3183
- if (database-> Rewrite (" \x04 pool" ))
3183
+ if (GetDatabase (). Rewrite (" \x04 pool" ))
3184
3184
{
3185
3185
for (const auto & spk_man_pair : m_spk_managers) {
3186
3186
spk_man_pair.second ->RewriteDB ();
@@ -3204,7 +3204,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
3204
3204
DBErrors CWallet::ZapSelectTx (std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut)
3205
3205
{
3206
3206
AssertLockHeld (cs_wallet);
3207
- DBErrors nZapSelectTxRet = WalletBatch (*database ).ZapSelectTx (vHashIn, vHashOut);
3207
+ DBErrors nZapSelectTxRet = WalletBatch (GetDatabase () ).ZapSelectTx (vHashIn, vHashOut);
3208
3208
for (const uint256& hash : vHashOut) {
3209
3209
const auto & it = mapWallet.find (hash);
3210
3210
wtxOrdered.erase (it->second .m_it_wtxOrdered );
@@ -3216,7 +3216,7 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
3216
3216
3217
3217
if (nZapSelectTxRet == DBErrors::NEED_REWRITE)
3218
3218
{
3219
- if (database-> Rewrite (" \x04 pool" ))
3219
+ if (GetDatabase (). Rewrite (" \x04 pool" ))
3220
3220
{
3221
3221
for (const auto & spk_man_pair : m_spk_managers) {
3222
3222
spk_man_pair.second ->RewriteDB ();
@@ -3254,14 +3254,14 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
3254
3254
3255
3255
bool CWallet::SetAddressBook (const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
3256
3256
{
3257
- WalletBatch batch (*database );
3257
+ WalletBatch batch (GetDatabase () );
3258
3258
return SetAddressBookWithDB (batch, address, strName, strPurpose);
3259
3259
}
3260
3260
3261
3261
bool CWallet::DelAddressBook (const CTxDestination& address)
3262
3262
{
3263
3263
bool is_mine;
3264
- WalletBatch batch (*database );
3264
+ WalletBatch batch (GetDatabase () );
3265
3265
{
3266
3266
LOCK (cs_wallet);
3267
3267
// If we want to delete receiving addresses, we need to take care that DestData "used" (and possibly newer DestData) gets preserved (and the "deleted" address transformed into a change entry instead of actually being deleted)
@@ -4008,7 +4008,7 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
4008
4008
int rescan_height = 0 ;
4009
4009
if (!gArgs .GetBoolArg (" -rescan" , false ))
4010
4010
{
4011
- WalletBatch batch (* walletInstance->database );
4011
+ WalletBatch batch (walletInstance->GetDatabase () );
4012
4012
CBlockLocator locator;
4013
4013
if (batch.ReadBestBlock (locator)) {
4014
4014
if (const Optional<int > fork_height = chain.findLocatorFork (locator)) {
@@ -4071,7 +4071,7 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
4071
4071
}
4072
4072
}
4073
4073
walletInstance->chainStateFlushed (chain.getTipLocator ());
4074
- walletInstance->database -> IncrementUpdateCounter ();
4074
+ walletInstance->GetDatabase (). IncrementUpdateCounter ();
4075
4075
}
4076
4076
4077
4077
{
@@ -4149,7 +4149,7 @@ void CWallet::postInitProcess()
4149
4149
4150
4150
bool CWallet::BackupWallet (const std::string& strDest) const
4151
4151
{
4152
- return database-> Backup (strDest);
4152
+ return GetDatabase (). Backup (strDest);
4153
4153
}
4154
4154
4155
4155
CKeyPool::CKeyPool ()
@@ -4452,7 +4452,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
4452
4452
4453
4453
void CWallet::AddActiveScriptPubKeyMan (uint256 id, OutputType type, bool internal)
4454
4454
{
4455
- WalletBatch batch (*database );
4455
+ WalletBatch batch (GetDatabase () );
4456
4456
if (!batch.WriteActiveScriptPubKeyMan (static_cast <uint8_t >(type), id, internal)) {
4457
4457
throw std::runtime_error (std::string (__func__) + " : writing active ScriptPubKeyMan id failed" );
4458
4458
}
0 commit comments