@@ -180,8 +180,6 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
180
180
if (HaveWatchOnly (script))
181
181
RemoveWatchOnly (script);
182
182
183
- if (!fFileBacked )
184
- return true ;
185
183
if (!IsCrypted ()) {
186
184
return CWalletDB (*dbw).WriteKey (pubkey,
187
185
secret.GetPrivKey (),
@@ -195,8 +193,6 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
195
193
{
196
194
if (!CCryptoKeyStore::AddCryptedKey (vchPubKey, vchCryptedSecret))
197
195
return false ;
198
- if (!fFileBacked )
199
- return true ;
200
196
{
201
197
LOCK (cs_wallet);
202
198
if (pwalletdbEncryption)
@@ -240,8 +236,6 @@ bool CWallet::AddCScript(const CScript& redeemScript)
240
236
{
241
237
if (!CCryptoKeyStore::AddCScript (redeemScript))
242
238
return false ;
243
- if (!fFileBacked )
244
- return true ;
245
239
return CWalletDB (*dbw).WriteCScript (Hash160 (redeemScript), redeemScript);
246
240
}
247
241
@@ -268,8 +262,6 @@ bool CWallet::AddWatchOnly(const CScript& dest)
268
262
const CKeyMetadata& meta = mapKeyMetadata[CScriptID (dest)];
269
263
UpdateTimeFirstKey (meta.nCreateTime );
270
264
NotifyWatchonlyChanged (true );
271
- if (!fFileBacked )
272
- return true ;
273
265
return CWalletDB (*dbw).WriteWatchOnly (dest, meta);
274
266
}
275
267
@@ -286,9 +278,8 @@ bool CWallet::RemoveWatchOnly(const CScript &dest)
286
278
return false ;
287
279
if (!HaveWatchOnly ())
288
280
NotifyWatchonlyChanged (false );
289
- if (fFileBacked )
290
- if (!CWalletDB (*dbw).EraseWatchOnly (dest))
291
- return false ;
281
+ if (!CWalletDB (*dbw).EraseWatchOnly (dest))
282
+ return false ;
292
283
293
284
return true ;
294
285
}
@@ -385,7 +376,6 @@ bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn,
385
376
if (nVersion > nWalletMaxVersion)
386
377
nWalletMaxVersion = nVersion;
387
378
388
- if (fFileBacked )
389
379
{
390
380
CWalletDB* pwalletdb = pwalletdbIn ? pwalletdbIn : new CWalletDB (*dbw);
391
381
if (nWalletVersion > 40000 )
@@ -594,24 +584,19 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
594
584
{
595
585
LOCK (cs_wallet);
596
586
mapMasterKeys[++nMasterKeyMaxID] = kMasterKey ;
597
- if (fFileBacked )
598
- {
599
- assert (!pwalletdbEncryption);
600
- pwalletdbEncryption = new CWalletDB (*dbw);
601
- if (!pwalletdbEncryption->TxnBegin ()) {
602
- delete pwalletdbEncryption;
603
- pwalletdbEncryption = NULL ;
604
- return false ;
605
- }
606
- pwalletdbEncryption->WriteMasterKey (nMasterKeyMaxID, kMasterKey );
587
+ assert (!pwalletdbEncryption);
588
+ pwalletdbEncryption = new CWalletDB (*dbw);
589
+ if (!pwalletdbEncryption->TxnBegin ()) {
590
+ delete pwalletdbEncryption;
591
+ pwalletdbEncryption = NULL ;
592
+ return false ;
607
593
}
594
+ pwalletdbEncryption->WriteMasterKey (nMasterKeyMaxID, kMasterKey );
608
595
609
596
if (!EncryptKeys (_vMasterKey))
610
597
{
611
- if (fFileBacked ) {
612
- pwalletdbEncryption->TxnAbort ();
613
- delete pwalletdbEncryption;
614
- }
598
+ pwalletdbEncryption->TxnAbort ();
599
+ delete pwalletdbEncryption;
615
600
// We now probably have half of our keys encrypted in memory, and half not...
616
601
// die and let the user reload the unencrypted wallet.
617
602
assert (false );
@@ -620,19 +605,16 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
620
605
// Encryption was introduced in version 0.4.0
621
606
SetMinVersion (FEATURE_WALLETCRYPT, pwalletdbEncryption, true );
622
607
623
- if (fFileBacked )
624
- {
625
- if (!pwalletdbEncryption->TxnCommit ()) {
626
- delete pwalletdbEncryption;
627
- // We now have keys encrypted in memory, but not on disk...
628
- // die to avoid confusion and let the user reload the unencrypted wallet.
629
- assert (false );
630
- }
631
-
608
+ if (!pwalletdbEncryption->TxnCommit ()) {
632
609
delete pwalletdbEncryption;
633
- pwalletdbEncryption = NULL ;
610
+ // We now have keys encrypted in memory, but not on disk...
611
+ // die to avoid confusion and let the user reload the unencrypted wallet.
612
+ assert (false );
634
613
}
635
614
615
+ delete pwalletdbEncryption;
616
+ pwalletdbEncryption = NULL ;
617
+
636
618
Lock ();
637
619
Unlock (strWalletPassphrase);
638
620
@@ -2816,8 +2798,6 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
2816
2798
2817
2799
DBErrors CWallet::LoadWallet (bool & fFirstRunRet )
2818
2800
{
2819
- if (!fFileBacked )
2820
- return DB_LOAD_OK;
2821
2801
fFirstRunRet = false ;
2822
2802
DBErrors nLoadWalletRet = CWalletDB (*dbw," cr+" ).LoadWallet (this );
2823
2803
if (nLoadWalletRet == DB_NEED_REWRITE)
@@ -2843,8 +2823,6 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
2843
2823
2844
2824
DBErrors CWallet::ZapSelectTx (std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut)
2845
2825
{
2846
- if (!fFileBacked )
2847
- return DB_LOAD_OK;
2848
2826
AssertLockHeld (cs_wallet); // mapWallet
2849
2827
vchDefaultKey = CPubKey ();
2850
2828
DBErrors nZapSelectTxRet = CWalletDB (*dbw," cr+" ).ZapSelectTx (vHashIn, vHashOut);
@@ -2873,8 +2851,6 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
2873
2851
2874
2852
DBErrors CWallet::ZapWalletTx (std::vector<CWalletTx>& vWtx)
2875
2853
{
2876
- if (!fFileBacked )
2877
- return DB_LOAD_OK;
2878
2854
vchDefaultKey = CPubKey ();
2879
2855
DBErrors nZapWalletTxRet = CWalletDB (*dbw," cr+" ).ZapWalletTx (vWtx);
2880
2856
if (nZapWalletTxRet == DB_NEED_REWRITE)
@@ -2909,8 +2885,6 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s
2909
2885
}
2910
2886
NotifyAddressBookChanged (this , address, strName, ::IsMine (*this , address) != ISMINE_NO,
2911
2887
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
2912
- if (!fFileBacked )
2913
- return false ;
2914
2888
if (!strPurpose.empty () && !CWalletDB (*dbw).WritePurpose (CBitcoinAddress (address).ToString (), strPurpose))
2915
2889
return false ;
2916
2890
return CWalletDB (*dbw).WriteName (CBitcoinAddress (address).ToString (), strName);
@@ -2921,33 +2895,25 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
2921
2895
{
2922
2896
LOCK (cs_wallet); // mapAddressBook
2923
2897
2924
- if (fFileBacked )
2898
+ // Delete destdata tuples associated with address
2899
+ std::string strAddress = CBitcoinAddress (address).ToString ();
2900
+ BOOST_FOREACH (const PAIRTYPE (std::string, std::string) &item, mapAddressBook[address].destdata )
2925
2901
{
2926
- // Delete destdata tuples associated with address
2927
- std::string strAddress = CBitcoinAddress (address).ToString ();
2928
- BOOST_FOREACH (const PAIRTYPE (std::string, std::string) &item, mapAddressBook[address].destdata )
2929
- {
2930
- CWalletDB (*dbw).EraseDestData (strAddress, item.first );
2931
- }
2902
+ CWalletDB (*dbw).EraseDestData (strAddress, item.first );
2932
2903
}
2933
2904
mapAddressBook.erase (address);
2934
2905
}
2935
2906
2936
2907
NotifyAddressBookChanged (this , address, " " , ::IsMine (*this , address) != ISMINE_NO, " " , CT_DELETED);
2937
2908
2938
- if (!fFileBacked )
2939
- return false ;
2940
2909
CWalletDB (*dbw).ErasePurpose (CBitcoinAddress (address).ToString ());
2941
2910
return CWalletDB (*dbw).EraseName (CBitcoinAddress (address).ToString ());
2942
2911
}
2943
2912
2944
2913
bool CWallet::SetDefaultKey (const CPubKey &vchPubKey)
2945
2914
{
2946
- if (fFileBacked )
2947
- {
2948
- if (!CWalletDB (*dbw).WriteDefaultKey (vchPubKey))
2949
- return false ;
2950
- }
2915
+ if (!CWalletDB (*dbw).WriteDefaultKey (vchPubKey))
2916
+ return false ;
2951
2917
vchDefaultKey = vchPubKey;
2952
2918
return true ;
2953
2919
}
@@ -3081,11 +3047,8 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool int
3081
3047
void CWallet::KeepKey (int64_t nIndex)
3082
3048
{
3083
3049
// Remove from key pool
3084
- if (fFileBacked )
3085
- {
3086
- CWalletDB walletdb (*dbw);
3087
- walletdb.ErasePool (nIndex);
3088
- }
3050
+ CWalletDB walletdb (*dbw);
3051
+ walletdb.ErasePool (nIndex);
3089
3052
LogPrintf (" keypool keep %d\n " , nIndex);
3090
3053
}
3091
3054
@@ -3597,17 +3560,13 @@ bool CWallet::AddDestData(const CTxDestination &dest, const std::string &key, co
3597
3560
return false ;
3598
3561
3599
3562
mapAddressBook[dest].destdata .insert (std::make_pair (key, value));
3600
- if (!fFileBacked )
3601
- return true ;
3602
3563
return CWalletDB (*dbw).WriteDestData (CBitcoinAddress (dest).ToString (), key, value);
3603
3564
}
3604
3565
3605
3566
bool CWallet::EraseDestData (const CTxDestination &dest, const std::string &key)
3606
3567
{
3607
3568
if (!mapAddressBook[dest].destdata .erase (key))
3608
3569
return false ;
3609
- if (!fFileBacked )
3610
- return true ;
3611
3570
return CWalletDB (*dbw).EraseDestData (CBitcoinAddress (dest).ToString (), key);
3612
3571
}
3613
3572
@@ -3979,8 +3938,6 @@ bool CWallet::ParameterInteraction()
3979
3938
3980
3939
bool CWallet::BackupWallet (const std::string& strDest)
3981
3940
{
3982
- if (!fFileBacked )
3983
- return false ;
3984
3941
return dbw->Backup (strDest);
3985
3942
}
3986
3943
0 commit comments