@@ -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
@@ -452,7 +452,7 @@ void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in,
452
452
nWalletMaxVersion = nVersion;
453
453
454
454
{
455
- WalletBatch* batch = batch_in ? batch_in : new WalletBatch (*database );
455
+ WalletBatch* batch = batch_in ? batch_in : new WalletBatch (GetDatabase () );
456
456
if (nWalletVersion > 40000 )
457
457
batch->WriteMinVersion (nWalletVersion);
458
458
if (!batch_in)
@@ -504,12 +504,12 @@ bool CWallet::HasWalletSpend(const uint256& txid) const
504
504
505
505
void CWallet::Flush ()
506
506
{
507
- database-> Flush ();
507
+ GetDatabase (). Flush ();
508
508
}
509
509
510
510
void CWallet::Close ()
511
511
{
512
- database-> Close ();
512
+ GetDatabase (). Close ();
513
513
}
514
514
515
515
void CWallet::SyncMetaData (std::pair<TxSpends::iterator, TxSpends::iterator> range)
@@ -635,7 +635,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
635
635
{
636
636
LOCK (cs_wallet);
637
637
mapMasterKeys[++nMasterKeyMaxID] = kMasterKey ;
638
- WalletBatch* encrypted_batch = new WalletBatch (*database );
638
+ WalletBatch* encrypted_batch = new WalletBatch (GetDatabase () );
639
639
if (!encrypted_batch->TxnBegin ()) {
640
640
delete encrypted_batch;
641
641
encrypted_batch = nullptr ;
@@ -687,12 +687,12 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
687
687
688
688
// Need to completely rewrite the wallet file; if we don't, bdb might keep
689
689
// bits of the unencrypted private key in slack space in the database file.
690
- database-> Rewrite ();
690
+ GetDatabase (). Rewrite ();
691
691
692
692
// BDB seems to have a bad habit of writing old data into
693
693
// slack space in .dat files; that is bad if the old data is
694
694
// unencrypted private keys. So:
695
- database-> ReloadDbEnv ();
695
+ GetDatabase (). ReloadDbEnv ();
696
696
697
697
}
698
698
NotifyStatusChanged (this );
@@ -703,7 +703,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
703
703
DBErrors CWallet::ReorderTransactions ()
704
704
{
705
705
LOCK (cs_wallet);
706
- WalletBatch batch (*database );
706
+ WalletBatch batch (GetDatabase () );
707
707
708
708
// Old wallets didn't have any defined order for transactions
709
709
// Probably a bad idea to change the output of this
@@ -764,7 +764,7 @@ int64_t CWallet::IncOrderPosNext(WalletBatch* batch)
764
764
if (batch) {
765
765
batch->WriteOrderPosNext (nOrderPosNext);
766
766
} else {
767
- WalletBatch (*database ).WriteOrderPosNext (nOrderPosNext);
767
+ WalletBatch (GetDatabase () ).WriteOrderPosNext (nOrderPosNext);
768
768
}
769
769
return nRet;
770
770
}
@@ -794,7 +794,7 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
794
794
795
795
wtx.mapValue [" replaced_by_txid" ] = newHash.ToString ();
796
796
797
- WalletBatch batch (*database );
797
+ WalletBatch batch (GetDatabase () );
798
798
799
799
bool success = true ;
800
800
if (!batch.WriteTx (wtx)) {
@@ -866,7 +866,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const CWalletTx::Confirmatio
866
866
{
867
867
LOCK (cs_wallet);
868
868
869
- WalletBatch batch (*database , fFlushOnClose );
869
+ WalletBatch batch (GetDatabase () , fFlushOnClose );
870
870
871
871
uint256 hash = tx->GetHash ();
872
872
@@ -1065,7 +1065,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1065
1065
{
1066
1066
LOCK (cs_wallet);
1067
1067
1068
- WalletBatch batch (*database );
1068
+ WalletBatch batch (GetDatabase () );
1069
1069
1070
1070
std::set<uint256> todo;
1071
1071
std::set<uint256> done;
@@ -1128,7 +1128,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
1128
1128
return ;
1129
1129
1130
1130
// Do not flush the wallet here for performance reasons
1131
- WalletBatch batch (*database , false );
1131
+ WalletBatch batch (GetDatabase () , false );
1132
1132
1133
1133
std::set<uint256> todo;
1134
1134
std::set<uint256> done;
@@ -1466,13 +1466,13 @@ void CWallet::SetWalletFlag(uint64_t flags)
1466
1466
{
1467
1467
LOCK (cs_wallet);
1468
1468
m_wallet_flags |= flags;
1469
- if (!WalletBatch (*database ).WriteWalletFlags (m_wallet_flags))
1469
+ if (!WalletBatch (GetDatabase () ).WriteWalletFlags (m_wallet_flags))
1470
1470
throw std::runtime_error (std::string (__func__) + " : writing wallet flags failed" );
1471
1471
}
1472
1472
1473
1473
void CWallet::UnsetWalletFlag (uint64_t flag)
1474
1474
{
1475
- WalletBatch batch (*database );
1475
+ WalletBatch batch (GetDatabase () );
1476
1476
UnsetWalletFlagWithDB (batch, flag);
1477
1477
}
1478
1478
@@ -1511,7 +1511,7 @@ bool CWallet::AddWalletFlags(uint64_t flags)
1511
1511
LOCK (cs_wallet);
1512
1512
// We should never be writing unknown non-tolerable wallet flags
1513
1513
assert (((flags & KNOWN_WALLET_FLAGS) >> 32 ) == (flags >> 32 ));
1514
- if (!WalletBatch (*database ).WriteWalletFlags (flags)) {
1514
+ if (!WalletBatch (GetDatabase () ).WriteWalletFlags (flags)) {
1515
1515
throw std::runtime_error (std::string (__func__) + " : writing wallet flags failed" );
1516
1516
}
1517
1517
@@ -1602,7 +1602,7 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
1602
1602
return false ;
1603
1603
}
1604
1604
if (apply_label) {
1605
- WalletBatch batch (*database );
1605
+ WalletBatch batch (GetDatabase () );
1606
1606
for (const CScript& script : script_pub_keys) {
1607
1607
CTxDestination dest;
1608
1608
ExtractDestination (script, dest);
@@ -3193,10 +3193,10 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
3193
3193
LOCK (cs_wallet);
3194
3194
3195
3195
fFirstRunRet = false ;
3196
- DBErrors nLoadWalletRet = WalletBatch (*database ).LoadWallet (this );
3196
+ DBErrors nLoadWalletRet = WalletBatch (GetDatabase () ).LoadWallet (this );
3197
3197
if (nLoadWalletRet == DBErrors::NEED_REWRITE)
3198
3198
{
3199
- if (database-> Rewrite (" \x04 pool" ))
3199
+ if (GetDatabase (). Rewrite (" \x04 pool" ))
3200
3200
{
3201
3201
for (const auto & spk_man_pair : m_spk_managers) {
3202
3202
spk_man_pair.second ->RewriteDB ();
@@ -3220,7 +3220,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
3220
3220
DBErrors CWallet::ZapSelectTx (std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut)
3221
3221
{
3222
3222
AssertLockHeld (cs_wallet);
3223
- DBErrors nZapSelectTxRet = WalletBatch (*database ).ZapSelectTx (vHashIn, vHashOut);
3223
+ DBErrors nZapSelectTxRet = WalletBatch (GetDatabase () ).ZapSelectTx (vHashIn, vHashOut);
3224
3224
for (const uint256& hash : vHashOut) {
3225
3225
const auto & it = mapWallet.find (hash);
3226
3226
wtxOrdered.erase (it->second .m_it_wtxOrdered );
@@ -3232,7 +3232,7 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
3232
3232
3233
3233
if (nZapSelectTxRet == DBErrors::NEED_REWRITE)
3234
3234
{
3235
- if (database-> Rewrite (" \x04 pool" ))
3235
+ if (GetDatabase (). Rewrite (" \x04 pool" ))
3236
3236
{
3237
3237
for (const auto & spk_man_pair : m_spk_managers) {
3238
3238
spk_man_pair.second ->RewriteDB ();
@@ -3270,14 +3270,14 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
3270
3270
3271
3271
bool CWallet::SetAddressBook (const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
3272
3272
{
3273
- WalletBatch batch (*database );
3273
+ WalletBatch batch (GetDatabase () );
3274
3274
return SetAddressBookWithDB (batch, address, strName, strPurpose);
3275
3275
}
3276
3276
3277
3277
bool CWallet::DelAddressBook (const CTxDestination& address)
3278
3278
{
3279
3279
bool is_mine;
3280
- WalletBatch batch (*database );
3280
+ WalletBatch batch (GetDatabase () );
3281
3281
{
3282
3282
LOCK (cs_wallet);
3283
3283
// 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)
@@ -4024,7 +4024,7 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
4024
4024
int rescan_height = 0 ;
4025
4025
if (!gArgs .GetBoolArg (" -rescan" , false ))
4026
4026
{
4027
- WalletBatch batch (* walletInstance->database );
4027
+ WalletBatch batch (walletInstance->GetDatabase () );
4028
4028
CBlockLocator locator;
4029
4029
if (batch.ReadBestBlock (locator)) {
4030
4030
if (const Optional<int > fork_height = chain.findLocatorFork (locator)) {
@@ -4087,7 +4087,7 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
4087
4087
}
4088
4088
}
4089
4089
walletInstance->chainStateFlushed (chain.getTipLocator ());
4090
- walletInstance->database -> IncrementUpdateCounter ();
4090
+ walletInstance->GetDatabase (). IncrementUpdateCounter ();
4091
4091
}
4092
4092
4093
4093
{
@@ -4168,7 +4168,7 @@ void CWallet::postInitProcess()
4168
4168
4169
4169
bool CWallet::BackupWallet (const std::string& strDest) const
4170
4170
{
4171
- return database-> Backup (strDest);
4171
+ return GetDatabase (). Backup (strDest);
4172
4172
}
4173
4173
4174
4174
CKeyPool::CKeyPool ()
@@ -4471,7 +4471,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
4471
4471
4472
4472
void CWallet::AddActiveScriptPubKeyMan (uint256 id, OutputType type, bool internal)
4473
4473
{
4474
- WalletBatch batch (*database );
4474
+ WalletBatch batch (GetDatabase () );
4475
4475
if (!batch.WriteActiveScriptPubKeyMan (static_cast <uint8_t >(type), id, internal)) {
4476
4476
throw std::runtime_error (std::string (__func__) + " : writing active ScriptPubKeyMan id failed" );
4477
4477
}
0 commit comments